catchorg / catchorg/Catch2

How to compare two floating point vectors

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

Description

**Description**
RangeEquals works well on int vector. But how to compare two double vectors?
I want to achieve the following effect:
```
vector vec1;
vector vec2;
for e1 in vec1, e2 in vec2:
REQUIRE_THAT(e1, WithinABS(e2 , 0.0001))
```

**Additional context**
I tried to use AllMatch. But i don't know how to pass the second vector element-wise to the matcher
```
REQUIRE_THAT(vec1,AllMatch(WithinAbs(vec2 ???,0.0001)));
```

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.