Add more macros to the DisabledMacros test

This commit is contained in:
Martin Hořeňovský 2022-01-01 16:45:28 +01:00
parent f2f585b478
commit ef3374ed81
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -3,6 +3,9 @@
// and expressions in assertion macros are not run. // and expressions in assertion macros are not run.
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_predicate.hpp>
#include <iostream> #include <iostream>
@ -30,12 +33,18 @@ 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" ) {
CHECK( 1 == 2 );
REQUIRE( 1 == 2 );
std::cout << "This should not happen\n"; std::cout << "This should not happen\n";
FAIL(); FAIL();
// Test that static assertions don't fire when macros are disabled // Test that static assertions don't fire when macros are disabled
STATIC_CHECK( 0 == 1 ); STATIC_CHECK( 0 == 1 );
STATIC_REQUIRE( !true ); STATIC_REQUIRE( !true );
REQUIRE_THAT( 1,
Catch::Matchers::Predicate( []( int ) { return false; } ) );
BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); };
} }
#if defined(__clang__) #if defined(__clang__)