summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hořeňovský <martin.horenovsky@gmail.com>2020-02-01 20:17:54 +0100
committerMartin Hořeňovský <martin.horenovsky@gmail.com>2020-02-01 20:18:05 +0100
commit6a3d0dc176672047d4ac53cf295ac883767e58b7 (patch)
tree7f7170205253445ff76280397b847cca0352904d
parentccb1f70629e8952c4b92d77535f79ad6c7055d23 (diff)
downloadcatch2-6a3d0dc176672047d4ac53cf295ac883767e58b7.tar.gz
Add a test for custom debug break macros
See #1846
-rw-r--r--projects/ExtraTests/CMakeLists.txt9
-rw-r--r--projects/ExtraTests/X12-CustomDebugBreakMacro.cpp17
2 files changed, 26 insertions, 0 deletions
diff --git a/projects/ExtraTests/CMakeLists.txt b/projects/ExtraTests/CMakeLists.txt
index 13b02870..0e514d96 100644
--- a/projects/ExtraTests/CMakeLists.txt
+++ b/projects/ExtraTests/CMakeLists.txt
@@ -137,6 +137,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
@@ -145,6 +153,7 @@ set( EXTRA_TEST_BINARIES
FallbackStringifier
DisableStringification
BenchmarkingMacros
+ DebugBreakMacros
)
# Shared config
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 <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);
+}