diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 6ae888c5..e049d7f5 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -434,6 +434,24 @@ public: return m_result.captureExpression( m_lhs, rhs ); } + /////////////////////////////////////////////////////////////////////////// + MutableResultInfo& operator == + ( + bool rhs + ) + { + return m_result.captureExpression( m_lhs, rhs ); + } + + /////////////////////////////////////////////////////////////////////////// + MutableResultInfo& operator != + ( + bool rhs + ) + { + return m_result.captureExpression( m_lhs, rhs ); + } + /////////////////////////////////////////////////////////////////////////// operator MutableResultInfo& () @@ -591,6 +609,16 @@ public: return expr; } + /////////////////////////////////////////////////////////////////////////// + Expression operator->* + ( + bool value + ) + { + Expression expr( m_result, value ); + return expr; + } + /////////////////////////////////////////////////////////////////////////// template ResultBuilder& operator << diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index ab388d1f..dbc4a646 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -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 +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::value == true ); + REQUIRE( true == is_true::value ); + } + SECTION("compare to false","") + { + REQUIRE( is_true::value == false ); + REQUIRE( false == is_true::value ); + } + + SECTION("negation", "") + { + REQUIRE( !is_true::value ); + } + + SECTION("double negation","") + { + REQUIRE( !!is_true::value ); + } + + SECTION("direct","") + { + REQUIRE( is_true::value ); + REQUIRE_FALSE( is_true::value ); + } +}