#string #comparison #testing #diff #assert-eq #macro #wrapper

str_assert

Thin wrapper around stdlib assert_eq macros using dissimilar as the comparison. (Only for strings)

2 unstable releases

0.2.0 May 26, 2024
0.1.0 May 26, 2024

#1591 in Rust patterns

39 downloads per month

Apache-2.0

7KB
72 lines

str_assert

Ideal for figuring out what part of a large string is causing tests to fail.

Thin wrapper around the stdlib assert_eq and assert_ne but using dissimilar for comparison

For example

#[test]
fn has_diff() {
    str_assert_eq!("Lorem ipsum doleret", "Lorem ipsum dolert", "Error");
}

Will panic with the message

assertion failed: `(left == right)`
  diff: [
    Equal("Lorem ipsum doler"),
    Delete("e"),
    Equal("t"),
]: Error

Dependencies

~70KB