Compare commits

...

8 Commits

Author SHA1 Message Date
Phil Nash
b971fe785b develop build 1 2015-07-02 08:21:38 +01:00
Phil Nash
088c5bc53e --filenames-as-tags 2015-07-02 08:20:18 +01:00
Phil Nash
680b1a881b Squashed some warnings about local variables shadowing members
- see #444
2015-07-01 07:50:53 +01:00
Phil Nash
805de43a3d Use CATCH_NULL instead of NULL
- expands to nullptr if CATCH_CONFIG_CPP11_NULLPTR is defined (see #444)
2015-07-01 07:33:27 +01:00
Phil Nash
3b18d9e962 build for v1.2.1 2015-06-30 18:26:09 +01:00
Phil Nash
6d5797231c Split imply from TrackedSection class to avoid use of incomplete type
- see #450
2015-06-30 18:25:49 +01:00
Phil Nash
804896cdfa Fixed approval tests script for new version number formatting 2015-06-30 18:24:59 +01:00
Phil Nash
7ab3b5aefb Added compiler feature suppression macros
_NO_ forms to disable detection of features - particularly C++11 features.
Also removed SFINAE detection (and use in tostring)
2015-06-30 08:41:55 +01:00
37 changed files with 441 additions and 473 deletions

View File

@@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.2.0* *v1.2.1-develop.1*
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)

View File

