Macro snapbox::assert_data_eq

source ·
macro_rules! assert_data_eq {
    ($actual: expr, $expected: expr $(,)?) => { ... };
}
Expand description

Check if a value is the same as an expected value

By default filters are applied, including:

  • ... is a line-wildcard when on a line by itself
  • [..] is a character-wildcard when inside a line
  • [EXE] matches .exe on Windows
  • \ to /
  • Newlines

To limit this to newline normalization for text, call Data::raw on expected.

§Effective signature

fn assert_data_eq(actual: impl IntoData, expected: impl IntoData) {
    // ...
}

§Examples

let output = "something";
let expected = "so[..]g";
assert_data_eq!(output, expected);

Can combine this with file!

let actual = "something";
assert_data_eq!(actual, file!["output.txt"]);