mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-15 18:05:38 +02:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ac220289a6 | ||
![]() |
be3570ef22 | ||
![]() |
a74d760d74 | ||
![]() |
f666f5f0ae | ||
![]() |
7940d58a2f | ||
![]() |
ebf9f3bb9d | ||
![]() |
1ebebd4ab8 | ||
![]() |
b57e734eb4 | ||
![]() |
5aa2b82b17 | ||
![]() |
5c198d85e6 | ||
![]() |
5a6b291878 | ||
![]() |
1706dd4f11 | ||
![]() |
92b141ee53 | ||
![]() |
4f1263d6b4 | ||
![]() |
3b19458fed | ||
![]() |
86c0ea2999 |
@@ -64,7 +64,7 @@ matrix:
|
|||||||
compiler: clang
|
compiler: clang
|
||||||
addons: &clang38
|
addons: &clang38
|
||||||
apt:
|
apt:
|
||||||
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test']
|
||||||
packages: ['clang-3.8']
|
packages: ['clang-3.8']
|
||||||
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release'
|
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
*v1.5.0*
|
*v1.5.5*
|
||||||
|
|
||||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
6
include/external/clara.h
vendored
6
include/external/clara.h
vendored
@@ -6,7 +6,7 @@
|
|||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Version 0.0.2.3
|
// Version 0.0.2.4
|
||||||
|
|
||||||
// Only use header guard if we are not using an outer namespace
|
// Only use header guard if we are not using an outer namespace
|
||||||
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
||||||
@@ -589,7 +589,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( std::string( " \t:=\0", 5 ).find( c ) == std::string::npos )
|
if( std::string( ":=\0", 5 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string optName = arg.substr( from, i-from );
|
std::string optName = arg.substr( from, i-from );
|
||||||
@@ -603,7 +603,7 @@ namespace Clara {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( inQuotes || std::string( " \t\0", 3 ).find( c ) == std::string::npos )
|
if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string data = arg.substr( from, i-from );
|
std::string data = arg.substr( from, i-from );
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
||||||
} \
|
} \
|
||||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||||
} while( Catch::isTrue( false && static_cast<bool>(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
|
} while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
||||||
|
@@ -36,10 +36,18 @@
|
|||||||
|
|
||||||
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
|
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
|
||||||
|
|
||||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
# if __cplusplus >= 201103L
|
||||||
# define CATCH_CPP11_OR_GREATER
|
# define CATCH_CPP11_OR_GREATER
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if __cplusplus >= 201402L
|
||||||
|
# define CATCH_CPP14_OR_GREATER
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
|
||||||
# if __has_feature(cxx_nullptr)
|
# if __has_feature(cxx_nullptr)
|
||||||
|
@@ -151,7 +151,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
ConfigData m_data;
|
ConfigData m_data;
|
||||||
|
|
||||||
std::auto_ptr<IStream const> m_stream;
|
CATCH_AUTO_PTR( IStream const ) m_stream;
|
||||||
TestSpec m_testSpec;
|
TestSpec m_testSpec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -219,6 +219,7 @@ namespace Catch
|
|||||||
bool aborting;
|
bool aborting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MultipleReporters;
|
||||||
|
|
||||||
struct IStreamingReporter : IShared {
|
struct IStreamingReporter : IShared {
|
||||||
virtual ~IStreamingReporter();
|
virtual ~IStreamingReporter();
|
||||||
@@ -247,6 +248,8 @@ namespace Catch
|
|||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ namespace Catch {
|
|||||||
|
|
||||||
|
|
||||||
class DebugOutStream : public IStream {
|
class DebugOutStream : public IStream {
|
||||||
std::auto_ptr<StreamBufBase> m_streamBuf;
|
CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
|
||||||
mutable std::ostream m_os;
|
mutable std::ostream m_os;
|
||||||
public:
|
public:
|
||||||
DebugOutStream();
|
DebugOutStream();
|
||||||
|
@@ -19,13 +19,30 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
#include <random>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct LexSort {
|
|
||||||
bool operator() (TestCase i,TestCase j) const { return (i<j);}
|
|
||||||
};
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
int operator()( int n ) const { return std::rand() % n; }
|
typedef int result_type;
|
||||||
|
|
||||||
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
static constexpr result_type min() { return 0; }
|
||||||
|
static constexpr result_type max() { return 1000000; }
|
||||||
|
result_type operator()() const { return std::rand() % max(); }
|
||||||
|
#endif
|
||||||
|
template<typename V>
|
||||||
|
static void shuffle( V& vector ) {
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
||||||
|
#else
|
||||||
|
std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
||||||
@@ -34,14 +51,12 @@ namespace Catch {
|
|||||||
|
|
||||||
switch( config.runOrder() ) {
|
switch( config.runOrder() ) {
|
||||||
case RunTests::InLexicographicalOrder:
|
case RunTests::InLexicographicalOrder:
|
||||||
std::sort( sorted.begin(), sorted.end(), LexSort() );
|
std::sort( sorted.begin(), sorted.end() );
|
||||||
break;
|
break;
|
||||||
case RunTests::InRandomOrder:
|
case RunTests::InRandomOrder:
|
||||||
{
|
{
|
||||||
seedRng( config );
|
seedRng( config );
|
||||||
|
RandomNumberGenerator::shuffle( sorted );
|
||||||
RandomNumberGenerator rng;
|
|
||||||
std::random_shuffle( sorted.begin(), sorted.end(), rng );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RunTests::InDeclarationOrder:
|
case RunTests::InDeclarationOrder:
|
||||||
@@ -61,12 +76,14 @@ namespace Catch {
|
|||||||
++it ) {
|
++it ) {
|
||||||
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
|
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
|
||||||
if( !prev.second ) {
|
if( !prev.second ) {
|
||||||
Catch::cerr()
|
std::ostringstream ss;
|
||||||
<< Colour( Colour::Red )
|
|
||||||
|
ss << Colour( Colour::Red )
|
||||||
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
|
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
|
||||||
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
|
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
|
||||||
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
|
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
|
||||||
exit(1);
|
|
||||||
|
throw std::runtime_error(ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,10 @@ namespace TestCaseTracking {
|
|||||||
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
||||||
virtual ITracker* findChild( std::string const& name ) = 0;
|
virtual ITracker* findChild( std::string const& name ) = 0;
|
||||||
virtual void openChild() = 0;
|
virtual void openChild() = 0;
|
||||||
|
|
||||||
|
// Debug/ checking
|
||||||
|
virtual bool isSectionTracker() const = 0;
|
||||||
|
virtual bool isIndexTracker() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrackerContext {
|
class TrackerContext {
|
||||||
@@ -167,6 +171,10 @@ namespace TestCaseTracking {
|
|||||||
m_parent->openChild();
|
m_parent->openChild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; }
|
||||||
|
virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
|
||||||
|
|
||||||
void open() {
|
void open() {
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
moveToThis();
|
moveToThis();
|
||||||
@@ -230,13 +238,16 @@ namespace TestCaseTracking {
|
|||||||
{}
|
{}
|
||||||
virtual ~SectionTracker();
|
virtual ~SectionTracker();
|
||||||
|
|
||||||
|
virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
|
||||||
|
|
||||||
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
||||||
SectionTracker* section = CATCH_NULL;
|
SectionTracker* section = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
section = dynamic_cast<SectionTracker*>( childTracker );
|
assert( childTracker );
|
||||||
assert( section );
|
assert( childTracker->isSectionTracker() );
|
||||||
|
section = static_cast<SectionTracker*>( childTracker );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
section = new SectionTracker( name, ctx, ¤tTracker );
|
section = new SectionTracker( name, ctx, ¤tTracker );
|
||||||
@@ -261,13 +272,16 @@ namespace TestCaseTracking {
|
|||||||
{}
|
{}
|
||||||
virtual ~IndexTracker();
|
virtual ~IndexTracker();
|
||||||
|
|
||||||
|
virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
|
||||||
|
|
||||||
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
||||||
IndexTracker* tracker = CATCH_NULL;
|
IndexTracker* tracker = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
tracker = dynamic_cast<IndexTracker*>( childTracker );
|
assert( childTracker );
|
||||||
assert( tracker );
|
assert( childTracker->isIndexTracker() );
|
||||||
|
tracker = static_cast<IndexTracker*>( childTracker );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
||||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 5, 0, "", 0 );
|
Version libraryVersion( 1, 5, 5, "", 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -118,13 +118,18 @@ public: // IStreamingReporter
|
|||||||
++it )
|
++it )
|
||||||
(*it)->skipTest( testInfo );
|
(*it)->skipTest( testInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
||||||
Ptr<IStreamingReporter> resultingReporter;
|
Ptr<IStreamingReporter> resultingReporter;
|
||||||
|
|
||||||
if( existingReporter ) {
|
if( existingReporter ) {
|
||||||
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
MultipleReporters* multi = existingReporter->tryAsMulti();
|
||||||
if( !multi ) {
|
if( !multi ) {
|
||||||
multi = new MultipleReporters;
|
multi = new MultipleReporters;
|
||||||
resultingReporter = Ptr<IStreamingReporter>( multi );
|
resultingReporter = Ptr<IStreamingReporter>( multi );
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Catch v1.5.0
|
* Catch v1.5.5
|
||||||
* Generated: 2016-04-25 18:56:14.308559
|
* Generated: 2016-06-09 08:17:50.409622
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* 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.
|
||||||
@@ -106,10 +106,18 @@
|
|||||||
|
|
||||||
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
|
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
|
||||||
|
|
||||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
# if __cplusplus >= 201103L
|
||||||
# define CATCH_CPP11_OR_GREATER
|
# define CATCH_CPP11_OR_GREATER
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if __cplusplus >= 201402L
|
||||||
|
# define CATCH_CPP14_OR_GREATER
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
|
||||||
# if __has_feature(cxx_nullptr)
|
# if __has_feature(cxx_nullptr)
|
||||||
@@ -2065,7 +2073,7 @@ namespace Catch {
|
|||||||
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
||||||
} \
|
} \
|
||||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||||
} while( Catch::isTrue( false && static_cast<bool>(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
|
} while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
||||||
@@ -3450,7 +3458,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class DebugOutStream : public IStream {
|
class DebugOutStream : public IStream {
|
||||||
std::auto_ptr<StreamBufBase> m_streamBuf;
|
CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
|
||||||
mutable std::ostream m_os;
|
mutable std::ostream m_os;
|
||||||
public:
|
public:
|
||||||
DebugOutStream();
|
DebugOutStream();
|
||||||
@@ -3598,7 +3606,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
ConfigData m_data;
|
ConfigData m_data;
|
||||||
|
|
||||||
std::auto_ptr<IStream const> m_stream;
|
CATCH_AUTO_PTR( IStream const ) m_stream;
|
||||||
TestSpec m_testSpec;
|
TestSpec m_testSpec;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3618,7 +3626,7 @@ namespace Catch {
|
|||||||
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
|
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
|
||||||
// #included from: ../external/clara.h
|
// #included from: ../external/clara.h
|
||||||
|
|
||||||
// Version 0.0.2.3
|
// Version 0.0.2.4
|
||||||
|
|
||||||
// Only use header guard if we are not using an outer namespace
|
// Only use header guard if we are not using an outer namespace
|
||||||
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
||||||
@@ -4177,7 +4185,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( std::string( " \t:=\0", 5 ).find( c ) == std::string::npos )
|
if( std::string( ":=\0", 5 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string optName = arg.substr( from, i-from );
|
std::string optName = arg.substr( from, i-from );
|
||||||
@@ -4191,7 +4199,7 @@ namespace Clara {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( inQuotes || std::string( " \t\0", 3 ).find( c ) == std::string::npos )
|
if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string data = arg.substr( from, i-from );
|
std::string data = arg.substr( from, i-from );
|
||||||
@@ -5253,6 +5261,8 @@ namespace Catch
|
|||||||
bool aborting;
|
bool aborting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MultipleReporters;
|
||||||
|
|
||||||
struct IStreamingReporter : IShared {
|
struct IStreamingReporter : IShared {
|
||||||
virtual ~IStreamingReporter();
|
virtual ~IStreamingReporter();
|
||||||
|
|
||||||
@@ -5280,6 +5290,8 @@ namespace Catch
|
|||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IReporterFactory : IShared {
|
struct IReporterFactory : IShared {
|
||||||
@@ -5497,6 +5509,10 @@ namespace TestCaseTracking {
|
|||||||
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
||||||
virtual ITracker* findChild( std::string const& name ) = 0;
|
virtual ITracker* findChild( std::string const& name ) = 0;
|
||||||
virtual void openChild() = 0;
|
virtual void openChild() = 0;
|
||||||
|
|
||||||
|
// Debug/ checking
|
||||||
|
virtual bool isSectionTracker() const = 0;
|
||||||
|
virtual bool isIndexTracker() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrackerContext {
|
class TrackerContext {
|
||||||
@@ -5621,6 +5637,10 @@ namespace TestCaseTracking {
|
|||||||
m_parent->openChild();
|
m_parent->openChild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; }
|
||||||
|
virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
|
||||||
|
|
||||||
void open() {
|
void open() {
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
moveToThis();
|
moveToThis();
|
||||||
@@ -5684,13 +5704,16 @@ namespace TestCaseTracking {
|
|||||||
{}
|
{}
|
||||||
virtual ~SectionTracker();
|
virtual ~SectionTracker();
|
||||||
|
|
||||||
|
virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
|
||||||
|
|
||||||
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
||||||
SectionTracker* section = CATCH_NULL;
|
SectionTracker* section = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
section = dynamic_cast<SectionTracker*>( childTracker );
|
assert( childTracker );
|
||||||
assert( section );
|
assert( childTracker->isSectionTracker() );
|
||||||
|
section = static_cast<SectionTracker*>( childTracker );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
section = new SectionTracker( name, ctx, ¤tTracker );
|
section = new SectionTracker( name, ctx, ¤tTracker );
|
||||||
@@ -5715,13 +5738,16 @@ namespace TestCaseTracking {
|
|||||||
{}
|
{}
|
||||||
virtual ~IndexTracker();
|
virtual ~IndexTracker();
|
||||||
|
|
||||||
|
virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
|
||||||
|
|
||||||
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
||||||
IndexTracker* tracker = CATCH_NULL;
|
IndexTracker* tracker = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
tracker = dynamic_cast<IndexTracker*>( childTracker );
|
assert( childTracker );
|
||||||
assert( tracker );
|
assert( childTracker->isIndexTracker() );
|
||||||
|
tracker = static_cast<IndexTracker*>( childTracker );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
||||||
@@ -6421,13 +6447,30 @@ namespace Catch {
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
#include <random>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct LexSort {
|
|
||||||
bool operator() (TestCase i,TestCase j) const { return (i<j);}
|
|
||||||
};
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
int operator()( int n ) const { return std::rand() % n; }
|
typedef int result_type;
|
||||||
|
|
||||||
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
static constexpr result_type min() { return 0; }
|
||||||
|
static constexpr result_type max() { return 1000000; }
|
||||||
|
result_type operator()() const { return std::rand() % max(); }
|
||||||
|
#endif
|
||||||
|
template<typename V>
|
||||||
|
static void shuffle( V& vector ) {
|
||||||
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
|
std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
||||||
|
#else
|
||||||
|
std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
||||||
@@ -6436,14 +6479,12 @@ namespace Catch {
|
|||||||
|
|
||||||
switch( config.runOrder() ) {
|
switch( config.runOrder() ) {
|
||||||
case RunTests::InLexicographicalOrder:
|
case RunTests::InLexicographicalOrder:
|
||||||
std::sort( sorted.begin(), sorted.end(), LexSort() );
|
std::sort( sorted.begin(), sorted.end() );
|
||||||
break;
|
break;
|
||||||
case RunTests::InRandomOrder:
|
case RunTests::InRandomOrder:
|
||||||
{
|
{
|
||||||
seedRng( config );
|
seedRng( config );
|
||||||
|
RandomNumberGenerator::shuffle( sorted );
|
||||||
RandomNumberGenerator rng;
|
|
||||||
std::random_shuffle( sorted.begin(), sorted.end(), rng );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RunTests::InDeclarationOrder:
|
case RunTests::InDeclarationOrder:
|
||||||
@@ -6463,12 +6504,14 @@ namespace Catch {
|
|||||||
++it ) {
|
++it ) {
|
||||||
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
|
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
|
||||||
if( !prev.second ) {
|
if( !prev.second ) {
|
||||||
Catch::cerr()
|
std::ostringstream ss;
|
||||||
<< Colour( Colour::Red )
|
|
||||||
|
ss << Colour( Colour::Red )
|
||||||
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
|
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
|
||||||
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
|
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
|
||||||
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
|
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
|
||||||
exit(1);
|
|
||||||
|
throw std::runtime_error(ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7527,7 +7570,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 5, 0, "", 0 );
|
Version libraryVersion( 1, 5, 5, "", 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8506,13 +8549,18 @@ public: // IStreamingReporter
|
|||||||
++it )
|
++it )
|
||||||
(*it)->skipTest( testInfo );
|
(*it)->skipTest( testInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
||||||
Ptr<IStreamingReporter> resultingReporter;
|
Ptr<IStreamingReporter> resultingReporter;
|
||||||
|
|
||||||
if( existingReporter ) {
|
if( existingReporter ) {
|
||||||
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
MultipleReporters* multi = existingReporter->tryAsMulti();
|
||||||
if( !multi ) {
|
if( !multi ) {
|
||||||
multi = new MultipleReporters;
|
multi = new MultipleReporters;
|
||||||
resultingReporter = Ptr<IStreamingReporter>( multi );
|
resultingReporter = Ptr<IStreamingReporter>( multi );
|
||||||
|
Reference in New Issue
Block a user