From 3a33315ff8e047b1ff46b1ee2a5be3fdd7fbac08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 19 Mar 2020 13:32:45 +0100 Subject: [PATCH] Fix compilation error when lambdas are used in assertions This is a partial revert of b7b346c3e5603. --- include/internal/catch_capture.hpp | 2 +- include/internal/catch_compiler_capabilities.h | 2 -- .../SelfTest/Baselines/compact.sw.approved.txt | 1 + .../SelfTest/Baselines/console.std.approved.txt | 4 ++-- .../SelfTest/Baselines/console.sw.approved.txt | 15 +++++++++++++-- projects/SelfTest/Baselines/junit.sw.approved.txt | 3 ++- .../SelfTest/Baselines/sonarqube.sw.approved.txt | 1 + projects/SelfTest/Baselines/xml.sw.approved.txt | 15 +++++++++++++-- .../SelfTest/UsageTests/Compilation.tests.cpp | 3 +++ 9 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 482646e8..a65b3aec 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -51,7 +51,7 @@ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ INTERNAL_CATCH_REACT( catchAssertionHandler ) \ - } while( false ) + } while( (void)0, (false) && static_cast( !!(__VA_ARGS__) ) ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index 0ea76137..568e1ca0 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -140,8 +140,6 @@ # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)sizeof(__VA_ARGS__) - # if _MSC_VER >= 1900 // Visual Studio 2015 or newer # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS # endif diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index c61028a2..eef23b5a 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -764,6 +764,7 @@ Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hel Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" Condition.tests.cpp:: passed: data.str_hello.size() != 6 for: 5 != 6 +Compilation.tests.cpp:: passed: []() { return true; }() for: true Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index ba4f79d7..c0357adb 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1380,6 +1380,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 306 | 232 passed | 70 failed | 4 failed as expected -assertions: 1676 | 1524 passed | 131 failed | 21 failed as expected +test cases: 307 | 233 passed | 70 failed | 4 failed as expected +assertions: 1677 | 1525 passed | 131 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index e06366c4..1b0a8ce2 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -5729,6 +5729,17 @@ Condition.tests.cpp:: PASSED: with expansion: 5 != 6 +------------------------------------------------------------------------------- +Lambdas in assertions +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: PASSED: + REQUIRE( []() { return true; }() ) +with expansion: + true + ------------------------------------------------------------------------------- Less-than inequalities with different epsilons ------------------------------------------------------------------------------- @@ -13416,6 +13427,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 306 | 216 passed | 86 failed | 4 failed as expected -assertions: 1693 | 1524 passed | 148 failed | 21 failed as expected +test cases: 307 | 217 passed | 86 failed | 4 failed as expected +assertions: 1694 | 1525 passed | 148 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 6dd03a98..e8f7c09f 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -753,6 +753,7 @@ Condition.tests.cpp: + diff --git a/projects/SelfTest/Baselines/sonarqube.sw.approved.txt b/projects/SelfTest/Baselines/sonarqube.sw.approved.txt index 1f89e99c..2f11cf5b 100644 --- a/projects/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/projects/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -369,6 +369,7 @@ Class.tests.cpp: + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 4eed7125..cc90e0cb 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -7266,6 +7266,17 @@ Nor would this + + + + []() { return true; }() + + + true + + + + @@ -16037,7 +16048,7 @@ loose text artifact - + - + diff --git a/projects/SelfTest/UsageTests/Compilation.tests.cpp b/projects/SelfTest/UsageTests/Compilation.tests.cpp index d2ccce05..0baf2842 100644 --- a/projects/SelfTest/UsageTests/Compilation.tests.cpp +++ b/projects/SelfTest/UsageTests/Compilation.tests.cpp @@ -228,6 +228,9 @@ namespace { namespace CompilationTests { REQUIRE( 0 == y.v ); } + TEST_CASE("Lambdas in assertions") { + REQUIRE([]() { return true; }()); + } }} // namespace CompilationTests