Skip to content

Commit a117964

Browse files
committed
More robust error message check
1 parent 5d60010 commit a117964

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,12 @@ mod test {
11231123
try!(::std::str::from_utf8(s).context(p));
11241124
Ok(())
11251125
}
1126-
assert_eq!(format!("{}", parse_utf(b"a\x80\x80", "/etc").unwrap_err()),
1127-
"Path error at \"/etc\": invalid utf-8: \
1128-
invalid byte near index 1");
1129-
assert_eq!(format!("{}", parse_utf(b"\x80\x80",
1130-
PathBuf::from("/tmp")).unwrap_err()),
1131-
"Path error at \"/tmp\": invalid utf-8: \
1132-
invalid byte near index 0");
1126+
let etext = parse_utf(b"a\x80\x80", "/etc").unwrap_err().to_string();
1127+
assert!(etext.starts_with(
1128+
"Path error at \"/etc\": invalid utf-8: invalid "));
1129+
let etext = parse_utf(b"\x80\x80", PathBuf::from("/tmp")).unwrap_err()
1130+
.to_string();
1131+
assert!(etext.starts_with(
1132+
"Path error at \"/tmp\": invalid utf-8: invalid "));
11331133
}
11341134
}

0 commit comments

Comments
 (0)