diff --git a/docs/logging.md b/docs/logging.md index 79709386..1da97749 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -1,32 +1,30 @@ # Logging macros -Additional messages can be logged during a test case. Note that the messages logged with `INFO` are scoped and thus will not be reported if failure occurs in scope preceding the message declaration. An example: +Catch2 provides various macros for logging extra information when +running a test. These macros default to being scoped, and associate with +all assertions in the scope, regardless of whether they pass or fail. +**example** ```cpp -TEST_CASE("Foo") { +TEST_CASE("Simple info") { INFO("Test case start"); - for (int i = 0; i < 2; ++i) { - INFO("The number is " << i); - CHECK(i == 0); + SECTION("A") { + INFO("Section A"); + CHECK(false); // 1 } + SECTION("B") { + INFO("Section B"); + CHECK(false); // 2 + } + CHECK(false); // 3 } +``` +The first assertion will report messages "Test case start", and "Section A" +as extra information. The second one will report messages "Test case +started" and "Section B", while the third one will only report "Test case +started" as the extra info. -TEST_CASE("Bar") { - INFO("Test case start"); - for (int i = 0; i < 2; ++i) { - INFO("The number is " << i); - CHECK(i == i); - } - CHECK(false); -} -``` -When the `CHECK` fails in the "Foo" test case, then two messages will be printed. -``` -Test case start -The number is 1 -``` -When the last `CHECK` fails in the "Bar" test case, then only one message will be printed: `Test case start`. ## Logging without local scope diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp index 7b09ab87..d3914a80 100644 --- a/src/catch2/catch_message.cpp +++ b/src/catch2/catch_message.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include #include #include @@ -31,7 +30,7 @@ namespace Catch { } ScopedMessage::~ScopedMessage() { - if ( !uncaught_exceptions() && !m_moved ){ + if ( !m_moved ){ getResultCapture().popScopedMessage(m_info); } } @@ -101,11 +100,9 @@ namespace Catch { m_messages.back().message += " := "; } Capturer::~Capturer() { - if ( !uncaught_exceptions() ){ - assert( m_captured == m_messages.size() ); - for( size_t i = 0; i < m_captured; ++i ) - m_resultCapture.popScopedMessage( m_messages[i] ); - } + assert( m_captured == m_messages.size() ); + for ( size_t i = 0; i < m_captured; ++i ) + m_resultCapture.popScopedMessage( m_messages[i] ); } void Capturer::captureValue( size_t index, std::string const& value ) { diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index a6b99c02..6991ddcf 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -402,9 +402,6 @@ namespace Catch { endInfo.durationInSeconds, missingAssertions ) ); } - - m_messages.clear(); - m_messageScopes.clear(); } void RunContext::sectionEndedEarly(SectionEndInfo&& endInfo) { @@ -568,8 +565,10 @@ namespace Catch { m_testCaseTracker->close(); handleUnfinishedSections(); - m_messages.clear(); m_messageScopes.clear(); + // TBD: At this point, m_messages should be empty. Do we want to + // assert that this is true, or keep the defensive clear call? + m_messages.clear(); SectionStats testCaseSectionStats(CATCH_MOVE(testCaseSection), assertions, duration, missingAssertions); m_reporter->sectionEnded(testCaseSectionStats); diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index bff15522..c5f538ff 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -102,6 +102,8 @@ Nor would this :test-result: PASS CAPTURE can deal with complex expressions involving commas :test-result: PASS CAPTURE parses string and character constants :test-result: PASS Capture and info messages +:test-result: FAIL Captures do not leave block with an exception +:test-result: FAIL Captures outlive section end :test-result: PASS CaseInsensitiveEqualsTo is case insensitive :test-result: PASS CaseInsensitiveLess is case insensitive :test-result: PASS Character pretty printing @@ -226,6 +228,9 @@ Nor would this :test-result: PASS Scenario: Do that thing with the thing :test-result: PASS Scenario: This is a really long scenario name to see how the list command deals with wrapping :test-result: PASS Scenario: Vector resizing affects size and capacity +:test-result: FAIL Scoped message applies to all assertions in scope +:test-result: FAIL Scoped messages do not leave block with an exception +:test-result: FAIL Scoped messages outlive section end A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index b30e5491..b573f81e 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -100,6 +100,8 @@ :test-result: PASS CAPTURE can deal with complex expressions involving commas :test-result: PASS CAPTURE parses string and character constants :test-result: PASS Capture and info messages +:test-result: FAIL Captures do not leave block with an exception +:test-result: FAIL Captures outlive section end :test-result: PASS CaseInsensitiveEqualsTo is case insensitive :test-result: PASS CaseInsensitiveLess is case insensitive :test-result: PASS Character pretty printing @@ -224,6 +226,9 @@ :test-result: PASS Scenario: Do that thing with the thing :test-result: PASS Scenario: This is a really long scenario name to see how the list command deals with wrapping :test-result: PASS Scenario: Vector resizing affects size and capacity +:test-result: FAIL Scoped message applies to all assertions in scope +:test-result: FAIL Scoped messages do not leave block with an exception +:test-result: FAIL Scoped messages outlive section end :test-result: FAIL Sends stuff to stdout and stderr :test-result: PASS Some simple comparisons between doubles :test-result: FAIL Standard output from all sections is reported diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 5e2fef69..008d627c 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -85,7 +85,7 @@ Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smalle Matchers.tests.cpp:: passed: smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0.0f is within 2 ULPs of -1.40129846e-45f ([-4.20389539e-45, 1.40129846e-45]) Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) Generators.tests.cpp:: failed: unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} -Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: {Unknown expression after the reported line} with 1 message: 'expected exception' +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' Exception.tests.cpp:: passed: thisThrows() with 1 message: 'answer := 42' Compilation.tests.cpp:: passed: 42 == f for: 42 == {?} @@ -363,6 +363,9 @@ Message.tests.cpp:: passed: with 7 messages: 'custom_index_op{ Message.tests.cpp:: passed: with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' ToStringGeneral.tests.cpp:: passed: true with 1 message: 'i := 2' ToStringGeneral.tests.cpp:: passed: true with 1 message: '3' +Message.tests.cpp:: failed: false with 1 message: 'a := 1' +Message.tests.cpp:: passed: true with 1 message: 'a := 1' +Message.tests.cpp:: failed: false with 1 message: 'a := 1' Details.tests.cpp:: passed: eq( "", "" ) for: true Details.tests.cpp:: passed: !(eq( "", "a" )) for: !false Details.tests.cpp:: passed: eq( "a", "a" ) for: true @@ -1732,6 +1735,11 @@ BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +Message.tests.cpp:: failed: false with 1 message: 'This will be reported multiple times' +Message.tests.cpp:: failed: false with 1 message: 'This will be reported multiple times' +Message.tests.cpp:: failed: false with 1 message: 'Should be in scope at the end' +Message.tests.cpp:: passed: true with 1 message: 'Should survive a section end' +Message.tests.cpp:: failed: false with 1 message: 'Should survive a section end' A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog @@ -2854,7 +2862,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 423 | 313 passed | 90 failed | 6 skipped | 14 failed as expected -assertions: 2273 | 2087 passed | 151 failed | 35 failed as expected +test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected +assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index e96370e0..57303829 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -83,7 +83,7 @@ Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smalle Matchers.tests.cpp:: passed: smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0.0f is within 2 ULPs of -1.40129846e-45f ([-4.20389539e-45, 1.40129846e-45]) Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) Generators.tests.cpp:: failed: unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} -Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: {Unknown expression after the reported line} with 1 message: 'expected exception' +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' Exception.tests.cpp:: passed: thisThrows() with 1 message: 'answer := 42' Compilation.tests.cpp:: passed: 42 == f for: 42 == {?} @@ -361,6 +361,9 @@ Message.tests.cpp:: passed: with 7 messages: 'custom_index_op{ Message.tests.cpp:: passed: with 11 messages: '("comma, in string", "escaped, \", ") := "escaped, ", "' and '"single quote in string,'," := "single quote in string,',"' and '"some escapes, \\,\\\\" := "some escapes, \,\\"' and '"some, ), unmatched, } prenheses {[<" := "some, ), unmatched, } prenheses {[<"' and ''"' := '"'' and ''\'' := '''' and '',' := ','' and ''}' := '}'' and '')' := ')'' and ''(' := '('' and ''{' := '{'' ToStringGeneral.tests.cpp:: passed: true with 1 message: 'i := 2' ToStringGeneral.tests.cpp:: passed: true with 1 message: '3' +Message.tests.cpp:: failed: false with 1 message: 'a := 1' +Message.tests.cpp:: passed: true with 1 message: 'a := 1' +Message.tests.cpp:: failed: false with 1 message: 'a := 1' Details.tests.cpp:: passed: eq( "", "" ) for: true Details.tests.cpp:: passed: !(eq( "", "a" )) for: !false Details.tests.cpp:: passed: eq( "a", "a" ) for: true @@ -1730,6 +1733,11 @@ BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +Message.tests.cpp:: failed: false with 1 message: 'This will be reported multiple times' +Message.tests.cpp:: failed: false with 1 message: 'This will be reported multiple times' +Message.tests.cpp:: failed: false with 1 message: 'Should be in scope at the end' +Message.tests.cpp:: passed: true with 1 message: 'Should survive a section end' +Message.tests.cpp:: failed: false with 1 message: 'Should survive a section end' Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) @@ -2843,7 +2851,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 423 | 313 passed | 90 failed | 6 skipped | 14 failed as expected -assertions: 2273 | 2087 passed | 151 failed | 35 failed as expected +test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected +assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index b7933236..194b3676 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -47,8 +47,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: {Unknown expression after the reported line} -due to unexpected exception with messages: - answer := 42 +due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- @@ -348,6 +347,28 @@ Exception.tests.cpp:: FAILED: due to unexpected exception with message: unexpected exception +------------------------------------------------------------------------------- +Captures do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + +------------------------------------------------------------------------------- +Captures outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + ------------------------------------------------------------------------------- Contains string matcher ------------------------------------------------------------------------------- @@ -988,6 +1009,44 @@ with expansion: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively +------------------------------------------------------------------------------- +Scoped message applies to all assertions in scope +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +------------------------------------------------------------------------------- +Scoped messages do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should be in scope at the end + +------------------------------------------------------------------------------- +Scoped messages outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should survive a section end + A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog @@ -1613,6 +1672,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 423 | 331 passed | 71 failed | 7 skipped | 14 failed as expected -assertions: 2252 | 2087 passed | 130 failed | 35 failed as expected +test cases: 428 | 331 passed | 76 failed | 7 skipped | 14 failed as expected +assertions: 2260 | 2089 passed | 136 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index eb0ea034..1740933b 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -781,8 +781,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: {Unknown expression after the reported line} -due to unexpected exception with messages: - answer := 42 +due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- @@ -2867,6 +2866,40 @@ ToStringGeneral.tests.cpp:: PASSED: with message: 3 +------------------------------------------------------------------------------- +Captures do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + +------------------------------------------------------------------------------- +Captures outlive section end + Dummy section +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: PASSED: + CHECK( true ) +with message: + a := 1 + +------------------------------------------------------------------------------- +Captures outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + ------------------------------------------------------------------------------- CaseInsensitiveEqualsTo is case insensitive Degenerate cases @@ -11026,6 +11059,56 @@ BDD.tests.cpp:: PASSED: with expansion: 0 == 0 +------------------------------------------------------------------------------- +Scoped message applies to all assertions in scope +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +------------------------------------------------------------------------------- +Scoped messages do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should be in scope at the end + +------------------------------------------------------------------------------- +Scoped messages outlive section end + Dummy section +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: PASSED: + CHECK( true ) +with message: + Should survive a section end + +------------------------------------------------------------------------------- +Scoped messages outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should survive a section end + A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog @@ -19051,6 +19134,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 423 | 313 passed | 90 failed | 6 skipped | 14 failed as expected -assertions: 2273 | 2087 passed | 151 failed | 35 failed as expected +test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected +assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 95f4f6f7..786ad4e9 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -779,8 +779,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: {Unknown expression after the reported line} -due to unexpected exception with messages: - answer := 42 +due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- @@ -2865,6 +2864,40 @@ ToStringGeneral.tests.cpp:: PASSED: with message: 3 +------------------------------------------------------------------------------- +Captures do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + +------------------------------------------------------------------------------- +Captures outlive section end + Dummy section +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: PASSED: + CHECK( true ) +with message: + a := 1 + +------------------------------------------------------------------------------- +Captures outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + a := 1 + ------------------------------------------------------------------------------- CaseInsensitiveEqualsTo is case insensitive Degenerate cases @@ -11024,6 +11057,56 @@ BDD.tests.cpp:: PASSED: with expansion: 0 == 0 +------------------------------------------------------------------------------- +Scoped message applies to all assertions in scope +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +Message.tests.cpp:: FAILED: + CHECK( false ) +with message: + This will be reported multiple times + +------------------------------------------------------------------------------- +Scoped messages do not leave block with an exception +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should be in scope at the end + +------------------------------------------------------------------------------- +Scoped messages outlive section end + Dummy section +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: PASSED: + CHECK( true ) +with message: + Should survive a section end + +------------------------------------------------------------------------------- +Scoped messages outlive section end +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + Should survive a section end + ------------------------------------------------------------------------------- Sends stuff to stdout and stderr ------------------------------------------------------------------------------- @@ -19040,6 +19123,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 423 | 313 passed | 90 failed | 6 skipped | 14 failed as expected -assertions: 2273 | 2087 passed | 151 failed | 35 failed as expected +test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected +assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.swa4.approved.txt b/tests/SelfTest/Baselines/console.swa4.approved.txt index 3d181c9f..c3a2676b 100644 --- a/tests/SelfTest/Baselines/console.swa4.approved.txt +++ b/tests/SelfTest/Baselines/console.swa4.approved.txt @@ -781,8 +781,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: {Unknown expression after the reported line} -due to unexpected exception with messages: - answer := 42 +due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index d4b2ee20..f4e3bb0e 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -67,7 +67,6 @@ at Generators.tests.cpp: FAILED: {Unknown expression after the reported line} expected exception -answer := 42 at Exception.tests.cpp: @@ -412,6 +411,23 @@ at Exception.tests.cpp: + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + @@ -1350,6 +1366,37 @@ at Matchers.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should be in scope at the end +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should survive a section end +at Message.tests.cpp: + + + A string sent directly to stdout diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index c23dff5b..0a205437 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -66,7 +66,6 @@ at Generators.tests.cpp: FAILED: {Unknown expression after the reported line} expected exception -answer := 42 at Exception.tests.cpp: @@ -411,6 +410,23 @@ at Exception.tests.cpp: + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + @@ -1349,6 +1365,37 @@ at Matchers.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should be in scope at the end +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should survive a section end +at Message.tests.cpp: + + + A string sent directly to stdout diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index e757c5a4..d25bceda 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -1012,7 +1012,6 @@ at Decomposition.tests.cpp: FAILED: {Unknown expression after the reported line} expected exception -answer := 42 at Exception.tests.cpp: @@ -1637,6 +1636,23 @@ at Matchers.tests.cpp: + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + FAILED: @@ -1726,6 +1742,37 @@ at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should be in scope at the end +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should survive a section end +at Message.tests.cpp: + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index eb7d7ffb..66b2c832 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -1011,7 +1011,6 @@ at Decomposition.tests.cpp: FAILED: {Unknown expression after the reported line} expected exception -answer := 42 at Exception.tests.cpp: @@ -1636,6 +1635,23 @@ at Matchers.tests.cpp: + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +a := 1 +at Message.tests.cpp: + + + FAILED: @@ -1725,6 +1741,37 @@ at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + +FAILED: + CHECK( false ) +This will be reported multiple times +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should be in scope at the end +at Message.tests.cpp: + + + + +FAILED: + REQUIRE( false ) +Should survive a section end +at Message.tests.cpp: + + + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 08bb5254..c7f2f3a5 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -167,7 +167,7 @@ ok {test-number} - smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0 # #2615 - Throwing in constructor generator fails test case but does not abort not ok {test-number} - unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} # #748 - captures with unexpected exceptions -not ok {test-number} - unexpected exception with message: 'answer := 42'; expression was: {Unknown expression after the reported line} with 1 message: 'expected exception' +not ok {test-number} - unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} # #748 - captures with unexpected exceptions not ok {test-number} - unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' # #748 - captures with unexpected exceptions @@ -674,6 +674,12 @@ ok {test-number} - with 11 messages: '("comma, in string", "escaped, \", ") := " ok {test-number} - true with 1 message: 'i := 2' # Capture and info messages ok {test-number} - true with 1 message: '3' +# Captures do not leave block with an exception +not ok {test-number} - false with 1 message: 'a := 1' +# Captures outlive section end +ok {test-number} - true with 1 message: 'a := 1' +# Captures outlive section end +not ok {test-number} - false with 1 message: 'a := 1' # CaseInsensitiveEqualsTo is case insensitive ok {test-number} - eq( "", "" ) for: true # CaseInsensitiveEqualsTo is case insensitive @@ -2616,6 +2622,16 @@ ok {test-number} - v.size() == 0 for: 0 == 0 ok {test-number} - v.capacity() >= 10 for: 10 >= 10 # Scenario: Vector resizing affects size and capacity ok {test-number} - v.size() == 0 for: 0 == 0 +# Scoped message applies to all assertions in scope +not ok {test-number} - false with 1 message: 'This will be reported multiple times' +# Scoped message applies to all assertions in scope +not ok {test-number} - false with 1 message: 'This will be reported multiple times' +# Scoped messages do not leave block with an exception +not ok {test-number} - false with 1 message: 'Should be in scope at the end' +# Scoped messages outlive section end +ok {test-number} - true with 1 message: 'Should survive a section end' +# Scoped messages outlive section end +not ok {test-number} - false with 1 message: 'Should survive a section end' A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog @@ -4567,5 +4583,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2285 +1..2293 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 4181327d..3632b386 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -165,7 +165,7 @@ ok {test-number} - smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0 # #2615 - Throwing in constructor generator fails test case but does not abort not ok {test-number} - unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} # #748 - captures with unexpected exceptions -not ok {test-number} - unexpected exception with message: 'answer := 42'; expression was: {Unknown expression after the reported line} with 1 message: 'expected exception' +not ok {test-number} - unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} # #748 - captures with unexpected exceptions not ok {test-number} - unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' # #748 - captures with unexpected exceptions @@ -672,6 +672,12 @@ ok {test-number} - with 11 messages: '("comma, in string", "escaped, \", ") := " ok {test-number} - true with 1 message: 'i := 2' # Capture and info messages ok {test-number} - true with 1 message: '3' +# Captures do not leave block with an exception +not ok {test-number} - false with 1 message: 'a := 1' +# Captures outlive section end +ok {test-number} - true with 1 message: 'a := 1' +# Captures outlive section end +not ok {test-number} - false with 1 message: 'a := 1' # CaseInsensitiveEqualsTo is case insensitive ok {test-number} - eq( "", "" ) for: true # CaseInsensitiveEqualsTo is case insensitive @@ -2614,6 +2620,16 @@ ok {test-number} - v.size() == 0 for: 0 == 0 ok {test-number} - v.capacity() >= 10 for: 10 >= 10 # Scenario: Vector resizing affects size and capacity ok {test-number} - v.size() == 0 for: 0 == 0 +# Scoped message applies to all assertions in scope +not ok {test-number} - false with 1 message: 'This will be reported multiple times' +# Scoped message applies to all assertions in scope +not ok {test-number} - false with 1 message: 'This will be reported multiple times' +# Scoped messages do not leave block with an exception +not ok {test-number} - false with 1 message: 'Should be in scope at the end' +# Scoped messages outlive section end +ok {test-number} - true with 1 message: 'Should survive a section end' +# Scoped messages outlive section end +not ok {test-number} - false with 1 message: 'Should survive a section end' # Some simple comparisons between doubles ok {test-number} - d == Approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Some simple comparisons between doubles @@ -4556,5 +4572,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2285 +1..2293 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 9b666cc0..388164ef 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -56,7 +56,7 @@ ##teamcity[testIgnored name='#2615 - Throwing in constructor generator fails test case but does not abort' message='Generators.tests.cpp:|n...............................................................................|n|nGenerators.tests.cpp:|nunexpected exception with message:|n "failure to init"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#2615 - Throwing in constructor generator fails test case but does not abort' duration="{duration}"] ##teamcity[testStarted name='#748 - captures with unexpected exceptions'] -##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|noutside assertions|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with messages:|n "answer := 42"|n "expected exception"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|noutside assertions|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "expected exception"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|ninside REQUIRE_NOTHROW|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with messages:|n "answer := 42"|n "expected exception"|n REQUIRE_NOTHROW( thisThrows() )|nwith expansion:|n thisThrows()|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#748 - captures with unexpected exceptions' duration="{duration}"] ##teamcity[testStarted name='#809'] @@ -239,6 +239,12 @@ ##teamcity[testFinished name='CAPTURE parses string and character constants' duration="{duration}"] ##teamcity[testStarted name='Capture and info messages'] ##teamcity[testFinished name='Capture and info messages' duration="{duration}"] +##teamcity[testStarted name='Captures do not leave block with an exception'] +##teamcity[testFailed name='Captures do not leave block with an exception' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "a := 1"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Captures do not leave block with an exception' duration="{duration}"] +##teamcity[testStarted name='Captures outlive section end'] +##teamcity[testFailed name='Captures outlive section end' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "a := 1"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Captures outlive section end' duration="{duration}"] ##teamcity[testStarted name='CaseInsensitiveEqualsTo is case insensitive'] ##teamcity[testFinished name='CaseInsensitiveEqualsTo is case insensitive' duration="{duration}"] ##teamcity[testStarted name='CaseInsensitiveLess is case insensitive'] @@ -566,6 +572,16 @@ ##teamcity[testFinished name='Scenario: This is a really long scenario name to see how the list command deals with wrapping' duration="{duration}"] ##teamcity[testStarted name='Scenario: Vector resizing affects size and capacity'] ##teamcity[testFinished name='Scenario: Vector resizing affects size and capacity' duration="{duration}"] +##teamcity[testStarted name='Scoped message applies to all assertions in scope'] +##teamcity[testFailed name='Scoped message applies to all assertions in scope' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "This will be reported multiple times"|n CHECK( false )|nwith expansion:|n false|n'] +##teamcity[testFailed name='Scoped message applies to all assertions in scope' message='Message.tests.cpp:|nexpression failed with message:|n "This will be reported multiple times"|n CHECK( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped message applies to all assertions in scope' duration="{duration}"] +##teamcity[testStarted name='Scoped messages do not leave block with an exception'] +##teamcity[testFailed name='Scoped messages do not leave block with an exception' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "Should be in scope at the end"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped messages do not leave block with an exception' duration="{duration}"] +##teamcity[testStarted name='Scoped messages outlive section end'] +##teamcity[testFailed name='Scoped messages outlive section end' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "Should survive a section end"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped messages outlive section end' duration="{duration}"] ##teamcity[testStarted name='Sends stuff to stdout and stderr'] ##teamcity[testStdOut name='Sends stuff to stdout and stderr' out='A string sent directly to stdout|n'] ##teamcity[testStdErr name='Sends stuff to stdout and stderr' out='A string sent directly to stderr|nA string sent to stderr via clog|n'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 69b4a760..1140d12b 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -56,7 +56,7 @@ ##teamcity[testIgnored name='#2615 - Throwing in constructor generator fails test case but does not abort' message='Generators.tests.cpp:|n...............................................................................|n|nGenerators.tests.cpp:|nunexpected exception with message:|n "failure to init"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#2615 - Throwing in constructor generator fails test case but does not abort' duration="{duration}"] ##teamcity[testStarted name='#748 - captures with unexpected exceptions'] -##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|noutside assertions|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with messages:|n "answer := 42"|n "expected exception"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|noutside assertions|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "expected exception"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='#748 - captures with unexpected exceptions' message='-------------------------------------------------------------------------------|ninside REQUIRE_NOTHROW|n-------------------------------------------------------------------------------|nException.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with messages:|n "answer := 42"|n "expected exception"|n REQUIRE_NOTHROW( thisThrows() )|nwith expansion:|n thisThrows()|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#748 - captures with unexpected exceptions' duration="{duration}"] ##teamcity[testStarted name='#809'] @@ -239,6 +239,12 @@ ##teamcity[testFinished name='CAPTURE parses string and character constants' duration="{duration}"] ##teamcity[testStarted name='Capture and info messages'] ##teamcity[testFinished name='Capture and info messages' duration="{duration}"] +##teamcity[testStarted name='Captures do not leave block with an exception'] +##teamcity[testFailed name='Captures do not leave block with an exception' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "a := 1"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Captures do not leave block with an exception' duration="{duration}"] +##teamcity[testStarted name='Captures outlive section end'] +##teamcity[testFailed name='Captures outlive section end' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "a := 1"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Captures outlive section end' duration="{duration}"] ##teamcity[testStarted name='CaseInsensitiveEqualsTo is case insensitive'] ##teamcity[testFinished name='CaseInsensitiveEqualsTo is case insensitive' duration="{duration}"] ##teamcity[testStarted name='CaseInsensitiveLess is case insensitive'] @@ -566,6 +572,16 @@ ##teamcity[testFinished name='Scenario: This is a really long scenario name to see how the list command deals with wrapping' duration="{duration}"] ##teamcity[testStarted name='Scenario: Vector resizing affects size and capacity'] ##teamcity[testFinished name='Scenario: Vector resizing affects size and capacity' duration="{duration}"] +##teamcity[testStarted name='Scoped message applies to all assertions in scope'] +##teamcity[testFailed name='Scoped message applies to all assertions in scope' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "This will be reported multiple times"|n CHECK( false )|nwith expansion:|n false|n'] +##teamcity[testFailed name='Scoped message applies to all assertions in scope' message='Message.tests.cpp:|nexpression failed with message:|n "This will be reported multiple times"|n CHECK( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped message applies to all assertions in scope' duration="{duration}"] +##teamcity[testStarted name='Scoped messages do not leave block with an exception'] +##teamcity[testFailed name='Scoped messages do not leave block with an exception' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "Should be in scope at the end"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped messages do not leave block with an exception' duration="{duration}"] +##teamcity[testStarted name='Scoped messages outlive section end'] +##teamcity[testFailed name='Scoped messages outlive section end' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with message:|n "Should survive a section end"|n REQUIRE( false )|nwith expansion:|n false|n'] +##teamcity[testFinished name='Scoped messages outlive section end' duration="{duration}"] ##teamcity[testStarted name='Sends stuff to stdout and stderr'] ##teamcity[testStdOut name='Sends stuff to stdout and stderr' out='A string sent directly to stdout|n'] ##teamcity[testStdErr name='Sends stuff to stdout and stderr' out='A string sent directly to stderr|nA string sent to stderr via clog|n'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 26996f16..e004b390 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -683,9 +683,6 @@ Nor would this
- - answer := 42 - {Unknown expression after the reported line} @@ -3090,6 +3087,48 @@ Approx( 1.23399996757507324 )
+ + + a := 1 + + + + false + + + false + + + + + +
+ + a := 1 + + + + true + + + true + + + +
+ + a := 1 + + + + false + + + false + + + +
@@ -12893,6 +12932,73 @@ All available test cases:
+ + + This will be reported multiple times + + + + false + + + false + + + + This will be reported multiple times + + + + false + + + false + + + + + + + Should be in scope at the end + + + + false + + + false + + + + + +
+ + Should survive a section end + + + + true + + + true + + + +
+ + Should survive a section end + + + + false + + + false + + + +
@@ -22007,6 +22113,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 0223edc1..897c955d 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -683,9 +683,6 @@ Nor would this
- - answer := 42 - {Unknown expression after the reported line} @@ -3090,6 +3087,48 @@ Approx( 1.23399996757507324 )
+ + + a := 1 + + + + false + + + false + + + + + +
+ + a := 1 + + + + true + + + true + + + +
+ + a := 1 + + + + false + + + false + + + +
@@ -12893,6 +12932,73 @@ All available test cases:
+ + + This will be reported multiple times + + + + false + + + false + + + + This will be reported multiple times + + + + false + + + false + + + + + + + Should be in scope at the end + + + + false + + + false + + + + + +
+ + Should survive a section end + + + + true + + + true + + + +
+ + Should survive a section end + + + + false + + + false + + + +
@@ -22006,6 +22112,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 7626e005..07d3ee7b 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -310,3 +310,53 @@ TEST_CASE( "INFO and UNSCOPED_INFO can stream multiple arguments", << " parts." ); FAIL( "Show infos!" ); } + +TEST_CASE( "Scoped messages do not leave block with an exception", "[messages][info][.failing]" ) { + INFO( "Should be in scope at the end" ); + { INFO( "This should go out of scope immediately" ); } + + try { + INFO( "Should not be in scope at the end" ); + throw std::runtime_error( "ex" ); + } catch (std::exception const&) {} + + REQUIRE( false ); +} + +TEST_CASE( "Captures do not leave block with an exception", + "[messages][capture][.failing]" ) { + int a = 1, b = 2, c = 3; + + CAPTURE( a ); + { CAPTURE( b ); } + + try { + CAPTURE( c ); + throw std::runtime_error( "ex" ); + } catch ( std::exception const& ) {} + + REQUIRE( false ); +} + +TEST_CASE( "Scoped messages outlive section end", + "[messages][info][.failing]" ) { + INFO( "Should survive a section end" ); + SECTION( "Dummy section" ) { CHECK( true ); } + + REQUIRE( false ); +} + +TEST_CASE( "Captures outlive section end", "[messages][info][.failing]" ) { + int a = 1; + CAPTURE( a ); + SECTION( "Dummy section" ) { CHECK( true ); } + + REQUIRE( false ); +} + +TEST_CASE( "Scoped message applies to all assertions in scope", + "[messages][info][.failing]" ) { + INFO( "This will be reported multiple times" ); + CHECK( false ); + CHECK( false ); +}