diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 4cc9705f..575f1931 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -88,7 +88,6 @@ inline bool isTrue( bool value ){ return value; } } catch( ... ) { \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \ resultDisposition | Catch::ResultDisposition::ContinueOnFailure, expr ); \ - throw; \ } \ } while( Catch::isTrue( false ) ) @@ -179,7 +178,6 @@ inline bool isTrue( bool value ){ return value; } } catch( ... ) { \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \ resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \ - throw; \ } \ } while( Catch::isTrue( false ) ) diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt index bfb9e47b..4af07a10 100644 --- a/projects/SelfTest/Baselines/approvedResults.txt +++ b/projects/SelfTest/Baselines/approvedResults.txt @@ -1095,31 +1095,42 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./succeeding/exceptions/implicit +./failing/exceptions/implicit/4 ------------------------------------------------------------------------------- ExceptionTests.cpp:69 ............................................................................... +ExceptionTests.cpp:71: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +./succeeding/exceptions/implicit +------------------------------------------------------------------------------- +ExceptionTests.cpp:75 +............................................................................... + No assertions in test case, './succeeding/exceptions/implicit' ------------------------------------------------------------------------------- ./failing/exceptions/custom ------------------------------------------------------------------------------- -ExceptionTests.cpp:106 +ExceptionTests.cpp:112 ............................................................................... -ExceptionTests.cpp:106: FAILED: +ExceptionTests.cpp:112: FAILED: due to unexpected exception with message: custom exception ------------------------------------------------------------------------------- ./failing/exceptions/custom/nothrow ------------------------------------------------------------------------------- -ExceptionTests.cpp:114 +ExceptionTests.cpp:120 ............................................................................... -ExceptionTests.cpp:116: FAILED: +ExceptionTests.cpp:122: FAILED: REQUIRE_NOTHROW( throw CustomException( "unexpected custom exception" ) ) due to unexpected exception with message: unexpected custom exception @@ -1127,10 +1138,10 @@ due to unexpected exception with message: ------------------------------------------------------------------------------- ./failing/exceptions/custom/throw ------------------------------------------------------------------------------- -ExceptionTests.cpp:119 +ExceptionTests.cpp:125 ............................................................................... -ExceptionTests.cpp:121: FAILED: +ExceptionTests.cpp:127: FAILED: REQUIRE_THROWS_AS( throw CustomException( "custom exception - not std" ) ) due to unexpected exception with message: custom exception - not std @@ -1138,20 +1149,20 @@ due to unexpected exception with message: ------------------------------------------------------------------------------- ./failing/exceptions/custom/double ------------------------------------------------------------------------------- -ExceptionTests.cpp:125 +ExceptionTests.cpp:131 ............................................................................... -ExceptionTests.cpp:125: FAILED: +ExceptionTests.cpp:131: FAILED: due to unexpected exception with message: 3.14 ------------------------------------------------------------------------------- ./succeeding/exceptions/notimplemented ------------------------------------------------------------------------------- -ExceptionTests.cpp:134 +ExceptionTests.cpp:140 ............................................................................... -ExceptionTests.cpp:136: +ExceptionTests.cpp:142: PASSED: REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ) @@ -3207,6 +3218,11 @@ PASSED: with message: Tests failed, as expected +catch_self_test.hpp:120: +PASSED: +with message: + Tests failed, as expected + ------------------------------------------------------------------------------- selftest/main selftest/expected result @@ -3489,9 +3505,9 @@ with expansion: TestMain.cpp:49: PASSED: - CHECK( totals.assertions.failed == 73 ) + CHECK( totals.assertions.failed == 74 ) with expansion: - 73 == 73 + 74 == 74 ------------------------------------------------------------------------------- meta/Misc/Sections @@ -5503,7 +5519,7 @@ with message: boo! =============================================================================== -110 test cases - 48 failed (703 assertions - 105 failed) +111 test cases - 49 failed (705 assertions - 106 failed) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -5824,7 +5840,7 @@ with expansion: 13 test cases - 3 failed (40 assertions - 4 failed) - + @@ -6024,25 +6040,30 @@ ExceptionTests.cpp:56 ExceptionTests.cpp:62 + + +ExceptionTests.cpp:71 + + -ExceptionTests.cpp:106 +ExceptionTests.cpp:112 -ExceptionTests.cpp:116 +ExceptionTests.cpp:122 -ExceptionTests.cpp:121 +ExceptionTests.cpp:127 -ExceptionTests.cpp:125 +ExceptionTests.cpp:131 @@ -7762,51 +7783,65 @@ ExceptionTests.cpp" line="62"> + +ExceptionTests.cpp" line="71"> + + thisThrows() == 0 + + + thisThrows() == 0 + +ExceptionTests.cpp" line="71"> + expected exception + + + + -ExceptionTests.cpp" line="106"> +ExceptionTests.cpp" line="112"> custom exception -ExceptionTests.cpp" line="116"> +ExceptionTests.cpp" line="122"> throw CustomException( "unexpected custom exception" ) throw CustomException( "unexpected custom exception" ) -ExceptionTests.cpp" line="116"> +ExceptionTests.cpp" line="122"> unexpected custom exception -ExceptionTests.cpp" line="121"> +ExceptionTests.cpp" line="127"> throw CustomException( "custom exception - not std" ) throw CustomException( "custom exception - not std" ) -ExceptionTests.cpp" line="121"> +ExceptionTests.cpp" line="127"> custom exception - not std -ExceptionTests.cpp" line="125"> +ExceptionTests.cpp" line="131"> 3.14 -ExceptionTests.cpp" line="136"> +ExceptionTests.cpp" line="142"> thisFunctionNotImplemented( 7 ) @@ -9957,9 +9992,9 @@ MiscTests.cpp" line="332">
- +
- +
@@ -10004,10 +10039,10 @@ TestMain.cpp" line="48"> TestMain.cpp" line="49"> - totals.assertions.failed == 73 + totals.assertions.failed == 74 - 73 == 73 + 74 == 74 @@ -12217,9 +12252,9 @@ BDDTests.cpp" line="54">
- + - + [Started testing: CatchSelfTest] [Started group: '~dummy'] @@ -12483,6 +12518,10 @@ ExceptionTests.cpp:62: Unexpected exception with message: 'unexpected exception' [Finished: './failing/exceptions/implicit/3' 1 test case failed (1 assertion failed)] +[Running: ./failing/exceptions/implicit/4] +ExceptionTests.cpp:71: thisThrows() == 0 failed with unexpected exception with message: 'expected exception' +[Finished: './failing/exceptions/implicit/4' 1 test case failed (1 assertion failed)] + [Running: ./succeeding/exceptions/implicit] No assertions in test case, './succeeding/exceptions/implicit' @@ -12490,23 +12529,23 @@ No assertions in test case, './succeeding/exceptions/implicit' [Finished: './succeeding/exceptions/implicit' 1 test case failed (1 assertion failed)] [Running: ./failing/exceptions/custom] -ExceptionTests.cpp:106: Unexpected exception with message: 'custom exception' +ExceptionTests.cpp:112: Unexpected exception with message: 'custom exception' [Finished: './failing/exceptions/custom' 1 test case failed (1 assertion failed)] [Running: ./failing/exceptions/custom/nothrow] -ExceptionTests.cpp:116: throw CustomException( "unexpected custom exception" ) failed with unexpected exception with message: 'unexpected custom exception' +ExceptionTests.cpp:122: throw CustomException( "unexpected custom exception" ) failed with unexpected exception with message: 'unexpected custom exception' [Finished: './failing/exceptions/custom/nothrow' 1 test case failed (1 assertion failed)] [Running: ./failing/exceptions/custom/throw] -ExceptionTests.cpp:121: throw CustomException( "custom exception - not std" ) failed with unexpected exception with message: 'custom exception - not std' +ExceptionTests.cpp:127: throw CustomException( "custom exception - not std" ) failed with unexpected exception with message: 'custom exception - not std' [Finished: './failing/exceptions/custom/throw' 1 test case failed (1 assertion failed)] [Running: ./failing/exceptions/custom/double] -ExceptionTests.cpp:125: Unexpected exception with message: '3.14' +ExceptionTests.cpp:131: Unexpected exception with message: '3.14' [Finished: './failing/exceptions/custom/double' 1 test case failed (1 assertion failed)] [Running: ./succeeding/exceptions/notimplemented] -ExceptionTests.cpp:136: thisFunctionNotImplemented( 7 ) succeeded +ExceptionTests.cpp:142: thisFunctionNotImplemented( 7 ) succeeded [Finished: './succeeding/exceptions/notimplemented' All tests passed (1 assertion in 1 test case)] [Running: ./succeeding/generators/1] @@ -13094,9 +13133,11 @@ catch_self_test.hpp:120: succeeded [with message: Tests failed, as expected] catch_self_test.hpp:120: succeeded [with message: Tests failed, as expected] -[End of section: 'selftest/expected result/failing tests' All 26 assertions passed] +catch_self_test.hpp:120: succeeded +[with message: Tests failed, as expected] +[End of section: 'selftest/expected result/failing tests' All 27 assertions passed] -[End of section: 'selftest/expected result' All 26 assertions passed] +[End of section: 'selftest/expected result' All 27 assertions passed] [Started section: 'selftest/expected result'] [Started section: 'selftest/expected result/succeeding tests'] @@ -13215,12 +13256,12 @@ TestMain.cpp:42: totals.assertions.failed == 0 succeeded for: 0 == 0 [Started section: 'selftest/test counts'] [Started section: 'selftest/test counts/failing tests'] TestMain.cpp:48: totals.assertions.passed == 1 succeeded for: 1 == 1 -TestMain.cpp:49: totals.assertions.failed == 73 succeeded for: 73 == 73 +TestMain.cpp:49: totals.assertions.failed == 74 succeeded for: 74 == 74 [End of section: 'selftest/test counts/failing tests' All 2 assertions passed] [End of section: 'selftest/test counts' All 2 assertions passed] -[Finished: 'selftest/main' All tests passed (76 assertions in 1 test case)] +[Finished: 'selftest/main' All tests passed (77 assertions in 1 test case)] [Running: meta/Misc/Sections] TestMain.cpp:58: totals.assertions.passed == 2 succeeded for: 2 == 2 @@ -14050,10 +14091,10 @@ BDDTests.cpp:67: succeeded [End of section: ' Given: A section name that is so long that it cannot fit in a single console width' 1 assertion passed] [Finished: 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' All tests passed (1 assertion in 1 test case)] -[End of group: '~dummy'. 48 of 110 test cases failed (105 of 703 assertions failed)] +[End of group: '~dummy'. 49 of 111 test cases failed (106 of 705 assertions failed)] -[Testing completed. 48 of 110 test cases failed (105 of 703 assertions failed)] +[Testing completed. 49 of 111 test cases failed (106 of 705 assertions failed)] [Started testing: CatchSelfTest] [Started group: '~dummy'] diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 444328c3..bf951222 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -66,6 +66,12 @@ TEST_CASE( "./failing/exceptions/implicit/3", "When unchecked exceptions are thr } } +TEST_CASE_NORETURN( "./failing/exceptions/implicit/4", "When unchecked exceptions are thrown they are always failures" ) +{ + CHECK( thisThrows() == 0 ); + /*NOTREACHED*/ +} + TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" ) { try diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index e6e4faf9..7b31bbba 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -46,7 +46,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" "Number of 'failing' tests is fixed" ) { Totals totals = runner.runMatching( "./failing/*", 1, 2 ); CHECK( totals.assertions.passed == 1 ); - CHECK( totals.assertions.failed == 73 ); + CHECK( totals.assertions.failed == 74 ); } } }