From 9b3f508a1b1579f5366cf83d19822cb395f23528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 2 Aug 2025 10:21:41 +0200 Subject: [PATCH] Cleanup WIP changes from last commit --- src/catch2/catch_tostring.cpp | 2 -- .../Baselines/automake.sw.approved.txt | 2 +- .../Baselines/automake.sw.multi.approved.txt | 2 +- .../Baselines/compact.sw.approved.txt | 6 ++--- .../Baselines/compact.sw.multi.approved.txt | 6 ++--- .../Baselines/console.sw.approved.txt | 26 +++++++++---------- .../Baselines/console.sw.multi.approved.txt | 26 +++++++++---------- .../SelfTest/Baselines/junit.sw.approved.txt | 2 +- .../Baselines/junit.sw.multi.approved.txt | 2 +- .../Baselines/sonarqube.sw.approved.txt | 2 +- .../Baselines/sonarqube.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/tap.sw.approved.txt | 4 +-- .../Baselines/tap.sw.multi.approved.txt | 4 +-- .../Baselines/teamcity.sw.approved.txt | 4 +-- .../Baselines/teamcity.sw.multi.approved.txt | 4 +-- tests/SelfTest/Baselines/xml.sw.approved.txt | 26 +++++++++---------- .../Baselines/xml.sw.multi.approved.txt | 26 +++++++++---------- .../IntrospectiveTests/ToString.tests.cpp | 2 +- 18 files changed, 73 insertions(+), 75 deletions(-) diff --git a/src/catch2/catch_tostring.cpp b/src/catch2/catch_tostring.cpp index 940e61b5..4d80b173 100644 --- a/src/catch2/catch_tostring.cpp +++ b/src/catch2/catch_tostring.cpp @@ -121,8 +121,6 @@ namespace Detail { } - - } // end Detail namespace diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index aec224fa..2c608188 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -153,6 +153,7 @@ Nor would this :test-result: PASS Exception matchers that succeed :test-result: PASS Exception message can be matched :test-result: PASS Exception messages can be tested for +:test-result: PASS Exception thrown inside stringify does not fail the test :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 @@ -248,7 +249,6 @@ Message from section two :test-result: PASS String matchers :test-result: PASS StringRef :test-result: PASS StringRef at compilation time -:test-result: PASS Stringifying bla bla bla :test-result: PASS Stringifying char arrays with statically known sizes - char :test-result: PASS Stringifying char arrays with statically known sizes - signed char :test-result: PASS Stringifying char arrays with statically known sizes - unsigned char diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 74eb7756..6ee054f1 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -151,6 +151,7 @@ :test-result: PASS Exception matchers that succeed :test-result: PASS Exception message can be matched :test-result: PASS Exception messages can be tested for +:test-result: PASS Exception thrown inside stringify does not fail the test :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 @@ -241,7 +242,6 @@ :test-result: PASS String matchers :test-result: PASS StringRef :test-result: PASS StringRef at compilation time -:test-result: PASS Stringifying bla bla bla :test-result: PASS Stringifying char arrays with statically known sizes - char :test-result: PASS Stringifying char arrays with statically known sizes - signed char :test-result: PASS Stringifying char arrays with statically known sizes - unsigned char diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 445f059b..477aa5ff 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -635,6 +635,9 @@ Exception.tests.cpp:: passed: thisThrows(), StartsWith( "expected" Exception.tests.cpp:: passed: thisThrows(), EndsWith( "exception" ) for: "expected exception" ends with: "exception" Exception.tests.cpp:: passed: thisThrows(), ContainsSubstring( "except" ) for: "expected exception" contains: "except" Exception.tests.cpp:: passed: thisThrows(), ContainsSubstring( "exCept", Catch::CaseSensitive::No ) for: "expected exception" contains: "except" (case insensitive) +ToString.tests.cpp:: passed: tos == tos for: { stringification failed with an exception: "Invalid" } +== +{ stringification failed with an exception: "Invalid" } Matchers.tests.cpp:: passed: throwsDerivedException(), DerivedException, Message( "DerivedException::what" ) for: DerivedException::what exception message matches "DerivedException::what" Matchers.tests.cpp:: passed: throwsDerivedException(), DerivedException, !Message( "derivedexception::what" ) for: DerivedException::what not exception message matches "derivedexception::what" Matchers.tests.cpp:: passed: throwsSpecialException( 2 ), SpecialException, !Message( "DerivedException::what" ) for: SpecialException::what not exception message matches "DerivedException::what" @@ -1848,9 +1851,6 @@ String.tests.cpp:: passed: with 1 message: '!(sr1.empty())' String.tests.cpp:: passed: with 1 message: 'sr1.size() == 3' String.tests.cpp:: passed: with 1 message: 'sr2.empty()' String.tests.cpp:: passed: with 1 message: 'sr2.size() == 0' -ToString.tests.cpp:: passed: tos == tos for: { stringification failed with an exception: "Invalid" } -== -{ stringification failed with an exception: "Invalid" } ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( no_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index d85c8f12..d6b9f0c3 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -633,6 +633,9 @@ Exception.tests.cpp:: passed: thisThrows(), StartsWith( "expected" Exception.tests.cpp:: passed: thisThrows(), EndsWith( "exception" ) for: "expected exception" ends with: "exception" Exception.tests.cpp:: passed: thisThrows(), ContainsSubstring( "except" ) for: "expected exception" contains: "except" Exception.tests.cpp:: passed: thisThrows(), ContainsSubstring( "exCept", Catch::CaseSensitive::No ) for: "expected exception" contains: "except" (case insensitive) +ToString.tests.cpp:: passed: tos == tos for: { stringification failed with an exception: "Invalid" } +== +{ stringification failed with an exception: "Invalid" } Matchers.tests.cpp:: passed: throwsDerivedException(), DerivedException, Message( "DerivedException::what" ) for: DerivedException::what exception message matches "DerivedException::what" Matchers.tests.cpp:: passed: throwsDerivedException(), DerivedException, !Message( "derivedexception::what" ) for: DerivedException::what not exception message matches "derivedexception::what" Matchers.tests.cpp:: passed: throwsSpecialException( 2 ), SpecialException, !Message( "DerivedException::what" ) for: SpecialException::what not exception message matches "DerivedException::what" @@ -1841,9 +1844,6 @@ String.tests.cpp:: passed: with 1 message: '!(sr1.empty())' String.tests.cpp:: passed: with 1 message: 'sr1.size() == 3' String.tests.cpp:: passed: with 1 message: 'sr2.empty()' String.tests.cpp:: passed: with 1 message: 'sr2.size() == 0' -ToString.tests.cpp:: passed: tos == tos for: { stringification failed with an exception: "Invalid" } -== -{ stringification failed with an exception: "Invalid" } ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( no_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index ff7fdf04..7da948d1 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -4556,6 +4556,19 @@ Exception.tests.cpp:: PASSED: with expansion: "expected exception" contains: "except" (case insensitive) +------------------------------------------------------------------------------- +Exception thrown inside stringify does not fail the test +------------------------------------------------------------------------------- +ToString.tests.cpp: +............................................................................... + +ToString.tests.cpp:: PASSED: + CHECK( tos == tos ) +with expansion: + { stringification failed with an exception: "Invalid" } + == + { stringification failed with an exception: "Invalid" } + ------------------------------------------------------------------------------- Exceptions matchers ------------------------------------------------------------------------------- @@ -11789,19 +11802,6 @@ String.tests.cpp:: PASSED: with message: sr2.size() == 0 -------------------------------------------------------------------------------- -Stringifying bla bla bla -------------------------------------------------------------------------------- -ToString.tests.cpp: -............................................................................... - -ToString.tests.cpp:: PASSED: - CHECK( tos == tos ) -with expansion: - { stringification failed with an exception: "Invalid" } - == - { stringification failed with an exception: "Invalid" } - ------------------------------------------------------------------------------- Stringifying char arrays with statically known sizes - char ------------------------------------------------------------------------------- diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 9ab35540..27247b0f 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -4554,6 +4554,19 @@ Exception.tests.cpp:: PASSED: with expansion: "expected exception" contains: "except" (case insensitive) +------------------------------------------------------------------------------- +Exception thrown inside stringify does not fail the test +------------------------------------------------------------------------------- +ToString.tests.cpp: +............................................................................... + +ToString.tests.cpp:: PASSED: + CHECK( tos == tos ) +with expansion: + { stringification failed with an exception: "Invalid" } + == + { stringification failed with an exception: "Invalid" } + ------------------------------------------------------------------------------- Exceptions matchers ------------------------------------------------------------------------------- @@ -11782,19 +11795,6 @@ String.tests.cpp:: PASSED: with message: sr2.size() == 0 -------------------------------------------------------------------------------- -Stringifying bla bla bla -------------------------------------------------------------------------------- -ToString.tests.cpp: -............................................................................... - -ToString.tests.cpp:: PASSED: - CHECK( tos == tos ) -with expansion: - { stringification failed with an exception: "Invalid" } - == - { stringification failed with an exception: "Invalid" } - ------------------------------------------------------------------------------- Stringifying char arrays with statically known sizes - char ------------------------------------------------------------------------------- diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 225b1459..3c54c89c 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -744,6 +744,7 @@ at Matchers.tests.cpp: + @@ -1511,7 +1512,6 @@ at Matchers.tests.cpp: - diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 10396194..8d3704c3 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -743,6 +743,7 @@ at Matchers.tests.cpp: + @@ -1510,7 +1511,6 @@ at Matchers.tests.cpp: - diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 7663796e..c7026e37 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -387,8 +387,8 @@ at AssertionHandler.tests.cpp: + - diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index a899aafc..a41578fc 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -386,8 +386,8 @@ at AssertionHandler.tests.cpp: + - diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 5e8e508a..340bbb1e 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -1130,6 +1130,8 @@ ok {test-number} - thisThrows(), EndsWith( "exception" ) for: "expected exceptio ok {test-number} - thisThrows(), ContainsSubstring( "except" ) for: "expected exception" contains: "except" # Exception messages can be tested for ok {test-number} - thisThrows(), ContainsSubstring( "exCept", Catch::CaseSensitive::No ) for: "expected exception" contains: "except" (case insensitive) +# Exception thrown inside stringify does not fail the test +ok {test-number} - tos == tos for: { stringification failed with an exception: "Invalid" } == { stringification failed with an exception: "Invalid" } # Exceptions matchers ok {test-number} - throwsDerivedException(), DerivedException, Message( "DerivedException::what" ) for: DerivedException::what exception message matches "DerivedException::what" # Exceptions matchers @@ -2803,8 +2805,6 @@ ok {test-number} - with 1 message: 'sr1.size() == 3' ok {test-number} - with 1 message: 'sr2.empty()' # StringRef at compilation time ok {test-number} - with 1 message: 'sr2.size() == 0' -# Stringifying bla bla bla -ok {test-number} - tos == tos for: { stringification failed with an exception: "Invalid" } == { stringification failed with an exception: "Invalid" } # Stringifying char arrays with statically known sizes - char ok {test-number} - ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" # Stringifying char arrays with statically known sizes - char diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index a748999c..132ad3de 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -1128,6 +1128,8 @@ ok {test-number} - thisThrows(), EndsWith( "exception" ) for: "expected exceptio ok {test-number} - thisThrows(), ContainsSubstring( "except" ) for: "expected exception" contains: "except" # Exception messages can be tested for ok {test-number} - thisThrows(), ContainsSubstring( "exCept", Catch::CaseSensitive::No ) for: "expected exception" contains: "except" (case insensitive) +# Exception thrown inside stringify does not fail the test +ok {test-number} - tos == tos for: { stringification failed with an exception: "Invalid" } == { stringification failed with an exception: "Invalid" } # Exceptions matchers ok {test-number} - throwsDerivedException(), DerivedException, Message( "DerivedException::what" ) for: DerivedException::what exception message matches "DerivedException::what" # Exceptions matchers @@ -2796,8 +2798,6 @@ ok {test-number} - with 1 message: 'sr1.size() == 3' ok {test-number} - with 1 message: 'sr2.empty()' # StringRef at compilation time ok {test-number} - with 1 message: 'sr2.size() == 0' -# Stringifying bla bla bla -ok {test-number} - tos == tos for: { stringification failed with an exception: "Invalid" } == { stringification failed with an exception: "Invalid" } # Stringifying char arrays with statically known sizes - char ok {test-number} - ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" # Stringifying char arrays with statically known sizes - char diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 9c6e190a..52c56fb9 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -376,6 +376,8 @@ ##teamcity[testFinished name='Exception message can be matched' duration="{duration}"] ##teamcity[testStarted name='Exception messages can be tested for'] ##teamcity[testFinished name='Exception messages can be tested for' duration="{duration}"] +##teamcity[testStarted name='Exception thrown inside stringify does not fail the test'] +##teamcity[testFinished name='Exception thrown inside stringify does not fail the test' duration="{duration}"] ##teamcity[testStarted name='Exceptions matchers'] ##teamcity[testFinished name='Exceptions matchers' duration="{duration}"] ##teamcity[testStarted name='Expected exceptions that don|'t throw or unexpected exceptions fail the test'] @@ -617,8 +619,6 @@ ##teamcity[testFinished name='StringRef' duration="{duration}"] ##teamcity[testStarted name='StringRef at compilation time'] ##teamcity[testFinished name='StringRef at compilation time' duration="{duration}"] -##teamcity[testStarted name='Stringifying bla bla bla'] -##teamcity[testFinished name='Stringifying bla bla bla' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - char'] ##teamcity[testFinished name='Stringifying char arrays with statically known sizes - char' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - signed char'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 9cf4cba1..28ee520b 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -376,6 +376,8 @@ ##teamcity[testFinished name='Exception message can be matched' duration="{duration}"] ##teamcity[testStarted name='Exception messages can be tested for'] ##teamcity[testFinished name='Exception messages can be tested for' duration="{duration}"] +##teamcity[testStarted name='Exception thrown inside stringify does not fail the test'] +##teamcity[testFinished name='Exception thrown inside stringify does not fail the test' duration="{duration}"] ##teamcity[testStarted name='Exceptions matchers'] ##teamcity[testFinished name='Exceptions matchers' duration="{duration}"] ##teamcity[testStarted name='Expected exceptions that don|'t throw or unexpected exceptions fail the test'] @@ -617,8 +619,6 @@ ##teamcity[testFinished name='StringRef' duration="{duration}"] ##teamcity[testStarted name='StringRef at compilation time'] ##teamcity[testFinished name='StringRef at compilation time' duration="{duration}"] -##teamcity[testStarted name='Stringifying bla bla bla'] -##teamcity[testFinished name='Stringifying bla bla bla' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - char'] ##teamcity[testFinished name='Stringifying char arrays with statically known sizes - char' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - signed char'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 9cf98a1a..fb0eff1a 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -5121,6 +5121,19 @@ Approx( 1.30000000000000004 ) + + + + tos == tos + + + { stringification failed with an exception: "Invalid" } +== +{ stringification failed with an exception: "Invalid" } + + + + @@ -13725,19 +13738,6 @@ Message from section two - - - - tos == tos - - - { stringification failed with an exception: "Invalid" } -== -{ stringification failed with an exception: "Invalid" } - - - - diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index ef19a45e..39fe9c40 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -5121,6 +5121,19 @@ Approx( 1.30000000000000004 ) + + + + tos == tos + + + { stringification failed with an exception: "Invalid" } +== +{ stringification failed with an exception: "Invalid" } + + + + @@ -13725,19 +13738,6 @@ Message from section two - - - - tos == tos - - - { stringification failed with an exception: "Invalid" } -== -{ stringification failed with an exception: "Invalid" } - - - - diff --git a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp index c3c70142..be639ce3 100644 --- a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp @@ -135,7 +135,7 @@ struct Catch::StringMaker { } }; -TEST_CASE( "Stringifying bla bla bla" ) { +TEST_CASE( "Exception thrown inside stringify does not fail the test", "[toString]" ) { ThrowsOnStringification tos; CHECK( tos == tos ); }