diff options
| author | Martin Hořeňovský | 2026-01-08 14:35:05 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-01-11 14:53:08 +0100 |
| commit | 2580eadc4230eedf1b66841bdd27a8aacc2412a5 (patch) | |
| tree | ba8508f3ab737c0b9d11a2fd5c33d0bdbfcd457e /tests | |
| parent | b59f4f352291a89c4a3fe1488eeccbddeea85625 (diff) | |
| download | catch3-2580eadc4230eedf1b66841bdd27a8aacc2412a5.tar.gz | |
Add UNSCOPED_CAPTURE
Closes #2954
Closes #3010
Diffstat (limited to 'tests')
20 files changed, 196 insertions, 18 deletions
diff --git a/tests/ExtraTests/X01-PrefixedMacros.cpp b/tests/ExtraTests/X01-PrefixedMacros.cpp index d1c246ec..d2d05528 100644 --- a/tests/ExtraTests/X01-PrefixedMacros.cpp +++ b/tests/ExtraTests/X01-PrefixedMacros.cpp @@ -67,6 +67,7 @@ CATCH_TEST_CASE("PrefixedMacros") { int i = 1; CATCH_CAPTURE( i ); CATCH_CAPTURE( i, i + 1 ); + CATCH_UNSCOPED_CAPTURE( i + 2, i + 3 ); CATCH_DYNAMIC_SECTION("Dynamic section: " << i) { CATCH_FAIL_CHECK( "failure" ); } diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp index 231adfb0..0c051acc 100644 --- a/tests/ExtraTests/X02-DisabledMacros.cpp +++ b/tests/ExtraTests/X02-DisabledMacros.cpp @@ -48,6 +48,7 @@ TEST_CASE( "Disabled Macros" ) { CAPTURE( 1 ); CAPTURE( 1, "captured" ); + UNSCOPED_CAPTURE( 3 ); REQUIRE_THAT( 1, Catch::Matchers::Predicate( []( int ) { return false; } ) ); @@ -68,6 +69,7 @@ TEST_CASE_PERSISTENT_FIXTURE( DisabledFixture, "Disabled Persistent Fixture" ) { CAPTURE( 1 ); CAPTURE( 1, "captured" ); + UNSCOPED_CAPTURE( 3 ); REQUIRE_THAT( 1, Catch::Matchers::Predicate( []( int ) { return false; } ) ); diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 6b0ac614..05c6384b 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -299,6 +299,7 @@ Message from section two :test-result: PASS Trim strings :test-result: PASS Type conversions of RangeEquals and similar :test-result: FAIL Unexpected exceptions can be translated +:test-result: FAIL Unscoped capture outlives scope :test-result: PASS Upcasting special member functions :test-result: PASS Usage of AllMatch range matcher :test-result: PASS Usage of AllTrue range matcher diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 54d1c58f..75c116d5 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -292,6 +292,7 @@ :test-result: PASS Trim strings :test-result: PASS Type conversions of RangeEquals and similar :test-result: FAIL Unexpected exceptions can be translated +:test-result: FAIL Unscoped capture outlives scope :test-result: PASS Upcasting special member functions :test-result: PASS Usage of AllMatch range matcher :test-result: PASS Usage of AllTrue range matcher diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 29a1017c..ea8d519a 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -2205,6 +2205,7 @@ MatchersRanges.tests.cpp:<line number>: passed: a, UnorderedRangeEquals( b ) for MatchersRanges.tests.cpp:<line number>: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } MatchersRanges.tests.cpp:<line number>: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14000000000000012' +Message.tests.cpp:<line number>: failed: false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3' UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 MatchersRanges.tests.cpp:<line number>: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 @@ -2894,7 +2895,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed: -test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected -assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected +test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 5e9a32c7..dbfab609 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -2198,6 +2198,7 @@ MatchersRanges.tests.cpp:<line number>: passed: a, UnorderedRangeEquals( b ) for MatchersRanges.tests.cpp:<line number>: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } MatchersRanges.tests.cpp:<line number>: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14000000000000012' +Message.tests.cpp:<line number>: failed: false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3' UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 MatchersRanges.tests.cpp:<line number>: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 @@ -2883,7 +2884,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed: -test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected -assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected +test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 8c7f79da..7de7b1f9 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1204,6 +1204,19 @@ due to unexpected exception with message: 3.14000000000000012 ------------------------------------------------------------------------------- +Unscoped capture outlives scope +------------------------------------------------------------------------------- +Message.tests.cpp:<line number> +............................................................................... + +Message.tests.cpp:<line number>: FAILED: + REQUIRE( false ) +with messages: + i := 1 + j := 2 + i + j := 3 + +------------------------------------------------------------------------------- Vector Approx matcher -- failing Empty and non empty vectors are not approx equal ------------------------------------------------------------------------------- @@ -1730,6 +1743,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 436 | 335 passed | 76 failed | 7 skipped | 18 failed as expected -assertions: 2288 | 2110 passed | 136 failed | 42 failed as expected +test cases: 437 | 335 passed | 76 failed | 7 skipped | 19 failed as expected +assertions: 2289 | 2110 passed | 136 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index d6e61ff6..ab18d08c 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -14325,6 +14325,29 @@ due to unexpected exception with message: 3.14000000000000012 ------------------------------------------------------------------------------- +Unscoped capture outlives scope + A +------------------------------------------------------------------------------- +Message.tests.cpp:<line number> +............................................................................... + + +No assertions in section 'A' + +------------------------------------------------------------------------------- +Unscoped capture outlives scope +------------------------------------------------------------------------------- +Message.tests.cpp:<line number> +............................................................................... + +Message.tests.cpp:<line number>: FAILED: + REQUIRE( false ) +with messages: + i := 1 + j := 2 + i + j := 3 + +------------------------------------------------------------------------------- Upcasting special member functions Move constructor ------------------------------------------------------------------------------- @@ -19349,6 +19372,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected -assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected +test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 9bd865da..05d6eb6c 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -14318,6 +14318,29 @@ due to unexpected exception with message: 3.14000000000000012 ------------------------------------------------------------------------------- +Unscoped capture outlives scope + A +------------------------------------------------------------------------------- +Message.tests.cpp:<line number> +............................................................................... + + +No assertions in section 'A' + +------------------------------------------------------------------------------- +Unscoped capture outlives scope +------------------------------------------------------------------------------- +Message.tests.cpp:<line number> +............................................................................... + +Message.tests.cpp:<line number>: FAILED: + REQUIRE( false ) +with messages: + i := 1 + j := 2 + i + j := 3 + +------------------------------------------------------------------------------- Upcasting special member functions Move constructor ------------------------------------------------------------------------------- @@ -19338,6 +19361,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 436 | 317 passed | 95 failed | 6 skipped | 18 failed as expected -assertions: 2309 | 2110 passed | 157 failed | 42 failed as expected +test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 24d16a96..10523416 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuitesloose text artifact > - <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2321" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -1694,6 +1694,18 @@ FAILED: at Exception.tests.cpp:<line number> </error> </testcase> + <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope" time="{duration}" status="run"> + <skipped message="TEST_CASE tagged with !mayfail"/> + <failure message="false" type="REQUIRE"> +FAILED: + REQUIRE( false ) +i := 1 +j := 2 +i + j := 3 +at Message.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope/A" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 21e6a885..2199b7f7 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuites> - <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2321" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -1693,6 +1693,18 @@ FAILED: at Exception.tests.cpp:<line number> </error> </testcase> + <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope" time="{duration}" status="run"> + <skipped message="TEST_CASE tagged with !mayfail"/> + <failure message="false" type="REQUIRE"> +FAILED: + REQUIRE( false ) +i := 1 +j := 2 +i + j := 3 +at Message.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.global" name="Unscoped capture outlives scope/A" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 184bdf71..27dc2cdd 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -1833,6 +1833,17 @@ at Message.tests.cpp:<line number> <testCase name="Standard output from all sections is reported/one" duration="{duration}"/> <testCase name="Standard output from all sections is reported/two" duration="{duration}"/> <testCase name="The NO_FAIL macro reports a failure but does not fail the test" duration="{duration}"/> + <testCase name="Unscoped capture outlives scope" duration="{duration}"> + <skipped message="REQUIRE(false)"> +FAILED: + REQUIRE( false ) +i := 1 +j := 2 +i + j := 3 +at Message.tests.cpp:<line number> + </skipped> + </testCase> + <testCase name="Unscoped capture outlives scope/A" duration="{duration}"/> <testCase name="just failure" duration="{duration}"> <failure message="FAIL()"> FAILED: diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index c7dc1ce0..93e3bcc8 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -1832,6 +1832,17 @@ at Message.tests.cpp:<line number> <testCase name="Standard output from all sections is reported/one" duration="{duration}"/> <testCase name="Standard output from all sections is reported/two" duration="{duration}"/> <testCase name="The NO_FAIL macro reports a failure but does not fail the test" duration="{duration}"/> + <testCase name="Unscoped capture outlives scope" duration="{duration}"> + <skipped message="REQUIRE(false)"> +FAILED: + REQUIRE( false ) +i := 1 +j := 2 +i + j := 3 +at Message.tests.cpp:<line number> + </skipped> + </testCase> + <testCase name="Unscoped capture outlives scope/A" duration="{duration}"/> <testCase name="just failure" duration="{duration}"> <failure message="FAIL()"> FAILED: diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index c9498ec5..0b5e1c91 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -3417,6 +3417,8 @@ ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated not ok {test-number} - unexpected exception with message: '3.14000000000000012' +# Unscoped capture outlives scope +not ok {test-number} - false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3' # Upcasting special member functions ok {test-number} - bptr->i == 3 for: 3 == 3 # Upcasting special member functions @@ -4639,5 +4641,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2321 +1..2323 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 4d86c1c1..de5c68fb 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -3410,6 +3410,8 @@ ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated not ok {test-number} - unexpected exception with message: '3.14000000000000012' +# Unscoped capture outlives scope +not ok {test-number} - false with 3 messages: 'i := 1' and 'j := 2' and 'i + j := 3' # Upcasting special member functions ok {test-number} - bptr->i == 3 for: 3 == 3 # Upcasting special member functions @@ -4628,5 +4630,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2321 +1..2323 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index e911941c..45e97905 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -727,6 +727,9 @@ ##teamcity[testStarted name='Unexpected exceptions can be translated'] ##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:<line number>|n...............................................................................|n|nException.tests.cpp:<line number>|nunexpected exception with message:|n "3.14000000000000012"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] +##teamcity[testStarted name='Unscoped capture outlives scope'] +##teamcity[testIgnored name='Unscoped capture outlives scope' message='Message.tests.cpp:<line number>|n...............................................................................|n|nMessage.tests.cpp:<line number>|nexpression failed with messages:|n "i := 1"|n "j := 2"|n "i + j := 3"|n REQUIRE( false )|nwith expansion:|n false|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Unscoped capture outlives scope' duration="{duration}"] ##teamcity[testStarted name='Upcasting special member functions'] ##teamcity[testFinished name='Upcasting special member functions' duration="{duration}"] ##teamcity[testStarted name='Usage of AllMatch range matcher'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 2c7f78e2..787bd222 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -727,6 +727,9 @@ ##teamcity[testStarted name='Unexpected exceptions can be translated'] ##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:<line number>|n...............................................................................|n|nException.tests.cpp:<line number>|nunexpected exception with message:|n "3.14000000000000012"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] +##teamcity[testStarted name='Unscoped capture outlives scope'] +##teamcity[testIgnored name='Unscoped capture outlives scope' message='Message.tests.cpp:<line number>|n...............................................................................|n|nMessage.tests.cpp:<line number>|nexpression failed with messages:|n "i := 1"|n "j := 2"|n "i + j := 3"|n REQUIRE( false )|nwith expansion:|n false|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testFinished name='Unscoped capture outlives scope' duration="{duration}"] ##teamcity[testStarted name='Upcasting special member functions'] ##teamcity[testFinished name='Upcasting special member functions' duration="{duration}"] ##teamcity[testStarted name='Usage of AllMatch range matcher'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index d2fea72f..95a7cb2f 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -16561,6 +16561,29 @@ There is no extra whitespace here </Exception> <OverallResult success="false" skips="0"/> </TestCase> + <TestCase name="Unscoped capture outlives scope" tags="[!shouldfail][capture][messages][unscoped]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <Section name="A" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <OverallResults successes="0" failures="1" expectedFailures="0" skipped="false"/> + </Section> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + i := 1 + </Info> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + j := 2 + </Info> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + i + j := 3 + </Info> + <Expression success="false" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <Original> + false + </Original> + <Expanded> + false + </Expanded> + </Expression> + <OverallResult success="false" skips="0"/> + </TestCase> <TestCase name="Upcasting special member functions" tags="[internals][unique-ptr]" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > <Section name="Move constructor" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > @@ -22393,6 +22416,6 @@ Approx( -1.95996398454005449 ) </Section> <OverallResult success="true" skips="0"/> </TestCase> - <OverallResults successes="2110" failures="157" expectedFailures="42" skips="12"/> - <OverallResultsCases successes="317" failures="95" expectedFailures="18" skips="6"/> + <OverallResults successes="2110" failures="158" expectedFailures="43" skips="12"/> + <OverallResultsCases successes="317" failures="96" expectedFailures="18" skips="6"/> </Catch2TestRun> diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 43afc154..68ae54fe 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -16561,6 +16561,29 @@ There is no extra whitespace here </Exception> <OverallResult success="false" skips="0"/> </TestCase> + <TestCase name="Unscoped capture outlives scope" tags="[!shouldfail][capture][messages][unscoped]" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <Section name="A" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <OverallResults successes="0" failures="1" expectedFailures="0" skipped="false"/> + </Section> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + i := 1 + </Info> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + j := 2 + </Info> + <Info filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + i + j := 3 + </Info> + <Expression success="false" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Message.tests.cpp" > + <Original> + false + </Original> + <Expanded> + false + </Expanded> + </Expression> + <OverallResult success="false" skips="0"/> + </TestCase> <TestCase name="Upcasting special member functions" tags="[internals][unique-ptr]" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > <Section name="Move constructor" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp" > @@ -22392,6 +22415,6 @@ Approx( -1.95996398454005449 ) </Section> <OverallResult success="true" skips="0"/> </TestCase> - <OverallResults successes="2110" failures="157" expectedFailures="42" skips="12"/> - <OverallResultsCases successes="317" failures="95" expectedFailures="18" skips="6"/> + <OverallResults successes="2110" failures="158" expectedFailures="43" skips="12"/> + <OverallResultsCases successes="317" failures="96" expectedFailures="18" skips="6"/> </Catch2TestRun> diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 594e8892..9d2a2f5e 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -369,3 +369,13 @@ TEST_CASE( UNSCOPED_INFO( "b" ); REQUIRE( false ); } + +TEST_CASE( "Unscoped capture outlives scope", + "[messages][unscoped][capture][!shouldfail]" ) { + int i = 1; + SECTION( "A" ) { + int j = 2; + UNSCOPED_CAPTURE( i, j, i + j ); + } + REQUIRE( false ); +} |