I tried using the assert_diff function to make some tests with long strings easier to debug. The problem with the function is the tests will fail and reference the line in the difference crate, not the tests where its used. This can be solved with a macro and makes using this function a lot more useful. This is my version of assert_diff!,
#[macro_export]
macro_rules! assert_diff {
($orig:expr , $edit:expr, $split: expr, $expected: expr) => ({
use difference::{diff, print_diff};
let orig = $orig;
let edit = $edit;
let (d, _) = diff(orig, edit, &($split));
if d != $expected {
print_diff(orig, edit, &($split));
panic!("assertion failed: edit distance between {:?} and {:?} is {} and not {}, see \
diffset above",
orig,
edit,
d,
&($expected))
}
})
}
I tried using the
assert_diff
function to make some tests with long strings easier to debug. The problem with the function is the tests will fail and reference the line in the difference crate, not the tests where its used. This can be solved with a macro and makes using this function a lot more useful. This is my version ofassert_diff!
,