Skip to content

Commit decff38

Browse files
committed
Use a more specific error assert
1 parent 6dae31a commit decff38

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/tests/rust_fmt_argument_max_padding.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,12 @@ fn test_format_specifiers_int_max_fail() {
233233
let fmt_str = format!("'%{width}{spec}'");
234234
// Use a very small buffer to force a write failure.
235235
let mut buf = [0u8; 100];
236-
let result = TimeFormatter::new(&time, fmt_str.as_bytes()).fmt(&mut &mut buf[..]);
236+
let err = TimeFormatter::new(&time, fmt_str.as_bytes())
237+
.fmt(&mut &mut buf[..])
238+
.unwrap_err();
237239
assert!(
238-
matches!(result, Err(Error::WriteZero)),
239-
"Expected an error for specifier '{spec}' with width {width} but got success",
240+
matches!(err, Error::WriteZero),
241+
"Expected write failure for specifier '{spec}' with width {width} but got unexpected error: {err:?}",
240242
);
241243
}
242244
}

0 commit comments

Comments
 (0)