diff --git a/Test/ExceptionTests.cpp b/Test/ExceptionTests.cpp index 5fba0da8..e0332be8 100644 --- a/Test/ExceptionTests.cpp +++ b/Test/ExceptionTests.cpp @@ -46,7 +46,7 @@ TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown CHECK_NOTHROW( thisThrows() ); } -INTERNAL_CATCH_TESTCASE_NORETURN( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" ) +TEST_CASE_NORETURN( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" ) { throw std::domain_error( "unexpected exception" ); /*NOTREACHED*/ diff --git a/catch_reporter_basic.hpp b/catch_reporter_basic.hpp index 72843f2f..d5bd64af 100644 --- a/catch_reporter_basic.hpp +++ b/catch_reporter_basic.hpp @@ -194,6 +194,12 @@ namespace Catch m_config.stream() << "Unexpected"; m_config.stream() << " exception with message: '" << resultInfo.getMessage() << "'"; break; + case ResultWas::DidntThrowException: + if( resultInfo.hasExpression() ) + m_config.stream() << " because no exception was thrown where one was expected"; + else + m_config.stream() << "No exception thrown where one was expected"; + break; case ResultWas::Info: m_config.stream() << "info:\n'" << resultInfo.getMessage() << "'"; break; @@ -204,6 +210,13 @@ namespace Catch m_config.stream() << "failed with message: '" << resultInfo.getMessage() << "'"; break; default: + if( !resultInfo.hasExpression() ) + { + if( resultInfo.ok() ) + m_config.stream() << " succeeded"; + else + m_config.stream() << " failed"; + } break; } diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp index 80eb5ef4..72b449a0 100644 --- a/internal/catch_capture.hpp +++ b/internal/catch_capture.hpp @@ -537,8 +537,8 @@ inline bool isTrue } // end namespace Catch /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ACCEPT_RESULT2( result, stopOnFailure ) \ - if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptResult( result ) ) \ +#define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure ) \ + if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptExpression( expr ) ) \ { \ if( action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \ if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \ @@ -546,34 +546,34 @@ inline bool isTrue /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \ - Catch::Hub::getResultCapture().acceptExpression( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr ); + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr ), stopOnFailure ); /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \ try \ { \ - using namespace Catch; \ expr; \ - Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \ } \ catch( ... ) \ { \ - using namespace Catch; \ - Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \ } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ try \ { \ - using namespace Catch; \ expr; \ - Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::DidntThrowException ) ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure ); \ + } \ + catch( Catch::TestFailureException& ) \ + { \ + throw; \ } \ catch( exceptionType ) \ { \ - using namespace Catch; \ - Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \ } /////////////////////////////////////////////////////////////////////////////// @@ -581,8 +581,7 @@ inline bool isTrue INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ catch( ... ) \ { \ - using namespace Catch; \ - Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \ } /////////////////////////////////////////////////////////////////////////////// diff --git a/internal/catch_result_type.h b/internal/catch_result_type.h index 4df93880..e8f6f528 100644 --- a/internal/catch_result_type.h +++ b/internal/catch_result_type.h @@ -28,7 +28,7 @@ struct ResultWas{ enum OfType ExpressionFailed = FailureBit | 1, ExplicitFailure = FailureBit | 2, - Exception = 0x110, + Exception = 0x100 | FailureBit, ThrewException = Exception | 1, DidntThrowException = Exception | 2