trycmd icon indicating copy to clipboard operation
trycmd copied to clipboard

Incorrect `assert_data_eq` report

Open smoelius opened this issue 1 month ago • 4 comments

Recently, I ran into a failure like this:[^1]

fn main() {
    let actual = r#"    before_tokens: "["let", "(", "_", ",", "ref_count"]","#;
    let expected = r#"    before_tokens: "[..]","#;
    snapbox::assert_data_eq!(actual, expected);
}

From what I can tell, the problem is:

  • expected gets broken up into sections before_tokens: " and ",.
  • The latter appears in the middle of actual just after let.
  • When there are no more sections to process, line_matches returns false because remainder is not empty: https://github.com/assert-rs/snapbox/blob/90fd7f0c6d9e0d462bfcaa3a8df66a462a2be28a/crates/snapbox/src/filter/pattern.rs#L599

Does that sound about right?

If so, would you be open to a reimplementation of line_matches that uses regex Captures?

[^1]: Corrected per @Muscraft's comment: https://github.com/assert-rs/snapbox/issues/411#issuecomment-3539740339

smoelius avatar Nov 17 '25 01:11 smoelius