Catch2
Catch2 copied to clipboard
Custom output when RangeEquals fails
Description I am comparing two arrays for point-wise equality and would like to have a simple custom error message. For instance, count of mismatched elements and a few first mismatches. How can this be achieved?
Additional context Currently I have the code below, and on error it dumps entire spans, and it's hard to see which elements do not match.
int n;
int* expected; // size [n]
int* result; // size [n]
REQUIRE_THAT(std::span(result, n), Catch::Matchers::RangeEquals(std::span(expected, n)));
I was asking myself exactly the same question ! More generally, it would be good if this where possible for a home made matcher to change the error message upon failure. Currently both match and describe are supposed to be const.