develop build 1

This commit is contained in:
Phil Nash 2015-07-02 08:21:38 +01:00
parent 088c5bc53e
commit b971fe785b
3 changed files with 104 additions and 59 deletions

View File

@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.2.1* *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

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

View File

@ -1,6 +1,6 @@
/* /*
* Catch v1.2.1 * Catch v1.2.1-develop.1
* Generated: 2015-06-30 18:23:27.961086 * 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.
@ -224,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 {
@ -397,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();
@ -413,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 );
@ -430,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;
@ -994,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
@ -1190,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 );
} }
@ -1200,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 );
} }
@ -2440,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() {
@ -2469,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; }
@ -2481,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() );
} }
@ -2542,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;
@ -2654,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 );
@ -3132,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 ),
@ -3151,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;
@ -3517,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;
@ -3537,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;
@ -3836,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;
} }
@ -3920,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() )
@ -4284,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;
} }
@ -4977,7 +4992,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 ) )
@ -4999,7 +5014,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 )
{} {}
@ -5016,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;
} }
@ -5174,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() ),
@ -5193,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 );
} }
@ -5234,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;
@ -5589,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;
@ -5659,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 );
@ -5872,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 ) );
} }
@ -5997,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;
@ -6012,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() {
@ -6113,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 )
@ -6123,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;
} }
} }
@ -6142,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& );
@ -6188,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() {
@ -6209,7 +6247,7 @@ namespace Catch {
}; };
namespace { namespace {
Context* currentContext = NULL; Context* currentContext = CATCH_NULL;
} }
IMutableContext& getCurrentMutableContext() { IMutableContext& getCurrentMutableContext() {
if( !currentContext ) if( !currentContext )
@ -6230,7 +6268,7 @@ namespace Catch {
void cleanUpContext() { void cleanUpContext() {
delete currentContext; delete currentContext;
currentContext = NULL; currentContext = CATCH_NULL;
} }
} }
@ -6640,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,
@ -6648,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 )
@ -6767,7 +6812,7 @@ namespace Catch {
return os; return os;
} }
Version libraryVersion( 1, 2, 1, "", 0 ); Version libraryVersion( 1, 2, 1, "develop", 1 );
} }
@ -6960,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
@ -7151,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;
} }
@ -7872,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() {