Open newyorker123 opened 1 year ago
You can add header #include <catch2/matchers/catch_matchers_all.hpp> and add this below line to check in your code to assert the value. REQUIRE_THAT(vec1, Catch::Matchers::WithinAbs(vec2, 0.0001));
The documentation here: https://github.com/catchorg/Catch2/blob/devel/docs/matchers.md#floating-point-matchers. Might make sense to have an example there on that page as well. I will try and add that.
You will want something like this:
std::vector<float> some_vec{ 1.111, 2.222, 3.333 };
std::vector<float> to_compare{1.111, 2.222, 3.333};
REQUIRE_THAT(some_vec, Approx(to_compare).margin(0.0001));
See this #760 for more details.
Description RangeEquals works well on int vector. But how to compare two double vectors? I want to achieve the following effect:
Additional context I tried to use AllMatch. But i don't know how to pass the second vector element-wise to the matcher