mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Use CATCH_NULL instead of NULL
- expands to nullptr if CATCH_CONFIG_CPP11_NULLPTR is defined (see #444)
This commit is contained in:
parent
3b18d9e962
commit
805de43a3d
8
include/external/clara.h
vendored
8
include/external/clara.h
vendored
@ -264,11 +264,11 @@ namespace Clara {
|
|||||||
template<typename ConfigT>
|
template<typename ConfigT>
|
||||||
class BoundArgFunction {
|
class BoundArgFunction {
|
||||||
public:
|
public:
|
||||||
BoundArgFunction() : functionObj( NULL ) {}
|
BoundArgFunction() : functionObj( CATCH_NULL ) {}
|
||||||
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
BoundArgFunction( IArgFunction<ConfigT>* _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 ) {
|
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
|
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL;
|
||||||
delete functionObj;
|
delete functionObj;
|
||||||
functionObj = newFunctionObj;
|
functionObj = newFunctionObj;
|
||||||
return *this;
|
return *this;
|
||||||
@ -284,7 +284,7 @@ namespace Clara {
|
|||||||
bool takesArg() const { return functionObj->takesArg(); }
|
bool takesArg() const { return functionObj->takesArg(); }
|
||||||
|
|
||||||
bool isSet() const {
|
bool isSet() const {
|
||||||
return functionObj != NULL;
|
return functionObj != CATCH_NULL;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
IArgFunction<ConfigT>* functionObj;
|
IArgFunction<ConfigT>* functionObj;
|
||||||
|
@ -162,6 +162,12 @@
|
|||||||
# define CATCH_NOEXCEPT_IS(x)
|
# define CATCH_NOEXCEPT_IS(x)
|
||||||
#endif
|
#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
|
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace Catch {
|
|||||||
|
|
||||||
class Context : public IMutableContext {
|
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& );
|
Context( Context const& );
|
||||||
void operator=( Context const& );
|
void operator=( Context const& );
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace Catch {
|
|||||||
m_generatorsByTestName.find( testName );
|
m_generatorsByTestName.find( testName );
|
||||||
return it != m_generatorsByTestName.end()
|
return it != m_generatorsByTestName.end()
|
||||||
? it->second
|
? it->second
|
||||||
: NULL;
|
: CATCH_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
||||||
@ -84,7 +84,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Context* currentContext = NULL;
|
Context* currentContext = CATCH_NULL;
|
||||||
}
|
}
|
||||||
IMutableContext& getCurrentMutableContext() {
|
IMutableContext& getCurrentMutableContext() {
|
||||||
if( !currentContext )
|
if( !currentContext )
|
||||||
@ -105,7 +105,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void cleanUpContext() {
|
void cleanUpContext() {
|
||||||
delete currentContext;
|
delete currentContext;
|
||||||
currentContext = NULL;
|
currentContext = CATCH_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
// Call sysctl.
|
// Call sysctl.
|
||||||
|
|
||||||
size = sizeof(info);
|
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;
|
Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -163,10 +163,10 @@ namespace Internal {
|
|||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
// pointer to nullptr_t (when comparing against nullptr)
|
// pointer to nullptr_t (when comparing against nullptr)
|
||||||
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
|
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( NULL, rhs );
|
return Evaluator<T*, T*, Op>::evaluate( CATCH_NULL, rhs );
|
||||||
}
|
}
|
||||||
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
|
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, NULL );
|
return Evaluator<T*, T*, Op>::evaluate( lhs, CATCH_NULL );
|
||||||
}
|
}
|
||||||
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace Catch {
|
|||||||
|
|
||||||
inline size_t registerTestMethods() {
|
inline size_t registerTestMethods() {
|
||||||
size_t noTestMethods = 0;
|
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);
|
Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
|
||||||
objc_getClassList( classes, noClasses );
|
objc_getClassList( classes, noClasses );
|
||||||
|
@ -16,12 +16,12 @@ namespace Catch {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Option {
|
class Option {
|
||||||
public:
|
public:
|
||||||
Option() : nullableValue( NULL ) {}
|
Option() : nullableValue( CATCH_NULL ) {}
|
||||||
Option( T const& _value )
|
Option( T const& _value )
|
||||||
: nullableValue( new( storage ) T( _value ) )
|
: nullableValue( new( storage ) T( _value ) )
|
||||||
{}
|
{}
|
||||||
Option( Option const& _other )
|
Option( Option const& _other )
|
||||||
: nullableValue( _other ? new( storage ) T( *_other ) : NULL )
|
: nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~Option() {
|
~Option() {
|
||||||
@ -45,7 +45,7 @@ namespace Catch {
|
|||||||
void reset() {
|
void reset() {
|
||||||
if( nullableValue )
|
if( nullableValue )
|
||||||
nullableValue->~T();
|
nullableValue->~T();
|
||||||
nullableValue = NULL;
|
nullableValue = CATCH_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() { return *nullableValue; }
|
T& operator*() { return *nullableValue; }
|
||||||
@ -57,10 +57,10 @@ namespace Catch {
|
|||||||
return nullableValue ? *nullableValue : defaultValue;
|
return nullableValue ? *nullableValue : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool some() const { return nullableValue != NULL; }
|
bool some() const { return nullableValue != CATCH_NULL; }
|
||||||
bool none() const { return nullableValue == 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 {
|
operator SafeBool::type() const {
|
||||||
return SafeBool::makeSafe( some() );
|
return SafeBool::makeSafe( some() );
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace Catch {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Ptr {
|
class Ptr {
|
||||||
public:
|
public:
|
||||||
Ptr() : m_p( NULL ){}
|
Ptr() : m_p( CATCH_NULL ){}
|
||||||
Ptr( T* p ) : m_p( p ){
|
Ptr( T* p ) : m_p( p ){
|
||||||
if( m_p )
|
if( m_p )
|
||||||
m_p->addRef();
|
m_p->addRef();
|
||||||
@ -39,7 +39,7 @@ namespace Catch {
|
|||||||
void reset() {
|
void reset() {
|
||||||
if( m_p )
|
if( m_p )
|
||||||
m_p->release();
|
m_p->release();
|
||||||
m_p = NULL;
|
m_p = CATCH_NULL;
|
||||||
}
|
}
|
||||||
Ptr& operator = ( T* p ){
|
Ptr& operator = ( T* p ){
|
||||||
Ptr temp( p );
|
Ptr temp( p );
|
||||||
@ -56,8 +56,8 @@ namespace Catch {
|
|||||||
const T* get() const{ return m_p; }
|
const T* get() const{ return m_p; }
|
||||||
T& operator*() const { return *m_p; }
|
T& operator*() const { return *m_p; }
|
||||||
T* operator->() const { return m_p; }
|
T* operator->() const { return m_p; }
|
||||||
bool operator !() const { return m_p == NULL; }
|
bool operator !() const { return m_p == CATCH_NULL; }
|
||||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); }
|
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_p;
|
T* m_p;
|
||||||
|
@ -55,7 +55,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// Single, global, instance
|
// Single, global, instance
|
||||||
inline RegistryHub*& getTheRegistryHub() {
|
inline RegistryHub*& getTheRegistryHub() {
|
||||||
static RegistryHub* theRegistryHub = NULL;
|
static RegistryHub* theRegistryHub = CATCH_NULL;
|
||||||
if( !theRegistryHub )
|
if( !theRegistryHub )
|
||||||
theRegistryHub = new RegistryHub();
|
theRegistryHub = new RegistryHub();
|
||||||
return theRegistryHub;
|
return theRegistryHub;
|
||||||
@ -70,7 +70,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
delete getTheRegistryHub();
|
delete getTheRegistryHub();
|
||||||
getTheRegistryHub() = NULL;
|
getTheRegistryHub() = CATCH_NULL;
|
||||||
cleanUpContext();
|
cleanUpContext();
|
||||||
}
|
}
|
||||||
std::string translateActiveException() {
|
std::string translateActiveException() {
|
||||||
|
@ -25,7 +25,7 @@ namespace Catch {
|
|||||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
||||||
FactoryMap::const_iterator it = m_factories.find( name );
|
FactoryMap::const_iterator it = m_factories.find( name );
|
||||||
if( it == m_factories.end() )
|
if( it == m_factories.end() )
|
||||||
return NULL;
|
return CATCH_NULL;
|
||||||
return it->second->create( ReporterConfig( config ) );
|
return it->second->create( ReporterConfig( config ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ namespace Catch {
|
|||||||
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
||||||
: m_runInfo( config->name() ),
|
: m_runInfo( config->name() ),
|
||||||
m_context( getCurrentMutableContext() ),
|
m_context( getCurrentMutableContext() ),
|
||||||
m_activeTestCase( NULL ),
|
m_activeTestCase( CATCH_NULL ),
|
||||||
m_config( config ),
|
m_config( config ),
|
||||||
m_reporter( reporter ),
|
m_reporter( reporter ),
|
||||||
m_prevRunner( m_context.getRunner() ),
|
m_prevRunner( m_context.getRunner() ),
|
||||||
@ -78,7 +78,7 @@ namespace Catch {
|
|||||||
virtual ~RunContext() {
|
virtual ~RunContext() {
|
||||||
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
||||||
m_context.setRunner( m_prevRunner );
|
m_context.setRunner( m_prevRunner );
|
||||||
m_context.setConfig( NULL );
|
m_context.setConfig( CATCH_NULL );
|
||||||
m_context.setResultCapture( m_prevResultCapture );
|
m_context.setResultCapture( m_prevResultCapture );
|
||||||
m_context.setConfig( m_prevConfig );
|
m_context.setConfig( m_prevConfig );
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ namespace Catch {
|
|||||||
redirectedCerr,
|
redirectedCerr,
|
||||||
aborting() ) );
|
aborting() ) );
|
||||||
|
|
||||||
m_activeTestCase = NULL;
|
m_activeTestCase = CATCH_NULL;
|
||||||
m_testCaseTracker.reset();
|
m_testCaseTracker.reset();
|
||||||
|
|
||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
|
@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
|
|
||||||
RunningSection( std::string const& name )
|
RunningSection( std::string const& name )
|
||||||
: m_state( Root ),
|
: m_state( Root ),
|
||||||
m_parent( NULL ),
|
m_parent( CATCH_NULL ),
|
||||||
m_name( name )
|
m_name( name )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Stream::Stream()
|
Stream::Stream()
|
||||||
: streamBuf( NULL ), isOwned( false )
|
: streamBuf( CATCH_NULL ), isOwned( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
|
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
|
||||||
@ -75,7 +75,7 @@ namespace Catch {
|
|||||||
void Stream::release() {
|
void Stream::release() {
|
||||||
if( isOwned ) {
|
if( isOwned ) {
|
||||||
delete streamBuf;
|
delete streamBuf;
|
||||||
streamBuf = NULL;
|
streamBuf = CATCH_NULL;
|
||||||
isOwned = false;
|
isOwned = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "catch_compiler_capabilities.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -60,7 +62,7 @@ namespace SectionTracking {
|
|||||||
TrackedSections::iterator it = m_children.find( childName );
|
TrackedSections::iterator it = m_children.find( childName );
|
||||||
return it != m_children.end()
|
return it != m_children.end()
|
||||||
? &it->second
|
? &it->second
|
||||||
: NULL;
|
: CATCH_NULL;
|
||||||
}
|
}
|
||||||
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
||||||
if( TrackedSection* child = findChild( childName ) )
|
if( TrackedSection* child = findChild( childName ) )
|
||||||
@ -82,7 +84,7 @@ namespace SectionTracking {
|
|||||||
class TestCaseTracker {
|
class TestCaseTracker {
|
||||||
public:
|
public:
|
||||||
TestCaseTracker( std::string const& testCaseName )
|
TestCaseTracker( std::string const& testCaseName )
|
||||||
: m_testCase( testCaseName, NULL ),
|
: m_testCase( testCaseName, CATCH_NULL ),
|
||||||
m_currentSection( &m_testCase ),
|
m_currentSection( &m_testCase ),
|
||||||
m_completedASectionThisRun( false )
|
m_completedASectionThisRun( false )
|
||||||
{}
|
{}
|
||||||
@ -99,7 +101,7 @@ namespace SectionTracking {
|
|||||||
void leaveSection() {
|
void leaveSection() {
|
||||||
m_currentSection->leave();
|
m_currentSection->leave();
|
||||||
m_currentSection = m_currentSection->getParent();
|
m_currentSection = m_currentSection->getParent();
|
||||||
assert( m_currentSection != NULL );
|
assert( m_currentSection != CATCH_NULL );
|
||||||
m_completedASectionThisRun = true;
|
m_completedASectionThisRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
#else
|
#else
|
||||||
uint64_t getCurrentTicks() {
|
uint64_t getCurrentTicks() {
|
||||||
timeval t;
|
timeval t;
|
||||||
gettimeofday(&t,NULL);
|
gettimeofday(&t,CATCH_NULL);
|
||||||
return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
|
return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,7 +148,7 @@ struct StringMaker<T*> {
|
|||||||
template<typename U>
|
template<typename U>
|
||||||
static std::string convert( U* p ) {
|
static std::string convert( U* p ) {
|
||||||
if( !p )
|
if( !p )
|
||||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
return "NULL";
|
||||||
else
|
else
|
||||||
return Detail::rawMemoryToString( p );
|
return Detail::rawMemoryToString( p );
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ template<typename R, typename C>
|
|||||||
struct StringMaker<R C::*> {
|
struct StringMaker<R C::*> {
|
||||||
static std::string convert( R C::* p ) {
|
static std::string convert( R C::* p ) {
|
||||||
if( !p )
|
if( !p )
|
||||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
return "NULL";
|
||||||
else
|
else
|
||||||
return Detail::rawMemoryToString( p );
|
return Detail::rawMemoryToString( p );
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
|
||||||
#define 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 <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -27,7 +28,7 @@ namespace Catch {
|
|||||||
|
|
||||||
ScopedElement( ScopedElement const& other )
|
ScopedElement( ScopedElement const& other )
|
||||||
: m_writer( other.m_writer ){
|
: m_writer( other.m_writer ){
|
||||||
other.m_writer = NULL;
|
other.m_writer = CATCH_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopedElement() {
|
~ScopedElement() {
|
||||||
|
@ -973,51 +973,51 @@ ConditionTests.cpp:<line number>
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( p == __null )
|
REQUIRE( p == nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
__null == 0
|
NULL == nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( p == pNULL )
|
REQUIRE( p == pNULL )
|
||||||
with expansion:
|
with expansion:
|
||||||
__null == __null
|
NULL == NULL
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( p != __null )
|
REQUIRE( p != nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( cp != __null )
|
REQUIRE( cp != nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( cpc != __null )
|
REQUIRE( cpc != nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( returnsNull() == __null )
|
REQUIRE( returnsNull() == nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
{null string} == 0
|
{null string} == nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( returnsConstNull() == __null )
|
REQUIRE( returnsConstNull() == nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
{null string} == 0
|
{null string} == nullptr
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( __null != p )
|
REQUIRE( nullptr != p )
|
||||||
with expansion:
|
with expansion:
|
||||||
0 != 0x<hex digits>
|
nullptr != 0x<hex digits>
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
'Not' checks that should succeed
|
'Not' checks that should succeed
|
||||||
@ -3113,13 +3113,13 @@ MiscTests.cpp:<line number>
|
|||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MiscTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( makeString( false ) != static_cast<char*>(__null) )
|
REQUIRE( makeString( false ) != static_cast<char*>(nullptr) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"valid string" != {null string}
|
"valid string" != {null string}
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MiscTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( makeString( true ) == static_cast<char*>(__null) )
|
REQUIRE( makeString( true ) == static_cast<char*>(nullptr) )
|
||||||
with expansion:
|
with expansion:
|
||||||
{null string} == {null string}
|
{null string} == {null string}
|
||||||
|
|
||||||
@ -3316,7 +3316,7 @@ MiscTests.cpp:<line number>
|
|||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MiscTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE_THAT( "" Equals(__null) )
|
REQUIRE_THAT( "" Equals(nullptr) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"" equals: ""
|
"" equals: ""
|
||||||
|
|
||||||
@ -5863,9 +5863,9 @@ TrickyTests.cpp:<line number>
|
|||||||
|
|
||||||
TrickyTests.cpp:<line number>:
|
TrickyTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( obj.prop != __null )
|
REQUIRE( obj.prop != nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
(unimplemented) static bools can be evaluated
|
(unimplemented) static bools can be evaluated
|
||||||
@ -6106,7 +6106,7 @@ TrickyTests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( p == 0 )
|
REQUIRE( p == 0 )
|
||||||
with expansion:
|
with expansion:
|
||||||
__null == 0
|
NULL == 0
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
null_ptr
|
null_ptr
|
||||||
@ -6118,7 +6118,7 @@ TrickyTests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( ptr.get() == nullptr )
|
REQUIRE( ptr.get() == nullptr )
|
||||||
with expansion:
|
with expansion:
|
||||||
__null == nullptr
|
NULL == nullptr
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
X/level/0/a
|
X/level/0/a
|
||||||
|
@ -1205,10 +1205,10 @@
|
|||||||
<TestCase name="Pointers can be compared to null">
|
<TestCase name="Pointers can be compared to null">
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
p == __null
|
p == nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
__null == 0
|
NULL == nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
@ -1216,55 +1216,55 @@
|
|||||||
p == pNULL
|
p == pNULL
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
__null == __null
|
NULL == NULL
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
p != __null
|
p != nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
cp != __null
|
cp != nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
cpc != __null
|
cpc != nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
returnsNull() == __null
|
returnsNull() == nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
{null string} == 0
|
{null string} == nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
returnsConstNull() == __null
|
returnsConstNull() == nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
{null string} == 0
|
{null string} == nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
__null != p
|
nullptr != p
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
0 != 0x<hex digits>
|
nullptr != 0x<hex digits>
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
@ -3226,7 +3226,7 @@
|
|||||||
<TestCase name="null strings">
|
<TestCase name="null strings">
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
makeString( false ) != static_cast<char*>(__null)
|
makeString( false ) != static_cast<char*>(nullptr)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"valid string" != {null string}
|
"valid string" != {null string}
|
||||||
@ -3234,7 +3234,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
makeString( true ) == static_cast<char*>(__null)
|
makeString( true ) == static_cast<char*>(nullptr)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
{null string} == {null string}
|
{null string} == {null string}
|
||||||
@ -3434,7 +3434,7 @@
|
|||||||
<TestCase name="Equals string matcher, with NULL">
|
<TestCase name="Equals string matcher, with NULL">
|
||||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
"" Equals(__null)
|
"" Equals(nullptr)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"" equals: ""
|
"" equals: ""
|
||||||
@ -6041,10 +6041,10 @@ there"
|
|||||||
<TestCase name="boolean member">
|
<TestCase name="boolean member">
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TrickyTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TrickyTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
obj.prop != __null
|
obj.prop != nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
0x<hex digits> != 0
|
0x<hex digits> != nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
@ -6270,7 +6270,7 @@ there"
|
|||||||
p == 0
|
p == 0
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
__null == 0
|
NULL == 0
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
@ -6281,7 +6281,7 @@ there"
|
|||||||
ptr.get() == nullptr
|
ptr.get() == nullptr
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
__null == nullptr
|
NULL == nullptr
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "catch_test_spec_parser.hpp"
|
#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", "" ) {
|
TEST_CASE( "Parse test names and tags", "" ) {
|
||||||
|
|
||||||
|
@ -265,32 +265,32 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" )
|
|||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline const char* returnsConstNull(){ return NULL; }
|
inline const char* returnsConstNull(){ return CATCH_NULL; }
|
||||||
inline char* returnsNull(){ return NULL; }
|
inline char* returnsNull(){ return CATCH_NULL; }
|
||||||
|
|
||||||
TEST_CASE( "Pointers can be compared to null", "" )
|
TEST_CASE( "Pointers can be compared to null", "" )
|
||||||
{
|
{
|
||||||
TestData* p = NULL;
|
TestData* p = CATCH_NULL;
|
||||||
TestData* pNULL = NULL;
|
TestData* pNULL = CATCH_NULL;
|
||||||
|
|
||||||
REQUIRE( p == NULL );
|
REQUIRE( p == CATCH_NULL );
|
||||||
REQUIRE( p == pNULL );
|
REQUIRE( p == pNULL );
|
||||||
|
|
||||||
TestData data;
|
TestData data;
|
||||||
p = &data;
|
p = &data;
|
||||||
|
|
||||||
REQUIRE( p != NULL );
|
REQUIRE( p != CATCH_NULL );
|
||||||
|
|
||||||
const TestData* cp = p;
|
const TestData* cp = p;
|
||||||
REQUIRE( cp != NULL );
|
REQUIRE( cp != CATCH_NULL );
|
||||||
|
|
||||||
const TestData* const cpc = p;
|
const TestData* const cpc = p;
|
||||||
REQUIRE( cpc != NULL );
|
REQUIRE( cpc != CATCH_NULL );
|
||||||
|
|
||||||
REQUIRE( returnsNull() == NULL );
|
REQUIRE( returnsNull() == CATCH_NULL );
|
||||||
REQUIRE( returnsConstNull() == NULL );
|
REQUIRE( returnsConstNull() == CATCH_NULL );
|
||||||
|
|
||||||
REQUIRE( NULL != p );
|
REQUIRE( CATCH_NULL != p );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not (!) tests
|
// Not (!) tests
|
||||||
|
@ -124,13 +124,13 @@ TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
|
|||||||
|
|
||||||
inline const char* makeString( bool makeNull )
|
inline const char* makeString( bool makeNull )
|
||||||
{
|
{
|
||||||
return makeNull ? NULL : "valid string";
|
return makeNull ? CATCH_NULL : "valid string";
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "null strings", "" )
|
TEST_CASE( "null strings", "" )
|
||||||
{
|
{
|
||||||
REQUIRE( makeString( false ) != static_cast<char*>(NULL));
|
REQUIRE( makeString( false ) != static_cast<char*>(CATCH_NULL));
|
||||||
REQUIRE( makeString( true ) == static_cast<char*>(NULL));
|
REQUIRE( makeString( true ) == static_cast<char*>(CATCH_NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
|||||||
}
|
}
|
||||||
TEST_CASE("Equals string matcher, with NULL", "[matchers]")
|
TEST_CASE("Equals string matcher, with NULL", "[matchers]")
|
||||||
{
|
{
|
||||||
REQUIRE_THAT("", Equals(NULL));
|
REQUIRE_THAT("", Equals(CATCH_NULL));
|
||||||
}
|
}
|
||||||
TEST_CASE("AllOf matcher", "[matchers]")
|
TEST_CASE("AllOf matcher", "[matchers]")
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
|
|||||||
return "";
|
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]" ) {
|
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||||
|
|
||||||
|
@ -42,12 +42,14 @@ TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
|||||||
CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) );
|
CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
|
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
|
||||||
{
|
{
|
||||||
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
||||||
type value { nullptr, 42, "Catch me" };
|
type value { nullptr, 42, "Catch me" };
|
||||||
CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) );
|
CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
@ -234,7 +234,7 @@ struct Obj
|
|||||||
TEST_CASE("boolean member", "[Tricky]")
|
TEST_CASE("boolean member", "[Tricky]")
|
||||||
{
|
{
|
||||||
Obj obj;
|
Obj obj;
|
||||||
REQUIRE( obj.prop != NULL );
|
REQUIRE( obj.prop != CATCH_NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests for a problem submitted by Ralph McArdell
|
// Tests for a problem submitted by Ralph McArdell
|
||||||
|
Loading…
Reference in New Issue
Block a user