catchorg / catchorg/Catch2

Custom output when RangeEquals fails

Open
#2,748 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**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)));
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.