Comparing floating point containers without `Approx`
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
Before the move away from [`Approx`](https://catch2-temp.readthedocs.io/en/latest/comparing-floating-point-numbers.html#approx), the way of absolutely comparing two `std::vector` was to my understanding
```
std::vector sample, truth;
constexpr double delta = 1e-12;
CHECK_THAT(sample, Approx(truth).margin(delta));
```
using the `WithinAbs` comparison however, seems to require unrolling:
```
for (size_t i = 0; i < sample.size(); ++i)
{
CHECK_THAT(sample[i],
Catch::Matchers::WithinAbs(truth[i], delta));
}
```
or
```
CHECK_THAT(sample, Catch::Matchers::RangeEquals(truth, [](auto x, auto y){ return std::abs(x-y) < delta;}));
```
We're wanting to follow the deprecation guidance, and are moving away from `Approx`, but is there a recommended way of doing a floating point comparison on a container that I missed? Having a single check for a container was quite elegant.
Contributor guide
Assessment
This issue has not been assessed yet.