mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-14 17:35:39 +02:00
Compare commits
20 Commits
v1.2.1-dev
...
v1.2.1-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8b1b7cd66e | ||
![]() |
34fa25ed2f | ||
![]() |
85c8074784 | ||
![]() |
0edebf41b0 | ||
![]() |
f3308ed7c4 | ||
![]() |
74eef52644 | ||
![]() |
e085d4811a | ||
![]() |
2f6371f2ec | ||
![]() |
70975517b3 | ||
![]() |
733ebb6024 | ||
![]() |
d6e59cd56f | ||
![]() |
6de135c63a | ||
![]() |
5bbdc8fd38 | ||
![]() |
72868920bb | ||
![]() |
8342ae8dfb | ||
![]() |
2104ca2aa4 | ||
![]() |
93a842e2f0 | ||
![]() |
85de743d70 | ||
![]() |
5d5ed5a283 | ||
![]() |
57df3ba998 |
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
*v1.2.1-develop.5*
|
*v1.2.1-develop.11*
|
||||||
|
|
||||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@@ -70,8 +70,9 @@
|
|||||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
|
#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_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_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_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" )
|
#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( 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_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 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" )
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
||||||
@@ -123,11 +125,11 @@
|
|||||||
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
|
#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 )
|
#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
|
||||||
#endif
|
#endif
|
||||||
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
|
#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
|
||||||
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
|
#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
|
||||||
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" )
|
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
|
||||||
#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" )
|
#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
|
||||||
#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " 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
|
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
|
||||||
#else
|
#else
|
||||||
@@ -135,8 +137,9 @@
|
|||||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
|
#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_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_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 REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
|
||||||
|
|
||||||
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
|
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
|
||||||
@@ -145,8 +148,9 @@
|
|||||||
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
|
#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_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_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_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" )
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
||||||
@@ -192,11 +196,11 @@
|
|||||||
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
|
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
|
||||||
#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
|
#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
|
||||||
#endif
|
#endif
|
||||||
#define GIVEN( desc ) SECTION( " Given: " desc, "" )
|
#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
|
||||||
#define WHEN( desc ) SECTION( " When: " desc, "" )
|
#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
|
||||||
#define AND_WHEN( desc ) SECTION( "And when: " desc, "" )
|
#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
|
||||||
#define THEN( desc ) SECTION( " Then: " desc, "" )
|
#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
|
||||||
#define AND_THEN( desc ) SECTION( " And: " desc, "" )
|
#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
|
||||||
|
|
||||||
using Catch::Detail::Approx;
|
using Catch::Detail::Approx;
|
||||||
|
|
||||||
|
@@ -21,90 +21,77 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class Runner {
|
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
||||||
|
std::string reporterName = config->getReporterName().empty()
|
||||||
|
? "console"
|
||||||
|
: config->getReporterName();
|
||||||
|
|
||||||
public:
|
Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
|
||||||
Runner( Ptr<Config> const& config )
|
if( !reporter ) {
|
||||||
: m_config( config )
|
std::ostringstream oss;
|
||||||
{
|
oss << "No reporter registered with name: '" << reporterName << "'";
|
||||||
openStream();
|
throw std::domain_error( oss.str() );
|
||||||
makeReporter();
|
}
|
||||||
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals runTests() {
|
void openStreamInto( Ptr<Config> const& config, std::ofstream& ofs ) {
|
||||||
|
// Open output file, if specified
|
||||||
|
if( !config->getFilename().empty() ) {
|
||||||
|
ofs.open( config->getFilename().c_str() );
|
||||||
|
if( ofs.fail() ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Unable to open file: '" << config->getFilename() << "'";
|
||||||
|
throw std::domain_error( oss.str() );
|
||||||
|
}
|
||||||
|
config->setStreamBuf( ofs.rdbuf() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RunContext context( m_config.get(), m_reporter );
|
Totals runTests( Ptr<Config> const& config ) {
|
||||||
|
|
||||||
|
std::ofstream ofs;
|
||||||
|
openStreamInto( config, ofs );
|
||||||
|
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
||||||
|
|
||||||
|
RunContext context( config.get(), reporter );
|
||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
|
|
||||||
context.testGroupStarting( "all tests", 1, 1 ); // deprecated?
|
context.testGroupStarting( config->name(), 1, 1 );
|
||||||
|
|
||||||
TestSpec testSpec = m_config->testSpec();
|
TestSpec testSpec = config->testSpec();
|
||||||
if( !testSpec.hasFilters() )
|
if( !testSpec.hasFilters() )
|
||||||
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
|
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
|
||||||
|
|
||||||
std::vector<TestCase> testCases;
|
std::vector<TestCase> testCases;
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *m_config, testCases );
|
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *config, testCases );
|
||||||
|
|
||||||
int testsRunForGroup = 0;
|
std::set<TestCase> testsAlreadyRun;
|
||||||
for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
|
for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
testsRunForGroup++;
|
if( testsAlreadyRun.find( *it ) == testsAlreadyRun.end() ) {
|
||||||
if( m_testsAlreadyRun.find( *it ) == m_testsAlreadyRun.end() ) {
|
|
||||||
|
|
||||||
if( context.aborting() )
|
if( context.aborting() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
totals += context.runTest( *it );
|
totals += context.runTest( *it );
|
||||||
m_testsAlreadyRun.insert( *it );
|
testsAlreadyRun.insert( *it );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<TestCase> skippedTestCases;
|
std::vector<TestCase> skippedTestCases;
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *m_config, skippedTestCases, true );
|
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *config, skippedTestCases, true );
|
||||||
|
|
||||||
for( std::vector<TestCase>::const_iterator it = skippedTestCases.begin(), itEnd = skippedTestCases.end();
|
for( std::vector<TestCase>::const_iterator it = skippedTestCases.begin(), itEnd = skippedTestCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it )
|
++it )
|
||||||
m_reporter->skipTest( *it );
|
reporter->skipTest( *it );
|
||||||
|
|
||||||
context.testGroupEnded( "all tests", totals, 1, 1 );
|
context.testGroupEnded( config->name(), totals, 1, 1 );
|
||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
void applyFilenamesAsTags() {
|
void applyFilenamesAsTags() {
|
||||||
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
|
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
|
||||||
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
||||||
@@ -200,13 +187,11 @@ namespace Catch {
|
|||||||
|
|
||||||
seedRng( *m_config );
|
seedRng( *m_config );
|
||||||
|
|
||||||
Runner runner( m_config );
|
|
||||||
|
|
||||||
// Handle list request
|
// Handle list request
|
||||||
if( Option<std::size_t> listed = list( config() ) )
|
if( Option<std::size_t> listed = list( config() ) )
|
||||||
return static_cast<int>( *listed );
|
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( std::exception& ex ) {
|
||||||
Catch::cerr() << ex.what() << std::endl;
|
Catch::cerr() << ex.what() << std::endl;
|
||||||
|
@@ -66,16 +66,16 @@
|
|||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
expr; \
|
expr; \
|
||||||
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
||||||
} \
|
} \
|
||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
__catchResult.captureExpectedException( matcher ); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||||
|
@@ -25,6 +25,11 @@ namespace Catch {
|
|||||||
|
|
||||||
struct IConfig;
|
struct IConfig;
|
||||||
|
|
||||||
|
struct CaseSensitive { enum Choice {
|
||||||
|
Yes,
|
||||||
|
No
|
||||||
|
}; };
|
||||||
|
|
||||||
class NonCopyable {
|
class NonCopyable {
|
||||||
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||||
NonCopyable( NonCopyable const& ) = delete;
|
NonCopyable( NonCopyable const& ) = delete;
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
|
// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
|
||||||
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
|
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
|
||||||
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
|
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
|
||||||
|
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
|
||||||
|
|
||||||
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
||||||
|
|
||||||
@@ -66,10 +67,13 @@
|
|||||||
// GCC
|
// GCC
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
|
||||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
|
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
|
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// - otherwise more recent versions define __cplusplus >= 201103L
|
||||||
|
// and will get picked up below
|
||||||
|
|
||||||
|
|
||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|
||||||
@@ -130,6 +134,10 @@
|
|||||||
# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
|
# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
|
||||||
|
# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif // __cplusplus >= 201103L
|
#endif // __cplusplus >= 201103L
|
||||||
|
|
||||||
// Now set the actual defines based on the above + anything the user has configured
|
// Now set the actual defines based on the above + anything the user has configured
|
||||||
@@ -149,7 +157,10 @@
|
|||||||
# define CATCH_CONFIG_CPP11_TUPLE
|
# define CATCH_CONFIG_CPP11_TUPLE
|
||||||
#endif
|
#endif
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
|
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
|
||||||
#define CATCH_CONFIG_VARIADIC_MACROS
|
# define CATCH_CONFIG_VARIADIC_MACROS
|
||||||
|
#endif
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG)
|
||||||
|
# define CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -160,13 +160,51 @@ namespace Internal {
|
|||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
|
// long long to unsigned X
|
||||||
|
template<Operator Op> bool compare( long long lhs, unsigned int rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( long long lhs, unsigned long rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( long long lhs, unsigned long long rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsigned long long to X
|
||||||
|
template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( unsigned long long lhs, long rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( unsigned long long lhs, long long rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
|
||||||
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
// pointer to long long (when comparing against NULL)
|
||||||
|
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
|
||||||
|
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
||||||
|
}
|
||||||
|
template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
|
||||||
|
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
||||||
|
}
|
||||||
|
#endif // CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
|
|
||||||
#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( CATCH_NULL, rhs );
|
return Evaluator<T*, T*, Op>::evaluate( nullptr, 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, CATCH_NULL );
|
return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr );
|
||||||
}
|
}
|
||||||
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
||||||
|
|
||||||
|
@@ -77,6 +77,7 @@ namespace Catch {
|
|||||||
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||||
IGeneratorInfo::~IGeneratorInfo() {}
|
IGeneratorInfo::~IGeneratorInfo() {}
|
||||||
IGeneratorsForTest::~IGeneratorsForTest() {}
|
IGeneratorsForTest::~IGeneratorsForTest() {}
|
||||||
|
WildcardPattern::~WildcardPattern() {}
|
||||||
TestSpec::Pattern::~Pattern() {}
|
TestSpec::Pattern::~Pattern() {}
|
||||||
TestSpec::NamePattern::~NamePattern() {}
|
TestSpec::NamePattern::~NamePattern() {}
|
||||||
TestSpec::TagPattern::~TagPattern() {}
|
TestSpec::TagPattern::~TagPattern() {}
|
||||||
|
@@ -108,68 +108,96 @@ namespace Matchers {
|
|||||||
inline std::string makeString( std::string const& str ) { return str; }
|
inline std::string makeString( std::string const& str ) { return str; }
|
||||||
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
|
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
|
||||||
|
|
||||||
|
struct CasedString
|
||||||
|
{
|
||||||
|
CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
|
||||||
|
: m_caseSensitivity( caseSensitivity ),
|
||||||
|
m_str( adjustString( str ) )
|
||||||
|
{}
|
||||||
|
std::string adjustString( std::string const& str ) const {
|
||||||
|
return m_caseSensitivity == CaseSensitive::No
|
||||||
|
? toLower( str )
|
||||||
|
: str;
|
||||||
|
|
||||||
|
}
|
||||||
|
std::string toStringSuffix() const
|
||||||
|
{
|
||||||
|
return m_caseSensitivity == CaseSensitive::No
|
||||||
|
? " (case insensitive)"
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
CaseSensitive::Choice m_caseSensitivity;
|
||||||
|
std::string m_str;
|
||||||
|
};
|
||||||
|
|
||||||
struct Equals : MatcherImpl<Equals, std::string> {
|
struct Equals : MatcherImpl<Equals, std::string> {
|
||||||
Equals( std::string const& str ) : m_str( str ){}
|
Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
Equals( Equals const& other ) : m_str( other.m_str ){}
|
: m_data( str, caseSensitivity )
|
||||||
|
{}
|
||||||
|
Equals( Equals const& other ) : m_data( other.m_data ){}
|
||||||
|
|
||||||
virtual ~Equals();
|
virtual ~Equals();
|
||||||
|
|
||||||
virtual bool match( std::string const& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return m_str == expr;
|
return m_data.m_str == m_data.adjustString( expr );;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "equals: \"" + m_str + "\"";
|
return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_str;
|
CasedString m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Contains : MatcherImpl<Contains, std::string> {
|
struct Contains : MatcherImpl<Contains, std::string> {
|
||||||
Contains( std::string const& substr ) : m_substr( substr ){}
|
Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
Contains( Contains const& other ) : m_substr( other.m_substr ){}
|
: m_data( substr, caseSensitivity ){}
|
||||||
|
Contains( Contains const& other ) : m_data( other.m_data ){}
|
||||||
|
|
||||||
virtual ~Contains();
|
virtual ~Contains();
|
||||||
|
|
||||||
virtual bool match( std::string const& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) != std::string::npos;
|
return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "contains: \"" + m_substr + "\"";
|
return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_substr;
|
CasedString m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
||||||
StartsWith( std::string const& substr ) : m_substr( substr ){}
|
StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
StartsWith( StartsWith const& other ) : m_substr( other.m_substr ){}
|
: m_data( substr, caseSensitivity ){}
|
||||||
|
|
||||||
|
StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
|
||||||
|
|
||||||
virtual ~StartsWith();
|
virtual ~StartsWith();
|
||||||
|
|
||||||
virtual bool match( std::string const& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) == 0;
|
return m_data.adjustString( expr ).find( m_data.m_str ) == 0;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "starts with: \"" + m_substr + "\"";
|
return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_substr;
|
CasedString m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EndsWith : MatcherImpl<EndsWith, std::string> {
|
struct EndsWith : MatcherImpl<EndsWith, std::string> {
|
||||||
EndsWith( std::string const& substr ) : m_substr( substr ){}
|
EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
EndsWith( EndsWith const& other ) : m_substr( other.m_substr ){}
|
: m_data( substr, caseSensitivity ){}
|
||||||
|
EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
|
||||||
|
|
||||||
virtual ~EndsWith();
|
virtual ~EndsWith();
|
||||||
|
|
||||||
virtual bool match( std::string const& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) == expr.size() - m_substr.size();
|
return m_data.adjustString( expr ).find( m_data.m_str ) == expr.size() - m_data.m_str.size();
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "ends with: \"" + m_substr + "\"";
|
return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_substr;
|
CasedString m_data;
|
||||||
};
|
};
|
||||||
} // namespace StdString
|
} // namespace StdString
|
||||||
} // namespace Impl
|
} // namespace Impl
|
||||||
@@ -199,17 +227,17 @@ namespace Matchers {
|
|||||||
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Impl::StdString::Equals Equals( std::string const& str ) {
|
inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
|
||||||
return Impl::StdString::Equals( str );
|
return Impl::StdString::Equals( str, caseSensitivity );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Equals Equals( const char* str ) {
|
inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
|
||||||
return Impl::StdString::Equals( Impl::StdString::makeString( str ) );
|
return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Contains Contains( std::string const& substr ) {
|
inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
|
||||||
return Impl::StdString::Contains( substr );
|
return Impl::StdString::Contains( substr, caseSensitivity );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Contains Contains( const char* substr ) {
|
inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
|
||||||
return Impl::StdString::Contains( Impl::StdString::makeString( substr ) );
|
return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
|
inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
|
||||||
return Impl::StdString::StartsWith( substr );
|
return Impl::StdString::StartsWith( substr );
|
||||||
|
@@ -52,8 +52,7 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
|
void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
|
||||||
T* get() { return m_p; }
|
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 == CATCH_NULL; }
|
bool operator !() const { return m_p == CATCH_NULL; }
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include "catch_result_type.h"
|
#include "catch_result_type.h"
|
||||||
#include "catch_assertionresult.h"
|
#include "catch_assertionresult.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
|
#include "catch_matchers.hpp"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@@ -38,7 +39,8 @@ namespace Catch {
|
|||||||
ResultBuilder( char const* macroName,
|
ResultBuilder( char const* macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition );
|
ResultDisposition::Flags resultDisposition,
|
||||||
|
char const* secondArg = "" );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ExpressionLhs<T const&> operator <= ( T const& operand );
|
ExpressionLhs<T const&> operator <= ( T const& operand );
|
||||||
@@ -67,6 +69,9 @@ namespace Catch {
|
|||||||
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
|
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
|
||||||
void captureResult( ResultWas::OfType resultType );
|
void captureResult( ResultWas::OfType resultType );
|
||||||
void captureExpression();
|
void captureExpression();
|
||||||
|
void captureExpectedException( std::string const& expectedMessage );
|
||||||
|
void captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher );
|
||||||
|
void handleResult( AssertionResult const& result );
|
||||||
void react();
|
void react();
|
||||||
bool shouldDebugBreak() const;
|
bool shouldDebugBreak() const;
|
||||||
bool allowThrows() const;
|
bool allowThrows() const;
|
||||||
|
@@ -14,15 +14,21 @@
|
|||||||
#include "catch_interfaces_runner.h"
|
#include "catch_interfaces_runner.h"
|
||||||
#include "catch_interfaces_capture.h"
|
#include "catch_interfaces_capture.h"
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
|
#include "catch_wildcard_pattern.hpp"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
|
||||||
|
return secondArg.empty() || secondArg == "\"\""
|
||||||
|
? capturedExpression
|
||||||
|
: capturedExpression + ", " + secondArg;
|
||||||
|
}
|
||||||
ResultBuilder::ResultBuilder( char const* macroName,
|
ResultBuilder::ResultBuilder( char const* macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition )
|
ResultDisposition::Flags resultDisposition,
|
||||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition ),
|
char const* secondArg )
|
||||||
|
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false )
|
m_shouldThrow( false )
|
||||||
{}
|
{}
|
||||||
@@ -63,9 +69,35 @@ namespace Catch {
|
|||||||
setResultType( resultType );
|
setResultType( resultType );
|
||||||
captureExpression();
|
captureExpression();
|
||||||
}
|
}
|
||||||
|
void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
|
||||||
|
if( expectedMessage.empty() )
|
||||||
|
captureExpectedException( Matchers::Impl::Generic::AllOf<std::string>() );
|
||||||
|
else
|
||||||
|
captureExpectedException( Matchers::Equals( expectedMessage ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
|
||||||
|
|
||||||
|
assert( m_exprComponents.testFalse == false );
|
||||||
|
AssertionResultData data = m_data;
|
||||||
|
data.resultType = ResultWas::Ok;
|
||||||
|
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||||
|
|
||||||
|
std::string actualMessage = Catch::translateActiveException();
|
||||||
|
if( !matcher.match( actualMessage ) ) {
|
||||||
|
data.resultType = ResultWas::ExpressionFailed;
|
||||||
|
data.reconstructedExpression = actualMessage;
|
||||||
|
}
|
||||||
|
AssertionResult result( m_assertionInfo, data );
|
||||||
|
handleResult( result );
|
||||||
|
}
|
||||||
|
|
||||||
void ResultBuilder::captureExpression() {
|
void ResultBuilder::captureExpression() {
|
||||||
AssertionResult result = build();
|
AssertionResult result = build();
|
||||||
|
handleResult( result );
|
||||||
|
}
|
||||||
|
void ResultBuilder::handleResult( AssertionResult const& result )
|
||||||
|
{
|
||||||
getResultCapture().assertionEnded( result );
|
getResultCapture().assertionEnded( result );
|
||||||
|
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
|
@@ -105,6 +105,7 @@ namespace Catch {
|
|||||||
std::vector<TestCase> m_functionsInOrder;
|
std::vector<TestCase> m_functionsInOrder;
|
||||||
std::vector<TestCase> m_nonHiddenFunctions;
|
std::vector<TestCase> m_nonHiddenFunctions;
|
||||||
size_t m_unnamedCount;
|
size_t m_unnamedCount;
|
||||||
|
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#pragma clang diagnostic ignored "-Wpadded"
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "catch_wildcard_pattern.hpp"
|
||||||
#include "catch_test_case_info.h"
|
#include "catch_test_case_info.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -26,50 +27,18 @@ namespace Catch {
|
|||||||
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
||||||
};
|
};
|
||||||
class NamePattern : public Pattern {
|
class NamePattern : public Pattern {
|
||||||
enum WildcardPosition {
|
|
||||||
NoWildcard = 0,
|
|
||||||
WildcardAtStart = 1,
|
|
||||||
WildcardAtEnd = 2,
|
|
||||||
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) {
|
NamePattern( std::string const& name )
|
||||||
if( startsWith( m_name, "*" ) ) {
|
: m_wildcardPattern( toLower( name ), CaseSensitive::No )
|
||||||
m_name = m_name.substr( 1 );
|
{}
|
||||||
m_wildcard = WildcardAtStart;
|
|
||||||
}
|
|
||||||
if( endsWith( m_name, "*" ) ) {
|
|
||||||
m_name = m_name.substr( 0, m_name.size()-1 );
|
|
||||||
m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual ~NamePattern();
|
virtual ~NamePattern();
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const {
|
virtual bool matches( TestCaseInfo const& testCase ) const {
|
||||||
switch( m_wildcard ) {
|
return m_wildcardPattern.matches( toLower( testCase.name ) );
|
||||||
case NoWildcard:
|
|
||||||
return m_name == toLower( testCase.name );
|
|
||||||
case WildcardAtStart:
|
|
||||||
return endsWith( toLower( testCase.name ), m_name );
|
|
||||||
case WildcardAtEnd:
|
|
||||||
return startsWith( toLower( testCase.name ), m_name );
|
|
||||||
case WildcardAtBothEnds:
|
|
||||||
return contains( toLower( testCase.name ), m_name );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
|
||||||
#endif
|
|
||||||
throw std::logic_error( "Unknown enum" );
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
WildcardPattern m_wildcardPattern;
|
||||||
WildcardPosition m_wildcard;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TagPattern : public Pattern {
|
class TagPattern : public Pattern {
|
||||||
public:
|
public:
|
||||||
TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
|
TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
|
||||||
@@ -80,6 +49,7 @@ namespace Catch {
|
|||||||
private:
|
private:
|
||||||
std::string m_tag;
|
std::string m_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExcludedPattern : public Pattern {
|
class ExcludedPattern : public Pattern {
|
||||||
public:
|
public:
|
||||||
ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
|
ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
|
||||||
|
@@ -52,6 +52,11 @@ std::string toString( char value );
|
|||||||
std::string toString( signed char value );
|
std::string toString( signed char value );
|
||||||
std::string toString( unsigned char value );
|
std::string toString( unsigned char value );
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
|
std::string toString( long long value );
|
||||||
|
std::string toString( unsigned long long value );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
std::string toString( std::nullptr_t );
|
std::string toString( std::nullptr_t );
|
||||||
#endif
|
#endif
|
||||||
@@ -65,7 +70,7 @@ std::string toString( std::nullptr_t );
|
|||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
extern std::string unprintableString;
|
extern const std::string unprintableString;
|
||||||
|
|
||||||
struct BorgType {
|
struct BorgType {
|
||||||
template<typename T> BorgType( T const& );
|
template<typename T> BorgType( T const& );
|
||||||
|
@@ -15,9 +15,11 @@ namespace Catch {
|
|||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
std::string unprintableString = "{?}";
|
const std::string unprintableString = "{?}";
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
const int hexThreshold = 255;
|
||||||
|
|
||||||
struct Endianness {
|
struct Endianness {
|
||||||
enum Arch { Big, Little };
|
enum Arch { Big, Little };
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ std::string toString( wchar_t* const value )
|
|||||||
std::string toString( int value ) {
|
std::string toString( int value ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << value;
|
oss << value;
|
||||||
if( value >= 255 )
|
if( value > Detail::hexThreshold )
|
||||||
oss << " (0x" << std::hex << value << ")";
|
oss << " (0x" << std::hex << value << ")";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
@@ -107,7 +109,7 @@ std::string toString( int value ) {
|
|||||||
std::string toString( unsigned long value ) {
|
std::string toString( unsigned long value ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << value;
|
oss << value;
|
||||||
if( value >= 255 )
|
if( value > Detail::hexThreshold )
|
||||||
oss << " (0x" << std::hex << value << ")";
|
oss << " (0x" << std::hex << value << ")";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
@@ -157,6 +159,23 @@ std::string toString( unsigned char value ) {
|
|||||||
return toString( static_cast<char>( value ) );
|
return toString( static_cast<char>( value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
|
std::string toString( long long value ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << value;
|
||||||
|
if( value > Detail::hexThreshold )
|
||||||
|
oss << " (0x" << std::hex << value << ")";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
std::string toString( unsigned long long value ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << value;
|
||||||
|
if( value > Detail::hexThreshold )
|
||||||
|
oss << " (0x" << std::hex << value << ")";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
std::string toString( std::nullptr_t ) {
|
std::string toString( std::nullptr_t ) {
|
||||||
return "nullptr";
|
return "nullptr";
|
||||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 2, 1, "develop", 5 );
|
Version libraryVersion( 1, 2, 1, "develop", 11 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
71
include/internal/catch_wildcard_pattern.hpp
Normal file
71
include/internal/catch_wildcard_pattern.hpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 13/7/2015.
|
||||||
|
* Copyright 2015 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_WILDCARD_PATTERN_HPP_INCLUDED
|
||||||
|
#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "catch_common.h"
|
||||||
|
|
||||||
|
namespace Catch
|
||||||
|
{
|
||||||
|
class WildcardPattern {
|
||||||
|
enum WildcardPosition {
|
||||||
|
NoWildcard = 0,
|
||||||
|
WildcardAtStart = 1,
|
||||||
|
WildcardAtEnd = 2,
|
||||||
|
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
|
||||||
|
: m_caseSensitivity( caseSensitivity ),
|
||||||
|
m_wildcard( NoWildcard ),
|
||||||
|
m_pattern( adjustCase( pattern ) )
|
||||||
|
{
|
||||||
|
if( startsWith( m_pattern, "*" ) ) {
|
||||||
|
m_pattern = m_pattern.substr( 1 );
|
||||||
|
m_wildcard = WildcardAtStart;
|
||||||
|
}
|
||||||
|
if( endsWith( m_pattern, "*" ) ) {
|
||||||
|
m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
|
||||||
|
m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual ~WildcardPattern();
|
||||||
|
virtual bool matches( std::string const& str ) const {
|
||||||
|
switch( m_wildcard ) {
|
||||||
|
case NoWildcard:
|
||||||
|
return m_pattern == adjustCase( str );
|
||||||
|
case WildcardAtStart:
|
||||||
|
return endsWith( adjustCase( str ), m_pattern );
|
||||||
|
case WildcardAtEnd:
|
||||||
|
return startsWith( adjustCase( str ), m_pattern );
|
||||||
|
case WildcardAtBothEnds:
|
||||||
|
return contains( adjustCase( str ), m_pattern );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
|
#endif
|
||||||
|
throw std::logic_error( "Unknown enum" );
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::string adjustCase( std::string const& str ) const {
|
||||||
|
return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;
|
||||||
|
}
|
||||||
|
CaseSensitive::Choice m_caseSensitivity;
|
||||||
|
WildcardPosition m_wildcard;
|
||||||
|
std::string m_pattern;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
|
@@ -10,13 +10,70 @@
|
|||||||
|
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
#include "catch_suppress_warnings.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
class XmlEncode {
|
||||||
|
public:
|
||||||
|
enum ForWhat { ForTextNodes, ForAttributes };
|
||||||
|
|
||||||
|
XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
|
||||||
|
: m_str( str ),
|
||||||
|
m_forWhat( forWhat )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void encodeTo( std::ostream& os ) const {
|
||||||
|
|
||||||
|
// Apostrophe escaping not necessary if we always use " to write attributes
|
||||||
|
// (see: http://www.w3.org/TR/xml/#syntax)
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < m_str.size(); ++ i ) {
|
||||||
|
char c = m_str[i];
|
||||||
|
switch( c ) {
|
||||||
|
case '<': os << "<"; break;
|
||||||
|
case '&': os << "&"; break;
|
||||||
|
|
||||||
|
case '>':
|
||||||
|
// See: http://www.w3.org/TR/xml/#syntax
|
||||||
|
if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
|
||||||
|
os << ">";
|
||||||
|
else
|
||||||
|
os << c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\"':
|
||||||
|
if( m_forWhat == ForAttributes )
|
||||||
|
os << """;
|
||||||
|
else
|
||||||
|
os << c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Escape control chars - based on contribution by @espenalb in PR #465
|
||||||
|
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
||||||
|
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
|
||||||
|
else
|
||||||
|
os << c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
|
||||||
|
xmlEncode.encodeTo( os );
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_str;
|
||||||
|
ForWhat m_forWhat;
|
||||||
|
};
|
||||||
|
|
||||||
class XmlWriter {
|
class XmlWriter {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -99,11 +156,8 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
|
||||||
if( !name.empty() && !attribute.empty() ) {
|
if( !name.empty() && !attribute.empty() )
|
||||||
stream() << " " << name << "=\"";
|
stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
|
||||||
writeEncodedText( attribute );
|
|
||||||
stream() << "\"";
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +168,9 @@ namespace Catch {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
|
||||||
if( !name.empty() )
|
std::ostringstream oss;
|
||||||
stream() << " " << name << "=\"" << attribute << "\"";
|
oss << attribute;
|
||||||
return *this;
|
return writeAttribute( name, oss.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeText( std::string const& text, bool indent = true ) {
|
XmlWriter& writeText( std::string const& text, bool indent = true ) {
|
||||||
@@ -125,7 +179,7 @@ namespace Catch {
|
|||||||
ensureTagClosed();
|
ensureTagClosed();
|
||||||
if( tagWasOpen && indent )
|
if( tagWasOpen && indent )
|
||||||
stream() << m_indent;
|
stream() << m_indent;
|
||||||
writeEncodedText( text );
|
stream() << XmlEncode( text );
|
||||||
m_needsNewline = true;
|
m_needsNewline = true;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -170,30 +224,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEncodedText( std::string const& text ) {
|
|
||||||
static const char* charsToEncode = "<&\"";
|
|
||||||
std::string mtext = text;
|
|
||||||
std::string::size_type pos = mtext.find_first_of( charsToEncode );
|
|
||||||
while( pos != std::string::npos ) {
|
|
||||||
stream() << mtext.substr( 0, pos );
|
|
||||||
|
|
||||||
switch( mtext[pos] ) {
|
|
||||||
case '<':
|
|
||||||
stream() << "<";
|
|
||||||
break;
|
|
||||||
case '&':
|
|
||||||
stream() << "&";
|
|
||||||
break;
|
|
||||||
case '\"':
|
|
||||||
stream() << """;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mtext = mtext.substr( pos+1 );
|
|
||||||
pos = mtext.find_first_of( charsToEncode );
|
|
||||||
}
|
|
||||||
stream() << mtext;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool m_tagIsOpen;
|
bool m_tagIsOpen;
|
||||||
bool m_needsNewline;
|
bool m_needsNewline;
|
||||||
std::vector<std::string> m_tags;
|
std::vector<std::string> m_tags;
|
||||||
@@ -202,4 +232,6 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#include "catch_reenable_warnings.h"
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
|
||||||
|
@@ -397,6 +397,17 @@ ExceptionTests.cpp:<line number>: FAILED:
|
|||||||
due to unexpected exception with message:
|
due to unexpected exception with message:
|
||||||
3.14
|
3.14
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Mismatching exception messages failing the test
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
|
||||||
|
with expansion:
|
||||||
|
expected exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
INFO and WARN do not abort tests
|
INFO and WARN do not abort tests
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -786,6 +797,6 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 155 | 116 passed | 38 failed | 1 failed as expected
|
test cases: 159 | 119 passed | 39 failed | 1 failed as expected
|
||||||
assertions: 765 | 673 passed | 79 failed | 13 failed as expected
|
assertions: 784 | 691 passed | 80 failed | 13 failed as expected
|
||||||
|
|
||||||
|
@@ -1277,6 +1277,66 @@ ExceptionTests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) )
|
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Exception messages can be tested for
|
||||||
|
exact match
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Exception messages can be tested for
|
||||||
|
different case
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Exception messages can be tested for
|
||||||
|
wildcarded
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) )
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) )
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) )
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Mismatching exception messages failing the test
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
|
||||||
|
with expansion:
|
||||||
|
expected exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Generators over two ranges
|
Generators over two ranges
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -3702,6 +3762,142 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
""wide load"" == ""wide load""
|
""wide load"" == ""wide load""
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
normal string
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "normal string" ) == "normal string" )
|
||||||
|
with expansion:
|
||||||
|
"normal string" == "normal string"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
empty string
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "" ) == "" )
|
||||||
|
with expansion:
|
||||||
|
"" == ""
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with ampersand
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "smith & jones" ) == "smith & jones" )
|
||||||
|
with expansion:
|
||||||
|
"smith & jones" == "smith & jones"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with less-than
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "smith < jones" ) == "smith < jones" )
|
||||||
|
with expansion:
|
||||||
|
"smith < jones" == "smith < jones"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with greater-than
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "smith > jones" ) == "smith > jones" )
|
||||||
|
with expansion:
|
||||||
|
"smith > jones" == "smith > jones"
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" )
|
||||||
|
with expansion:
|
||||||
|
"smith ]]> jones"
|
||||||
|
==
|
||||||
|
"smith ]]> jones"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with quotes
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes )
|
||||||
|
with expansion:
|
||||||
|
"don't "quote" me on that"
|
||||||
|
==
|
||||||
|
"don't "quote" me on that"
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" )
|
||||||
|
with expansion:
|
||||||
|
"don't "quote" me on that"
|
||||||
|
==
|
||||||
|
"don't "quote" me on that"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with control char (1)
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "[\x01]" ) == "[]" )
|
||||||
|
with expansion:
|
||||||
|
"[]" == "[]"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlEncode
|
||||||
|
string with control char (x7F)
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( encode( "[\x7F]" ) == "[]" )
|
||||||
|
with expansion:
|
||||||
|
"[]" == "[]"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
long long
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( l == std::numeric_limits<long long>::max() )
|
||||||
|
with expansion:
|
||||||
|
9223372036854775807 (0x<hex digits>)
|
||||||
|
==
|
||||||
|
9223372036854775807 (0x<hex digits>)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Process can be configured on command line
|
Process can be configured on command line
|
||||||
default - no arguments
|
default - no arguments
|
||||||
@@ -7944,6 +8140,6 @@ with expansion:
|
|||||||
true
|
true
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 155 | 100 passed | 54 failed | 1 failed as expected
|
test cases: 159 | 103 passed | 55 failed | 1 failed as expected
|
||||||
assertions: 785 | 673 passed | 99 failed | 13 failed as expected
|
assertions: 804 | 691 passed | 100 failed | 13 failed as expected
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="all tests" errors="12" failures="87" tests="785" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="CatchSelfTest" errors="12" failures="88" tests="804" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||||
@@ -251,6 +251,14 @@ ExceptionTests.cpp:<line number>
|
|||||||
</error>
|
</error>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
|
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
|
||||||
|
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
|
||||||
|
<testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
|
||||||
|
<testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
|
||||||
|
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
<testcase classname="global" name="Generators over two ranges" time="{duration}"/>
|
<testcase classname="global" name="Generators over two ranges" time="{duration}"/>
|
||||||
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
|
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
|
||||||
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
||||||
@@ -455,6 +463,15 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
|
<testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
|
<testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/>
|
<testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="normal string" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="empty string" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with ampersand" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with less-than" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with greater-than" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with quotes" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/>
|
||||||
|
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="long long" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -152,3 +152,23 @@ TEST_CASE( "NotImplemented exception", "" )
|
|||||||
{
|
{
|
||||||
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
|
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Exception messages can be tested for", "" ) {
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
SECTION( "exact match" )
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||||
|
SECTION( "different case" )
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) );
|
||||||
|
SECTION( "wildcarded" ) {
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) );
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) );
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) );
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Mismatching exception messages failing the test", "[.][failing]" ) {
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||||
|
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||||
|
}
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
#include "internal/catch_xmlwriter.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -381,6 +382,50 @@ TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
|||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << Catch::XmlEncode( str, forWhat );
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "XmlEncode" ) {
|
||||||
|
SECTION( "normal string" ) {
|
||||||
|
REQUIRE( encode( "normal string" ) == "normal string" );
|
||||||
|
}
|
||||||
|
SECTION( "empty string" ) {
|
||||||
|
REQUIRE( encode( "" ) == "" );
|
||||||
|
}
|
||||||
|
SECTION( "string with ampersand" ) {
|
||||||
|
REQUIRE( encode( "smith & jones" ) == "smith & jones" );
|
||||||
|
}
|
||||||
|
SECTION( "string with less-than" ) {
|
||||||
|
REQUIRE( encode( "smith < jones" ) == "smith < jones" );
|
||||||
|
}
|
||||||
|
SECTION( "string with greater-than" ) {
|
||||||
|
REQUIRE( encode( "smith > jones" ) == "smith > jones" );
|
||||||
|
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" );
|
||||||
|
}
|
||||||
|
SECTION( "string with quotes" ) {
|
||||||
|
std::string stringWithQuotes = "don't \"quote\" me on that";
|
||||||
|
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes );
|
||||||
|
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
|
||||||
|
}
|
||||||
|
SECTION( "string with control char (1)" ) {
|
||||||
|
REQUIRE( encode( "[\x01]" ) == "[]" );
|
||||||
|
}
|
||||||
|
SECTION( "string with control char (x7F)" ) {
|
||||||
|
REQUIRE( encode( "[\x7F]" ) == "[]" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
|
TEST_CASE( "long long" ) {
|
||||||
|
long long l = std::numeric_limits<long long>::max();
|
||||||
|
|
||||||
|
REQUIRE( l == std::numeric_limits<long long>::max() );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
|
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
|
||||||
// int i = 0;
|
// int i = 0;
|
||||||
// int x = 10/i; // This should cause the signal to fire
|
// int x = 10/i; // This should cause the signal to fire
|
||||||
|
@@ -108,6 +108,7 @@
|
|||||||
269831E719121CA500BB0CE0 /* catch_reporter_compact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_compact.hpp; sourceTree = "<group>"; };
|
269831E719121CA500BB0CE0 /* catch_reporter_compact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_compact.hpp; sourceTree = "<group>"; };
|
||||||
26AEAF1617BEA18E009E32C9 /* catch_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_platform.h; sourceTree = "<group>"; };
|
26AEAF1617BEA18E009E32C9 /* catch_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_platform.h; sourceTree = "<group>"; };
|
||||||
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
|
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
|
||||||
|
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_wildcard_pattern.hpp; sourceTree = "<group>"; };
|
||||||
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
|
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
|
||||||
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
|
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
|
||||||
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
|
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
|
||||||
@@ -470,6 +471,7 @@
|
|||||||
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,
|
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,
|
||||||
2656C227192A78410040DB02 /* catch_reenable_warnings.h */,
|
2656C227192A78410040DB02 /* catch_reenable_warnings.h */,
|
||||||
263F7A4519A66608009474C2 /* catch_fatal_condition.hpp */,
|
263F7A4519A66608009474C2 /* catch_fatal_condition.hpp */,
|
||||||
|
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */,
|
||||||
);
|
);
|
||||||
name = Infrastructure;
|
name = Infrastructure;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@@ -15,7 +15,8 @@ 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]*\.[0-9].?( .*)' )
|
versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)' )
|
||||||
|
devVersionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)' )
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
cmdPath = sys.argv[1]
|
cmdPath = sys.argv[1]
|
||||||
@@ -41,6 +42,10 @@ def filterLine( line ):
|
|||||||
if path.startswith( catchPath ):
|
if path.startswith( catchPath ):
|
||||||
path = path[1+len(catchPath):]
|
path = path[1+len(catchPath):]
|
||||||
line = m.group(1) + path + m.group(3)
|
line = m.group(1) + path + m.group(3)
|
||||||
|
m = devVersionParser.match( line )
|
||||||
|
if m:
|
||||||
|
line = m.group(1) + "<version>" + m.group(2)
|
||||||
|
else:
|
||||||
m = versionParser.match( line )
|
m = versionParser.match( line )
|
||||||
if m:
|
if m:
|
||||||
line = m.group(1) + "<version>" + m.group(2)
|
line = m.group(1) + "<version>" + m.group(2)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user