mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 04:07:10 +01:00 
			
		
		
		
	Remove isTrue, alwaysTrue, alwaysFalse
isTrue and alwaysFalse were replaced by (void)0, 0 inspired by doctest alwaysTrue was replaced by warning suppression
This commit is contained in:
		| @@ -762,9 +762,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assertions then sections | ||||
| @@ -775,9 +773,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assertions then sections | ||||
| @@ -789,9 +785,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assertions then sections | ||||
| @@ -801,9 +795,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assertions then sections | ||||
| @@ -814,9 +806,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assertions then sections | ||||
| @@ -828,9 +818,7 @@ Tricky.tests.cpp:<line number> | ||||
|  | ||||
| Tricky.tests.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( Catch::alwaysTrue() ) | ||||
| with expansion: | ||||
|   true | ||||
|   REQUIRE( true ) | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Assorted miscellaneous tests | ||||
|   | ||||
| @@ -819,7 +819,7 @@ | ||||
|     <TestCase name="Assertions then sections" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|         <Original> | ||||
|           Catch::alwaysTrue() | ||||
|           true | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           true | ||||
| @@ -828,7 +828,7 @@ | ||||
|       <Section name="A section" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|         <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|           <Original> | ||||
|             Catch::alwaysTrue() | ||||
|             true | ||||
|           </Original> | ||||
|           <Expanded> | ||||
|             true | ||||
| @@ -837,7 +837,7 @@ | ||||
|         <Section name="Another section" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|           <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|             <Original> | ||||
|               Catch::alwaysTrue() | ||||
|               true | ||||
|             </Original> | ||||
|             <Expanded> | ||||
|               true | ||||
| @@ -849,7 +849,7 @@ | ||||
|       </Section> | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|         <Original> | ||||
|           Catch::alwaysTrue() | ||||
|           true | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           true | ||||
| @@ -858,7 +858,7 @@ | ||||
|       <Section name="A section" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|         <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|           <Original> | ||||
|             Catch::alwaysTrue() | ||||
|             true | ||||
|           </Original> | ||||
|           <Expanded> | ||||
|             true | ||||
| @@ -867,7 +867,7 @@ | ||||
|         <Section name="Another other section" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|           <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" > | ||||
|             <Original> | ||||
|               Catch::alwaysTrue() | ||||
|               true | ||||
|             </Original> | ||||
|             <Expanded> | ||||
|               true | ||||
|   | ||||
| @@ -12,11 +12,12 @@ | ||||
| #include <stdexcept> | ||||
|  | ||||
| #ifdef _MSC_VER | ||||
| #pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection | ||||
| #pragma warning(disable:4702) // Unreachable code -- uncoditional throws and so on | ||||
| #endif | ||||
| #ifdef __clang__ | ||||
| #pragma clang diagnostic push | ||||
| #pragma clang diagnostic ignored "-Wweak-vtables" | ||||
| #pragma clang diagnostic ignored "-Wmissing-noreturn" | ||||
| #endif | ||||
|  | ||||
| namespace { namespace ExceptionTests { | ||||
| @@ -24,9 +25,8 @@ namespace { namespace ExceptionTests { | ||||
| #ifndef EXCEPTION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU | ||||
| #define EXCEPTION_TEST_HELPERS_INCLUDED | ||||
|  | ||||
| inline int thisThrows() { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw std::domain_error( "expected exception" ); | ||||
| int thisThrows() { | ||||
|     throw std::domain_error( "expected exception" ); | ||||
|     return 1; | ||||
| } | ||||
|  | ||||
| @@ -63,9 +63,8 @@ private: | ||||
|     std::string m_msg; | ||||
| }; | ||||
|  | ||||
| inline void throwCustom() { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw CustomException( "custom exception - not std" ); | ||||
| [[noreturn]] void throwCustom() { | ||||
|     throw CustomException( "custom exception - not std" ); | ||||
| } | ||||
|  | ||||
| #endif | ||||
| @@ -83,20 +82,17 @@ TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail t | ||||
| } | ||||
|  | ||||
| TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing][!throws]" ) { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw std::domain_error( "unexpected exception" ); | ||||
|     throw std::domain_error( "unexpected exception" ); | ||||
| } | ||||
|  | ||||
| TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing][!throws]" ) { | ||||
|     CHECK( 1 == 1 ); | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw std::domain_error( "unexpected exception" ); | ||||
|     throw std::domain_error( "unexpected exception" ); | ||||
| } | ||||
|  | ||||
| TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing][!throws]" ) { | ||||
|     SECTION( "section name" ) { | ||||
|         if( Catch::alwaysTrue() ) | ||||
|             throw std::domain_error( "unexpected exception" ); | ||||
|         throw std::domain_error("unexpected exception"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -139,13 +135,11 @@ CATCH_TRANSLATE_EXCEPTION( double& ex ) { | ||||
| } | ||||
|  | ||||
| TEST_CASE("Non-std exceptions can be translated", "[.][failing][!throws]" ) { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw CustomException( "custom exception" ); | ||||
|     throw CustomException( "custom exception" ); | ||||
| } | ||||
|  | ||||
| TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing][!throws]" ) { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw CustomException( "custom std exception" ); | ||||
|     throw CustomException( "custom std exception" ); | ||||
| } | ||||
|  | ||||
| TEST_CASE( "Custom exceptions can be translated when testing for nothrow", "[.][failing][!throws]" ) { | ||||
| @@ -157,8 +151,7 @@ TEST_CASE( "Custom exceptions can be translated when testing for throwing as som | ||||
| } | ||||
|  | ||||
| TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]"  ) { | ||||
|     if( Catch::alwaysTrue() ) | ||||
|         throw double( 3.14 ); | ||||
|     throw double( 3.14 ); | ||||
| } | ||||
|  | ||||
| #ifndef CATCH_CONFIG_DISABLE_MATCHERS | ||||
|   | ||||
| @@ -298,19 +298,19 @@ TEST_CASE( "Assertions then sections", "[Tricky]" ) | ||||
|     // This was causing a failure due to the way the console reporter was handling | ||||
|     // the current section | ||||
|  | ||||
|     REQUIRE( Catch::alwaysTrue() ); | ||||
|     REQUIRE( true ); | ||||
|  | ||||
|     SECTION( "A section" ) | ||||
|     { | ||||
|         REQUIRE( Catch::alwaysTrue() ); | ||||
|         REQUIRE( true ); | ||||
|  | ||||
|         SECTION( "Another section" ) | ||||
|         { | ||||
|             REQUIRE( Catch::alwaysTrue() ); | ||||
|             REQUIRE( true ); | ||||
|         } | ||||
|         SECTION( "Another other section" ) | ||||
|         { | ||||
|             REQUIRE( Catch::alwaysTrue() ); | ||||
|             REQUIRE( true ); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský