Fix test that fails on Clang due to float compares

These results were failing because of trying to do exact floating point
equality on computed values.
This commit is contained in:
Jakob Botsch Nielsen 2018-06-16 01:35:21 +02:00 committed by Jakob Botsch Nielsen
parent 6e36a351c2
commit b39e967e4f

View File

@ -16,18 +16,18 @@ TEST_CASE("dtRandomPointInConvexPoly")
float out[3];
dtRandomPointInConvexPoly(pts, npts, areas, 0.0f, 1.0f, out);
REQUIRE(out[0] == 0);
REQUIRE(out[1] == 0);
REQUIRE(out[2] == 1);
REQUIRE(out[0] == Approx(0));
REQUIRE(out[1] == Approx(0));
REQUIRE(out[2] == Approx(1));
dtRandomPointInConvexPoly(pts, npts, areas, 0.5f, 1.0f, out);
REQUIRE(out[0] == 1.0f / 2);
REQUIRE(out[1] == 0);
REQUIRE(out[2] == 1.0f / 2);
REQUIRE(out[0] == Approx(1.0f / 2));
REQUIRE(out[1] == Approx(0));
REQUIRE(out[2] == Approx(1.0f / 2));
dtRandomPointInConvexPoly(pts, npts, areas, 1.0f, 1.0f, out);
REQUIRE(out[0] == 1);
REQUIRE(out[1] == 0);
REQUIRE(out[2] == 0);
REQUIRE(out[0] == Approx(1));
REQUIRE(out[1] == Approx(0));
REQUIRE(out[2] == Approx(0));
}
}