Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Renamed ResultBuilder -> ExpressionBuilder

Commit
6acb36a996822a6d524c5f9f46eb118f18a969df
Author
Phil Nash ·
Parents
7a0cadc34253

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp                 |  22 ++---
 include/internal/catch_expression_builder.hpp      | 106 +++++----------------
 include/internal/catch_resultinfo_builder.hpp      |   2 +-
 .../CatchSelfTest.xcodeproj/project.pbxproj        |   2 +-
 4 files changed, 37 insertions(+), 95 deletions(-)

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 <sstream>
 
-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<typename T>
-    Expression<const T&> operator->*
-    (
-        const T & operand
-    )
-    {
-        Expression<const T&> expr( m_result, operand );
-        
+    Expression<const T&> operator->* ( const T & operand ) {
+        Expression<const T&> expr( m_result, operand );        
         return expr;
     }
 
-    ///////////////////////////////////////////////////////////////////////////
-    Expression<const char*> operator->*
-    (
-        const char* const& operand
-     )
-    {
-        Expression<const char*> expr( m_result, operand );
-        
+    Expression<const char*> operator->* ( const char* const& operand ) {
+        Expression<const char*> expr( m_result, operand );        
         return expr;
     }
     
-    ///////////////////////////////////////////////////////////////////////////
     template<typename T>
-    PtrExpression<T> operator->*
-    (
-        const T* operand
-    )
-    {
-        PtrExpression<T> expr( m_result, operand );
-        
+    PtrExpression<T> operator->* ( const T* operand ) {
+        PtrExpression<T> expr( m_result, operand );        
         return expr;
     }
     
-    ///////////////////////////////////////////////////////////////////////////
     template<typename T>
-    PtrExpression<T> operator->*
-    (
-        T* operand
-    )
-    {
-        PtrExpression<T> expr( m_result, operand );
-        
+    PtrExpression<T> operator->* ( T* operand ) {
+        PtrExpression<T> expr( m_result, operand );        
         return expr;
     }
     
-    ///////////////////////////////////////////////////////////////////////////
-    Expression<bool> operator->*
-    (
-        bool value
-    )
-    {
+    Expression<bool> operator->* ( bool value ) {
         Expression<bool> expr( m_result, value );
         return expr;
     }
     
-    ///////////////////////////////////////////////////////////////////////////
     template<typename T>
-    ResultBuilder& operator <<
-    (
-        const T & value
-    )
-    {
+    ExpressionBuilder& operator << ( const T & value ) {
         m_messageStream << Catch::toString( value );        
         return *this;
     }
     
-    ///////////////////////////////////////////////////////////////////////////
     template<typename MatcherT, typename ArgT>
-    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<typename MatcherT, typename ArgT>
-    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<typename T> friend class Expression;
 
     template<typename T> 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 = "<group>"; };
 		4A6D0C44149B3E1500DB3EAA /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../../../../include/catch.hpp; sourceTree = "<group>"; };
 		4A6D0C46149B3E3D00DB3EAA /* catch_approx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_approx.hpp; sourceTree = "<group>"; };
-		4A6D0C47149B3E3D00DB3EAA /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_capture.hpp; sourceTree = "<group>"; };
+		4A6D0C47149B3E3D00DB3EAA /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_capture.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
 		4A6D0C48149B3E3D00DB3EAA /* catch_commandline.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_commandline.hpp; sourceTree = "<group>"; };
 		4A6D0C49149B3E3D00DB3EAA /* catch_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_common.h; sourceTree = "<group>"; };
 		4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_config.hpp; sourceTree = "<group>"; };