Secondary fix for #270 (addresses same issue with CHECK)

This commit is contained in:
Phil Nash 2014-04-12 19:20:46 +01:00
parent a176b93738
commit 1bccc03213
6 changed files with 63 additions and 11 deletions

View File

@ -87,7 +87,7 @@ struct TestFailureException{};
throw; \ throw; \
} catch( ... ) { \ } catch( ... ) { \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \
resultDisposition, expr ); \ Catch::ResultDisposition::Normal, expr ); \
} \ } \
} while( Catch::isTrue( false ) ) } while( Catch::isTrue( false ) )

View File

@ -332,7 +332,8 @@ due to unexpected exception with message:
expected exception expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
When unchecked exceptions are thrown during a require the test should fail When unchecked exceptions are thrown during a REQUIRE the test should abort
fail
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
@ -342,6 +343,18 @@ ExceptionTests.cpp:<line number>: FAILED:
due to unexpected exception with message: due to unexpected exception with message:
expected exception expected exception
-------------------------------------------------------------------------------
When unchecked exceptions are thrown during a CHECK the test should abort and
fail
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>: FAILED:
CHECK( thisThrows() == 0 )
due to unexpected exception with message:
expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Unexpected custom exceptions can be translated Unexpected custom exceptions can be translated
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -761,5 +774,5 @@ with expansion:
"first" == "second" "first" == "second"
=============================================================================== ===============================================================================
123 test cases - 37 failed (659 assertions - 92 failed) 124 test cases - 38 failed (660 assertions - 93 failed)

View File

@ -1111,7 +1111,8 @@ due to unexpected exception with message:
expected exception expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
When unchecked exceptions are thrown during a require the test should fail When unchecked exceptions are thrown during a REQUIRE the test should abort
fail
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
@ -1121,6 +1122,18 @@ ExceptionTests.cpp:<line number>: FAILED:
due to unexpected exception with message: due to unexpected exception with message:
expected exception expected exception
-------------------------------------------------------------------------------
When unchecked exceptions are thrown during a CHECK the test should abort and
fail
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>: FAILED:
CHECK( thisThrows() == 0 )
due to unexpected exception with message:
expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
When unchecked exceptions are thrown, but caught, they do not affect the test When unchecked exceptions are thrown, but caught, they do not affect the test
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -6969,5 +6982,5 @@ with expansion:
true true
=============================================================================== ===============================================================================
123 test cases - 52 failed (678 assertions - 111 failed) 124 test cases - 53 failed (679 assertions - 112 failed)

View File

@ -1,5 +1,5 @@
<testsuites> <testsuites>
<testsuite name="~_" errors="11" failures="100" tests="678" hostname="tbd" time="{duration}" timestamp="tbd"> <testsuite name="~_" errors="12" failures="100" tests="679" hostname="tbd" time="{duration}" timestamp="tbd">
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/> <testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/> <testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/> <testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
@ -210,9 +210,15 @@ expected exception
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
</error> </error>
</testcase> </testcase>
<testcase classname="global" name="When unchecked exceptions are thrown during a require the test should fail" time="{duration}"> <testcase classname="global" name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail" time="{duration}">
<error message="thisThrows() == 0" type="REQUIRE"> <error message="thisThrows() == 0" type="REQUIRE">
expected exception expected exception
ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="global" name="When unchecked exceptions are thrown during a CHECK the test should abort and fail" time="{duration}">
<error message="thisThrows() == 0" type="CHECK">
expected exception
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
</error> </error>
</testcase> </testcase>

View File

@ -1426,7 +1426,21 @@
</Expression> </Expression>
<OverallResult success="false"/> <OverallResult success="false"/>
</TestCase> </TestCase>
<TestCase name="When unchecked exceptions are thrown during a require the test should fail"> <TestCase name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail">
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows() == 0
</Original>
<Expanded>
thisThrows() == 0
</Expanded>
<Exception filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
expected exception
</Exception>
</Expression>
<OverallResult success="false"/>
</TestCase>
<TestCase name="When unchecked exceptions are thrown during a CHECK the test should abort and fail">
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" > <Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
<Original> <Original>
thisThrows() == 0 thisThrows() == 0
@ -7228,7 +7242,7 @@ there&quot;
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="567" failures="111"/> <OverallResults successes="567" failures="112"/>
</Group> </Group>
<OverallResults successes="567" failures="111"/> <OverallResults successes="567" failures="112"/>
</Catch> </Catch>

View File

@ -66,12 +66,18 @@ TEST_CASE( "When unchecked exceptions are thrown from functions they are always
CHECK( thisThrows() == 0 ); CHECK( thisThrows() == 0 );
} }
TEST_CASE( "When unchecked exceptions are thrown during a require the test should fail", "[.][failing]" ) TEST_CASE( "When unchecked exceptions are thrown during a REQUIRE the test should abort fail", "[.][failing]" )
{ {
REQUIRE( thisThrows() == 0 ); REQUIRE( thisThrows() == 0 );
FAIL( "This should never happen" ); FAIL( "This should never happen" );
} }
TEST_CASE( "When unchecked exceptions are thrown during a CHECK the test should abort and fail", "[.][failing]" )
{
CHECK( thisThrows() == 0 );
FAIL( "This should never happen" );
}
TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" ) TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" )
{ {
try try