Description
The following code:
snapbox::assert_eq("foo", "bar");
results in:
--- Expected
+++ Actual
1 - foo∅
1 + bar∅
which funnily enough is rather unexpected. When writing comparisons in code it is common practice to put constants on the right side of the operator e.g:
if self.length == 0 {
rather than:
if 0 == self.length {
And even though std::assert_eq
does not document any convention and also just speaks of left
and right
in its panic messages, the vast majority of Rust code uses the same convention of putting the expected value last (e.g. assert_eq!(self.length, 0)
instead of assert_eq!(0, self.length)
.
The non-file-based methods of snapbox however use the opposite order ... which matters because snapbox (contrary to std, pretty_assertions and similar-asserts does label its diff with expected/actual instead of just left/right).
Note that I think attempting to label actual/expected for non-file based methods is a good idea ... it's just that I think not breaking the user expectation is more important than anything else. We could still achieve both labeling and adhering to user expectations but it would require a breaking change.