diff options
| author | Phil Nash | 2012-10-28 20:57:21 +0000 |
|---|---|---|
| committer | Phil Nash | 2012-10-28 20:57:21 +0000 |
| commit | 134e45b3ade922e5cbdb2df6b81830fbd93fe448 (patch) | |
| tree | 2eb7043e1463122e721b44115e607686a30cd0e1 /include | |
| parent | 2f92db9898978ca1ee27c964d8a51fa507391935 (diff) | |
| download | catch3-134e45b3ade922e5cbdb2df6b81830fbd93fe448.tar.gz | |
Fixed #132
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_expression_lhs.hpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp index f7c4fb14..572c8c37 100644 --- a/include/internal/catch_expression_lhs.hpp +++ b/include/internal/catch_expression_lhs.hpp @@ -13,13 +13,7 @@ namespace Catch { - struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - - template<typename T> - inline void setResultIfBoolean( ExpressionResultBuilder&, const T& ) {} - inline void setResultIfBoolean( ExpressionResultBuilder& result, bool value ) { - result.setResultType( value ); - } +struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; // Wraps the LHS of an expression and captures the operator and RHS (if any) - wrapping them all // in an ExpressionResultBuilder object @@ -28,9 +22,7 @@ class ExpressionLhs { void operator = ( const ExpressionLhs& ); public: - ExpressionLhs( T lhs ) : m_lhs( lhs ) { - setResultIfBoolean( m_result.setLhs( Catch::toString( lhs ) ), lhs ); - } + ExpressionLhs( T lhs ) : m_lhs( lhs ) {} template<typename RhsT> ExpressionResultBuilder& operator == ( const RhsT& rhs ) { @@ -71,7 +63,11 @@ public: } ExpressionResultBuilder& negate( bool shouldNegate ) { - return m_result.negate( shouldNegate ); + bool value = m_lhs ? true : false; + return m_result + .setLhs( Catch::toString( value ) ) + .setResultType( value ) + .negate( shouldNegate ); } // Only simple binary expressions are allowed on the LHS. @@ -86,6 +82,7 @@ private: ExpressionResultBuilder& captureExpression( const RhsT& rhs ) { return m_result .setResultType( Internal::compare<Op>( m_lhs, rhs ) ) + .setLhs( Catch::toString( m_lhs ) ) .setRhs( Catch::toString( rhs ) ) .setOp( Internal::OperatorTraits<Op>::getName() ); } |