u02/tests: Fix floating point comparison
I didn’t really understand what WithinRel and WithinAbs do. Now I know that for this use case WithinAbs is the better choice. This also increases the allowed deviance for the average point of all points of a star, because this would now fail for larger values.
This commit is contained in:
parent
d4794e1544
commit
ad02a06db4
|
@ -17,7 +17,7 @@
|
|||
#include "sweep_line_tool.h"
|
||||
#include "util.h"
|
||||
|
||||
using Catch::Matchers::WithinRel;
|
||||
using Catch::Matchers::WithinAbs;
|
||||
|
||||
TEST_CASE("Transform Mirror") {
|
||||
// elementary operations
|
||||
|
@ -440,7 +440,7 @@ TEST_CASE("Barycentric coordinates (prop: Σ = 1)") {
|
|||
|
||||
// If all points are on a straight line, the property does not hold
|
||||
if (!(x0 == x1 && x1 == x2) && !(y0 == y1 && y1 == y2)) {
|
||||
REQUIRE_THAT(b1 + b2 + b3, WithinRel(1.0, 0.01));
|
||||
REQUIRE_THAT(b1 + b2 + b3, WithinAbs(1.0, 0.01));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,8 +580,8 @@ TEST_CASE("Star (prop: average of all points is centre)") {
|
|||
y += point.second;
|
||||
}
|
||||
|
||||
REQUIRE_THAT(x / points.size(), WithinRel(x0, 0.1));
|
||||
REQUIRE_THAT(y / points.size(), WithinRel(y0, 0.1));
|
||||
REQUIRE_THAT(x / points.size(), WithinAbs(x0, 0.5));
|
||||
REQUIRE_THAT(y / points.size(), WithinAbs(y0, 0.5));
|
||||
}
|
||||
|
||||
// The Haskell implementation of regular_polygon_mod has many more tests,
|
||||
|
|
Reference in a new issue