Skip to content

Commit

Permalink
assert_eq_hex with extra string doesn't compile
Browse files Browse the repository at this point in the history
Fix #8, add the missing comma and fix the build. (And add a test!)
  • Loading branch information
hortont424 committed Sep 17, 2023
1 parent fba9dbd commit 796bbfd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ macro_rules! assert_eq_hex {
// noticeable slow down.
panic!(r#"assertion `left == right` failed: {}
left: {:#x?}
right: {:#x?}"#, format_args!($($arg)+) &*left_val, &*right_val)
right: {:#x?}"#, format_args!($($arg)+), &*left_val, &*right_val)
}
}
}
Expand Down Expand Up @@ -127,6 +127,14 @@ mod tests {
assert_eq_hex!(vec![0x00, 0x01, 0x02], vec![0x46, 0x50, 0x40]);
}

#[test]
#[should_panic(expected = r#"assertion `left == right` failed: yikes
left: 0xff
right: 0x0"#)]
fn test_eq_more() {
assert_eq_hex!(0xff, 0x00, "yikes");
}

#[test]
#[should_panic(expected = r#"assertion `left != right` failed
left: 0x50
Expand Down

0 comments on commit 796bbfd

Please sign in to comment.