Add constructor arg checking to WithinAbsMatcher

Also tests :-)
This commit is contained in:
Martin Hořeňovský
2017-12-06 15:37:13 +01:00
parent d19b7292b3
commit 0c122c135d
6 changed files with 143 additions and 7 deletions

View File

@@ -298,6 +298,13 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)));
}
SECTION("Constructor validation") {
REQUIRE_NOTHROW(WithinAbs(1.f, 0.f));
REQUIRE_THROWS_AS(WithinAbs(1.f, -1.f), std::domain_error);
REQUIRE_NOTHROW(WithinULP(1.f, 0));
REQUIRE_THROWS_AS(WithinULP(1.f, -1), std::domain_error);
}
}
TEST_CASE("Floating point matchers: double", "[matchers][floating-point]") {
@@ -328,6 +335,13 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)));
}
SECTION("Constructor validation") {
REQUIRE_NOTHROW(WithinAbs(1., 0.));
REQUIRE_THROWS_AS(WithinAbs(1., -1.), std::domain_error);
REQUIRE_NOTHROW(WithinULP(1., 0));
REQUIRE_THROWS_AS(WithinULP(1., -1), std::domain_error);
}
}
} } // namespace MatchersTests