Skip to content

Commit

Permalink
Add a test for custom debug break macros
Browse files Browse the repository at this point in the history
See #1846
  • Loading branch information
horenmar committed Feb 16, 2020
1 parent 3c7e737 commit 89f18f1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions projects/ExtraTests/X12-CustomDebugBreakMacro.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
9 changes: 9 additions & 0 deletions tests/ExtraTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -150,6 +158,7 @@ set( EXTRA_TEST_BINARIES
FallbackStringifier
DisableStringification
BenchmarkingMacros
DebugBreakMacros
)

# Shared config
Expand Down

0 comments on commit 89f18f1

Please sign in to comment.