Allow { NULL <op> T }to work

This commit is contained in:
Phil Nash 2011-03-18 19:08:33 +00:00
parent ef611c65d9
commit 7dfd830a3a
3 changed files with 80 additions and 57 deletions

View File

@ -224,7 +224,16 @@ TEST_CASE( "./succeeding/conditions/ptr", "Pointers can be compared to null" )
TestData data; TestData data;
p = &data; p = &data;
REQUIRE( p != NULL ); 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 // Not (!) tests

View File

@ -395,10 +395,10 @@ private:
const T& m_lhs; const T& m_lhs;
}; };
template<typename LhsT> template<typename LhsT>
class PtrExpression class PtrExpression
{ {
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
PtrExpression PtrExpression
@ -450,10 +450,10 @@ private:
return m_result.captureExpression<Internal::IsNotEqualTo>( m_lhs, rhs ); return m_result.captureExpression<Internal::IsNotEqualTo>( m_lhs, rhs );
} }
private: private:
MutableResultInfo& m_result; MutableResultInfo& m_result;
const LhsT* m_lhs; const LhsT* m_lhs;
}; };
class ResultBuilder class ResultBuilder
{ {

View File

@ -217,6 +217,20 @@ namespace Internal
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs, testLhsSign( lhs ) ); return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs, testLhsSign( lhs ) );
} }
template<Operator Op, typename T>
bool compare( long lhs, const T* rhs )
{
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( NULL ), rhs );
}
template<Operator Op, typename T>
bool compare( long lhs, T* rhs )
{
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
}
} // end of namespace Internal } // end of namespace Internal
} // end of namespace Catch } // end of namespace Catch