From f2d5f1b3e444055ff02ed0536d5d0610b08ecb9f Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 19 Oct 2012 08:01:05 +0100 Subject: [PATCH] Expression has its own result builder - not passed in from expression builder --- include/internal/catch_expression.hpp | 17 +++++++++-------- include/internal/catch_expression_builder.hpp | 14 ++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/include/internal/catch_expression.hpp b/include/internal/catch_expression.hpp index 60aaa626..aa8d0b42 100644 --- a/include/internal/catch_expression.hpp +++ b/include/internal/catch_expression.hpp @@ -18,10 +18,9 @@ class Expression { void operator = ( const Expression& ); public: - Expression( AssertionResultBuilder& result, T lhs ) - : m_result( result.setLhs( Catch::toString( lhs ) ) ), - m_lhs( lhs ) - {} + Expression( T lhs ) : m_lhs( lhs ) { + m_result.setLhs( Catch::toString( lhs ) ); + } template AssertionResultBuilder& operator == ( const RhsT& rhs ) { @@ -61,10 +60,12 @@ public: return captureExpression( rhs ); } - operator AssertionResultBuilder& () { - return m_result.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed ); + AssertionResultBuilder setIsFalse( bool isFalse ) { + return m_result + .setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed ) + .setIsFalse( isFalse ); } - + template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( const RhsT& ); @@ -81,7 +82,7 @@ private: } private: - AssertionResultBuilder& m_result; + AssertionResultBuilder m_result; T m_lhs; }; diff --git a/include/internal/catch_expression_builder.hpp b/include/internal/catch_expression_builder.hpp index deca8022..a3282b95 100644 --- a/include/internal/catch_expression_builder.hpp +++ b/include/internal/catch_expression_builder.hpp @@ -16,24 +16,14 @@ namespace Catch { class ExpressionBuilder { public: - ExpressionBuilder( bool isFalse = false ) - { - m_result.setIsFalse( isFalse ); - } - template Expression operator->* ( const T & operand ) { - Expression expr( m_result, operand ); - return expr; + return Expression( operand ); } Expression operator->* ( bool value ) { - Expression expr( m_result, value ); - return expr; + return Expression( value ); } - -private: - AssertionResultBuilder m_result; }; } // end namespace Catch