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

integrated INTERNAL_CHECK_THAT with new AssertionHandler

Commit
9668410b8e415c22d2665a820a1e113acfd6ae64
Author
Phil Nash ·
Parents
2832e23aa9b4

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp  | 10 +++++-----
 include/internal/catch_decomposer.h | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index b13b9fe6..ef152dae 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -149,11 +149,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
     do { \
-        Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
-        INTERNAL_CATCH_TRY( __catchResult ) { \
-            __catchResult.captureMatch( arg, matcher, #matcher ); \
-        } INTERNAL_CATCH_CATCH( __catchResult, resultDisposition ) \
-        INTERNAL_CATCH_REACT( __catchResult ) \
+        Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
+        INTERNAL_CATCH_TRY( catchAssertionHandler ) { \
+            catchAssertionHandler.handle( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \
+        } INTERNAL_CATCH_CATCH2( catchAssertionHandler ) \
+        INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
     } while( Catch::alwaysFalse() )
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/include/internal/catch_decomposer.h b/include/internal/catch_decomposer.h
index 82e386a5..f289387a 100644
--- a/include/internal/catch_decomposer.h
+++ b/include/internal/catch_decomposer.h
@@ -144,6 +144,38 @@ namespace Catch {
         }
     };
 
+    // !TBD: this is just here temporarily
+    template<typename ArgT, typename MatcherT>
+    class MatchExpr : public ITransientExpression {
+        ArgT const& m_arg;
+        MatcherT const& m_matcher;
+        StringRef m_matcherString;
+        bool m_result;
+    public:
+        MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString )
+        :   m_arg( arg ),
+            m_matcher( matcher ),
+            m_matcherString( matcherString ),
+            m_result( matcher.match( arg ) )
+        {}
+
+        auto isBinaryExpression() const -> bool  override { return true; }
+        auto getResult() const -> bool override { return m_result; }
+
+        void streamReconstructedExpression( std::ostream &os ) const override {
+            auto matcherAsString = m_matcher.toString();
+            os << Catch::Detail::stringify( m_arg ) << ' ';
+            if( matcherAsString == Detail::unprintableString )
+                os << m_matcherString.c_str();
+            else
+                os << matcherAsString;
+        }
+    };
+    template<typename ArgT, typename MatcherT>
+    auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString  ) -> MatchExpr<ArgT, MatcherT> {
+        return MatchExpr<ArgT, MatcherT>( arg, matcher, matcherString );
+    }
+
 } // end namespace Catch
 
 #endif // TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED