mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Fixed remaining reporting regressions
This commit is contained in:
		| @@ -80,9 +80,12 @@ inline bool isTrue( bool value ){ return value; } | |||||||
|  |  | ||||||
| } // end namespace Catch | } // end namespace Catch | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | #define INTERNAL_CATCH_ASSERTIONINFO_NAME INTERNAL_CATCH_UNIQUE_NAME( __assertionInfo ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, stopOnFailure, originalExpr ) \ | #define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, stopOnFailure, originalExpr ) \ | ||||||
|     if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr )  ) { \ |     if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, INTERNAL_CATCH_ASSERTIONINFO_NAME )  ) { \ | ||||||
|         if( internal_catch_action & Catch::ResultAction::Debug ) BreakIntoDebugger(); \ |         if( internal_catch_action & Catch::ResultAction::Debug ) BreakIntoDebugger(); \ | ||||||
|         if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \ |         if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \ | ||||||
|         if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \ |         if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \ | ||||||
| @@ -91,19 +94,22 @@ inline bool isTrue( bool value ){ return value; } | |||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, shouldNegate ) \ | #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, shouldNegate ) \ | ||||||
|     Catch::getResultCapture().acceptAssertionInfo( Catch::AssertionInfo( macroName, CATCH_INTERNAL_LINEINFO, expr, shouldNegate ) ); |     Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, shouldNegate ); | ||||||
|  | // !TBD    Catch::getResultCapture().acceptAssertionInfo( INTERNAL_CATCH_ASSERTIONINFO_NAME ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_TEST( expr, shouldNegate, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_TEST( expr, shouldNegate, stopOnFailure, macroName ) \ | ||||||
|     do { try { \ |     do { \ | ||||||
|         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, shouldNegate ); \ |         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, shouldNegate ); \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionDecomposer()->*expr ).negate( shouldNegate ), stopOnFailure, expr ); \ |         try { \ | ||||||
|     } catch( Catch::TestFailureException& ) { \ |             INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionDecomposer()->*expr ).negate( shouldNegate ), stopOnFailure, expr ); \ | ||||||
|         throw; \ |         } catch( Catch::TestFailureException& ) { \ | ||||||
|     } catch( ... ) { \ |             throw; \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), false, expr ); \ |         } catch( ... ) { \ | ||||||
|         throw; \ |             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), false, expr ); \ | ||||||
|     } } while( Catch::isTrue( false ) ) |             throw; \ | ||||||
|  |         } \ | ||||||
|  |     } while( Catch::isTrue( false ) ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_IF( expr, shouldNegate, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_IF( expr, shouldNegate, stopOnFailure, macroName ) \ | ||||||
| @@ -117,19 +123,20 @@ inline bool isTrue( bool value ){ return value; } | |||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \ | ||||||
|     try { \ |     do { \ | ||||||
|         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, false ); \ |         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, false ); \ | ||||||
|         expr; \ |         try { \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \ |             expr; \ | ||||||
|     } \ |             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \ | ||||||
|     catch( ... ) { \ |         } \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), stopOnFailure, false ); \ |         catch( ... ) { \ | ||||||
|     } |             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), stopOnFailure, false ); \ | ||||||
|  |         } \ | ||||||
|  | } while( Catch::isTrue( false ) ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, stopOnFailure ) \ | ||||||
|     try { \ |     try { \ | ||||||
|         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, false ); \ |  | ||||||
|         if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \ |         if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \ | ||||||
|             expr; \ |             expr; \ | ||||||
|             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \ |             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \ | ||||||
| @@ -142,15 +149,26 @@ inline bool isTrue( bool value ){ return value; } | |||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \ |         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \ | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | #define INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ | ||||||
|  |     do { \ | ||||||
|  |         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, false ); \ | ||||||
|  |         INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, stopOnFailure ) \ | ||||||
|  |     } while( Catch::isTrue( false ) ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, stopOnFailure, macroName ) \ | ||||||
|     INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ |     do { \ | ||||||
|     catch( ... ) { \ |         INTERNAL_CATCH_ACCEPT_INFO( #expr, macroName, false ); \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), stopOnFailure, false ); \ |         INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, stopOnFailure ) \ | ||||||
|     } |         catch( ... ) { \ | ||||||
|  |             INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), stopOnFailure, false ); \ | ||||||
|  |         } \ | ||||||
|  |     } while( Catch::isTrue( false ) ) | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ | #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ | ||||||
|  |     INTERNAL_CATCH_ACCEPT_INFO( "", macroName, false ); \ | ||||||
|     INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ); |     INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( resultType ) << reason, stopOnFailure, true ); | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| @@ -161,14 +179,16 @@ inline bool isTrue( bool value ){ return value; } | |||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
| #define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \ | #define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \ | ||||||
|     do { try { \ |     do { \ | ||||||
|         INTERNAL_CATCH_ACCEPT_INFO( #arg " " #matcher, macroName, false ) \ |         INTERNAL_CATCH_ACCEPT_INFO( #arg " " #matcher, macroName, false ); \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::expressionResultBuilderFromMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), stopOnFailure, false ); \ |         try { \ | ||||||
|     } catch( Catch::TestFailureException& ) { \ |             INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::expressionResultBuilderFromMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), stopOnFailure, false ); \ | ||||||
|         throw; \ |         } catch( Catch::TestFailureException& ) { \ | ||||||
|     } catch( ... ) { \ |             throw; \ | ||||||
|         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), false, false ); \ |         } catch( ... ) { \ | ||||||
|         throw; \ |             INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), false, false ); \ | ||||||
|     }}while( Catch::isTrue( false ) ) |             throw; \ | ||||||
|  |         } \ | ||||||
|  |     } while( Catch::isTrue( false ) ) | ||||||
|  |  | ||||||
| #endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED | #endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ namespace Catch { | |||||||
|         virtual bool shouldDebugBreak() const = 0; |         virtual bool shouldDebugBreak() const = 0; | ||||||
|          |          | ||||||
|         virtual void acceptAssertionInfo( const AssertionInfo& assertionInfo ) = 0; |         virtual void acceptAssertionInfo( const AssertionInfo& assertionInfo ) = 0; | ||||||
|         virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult ) = 0; |         virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) = 0; | ||||||
|          |          | ||||||
|         virtual std::string getCurrentTestName() const = 0;         |         virtual std::string getCurrentTestName() const = 0;         | ||||||
|         virtual const AssertionResult* getLastResult() const = 0;         |         virtual const AssertionResult* getLastResult() const = 0;         | ||||||
|   | |||||||
| @@ -135,7 +135,8 @@ namespace Catch { | |||||||
|             m_assertionInfo = assertionInfo; |             m_assertionInfo = assertionInfo; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult ) { |         virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) { | ||||||
|  |             m_assertionInfo = assertionInfo; | ||||||
|             m_currentResult = assertionResult; |             m_currentResult = assertionResult; | ||||||
|             return actOnCurrentResult(); |             return actOnCurrentResult(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -234,10 +234,11 @@ namespace Catch { | |||||||
|              |              | ||||||
|             if( assertionResult.hasExpandedExpression() ) { |             if( assertionResult.hasExpandedExpression() ) { | ||||||
|                 m_config.stream << " for: "; |                 m_config.stream << " for: "; | ||||||
|                 if( assertionResult.getExpandedExpression().size() > 40 ) |                 if( assertionResult.getExpandedExpression().size() > 40 ) { | ||||||
|                     m_config.stream << "\n"; |                     m_config.stream << "\n"; | ||||||
|                 if( assertionResult.getExpandedExpression().size() < 70 ) |                     if( assertionResult.getExpandedExpression().size() < 70 ) | ||||||
|                     m_config.stream << "\t"; |                         m_config.stream << "\t"; | ||||||
|  |                 } | ||||||
|                 TextColour colour( TextColour::ReconstructedExpression ); |                 TextColour colour( TextColour::ReconstructedExpression ); | ||||||
|                 m_config.stream << assertionResult.getExpandedExpression(); |                 m_config.stream << assertionResult.getExpandedExpression(); | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash