/* * catch_evaluate.hpp * Catch * * Created by Phil on 04/03/2011. * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ #ifndef TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED namespace Catch { enum Operator { IsEqualTo, IsNotEqualTo, IsLessThan, IsGreaterThan, IsLessThanOrEqualTo, IsGreaterThanOrEqualTo }; template class Evaluator{}; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs == rhs; } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs != rhs; } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs < rhs; } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs > rhs; } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs >= rhs; } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { return lhs <= rhs; } }; template bool compare( const T1& lhs, const T2& rhs ) { return Evaluator::evaluate( lhs, rhs ); } // unsigned X to int template bool compare( unsigned int lhs, int rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } template bool compare( unsigned long lhs, int rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } template bool compare( unsigned char lhs, int rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } // unsigned X to long template bool compare( unsigned int lhs, long rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } template bool compare( unsigned long lhs, long rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } template bool compare( unsigned char lhs, long rhs ) { return Evaluator::evaluate( lhs, static_cast( rhs ) ); } // int to unsigned X template bool compare( int lhs, unsigned int rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } template bool compare( int lhs, unsigned long rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } template bool compare( int lhs, unsigned char rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } // long to unsigned X template bool compare( long lhs, unsigned int rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } template bool compare( long lhs, unsigned long rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } template bool compare( long lhs, unsigned char rhs ) { return Evaluator::evaluate( static_cast( lhs ), rhs ); } } #endif // TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED