catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Added evaluator overloads for case when comparing pointers against NULLs that decay to ints
- Commit
2ffb37229078513b019b530926f7fa3e621f1f1d- Author
- Phil Nash ·
- Parents
a8570dfdfe87
Changes
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 686e0b30..85f12de7 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -125,6 +125,7 @@ namespace Internal { return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); } + // pointer to long (when comparing against NULL) template<Operator Op, typename T> bool compare( long lhs, const T* rhs ) { return Evaluator<const T*, const T*, Op>::evaluate( reinterpret_cast<const T*>( lhs ), rhs ); @@ -145,6 +146,27 @@ namespace Internal { return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); } + // pointer to int (when comparing against NULL) + template<Operator Op, typename T> + bool compare( int lhs, const T* rhs ) { + return Evaluator<const T*, const T*, Op>::evaluate( reinterpret_cast<const T*>( lhs ), rhs ); + } + + template<Operator Op, typename T> + bool compare( int lhs, T* rhs ) { + return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs ); + } + + template<Operator Op, typename T> + bool compare( const T* lhs, int rhs ) { + return Evaluator<const T*, const T*, Op>::evaluate( lhs, reinterpret_cast<const T*>( rhs ) ); + } + + template<Operator Op, typename T> + bool compare( T* lhs, int rhs ) { + return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); + } + } // end of namespace Internal } // end of namespace Catch