mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Fixes issue #164
- Removed spurious (re-)throw when catching unexpected exception
This commit is contained in:
parent
b3acf45d70
commit
2666c96d4e
@ -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 ) )
|
||||
|
||||
|
@ -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)
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="~dummy" errors="9" failures="78" tests="703" hostname="tbd" time="tbd" timestamp="tbd">
|
||||
<testsuite name="~dummy" errors="10" failures="78" tests="705" hostname="tbd" time="tbd" timestamp="tbd">
|
||||
<testcase classname="global" name="./succeeding/Approx/simple" time="tbd"/>
|
||||
<testcase classname="global" name="./succeeding/Approx/epsilon" time="tbd"/>
|
||||
<testcase classname="global" name="./succeeding/Approx/float" time="tbd"/>
|
||||
@ -6024,25 +6040,30 @@ ExceptionTests.cpp:56
|
||||
ExceptionTests.cpp:62
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./failing/exceptions/implicit/4" time="tbd">
|
||||
<error message="thisThrows() == 0" type="CHECK">
|
||||
ExceptionTests.cpp:71
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./succeeding/exceptions/implicit" time="tbd"/>
|
||||
<testcase classname="global" name="./failing/exceptions/custom" time="tbd">
|
||||
<error type="TEST_CASE">
|
||||
ExceptionTests.cpp:106
|
||||
ExceptionTests.cpp:112
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./failing/exceptions/custom/nothrow" time="tbd">
|
||||
<error message="throw CustomException( "unexpected custom exception" )" type="REQUIRE_NOTHROW">
|
||||
ExceptionTests.cpp:116
|
||||
ExceptionTests.cpp:122
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./failing/exceptions/custom/throw" time="tbd">
|
||||
<error message="throw CustomException( "custom exception - not std" )" type="REQUIRE_THROWS_AS">
|
||||
ExceptionTests.cpp:121
|
||||
ExceptionTests.cpp:127
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./failing/exceptions/custom/double" time="tbd">
|
||||
<error type="TEST_CASE">
|
||||
ExceptionTests.cpp:125
|
||||
ExceptionTests.cpp:131
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="./succeeding/exceptions/notimplemented" time="tbd"/>
|
||||
@ -7762,51 +7783,65 @@ ExceptionTests.cpp" line="62">
|
||||
</Section>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./failing/exceptions/implicit/4">
|
||||
ExceptionTests.cpp" line="71">
|
||||
<Original>
|
||||
thisThrows() == 0
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows() == 0
|
||||
</Expanded>
|
||||
ExceptionTests.cpp" line="71">
|
||||
expected exception
|
||||
</Exception>
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./succeeding/exceptions/implicit">
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="./failing/exceptions/custom">
|
||||
ExceptionTests.cpp" line="106">
|
||||
ExceptionTests.cpp" line="112">
|
||||
custom exception
|
||||
</Exception>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./failing/exceptions/custom/nothrow">
|
||||
ExceptionTests.cpp" line="116">
|
||||
ExceptionTests.cpp" line="122">
|
||||
<Original>
|
||||
throw CustomException( "unexpected custom exception" )
|
||||
</Original>
|
||||
<Expanded>
|
||||
throw CustomException( "unexpected custom exception" )
|
||||
</Expanded>
|
||||
ExceptionTests.cpp" line="116">
|
||||
ExceptionTests.cpp" line="122">
|
||||
unexpected custom exception
|
||||
</Exception>
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./failing/exceptions/custom/throw">
|
||||
ExceptionTests.cpp" line="121">
|
||||
ExceptionTests.cpp" line="127">
|
||||
<Original>
|
||||
throw CustomException( "custom exception - not std" )
|
||||
</Original>
|
||||
<Expanded>
|
||||
throw CustomException( "custom exception - not std" )
|
||||
</Expanded>
|
||||
ExceptionTests.cpp" line="121">
|
||||
ExceptionTests.cpp" line="127">
|
||||
custom exception - not std
|
||||
</Exception>
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./failing/exceptions/custom/double">
|
||||
ExceptionTests.cpp" line="125">
|
||||
ExceptionTests.cpp" line="131">
|
||||
3.14
|
||||
</Exception>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="./succeeding/exceptions/notimplemented">
|
||||
ExceptionTests.cpp" line="136">
|
||||
ExceptionTests.cpp" line="142">
|
||||
<Original>
|
||||
thisFunctionNotImplemented( 7 )
|
||||
</Original>
|
||||
@ -9957,9 +9992,9 @@ MiscTests.cpp" line="332">
|
||||
<TestCase name="selftest/main">
|
||||
<Section name="selftest/expected result" description="Tests do what they claim">
|
||||
<Section name="selftest/expected result/failing tests" description="Tests in the 'failing' branch fail">
|
||||
<OverallResults successes="26" failures="0"/>
|
||||
<OverallResults successes="27" failures="0"/>
|
||||
</Section>
|
||||
<OverallResults successes="26" failures="0"/>
|
||||
<OverallResults successes="27" failures="0"/>
|
||||
</Section>
|
||||
<Section name="selftest/expected result" description="Tests do what they claim">
|
||||
<Section name="selftest/expected result/succeeding tests" description="Tests in the 'succeeding' branch succeed">
|
||||
@ -10004,10 +10039,10 @@ TestMain.cpp" line="48">
|
||||
</Expression>
|
||||
TestMain.cpp" line="49">
|
||||
<Original>
|
||||
totals.assertions.failed == 73
|
||||
totals.assertions.failed == 74
|
||||
</Original>
|
||||
<Expanded>
|
||||
73 == 73
|
||||
74 == 74
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="2" failures="0"/>
|
||||
@ -12217,9 +12252,9 @@ BDDTests.cpp" line="54">
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="598" failures="105"/>
|
||||
<OverallResults successes="599" failures="106"/>
|
||||
</Group>
|
||||
<OverallResults successes="598" failures="105"/>
|
||||
<OverallResults successes="599" failures="106"/>
|
||||
</Catch>
|
||||
[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']
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user