From 2ffb37229078513b019b530926f7fa3e621f1f1d Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 24 May 2012 18:41:14 +0100 Subject: [PATCH] Added evaluator overloads for case when comparing pointers against NULLs that decay to ints --- include/internal/catch_evaluate.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 686e0b3..85f12de 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -125,6 +125,7 @@ namespace Internal { return applyEvaluator( static_cast( lhs ), rhs ); } + // pointer to long (when comparing against NULL) template bool compare( long lhs, const T* rhs ) { return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); @@ -145,6 +146,27 @@ namespace Internal { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } + // pointer to int (when comparing against NULL) + template + bool compare( int lhs, const T* rhs ) { + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + } + + template + bool compare( int lhs, T* rhs ) { + return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); + } + + template + bool compare( const T* lhs, int rhs ) { + return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); + } + + template + bool compare( T* lhs, int rhs ) { + return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); + } + } // end of namespace Internal } // end of namespace Catch