diff --git a/README.md b/README.md index 5a0a5563..9c4ca2cd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](https://raw.github.com/philsquared/Catch/Integration/catch-logo-small.png) -## CATCH v0.9 build 35 (integration branch) +## CATCH v0.9 build 36 (integration branch) An automated test framework for C, C++ and Objective-C. This branch may contain code that is experimental or not yet fully tested. diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 5971022a..db1be5ee 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -33,6 +33,14 @@ namespace Internal { template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; + template + inline T& opCast(const T& t) { return const_cast(t); } + +// nullptr_t support based on pull request #154 from Konstantin Baumann +#ifdef CATCH_CONFIG_CPP11_NULLPTR + inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } +#endif // CATCH_CONFIG_CPP11_NULLPTR + // So the compare overloads can be operator agnostic we convey the operator as a template // enum, which is used to specialise an Evaluator for doing the comparison. @@ -42,37 +50,37 @@ namespace Internal { template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs) { - return const_cast( lhs ) == const_cast( rhs ); + return opCast( lhs ) == opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) != const_cast( rhs ); + return opCast( lhs ) != opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) < const_cast( rhs ); + return opCast( lhs ) < opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) > const_cast( rhs ); + return opCast( lhs ) > opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) >= const_cast( rhs ); + return opCast( lhs ) >= opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) <= const_cast( rhs ); + return opCast( lhs ) <= opCast( rhs ); } }; @@ -149,6 +157,16 @@ namespace Internal { template bool compare( T* lhs, int rhs ) { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } + +#ifdef CATCH_CONFIG_CPP11_NULLPTR + // pointer to nullptr_t (when comparing against nullptr) + template bool compare( std::nullptr_t, T* rhs ) { + return Evaluator::evaluate( NULL, rhs ); + } + template bool compare( T* lhs, std::nullptr_t ) { + return Evaluator::evaluate( lhs, NULL ); + } +#endif // CATCH_CONFIG_CPP11_NULLPTR } // end of namespace Internal } // end of namespace Catch diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 856b33fc..3fa228b3 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -189,7 +189,6 @@ namespace Catch bool aborting; }; - // !Work In progress struct IStreamingReporter : IShared { virtual ~IStreamingReporter(); diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 5c5f4ccd..05478a72 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 0, 9, 35, "integration" ); + Version libraryVersion( 0, 9, 36, "integration" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt index 30599ef3..e4441aa0 100644 --- a/projects/SelfTest/Baselines/approvedResults.txt +++ b/projects/SelfTest/Baselines/approvedResults.txt @@ -1,6 +1,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -CatchSelfTest is a CATCH v0.9 b35 (integration) host application. +CatchSelfTest is a CATCH v0.9 b36 (integration) host application. Run with -? for options ------------------------------------------------------------------------------- @@ -5278,10 +5278,10 @@ with expansion: ------------------------------------------------------------------------------- Anonymous test case 1 ------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:12 +VariadicMacrosTests.cpp:11 ............................................................................... -VariadicMacrosTests.cpp:14: +VariadicMacrosTests.cpp:13: PASSED: with message: anonymous test case @@ -5289,10 +5289,10 @@ with message: ------------------------------------------------------------------------------- Test case with one argument ------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:17 +VariadicMacrosTests.cpp:16 ............................................................................... -VariadicMacrosTests.cpp:19: +VariadicMacrosTests.cpp:18: PASSED: with message: no assertions @@ -5301,10 +5301,10 @@ with message: Variadic macros Section with one argument ------------------------------------------------------------------------------- -VariadicMacrosTests.cpp:24 +VariadicMacrosTests.cpp:23 ............................................................................... -VariadicMacrosTests.cpp:26: +VariadicMacrosTests.cpp:25: PASSED: with message: no assertions @@ -5535,7 +5535,7 @@ with message: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -CatchSelfTest is a CATCH v0.9 b35 (integration) host application. +CatchSelfTest is a CATCH v0.9 b36 (integration) host application. Run with -? for options ------------------------------------------------------------------------------- @@ -14009,18 +14009,18 @@ TrickyTests.cpp:349: s == "7" succeeded for: "7" == "7" [Finished: 'non streamable - with conv. op' All tests passed (1 assertion in 1 test case)] [Running: Anonymous test case 1] -VariadicMacrosTests.cpp:14: succeeded +VariadicMacrosTests.cpp:13: succeeded [with message: anonymous test case] [Finished: 'Anonymous test case 1' All tests passed (1 assertion in 1 test case)] [Running: Test case with one argument] -VariadicMacrosTests.cpp:19: succeeded +VariadicMacrosTests.cpp:18: succeeded [with message: no assertions] [Finished: 'Test case with one argument' All tests passed (1 assertion in 1 test case)] [Running: Variadic macros] [Started section: 'Section with one argument'] -VariadicMacrosTests.cpp:26: succeeded +VariadicMacrosTests.cpp:25: succeeded [with message: no assertions] [End of section: 'Section with one argument' 1 assertion passed] diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index c79ad008..ec07f1fc 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -348,3 +348,15 @@ TEST_CASE( "non streamable - with conv. op", "" ) std::string s = Catch::toString( awkward ); REQUIRE( s == "7" ); } + +#ifdef CATCH_CONFIG_CPP11_NULLPTR + +#include + +TEST_CASE( "null_ptr", "" ) +{ + std::unique_ptr ptr; + REQUIRE(ptr.get() == nullptr); +} + +#endif diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 5993fa47..748d288c 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -503,8 +503,8 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; - CLANG_CXX_LIBRARY = "compiler-default"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_CXX0X_EXTENSIONS = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; @@ -522,7 +522,7 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; - GCC_VERSION = ""; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; @@ -551,8 +551,8 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; - CLANG_CXX_LIBRARY = "compiler-default"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_CXX0X_EXTENSIONS = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; @@ -564,7 +564,7 @@ GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; - GCC_VERSION = ""; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; diff --git a/single_include/catch.hpp b/single_include/catch.hpp index d53a8600..672d9ead 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v0.9 build 35 (integration branch) - * Generated: 2013-04-20 23:19:15.811241 + * CATCH v0.9 build 36 (integration branch) + * Generated: 2013-04-22 18:53:02.845247 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -21,14 +21,6 @@ #pragma clang diagnostic ignored "-Wpadded" #endif -// Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ - ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ - ( defined __GNUC__ && __GNUC__ >= 3 ) || \ - ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) - #define CATCH_CONFIG_VARIADIC_MACROS -#endif - // #included from: internal/catch_notimplemented_exception.h #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED @@ -372,6 +364,77 @@ namespace Catch { }; } +// #included from: internal/catch_compiler_capabilities.h +#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED + +// Much of the following code is based on Boost (1.53) + +//////////////////////////////////////////////////////////////////////////////// +// Borland +#ifdef __BORLANDC__ + +#if (__BORLANDC__ > 0x582 ) +//#define CATCH_CONFIG_SFINAE // Not confirmed +#endif + +#endif // __BORLANDC__ + +//////////////////////////////////////////////////////////////////////////////// +// EDG +#ifdef __EDG_VERSION__ + +#if (__EDG_VERSION__ > 238 ) +//#define CATCH_CONFIG_SFINAE // Not confirmed +#endif + +#endif // __EDG_VERSION__ + +//////////////////////////////////////////////////////////////////////////////// +// Digital Mars +#ifdef __DMC__ + +#if (__DMC__ > 0x840 ) +//#define CATCH_CONFIG_SFINAE // Not confirmed +#endif + +#endif // __DMC__ + +//////////////////////////////////////////////////////////////////////////////// +// GCC +#ifdef __GNUC__ + +#if __GNUC__ < 3 + +#if (__GNUC_MINOR__ >= 96 ) +#define CATCH_CONFIG_SFINAE +#endif + +#elif __GNUC__ >= 3 + +// #define CATCH_CONFIG_SFINAE // Taking this out completely for now + +#endif // __GNUC__ < 3 + +#endif // __GNUC__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#ifdef _MSC_VER + +#if (_MSC_VER >= 1310 ) // (VC++ 7.0+) +//#define CATCH_CONFIG_SFINAE // Not confirmed +#endif + +#endif // _MSC_VER + +// Use variadic macros if the compiler supports them +#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ + ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ + ( defined __GNUC__ && __GNUC__ >= 3 ) || \ + ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) + #define CATCH_CONFIG_VARIADIC_MACROS +#endif + namespace Catch { template @@ -508,69 +571,6 @@ private: #define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED // Try to detect if the current compiler supports SFINAE -// #included from: catch_compiler_capabilities.h -#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED - -// Much of the following code is based on Boost (1.53) - -//////////////////////////////////////////////////////////////////////////////// -// Borland -#ifdef __BORLANDC__ - -#if (__BORLANDC__ > 0x582 ) -//#define CATCH_SFINAE // Not confirmed -#endif - -#endif // __BORLANDC__ - -//////////////////////////////////////////////////////////////////////////////// -// EDG -#ifdef __EDG_VERSION__ - -#if (__EDG_VERSION__ > 238 ) -//#define CATCH_SFINAE // Not confirmed -#endif - -#endif // __EDG_VERSION__ - -//////////////////////////////////////////////////////////////////////////////// -// Digital Mars -#ifdef __DMC__ - -#if (__DMC__ > 0x840 ) -//#define CATCH_SFINAE // Not confirmed -#endif - -#endif // __DMC__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -#if __GNUC__ < 3 - -#if (__GNUC_MINOR__ >= 96 ) -#define CATCH_SFINAE -#endif - -#elif __GNUC__ >= 3 - -// #define CATCH_SFINAE // Taking this out completely for now - -#endif // __GNUC__ < 3 - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#if (_MSC_VER >= 1310 ) // (VC++ 7.0+) -//#define CATCH_SFINAE // Not confirmed -#endif - -#endif // _MSC_VER - namespace Catch { @@ -585,7 +585,7 @@ namespace Catch { char sizer[2]; }; -#ifdef CATCH_SFINAE +#ifdef CATCH_CONFIG_SFINAE template struct NotABooleanExpression; @@ -597,7 +597,7 @@ namespace Catch { template<> struct SizedIf : TrueType {}; template<> struct SizedIf : FalseType {}; -#endif // CATCH_SFINAE +#endif // CATCH_CONFIG_SFINAE } // end namespace Catch @@ -656,8 +656,8 @@ namespace Detail { // SFINAE is currently disabled by default for all compilers. // If the non SFINAE version of IsStreamInsertable is ambiguous for you -// and your compiler supports SFINAE, try #defining CATCH_SFINAE -#ifdef CATCH_SFINAE +// and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE +#ifdef CATCH_CONFIG_SFINAE template class IsStreamInsertableHelper { @@ -993,6 +993,14 @@ namespace Internal { template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; + template + inline T& opCast(const T& t) { return const_cast(t); } + +// nullptr_t support based on pull request #154 from Konstantin Baumann +#ifdef CATCH_CONFIG_CPP11_NULLPTR + inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } +#endif // CATCH_CONFIG_CPP11_NULLPTR + // So the compare overloads can be operator agnostic we convey the operator as a template // enum, which is used to specialise an Evaluator for doing the comparison. template @@ -1001,37 +1009,37 @@ namespace Internal { template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs) { - return const_cast( lhs ) == const_cast( rhs ); + return opCast( lhs ) == opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) != const_cast( rhs ); + return opCast( lhs ) != opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) < const_cast( rhs ); + return opCast( lhs ) < opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) > const_cast( rhs ); + return opCast( lhs ) > opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) >= const_cast( rhs ); + return opCast( lhs ) >= opCast( rhs ); } }; template struct Evaluator { static bool evaluate( const T1& lhs, const T2& rhs ) { - return const_cast( lhs ) <= const_cast( rhs ); + return opCast( lhs ) <= opCast( rhs ); } }; @@ -1109,6 +1117,16 @@ namespace Internal { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } +#ifdef CATCH_CONFIG_CPP11_NULLPTR + // pointer to nullptr_t (when comparing against nullptr) + template bool compare( std::nullptr_t, T* rhs ) { + return Evaluator::evaluate( NULL, rhs ); + } + template bool compare( T* lhs, std::nullptr_t ) { + return Evaluator::evaluate( lhs, NULL ); + } +#endif // CATCH_CONFIG_CPP11_NULLPTR + } // end of namespace Internal } // end of namespace Catch @@ -2420,7 +2438,6 @@ namespace Catch bool aborting; }; - // !Work In progress struct IStreamingReporter : IShared { virtual ~IStreamingReporter(); @@ -6155,7 +6172,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 0, 9, 35, "integration" ); + Version libraryVersion( 0, 9, 36, "integration" ); } // #included from: catch_text.hpp