Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/ExtraTests
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-11-30 12:56:06 +0100
committerMartin Hořeňovský2025-11-30 14:30:19 +0100
commit985a3f44605bf3ee7bd4a0c6129ca69ec53a7ebe (patch)
tree45ad4f5e3587018288711564bc9e385b2f3b6cb2 /tests/ExtraTests
parenta1faad9315ece8e7146e9d2263ceb3d42ea0619a (diff)
downloadcatch3-985a3f44605bf3ee7bd4a0c6129ca69ec53a7ebe.tar.gz
Fix lazy removal of unscoped messages also removing still valid msgs
Diffstat (limited to 'tests/ExtraTests')
-rw-r--r--tests/ExtraTests/CMakeLists.txt13
-rw-r--r--tests/ExtraTests/X06-MixingClearedAndUnclearedMessages.cpp27
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt
index fbcc3465..e7965fa9 100644
--- a/tests/ExtraTests/CMakeLists.txt
+++ b/tests/ExtraTests/CMakeLists.txt
@@ -177,6 +177,18 @@ set_tests_properties(DeferredStaticChecks
PASS_REGULAR_EXPRESSION "test cases: 1 \\| 1 failed\nassertions: 3 \\| 3 failed"
)
+add_executable(MixingClearedAndUnclearedMessages ${TESTS_DIR}/X06-MixingClearedAndUnclearedMessages.cpp)
+target_link_libraries(MixingClearedAndUnclearedMessages PRIVATE Catch2WithMain)
+
+add_test(NAME MixingClearedAndUnclearedMessages
+ COMMAND
+ MixingClearedAndUnclearedMessages
+ -r compact)
+set_tests_properties(MixingClearedAndUnclearedMessages
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION ": false with 1 message: 'b'"
+)
+
add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
target_compile_definitions(FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier)
target_link_libraries(FallbackStringifier Catch2WithMain)
@@ -528,6 +540,7 @@ set(EXTRA_TEST_BINARIES
DuplicatedTestCases-DuplicatedTestCaseMethods
NoTests
ListenersGetEventsBeforeReporters
+ MixingClearedAndUnclearedMessages
# DebugBreakMacros
)
diff --git a/tests/ExtraTests/X06-MixingClearedAndUnclearedMessages.cpp b/tests/ExtraTests/X06-MixingClearedAndUnclearedMessages.cpp
new file mode 100644
index 00000000..2c52ba1b
--- /dev/null
+++ b/tests/ExtraTests/X06-MixingClearedAndUnclearedMessages.cpp
@@ -0,0 +1,27 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+/**\file
+ * Checks that when we use up an unscoped message (e.g. `UNSCOPED_INFO`),
+ * with an assertion, and then add another message later, it will be
+ * properly reported with later failing assertion.
+ *
+ * This needs separate binary to avoid the main test binary's validating
+ * listener, which disables the assertion fast path.
+ */
+
+#include <catch2/catch_test_macros.hpp>
+
+TEST_CASE(
+ "Delayed unscoped message clearing does not catch newly inserted messages",
+ "[messages][unscoped][!shouldfail]" ) {
+ UNSCOPED_INFO( "a" );
+ REQUIRE( true );
+ UNSCOPED_INFO( "b" );
+ REQUIRE( false );
+}