mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Added CATCH_CONFIG_CPP11_LONG_LONG support
This commit is contained in:
		| @@ -16,6 +16,7 @@ | ||||
| // CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods | ||||
| // CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? | ||||
| // CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported | ||||
| // CATCH_CONFIG_CPP11_LONG_LONG : is long long supported? | ||||
|  | ||||
| // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? | ||||
|  | ||||
| @@ -130,6 +131,10 @@ | ||||
| #    define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS | ||||
| #  endif | ||||
|  | ||||
| #  if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) | ||||
| #    define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG | ||||
| #  endif | ||||
|  | ||||
| #endif // __cplusplus >= 201103L | ||||
|  | ||||
| // Now set the actual defines based on the above + anything the user has configured | ||||
| @@ -149,7 +154,10 @@ | ||||
| #   define CATCH_CONFIG_CPP11_TUPLE | ||||
| #endif | ||||
| #if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS) | ||||
| #define CATCH_CONFIG_VARIADIC_MACROS | ||||
| #   define CATCH_CONFIG_VARIADIC_MACROS | ||||
| #endif | ||||
| #if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) | ||||
| #   define CATCH_CONFIG_CPP11_LONG_LONG | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -160,13 +160,51 @@ namespace Internal { | ||||
|         return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); | ||||
|     } | ||||
|  | ||||
| #ifdef CATCH_CONFIG_CPP11_LONG_LONG | ||||
|     // long long to unsigned X | ||||
|     template<Operator Op> bool compare( long long lhs, unsigned int rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( long long lhs, unsigned long rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( long long lhs, unsigned long long rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( long long lhs, unsigned char rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); | ||||
|     } | ||||
|      | ||||
|     // unsigned long long to X | ||||
|     template<Operator Op> bool compare( unsigned long long lhs, int rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( unsigned long long lhs, long rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( unsigned long long lhs, long long rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<long>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op> bool compare( unsigned long long lhs, char rhs ) { | ||||
|         return applyEvaluator<Op>( static_cast<long>( lhs ), rhs ); | ||||
|     } | ||||
|      | ||||
|     // pointer to long long (when comparing against NULL) | ||||
|     template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) { | ||||
|         return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs ); | ||||
|     } | ||||
|     template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) { | ||||
|         return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); | ||||
|     } | ||||
| #endif // CATCH_CONFIG_CPP11_LONG_LONG | ||||
|      | ||||
| #ifdef CATCH_CONFIG_CPP11_NULLPTR | ||||
|     // pointer to nullptr_t (when comparing against nullptr) | ||||
|     template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) { | ||||
|         return Evaluator<T*, T*, Op>::evaluate( CATCH_NULL, rhs ); | ||||
|         return Evaluator<T*, T*, Op>::evaluate( nullptr, rhs ); | ||||
|     } | ||||
|     template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) { | ||||
|         return Evaluator<T*, T*, Op>::evaluate( lhs, CATCH_NULL ); | ||||
|         return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr ); | ||||
|     } | ||||
| #endif // CATCH_CONFIG_CPP11_NULLPTR | ||||
|  | ||||
|   | ||||
| @@ -52,6 +52,11 @@ std::string toString( char value ); | ||||
| std::string toString( signed char value ); | ||||
| std::string toString( unsigned char value ); | ||||
|  | ||||
| #ifdef CATCH_CONFIG_CPP11_LONG_LONG | ||||
| std::string toString( long long value ); | ||||
| std::string toString( unsigned long long value ); | ||||
| #endif | ||||
|  | ||||
| #ifdef CATCH_CONFIG_CPP11_NULLPTR | ||||
| std::string toString( std::nullptr_t ); | ||||
| #endif | ||||
| @@ -65,7 +70,7 @@ std::string toString( std::nullptr_t ); | ||||
|    | ||||
| namespace Detail { | ||||
|  | ||||
|     extern std::string unprintableString; | ||||
|     extern const std::string unprintableString; | ||||
|  | ||||
|     struct BorgType { | ||||
|         template<typename T> BorgType( T const& ); | ||||
|   | ||||
| @@ -15,9 +15,11 @@ namespace Catch { | ||||
|  | ||||
| namespace Detail { | ||||
|  | ||||
|     std::string unprintableString = "{?}"; | ||||
|  | ||||
|     const std::string unprintableString = "{?}"; | ||||
|      | ||||
|     namespace { | ||||
|         const int hexThreshold = 255; | ||||
|  | ||||
|         struct Endianness { | ||||
|             enum Arch { Big, Little }; | ||||
|  | ||||
| @@ -99,7 +101,7 @@ std::string toString( wchar_t* const value ) | ||||
| std::string toString( int value ) { | ||||
|     std::ostringstream oss; | ||||
|     oss << value; | ||||
|     if( value >= 255 ) | ||||
|     if( value > Detail::hexThreshold ) | ||||
|         oss << " (0x" << std::hex << value << ")"; | ||||
|     return oss.str(); | ||||
| } | ||||
| @@ -107,7 +109,7 @@ std::string toString( int value ) { | ||||
| std::string toString( unsigned long value ) { | ||||
|     std::ostringstream oss; | ||||
|     oss << value; | ||||
|     if( value >= 255 ) | ||||
|     if( value > Detail::hexThreshold ) | ||||
|         oss << " (0x" << std::hex << value << ")"; | ||||
|     return oss.str(); | ||||
| } | ||||
| @@ -157,6 +159,23 @@ std::string toString( unsigned char value ) { | ||||
|     return toString( static_cast<char>( value ) ); | ||||
| } | ||||
|  | ||||
| #ifdef CATCH_CONFIG_CPP11_LONG_LONG | ||||
| std::string toString( long long value ) { | ||||
|     std::ostringstream oss; | ||||
|     oss << value; | ||||
|     if( value > Detail::hexThreshold ) | ||||
|         oss << " (0x" << std::hex << value << ")"; | ||||
|     return oss.str(); | ||||
| } | ||||
| std::string toString( unsigned long long value ) { | ||||
|     std::ostringstream oss; | ||||
|     oss << value; | ||||
|     if( value > Detail::hexThreshold ) | ||||
|         oss << " (0x" << std::hex << value << ")"; | ||||
|     return oss.str(); | ||||
| } | ||||
| #endif | ||||
|      | ||||
| #ifdef CATCH_CONFIG_CPP11_NULLPTR | ||||
| std::string toString( std::nullptr_t ) { | ||||
|     return "nullptr"; | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| #include "catch_stream.h" | ||||
| #include "catch_compiler_capabilities.h" | ||||
| #include "catch_suppress_warnings.h" | ||||
|  | ||||
| #include <sstream> | ||||
| #include <string> | ||||
| @@ -231,4 +232,6 @@ namespace Catch { | ||||
|     }; | ||||
|  | ||||
| } | ||||
| #include "catch_reenable_warnings.h" | ||||
|  | ||||
| #endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash