Skip to content

Commit fadf06a

Browse files
authored
fix: vector-approx macro (#840)
1 parent 89b0b56 commit fadf06a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

exercises/concept/lasagna-master/lasagna_master_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
#include "test/catch.hpp"
66
#endif
77

8+
#include <cmath>
9+
810
using namespace lasagna_master;
911

1012
// As long as we have catch2 v2 and v3 in parallel, we can't use either
1113
// of their comparison marcors for floating point comparisons.
1214
#define REQUIRE_VECTOR_APROX_EQUAL(vec1, vec2, margin) \
1315
REQUIRE(vec1.size() == vec2.size()); \
1416
for (size_t i = 0; i < vec1.size(); i++) { \
15-
REQUIRE( vec1.at(i) - vec2.at(i) < margin); \
17+
REQUIRE( std::abs(vec1.at(i) - vec2.at(i)) < margin); \
1618
}
1719

1820
TEST_CASE("preparationTime: Preparation time for many layers with custom average time", "[task_1]") {

0 commit comments

Comments
 (0)