mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fixed issue with evaluating static bools
This commit is contained in:
parent
4021d65f64
commit
4d0a8d96e6
@ -434,6 +434,24 @@ public:
|
|||||||
return m_result.captureExpression<Internal::IsGreaterThanOrEqualTo>( m_lhs, rhs );
|
return m_result.captureExpression<Internal::IsGreaterThanOrEqualTo>( m_lhs, rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
MutableResultInfo& operator ==
|
||||||
|
(
|
||||||
|
bool rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return m_result.captureExpression<Internal::IsEqualTo>( m_lhs, rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
MutableResultInfo& operator !=
|
||||||
|
(
|
||||||
|
bool rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return m_result.captureExpression<Internal::IsNotEqualTo>( m_lhs, rhs );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
operator MutableResultInfo&
|
operator MutableResultInfo&
|
||||||
()
|
()
|
||||||
@ -591,6 +609,16 @@ public:
|
|||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
Expression<bool> operator->*
|
||||||
|
(
|
||||||
|
bool value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Expression<bool> expr( m_result, value );
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ResultBuilder& operator <<
|
ResultBuilder& operator <<
|
||||||
|
@ -235,3 +235,46 @@ TEST_CASE("./succeeding/boolean member", "")
|
|||||||
Obj obj;
|
Obj obj;
|
||||||
REQUIRE( obj.prop != NULL );
|
REQUIRE( obj.prop != NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests for a problem submitted by Ralph McArdell
|
||||||
|
//
|
||||||
|
// The static bool value should not need to be defined outside the
|
||||||
|
// struct it is declared in - but when evaluating it in a deduced
|
||||||
|
// context it appears to require the extra definition.
|
||||||
|
// The issue was fixed by adding bool overloads to bypass the
|
||||||
|
// templates that were deduce it.
|
||||||
|
template <bool B>
|
||||||
|
struct is_true
|
||||||
|
{
|
||||||
|
static const bool value = B;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE( "./succeeding/unimplemented static bool", "static bools can be evaluated" )
|
||||||
|
{
|
||||||
|
SECTION("compare to true","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<true>::value == true );
|
||||||
|
REQUIRE( true == is_true<true>::value );
|
||||||
|
}
|
||||||
|
SECTION("compare to false","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<false>::value == false );
|
||||||
|
REQUIRE( false == is_true<false>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("negation", "")
|
||||||
|
{
|
||||||
|
REQUIRE( !is_true<false>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("double negation","")
|
||||||
|
{
|
||||||
|
REQUIRE( !!is_true<true>::value );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("direct","")
|
||||||
|
{
|
||||||
|
REQUIRE( is_true<true>::value );
|
||||||
|
REQUIRE_FALSE( is_true<false>::value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user