Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/onqtam/doctest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan <29021710+Saalvage@users.noreply.github.com>2022-01-11 21:35:14 +0300
committerGitHub <noreply@github.com>2022-01-11 21:35:14 +0300
commit8acee4fa084d3e16b08a6c9bb5c37340cb7fcbb6 (patch)
tree768dc1715058fef7d5ce3792b71f7cb7f54c83f7 /examples
parent23d3e5d75d9e37188d489f7dd44dbe096cb6c06e (diff)
Nan check (#582)
* CHECK_NAN (Resolves #105) * Fix helper macro * Include correct test header * Move definitions to cpp file * Extern declaration and exception fix * Fix more warnings * Warning suppression * Add NaN checking docs * Improved wording
Diffstat (limited to 'examples')
-rw-r--r--examples/all_features/assertion_macros.cpp10
-rw-r--r--examples/all_features/asserts_used_outside_of_tests.cpp1
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp.txt14
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp_junit.txt16
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp_xml.txt23
-rw-r--r--examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt2
-rw-r--r--examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt2
-rw-r--r--examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt2
-rw-r--r--examples/all_features/test_output/filter_2.txt2
-rw-r--r--examples/all_features/test_output/filter_2_xml.txt3
10 files changed, 68 insertions, 7 deletions
diff --git a/examples/all_features/assertion_macros.cpp b/examples/all_features/assertion_macros.cpp
index d2f0ada5..8dcebb94 100644
--- a/examples/all_features/assertion_macros.cpp
+++ b/examples/all_features/assertion_macros.cpp
@@ -4,6 +4,8 @@
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
#include <stdexcept>
+#include <cmath>
+#include <limits>
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
TEST_CASE("normal macros") {
@@ -204,3 +206,11 @@ TEST_CASE("macro return values") {
if (CHECK_THROWS([]{}())) { MESSAGE("should not be reached!"); }
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 289c2666..b4273481 100644
--- a/examples/all_features/asserts_used_outside_of_tests.cpp
+++ b/examples/all_features/asserts_used_outside_of_tests.cpp
@@ -22,6 +22,7 @@ static void some_func() {
CHECK(false);
CHECK_THROWS(std::cout << "hello! \n");
+ CHECK_NAN(0.);
}
// std::mutex g_mut;
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index e3773969..03660105 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -219,7 +219,17 @@ assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct!
assertion_macros.cpp(0): ERROR: CHECK_THROWS( []{}() ) did NOT throw at all!
===============================================================================
-[doctest] test cases: 22 | 3 passed | 19 failed |
-[doctest] assertions: 80 | 35 passed | 45 failed |
+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: 23 | 3 passed | 20 failed |
+[doctest] assertions: 84 | 38 passed | 46 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 d9a23f0d..904841df 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="58" tests="80">
+ <testsuite name="all_features" errors="0" failures="60" tests="84">
<testcase classname="assertion_macros.cpp" name="normal macros" status="run">
<failure type="CHECK">
assertion_macros.cpp(0):
@@ -354,6 +354,20 @@ CHECK_THROWS( []{}() ) did NOT throw at all!
</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&lt;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&lt;float>::quiet_NaN() ) is NOT correct!
+ values: WARN_NOT_NAN( nanf )
+
+ </failure>
+ </testcase>
</testsuite>
</testsuites>
Program code.
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 7b64f0df..65245d91 100644
--- a/examples/all_features/test_output/assertion_macros.cpp_xml.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
@@ -580,8 +580,27 @@
</Expression>
<OverallResultsAsserts successes="0" failures="6" 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&lt;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&lt;float>::quiet_NaN()
+ </Original>
+ <Expanded>
+ nanf
+ </Expanded>
+ </Expression>
+ <OverallResultsAsserts successes="3" failures="1" test_case_success="false"/>
+ </TestCase>
</TestSuite>
- <OverallResultsAsserts successes="35" failures="45"/>
- <OverallResultsTestCases successes="3" failures="19"/>
+ <OverallResultsAsserts successes="38" failures="46"/>
+ <OverallResultsTestCases successes="3" failures="20"/>
</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 9c090606..f2d85771 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,3 +14,5 @@ asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct!
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 5727760e..0b9472b0 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,3 +13,5 @@ asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct!
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 6490fb18..935fda8b 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,3 +15,5 @@ asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct!
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 d4b108f0..662a7e29 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 | 95 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 90a28249..57a62a05 100644
--- a/examples/all_features/test_output/filter_2_xml.txt
+++ b/examples/all_features/test_output/filter_2_xml.txt
@@ -88,6 +88,7 @@
<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>
@@ -135,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="95"/>
+ <OverallResultsTestCases successes="0" failures="0" skipped="96"/>
</doctest>
Program code.