From 805de43a3dfc14b03927afb66d3856e9a72eaa64 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 1 Jul 2015 07:33:27 +0100 Subject: [PATCH] Use CATCH_NULL instead of NULL - expands to nullptr if CATCH_CONFIG_CPP11_NULLPTR is defined (see #444) --- include/external/clara.h | 8 ++-- .../internal/catch_compiler_capabilities.h | 6 +++ include/internal/catch_context_impl.hpp | 8 ++-- include/internal/catch_debugger.hpp | 2 +- include/internal/catch_evaluate.hpp | 4 +- include/internal/catch_objc.hpp | 2 +- include/internal/catch_option.hpp | 12 ++--- include/internal/catch_ptr.hpp | 8 ++-- include/internal/catch_registry_hub.hpp | 4 +- include/internal/catch_reporter_registry.hpp | 2 +- include/internal/catch_runner_impl.hpp | 6 +-- include/internal/catch_section_info.hpp | 2 +- include/internal/catch_stream.hpp | 4 +- include/internal/catch_test_case_tracker.hpp | 8 ++-- include/internal/catch_timer.hpp | 2 +- include/internal/catch_tostring.h | 4 +- include/internal/catch_xmlwriter.hpp | 5 ++- .../Baselines/console.sw.approved.txt | 44 +++++++++---------- .../SelfTest/Baselines/xml.sw.approved.txt | 44 +++++++++---------- projects/SelfTest/CmdLineTests.cpp | 2 +- projects/SelfTest/ConditionTests.cpp | 22 +++++----- projects/SelfTest/MiscTests.cpp | 8 ++-- projects/SelfTest/TestMain.cpp | 2 +- projects/SelfTest/ToStringTuple.cpp | 2 + projects/SelfTest/TrickyTests.cpp | 2 +- 25 files changed, 112 insertions(+), 101 deletions(-) diff --git a/include/external/clara.h b/include/external/clara.h index bc162806..0971ebf5 100644 --- a/include/external/clara.h +++ b/include/external/clara.h @@ -264,11 +264,11 @@ namespace Clara { template class BoundArgFunction { public: - BoundArgFunction() : functionObj( NULL ) {} + BoundArgFunction() : functionObj( CATCH_NULL ) {} BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} - BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {} + BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CATCH_NULL ) {} BoundArgFunction& operator = ( BoundArgFunction const& other ) { - IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL; + IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL; delete functionObj; functionObj = newFunctionObj; return *this; @@ -284,7 +284,7 @@ namespace Clara { bool takesArg() const { return functionObj->takesArg(); } bool isSet() const { - return functionObj != NULL; + return functionObj != CATCH_NULL; } private: IArgFunction* functionObj; diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index 20528c29..db8100f0 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -162,6 +162,12 @@ # define CATCH_NOEXCEPT_IS(x) #endif +// nullptr support +#ifdef CATCH_CONFIG_CPP11_NULLPTR +# define CATCH_NULL nullptr +#else +# define CATCH_NULL NULL +#endif #endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context_impl.hpp index a495503c..3c97fcb1 100644 --- a/include/internal/catch_context_impl.hpp +++ b/include/internal/catch_context_impl.hpp @@ -17,7 +17,7 @@ namespace Catch { class Context : public IMutableContext { - Context() : m_config( NULL ), m_runner( NULL ), m_resultCapture( NULL ) {} + Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {} Context( Context const& ); void operator=( Context const& ); @@ -63,7 +63,7 @@ namespace Catch { m_generatorsByTestName.find( testName ); return it != m_generatorsByTestName.end() ? it->second - : NULL; + : CATCH_NULL; } IGeneratorsForTest& getGeneratorsForCurrentTest() { @@ -84,7 +84,7 @@ namespace Catch { }; namespace { - Context* currentContext = NULL; + Context* currentContext = CATCH_NULL; } IMutableContext& getCurrentMutableContext() { if( !currentContext ) @@ -105,7 +105,7 @@ namespace Catch { void cleanUpContext() { delete currentContext; - currentContext = NULL; + currentContext = CATCH_NULL; } } diff --git a/include/internal/catch_debugger.hpp b/include/internal/catch_debugger.hpp index 4151aec7..8c552661 100644 --- a/include/internal/catch_debugger.hpp +++ b/include/internal/catch_debugger.hpp @@ -50,7 +50,7 @@ // Call sysctl. size = sizeof(info); - if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) != 0 ) { + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) { Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; return false; } diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 2f85a2b9..ab9db784 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -163,10 +163,10 @@ namespace Internal { #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 ); + return Evaluator::evaluate( CATCH_NULL, rhs ); } template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, NULL ); + return Evaluator::evaluate( lhs, CATCH_NULL ); } #endif // CATCH_CONFIG_CPP11_NULLPTR diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index 7e315c22..489cf558 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -72,7 +72,7 @@ namespace Catch { inline size_t registerTestMethods() { size_t noTestMethods = 0; - int noClasses = objc_getClassList( NULL, 0 ); + int noClasses = objc_getClassList( CATCH_NULL, 0 ); Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); objc_getClassList( classes, noClasses ); diff --git a/include/internal/catch_option.hpp b/include/internal/catch_option.hpp index bf3bce3d..5413abf0 100644 --- a/include/internal/catch_option.hpp +++ b/include/internal/catch_option.hpp @@ -16,12 +16,12 @@ namespace Catch { template class Option { public: - Option() : nullableValue( NULL ) {} + Option() : nullableValue( CATCH_NULL ) {} Option( T const& _value ) : nullableValue( new( storage ) T( _value ) ) {} Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : NULL ) + : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL ) {} ~Option() { @@ -45,7 +45,7 @@ namespace Catch { void reset() { if( nullableValue ) nullableValue->~T(); - nullableValue = NULL; + nullableValue = CATCH_NULL; } T& operator*() { return *nullableValue; } @@ -57,10 +57,10 @@ namespace Catch { return nullableValue ? *nullableValue : defaultValue; } - bool some() const { return nullableValue != NULL; } - bool none() const { return nullableValue == NULL; } + bool some() const { return nullableValue != CATCH_NULL; } + bool none() const { return nullableValue == CATCH_NULL; } - bool operator !() const { return nullableValue == NULL; } + bool operator !() const { return nullableValue == CATCH_NULL; } operator SafeBool::type() const { return SafeBool::makeSafe( some() ); } diff --git a/include/internal/catch_ptr.hpp b/include/internal/catch_ptr.hpp index 3d76e328..e37da385 100644 --- a/include/internal/catch_ptr.hpp +++ b/include/internal/catch_ptr.hpp @@ -23,7 +23,7 @@ namespace Catch { template class Ptr { public: - Ptr() : m_p( NULL ){} + Ptr() : m_p( CATCH_NULL ){} Ptr( T* p ) : m_p( p ){ if( m_p ) m_p->addRef(); @@ -39,7 +39,7 @@ namespace Catch { void reset() { if( m_p ) m_p->release(); - m_p = NULL; + m_p = CATCH_NULL; } Ptr& operator = ( T* p ){ Ptr temp( p ); @@ -56,8 +56,8 @@ namespace Catch { const T* get() const{ return m_p; } T& operator*() const { return *m_p; } T* operator->() const { return m_p; } - bool operator !() const { return m_p == NULL; } - operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); } + bool operator !() const { return m_p == CATCH_NULL; } + operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); } private: T* m_p; diff --git a/include/internal/catch_registry_hub.hpp b/include/internal/catch_registry_hub.hpp index 303a843a..cd6a4e07 100644 --- a/include/internal/catch_registry_hub.hpp +++ b/include/internal/catch_registry_hub.hpp @@ -55,7 +55,7 @@ namespace Catch { // Single, global, instance inline RegistryHub*& getTheRegistryHub() { - static RegistryHub* theRegistryHub = NULL; + static RegistryHub* theRegistryHub = CATCH_NULL; if( !theRegistryHub ) theRegistryHub = new RegistryHub(); return theRegistryHub; @@ -70,7 +70,7 @@ namespace Catch { } void cleanUp() { delete getTheRegistryHub(); - getTheRegistryHub() = NULL; + getTheRegistryHub() = CATCH_NULL; cleanUpContext(); } std::string translateActiveException() { diff --git a/include/internal/catch_reporter_registry.hpp b/include/internal/catch_reporter_registry.hpp index 2ce24bef..3e2ae4c9 100644 --- a/include/internal/catch_reporter_registry.hpp +++ b/include/internal/catch_reporter_registry.hpp @@ -25,7 +25,7 @@ namespace Catch { virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const { FactoryMap::const_iterator it = m_factories.find( name ); if( it == m_factories.end() ) - return NULL; + return CATCH_NULL; return it->second->create( ReporterConfig( config ) ); } diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index e6893518..5c39bcb2 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -62,7 +62,7 @@ namespace Catch { explicit RunContext( Ptr const& config, Ptr const& reporter ) : m_runInfo( config->name() ), m_context( getCurrentMutableContext() ), - m_activeTestCase( NULL ), + m_activeTestCase( CATCH_NULL ), m_config( config ), m_reporter( reporter ), m_prevRunner( m_context.getRunner() ), @@ -78,7 +78,7 @@ namespace Catch { virtual ~RunContext() { m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); m_context.setRunner( m_prevRunner ); - m_context.setConfig( NULL ); + m_context.setConfig( CATCH_NULL ); m_context.setResultCapture( m_prevResultCapture ); m_context.setConfig( m_prevConfig ); } @@ -119,7 +119,7 @@ namespace Catch { redirectedCerr, aborting() ) ); - m_activeTestCase = NULL; + m_activeTestCase = CATCH_NULL; m_testCaseTracker.reset(); return deltaTotals; diff --git a/include/internal/catch_section_info.hpp b/include/internal/catch_section_info.hpp index f60896c4..6258a281 100644 --- a/include/internal/catch_section_info.hpp +++ b/include/internal/catch_section_info.hpp @@ -36,7 +36,7 @@ namespace Catch { RunningSection( std::string const& name ) : m_state( Root ), - m_parent( NULL ), + m_parent( CATCH_NULL ), m_name( name ) {} diff --git a/include/internal/catch_stream.hpp b/include/internal/catch_stream.hpp index 604ed97b..42933487 100644 --- a/include/internal/catch_stream.hpp +++ b/include/internal/catch_stream.hpp @@ -65,7 +65,7 @@ namespace Catch { }; Stream::Stream() - : streamBuf( NULL ), isOwned( false ) + : streamBuf( CATCH_NULL ), isOwned( false ) {} Stream::Stream( std::streambuf* _streamBuf, bool _isOwned ) @@ -75,7 +75,7 @@ namespace Catch { void Stream::release() { if( isOwned ) { delete streamBuf; - streamBuf = NULL; + streamBuf = CATCH_NULL; isOwned = false; } } diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index 86b6be50..eb2616e0 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -8,6 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED +#include "catch_compiler_capabilities.h" + #include #include #include @@ -60,7 +62,7 @@ namespace SectionTracking { TrackedSections::iterator it = m_children.find( childName ); return it != m_children.end() ? &it->second - : NULL; + : CATCH_NULL; } inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) { if( TrackedSection* child = findChild( childName ) ) @@ -82,7 +84,7 @@ namespace SectionTracking { class TestCaseTracker { public: TestCaseTracker( std::string const& testCaseName ) - : m_testCase( testCaseName, NULL ), + : m_testCase( testCaseName, CATCH_NULL ), m_currentSection( &m_testCase ), m_completedASectionThisRun( false ) {} @@ -99,7 +101,7 @@ namespace SectionTracking { void leaveSection() { m_currentSection->leave(); m_currentSection = m_currentSection->getParent(); - assert( m_currentSection != NULL ); + assert( m_currentSection != CATCH_NULL ); m_completedASectionThisRun = true; } diff --git a/include/internal/catch_timer.hpp b/include/internal/catch_timer.hpp index 47d9536b..2ba709e3 100644 --- a/include/internal/catch_timer.hpp +++ b/include/internal/catch_timer.hpp @@ -37,7 +37,7 @@ namespace Catch { #else uint64_t getCurrentTicks() { timeval t; - gettimeofday(&t,NULL); + gettimeofday(&t,CATCH_NULL); return static_cast( t.tv_sec ) * 1000000ull + static_cast( t.tv_usec ); } #endif diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 120619be..8efb9be3 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -148,7 +148,7 @@ struct StringMaker { template static std::string convert( U* p ) { if( !p ) - return INTERNAL_CATCH_STRINGIFY( NULL ); + return "NULL"; else return Detail::rawMemoryToString( p ); } @@ -158,7 +158,7 @@ template struct StringMaker { static std::string convert( R C::* p ) { if( !p ) - return INTERNAL_CATCH_STRINGIFY( NULL ); + return "NULL"; else return Detail::rawMemoryToString( p ); } diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp index 553c5a79..3355f4d3 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -8,7 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED -#include "../internal/catch_stream.h" +#include "catch_stream.h" +#include "catch_compiler_capabilities.h" #include #include @@ -27,7 +28,7 @@ namespace Catch { ScopedElement( ScopedElement const& other ) : m_writer( other.m_writer ){ - other.m_writer = NULL; + other.m_writer = CATCH_NULL; } ~ScopedElement() { diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 744fab67..2023c59b 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -973,51 +973,51 @@ ConditionTests.cpp: ConditionTests.cpp:: PASSED: - REQUIRE( p == __null ) + REQUIRE( p == nullptr ) with expansion: - __null == 0 + NULL == nullptr ConditionTests.cpp:: PASSED: REQUIRE( p == pNULL ) with expansion: - __null == __null + NULL == NULL ConditionTests.cpp:: PASSED: - REQUIRE( p != __null ) + REQUIRE( p != nullptr ) with expansion: - 0x != 0 + 0x != nullptr ConditionTests.cpp:: PASSED: - REQUIRE( cp != __null ) + REQUIRE( cp != nullptr ) with expansion: - 0x != 0 + 0x != nullptr ConditionTests.cpp:: PASSED: - REQUIRE( cpc != __null ) + REQUIRE( cpc != nullptr ) with expansion: - 0x != 0 + 0x != nullptr ConditionTests.cpp:: PASSED: - REQUIRE( returnsNull() == __null ) + REQUIRE( returnsNull() == nullptr ) with expansion: - {null string} == 0 + {null string} == nullptr ConditionTests.cpp:: PASSED: - REQUIRE( returnsConstNull() == __null ) + REQUIRE( returnsConstNull() == nullptr ) with expansion: - {null string} == 0 + {null string} == nullptr ConditionTests.cpp:: PASSED: - REQUIRE( __null != p ) + REQUIRE( nullptr != p ) with expansion: - 0 != 0x + nullptr != 0x ------------------------------------------------------------------------------- 'Not' checks that should succeed @@ -3113,13 +3113,13 @@ MiscTests.cpp: MiscTests.cpp:: PASSED: - REQUIRE( makeString( false ) != static_cast(__null) ) + REQUIRE( makeString( false ) != static_cast(nullptr) ) with expansion: "valid string" != {null string} MiscTests.cpp:: PASSED: - REQUIRE( makeString( true ) == static_cast(__null) ) + REQUIRE( makeString( true ) == static_cast(nullptr) ) with expansion: {null string} == {null string} @@ -3316,7 +3316,7 @@ MiscTests.cpp: MiscTests.cpp:: PASSED: - REQUIRE_THAT( "" Equals(__null) ) + REQUIRE_THAT( "" Equals(nullptr) ) with expansion: "" equals: "" @@ -5863,9 +5863,9 @@ TrickyTests.cpp: TrickyTests.cpp:: PASSED: - REQUIRE( obj.prop != __null ) + REQUIRE( obj.prop != nullptr ) with expansion: - 0x != 0 + 0x != nullptr ------------------------------------------------------------------------------- (unimplemented) static bools can be evaluated @@ -6106,7 +6106,7 @@ TrickyTests.cpp:: PASSED: REQUIRE( p == 0 ) with expansion: - __null == 0 + NULL == 0 ------------------------------------------------------------------------------- null_ptr @@ -6118,7 +6118,7 @@ TrickyTests.cpp:: PASSED: REQUIRE( ptr.get() == nullptr ) with expansion: - __null == nullptr + NULL == nullptr ------------------------------------------------------------------------------- X/level/0/a diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index c0a75b73..974559a2 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1205,10 +1205,10 @@ - p == __null + p == nullptr - __null == 0 + NULL == nullptr @@ -1216,55 +1216,55 @@ p == pNULL - __null == __null + NULL == NULL - p != __null + p != nullptr - 0x != 0 + 0x != nullptr - cp != __null + cp != nullptr - 0x != 0 + 0x != nullptr - cpc != __null + cpc != nullptr - 0x != 0 + 0x != nullptr - returnsNull() == __null + returnsNull() == nullptr - {null string} == 0 + {null string} == nullptr - returnsConstNull() == __null + returnsConstNull() == nullptr - {null string} == 0 + {null string} == nullptr - __null != p + nullptr != p - 0 != 0x + nullptr != 0x @@ -3226,7 +3226,7 @@ - makeString( false ) != static_cast<char*>(__null) + makeString( false ) != static_cast<char*>(nullptr) "valid string" != {null string} @@ -3234,7 +3234,7 @@ - makeString( true ) == static_cast<char*>(__null) + makeString( true ) == static_cast<char*>(nullptr) {null string} == {null string} @@ -3434,7 +3434,7 @@ - "" Equals(__null) + "" Equals(nullptr) "" equals: "" @@ -6041,10 +6041,10 @@ there" - obj.prop != __null + obj.prop != nullptr - 0x != 0 + 0x != nullptr @@ -6270,7 +6270,7 @@ there" p == 0 - __null == 0 + NULL == 0 @@ -6281,7 +6281,7 @@ there" ptr.get() == nullptr - __null == nullptr + NULL == nullptr diff --git a/projects/SelfTest/CmdLineTests.cpp b/projects/SelfTest/CmdLineTests.cpp index 46aecfd0..955bcd3d 100644 --- a/projects/SelfTest/CmdLineTests.cpp +++ b/projects/SelfTest/CmdLineTests.cpp @@ -10,7 +10,7 @@ #include "catch_test_spec_parser.hpp" -inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } +inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } TEST_CASE( "Parse test names and tags", "" ) { diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp index 097c3f33..910021ce 100644 --- a/projects/SelfTest/ConditionTests.cpp +++ b/projects/SelfTest/ConditionTests.cpp @@ -265,32 +265,32 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" ) #pragma GCC diagnostic pop #endif -inline const char* returnsConstNull(){ return NULL; } -inline char* returnsNull(){ return NULL; } +inline const char* returnsConstNull(){ return CATCH_NULL; } +inline char* returnsNull(){ return CATCH_NULL; } TEST_CASE( "Pointers can be compared to null", "" ) { - TestData* p = NULL; - TestData* pNULL = NULL; + TestData* p = CATCH_NULL; + TestData* pNULL = CATCH_NULL; - REQUIRE( p == NULL ); + REQUIRE( p == CATCH_NULL ); REQUIRE( p == pNULL ); TestData data; p = &data; - REQUIRE( p != NULL ); + REQUIRE( p != CATCH_NULL ); const TestData* cp = p; - REQUIRE( cp != NULL ); + REQUIRE( cp != CATCH_NULL ); const TestData* const cpc = p; - REQUIRE( cpc != NULL ); + REQUIRE( cpc != CATCH_NULL ); - REQUIRE( returnsNull() == NULL ); - REQUIRE( returnsConstNull() == NULL ); + REQUIRE( returnsNull() == CATCH_NULL ); + REQUIRE( returnsConstNull() == CATCH_NULL ); - REQUIRE( NULL != p ); + REQUIRE( CATCH_NULL != p ); } // Not (!) tests diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index 86bd4f39..d91db944 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -124,13 +124,13 @@ TEST_CASE( "Sends stuff to stdout and stderr", "[.]" ) inline const char* makeString( bool makeNull ) { - return makeNull ? NULL : "valid string"; + return makeNull ? CATCH_NULL : "valid string"; } TEST_CASE( "null strings", "" ) { - REQUIRE( makeString( false ) != static_cast(NULL)); - REQUIRE( makeString( true ) == static_cast(NULL)); + REQUIRE( makeString( false ) != static_cast(CATCH_NULL)); + REQUIRE( makeString( true ) == static_cast(CATCH_NULL)); } @@ -233,7 +233,7 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]") } TEST_CASE("Equals string matcher, with NULL", "[matchers]") { - REQUIRE_THAT("", Equals(NULL)); + REQUIRE_THAT("", Equals(CATCH_NULL)); } TEST_CASE("AllOf matcher", "[matchers]") { diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 7cb7ca42..dae87f0c 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -39,7 +39,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co return ""; } -inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } +inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) { diff --git a/projects/SelfTest/ToStringTuple.cpp b/projects/SelfTest/ToStringTuple.cpp index d1ab02f2..80e54530 100644 --- a/projects/SelfTest/ToStringTuple.cpp +++ b/projects/SelfTest/ToStringTuple.cpp @@ -42,12 +42,14 @@ TEST_CASE( "tuple,tuple<>,float>", "[toString][tuple]" ) CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) ); } +#ifdef CATCH_CONFIG_CPP11_NULLPTR TEST_CASE( "tuple", "[toString][tuple]" ) { typedef std::tuple type; type value { nullptr, 42, "Catch me" }; CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) ); } +#endif #ifdef __clang__ #pragma clang diagnostic pop diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index 462718db..95612022 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -234,7 +234,7 @@ struct Obj TEST_CASE("boolean member", "[Tricky]") { Obj obj; - REQUIRE( obj.prop != NULL ); + REQUIRE( obj.prop != CATCH_NULL ); } // Tests for a problem submitted by Ralph McArdell