Skip to main content

Crate philiprehberger_diff_assert

Crate philiprehberger_diff_assert 

Source
Expand description

§philiprehberger-diff-assert

Better test assertion diffs with colored inline comparisons.

Instead of the default assert_eq! output that dumps raw Debug representations, assert_eq_diff! shows a colored line-by-line diff so you can immediately see what changed.

§Quick start

use philiprehberger_diff_assert::assert_eq_diff;

let expected = "hello\nworld";
let actual = "hello\nworld";
assert_eq_diff!(expected, actual);

§Programmatic use

use philiprehberger_diff_assert::diff_strings;

let diff = diff_strings("a\nb\nc", "a\nx\nc");
// Returns a formatted diff string (with ANSI color codes)

§NO_COLOR support

If the NO_COLOR environment variable is set, all color output is suppressed automatically. You can also use diff_strings_no_color explicitly.

Macros§

assert_eq_diff
Asserts that two expressions are equal, showing a colored line-by-line diff on failure.

Functions§

diff_debug
Returns a formatted diff of two values using their Debug representations.
diff_strings
Returns a formatted line-by-line diff of two strings with ANSI color codes.
diff_strings_no_color
Returns a formatted line-by-line diff of two strings without ANSI color codes.