1#[macro_export]
11macro_rules! expect_eq {
12 ($expected:expr, $actual:expr $(,)?) => {
13 assert!(
14 $expected == $actual,
15 "assertion failed: `(expected == actual)`\nexpected: {:?}\n actual: {:?}",
16 $expected,
17 $actual
18 )
19 };
20}
21
22#[cfg(test)]
23#[allow(clippy::unwrap_used)] mod tests {
25 use crate::expect_eq;
26
27 #[test]
28 fn expect_eq() {
29 let panic = std::panic::catch_unwind(|| expect_eq!(2, 3)).unwrap_err();
30 let message = *panic.downcast::<String>().unwrap();
31 assert_eq!(
32 message,
33 "assertion failed: `(expected == actual)`\nexpected: 2\n actual: 3",
34 );
35 }
36}