Catch exceptions from StringMakers inside Detail::stringify

This stops tests failing falsely if the assertion passed, but the
stringification itself failed as the assertion was sent to the reporter.

I don't think that stringification should be fallible, but the
overhead in compilation ended up being small enough (<0.5% on `SelfTest`)
that it might be worth implementing, in case there is more users
with weird `StringMaker`s than just MongoDB.

Closes #2980
This commit is contained in:
Martin Hořeňovský
2025-08-01 23:23:34 +02:00
parent 17fe5eaa5c
commit c5e0ef4e67
20 changed files with 129 additions and 20 deletions

View File

@@ -13725,6 +13725,19 @@ Message from section two
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="Stringifying bla bla bla" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Original>
tos == tos
</Original>
<Expanded>
{ stringification failed with an exception: "Invalid" }
==
{ stringification failed with an exception: "Invalid" }
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="Stringifying char arrays with statically known sizes - char" tags="[toString]" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
<Original>
@@ -22213,6 +22226,6 @@ Approx( -1.95996398454005449 )
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<OverallResults successes="2093" failures="157" expectedFailures="41" skips="12"/>
<OverallResultsCases successes="315" failures="95" expectedFailures="17" skips="6"/>
<OverallResults successes="2094" failures="157" expectedFailures="41" skips="12"/>
<OverallResultsCases successes="316" failures="95" expectedFailures="17" skips="6"/>
</Catch2TestRun>