Fix bug in WithinAbs::match() and add tests for it

This commit is contained in:
jsc
2018-03-19 20:36:07 +01:00
committed by Martin Hořeňovský
parent 6c99b04c87
commit 8b78087412
7 changed files with 138 additions and 8 deletions

View File

@@ -321,6 +321,11 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(0.f, WithinAbs(-0.f, 0));
REQUIRE_THAT(NAN, !WithinAbs(NAN, 0));
REQUIRE_THAT(11.f, !WithinAbs(10.f, 0.5f));
REQUIRE_THAT(10.f, !WithinAbs(11.f, 0.5f));
REQUIRE_THAT(-10.f, WithinAbs(-10.f, 0.5f));
REQUIRE_THAT(-10.f, WithinAbs(-9.6f, 0.5f));
}
SECTION("ULPs") {
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
@@ -358,6 +363,11 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(0., !WithinAbs(1., 0.99));
REQUIRE_THAT(NAN, !WithinAbs(NAN, 0));
REQUIRE_THAT(11., !WithinAbs(10., 0.5));
REQUIRE_THAT(10., !WithinAbs(11., 0.5));
REQUIRE_THAT(-10., WithinAbs(-10., 0.5));
REQUIRE_THAT(-10., WithinAbs(-9.6, 0.5));
}
SECTION("ULPs") {
REQUIRE_THAT(1., WithinULP(1., 0));