Fixed issue with evaluating static bools

This commit is contained in:
Phil Nash 2011-08-09 08:18:27 +01:00
parent 4021d65f64
commit 4d0a8d96e6
2 changed files with 71 additions and 0 deletions

View File

@ -434,6 +434,24 @@ public:
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&
()
@ -591,6 +609,16 @@ public:
return expr;
}
///////////////////////////////////////////////////////////////////////////
Expression<bool> operator->*
(
bool value
)
{
Expression<bool> expr( m_result, value );
return expr;
}
///////////////////////////////////////////////////////////////////////////
template<typename T>
ResultBuilder& operator <<

View File

@ -235,3 +235,46 @@ TEST_CASE("./succeeding/boolean member", "")
Obj obj;
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 );
}
}