assertor icon indicating copy to clipboard operation
assertor copied to clipboard

Better diff representation using bold / color

Open cocuh opened this issue 2 years ago • 0 comments

Adding the semantics of swap, insertion or deletion.

This feature should be able to be turned on/off by feature.

Example 1:

assert_that!(vec![1,4,3,2]).contains_exactly_in_order(vec![1,2,3,4]);

Idea of better message:

contents match, but order was wrong
---
expected: [1, 2, 3, 4]
actual  : [1, <bold>4</bold>, 3, <bold>2</bold>]

Example 2:

assert_that!(vec![1, 3, 4, 5]).contains_exactly_in_order(vec![1,2,3,4]);

Idea of better message:

contents match, but order was wrong
---
expected: [1, <green>2</green>, 3, 4]
actual  : [1,<space/>           3, 4, <red>5</red>]

Color usage guideline: Green should emphasize the normal case, and red should emphasize the unexpected case, imo.

Estimation/design: This needs quite big structural change in Fact struct. Specifically, more semantic structs may need to be defined to represent added or deleted object, because generating Fact should be decoupled from formatting in order to change the formatting logic in runtime.

cocuh avatar Jun 10 '23 12:06 cocuh