@@ -52,14 +52,18 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
# C++ conformance toggles # C++ conformance toggles
CATCH_CONFIG_CPP11_NULLPTR CATCH_CONFIG_CPP11_NULLPTR // nullptr is supported?
CATCH_CONFIG_CPP11_NOEXCEPT CATCH_CONFIG_CPP11_NOEXCEPT // noexcept is supported?
CATCH_CONFIG_SFINAE // Basic, C++03, support for SFINAE CATCH_CONFIG_CPP11_GENERATED_METHODS // delete and default keywords for methods
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
CATCH_CONFIG_NO_VARIADIC_MACROS // Suppress if Catch is too eager to enable it
Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative. Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support. So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.
You may also suppress any of these features by using the `_NO_` form, e.g. `CATCH_CONFIG_CPP11_NO_NULLPTR`.
All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11`
--- ---

View File

@@ -105,6 +105,26 @@ namespace Catch {
std::set<TestCase> m_testsAlreadyRun; std::set<TestCase> m_testsAlreadyRun;
}; };
void applyFilenamesAsTags() {
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
for(std::size_t i = 0; i < tests.size(); ++i ) {
TestCase& test = const_cast<TestCase&>( tests[i] );
std::set<std::string> tags = test.tags;
std::string filename = test.lineInfo.file;
std::string::size_type lastSlash = filename.find_last_of( "\//" );
if( lastSlash != std::string::npos )
filename = filename.substr( lastSlash+1 );
std::string::size_type lastDot = filename.find_last_of( "." );
if( lastDot != std::string::npos )
filename = filename.substr( 0, lastDot );
tags.insert( "@" + filename );
setTags( test, tags );
}
}
class Session : NonCopyable { class Session : NonCopyable {
static bool alreadyInstantiated; static bool alreadyInstantiated;
@@ -175,6 +195,9 @@ namespace Catch {
{ {
config(); // Force config to be constructed config(); // Force config to be constructed
if( m_configData.filenamesAsTags )
applyFilenamesAsTags();
std::srand( m_configData.rngSeed ); std::srand( m_configData.rngSeed );
Runner runner( m_config ); Runner runner( m_config );

View File

@@ -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;
@@ -585,8 +585,8 @@ namespace Clara {
m_arg->description = description; m_arg->description = description;
return *this; return *this;
} }
ArgBuilder& detail( std::string const& detail ) { ArgBuilder& detail( std::string const& _detail ) {
m_arg->detail = detail; m_arg->detail = _detail;
return *this; return *this;
} }
@@ -670,14 +670,14 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() ); maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) { for( it = itBegin; it != itEnd; ++it ) {
Detail::Text usage( it->commands(), Detail::TextAttributes() Detail::Text usageText( it->commands(), Detail::TextAttributes()
.setWidth( maxWidth+indent ) .setWidth( maxWidth+indent )
.setIndent( indent ) ); .setIndent( indent ) );
Detail::Text desc( it->description, Detail::TextAttributes() Detail::Text desc( it->description, Detail::TextAttributes()
.setWidth( width - maxWidth - 3 ) ); .setWidth( width - maxWidth - 3 ) );
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
std::string usageCol = i < usage.size() ? usage[i] : ""; std::string usageCol = i < usageText.size() ? usageText[i] : "";
os << usageCol; os << usageCol;
if( i < desc.size() && !desc[i].empty() ) if( i < desc.size() && !desc[i].empty() )

View File

@@ -174,6 +174,10 @@ namespace Catch {
.describe( "force colourised output" ) .describe( "force colourised output" )
.bind( &ConfigData::forceColour ); .bind( &ConfigData::forceColour );
cli["--filenames-as-tags"]
.describe( "adds a tag for the filename" )
.bind( &ConfigData::filenamesAsTags );
return cli; return cli;
} }

View File

@@ -19,20 +19,24 @@
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_SFINAE : is basic (C++03) SFINAE supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// A lot of this code is based on Boost (1.53) // In general each macro has a _NO_<feature name> form
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __clang__ #ifdef __clang__
# if __has_feature(cxx_nullptr) # if __has_feature(cxx_nullptr)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# if __has_feature(cxx_noexcept) # if __has_feature(cxx_noexcept)
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
#endif // __clang__ #endif // __clang__
@@ -41,9 +45,6 @@
// Borland // Borland
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#if (__BORLANDC__ > 0x582 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __BORLANDC__ #endif // __BORLANDC__
@@ -51,9 +52,6 @@
// EDG // EDG
#ifdef __EDG_VERSION__ #ifdef __EDG_VERSION__
#if (__EDG_VERSION__ > 238 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __EDG_VERSION__ #endif // __EDG_VERSION__
@@ -61,9 +59,6 @@
// Digital Mars // Digital Mars
#ifdef __DMC__ #ifdef __DMC__
#if (__DMC__ > 0x840 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __DMC__ #endif // __DMC__
@@ -71,21 +66,8 @@
// GCC // GCC
#ifdef __GNUC__ #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
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) ) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#define CATCH_CONFIG_CPP11_NULLPTR
#endif #endif
@@ -95,17 +77,13 @@
// Visual C++ // Visual C++
#ifdef _MSC_VER #ifdef _MSC_VER
#if (_MSC_VER >= 1310 ) // (VC++ 7.0+)
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#if (_MSC_VER >= 1600) #if (_MSC_VER >= 1600)
#define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif #endif
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) #if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CATCH_CONFIG_CPP11_NOEXCEPT #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_CONFIG_CPP11_GENERATED_METHODS #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif #endif
#endif // _MSC_VER #endif // _MSC_VER
@@ -116,9 +94,7 @@
( defined __GNUC__ && __GNUC__ >= 3 ) || \ ( defined __GNUC__ && __GNUC__ >= 3 ) || \
( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
#ifndef CATCH_CONFIG_NO_VARIADIC_MACROS #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#define CATCH_CONFIG_VARIADIC_MACROS
#endif
#endif #endif
@@ -130,36 +106,53 @@
# define CATCH_CPP11_OR_GREATER # define CATCH_CPP11_OR_GREATER
# ifndef CATCH_CONFIG_CPP11_NULLPTR # if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# ifndef CATCH_CONFIG_CPP11_NOEXCEPT # ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS # ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# define CATCH_CONFIG_CPP11_GENERATED_METHODS # define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# endif # endif
# ifndef CATCH_CONFIG_CPP11_IS_ENUM # ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# define CATCH_CONFIG_CPP11_IS_ENUM # define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# endif # endif
# ifndef CATCH_CONFIG_CPP11_TUPLE # ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# define CATCH_CONFIG_CPP11_TUPLE # define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# endif # endif
# ifndef CATCH_CONFIG_SFINAE # ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
//# define CATCH_CONFIG_SFINAE // Don't use, for now # define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
# endif
# ifndef CATCH_CONFIG_VARIADIC_MACROS
# define CATCH_CONFIG_VARIADIC_MACROS
# endif # endif
#endif // __cplusplus >= 201103L #endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NULLPTR
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_IS_ENUM
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
# 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
#endif
// noexcept support: // noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
# define CATCH_NOEXCEPT noexcept # define CATCH_NOEXCEPT noexcept
@@ -169,5 +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

View File

@@ -38,6 +38,7 @@ namespace Catch {
showHelp( false ), showHelp( false ),
showInvisibles( false ), showInvisibles( false ),
forceColour( false ), forceColour( false ),
filenamesAsTags( false ),
abortAfter( -1 ), abortAfter( -1 ),
rngSeed( 0 ), rngSeed( 0 ),
verbosity( Verbosity::Normal ), verbosity( Verbosity::Normal ),
@@ -57,6 +58,7 @@ namespace Catch {
bool showHelp; bool showHelp;
bool showInvisibles; bool showInvisibles;
bool forceColour; bool forceColour;
bool filenamesAsTags;
int abortAfter; int abortAfter;
unsigned int rngSeed; unsigned int rngSeed;

View File

@@ -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;
} }
} }

View File

@@ -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;
} }

View File

@@ -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

View File

@@ -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 );

View File

@@ -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() );
} }

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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 ) );
} }

View File

@@ -59,11 +59,11 @@ namespace Catch {
public: public:
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() ),
m_prevResultCapture( m_context.getResultCapture() ), m_prevResultCapture( m_context.getResultCapture() ),
@@ -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;

View File

@@ -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 )
{} {}

View File

@@ -1,44 +0,0 @@
/*
* Created by Phil on 15/04/2013.
* Copyright 2013 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_SFINAE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED
// Try to detect if the current compiler supports SFINAE
#include "catch_compiler_capabilities.h"
namespace Catch {
struct TrueType {
static const bool value = true;
typedef void Enable;
char sizer[1];
};
struct FalseType {
static const bool value = false;
typedef void Disable;
char sizer[2];
};
#ifdef CATCH_CONFIG_SFINAE
template<bool> struct NotABooleanExpression;
template<bool c> struct If : NotABooleanExpression<c> {};
template<> struct If<true> : TrueType {};
template<> struct If<false> : FalseType {};
template<int size> struct SizedIf;
template<> struct SizedIf<sizeof(TrueType)> : TrueType {};
template<> struct SizedIf<sizeof(FalseType)> : FalseType {};
#endif // CATCH_CONFIG_SFINAE
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED

View File

@@ -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;
} }
} }

View File

@@ -40,6 +40,8 @@ namespace Catch {
TestCaseInfo( TestCaseInfo const& other ); TestCaseInfo( TestCaseInfo const& other );
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
bool isHidden() const; bool isHidden() const;
bool throws() const; bool throws() const;
bool okToFail() const; bool okToFail() const;

View File

@@ -93,6 +93,21 @@ namespace Catch {
return TestCase( _testCase, info ); return TestCase( _testCase, info );
} }
void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags )
{
testCaseInfo.tags = tags;
testCaseInfo.lcaseTags.clear();
std::ostringstream oss;
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
testCaseInfo.lcaseTags.insert( lcaseTag );
}
testCaseInfo.tagsAsString = oss.str();
}
TestCaseInfo::TestCaseInfo( std::string const& _name, TestCaseInfo::TestCaseInfo( std::string const& _name,
std::string const& _className, std::string const& _className,
std::string const& _description, std::string const& _description,
@@ -101,18 +116,10 @@ namespace Catch {
: name( _name ), : name( _name ),
className( _className ), className( _className ),
description( _description ), description( _description ),
tags( _tags ),
lineInfo( _lineInfo ), lineInfo( _lineInfo ),
properties( None ) properties( None )
{ {
std::ostringstream oss; setTags( *this, _tags );
for( std::set<std::string>::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
lcaseTags.insert( lcaseTag );
}
tagsAsString = oss.str();
} }
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )

View File

@@ -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>
@@ -33,32 +35,15 @@ namespace SectionTracking {
RunState runState() const { return m_runState; } RunState runState() const { return m_runState; }
TrackedSection* findChild( std::string const& childName ) { TrackedSection* findChild( std::string const& childName );
TrackedSections::iterator it = m_children.find( childName ); TrackedSection* acquireChild( std::string const& childName );
return it != m_children.end()
? &it->second
: NULL;
}
TrackedSection* acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
void enter() { void enter() {
if( m_runState == NotStarted ) if( m_runState == NotStarted )
m_runState = Executing; m_runState = Executing;
} }
void leave() { void leave();
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
TrackedSection* getParent() { TrackedSection* getParent() {
return m_parent; return m_parent;
} }
@@ -71,13 +56,35 @@ namespace SectionTracking {
RunState m_runState; RunState m_runState;
TrackedSections m_children; TrackedSections m_children;
TrackedSection* m_parent; TrackedSection* m_parent;
}; };
inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
TrackedSections::iterator it = m_children.find( childName );
return it != m_children.end()
? &it->second
: CATCH_NULL;
}
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
inline void TrackedSection::leave() {
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
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 )
{} {}
@@ -94,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;
} }

View File

@@ -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

View File

@@ -9,7 +9,6 @@
#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED #define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
#include "catch_common.h" #include "catch_common.h"
#include "catch_sfinae.hpp"
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
@@ -68,32 +67,13 @@ namespace Detail {
extern std::string unprintableString; extern std::string unprintableString;
// 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_CONFIG_SFINAE
#ifdef CATCH_CONFIG_SFINAE
template<typename T>
class IsStreamInsertableHelper {
template<int N> struct TrueIfSizeable : TrueType {};
template<typename T2>
static TrueIfSizeable<sizeof((*(std::ostream*)0) << *((T2 const*)0))> dummy(T2*);
static FalseType dummy(...);
public:
typedef SizedIf<sizeof(dummy((T*)0))> type;
};
template<typename T>
struct IsStreamInsertable : IsStreamInsertableHelper<T>::type {};
#else
struct BorgType { struct BorgType {
template<typename T> BorgType( T const& ); template<typename T> BorgType( T const& );
}; };
struct TrueType { char sizer[1]; };
struct FalseType { char sizer[2]; };
TrueType& testStreamable( std::ostream& ); TrueType& testStreamable( std::ostream& );
FalseType testStreamable( FalseType ); FalseType testStreamable( FalseType );
@@ -106,8 +86,6 @@ namespace Detail {
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
}; };
#endif
#if defined(CATCH_CONFIG_CPP11_IS_ENUM) #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template<typename T, template<typename T,
bool IsEnum = std::is_enum<T>::value bool IsEnum = std::is_enum<T>::value
@@ -170,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 );
} }
@@ -180,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 );
} }

View File

@@ -37,7 +37,7 @@ namespace Catch {
return os; return os;
} }
Version libraryVersion( 1, 2, 0, "", 0 ); Version libraryVersion( 1, 2, 1, "develop", 1 );
} }

View File

@@ -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() {

View File

@@ -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

View File

@@ -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&lt;char*>(__null) makeString( false ) != static_cast&lt;char*>(nullptr)
</Original> </Original>
<Expanded> <Expanded>
&quot;valid string&quot; != {null string} &quot;valid string&quot; != {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&lt;char*>(__null) makeString( true ) == static_cast&lt;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>
&quot;&quot; Equals(__null) &quot;&quot; Equals(nullptr)
</Original> </Original>
<Expanded> <Expanded>
&quot;&quot; equals: &quot;&quot; &quot;&quot; equals: &quot;&quot;
@@ -6041,10 +6041,10 @@ there&quot;
<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&quot;
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&quot;
ptr.get() == nullptr ptr.get() == nullptr
</Original> </Original>
<Expanded> <Expanded>
__null == nullptr NULL == nullptr
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>

View File

@@ -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", "" ) {

View File

@@ -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

View File

@@ -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]")
{ {

View File

@@ -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]" ) {

View File

@@ -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

View File

@@ -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

View File

@@ -91,7 +91,6 @@
26711C91195D47820033EDA2 /* catch_tag_alias.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias.h; sourceTree = "<group>"; }; 26711C91195D47820033EDA2 /* catch_tag_alias.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias.h; sourceTree = "<group>"; };
26711C92195D48F60033EDA2 /* catch_tag_alias_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_tag_alias_registry.hpp; sourceTree = "<group>"; }; 26711C92195D48F60033EDA2 /* catch_tag_alias_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_tag_alias_registry.hpp; sourceTree = "<group>"; };
26711C94195D4B120033EDA2 /* catch_tag_alias_registry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias_registry.h; sourceTree = "<group>"; }; 26711C94195D4B120033EDA2 /* catch_tag_alias_registry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias_registry.h; sourceTree = "<group>"; };
26759472171C72A400A84BD1 /* catch_sfinae.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_sfinae.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_compiler_capabilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_compiler_capabilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; }; 26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; };
26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; }; 26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; };
@@ -453,6 +452,7 @@
266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */, 266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */,
266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */, 266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */,
4A6D0C49149B3E3D00DB3EAA /* catch_common.h */, 4A6D0C49149B3E3D00DB3EAA /* catch_common.h */,
262E739A1846759000CAC268 /* catch_common.hpp */,
4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */, 4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */,
261488FF184DC4A20041FBEB /* catch_debugger.h */, 261488FF184DC4A20041FBEB /* catch_debugger.h */,
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */, 4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */,
@@ -461,12 +461,10 @@
4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */, 4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */,
4AEE0326161431070071E950 /* catch_streambuf.h */, 4AEE0326161431070071E950 /* catch_streambuf.h */,
4ACE21C8166CA19700FB5509 /* catch_option.hpp */, 4ACE21C8166CA19700FB5509 /* catch_option.hpp */,
26759472171C72A400A84BD1 /* catch_sfinae.hpp */,
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */, 26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */,
26DACF2F17206D3400A21326 /* catch_text.h */, 26DACF2F17206D3400A21326 /* catch_text.h */,
263FD06117AF8DF200988A20 /* catch_timer.h */, 263FD06117AF8DF200988A20 /* catch_timer.h */,
26AEAF1617BEA18E009E32C9 /* catch_platform.h */, 26AEAF1617BEA18E009E32C9 /* catch_platform.h */,
262E739A1846759000CAC268 /* catch_common.hpp */,
261488FC184D1DC10041FBEB /* catch_stream.h */, 261488FC184D1DC10041FBEB /* catch_stream.h */,
268F47B018A93F7800D8C14F /* catch_clara.h */, 268F47B018A93F7800D8C14F /* catch_clara.h */,
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */, 2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,

View File

@@ -15,7 +15,7 @@ pathParser = re.compile( r'(.*?)/(.*\..pp)(.*)' )
lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' ) lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' )
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' ) hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' ) durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' )
versionParser = re.compile( r'(.*?)Catch v[0-9]*.[0-9]* b[0-9]*(.*)' ) versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9].?( .*)' )
if len(sys.argv) == 2: if len(sys.argv) == 2:
cmdPath = sys.argv[1] cmdPath = sys.argv[1]

View File

@@ -1,6 +1,6 @@
/* /*
* Catch v1.2.0 * Catch v1.2.1-develop.1
* Generated: 2015-06-29 08:12:52.943445 * Generated: 2015-07-02 08:21:11.983471
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -87,19 +87,23 @@
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_SFINAE : is basic (C++03) SFINAE supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// A lot of this code is based on Boost (1.53) // In general each macro has a _NO_<feature name> form
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __clang__ #ifdef __clang__
# if __has_feature(cxx_nullptr) # if __has_feature(cxx_nullptr)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# if __has_feature(cxx_noexcept) # if __has_feature(cxx_noexcept)
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
#endif // __clang__ #endif // __clang__
@@ -108,51 +112,26 @@
// Borland // Borland
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#if (__BORLANDC__ > 0x582 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __BORLANDC__ #endif // __BORLANDC__
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// EDG // EDG
#ifdef __EDG_VERSION__ #ifdef __EDG_VERSION__
#if (__EDG_VERSION__ > 238 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __EDG_VERSION__ #endif // __EDG_VERSION__
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Digital Mars // Digital Mars
#ifdef __DMC__ #ifdef __DMC__
#if (__DMC__ > 0x840 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __DMC__ #endif // __DMC__
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// GCC // GCC
#ifdef __GNUC__ #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
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) ) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#define CATCH_CONFIG_CPP11_NULLPTR
#endif #endif
#endif // __GNUC__ #endif // __GNUC__
@@ -161,17 +140,13 @@
// Visual C++ // Visual C++
#ifdef _MSC_VER #ifdef _MSC_VER
#if (_MSC_VER >= 1310 ) // (VC++ 7.0+)
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#if (_MSC_VER >= 1600) #if (_MSC_VER >= 1600)
#define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif #endif
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) #if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CATCH_CONFIG_CPP11_NOEXCEPT #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_CONFIG_CPP11_GENERATED_METHODS #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif #endif
#endif // _MSC_VER #endif // _MSC_VER
@@ -182,9 +157,7 @@
( defined __GNUC__ && __GNUC__ >= 3 ) || \ ( defined __GNUC__ && __GNUC__ >= 3 ) || \
( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
#ifndef CATCH_CONFIG_NO_VARIADIC_MACROS #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#define CATCH_CONFIG_VARIADIC_MACROS
#endif
#endif #endif
@@ -196,36 +169,52 @@
# define CATCH_CPP11_OR_GREATER # define CATCH_CPP11_OR_GREATER
# ifndef CATCH_CONFIG_CPP11_NULLPTR # if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# ifndef CATCH_CONFIG_CPP11_NOEXCEPT # ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS # ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# define CATCH_CONFIG_CPP11_GENERATED_METHODS # define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# endif # endif
# ifndef CATCH_CONFIG_CPP11_IS_ENUM # ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# define CATCH_CONFIG_CPP11_IS_ENUM # define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# endif # endif
# ifndef CATCH_CONFIG_CPP11_TUPLE # ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# define CATCH_CONFIG_CPP11_TUPLE # define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# endif # endif
# ifndef CATCH_CONFIG_SFINAE # ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
//# define CATCH_CONFIG_SFINAE // Don't use, for now # define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
# endif
# ifndef CATCH_CONFIG_VARIADIC_MACROS
# define CATCH_CONFIG_VARIADIC_MACROS
# endif # endif
#endif // __cplusplus >= 201103L #endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NULLPTR
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_IS_ENUM
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
# 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
#endif
// noexcept support: // noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
# define CATCH_NOEXCEPT noexcept # define CATCH_NOEXCEPT noexcept
@@ -235,6 +224,13 @@
# 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
namespace Catch { namespace Catch {
class NonCopyable { class NonCopyable {
@@ -408,7 +404,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();
@@ -424,7 +420,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 );
@@ -441,8 +437,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;
@@ -1005,10 +1001,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
@@ -1022,40 +1018,6 @@ namespace Internal {
// #included from: catch_tostring.h // #included from: catch_tostring.h
#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED #define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
// #included from: catch_sfinae.hpp
#define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED
// Try to detect if the current compiler supports SFINAE
namespace Catch {
struct TrueType {
static const bool value = true;
typedef void Enable;
char sizer[1];
};
struct FalseType {
static const bool value = false;
typedef void Disable;
char sizer[2];
};
#ifdef CATCH_CONFIG_SFINAE
template<bool> struct NotABooleanExpression;
template<bool c> struct If : NotABooleanExpression<c> {};
template<> struct If<true> : TrueType {};
template<> struct If<false> : FalseType {};
template<int size> struct SizedIf;
template<> struct SizedIf<sizeof(TrueType)> : TrueType {};
template<> struct SizedIf<sizeof(FalseType)> : FalseType {};
#endif // CATCH_CONFIG_SFINAE
} // end namespace Catch
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <limits> #include <limits>
@@ -1154,32 +1116,13 @@ namespace Detail {
extern std::string unprintableString; extern std::string unprintableString;
// 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_CONFIG_SFINAE
#ifdef CATCH_CONFIG_SFINAE
template<typename T>
class IsStreamInsertableHelper {
template<int N> struct TrueIfSizeable : TrueType {};
template<typename T2>
static TrueIfSizeable<sizeof((*(std::ostream*)0) << *((T2 const*)0))> dummy(T2*);
static FalseType dummy(...);
public:
typedef SizedIf<sizeof(dummy((T*)0))> type;
};
template<typename T>
struct IsStreamInsertable : IsStreamInsertableHelper<T>::type {};
#else
struct BorgType { struct BorgType {
template<typename T> BorgType( T const& ); template<typename T> BorgType( T const& );
}; };
struct TrueType { char sizer[1]; };
struct FalseType { char sizer[2]; };
TrueType& testStreamable( std::ostream& ); TrueType& testStreamable( std::ostream& );
FalseType testStreamable( FalseType ); FalseType testStreamable( FalseType );
@@ -1192,8 +1135,6 @@ namespace Detail {
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
}; };
#endif
#if defined(CATCH_CONFIG_CPP11_IS_ENUM) #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template<typename T, template<typename T,
bool IsEnum = std::is_enum<T>::value bool IsEnum = std::is_enum<T>::value
@@ -1256,7 +1197,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 );
} }
@@ -1266,7 +1207,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 );
} }
@@ -2506,12 +2447,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() {
@@ -2535,7 +2476,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; }
@@ -2547,10 +2488,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() );
} }
@@ -2608,6 +2549,8 @@ namespace Catch {
TestCaseInfo( TestCaseInfo const& other ); TestCaseInfo( TestCaseInfo const& other );
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
bool isHidden() const; bool isHidden() const;
bool throws() const; bool throws() const;
bool okToFail() const; bool okToFail() const;
@@ -2720,7 +2663,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 );
@@ -3198,6 +3141,7 @@ namespace Catch {
showHelp( false ), showHelp( false ),
showInvisibles( false ), showInvisibles( false ),
forceColour( false ), forceColour( false ),
filenamesAsTags( false ),
abortAfter( -1 ), abortAfter( -1 ),
rngSeed( 0 ), rngSeed( 0 ),
verbosity( Verbosity::Normal ), verbosity( Verbosity::Normal ),
@@ -3217,6 +3161,7 @@ namespace Catch {
bool showHelp; bool showHelp;
bool showInvisibles; bool showInvisibles;
bool forceColour; bool forceColour;
bool filenamesAsTags;
int abortAfter; int abortAfter;
unsigned int rngSeed; unsigned int rngSeed;
@@ -3583,11 +3528,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;
@@ -3603,7 +3548,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;
@@ -3902,8 +3847,8 @@ namespace Clara {
m_arg->description = description; m_arg->description = description;
return *this; return *this;
} }
ArgBuilder& detail( std::string const& detail ) { ArgBuilder& detail( std::string const& _detail ) {
m_arg->detail = detail; m_arg->detail = _detail;
return *this; return *this;
} }
@@ -3986,14 +3931,14 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() ); maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) { for( it = itBegin; it != itEnd; ++it ) {
Detail::Text usage( it->commands(), Detail::TextAttributes() Detail::Text usageText( it->commands(), Detail::TextAttributes()
.setWidth( maxWidth+indent ) .setWidth( maxWidth+indent )
.setIndent( indent ) ); .setIndent( indent ) );
Detail::Text desc( it->description, Detail::TextAttributes() Detail::Text desc( it->description, Detail::TextAttributes()
.setWidth( width - maxWidth - 3 ) ); .setWidth( width - maxWidth - 3 ) );
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
std::string usageCol = i < usage.size() ? usage[i] : ""; std::string usageCol = i < usageText.size() ? usageText[i] : "";
os << usageCol; os << usageCol;
if( i < desc.size() && !desc[i].empty() ) if( i < desc.size() && !desc[i].empty() )
@@ -4350,6 +4295,10 @@ namespace Catch {
.describe( "force colourised output" ) .describe( "force colourised output" )
.bind( &ConfigData::forceColour ); .bind( &ConfigData::forceColour );
cli["--filenames-as-tags"]
.describe( "adds a tag for the filename" )
.bind( &ConfigData::filenamesAsTags );
return cli; return cli;
} }
@@ -5016,32 +4965,15 @@ namespace SectionTracking {
RunState runState() const { return m_runState; } RunState runState() const { return m_runState; }
TrackedSection* findChild( std::string const& childName ) { TrackedSection* findChild( std::string const& childName );
TrackedSections::iterator it = m_children.find( childName ); TrackedSection* acquireChild( std::string const& childName );
return it != m_children.end()
? &it->second
: NULL;
}
TrackedSection* acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
void enter() { void enter() {
if( m_runState == NotStarted ) if( m_runState == NotStarted )
m_runState = Executing; m_runState = Executing;
} }
void leave() { void leave();
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
TrackedSection* getParent() { TrackedSection* getParent() {
return m_parent; return m_parent;
} }
@@ -5054,13 +4986,35 @@ namespace SectionTracking {
RunState m_runState; RunState m_runState;
TrackedSections m_children; TrackedSections m_children;
TrackedSection* m_parent; TrackedSection* m_parent;
}; };
inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
TrackedSections::iterator it = m_children.find( childName );
return it != m_children.end()
? &it->second
: CATCH_NULL;
}
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
inline void TrackedSection::leave() {
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
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 )
{} {}
@@ -5077,7 +5031,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;
} }
@@ -5235,11 +5189,11 @@ namespace Catch {
public: public:
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() ),
m_prevResultCapture( m_context.getResultCapture() ), m_prevResultCapture( m_context.getResultCapture() ),
@@ -5254,7 +5208,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 );
} }
@@ -5295,7 +5249,7 @@ namespace Catch {
redirectedCerr, redirectedCerr,
aborting() ) ); aborting() ) );
m_activeTestCase = NULL; m_activeTestCase = CATCH_NULL;
m_testCaseTracker.reset(); m_testCaseTracker.reset();
return deltaTotals; return deltaTotals;
@@ -5650,6 +5604,26 @@ namespace Catch {
std::set<TestCase> m_testsAlreadyRun; std::set<TestCase> m_testsAlreadyRun;
}; };
void applyFilenamesAsTags() {
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
for(std::size_t i = 0; i < tests.size(); ++i ) {
TestCase& test = const_cast<TestCase&>( tests[i] );
std::set<std::string> tags = test.tags;
std::string filename = test.lineInfo.file;
std::string::size_type lastSlash = filename.find_last_of( "\//" );
if( lastSlash != std::string::npos )
filename = filename.substr( lastSlash+1 );
std::string::size_type lastDot = filename.find_last_of( "." );
if( lastDot != std::string::npos )
filename = filename.substr( 0, lastDot );
tags.insert( "@" + filename );
setTags( test, tags );
}
}
class Session : NonCopyable { class Session : NonCopyable {
static bool alreadyInstantiated; static bool alreadyInstantiated;
@@ -5720,6 +5694,9 @@ namespace Catch {
{ {
config(); // Force config to be constructed config(); // Force config to be constructed
if( m_configData.filenamesAsTags )
applyFilenamesAsTags();
std::srand( m_configData.rngSeed ); std::srand( m_configData.rngSeed );
Runner runner( m_config ); Runner runner( m_config );
@@ -5933,7 +5910,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 ) );
} }
@@ -6058,7 +6035,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;
@@ -6073,7 +6050,7 @@ namespace Catch {
} }
void cleanUp() { void cleanUp() {
delete getTheRegistryHub(); delete getTheRegistryHub();
getTheRegistryHub() = NULL; getTheRegistryHub() = CATCH_NULL;
cleanUpContext(); cleanUpContext();
} }
std::string translateActiveException() { std::string translateActiveException() {
@@ -6174,7 +6151,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 )
@@ -6184,7 +6161,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;
} }
} }
@@ -6203,7 +6180,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& );
@@ -6249,7 +6226,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() {
@@ -6270,7 +6247,7 @@ namespace Catch {
}; };
namespace { namespace {
Context* currentContext = NULL; Context* currentContext = CATCH_NULL;
} }
IMutableContext& getCurrentMutableContext() { IMutableContext& getCurrentMutableContext() {
if( !currentContext ) if( !currentContext )
@@ -6291,7 +6268,7 @@ namespace Catch {
void cleanUpContext() { void cleanUpContext() {
delete currentContext; delete currentContext;
currentContext = NULL; currentContext = CATCH_NULL;
} }
} }
@@ -6701,6 +6678,21 @@ namespace Catch {
return TestCase( _testCase, info ); return TestCase( _testCase, info );
} }
void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags )
{
testCaseInfo.tags = tags;
testCaseInfo.lcaseTags.clear();
std::ostringstream oss;
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
testCaseInfo.lcaseTags.insert( lcaseTag );
}
testCaseInfo.tagsAsString = oss.str();
}
TestCaseInfo::TestCaseInfo( std::string const& _name, TestCaseInfo::TestCaseInfo( std::string const& _name,
std::string const& _className, std::string const& _className,
std::string const& _description, std::string const& _description,
@@ -6709,18 +6701,10 @@ namespace Catch {
: name( _name ), : name( _name ),
className( _className ), className( _className ),
description( _description ), description( _description ),
tags( _tags ),
lineInfo( _lineInfo ), lineInfo( _lineInfo ),
properties( None ) properties( None )
{ {
std::ostringstream oss; setTags( *this, _tags );
for( std::set<std::string>::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
lcaseTags.insert( lcaseTag );
}
tagsAsString = oss.str();
} }
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
@@ -6828,7 +6812,7 @@ namespace Catch {
return os; return os;
} }
Version libraryVersion( 1, 2, 0, "", 0 ); Version libraryVersion( 1, 2, 1, "develop", 1 );
} }
@@ -7021,7 +7005,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
@@ -7212,7 +7196,7 @@ namespace Catch {
// 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;
} }
@@ -7933,7 +7917,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() {