From 89f18f15cae32f201ddad2cb110f062659e1bc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 1 Feb 2020 20:17:54 +0100 Subject: [PATCH] Add a test for custom debug break macros See #1846 --- .../ExtraTests/X12-CustomDebugBreakMacro.cpp | 17 +++++++++++++++++ tests/ExtraTests/CMakeLists.txt | 9 +++++++++ 2 files changed, 26 insertions(+) create mode 100644 projects/ExtraTests/X12-CustomDebugBreakMacro.cpp diff --git a/projects/ExtraTests/X12-CustomDebugBreakMacro.cpp b/projects/ExtraTests/X12-CustomDebugBreakMacro.cpp new file mode 100644 index 00000000..25ab4a0e --- /dev/null +++ b/projects/ExtraTests/X12-CustomDebugBreakMacro.cpp @@ -0,0 +1,17 @@ +// X12-CustomDebugBreakMacro.cpp +// Test that user-defined `CATCH_BREAK_INTO_DEBUGGER` is respected and used. + +#include + +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 + +TEST_CASE("Failing test that breaks into debugger", "[macros]") { + REQUIRE(1 == 2); +} diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index b534fc8d..05c444f4 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -142,6 +142,14 @@ if (MSVC) add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact) 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 PrefixedMacros DisabledMacros @@ -150,6 +158,7 @@ set( EXTRA_TEST_BINARIES FallbackStringifier DisableStringification BenchmarkingMacros + DebugBreakMacros ) # Shared config