The INTERNAL_CATCH_MSG macro, which is used by INFO, WARN and FAIL places its lines in a do…while block so it can be used after an if statement with no block
This commit is contained in:
Phil Nash 2012-11-06 07:52:28 +00:00
parent 88b70828f2
commit ec5956f471
3 changed files with 11 additions and 6 deletions

View File

@ -167,8 +167,10 @@ inline bool isTrue( bool value ){ return value; }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \
INTERNAL_CATCH_ACCEPT_INFO( "", macroName, false ); \ do { \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ); INTERNAL_CATCH_ACCEPT_INFO( "", macroName, false ); \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ) \
} while( Catch::isTrue( false ) )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \ #define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \

View File

@ -43,7 +43,8 @@ TEST_CASE( "./mixed/message/info/2", "INFO gets logged on failure" )
TEST_CASE( "./failing/message/fail", "FAIL aborts the test" ) TEST_CASE( "./failing/message/fail", "FAIL aborts the test" )
{ {
FAIL( "This is a " << "failure" ); // This should output the message and abort if( true )
FAIL( "This is a " << "failure" ); // This should output the message and abort
} }
TEST_CASE( "./failing/message/sections", "Output from all sections is reported" ) TEST_CASE( "./failing/message/sections", "Output from all sections is reported" )

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-11-04 21:39:24.756874 * Generated: 2012-11-06 07:51:06.701955
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -2162,8 +2162,10 @@ inline bool isTrue( bool value ){ return value; }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \
INTERNAL_CATCH_ACCEPT_INFO( "", macroName, false ); \ do { \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ); INTERNAL_CATCH_ACCEPT_INFO( "", macroName, false ); \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ) \
} while( Catch::isTrue( false ) )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \ #define INTERNAL_CATCH_SCOPED_INFO( log, macroName ) \