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
This commit is contained in:
Martin Hořeňovský
2025-07-27 20:28:51 +02:00
parent fee81626d2
commit d547cae549
21 changed files with 595 additions and 23 deletions

View File

@@ -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 {test-number} - i > 10 for: 2 > 10
# Assertions can be nested - CHECK
not ok {test-number} - unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
# Assertions can be nested - CHECK
ok {test-number} - true
# Assertions can be nested - REQUIRE
not ok {test-number} - i > 10 for: 2 > 10
# Assertions can be nested - REQUIRE
not ok {test-number} - unexpected exception with message: '{ nested assertion failed }'; expression was: foo( 2 ) == 2
# Assertions then sections
ok {test-number} - true
# Assertions then sections
@@ -1132,6 +1142,10 @@ not ok {test-number} - expected exception, got none; expression was: thisDoesntT
not ok {test-number} - unexpected exception with message: 'expected exception'; expression was: thisThrows()
# FAIL aborts the test
not ok {test-number} - explicitly with 1 message: 'This is a failure'
# FAIL can be nested in assertion
not ok {test-number} - explicitly with 1 message: 'Throw a Catch::TestFailureException'
# FAIL can be nested in assertion
not ok {test-number} - unexpected exception with message: '{ nested assertion failed }'; expression was: do_fail()
# FAIL does not require an argument
not ok {test-number} - explicitly
# FAIL_CHECK does not abort the test
@@ -4583,5 +4597,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2293
1..2300