Fix: CAPTURE not variadic when disabled (#2378)

Closes: #2316
This commit is contained in:
John Beard 2022-03-04 14:29:22 +00:00 committed by GitHub
parent 958944d27a
commit ff151d2833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -433,7 +433,7 @@ using Catch::Detail::Approx;
#define INFO( msg ) (void)(0) #define INFO( msg ) (void)(0)
#define UNSCOPED_INFO( msg ) (void)(0) #define UNSCOPED_INFO( msg ) (void)(0)
#define WARN( msg ) (void)(0) #define WARN( msg ) (void)(0)
#define CAPTURE( msg ) (void)(0) #define CAPTURE( ... ) (void)(0)
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))

View File

@ -53,6 +53,7 @@ CATCH_TEST_CASE("PrefixedMacros") {
CATCH_SECTION("some section") { CATCH_SECTION("some section") {
int i = 1; int i = 1;
CATCH_CAPTURE( i ); CATCH_CAPTURE( i );
CATCH_CAPTURE( i, i + 1 );
CATCH_DYNAMIC_SECTION("Dynamic section: " << i) { CATCH_DYNAMIC_SECTION("Dynamic section: " << i) {
CATCH_FAIL_CHECK( "failure" ); CATCH_FAIL_CHECK( "failure" );
} }

View File

@ -26,6 +26,10 @@ foo f;
// This test should not be run, because it won't be registered // This test should not be run, because it won't be registered
TEST_CASE( "Disabled Macros" ) { TEST_CASE( "Disabled Macros" ) {
CAPTURE( 1 );
CAPTURE( 1, "captured" );
std::cout << "This should not happen\n"; std::cout << "This should not happen\n";
FAIL(); FAIL();
} }