diff --git a/Test/ConditionTests.cpp b/Test/ConditionTests.cpp index 5a2c5751..96fcb1a7 100644 --- a/Test/ConditionTests.cpp +++ b/Test/ConditionTests.cpp @@ -224,7 +224,16 @@ TEST_CASE( "./succeeding/conditions/ptr", "Pointers can be compared to null" ) TestData data; p = &data; + REQUIRE( p != NULL ); + + const TestData* cp = p; + REQUIRE( cp != NULL ); + + const TestData* const cpc = p; + REQUIRE( cpc != NULL ); + +// REQUIRE( NULL != p ); // gives warning, but should compile and run ok } // Not (!) tests diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp index 69753f7a..abefecc7 100644 --- a/internal/catch_capture.hpp +++ b/internal/catch_capture.hpp @@ -395,65 +395,65 @@ private: const T& m_lhs; }; - template - class PtrExpression +template +class PtrExpression +{ +public: + + /////////////////////////////////////////////////////////////////////////// + PtrExpression + ( + MutableResultInfo& result, + const LhsT* lhs + ) + : m_result( result ), + m_lhs( lhs ) + {} + + /////////////////////////////////////////////////////////////////////////// + template + MutableResultInfo& operator == + ( + const RhsT* rhs + ) { - public: + return m_result.captureExpression( m_lhs, rhs ); + } - /////////////////////////////////////////////////////////////////////////// - PtrExpression - ( - MutableResultInfo& result, - const LhsT* lhs - ) - : m_result( result ), - m_lhs( lhs ) - {} - - /////////////////////////////////////////////////////////////////////////// - template - MutableResultInfo& operator == - ( - const RhsT* rhs - ) - { - return m_result.captureExpression( m_lhs, rhs ); - } - - /////////////////////////////////////////////////////////////////////////// - // This catches NULL - MutableResultInfo& operator == - ( - LhsT* rhs - ) - { - return m_result.captureExpression( m_lhs, rhs ); - } - - /////////////////////////////////////////////////////////////////////////// - template - MutableResultInfo& operator != - ( - const RhsT* rhs - ) - { - return m_result.captureExpression( m_lhs, rhs ); - } - - /////////////////////////////////////////////////////////////////////////// - // This catches NULL - MutableResultInfo& operator != - ( - LhsT* rhs - ) - { - return m_result.captureExpression( m_lhs, rhs ); - } - - private: - MutableResultInfo& m_result; - const LhsT* m_lhs; - }; + /////////////////////////////////////////////////////////////////////////// + // This catches NULL + MutableResultInfo& operator == + ( + LhsT* rhs + ) + { + return m_result.captureExpression( m_lhs, rhs ); + } + + /////////////////////////////////////////////////////////////////////////// + template + MutableResultInfo& operator != + ( + const RhsT* rhs + ) + { + return m_result.captureExpression( m_lhs, rhs ); + } + + /////////////////////////////////////////////////////////////////////////// + // This catches NULL + MutableResultInfo& operator != + ( + LhsT* rhs + ) + { + return m_result.captureExpression( m_lhs, rhs ); + } + +private: + MutableResultInfo& m_result; + const LhsT* m_lhs; +}; class ResultBuilder { diff --git a/internal/catch_evaluate.hpp b/internal/catch_evaluate.hpp index 2d020ca5..0bfe373f 100644 --- a/internal/catch_evaluate.hpp +++ b/internal/catch_evaluate.hpp @@ -216,6 +216,20 @@ namespace Internal { return applyEvaluator( static_cast( lhs ), rhs, testLhsSign( lhs ) ); } + + template + bool compare( long lhs, const T* rhs ) + { + return Evaluator::evaluate( reinterpret_cast( NULL ), rhs ); + + } + + template + bool compare( long lhs, T* rhs ) + { + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + + } } // end of namespace Internal } // end of namespace Catch