Add a test for custom debug break macros

See #1846
This commit is contained in:
Martin Hořeňovský 2020-02-01 20:17:54 +01:00
parent ccb1f70629
commit 6a3d0dc176
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 26 additions and 0 deletions

View File

@ -137,6 +137,14 @@ if (MSVC)
add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact) add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
endif() endif()
add_executable(DebugBreakMacros ${TESTS_DIR}/X12-CustomDebugBreakMacro.cpp)
add_test(NAME DebugBreakMacros COMMAND DebugBreakMacros --break)
set_tests_properties(
DebugBreakMacros
PROPERTIES
PASS_REGULAR_EXPRESSION "Pretty please, break into debugger"
)
set( EXTRA_TEST_BINARIES set( EXTRA_TEST_BINARIES
PrefixedMacros PrefixedMacros
DisabledMacros DisabledMacros
@ -145,6 +153,7 @@ set( EXTRA_TEST_BINARIES
FallbackStringifier FallbackStringifier
DisableStringification DisableStringification
BenchmarkingMacros BenchmarkingMacros
DebugBreakMacros
) )
# Shared config # Shared config

View File

@ -0,0 +1,17 @@
// X12-CustomDebugBreakMacro.cpp
// Test that user-defined `CATCH_BREAK_INTO_DEBUGGER` is respected and used.
#include <iostream>
void custom_debug_break() {
std::cerr << "Pretty please, break into debugger\n";
}
#define CATCH_BREAK_INTO_DEBUGGER() custom_debug_break()
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
TEST_CASE("Failing test that breaks into debugger", "[macros]") {
REQUIRE(1 == 2);
}