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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-07-27 20:28:51 +0200
committerMartin Hořeňovský2025-07-27 21:41:02 +0200
commitd547cae549f484dda3c6a2b3cc5f71b9db40e842 (patch)
treefb947c6dd70b9eb5e8d7fd792bd85684b454d0fd /tests/SelfTest
parentfee81626d2a4811095c3a39d20fb355eeb954101 (diff)
downloadcatch3-d547cae549f484dda3c6a2b3cc5f71b9db40e842.tar.gz
Fix bad error reporting for nested exceptions in default configuration
Bad handling of `TestFailureException` when translating unexpected exceptions inside assertion macros led to the unexpected exceptions handling erroring out through throwing the same exception again. This was then backstopped by the machinery for handling uncaught exceptions from assertions, which is normally used by the `CATCH_CONFIG_FAST_COMPILE` machinery, where we assume that it can only be invoked because the assertion macros are not configured to catch assertions. Closes #1292
Diffstat (limited to 'tests/SelfTest')
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/automake.sw.multi.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/compact.sw.multi.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt51
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt54
-rw-r--r--tests/SelfTest/Baselines/console.sw.multi.approved.txt54
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt48
-rw-r--r--tests/SelfTest/Baselines/junit.sw.multi.approved.txt48
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt43
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt43
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt16
-rw-r--r--tests/SelfTest/Baselines/tap.sw.multi.approved.txt16
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt12
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt12
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt73
-rw-r--r--tests/SelfTest/Baselines/xml.sw.multi.approved.txt73
-rw-r--r--tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp25
18 files changed, 578 insertions, 18 deletions
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index c5f538ff..63420188 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -95,6 +95,8 @@ Nor would this
:test-result: PASS Approximate comparisons with mixed numeric types
:test-result: PASS Arbitrary predicate matcher
:test-result: PASS Assertion macros support bit operators and bool conversions
+:test-result: XFAIL Assertions can be nested - CHECK
+:test-result: XFAIL Assertions can be nested - REQUIRE
:test-result: PASS Assertions then sections
:test-result: PASS Basic use of the Contains range matcher
:test-result: PASS Basic use of the Empty range matcher
@@ -153,6 +155,7 @@ Nor would this
:test-result: PASS Exceptions matchers
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
:test-result: FAIL FAIL aborts the test
+:test-result: XFAIL FAIL can be nested in assertion
:test-result: FAIL FAIL does not require an argument
:test-result: FAIL FAIL_CHECK does not abort the test
:test-result: PASS Factorials are computed
diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
index b573f81e..21725c68 100644
--- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
@@ -93,6 +93,8 @@
:test-result: PASS Approximate comparisons with mixed numeric types
:test-result: PASS Arbitrary predicate matcher
:test-result: PASS Assertion macros support bit operators and bool conversions
+:test-result: XFAIL Assertions can be nested - CHECK
+:test-result: XFAIL Assertions can be nested - REQUIRE
:test-result: PASS Assertions then sections
:test-result: PASS Basic use of the Contains range matcher
:test-result: PASS Basic use of the Empty range matcher
@@ -151,6 +153,7 @@
:test-result: PASS Exceptions matchers
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
:test-result: FAIL FAIL aborts the test
+:test-result: XFAIL FAIL can be nested in assertion
:test-result: FAIL FAIL does not require an argument
:test-result: FAIL FAIL_CHECK does not abort the test
:test-result: PASS Factorials are computed
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 008d627c..84b00a50 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -332,6 +332,11 @@ Compilation.tests.cpp:<line number>: passed: !(lhs & rhs) for: !(Val: 1 & Val: 2
Compilation.tests.cpp:<line number>: passed: HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1
Compilation.tests.cpp:<line number>: passed: lhs ^ rhs for: Val: 1 ^ Val: 2
Compilation.tests.cpp:<line number>: passed: !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1)
+AssertionHandler.tests.cpp:<line number>: failed: i > 10 for: 2 > 10
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
+AssertionHandler.tests.cpp:<line number>: passed: true
+AssertionHandler.tests.cpp:<line number>: failed: i > 10 for: 2 > 10
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
Tricky.tests.cpp:<line number>: passed: true
Tricky.tests.cpp:<line number>: passed: true
Tricky.tests.cpp:<line number>: passed: true
@@ -636,6 +641,8 @@ Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'e
Exception.tests.cpp:<line number>: failed: expected exception, got none; expression was: thisDoesntThrow(), std::domain_error
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows()
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
+AssertionHandler.tests.cpp:<line number>: failed: explicitly with 1 message: 'Throw a Catch::TestFailureException'
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: do_fail()
Message.tests.cpp:<line number>: failed: explicitly
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
Message.tests.cpp:<line number>: warning: 'This message appears in the output'
@@ -2862,7 +2869,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: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected
-assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected
+test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
+assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index 57303829..dc500516 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -330,6 +330,11 @@ Compilation.tests.cpp:<line number>: passed: !(lhs & rhs) for: !(Val: 1 & Val: 2
Compilation.tests.cpp:<line number>: passed: HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1
Compilation.tests.cpp:<line number>: passed: lhs ^ rhs for: Val: 1 ^ Val: 2
Compilation.tests.cpp:<line number>: passed: !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1)
+AssertionHandler.tests.cpp:<line number>: failed: i > 10 for: 2 > 10
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
+AssertionHandler.tests.cpp:<line number>: passed: true
+AssertionHandler.tests.cpp:<line number>: failed: i > 10 for: 2 > 10
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
Tricky.tests.cpp:<line number>: passed: true
Tricky.tests.cpp:<line number>: passed: true
Tricky.tests.cpp:<line number>: passed: true
@@ -634,6 +639,8 @@ Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'e
Exception.tests.cpp:<line number>: failed: expected exception, got none; expression was: thisDoesntThrow(), std::domain_error
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows()
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
+AssertionHandler.tests.cpp:<line number>: failed: explicitly with 1 message: 'Throw a Catch::TestFailureException'
+AssertionHandler.tests.cpp:<line number>: failed: unexpected exception with message: '{ nested assertion failed }'; expression was: do_fail()
Message.tests.cpp:<line number>: failed: explicitly
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'This is a failure'
Message.tests.cpp:<line number>: warning: 'This message appears in the output'
@@ -2851,7 +2858,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: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected
-assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected
+test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
+assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 194b3676..96f43224 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -348,6 +348,38 @@ due to unexpected exception with message:
unexpected exception
-------------------------------------------------------------------------------
+Assertions can be nested - CHECK
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
+Assertions can be nested - REQUIRE
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
Captures do not leave block with an exception
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
@@ -620,6 +652,21 @@ explicitly with message:
This is a failure
-------------------------------------------------------------------------------
+FAIL can be nested in assertion
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+explicitly with message:
+ Throw a Catch::TestFailureException
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK_NOTHROW( do_fail() )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
FAIL does not require an argument
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
@@ -1672,6 +1719,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 428 | 331 passed | 76 failed | 7 skipped | 14 failed as expected
-assertions: 2260 | 2089 passed | 136 failed | 35 failed as expected
+test cases: 431 | 331 passed | 76 failed | 7 skipped | 17 failed as expected
+assertions: 2267 | 2090 passed | 136 failed | 41 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 1740933b..efb96e04 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -2567,6 +2567,41 @@ with expansion:
!(Val: 1 ^ Val: 1)
-------------------------------------------------------------------------------
+Assertions can be nested - CHECK
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+AssertionHandler.tests.cpp:<line number>: PASSED:
+ CHECK( true )
+
+-------------------------------------------------------------------------------
+Assertions can be nested - REQUIRE
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
Assertions then sections
-------------------------------------------------------------------------------
Tricky.tests.cpp:<line number>
@@ -4562,6 +4597,21 @@ explicitly with message:
This is a failure
-------------------------------------------------------------------------------
+FAIL can be nested in assertion
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+explicitly with message:
+ Throw a Catch::TestFailureException
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK_NOTHROW( do_fail() )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
FAIL does not require an argument
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
@@ -19134,6 +19184,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected
-assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected
+test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
+assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index 786ad4e9..0a84798a 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -2565,6 +2565,41 @@ with expansion:
!(Val: 1 ^ Val: 1)
-------------------------------------------------------------------------------
+Assertions can be nested - CHECK
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+AssertionHandler.tests.cpp:<line number>: PASSED:
+ CHECK( true )
+
+-------------------------------------------------------------------------------
+Assertions can be nested - REQUIRE
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
Assertions then sections
-------------------------------------------------------------------------------
Tricky.tests.cpp:<line number>
@@ -4560,6 +4595,21 @@ explicitly with message:
This is a failure
-------------------------------------------------------------------------------
+FAIL can be nested in assertion
+-------------------------------------------------------------------------------
+AssertionHandler.tests.cpp:<line number>
+...............................................................................
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+explicitly with message:
+ Throw a Catch::TestFailureException
+
+AssertionHandler.tests.cpp:<line number>: FAILED:
+ CHECK_NOTHROW( do_fail() )
+due to unexpected exception with message:
+ { nested assertion failed }
+
+-------------------------------------------------------------------------------
FAIL does not require an argument
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
@@ -19123,6 +19173,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected
-assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected
+test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
+assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index f4e3bb0e..5c3af7bb 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="2293" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2300" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -390,6 +390,38 @@ at Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Arbitrary predicate matcher/Function pointer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Arbitrary predicate matcher/Lambdas + different type" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertion macros support bit operators and bool conversions" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="Assertions can be nested - CHECK" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="i > 10" type="REQUIRE">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="foo( 2 ) == 2" type="CHECK">
+FAILED:
+ CHECK( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
+ <testcase classname="<exe-name>.global" name="Assertions can be nested - REQUIRE" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="i > 10" type="REQUIRE">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="foo( 2 ) == 2" type="REQUIRE">
+FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
<testcase classname="<exe-name>.global" name="Assertions then sections" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another section" time="{duration}" status="run"/>
@@ -738,6 +770,20 @@ This is a failure
at Message.tests.cpp:<line number>
</failure>
</testcase>
+ <testcase classname="<exe-name>.global" name="FAIL can be nested in assertion" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure type="FAIL">
+FAILED:
+Throw a Catch::TestFailureException
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="do_fail()" type="CHECK_NOTHROW">
+FAILED:
+ CHECK_NOTHROW( do_fail() )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
index 0a205437..7b4563ff 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="2293" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="140" skipped="12" tests="2300" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -389,6 +389,38 @@ at Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Arbitrary predicate matcher/Function pointer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Arbitrary predicate matcher/Lambdas + different type" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertion macros support bit operators and bool conversions" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="Assertions can be nested - CHECK" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="i > 10" type="REQUIRE">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="foo( 2 ) == 2" type="CHECK">
+FAILED:
+ CHECK( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
+ <testcase classname="<exe-name>.global" name="Assertions can be nested - REQUIRE" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure message="i > 10" type="REQUIRE">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="foo( 2 ) == 2" type="REQUIRE">
+FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
<testcase classname="<exe-name>.global" name="Assertions then sections" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another section" time="{duration}" status="run"/>
@@ -737,6 +769,20 @@ This is a failure
at Message.tests.cpp:<line number>
</failure>
</testcase>
+ <testcase classname="<exe-name>.global" name="FAIL can be nested in assertion" time="{duration}" status="run">
+ <skipped message="TEST_CASE tagged with !mayfail"/>
+ <failure type="FAIL">
+FAILED:
+Throw a Catch::TestFailureException
+at AssertionHandler.tests.cpp:<line number>
+ </failure>
+ <error message="do_fail()" type="CHECK_NOTHROW">
+FAILED:
+ CHECK_NOTHROW( do_fail() )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </error>
+ </testcase>
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}" status="run">
<failure type="FAIL">
FAILED:
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index d25bceda..b97312d2 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -3,6 +3,49 @@
<testExecutions version="1"loose text artifact
>
<file path="tests/<exe-name>/IntrospectiveTests/AssertionHandler.tests.cpp">
+ <testCase name="Assertions can be nested - CHECK" duration="{duration}">
+ <skipped message="REQUIRE(i > 10)">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="CHECK(foo( 2 ) == 2)">
+FAILED:
+ CHECK( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
+ <testCase name="Assertions can be nested - REQUIRE" duration="{duration}">
+ <skipped message="REQUIRE(i > 10)">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="REQUIRE(foo( 2 ) == 2)">
+FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
+ <testCase name="FAIL can be nested in assertion" duration="{duration}">
+ <skipped message="FAIL()">
+FAILED:
+Throw a Catch::TestFailureException
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="CHECK_NOTHROW(do_fail())">
+FAILED:
+ CHECK_NOTHROW( do_fail() )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
<testCase name="Incomplete AssertionHandler" duration="{duration}">
<skipped message="REQUIRE(Dummy)">
FAILED:
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index 66b2c832..43493ebf 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -2,6 +2,49 @@
<!-- filters='"*" ~[!nonportable] ~[!benchmark] ~[approvals]' rng-seed=1 -->
<testExecutions version="1">
<file path="tests/<exe-name>/IntrospectiveTests/AssertionHandler.tests.cpp">
+ <testCase name="Assertions can be nested - CHECK" duration="{duration}">
+ <skipped message="REQUIRE(i > 10)">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="CHECK(foo( 2 ) == 2)">
+FAILED:
+ CHECK( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
+ <testCase name="Assertions can be nested - REQUIRE" duration="{duration}">
+ <skipped message="REQUIRE(i > 10)">
+FAILED:
+ REQUIRE( i > 10 )
+with expansion:
+ 2 > 10
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="REQUIRE(foo( 2 ) == 2)">
+FAILED:
+ REQUIRE( foo( 2 ) == 2 )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
+ <testCase name="FAIL can be nested in assertion" duration="{duration}">
+ <skipped message="FAIL()">
+FAILED:
+Throw a Catch::TestFailureException
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ <skipped message="CHECK_NOTHROW(do_fail())">
+FAILED:
+ CHECK_NOTHROW( do_fail() )
+{ nested assertion failed }
+at AssertionHandler.tests.cpp:<line number>
+ </skipped>
+ </testCase>
<testCase name="Incomplete AssertionHandler" duration="{duration}">
<skipped message="REQUIRE(Dummy)">
FAILED:
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index c7f2f3a5..ed79ca8d 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -612,6 +612,16 @@ ok {test-number} - HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val
ok {test-number} - lhs ^ rhs for: Val: 1 ^ Val: 2
# Assertion macros support bit operators and bool conversions
ok {test-number} - !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1)
+# Assertions can be nested - CHECK
+not ok {tes