mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Expression has its own result builder - not passed in from expression builder
This commit is contained in:
parent
e3b111a39a
commit
f2d5f1b3e4
@ -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<typename RhsT>
|
||||
AssertionResultBuilder& operator == ( const RhsT& rhs ) {
|
||||
@ -61,8 +60,10 @@ public:
|
||||
return captureExpression<Internal::IsNotEqualTo>( 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<typename RhsT>
|
||||
@ -81,7 +82,7 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
AssertionResultBuilder& m_result;
|
||||
AssertionResultBuilder m_result;
|
||||
T m_lhs;
|
||||
};
|
||||
|
||||
|
@ -16,24 +16,14 @@ namespace Catch {
|
||||
class ExpressionBuilder {
|
||||
public:
|
||||
|
||||
ExpressionBuilder( bool isFalse = false )
|
||||
{
|
||||
m_result.setIsFalse( isFalse );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Expression<const T&> operator->* ( const T & operand ) {
|
||||
Expression<const T&> expr( m_result, operand );
|
||||
return expr;
|
||||
return Expression<const T&>( operand );
|
||||
}
|
||||
|
||||
Expression<bool> operator->* ( bool value ) {
|
||||
Expression<bool> expr( m_result, value );
|
||||
return expr;
|
||||
return Expression<bool>( value );
|
||||
}
|
||||
|
||||
private:
|
||||
AssertionResultBuilder m_result;
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
Loading…
Reference in New Issue
Block a user