Big assertion capture refactoring.

- moved as much logic out of the macros as possible
- moved most logic into new ResultBuilder class, which wraps ExpressionResultBuilder (may take it over next), subsumes ResultAction and also takes place of ExpressionDecomposer.

This introduces many SRP violations - but all in the name of minimising macro logic!
This commit is contained in:
Phil Nash
2014-05-28 18:53:01 +01:00
parent 14796814b8
commit 9438a03d5b
26 changed files with 312 additions and 260 deletions

View File

@@ -15,7 +15,7 @@ namespace
{
inline int thisThrows()
{
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw std::domain_error( "expected exception" );
return 1;
}
@@ -42,14 +42,14 @@ TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail t
TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing]" )
{
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw std::domain_error( "unexpected exception" );
}
TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing]" )
{
CHECK( 1 == 1 );
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw std::domain_error( "unexpected exception" );
}
@@ -57,7 +57,7 @@ TEST_CASE( "When unchecked exceptions are thrown from sections they are always f
{
SECTION( "section name", "" )
{
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw std::domain_error( "unexpected exception" );
}
}
@@ -118,12 +118,12 @@ CATCH_TRANSLATE_EXCEPTION( double& ex )
TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" )
{
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw CustomException( "custom exception" );
}
inline void throwCustom() {
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw CustomException( "custom exception - not std" );
}
@@ -140,7 +140,7 @@ TEST_CASE( "Custom exceptions can be translated when testing for throwing as som
TEST_CASE( "Unexpected exceptions can be translated", "[.][failing]" )
{
if( Catch::isTrue( true ) )
if( Catch::alwaysTrue() )
throw double( 3.14 );
}