matcher-like nan check
diff --git a/examples/all_features/assert_returns_disabled.cpp b/examples/all_features/assert_returns_disabled.cpp
index c181d1c..1ac65e2 100644
--- a/examples/all_features/assert_returns_disabled.cpp
+++ b/examples/all_features/assert_returns_disabled.cpp
@@ -24,8 +24,6 @@
if (TEST_FLIP ^ CHECK_NOTHROW([]{ }())) { TEST_FAIL(); }
if (CHECK_THROWS_WITH([] { throw 2; }(), "2")) { TEST_FAIL(); }
#endif
- if (CHECK_NAN(std::numeric_limits<float>::quiet_NaN())) { TEST_FAIL(); }
- if (CHECK_NOT_NAN(22.)) { TEST_FAIL(); }
return 0;
}();
diff --git a/examples/all_features/assertion_macros.cpp b/examples/all_features/assertion_macros.cpp
index cd03dd1..913c86a 100644
--- a/examples/all_features/assertion_macros.cpp
+++ b/examples/all_features/assertion_macros.cpp
@@ -210,8 +210,6 @@
if (CHECK_THROWS_AS(throw_if(true, 2), int)) { MESSAGE(":D"); }
if (CHECK_NOTHROW(throw_if(false, 2))) { MESSAGE(":D"); }
if (CHECK_THROWS_WITH(throw_if(true, 2), "2")) { MESSAGE(":D"); }
- if (CHECK_NAN(std::numeric_limits<float>::quiet_NaN())) { MESSAGE(":D"); }
- if (CHECK_NOT_NAN(22.)) { MESSAGE(":D"); }
}
TEST_CASE("check return values no print") {
@@ -221,15 +219,5 @@
if (CHECK_THROWS_AS(throw_if(true, 2), doctest::Approx)) { MESSAGE(":D"); }
if (CHECK_NOTHROW(throw_if(true, 2))) { MESSAGE(":D"); }
if (CHECK_THROWS_WITH(throw_if(true, 2), "1")) { MESSAGE(":D"); }
- if (CHECK_NAN(0.)) { MESSAGE(":D"); }
- // CHECK_NOT_NAN can't be checked because stringification is (partly) implementation defined
}
DOCTEST_MSVC_SUPPRESS_WARNING_POP
-
-TEST_CASE("nan") {
- REQUIRE_NOT_NAN(0.f);
- CHECK_NAN(std::numeric_limits<long double>::infinity());
- CHECK_NOT_NAN(0.);
- WARN_NOT_NAN(std::numeric_limits<float>::quiet_NaN());
- REQUIRE_NAN(std::numeric_limits<long double>::signaling_NaN());
-}
diff --git a/examples/all_features/asserts_used_outside_of_tests.cpp b/examples/all_features/asserts_used_outside_of_tests.cpp
index b427348..289c266 100644
--- a/examples/all_features/asserts_used_outside_of_tests.cpp
+++ b/examples/all_features/asserts_used_outside_of_tests.cpp
@@ -22,7 +22,6 @@
CHECK(false);
CHECK_THROWS(std::cout << "hello! \n");
- CHECK_NAN(0.);
}
// std::mutex g_mut;
diff --git a/examples/all_features/stringification.cpp b/examples/all_features/stringification.cpp
index 97e21e4..d26c5cc 100644
--- a/examples/all_features/stringification.cpp
+++ b/examples/all_features/stringification.cpp
@@ -146,6 +146,10 @@
CHECK_MESSAGE(s1 == s2, s1, " is not really ", s2);
}
+ CHECK(doctest::IsNaN(0.5));
+ CHECK(doctest::IsNaN(std::numeric_limits<float>::infinity()));
+ // can't test actual nan because it's implementation definedDOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4738)
+
// lets see if this exception gets translated
throw_if(true, bla1);
}
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index dbd8313..513939d 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -219,10 +219,6 @@
assertion_macros.cpp(0): MESSAGE: :D
-assertion_macros.cpp(0): MESSAGE: :D
-
-assertion_macros.cpp(0): MESSAGE: :D
-
===============================================================================
assertion_macros.cpp(0):
TEST CASE: check return values no print
@@ -250,21 +246,8 @@
assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2"
-assertion_macros.cpp(0): ERROR: CHECK_NAN( 0. ) is NOT correct!
- values: CHECK_NAN( 0.0 )
-
===============================================================================
-assertion_macros.cpp(0):
-TEST CASE: nan
-
-assertion_macros.cpp(0): ERROR: CHECK_NAN( std::numeric_limits<long double>::infinity() ) is NOT correct!
- values: CHECK_NAN( inf )
-
-assertion_macros.cpp(0): WARNING: WARN_NOT_NAN( std::numeric_limits<float>::quiet_NaN() ) is NOT correct!
- values: WARN_NOT_NAN( nanf )
-
-===============================================================================
-[doctest] test cases: 24 | 4 passed | 20 failed |
-[doctest] assertions: 99 | 49 passed | 50 failed |
+[doctest] test cases: 23 | 4 passed | 19 failed |
+[doctest] assertions: 92 | 44 passed | 48 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/assertion_macros.cpp_junit.txt b/examples/all_features/test_output/assertion_macros.cpp_junit.txt
index 966f923..bcc119c 100644
--- a/examples/all_features/test_output/assertion_macros.cpp_junit.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp_junit.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="all_features" errors="0" failures="64" tests="99">
+ <testsuite name="all_features" errors="0" failures="61" tests="92">
<testcase classname="assertion_macros.cpp" name="normal macros" status="run">
<failure type="CHECK">
assertion_macros.cpp(0):
@@ -369,26 +369,6 @@
CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2"
</failure>
- <failure message="0.0" type="CHECK_NAN">
-assertion_macros.cpp(0):
-CHECK_NAN( 0. ) is NOT correct!
- values: CHECK_NAN( 0.0 )
-
- </failure>
- </testcase>
- <testcase classname="assertion_macros.cpp" name="nan" status="run">
- <failure message="inf" type="CHECK_NAN">
-assertion_macros.cpp(0):
-CHECK_NAN( std::numeric_limits<long double>::infinity() ) is NOT correct!
- values: CHECK_NAN( inf )
-
- </failure>
- <failure message="nanf" type="WARN_NOT_NAN">
-assertion_macros.cpp(0):
-WARN_NOT_NAN( std::numeric_limits<float>::quiet_NaN() ) is NOT correct!
- values: WARN_NOT_NAN( nanf )
-
- </failure>
</testcase>
</testsuite>
</testsuites>
diff --git a/examples/all_features/test_output/assertion_macros.cpp_xml.txt b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
index c0bfcd9..28e1033 100644
--- a/examples/all_features/test_output/assertion_macros.cpp_xml.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
@@ -578,17 +578,7 @@
:D
</Text>
</Message>
- <Message type="WARNING" filename="assertion_macros.cpp" line="0">
- <Text>
- :D
- </Text>
- </Message>
- <Message type="WARNING" filename="assertion_macros.cpp" line="0">
- <Text>
- :D
- </Text>
- </Message>
- <OverallResultsAsserts successes="11" failures="0" test_case_success="true"/>
+ <OverallResultsAsserts successes="9" failures="0" test_case_success="true"/>
</TestCase>
<TestCase name="check return values no print" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="CHECK" filename="assertion_macros.cpp" line="0">
@@ -666,37 +656,10 @@
1
</ExpectedExceptionString>
</Expression>
- <Expression success="false" type="CHECK_NAN" filename="assertion_macros.cpp" line="0">
- <Original>
- 0.
- </Original>
- <Expanded>
- 0.0
- </Expanded>
- </Expression>
- <OverallResultsAsserts successes="0" failures="10" test_case_success="false"/>
- </TestCase>
- <TestCase name="nan" filename="assertion_macros.cpp" line="0">
- <Expression success="false" type="CHECK_NAN" filename="assertion_macros.cpp" line="0">
- <Original>
- std::numeric_limits<long double>::infinity()
- </Original>
- <Expanded>
- inf
- </Expanded>
- </Expression>
- <Expression success="false" type="WARN_NOT_NAN" filename="assertion_macros.cpp" line="0">
- <Original>
- std::numeric_limits<float>::quiet_NaN()
- </Original>
- <Expanded>
- nanf
- </Expanded>
- </Expression>
- <OverallResultsAsserts successes="3" failures="1" test_case_success="false"/>
+ <OverallResultsAsserts successes="0" failures="9" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="49" failures="50"/>
- <OverallResultsTestCases successes="4" failures="20"/>
+ <OverallResultsAsserts successes="44" failures="48"/>
+ <OverallResultsTestCases successes="4" failures="19"/>
</doctest>
Program code.
diff --git a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
index f2d8577..9c09060 100644
--- a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
+++ b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
@@ -14,5 +14,3 @@
values: CHECK( false )
hello!
asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed!
-asserts_used_outside_of_tests.cpp(25): ERROR: CHECK_NAN( 0. ) is NOT correct!
- values: CHECK_NAN( 0.0 )
diff --git a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt
index 0b9472b..5727760 100644
--- a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt
+++ b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt
@@ -13,5 +13,3 @@
values: CHECK( false )
hello!
asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed!
-asserts_used_outside_of_tests.cpp(25): ERROR: CHECK_NAN( 0. ) is NOT correct!
- values: CHECK_NAN( 0.0 )
diff --git a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt
index 935fda8..6490fb1 100644
--- a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt
+++ b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt
@@ -15,5 +15,3 @@
values: CHECK( false )
hello!
asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed!
-asserts_used_outside_of_tests.cpp(25): ERROR: CHECK_NAN( 0. ) is NOT correct!
- values: CHECK_NAN( 0.0 )
diff --git a/examples/all_features/test_output/filter_2.txt b/examples/all_features/test_output/filter_2.txt
index 8618276..662a7e2 100644
--- a/examples/all_features/test_output/filter_2.txt
+++ b/examples/all_features/test_output/filter_2.txt
@@ -1,6 +1,6 @@
[doctest] run with "--help" for options
===============================================================================
-[doctest] test cases: 0 | 0 passed | 0 failed | 97 skipped
+[doctest] test cases: 0 | 0 passed | 0 failed | 96 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_2_xml.txt b/examples/all_features/test_output/filter_2_xml.txt
index bb6bd65..8764a89 100644
--- a/examples/all_features/test_output/filter_2_xml.txt
+++ b/examples/all_features/test_output/filter_2_xml.txt
@@ -89,7 +89,6 @@
<TestCase name="namespace 7 member vs global" filename="namespace7.cpp" line="0" skipped="true"/>
<TestCase name="namespace 8 friend vs global" filename="namespace8.cpp" line="0" skipped="true"/>
<TestCase name="namespace 9 both global" filename="namespace9.cpp" line="0" skipped="true"/>
- <TestCase name="nan" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="no checks" filename="no_failures.cpp" line="0" skipped="true"/>
<TestCase name="normal macros" filename="assertion_macros.cpp" line="0" skipped="true"/>
</TestSuite>
@@ -137,6 +136,6 @@
<TestCase name="will end from an unknown exception" filename="coverage_maxout.cpp" line="0" skipped="true"/>
</TestSuite>
<OverallResultsAsserts successes="0" failures="0"/>
- <OverallResultsTestCases successes="0" failures="0" skipped="97"/>
+ <OverallResultsTestCases successes="0" failures="0" skipped="96"/>
</doctest>
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp.txt b/examples/all_features/test_output/stringification.cpp.txt
index bdc5c5a..6ecf351 100644
--- a/examples/all_features/test_output/stringification.cpp.txt
+++ b/examples/all_features/test_output/stringification.cpp.txt
@@ -27,6 +27,12 @@
logged: s1=MyOtherType: 42 s2=MyOtherType: 666
MyOtherType: 42 is not really MyOtherType: 666
+stringification.cpp(0): ERROR: CHECK( doctest::IsNaN(0.5) ) is NOT correct!
+ values: CHECK( 0.5 )
+
+stringification.cpp(0): ERROR: CHECK( doctest::IsNaN(std::numeric_limits<float>::infinity()) ) is NOT correct!
+ values: CHECK( inf )
+
stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited<int>(5, 4)
===============================================================================
@@ -37,6 +43,6 @@
===============================================================================
[doctest] test cases: 2 | 0 passed | 2 failed |
-[doctest] assertions: 7 | 0 passed | 7 failed |
+[doctest] assertions: 9 | 0 passed | 9 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp_junit.txt b/examples/all_features/test_output/stringification.cpp_junit.txt
index 608cab1..9feb7cc 100644
--- a/examples/all_features/test_output/stringification.cpp_junit.txt
+++ b/examples/all_features/test_output/stringification.cpp_junit.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="all_features" errors="2" failures="7" tests="7">
+ <testsuite name="all_features" errors="2" failures="9" tests="9">
<testcase classname="stringification.cpp" name="all asserts should fail and show how the objects get stringified" status="run">
<failure message="Foo{} == Foo{}" type="CHECK">
stringification.cpp(0):
@@ -47,6 +47,18 @@
MyOtherType: 42 is not really MyOtherType: 666
</failure>
+ <failure message="0.5" type="CHECK">
+stringification.cpp(0):
+CHECK( doctest::IsNaN(0.5) ) is NOT correct!
+ values: CHECK( 0.5 )
+
+ </failure>
+ <failure message="inf" type="CHECK">
+stringification.cpp(0):
+CHECK( doctest::IsNaN(std::numeric_limits<float>::infinity()) ) is NOT correct!
+ values: CHECK( inf )
+
+ </failure>
<error message="exception">
MyTypeInherited<int>(5, 4)
</error>
diff --git a/examples/all_features/test_output/stringification.cpp_xml.txt b/examples/all_features/test_output/stringification.cpp_xml.txt
index a3af67b..f167b7f 100644
--- a/examples/all_features/test_output/stringification.cpp_xml.txt
+++ b/examples/all_features/test_output/stringification.cpp_xml.txt
@@ -68,10 +68,26 @@
MyOtherType: 42 is not really MyOtherType: 666
</Info>
</Expression>
+ <Expression success="false" type="CHECK" filename="stringification.cpp" line="0">
+ <Original>
+ doctest::IsNaN(0.5)
+ </Original>
+ <Expanded>
+ 0.5
+ </Expanded>
+ </Expression>
+ <Expression success="false" type="CHECK" filename="stringification.cpp" line="0">
+ <Original>
+ doctest::IsNaN(std::numeric_limits<float>::infinity())
+ </Original>
+ <Expanded>
+ inf
+ </Expanded>
+ </Expression>
<Exception crash="false">
MyTypeInherited<int>(5, 4)
</Exception>
- <OverallResultsAsserts successes="0" failures="7" test_case_success="false"/>
+ <OverallResultsAsserts successes="0" failures="9" test_case_success="false"/>
</TestCase>
<TestCase name="a test case that registers an exception translator for int and then throws one" filename="stringification.cpp" line="0">
<Exception crash="false">
@@ -80,7 +96,7 @@
<OverallResultsAsserts successes="0" failures="0" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="0" failures="7"/>
+ <OverallResultsAsserts successes="0" failures="9"/>
<OverallResultsTestCases successes="0" failures="2"/>
</doctest>
Program code.