Assert failure message easier to read

By having the left and right strings above and below on the same line it helps spot the difference between the two. E.g.

thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)`
left:  `"-aandb--S123.html"`
right: `"-aandb-S123.html"`',

When the strings are both on the same line it take a lot longer to spot the difference. It is a small change but the small time savings add up with repetition. This helps Rust be an excellent language to write tests in.
This commit is contained in:
Squirrel 2017-06-08 18:38:49 +01:00 committed by GitHub
parent ae3d3878ef
commit de8bbd2b16

View File

@ -116,8 +116,9 @@ macro_rules! assert_eq {
match (&$left, &$right) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)` \
(left: `{:?}`, right: `{:?}`)", left_val, right_val)
panic!(r#"assertion failed: `(left == right)`
left: `{:?}`
right: `{:?}`"#, left_val, right_val)
}
}
}
@ -126,8 +127,9 @@ macro_rules! assert_eq {
match (&($left), &($right)) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)` \
(left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
panic!(r#"assertion failed: `(left == right)`
left: `{:?}`
right: `{:?}`: {}"#, left_val, right_val,
format_args!($($arg)+))
}
}