foundry_test_utils

Macro assert_data_eq

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][crate::filter] 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
  • "{...}" is a JSON value wildcard
  • "...": "{...}" is a JSON key-value wildcard
  • \ to /
  • Newlines

To limit this to newline normalization for text, call [Data::raw][crate::Data] 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"]);