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

Fixed some issues caused by single evaluation work

Commit
2e444861c9a33a28d1776daaeae5019c1d6ddfa0
Author
Phil Nash ·
Parents
e0e74774e275

Files · Download .tar.gz

Changes

 Test/TrickyTests.cpp          | 19 ++++++++++++++++++-
 internal/catch_capture.hpp    | 39 +++++++++++++++++++++++++++++----------
 internal/catch_result_type.h  |  1 +
 internal/catch_resultinfo.hpp | 11 ++++-------
 4 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/Test/TrickyTests.cpp b/Test/TrickyTests.cpp
index 6078733d..1c1877f7 100644
--- a/Test/TrickyTests.cpp
+++ b/Test/TrickyTests.cpp
@@ -41,15 +41,32 @@ TEST_CASE
 ///////////////////////////////////////////////////////////////////////////////
 TEST_CASE
 (
-    "./inprogress/succeeding/Tricky/complex lhs", 
+    "./inprogress/failing/Tricky/complex lhs", 
     "Where the LHS is not a simple value"
 )
 {
+    /*
     int a = 1;
     int b = 2;
 
     // This only captures part of the expression, but issues a warning about the rest
     REQUIRE( a == 2 || b == 2 );
+     */
+}
+///////////////////////////////////////////////////////////////////////////////
+TEST_CASE
+(
+    "./inprogress/failing/Tricky/complex 2", 
+    "Where the LHS is not a simple value"
+)
+{
+    /*
+    int a = 1;
+    int b = 2;
+    
+    // This only captures part of the expression, but issues a warning about the rest
+    REQUIRE( a+1 == b-1 );
+    */
 }
 
 struct Opaque
diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp
index 35c84732..cf27c1aa 100644
--- a/internal/catch_capture.hpp
+++ b/internal/catch_capture.hpp
@@ -155,12 +155,13 @@ inline std::string toString
     return value ? "true" : "false";
 }
     
-class TestFailureException
+struct TestFailureException
 {
 };
-class DummyExceptionType_DontUse
+struct DummyExceptionType_DontUse
 {
 };
+struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
     
 class MutableResultInfo : public ResultInfo
 {
@@ -208,18 +209,21 @@ public:
     {
         m_message = message;
     }
+    
+    ///////////////////////////////////////////////////////////////////////////
+    template<typename RhsT>
+    STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator ||
+    (
+        const RhsT&
+    );
 
     ///////////////////////////////////////////////////////////////////////////
     template<typename RhsT>
-    MutableResultInfo& operator ||
+    STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator &&
     (
         const RhsT&
-    )
-    {
-        m_expressionIncomplete = true;
-        return *this;
-    }
-        
+    );
+    
 private:
     friend class ResultBuilder;
     template<typename T>
@@ -250,7 +254,8 @@ private:
         m_rhs = toString( rhs );
         m_op = OperatorTraits<Op>::getName();
         return *this;
-    }    
+    }
+    
 };
 
 template<typename T>
@@ -335,6 +340,20 @@ public:
         return m_result.captureBoolExpression( m_lhs );
     }
     
+    ///////////////////////////////////////////////////////////////////////////
+    template<typename RhsT>
+    STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator +
+    (
+        const RhsT&
+    );
+    
+    ///////////////////////////////////////////////////////////////////////////
+    template<typename RhsT>
+    STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator -
+    (
+        const RhsT&
+    );
+
 private:
     MutableResultInfo& m_result;
     const T& m_lhs;
diff --git a/internal/catch_result_type.h b/internal/catch_result_type.h
index 4df93880..39a2d5d0 100644
--- a/internal/catch_result_type.h
+++ b/internal/catch_result_type.h
@@ -27,6 +27,7 @@ struct ResultWas{ enum OfType
         
         ExpressionFailed = FailureBit | 1,
         ExplicitFailure = FailureBit | 2,
+        ExpressionTooComplex = FailureBit | 3,
         
         Exception = 0x110,
         
diff --git a/internal/catch_resultinfo.hpp b/internal/catch_resultinfo.hpp
index bbb82631..256618ba 100644
--- a/internal/catch_resultinfo.hpp
+++ b/internal/catch_resultinfo.hpp
@@ -26,8 +26,7 @@ namespace Catch
         ()
         :   m_line( 0 ),
             m_result( ResultWas::Unknown ),
-            m_isNot( false ),
-            m_expressionIncomplete( false )
+            m_isNot( false )
         {}
         
         ///////////////////////////////////////////////////////////////////////////
@@ -48,8 +47,7 @@ namespace Catch
             m_op( isNotExpression( expr ) ? "!" : "" ),
             m_message( message ),
             m_result( result ),
-            m_isNot( isNot ),
-            m_expressionIncomplete( false )
+            m_isNot( isNot )
         {
             if( isNot )
                 m_expr = "!" + m_expr;
@@ -103,8 +101,8 @@ namespace Catch
             if( !hasExpression() )
                 return "";
             
-            return m_expressionIncomplete
-                ? getExpandedExpressionInternal() + " {can't expand the rest of the expression - consider rewriting it}"
+            return m_result == ResultWas::ExpressionTooComplex
+                ? getExpandedExpressionInternal() + " {couldn't fully decompose the expression to evaluate it - please rewrite as a binary comparison}"
                 : getExpandedExpressionInternal();
         }
         
@@ -172,7 +170,6 @@ namespace Catch
         std::string m_message;
         ResultWas::OfType m_result;
         bool m_isNot;
-        bool m_expressionIncomplete;
     };
     
 } // end namespace Catch