diff options
| author | Martin Hořeňovský | 2023-02-26 00:14:32 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-02-26 00:14:32 +0100 |
| commit | 6fbb3f07235311d0c228b17b52406343a7aed8f2 (patch) | |
| tree | 9c1d0397f24cef4b8db3b27e85beea113ec8773a /tests/SelfTest/UsageTests | |
| parent | 9ff3cde87b1d8c61d2d97c34bdc71f0ec0a34a9c (diff) | |
| download | catch3-6fbb3f07235311d0c228b17b52406343a7aed8f2.tar.gz | |
Add IsNaN matcher
Diffstat (limited to 'tests/SelfTest/UsageTests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Matchers.tests.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index b2239572..49e25232 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -497,6 +497,9 @@ TEST_CASE( "Floating point matchers: float", "[matchers][floating-point]" ) { REQUIRE_THROWS_AS( WithinRel( 1.f, -0.2f ), std::domain_error ); REQUIRE_THROWS_AS( WithinRel( 1.f, 1.f ), std::domain_error ); } + SECTION( "IsNaN" ) { + REQUIRE_THAT( 1., !IsNaN() ); + } } TEST_CASE( "Floating point matchers: double", "[matchers][floating-point]" ) { @@ -552,6 +555,9 @@ TEST_CASE( "Floating point matchers: double", "[matchers][floating-point]" ) { REQUIRE_THROWS_AS( WithinRel( 1., -0.2 ), std::domain_error ); REQUIRE_THROWS_AS( WithinRel( 1., 1. ), std::domain_error ); } + SECTION("IsNaN") { + REQUIRE_THAT( 1., !IsNaN() ); + } } TEST_CASE( "Floating point matchers that are problematic in approvals", @@ -566,6 +572,8 @@ TEST_CASE( "Floating point matchers that are problematic in approvals", REQUIRE_THAT( NAN, !WithinRel( NAN ) ); REQUIRE_THAT( 1., !WithinRel( NAN ) ); REQUIRE_THAT( NAN, !WithinRel( 1. ) ); + REQUIRE_THAT( NAN, IsNaN() ); + REQUIRE_THAT( static_cast<double>(NAN), IsNaN() ); } TEST_CASE( "Arbitrary predicate matcher", "[matchers][generic]" ) { |