2019-01-11 09:03:00 -05:00
|
|
|
/// Like assert_eq, but nicer output for long strings.
|
2018-04-29 09:29:52 -04:00
|
|
|
#[cfg(test)]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! assert_eq_printed {
|
|
|
|
($expected:expr, $got:expr, $($tt:tt)*) => {
|
|
|
|
let expected = &*$expected;
|
|
|
|
let got = &*$got;
|
|
|
|
let label = format!($($tt)*);
|
|
|
|
if expected != got {
|
|
|
|
panic!("
|
|
|
|
printed outputs differ! (label: {})
|
|
|
|
|
|
|
|
expected:
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
{}
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
got:
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
{}
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
", label, expected, got);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|