Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2015-12-04 10:19:08 +0000
committerPhil Nash2015-12-04 10:19:08 +0000
commitfdc42d0af47f58fa13a42b685bbeaf55a8347673 (patch)
tree779ff3d692eeffd33353d89ad7697a592ab5201e /include
parentd758428fe297655e558a86cc6a013fcb1bcc8c7d (diff)
parentd274fc571c3980b5ac04cbe1416cf2205e6c99f7 (diff)
downloadcatch3-1.3.0.tar.gz
Merged from develop branchv1.3.0
- now v1.3.0
Diffstat (limited to 'include')
-rw-r--r--include/catch.hpp34
-rw-r--r--include/catch_session.hpp (renamed from include/catch_runner.hpp)165
-rw-r--r--include/external/clara.h25
-rw-r--r--include/internal/catch_capture.hpp10
-rw-r--r--include/internal/catch_commandline.hpp9
-rw-r--r--include/internal/catch_common.h10
-rw-r--r--include/internal/catch_common.hpp12
-rw-r--r--include/internal/catch_compiler_capabilities.h60
-rw-r--r--include/internal/catch_config.hpp45
-rw-r--r--include/internal/catch_console_colour_impl.hpp10
-rw-r--r--include/internal/catch_context_impl.hpp18
-rw-r--r--include/internal/catch_debugger.hpp2
-rw-r--r--include/internal/catch_evaluate.hpp42
-rw-r--r--include/internal/catch_exception_translator_registry.hpp21
-rw-r--r--include/internal/catch_impl.hpp18
-rw-r--r--include/internal/catch_interfaces_capture.h4
-rw-r--r--include/internal/catch_interfaces_exception.h14
-rw-r--r--include/internal/catch_interfaces_registry_hub.h5
-rw-r--r--include/internal/catch_interfaces_reporter.h21
-rw-r--r--include/internal/catch_interfaces_testcase.h8
-rw-r--r--include/internal/catch_list.hpp9
-rw-r--r--include/internal/catch_matchers.hpp149
-rw-r--r--include/internal/catch_objc.hpp2
-rw-r--r--include/internal/catch_option.hpp12
-rw-r--r--include/internal/catch_ptr.hpp11
-rw-r--r--include/internal/catch_registry_hub.hpp19
-rw-r--r--include/internal/catch_reporter_registrars.hpp26
-rw-r--r--include/internal/catch_reporter_registry.hpp19
-rw-r--r--include/internal/catch_result_builder.h9
-rw-r--r--include/internal/catch_result_builder.hpp38
-rw-r--r--include/internal/catch_result_type.h2
-rw-r--r--include/internal/catch_run_context.hpp (renamed from include/internal/catch_runner_impl.hpp)95
-rw-r--r--include/internal/catch_section.hpp9
-rw-r--r--include/internal/catch_section_info.h11
-rw-r--r--include/internal/catch_section_info.hpp2
-rw-r--r--include/internal/catch_stream.h53
-rw-r--r--include/internal/catch_stream.hpp38
-rw-r--r--include/internal/catch_suppress_warnings.h6
-rw-r--r--include/internal/catch_test_case_info.h4
-rw-r--r--include/internal/catch_test_case_info.hpp25
-rw-r--r--include/internal/catch_test_case_registry_impl.hpp179
-rw-r--r--include/internal/catch_test_case_tracker.hpp364
-rw-r--r--include/internal/catch_test_registry.hpp49
-rw-r--r--include/internal/catch_test_spec.hpp46
-rw-r--r--include/internal/catch_timer.hpp2
-rw-r--r--include/internal/catch_tostring.h15
-rw-r--r--include/internal/catch_tostring.hpp25
-rw-r--r--include/internal/catch_version.h2
-rw-r--r--include/internal/catch_version.hpp2
-rw-r--r--include/internal/catch_wildcard_pattern.hpp71
-rw-r--r--include/internal/catch_xmlwriter.hpp103
-rw-r--r--include/reporters/catch_reporter_bases.hpp76
-rw-r--r--include/reporters/catch_reporter_console.hpp23
-rw-r--r--include/reporters/catch_reporter_junit.hpp34
-rw-r--r--include/reporters/catch_reporter_multi.hpp147
-rw-r--r--include/reporters/catch_reporter_teamcity.hpp77
-rw-r--r--include/reporters/catch_reporter_xml.hpp43
57 files changed, 1580 insertions, 750 deletions
diff --git a/include/catch.hpp b/include/catch.hpp
index f6359c02..06ed7eee 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -70,8 +70,9 @@
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
-#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" )
+#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
+#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
@@ -82,6 +83,7 @@
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
+#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" )
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
@@ -97,6 +99,7 @@
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
+ #define CATCH_REGISTER_TEST_CASE( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ )
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
@@ -104,6 +107,7 @@
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
#define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
+ #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
@@ -123,11 +127,11 @@
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
-#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
-#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
-#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" )
-#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" )
-#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " desc, "" )
+#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
+#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
+#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
+#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
+#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
#else
@@ -135,8 +139,9 @@
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
-#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "REQUIRE_THROWS" )
+#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
+#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
@@ -145,8 +150,9 @@
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
-#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" )
+#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
+#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
@@ -162,6 +168,7 @@
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
+ #define REGISTER_TEST_CASE( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ )
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
@@ -169,6 +176,7 @@
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
#define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
+ #define REGISTER_TEST_CASE( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ )
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
@@ -192,11 +200,11 @@
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif
-#define GIVEN( desc ) SECTION( " Given: " desc, "" )
-#define WHEN( desc ) SECTION( " When: " desc, "" )
-#define AND_WHEN( desc ) SECTION( "And when: " desc, "" )
-#define THEN( desc ) SECTION( " Then: " desc, "" )
-#define AND_THEN( desc ) SECTION( " And: " desc, "" )
+#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
+#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
+#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
+#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
+#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
using Catch::Detail::Approx;
diff --git a/include/catch_runner.hpp b/include/catch_session.hpp
index 8023d970..9cfc28fd 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_session.hpp
@@ -10,7 +10,7 @@
#include "internal/catch_commandline.hpp"
#include "internal/catch_list.hpp"
-#include "internal/catch_runner_impl.hpp"
+#include "internal/catch_run_context.hpp"
#include "internal/catch_test_spec.hpp"
#include "internal/catch_version.h"
#include "internal/catch_text.h"
@@ -21,89 +21,88 @@
namespace Catch {
- class Runner {
-
- public:
- Runner( Ptr<Config> const& config )
- : m_config( config )
- {
- openStream();
- makeReporter();
+ Ptr<IStreamingReporter> createReporter( std::string const& reporterName, Ptr<Config> const& config ) {
+ Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
+ if( !reporter ) {
+ std::ostringstream oss;
+ oss << "No reporter registered with name: '" << reporterName << "'";
+ throw std::domain_error( oss.str() );
+ }
+ return reporter;
+ }
+
+ Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
+ std::vector<std::string> reporters = config->getReporterNames();
+ if( reporters.empty() )
+ reporters.push_back( "console" );
+
+ Ptr<IStreamingReporter> reporter;
+ for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
+ it != itEnd;
+ ++it )
+ reporter = addReporter( reporter, createReporter( *it, config ) );
+ return reporter;
+ }
+ Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
+ IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners();
+ for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end();
+ it != itEnd;
+ ++it )
+ reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
+ return reporters;
+ }
+
+
+ Totals runTests( Ptr<Config> const& config ) {
+
+ Ptr<IConfig const> iconfig = config.get();
+
+ Ptr<IStreamingReporter> reporter = makeReporter( config );
+ reporter = addListeners( iconfig, reporter );
+
+ RunContext context( iconfig, reporter );
+
+ Totals totals;
+
+ context.testGroupStarting( config->name(), 1, 1 );
+
+ TestSpec testSpec = config->testSpec();
+ if( !testSpec.hasFilters() )
+ testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
+
+ std::vector<TestCase> const& allTestCases = getAllTestCasesSorted( *iconfig );
+ for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
+ it != itEnd;
+ ++it ) {
+ if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) )
+ totals += context.runTest( *it );
+ else
+ reporter->skipTest( *it );
}
- Totals runTests() {
-
- RunContext context( m_config.get(), m_reporter );
-
- Totals totals;
-
- context.testGroupStarting( "all tests", 1, 1 ); // deprecated?
-
- TestSpec testSpec = m_config->testSpec();
- if( !testSpec.hasFilters() )
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
+ context.testGroupEnded( iconfig->name(), totals, 1, 1 );
+ return totals;
+ }
- std::vector<TestCase> testCases;
- getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *m_config, testCases );
+ void applyFilenamesAsTags( IConfig const& config ) {
+ std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
+ for(std::size_t i = 0; i < tests.size(); ++i ) {
+ TestCase& test = const_cast<TestCase&>( tests[i] );
+ std::set<std::string> tags = test.tags;
- int testsRunForGroup = 0;
- for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
- it != itEnd;
- ++it ) {
- testsRunForGroup++;
- if( m_testsAlreadyRun.find( *it ) == m_testsAlreadyRun.end() ) {
+ 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 );
- if( context.aborting() )
- break;
+ std::string::size_type lastDot = filename.find_last_of( "." );
+ if( lastDot != std::string::npos )
+ filename = filename.substr( 0, lastDot );
- totals += context.runTest( *it );
- m_testsAlreadyRun.insert( *it );
- }
- }
- std::vector<TestCase> skippedTestCases;
- getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *m_config, skippedTestCases, true );
-
- for( std::vector<TestCase>::const_iterator it = skippedTestCases.begin(), itEnd = skippedTestCases.end();
- it != itEnd;
- ++it )
- m_reporter->skipTest( *it );
-
- context.testGroupEnded( "all tests", totals, 1, 1 );
- return totals;
+ tags.insert( "#" + filename );
+ setTags( test, tags );
}
-
- private:
- void openStream() {
- // Open output file, if specified
- if( !m_config->getFilename().empty() ) {
- m_ofs.open( m_config->getFilename().c_str() );
- if( m_ofs.fail() ) {
- std::ostringstream oss;
- oss << "Unable to open file: '" << m_config->getFilename() << "'";
- throw std::domain_error( oss.str() );
- }
- m_config->setStreamBuf( m_ofs.rdbuf() );
- }
- }
- void makeReporter() {
- std::string reporterName = m_config->getReporterName().empty()
- ? "console"
- : m_config->getReporterName();
-
- m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, m_config.get() );
- if( !m_reporter ) {
- std::ostringstream oss;
- oss << "No reporter registered with name: '" << reporterName << "'";
- throw std::domain_error( oss.str() );
- }
- }
-
- private:
- Ptr<Config> m_config;
- std::ofstream m_ofs;
- Ptr<IStreamingReporter> m_reporter;
- std::set<TestCase> m_testsAlreadyRun;
- };
+ }
class Session : NonCopyable {
static bool alreadyInstantiated;
@@ -132,7 +131,7 @@ namespace Catch {
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
}
- int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
+ int applyCommandLine( int argc, char const* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
try {
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
@@ -159,7 +158,7 @@ namespace Catch {
m_config.reset();
}
- int run( int argc, char* const argv[] ) {
+ int run( int argc, char const* const argv[] ) {
int returnCode = applyCommandLine( argc, argv );
if( returnCode == 0 )
@@ -175,15 +174,16 @@ namespace Catch {
{
config(); // Force config to be constructed
- std::srand( m_configData.rngSeed );
+ seedRng( *m_config );
- Runner runner( m_config );
+ if( m_configData.filenamesAsTags )
+ applyFilenamesAsTags( *m_config );
// Handle list request
if( Option<std::size_t> listed = list( config() ) )
return static_cast<int>( *listed );
- return static_cast<int>( runner.runTests().assertions.failed );
+ return static_cast<int>( runTests( m_config ).assertions.failed );
}
catch( std::exception& ex ) {
Catch::cerr() << ex.what() << std::endl;
@@ -205,7 +205,6 @@ namespace Catch {
m_config = new Config( m_configData );
return *m_config;
}
-
private:
Clara::CommandLine<ConfigData> m_cli;
std::vector<Clara::Parser::Token> m_unusedTokens;
diff --git a/include/external/clara.h b/include/external/clara.h
index bc162806..2c03f985 100644
--- a/include/external/clara.h
+++ b/include/external/clara.h
@@ -264,11 +264,11 @@ namespace Clara {
template<typename ConfigT>
class BoundArgFunction {
public:
- BoundArgFunction() : functionObj( NULL ) {}
+ BoundArgFunction() : functionObj( CATCH_NULL ) {}
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 ) {
- IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
+ IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL;
delete functionObj;
functionObj = newFunctionObj;
return *this;
@@ -284,7 +284,7 @@ namespace Clara {
bool takesArg() const { return functionObj->takesArg(); }
bool isSet() const {
- return functionObj != NULL;
+ return functionObj != CATCH_NULL;
}
private:
IArgFunction<ConfigT>* functionObj;
@@ -503,12 +503,7 @@ namespace Clara {
}
};
- // NOTE: std::auto_ptr is deprecated in c++11/c++0x
-#if defined(__cplusplus) && __cplusplus > 199711L
- typedef std::unique_ptr<Arg> ArgAutoPtr;
-#else
- typedef std::auto_ptr<Arg> ArgAutoPtr;
-#endif
+ typedef CATCH_AUTO_PTR( Arg ) ArgAutoPtr;
friend void addOptName( Arg& arg, std::string const& optName )
{
@@ -585,8 +580,8 @@ namespace Clara {
m_arg->description = description;
return *this;
}
- ArgBuilder& detail( std::string const& detail ) {
- m_arg->detail = detail;
+ ArgBuilder& detail( std::string const& _detail ) {
+ m_arg->detail = _detail;
return *this;
}
@@ -670,14 +665,14 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) {
- Detail::Text usage( it->commands(), Detail::TextAttributes()
+ Detail::Text usageText( it->commands(), Detail::TextAttributes()
.setWidth( maxWidth+indent )
.setIndent( indent ) );
Detail::Text desc( it->description, Detail::TextAttributes()
.setWidth( width - maxWidth - 3 ) );
- for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
- std::string usageCol = i < usage.size() ? usage[i] : "";
+ for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
+ std::string usageCol = i < usageText.size() ? usageText[i] : "";
os << usageCol;
if( i < desc.size() && !desc[i].empty() )
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 7bfef0e1..22cf6959 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -66,16 +66,16 @@
} while( Catch::alwaysFalse() )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_THROWS( expr, resultDisposition, macroName ) \
+#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
+ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
if( __catchResult.allowThrows() ) \
try { \
expr; \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \
catch( ... ) { \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
+ __catchResult.captureExpectedException( matcher ); \
} \
else \
__catchResult.captureResult( Catch::ResultWas::Ok ); \
@@ -131,