Skip to content

Commit d27f166

Browse files
committed
Add error message for UTF-8 conversion
1 parent 505ea53 commit d27f166

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

googletest/src/matchers/is_encoded_string_matcher.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ where
8888
fn explain_match(&self, actual: &Self::ActualT) -> String {
8989
match String::from_utf8(actual.as_ref().to_vec()) {
9090
Ok(s) => format!("which is a UTF-8 encoded string {}", self.inner.explain_match(&s)),
91-
Err(_) => "which is not a UTF-8 encoded string".into(),
91+
Err(e) => format!("which is not a UTF-8 encoded string: {e}"),
9292
}
9393
}
9494
}
@@ -157,7 +157,7 @@ mod tests {
157157
fn has_correct_explanation_when_byte_array_is_not_utf8_encoded() -> Result<()> {
158158
let explanation = is_utf8_string(eq("A string")).explain_match(&&[192, 128, 0, 64]);
159159

160-
verify_that!(explanation, eq("which is not a UTF-8 encoded string"))
160+
verify_that!(explanation, starts_with("which is not a UTF-8 encoded string: "))
161161
}
162162

163163
#[test]

0 commit comments

Comments
 (0)