diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index e0d2d6eb..32b26e0f 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -17,7 +17,7 @@ namespace Catch { - + struct TestFailureException{}; class ScopedInfo @@ -62,11 +62,11 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \ do{ try{ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr, isNot )->*expr ), stopOnFailure, expr ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr, isNot )->*expr ), stopOnFailure, expr ); \ }catch( Catch::TestFailureException& ){ \ throw; \ } catch( ... ){ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \ throw; \ }}while( Catch::isTrue( false ) ) @@ -85,11 +85,11 @@ inline bool isTrue( bool value ){ return value; } try \ { \ expr; \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \ } \ catch( ... ) \ { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ } /////////////////////////////////////////////////////////////////////////////// @@ -97,7 +97,7 @@ inline bool isTrue( bool value ){ return value; } try \ { \ expr; \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \ } \ catch( Catch::TestFailureException& ) \ { \ @@ -105,7 +105,7 @@ inline bool isTrue( bool value ){ return value; } } \ catch( exceptionType ) \ { \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \ } /////////////////////////////////////////////////////////////////////////////// @@ -113,12 +113,12 @@ inline bool isTrue( bool value ){ return value; } INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ catch( ... ) \ { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ - Catch::Context::getResultCapture().acceptExpression( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) ); + Catch::Context::getResultCapture().acceptExpression( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) ); /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_SCOPED_INFO( log ) \ @@ -128,11 +128,11 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \ do{ try{ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure, false ); \ }catch( Catch::TestFailureException& ){ \ throw; \ } catch( ... ){ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \ throw; \ }}while( Catch::isTrue( false ) ) diff --git a/include/internal/catch_expression_builder.hpp b/include/internal/catch_expression_builder.hpp index 955a21cb..3d5a9ef8 100644 --- a/include/internal/catch_expression_builder.hpp +++ b/include/internal/catch_expression_builder.hpp @@ -17,102 +17,57 @@ #include "catch_common.h" #include -namespace Catch -{ +namespace Catch { -class ResultBuilder -{ +class ExpressionBuilder { public: - /////////////////////////////////////////////////////////////////////////// - ResultBuilder - ( - const SourceLineInfo& lineInfo, - const char* macroName, - const char* expr = "", - bool isNot = false - ) + ExpressionBuilder( const SourceLineInfo& lineInfo, + const char* macroName, + const char* expr = "", + bool isNot = false ) : m_result( expr, isNot, lineInfo, macroName ), m_messageStream() {} - /////////////////////////////////////////////////////////////////////////// template - Expression operator->* - ( - const T & operand - ) - { - Expression expr( m_result, operand ); - + Expression operator->* ( const T & operand ) { + Expression expr( m_result, operand ); return expr; } - /////////////////////////////////////////////////////////////////////////// - Expression operator->* - ( - const char* const& operand - ) - { - Expression expr( m_result, operand ); - + Expression operator->* ( const char* const& operand ) { + Expression expr( m_result, operand ); return expr; } - /////////////////////////////////////////////////////////////////////////// template - PtrExpression operator->* - ( - const T* operand - ) - { - PtrExpression expr( m_result, operand ); - + PtrExpression operator->* ( const T* operand ) { + PtrExpression expr( m_result, operand ); return expr; } - /////////////////////////////////////////////////////////////////////////// template - PtrExpression operator->* - ( - T* operand - ) - { - PtrExpression expr( m_result, operand ); - + PtrExpression operator->* ( T* operand ) { + PtrExpression expr( m_result, operand ); return expr; } - /////////////////////////////////////////////////////////////////////////// - Expression operator->* - ( - bool value - ) - { + Expression operator->* ( bool value ) { Expression expr( m_result, value ); return expr; } - /////////////////////////////////////////////////////////////////////////// template - ResultBuilder& operator << - ( - const T & value - ) - { + ExpressionBuilder& operator << ( const T & value ) { m_messageStream << Catch::toString( value ); return *this; } - /////////////////////////////////////////////////////////////////////////// template - ResultBuilder& acceptMatcher - ( - const MatcherT& matcher, - const ArgT& arg, - const std::string& matcherCallAsString - ) - { + ExpressionBuilder& acceptMatcher( const MatcherT& matcher, + const ArgT& arg, + const std::string& matcherCallAsString ) { std::string matcherAsString = Catch::toString( matcher ); if( matcherAsString == "{?}" ) matcherAsString = matcherCallAsString; @@ -123,15 +78,10 @@ public: return *this; } - /////////////////////////////////////////////////////////////////////////// template - ResultBuilder& acceptMatcher - ( - const MatcherT& matcher, - ArgT* arg, - const std::string& matcherCallAsString - ) - { + ExpressionBuilder& acceptMatcher( const MatcherT& matcher, + ArgT* arg, + const std::string& matcherCallAsString ) { std::string matcherAsString = Catch::toString( matcher ); if( matcherAsString == "{?}" ) matcherAsString = matcherCallAsString; @@ -142,20 +92,12 @@ public: return *this; } - /////////////////////////////////////////////////////////////////////////// - ResultBuilder& setResultType - ( - ResultWas::OfType resultType - ) - { + ExpressionBuilder& setResultType( ResultWas::OfType resultType ) { m_result.setResultType( resultType ); return *this; } - /////////////////////////////////////////////////////////////////////////// - operator ResultInfoBuilder& - () - { + operator ResultInfoBuilder&() { m_result.setMessage( m_messageStream.str() ); return m_result; } diff --git a/include/internal/catch_resultinfo_builder.hpp b/include/internal/catch_resultinfo_builder.hpp index bcbea3d0..0b613c1e 100644 --- a/include/internal/catch_resultinfo_builder.hpp +++ b/include/internal/catch_resultinfo_builder.hpp @@ -76,7 +76,7 @@ public: ); private: - friend class ResultBuilder; + friend class ExpressionBuilder; template friend class Expression; template friend class PtrExpression; diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index d7827a7b..c2321826 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -51,7 +51,7 @@ 4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_with_main.hpp; path = ../../../../include/catch_with_main.hpp; sourceTree = ""; }; 4A6D0C44149B3E1500DB3EAA /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../../../../include/catch.hpp; sourceTree = ""; }; 4A6D0C46149B3E3D00DB3EAA /* catch_approx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_approx.hpp; sourceTree = ""; }; - 4A6D0C47149B3E3D00DB3EAA /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_capture.hpp; sourceTree = ""; }; + 4A6D0C47149B3E3D00DB3EAA /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_capture.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4A6D0C48149B3E3D00DB3EAA /* catch_commandline.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_commandline.hpp; sourceTree = ""; }; 4A6D0C49149B3E3D00DB3EAA /* catch_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_common.h; sourceTree = ""; }; 4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_config.hpp; sourceTree = ""; };