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& );
|
void operator = ( const Expression& );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Expression( AssertionResultBuilder& result, T lhs )
|
Expression( T lhs ) : m_lhs( lhs ) {
|
||||||
: m_result( result.setLhs( Catch::toString( lhs ) ) ),
|
m_result.setLhs( Catch::toString( lhs ) );
|
||||||
m_lhs( lhs )
|
}
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
AssertionResultBuilder& operator == ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator == ( const RhsT& rhs ) {
|
||||||
@ -61,8 +60,10 @@ public:
|
|||||||
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
operator AssertionResultBuilder& () {
|
AssertionResultBuilder setIsFalse( bool isFalse ) {
|
||||||
return m_result.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed );
|
return m_result
|
||||||
|
.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed )
|
||||||
|
.setIsFalse( isFalse );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
@ -81,7 +82,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AssertionResultBuilder& m_result;
|
AssertionResultBuilder m_result;
|
||||||
T m_lhs;
|
T m_lhs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,24 +16,14 @@ namespace Catch {
|
|||||||
class ExpressionBuilder {
|
class ExpressionBuilder {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ExpressionBuilder( bool isFalse = false )
|
|
||||||
{
|
|
||||||
m_result.setIsFalse( isFalse );
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Expression<const T&> operator->* ( const T & operand ) {
|
Expression<const T&> operator->* ( const T & operand ) {
|
||||||
Expression<const T&> expr( m_result, operand );
|
return Expression<const T&>( operand );
|
||||||
return expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression<bool> operator->* ( bool value ) {
|
Expression<bool> operator->* ( bool value ) {
|
||||||
Expression<bool> expr( m_result, value );
|
return Expression<bool>( value );
|
||||||
return expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
AssertionResultBuilder m_result;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user