Fix the hotfix:
commit a62f12a8a3ca3a36fdac8b8b0414cb6a0bed01f1
Author: Salvage <29021710+Saalvage@users.noreply.github.com>
Date: Wed Jan 12 02:08:14 2022 +0100
Fix throwing
commit 5f40d27903048037752d78af92876bffd2f82dcb
Author: Salvage <29021710+Saalvage@users.noreply.github.com>
Date: Wed Jan 12 01:51:17 2022 +0100
Suppress more warnings
commit 6082269701220995688f2d57a54e0dd864f795fa
Author: Salvage <29021710+Saalvage@users.noreply.github.com>
Date: Wed Jan 12 01:36:28 2022 +0100
Suppress warnings
commit 8c3dc33998bba9a65bfc626002e35cc7ee64c948
Author: Salvage <29021710+Saalvage@users.noreply.github.com>
Date: Wed Jan 12 01:18:54 2022 +0100
Fix various errors
diff --git a/examples/all_features/CMakeLists.txt b/examples/all_features/CMakeLists.txt
index 128676c..683443c 100644
--- a/examples/all_features/CMakeLists.txt
+++ b/examples/all_features/CMakeLists.txt
@@ -106,6 +106,17 @@
doctest_add_test_impl(NAME disabled_but_evaluated COMMAND $<TARGET_FILE:disabled_but_evaluated>)
+if(MSVC)
+ target_compile_options(disabled_but_evaluated PRIVATE /wd4702) # unreachable code
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_options(disabled_but_evaluated PRIVATE -Wno-global-constructors)
+ target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable)
+endif()
+
################################################################################
## VARIATION OF THE BUILD WITH DOCTEST DISABLED - SHOULD STILL COMPILE
################################################################################
diff --git a/examples/all_features/assert_returns_disabled.cpp b/examples/all_features/assert_returns_disabled.cpp
index b53be00..c181d1c 100644
--- a/examples/all_features/assert_returns_disabled.cpp
+++ b/examples/all_features/assert_returns_disabled.cpp
@@ -1,9 +1,6 @@
#include <doctest/doctest.h>
-#ifdef _MSC_VER
-#define __STDC_WANT_SECURE_LIB__ 1
-#endif
-#include <iostream>
+#include <cstdio>
#include <limits>
@@ -11,23 +8,24 @@
#define TEST_FLIP 0
#endif
-#define TEST_FAIL() std::cout << "FAILED ON: " << __LINE__ \
- << " (" << (TEST_FLIP ? "EVALUATED" : "DISABLED") << ")\n";
+#define TEST_FAIL() printf("FAILED ON: %d (%s)\n", \
+ __LINE__, TEST_FLIP ? "EVALUATED" : "DISABLED")
-static int test_disabled_var_ = [&] {
- (void)&test_disabled_var_;
+static int test_disabled_var_ = [] {
// none may return true
if (TEST_FLIP ^ CHECK(0 == 0)) { TEST_FAIL(); }
if (TEST_FLIP ^ CHECK_FALSE(0 != 0)) { TEST_FAIL(); }
if (TEST_FLIP ^ CHECK_EQ(0, 0)) { TEST_FAIL(); }
if (TEST_FLIP ^ CHECK_UNARY(true)) { TEST_FAIL(); }
if (TEST_FLIP ^ CHECK_UNARY_FALSE(false)) { TEST_FAIL(); }
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
if (TEST_FLIP ^ CHECK_THROWS([] { throw 2; }())) { TEST_FAIL(); }
if (TEST_FLIP ^ CHECK_THROWS_AS([] { throw 2; }(), int)) { TEST_FAIL(); }
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(2'2.)) { 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 6ad8287..cd03dd1 100644
--- a/examples/all_features/assertion_macros.cpp
+++ b/examples/all_features/assertion_macros.cpp
@@ -202,27 +202,29 @@
if (CHECK_UNARY_FALSE(a != b)) { MESSAGE(":D"); }
}
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4702)
TEST_CASE("check return values") {
comp(0, 0);
- if (CHECK_THROWS([] { throw 2; }())) { MESSAGE(":D"); }
- if (CHECK_THROWS_AS([] { throw 2; }(), int)) { MESSAGE(":D"); }
- if (CHECK_NOTHROW([] { }())) { MESSAGE(":D"); }
- if (CHECK_THROWS_WITH([] { throw 2; }(), "2")) { MESSAGE(":D"); }
+ if (CHECK_THROWS(throw_if(true, true))) { MESSAGE(":D"); }
+ 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(2'2.)) { MESSAGE(":D"); }
+ if (CHECK_NOT_NAN(22.)) { MESSAGE(":D"); }
}
TEST_CASE("check return values no print") {
comp(4, 2);
- if (CHECK_THROWS([] { }())) { MESSAGE(":D"); }
- if (CHECK_THROWS_AS([] { throw 2; }(), doctest::Approx)) { MESSAGE(":D"); }
- if (CHECK_NOTHROW([] { throw 2; }())) { MESSAGE(":D"); }
- if (CHECK_THROWS_WITH([] { throw 2; }(), "1")) { MESSAGE(":D"); }
+ if (CHECK_THROWS(throw_if(false, false))) { MESSAGE(":D"); }
+ 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"); }
- if (CHECK_NOT_NAN(std::numeric_limits<long double>::signaling_NaN())) { 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);
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index ecdad44..dbd8313 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -242,20 +242,17 @@
assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct!
values: CHECK_UNARY_FALSE( true )
-assertion_macros.cpp(0): ERROR: CHECK_THROWS( [] { }() ) did NOT throw at all!
+assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, false) ) did NOT throw at all!
-assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( [] { throw 2; }(), doctest::Approx ) threw a DIFFERENT exception: "2"
+assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2"
-assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( [] { throw 2; }() ) THREW exception: "2"
+assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2"
-assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( [] { throw 2; }(), "1" ) threw a DIFFERENT exception: "2"
+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): ERROR: CHECK_NOT_NAN( std::numeric_limits<long double>::signaling_NaN() ) is NOT correct!
- values: CHECK_NOT_NAN( nan )
-
===============================================================================
assertion_macros.cpp(0):
TEST CASE: nan
@@ -267,7 +264,7 @@
values: WARN_NOT_NAN( nanf )
===============================================================================
-[doctest] test cases: 24 | 4 passed | 20 failed |
-[doctest] assertions: 100 | 49 passed | 51 failed |
+[doctest] test cases: 24 | 4 passed | 20 failed |
+[doctest] assertions: 99 | 49 passed | 50 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 aba023d..966f923 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="65" tests="100">
+ <testsuite name="all_features" errors="0" failures="64" tests="99">
<testcase classname="assertion_macros.cpp" name="normal macros" status="run">
<failure type="CHECK">
assertion_macros.cpp(0):
@@ -351,22 +351,22 @@
</failure>
<failure type="CHECK_THROWS">
assertion_macros.cpp(0):
-CHECK_THROWS( [] { }() ) did NOT throw at all!
+CHECK_THROWS( throw_if(false, false) ) did NOT throw at all!
</failure>
<failure type="CHECK_THROWS_AS">
assertion_macros.cpp(0):
-CHECK_THROWS_AS( [] { throw 2; }(), doctest::Approx ) threw a DIFFERENT exception: "2"
+CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2"
</failure>
<failure type="CHECK_NOTHROW">
assertion_macros.cpp(0):
-CHECK_NOTHROW( [] { throw 2; }() ) THREW exception: "2"
+CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2"
</failure>
<failure type="CHECK_THROWS_WITH">
assertion_macros.cpp(0):
-CHECK_THROWS_WITH( [] { throw 2; }(), "1" ) threw a DIFFERENT exception: "2"
+CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2"
</failure>
<failure message="0.0" type="CHECK_NAN">
@@ -375,12 +375,6 @@
values: CHECK_NAN( 0.0 )
</failure>
- <failure message="nan" type="CHECK_NOT_NAN">
-assertion_macros.cpp(0):
-CHECK_NOT_NAN( std::numeric_limits<long double>::signaling_NaN() ) is NOT correct!
- values: CHECK_NOT_NAN( nan )
-
- </failure>
</testcase>
<testcase classname="assertion_macros.cpp" name="nan" status="run">
<failure message="inf" type="CHECK_NAN">
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 4878404..c0bfcd9 100644
--- a/examples/all_features/test_output/assertion_macros.cpp_xml.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
@@ -633,12 +633,12 @@
</Expression>
<Expression success="false" type="CHECK_THROWS" filename="assertion_macros.cpp" line="0">
<Original>
- [] { }()
+ throw_if(false, false)
</Original>
</Expression>
<Expression success="false" type="CHECK_THROWS_AS" filename="assertion_macros.cpp" line="0">
<Original>
- [] { throw 2; }()
+ throw_if(true, 2)
</Original>
<Exception>
"2"
@@ -649,7 +649,7 @@
</Expression>
<Expression success="false" type="CHECK_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
- [] { throw 2; }()
+ throw_if(true, 2)
</Original>
<Exception>
"2"
@@ -657,7 +657,7 @@
</Expression>
<Expression success="false" type="CHECK_THROWS_WITH" filename="assertion_macros.cpp" line="0">
<Original>
- [] { throw 2; }()
+ throw_if(true, 2)
</Original>
<Exception>
"2"
@@ -674,15 +674,7 @@
0.0
</Expanded>
</Expression>
- <Expression success="false" type="CHECK_NOT_NAN" filename="assertion_macros.cpp" line="0">
- <Original>
- std::numeric_limits<long double>::signaling_NaN()
- </Original>
- <Expanded>
- nan
- </Expanded>
- </Expression>
- <OverallResultsAsserts successes="0" failures="11" test_case_success="false"/>
+ <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">
@@ -704,7 +696,7 @@
<OverallResultsAsserts successes="3" failures="1" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="49" failures="51"/>
+ <OverallResultsAsserts successes="49" failures="50"/>
<OverallResultsTestCases successes="4" failures="20"/>
</doctest>
Program code.