Skip to content

Commit

Permalink
Add some more panic message testing
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Sep 15, 2022
1 parent 364ac56 commit 05cb04f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/std/src/testing/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ mod tests {

#[test]
#[should_panic(
expected = "assertion failed: `(left ≈ right)`\nleft: 17\nright: 20\nrelative difference: 0.15\nmax allowed relative difference: 0.12\n: some extra info about the error"
expected = "assertion failed: `(left ≈ right)`\nleft: 17\nright: 20\nrelative difference: 0.15\nmax allowed relative difference: 0.12\n: some extra info about the error: Foo(8)"
)]
fn assert_approx_with_custom_panic_msg() {
let adjective = "extra";
#[derive(Debug)]
struct Foo(u32);
assert_approx_eq!(
17_u32,
20_u32,
"0.12",
"some extra {} about the error",
"info"
"some {adjective} {} about the error: {:?}",
"info",
Foo(8),
);
}
}

0 comments on commit 05cb04f

Please sign in to comment.