mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-19 19:25:38 +02:00
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:
@@ -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 );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user