Crate similar_asserts[−][src]
similar-asserts
is a crate that enhances the default assertion
experience by using similar for diffing.
On failed assertions it renders out a colorized diff to the terminal.
It comes with a handful of macros to replace std::assert_eq!
with:
assert_eq!
: diffsDebug
on assertion failure.assert_serde_eq!
: diffsSerialize
on assertion failure.assert_str_eq!
: compares both sides to strings and diffs those on failure.
Usage
use similar_asserts::assert_eq; assert_eq!((1..3).collect::<Vec<_>>(), vec![1, 2]);
Optionally the assertion macros also let you “name” the left and right side which will produce slightly more explicit output:
use similar_asserts::assert_eq; assert_eq!(expected: vec![1, 2], actual: (1..3).collect::<Vec<_>>());
Feature Flags
unicode
enable improved character matching (enabled by default)serde
turns on support for serde.
Macros
assert_eq | Asserts that two expressions are equal to each other (using |
assert_serde_eq | Asserts that two expressions are equal to each other (using |
assert_str_eq | Asserts that two stringified expressions are equal to each other
(using |