mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Fix compilation error when lambdas are used in assertions
This is a partial revert of b7b346c3e5.
			
			
This commit is contained in:
		| @@ -51,7 +51,7 @@ | |||||||
|             CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |             CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ | ||||||
|         } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ |         } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ | ||||||
|         INTERNAL_CATCH_REACT( catchAssertionHandler ) \ |         INTERNAL_CATCH_REACT( catchAssertionHandler ) \ | ||||||
|     } while( false ) |     } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ | #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ | ||||||
|   | |||||||
| @@ -140,8 +140,6 @@ | |||||||
| #  define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) | #  define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) | ||||||
| #  define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  __pragma( warning(pop) ) | #  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 | #  if _MSC_VER >= 1900 // Visual Studio 2015 or newer | ||||||
| #    define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS | #    define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS | ||||||
| #  endif | #  endif | ||||||
|   | |||||||
| @@ -764,6 +764,7 @@ Condition.tests.cpp:<line number>: passed: data.str_hello != "goodbye" for: "hel | |||||||
| Condition.tests.cpp:<line number>: passed: data.str_hello != "hell" for: "hello" != "hell" | Condition.tests.cpp:<line number>: passed: data.str_hello != "hell" for: "hello" != "hell" | ||||||
| Condition.tests.cpp:<line number>: passed: data.str_hello != "hello1" for: "hello" != "hello1" | Condition.tests.cpp:<line number>: passed: data.str_hello != "hello1" for: "hello" != "hello1" | ||||||
| Condition.tests.cpp:<line number>: passed: data.str_hello.size() != 6 for: 5 != 6 | Condition.tests.cpp:<line number>: passed: data.str_hello.size() != 6 for: 5 != 6 | ||||||
|  | Compilation.tests.cpp:<line number>: passed: []() { return true; }() for: true | ||||||
| Approx.tests.cpp:<line number>: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) | Approx.tests.cpp:<line number>: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) | ||||||
| Approx.tests.cpp:<line number>: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) | Approx.tests.cpp:<line number>: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) | ||||||
| Approx.tests.cpp:<line number>: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) | Approx.tests.cpp:<line number>: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) | ||||||
|   | |||||||
| @@ -1380,6 +1380,6 @@ due to unexpected exception with message: | |||||||
|   Why would you throw a std::string? |   Why would you throw a std::string? | ||||||
|  |  | ||||||
| =============================================================================== | =============================================================================== | ||||||
| test cases:  306 |  232 passed |  70 failed |  4 failed as expected | test cases:  307 |  233 passed |  70 failed |  4 failed as expected | ||||||
| assertions: 1676 | 1524 passed | 131 failed | 21 failed as expected | assertions: 1677 | 1525 passed | 131 failed | 21 failed as expected | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5729,6 +5729,17 @@ Condition.tests.cpp:<line number>: PASSED: | |||||||
| with expansion: | with expansion: | ||||||
|   5 != 6 |   5 != 6 | ||||||
|  |  | ||||||
|  | ------------------------------------------------------------------------------- | ||||||
|  | Lambdas in assertions | ||||||
|  | ------------------------------------------------------------------------------- | ||||||
|  | Compilation.tests.cpp:<line number> | ||||||
|  | ............................................................................... | ||||||
|  |  | ||||||
|  | Compilation.tests.cpp:<line number>: PASSED: | ||||||
|  |   REQUIRE( []() { return true; }() ) | ||||||
|  | with expansion: | ||||||
|  |   true | ||||||
|  |  | ||||||
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||||||
| Less-than inequalities with different epsilons | Less-than inequalities with different epsilons | ||||||
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||||||
| @@ -13416,6 +13427,6 @@ Misc.tests.cpp:<line number> | |||||||
| Misc.tests.cpp:<line number>: PASSED: | Misc.tests.cpp:<line number>: PASSED: | ||||||
|  |  | ||||||
| =============================================================================== | =============================================================================== | ||||||
| test cases:  306 |  216 passed |  86 failed |  4 failed as expected | test cases:  307 |  217 passed |  86 failed |  4 failed as expected | ||||||
| assertions: 1693 | 1524 passed | 148 failed | 21 failed as expected | assertions: 1694 | 1525 passed | 148 failed | 21 failed as expected | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <testsuitesloose text artifact | <testsuitesloose text artifact | ||||||
| > | > | ||||||
|   <testsuite name="<exe-name>" errors="17" failures="132" tests="1694" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> |   <testsuite name="<exe-name>" errors="17" failures="132" tests="1695" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||||
|     <properties> |     <properties> | ||||||
|       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> |       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> | ||||||
|       <property name="random-seed" value="1"/> |       <property name="random-seed" value="1"/> | ||||||
| @@ -753,6 +753,7 @@ Condition.tests.cpp:<line number> | |||||||
|       </failure> |       </failure> | ||||||
|     </testcase> |     </testcase> | ||||||
|     <testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/> |     <testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/> | ||||||
|  |     <testcase classname="<exe-name>.global" name="Lambdas in assertions" time="{duration}"/> | ||||||
|     <testcase classname="<exe-name>.global" name="Less-than inequalities with different epsilons" time="{duration}"/> |     <testcase classname="<exe-name>.global" name="Less-than inequalities with different epsilons" time="{duration}"/> | ||||||
|     <testcase classname="<exe-name>.global" name="ManuallyRegistered" time="{duration}"/> |     <testcase classname="<exe-name>.global" name="ManuallyRegistered" time="{duration}"/> | ||||||
|     <testcase classname="<exe-name>.global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/> |     <testcase classname="<exe-name>.global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/> | ||||||
|   | |||||||
| @@ -369,6 +369,7 @@ Class.tests.cpp:<line number> | |||||||
|     <testCase name="#809" duration="{duration}"/> |     <testCase name="#809" duration="{duration}"/> | ||||||
|     <testCase name="#833" duration="{duration}"/> |     <testCase name="#833" duration="{duration}"/> | ||||||
|     <testCase name="#872" duration="{duration}"/> |     <testCase name="#872" duration="{duration}"/> | ||||||
|  |     <testCase name="Lambdas in assertions" duration="{duration}"/> | ||||||
|     <testCase name="Optionally static assertions" duration="{duration}"/> |     <testCase name="Optionally static assertions" duration="{duration}"/> | ||||||
|   </file> |   </file> | ||||||
|   <file path="projects/<exe-name>/UsageTests/Condition.tests.cpp"> |   <file path="projects/<exe-name>/UsageTests/Condition.tests.cpp"> | ||||||
|   | |||||||
| @@ -7266,6 +7266,17 @@ Nor would this | |||||||
|       </Expression> |       </Expression> | ||||||
|       <OverallResult success="true"/> |       <OverallResult success="true"/> | ||||||
|     </TestCase> |     </TestCase> | ||||||
|  |     <TestCase name="Lambdas in assertions" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > | ||||||
|  |       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > | ||||||
|  |         <Original> | ||||||
|  |           []() { return true; }() | ||||||
|  |         </Original> | ||||||
|  |         <Expanded> | ||||||
|  |           true | ||||||
|  |         </Expanded> | ||||||
|  |       </Expression> | ||||||
|  |       <OverallResult success="true"/> | ||||||
|  |     </TestCase> | ||||||
|     <TestCase name="Less-than inequalities with different epsilons" tags="[Approx]" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > |     <TestCase name="Less-than inequalities with different epsilons" tags="[Approx]" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > | ||||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > |       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > | ||||||
|         <Original> |         <Original> | ||||||
| @@ -16037,7 +16048,7 @@ loose text artifact | |||||||
|       </Section> |       </Section> | ||||||
|       <OverallResult success="true"/> |       <OverallResult success="true"/> | ||||||
|     </TestCase> |     </TestCase> | ||||||
|     <OverallResults successes="1524" failures="149" expectedFailures="21"/> |     <OverallResults successes="1525" failures="149" expectedFailures="21"/> | ||||||
|   </Group> |   </Group> | ||||||
|   <OverallResults successes="1524" failures="148" expectedFailures="21"/> |   <OverallResults successes="1525" failures="148" expectedFailures="21"/> | ||||||
| </Catch> | </Catch> | ||||||
|   | |||||||
| @@ -228,6 +228,9 @@ namespace { namespace CompilationTests { | |||||||
|         REQUIRE( 0 == y.v ); |         REQUIRE( 0 == y.v ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     TEST_CASE("Lambdas in assertions") { | ||||||
|  |         REQUIRE([]() { return true; }()); | ||||||
|  |     } | ||||||
|  |  | ||||||
| }} // namespace CompilationTests | }} // namespace CompilationTests | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský