mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 02:25:38 +02:00
Compare commits
37 Commits
v1.2.1-dev
...
v2.0.0-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f4ba8aaf19 | ||
![]() |
25899ea20e | ||
![]() |
36cee598cf | ||
![]() |
506b915f7f | ||
![]() |
5cab3cc1b8 | ||
![]() |
d2642325ae | ||
![]() |
8fa41d96c7 | ||
![]() |
693355cc75 | ||
![]() |
5e0db60443 | ||
![]() |
ce547c1799 | ||
![]() |
28aece6a7a | ||
![]() |
bd8688cded | ||
![]() |
c70170e904 | ||
![]() |
6789dfa2ba | ||
![]() |
fdc8a2b2df | ||
![]() |
eea9357284 | ||
![]() |
73968f29a5 | ||
![]() |
b77b45a390 | ||
![]() |
2ebe11660c | ||
![]() |
e55273db19 | ||
![]() |
e4fa62a14e | ||
![]() |
a49f088032 | ||
![]() |
ed6e9128a4 | ||
![]() |
92356769f1 | ||
![]() |
d10b73f9f1 | ||
![]() |
71fd2c2fdf | ||
![]() |
08844e7e57 | ||
![]() |
054e3c5b43 | ||
![]() |
f3e7722cc6 | ||
![]() |
315c83ad87 | ||
![]() |
9576ad9108 | ||
![]() |
e91738103c | ||
![]() |
8c32b49d5f | ||
![]() |
ece529ae7c | ||
![]() |
9e42153fe5 | ||
![]() |
c81778ecd0 | ||
![]() |
f5642be7b4 |
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
*v1.2.1-develop.15*
|
*v2.0.0-develop.2*
|
||||||
|
|
||||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@@ -55,6 +55,16 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Exceptions
|
||||||
|
|
||||||
|
By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( MyType& ex ) {
|
||||||
|
return ex.message();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Home](Readme.md)
|
[Home](Readme.md)
|
||||||
|
@@ -29,11 +29,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "internal/catch_notimplemented_exception.h"
|
#include "internal/catch_notimplemented_exception.h"
|
||||||
#include "internal/catch_context.h"
|
|
||||||
#include "internal/catch_test_registry.hpp"
|
#include "internal/catch_test_registry.hpp"
|
||||||
#include "internal/catch_capture.hpp"
|
#include "internal/catch_capture.hpp"
|
||||||
#include "internal/catch_section.h"
|
#include "internal/catch_section.h"
|
||||||
#include "internal/catch_generators.hpp"
|
|
||||||
#include "internal/catch_interfaces_exception.h"
|
#include "internal/catch_interfaces_exception.h"
|
||||||
#include "internal/catch_approx.hpp"
|
#include "internal/catch_approx.hpp"
|
||||||
#include "internal/catch_matchers.hpp"
|
#include "internal/catch_matchers.hpp"
|
||||||
@@ -43,7 +41,6 @@
|
|||||||
// These files are included here so the single_include script doesn't put them
|
// These files are included here so the single_include script doesn't put them
|
||||||
// in the conditionally compiled sections
|
// in the conditionally compiled sections
|
||||||
#include "internal/catch_test_case_info.h"
|
#include "internal/catch_test_case_info.h"
|
||||||
#include "internal/catch_interfaces_runner.h"
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#include "internal/catch_objc.hpp"
|
#include "internal/catch_objc.hpp"
|
||||||
@@ -99,6 +96,7 @@
|
|||||||
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
#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_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_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_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||||
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __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__ )
|
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
|
||||||
@@ -106,6 +104,7 @@
|
|||||||
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#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_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_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_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_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 )
|
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
|
||||||
@@ -115,8 +114,6 @@
|
|||||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
||||||
|
|
||||||
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
|
||||||
|
|
||||||
// "BDD-style" convenience wrappers
|
// "BDD-style" convenience wrappers
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
|
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
|
||||||
@@ -166,6 +163,7 @@
|
|||||||
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||||
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __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 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 SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __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__ )
|
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
|
||||||
@@ -173,6 +171,7 @@
|
|||||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#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 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 METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
#define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
|
||||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
|
#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 )
|
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
|
||||||
@@ -182,8 +181,6 @@
|
|||||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
||||||
|
|
||||||
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
||||||
|
@@ -30,7 +30,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
||||||
std::vector<std::string> reporters = config->getReporterNames();
|
std::vector<std::string> reporters = config->getReporterNames();
|
||||||
if( reporters.empty() )
|
if( reporters.empty() )
|
||||||
@@ -40,7 +40,7 @@ namespace Catch {
|
|||||||
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it )
|
++it )
|
||||||
reporter = addReporter( reporter, createReporter( *it, config ) );
|
reporter = addReporter( reporter, createReporter( *it, config ) );
|
||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
|
Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
|
||||||
@@ -51,15 +51,15 @@ namespace Catch {
|
|||||||
reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
|
reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
|
||||||
return reporters;
|
return reporters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Totals runTests( Ptr<Config> const& config ) {
|
Totals runTests( Ptr<Config> const& config ) {
|
||||||
|
|
||||||
Ptr<IConfig const> iconfig = config.get();
|
Ptr<IConfig const> iconfig = config.get();
|
||||||
|
|
||||||
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
||||||
reporter = addListeners( iconfig, reporter );
|
reporter = addListeners( iconfig, reporter );
|
||||||
|
|
||||||
RunContext context( iconfig, reporter );
|
RunContext context( iconfig, reporter );
|
||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
@@ -74,7 +74,7 @@ namespace Catch {
|
|||||||
for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
|
for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) )
|
if( !context.isAborting() && matchTest( *it, testSpec, *iconfig ) )
|
||||||
totals += context.runTest( *it );
|
totals += context.runTest( *it );
|
||||||
else
|
else
|
||||||
reporter->skipTest( *it );
|
reporter->skipTest( *it );
|
||||||
@@ -83,13 +83,13 @@ namespace Catch {
|
|||||||
context.testGroupEnded( iconfig->name(), totals, 1, 1 );
|
context.testGroupEnded( iconfig->name(), totals, 1, 1 );
|
||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyFilenamesAsTags( IConfig const& config ) {
|
void applyFilenamesAsTags( IConfig const& config ) {
|
||||||
std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
|
std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
|
||||||
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
||||||
TestCase& test = const_cast<TestCase&>( tests[i] );
|
TestCase& test = const_cast<TestCase&>( tests[i] );
|
||||||
std::set<std::string> tags = test.tags;
|
std::set<std::string> tags = test.tags;
|
||||||
|
|
||||||
std::string filename = test.lineInfo.file;
|
std::string filename = test.lineInfo.file;
|
||||||
std::string::size_type lastSlash = filename.find_last_of( "\\/" );
|
std::string::size_type lastSlash = filename.find_last_of( "\\/" );
|
||||||
if( lastSlash != std::string::npos )
|
if( lastSlash != std::string::npos )
|
||||||
@@ -98,7 +98,7 @@ namespace Catch {
|
|||||||
std::string::size_type lastDot = filename.find_last_of( "." );
|
std::string::size_type lastDot = filename.find_last_of( "." );
|
||||||
if( lastDot != std::string::npos )
|
if( lastDot != std::string::npos )
|
||||||
filename = filename.substr( 0, lastDot );
|
filename = filename.substr( 0, lastDot );
|
||||||
|
|
||||||
tags.insert( "#" + filename );
|
tags.insert( "#" + filename );
|
||||||
setTags( test, tags );
|
setTags( test, tags );
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ namespace Catch {
|
|||||||
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
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 {
|
try {
|
||||||
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
|
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
|
||||||
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
||||||
@@ -158,7 +158,7 @@ namespace Catch {
|
|||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int run( int argc, char* const argv[] ) {
|
int run( int argc, char const* const argv[] ) {
|
||||||
|
|
||||||
int returnCode = applyCommandLine( argc, argv );
|
int returnCode = applyCommandLine( argc, argv );
|
||||||
if( returnCode == 0 )
|
if( returnCode == 0 )
|
||||||
@@ -173,12 +173,12 @@ namespace Catch {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
config(); // Force config to be constructed
|
config(); // Force config to be constructed
|
||||||
|
|
||||||
seedRng( *m_config );
|
seedRng( *m_config );
|
||||||
|
|
||||||
if( m_configData.filenamesAsTags )
|
if( m_configData.filenamesAsTags )
|
||||||
applyFilenamesAsTags( *m_config );
|
applyFilenamesAsTags( *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 );
|
||||||
|
@@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
#include "catch_result_builder.h"
|
#include "catch_result_builder.h"
|
||||||
#include "catch_message.h"
|
#include "catch_message.h"
|
||||||
#include "catch_interfaces_capture.h"
|
|
||||||
#include "catch_debugger.h"
|
#include "catch_debugger.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "catch_tostring.h"
|
#include "catch_tostring.h"
|
||||||
#include "catch_interfaces_runner.h"
|
|
||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
AssertionResult const* getLastResult();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// In the event of a failure works out if the debugger needs to be invoked
|
// In the event of a failure works out if the debugger needs to be invoked
|
||||||
@@ -44,12 +45,12 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
||||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||||
if( Catch::getResultCapture().getLastResult()->succeeded() )
|
if( Catch::getLastResult()->succeeded() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
|
||||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||||
if( !Catch::getResultCapture().getLastResult()->succeeded() )
|
if( !Catch::getLastResult()->succeeded() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
|
||||||
@@ -129,14 +130,14 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg " " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
std::string matcherAsString = ::Catch::Matchers::matcher.toString(); \
|
std::string matcherAsString = (matcher).toString(); \
|
||||||
__catchResult \
|
__catchResult \
|
||||||
.setLhs( Catch::toString( arg ) ) \
|
.setLhs( Catch::toString( arg ) ) \
|
||||||
.setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
|
.setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
|
||||||
.setOp( "matches" ) \
|
.setOp( "matches" ) \
|
||||||
.setResultType( ::Catch::Matchers::matcher.match( arg ) ); \
|
.setResultType( (matcher).match( arg ) ); \
|
||||||
__catchResult.captureExpression(); \
|
__catchResult.captureExpression(); \
|
||||||
} catch( ... ) { \
|
} catch( ... ) { \
|
||||||
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
||||||
|
@@ -163,7 +163,7 @@ namespace Catch {
|
|||||||
.describe( "list all/matching test cases names only" )
|
.describe( "list all/matching test cases names only" )
|
||||||
.bind( &ConfigData::listTestNamesOnly );
|
.bind( &ConfigData::listTestNamesOnly );
|
||||||
|
|
||||||
cli["--list-reporters"]
|
cli["--list-reporters"]
|
||||||
.describe( "list all reporters" )
|
.describe( "list all reporters" )
|
||||||
.bind( &ConfigData::listReporters );
|
.bind( &ConfigData::listReporters );
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ namespace Catch {
|
|||||||
cli["--force-colour"]
|
cli["--force-colour"]
|
||||||
.describe( "force colourised output" )
|
.describe( "force colourised output" )
|
||||||
.bind( &ConfigData::forceColour );
|
.bind( &ConfigData::forceColour );
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,11 @@
|
|||||||
|
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
#ifdef CATCH_CONFIG_COUNTER
|
||||||
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
|
||||||
|
#else
|
||||||
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
||||||
|
#endif
|
||||||
|
|
||||||
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
|
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
|
||||||
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
|
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
|
||||||
@@ -22,14 +26,14 @@
|
|||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct IConfig;
|
struct IConfig;
|
||||||
|
|
||||||
struct CaseSensitive { enum Choice {
|
struct CaseSensitive { enum Choice {
|
||||||
Yes,
|
Yes,
|
||||||
No
|
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;
|
||||||
@@ -118,7 +122,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void seedRng( IConfig const& config );
|
void seedRng( IConfig const& config );
|
||||||
unsigned int rngSeed();
|
unsigned int rngSeed();
|
||||||
|
|
||||||
// Use this in variadic streaming macros to allow
|
// Use this in variadic streaming macros to allow
|
||||||
// >> +StreamEndStop
|
// >> +StreamEndStop
|
||||||
// as well as
|
// as well as
|
||||||
|
@@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
|
|
||||||
return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
|
return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
|
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
|
||||||
bool replaced = false;
|
bool replaced = false;
|
||||||
std::size_t i = str.find( replaceThis );
|
std::size_t i = str.find( replaceThis );
|
||||||
@@ -50,7 +50,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
return replaced;
|
return replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
pluralise::pluralise( std::size_t count, std::string const& label )
|
pluralise::pluralise( std::size_t count, std::string const& label )
|
||||||
: m_count( count ),
|
: m_count( count ),
|
||||||
m_label( label )
|
m_label( label )
|
||||||
@@ -87,7 +87,9 @@ namespace Catch {
|
|||||||
std::srand( config.rngSeed() );
|
std::srand( config.rngSeed() );
|
||||||
}
|
}
|
||||||
unsigned int rngSeed() {
|
unsigned int rngSeed() {
|
||||||
return getCurrentContext().getConfig()->rngSeed();
|
return getCurrentConfig()
|
||||||
|
? getCurrentConfig()->rngSeed()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
||||||
|
|
||||||
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
|
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
|
||||||
|
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
|
||||||
// ****************
|
// ****************
|
||||||
// Note to maintainers: if new toggles are added please document them
|
// Note to maintainers: if new toggles are added please document them
|
||||||
// in configuration.md, too
|
// in configuration.md, too
|
||||||
@@ -111,6 +111,15 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Use __COUNTER__ if the compiler supports it
|
||||||
|
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
|
||||||
|
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
|
||||||
|
( defined __clang__ && __clang_major__ >= 3 )
|
||||||
|
|
||||||
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// C++ language feature support
|
// C++ language feature support
|
||||||
|
|
||||||
@@ -185,6 +194,9 @@
|
|||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||||
|
# define CATCH_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// noexcept support:
|
// noexcept support:
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_test_spec_parser.hpp"
|
#include "catch_test_spec_parser.hpp"
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_interfaces_config.h"
|
#include "catch_interfaces_config.h"
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ namespace Catch {
|
|||||||
virtual bool forceColour() const { return m_data.forceColour; }
|
virtual bool forceColour() const { return m_data.forceColour; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
IStream const* openStream() {
|
IStream const* openStream() {
|
||||||
if( m_data.outputFilename.empty() )
|
if( m_data.outputFilename.empty() )
|
||||||
return new CoutStream();
|
return new CoutStream();
|
||||||
|
@@ -145,7 +145,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
IColourImpl* platformColourInstance() {
|
IColourImpl* platformColourInstance() {
|
||||||
Ptr<IConfig const> config = getCurrentContext().getConfig();
|
IConfig const* config = getCurrentConfig();
|
||||||
return (config && config->forceColour()) || isatty(STDOUT_FILENO)
|
return (config && config->forceColour()) || isatty(STDOUT_FILENO)
|
||||||
? PosixColourImpl::instance()
|
? PosixColourImpl::instance()
|
||||||
: NoColourImpl::instance();
|
: NoColourImpl::instance();
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 31/12/2010.
|
|
||||||
* Copyright 2010 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_CONTEXT_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_interfaces_generators.h"
|
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class TestCase;
|
|
||||||
class Stream;
|
|
||||||
struct IResultCapture;
|
|
||||||
struct IRunner;
|
|
||||||
struct IGeneratorsForTest;
|
|
||||||
struct IConfig;
|
|
||||||
|
|
||||||
struct IContext
|
|
||||||
{
|
|
||||||
virtual ~IContext();
|
|
||||||
|
|
||||||
virtual IResultCapture* getResultCapture() = 0;
|
|
||||||
virtual IRunner* getRunner() = 0;
|
|
||||||
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
|
|
||||||
virtual bool advanceGeneratorsForCurrentTest() = 0;
|
|
||||||
virtual Ptr<IConfig const> getConfig() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IMutableContext : IContext
|
|
||||||
{
|
|
||||||
virtual ~IMutableContext();
|
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
|
||||||
virtual void setRunner( IRunner* runner ) = 0;
|
|
||||||
virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
IContext& getCurrentContext();
|
|
||||||
IMutableContext& getCurrentMutableContext();
|
|
||||||
void cleanUpContext();
|
|
||||||
Stream createStream( std::string const& streamName );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
|
@@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 31/12/2010.
|
|
||||||
* Copyright 2010 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_CONTEXT_IMPL_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_run_context.hpp"
|
|
||||||
|
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_stream.hpp"
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class Context : public IMutableContext {
|
|
||||||
|
|
||||||
Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
|
|
||||||
Context( Context const& );
|
|
||||||
void operator=( Context const& );
|
|
||||||
|
|
||||||
public: // IContext
|
|
||||||
virtual IResultCapture* getResultCapture() {
|
|
||||||
return m_resultCapture;
|
|
||||||
}
|
|
||||||
virtual IRunner* getRunner() {
|
|
||||||
return m_runner;
|
|
||||||
}
|
|
||||||
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
|
|
||||||
return getGeneratorsForCurrentTest()
|
|
||||||
.getGeneratorInfo( fileInfo, totalSize )
|
|
||||||
.getCurrentIndex();
|
|
||||||
}
|
|
||||||
virtual bool advanceGeneratorsForCurrentTest() {
|
|
||||||
IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
|
|
||||||
return generators && generators->moveNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Ptr<IConfig const> getConfig() const {
|
|
||||||
return m_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public: // IMutableContext
|
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) {
|
|
||||||
m_resultCapture = resultCapture;
|
|
||||||
}
|
|
||||||
virtual void setRunner( IRunner* runner ) {
|
|
||||||
m_runner = runner;
|
|
||||||
}
|
|
||||||
virtual void setConfig( Ptr<IConfig const> const& config ) {
|
|
||||||
m_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend IMutableContext& getCurrentMutableContext();
|
|
||||||
|
|
||||||
private:
|
|
||||||
IGeneratorsForTest* findGeneratorsForCurrentTest() {
|
|
||||||
std::string testName = getResultCapture()->getCurrentTestName();
|
|
||||||
|
|
||||||
std::map<std::string, IGeneratorsForTest*>::const_iterator it =
|
|
||||||
m_generatorsByTestName.find( testName );
|
|
||||||
return it != m_generatorsByTestName.end()
|
|
||||||
? it->second
|
|
||||||
: CATCH_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
|
||||||
IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
|
|
||||||
if( !generators ) {
|
|
||||||
std::string testName = getResultCapture()->getCurrentTestName();
|
|
||||||
generators = createGeneratorsForTest();
|
|
||||||
m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
|
|
||||||
}
|
|
||||||
return *generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ptr<IConfig const> m_config;
|
|
||||||
IRunner* m_runner;
|
|
||||||
IResultCapture* m_resultCapture;
|
|
||||||
std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
Context* currentContext = CATCH_NULL;
|
|
||||||
}
|
|
||||||
IMutableContext& getCurrentMutableContext() {
|
|
||||||
if( !currentContext )
|
|
||||||
currentContext = new Context();
|
|
||||||
return *currentContext;
|
|
||||||
}
|
|
||||||
IContext& getCurrentContext() {
|
|
||||||
return getCurrentMutableContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanUpContext() {
|
|
||||||
delete currentContext;
|
|
||||||
currentContext = CATCH_NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
@@ -11,7 +11,7 @@
|
|||||||
#ifndef __OBJC__
|
#ifndef __OBJC__
|
||||||
|
|
||||||
// Standard C/C++ main entry point
|
// Standard C/C++ main entry point
|
||||||
int main (int argc, char * const argv[]) {
|
int main (int argc, char * argv[]) {
|
||||||
return Catch::Session().run( argc, argv );
|
return Catch::Session().run( argc, argv );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -174,7 +174,7 @@ namespace Internal {
|
|||||||
template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
|
template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
|
||||||
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsigned long long to X
|
// unsigned long long to X
|
||||||
template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
|
template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
|
||||||
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
@@ -188,7 +188,7 @@ namespace Internal {
|
|||||||
template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
|
template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
|
||||||
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to long long (when comparing against NULL)
|
// pointer to long long (when comparing against NULL)
|
||||||
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
|
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
|
||||||
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
|
||||||
@@ -197,7 +197,7 @@ namespace Internal {
|
|||||||
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
|
||||||
}
|
}
|
||||||
#endif // CATCH_CONFIG_CPP11_LONG_LONG
|
#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 ) {
|
||||||
|
@@ -32,13 +32,13 @@ namespace Catch {
|
|||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
// In Objective-C try objective-c exceptions first
|
// In Objective-C try objective-c exceptions first
|
||||||
@try {
|
@try {
|
||||||
throw;
|
return tryTranslators();
|
||||||
}
|
}
|
||||||
@catch (NSException *exception) {
|
@catch (NSException *exception) {
|
||||||
return Catch::toString( [exception description] );
|
return Catch::toString( [exception description] );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
throw;
|
return tryTranslators();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch( TestFailureException& ) {
|
catch( TestFailureException& ) {
|
||||||
@@ -54,20 +54,15 @@ namespace Catch {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
return tryTranslators( m_translators.begin() );
|
return "Unknown exception";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tryTranslators( std::vector<const IExceptionTranslator*>::const_iterator it ) const {
|
std::string tryTranslators() const {
|
||||||
if( it == m_translators.end() )
|
if( m_translators.empty() )
|
||||||
return "Unknown exception";
|
throw;
|
||||||
|
else
|
||||||
try {
|
return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );
|
||||||
return (*it)->translate();
|
|
||||||
}
|
|
||||||
catch(...) {
|
|
||||||
return tryTranslators( it+1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -14,9 +14,8 @@ namespace Catch {
|
|||||||
|
|
||||||
// Report the error condition then exit the process
|
// Report the error condition then exit the process
|
||||||
inline void fatal( std::string const& message, int exitCode ) {
|
inline void fatal( std::string const& message, int exitCode ) {
|
||||||
IContext& context = Catch::getCurrentContext();
|
IRunContext& runContext = getCurrentRunContext();
|
||||||
IResultCapture* resultCapture = context.getResultCapture();
|
runContext.handleFatalErrorCondition( message );
|
||||||
resultCapture->handleFatalErrorCondition( message );
|
|
||||||
|
|
||||||
if( Catch::alwaysTrue() ) // avoids "no return" warnings
|
if( Catch::alwaysTrue() ) // avoids "no return" warnings
|
||||||
exit( exitCode );
|
exit( exitCode );
|
||||||
|
@@ -1,190 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 27/01/2011.
|
|
||||||
* Copyright 2011 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_GENERATORS_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_context.h"
|
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct IGenerator {
|
|
||||||
virtual ~IGenerator() {}
|
|
||||||
virtual T getValue( std::size_t index ) const = 0;
|
|
||||||
virtual std::size_t size () const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class BetweenGenerator : public IGenerator<T> {
|
|
||||||
public:
|
|
||||||
BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
|
|
||||||
|
|
||||||
virtual T getValue( std::size_t index ) const {
|
|
||||||
return m_from+static_cast<int>( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::size_t size() const {
|
|
||||||
return static_cast<std::size_t>( 1+m_to-m_from );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
T m_from;
|
|
||||||
T m_to;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class ValuesGenerator : public IGenerator<T> {
|
|
||||||
public:
|
|
||||||
ValuesGenerator(){}
|
|
||||||
|
|
||||||
void add( T value ) {
|
|
||||||
m_values.push_back( value );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual T getValue( std::size_t index ) const {
|
|
||||||
return m_values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::size_t size() const {
|
|
||||||
return m_values.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<T> m_values;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class CompositeGenerator {
|
|
||||||
public:
|
|
||||||
CompositeGenerator() : m_totalSize( 0 ) {}
|
|
||||||
|
|
||||||
// *** Move semantics, similar to auto_ptr ***
|
|
||||||
CompositeGenerator( CompositeGenerator& other )
|
|
||||||
: m_fileInfo( other.m_fileInfo ),
|
|
||||||
m_totalSize( 0 )
|
|
||||||
{
|
|
||||||
move( other );
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& setFileInfo( const char* fileInfo ) {
|
|
||||||
m_fileInfo = fileInfo;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
~CompositeGenerator() {
|
|
||||||
deleteAll( m_composed );
|
|
||||||
}
|
|
||||||
|
|
||||||
operator T () const {
|
|
||||||
size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
|
|
||||||
|
|
||||||
typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
|
|
||||||
typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
|
|
||||||
for( size_t index = 0; it != itEnd; ++it )
|
|
||||||
{
|
|
||||||
const IGenerator<T>* generator = *it;
|
|
||||||
if( overallIndex >= index && overallIndex < index + generator->size() )
|
|
||||||
{
|
|
||||||
return generator->getValue( overallIndex-index );
|
|
||||||
}
|
|
||||||
index += generator->size();
|
|
||||||
}
|
|
||||||
CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
|
|
||||||
return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
|
|
||||||
}
|
|
||||||
|
|
||||||
void add( const IGenerator<T>* generator ) {
|
|
||||||
m_totalSize += generator->size();
|
|
||||||
m_composed.push_back( generator );
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& then( CompositeGenerator& other ) {
|
|
||||||
move( other );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& then( T value ) {
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( value );
|
|
||||||
add( valuesGen );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void move( CompositeGenerator& other ) {
|
|
||||||
std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
|
|
||||||
m_totalSize += other.m_totalSize;
|
|
||||||
other.m_composed.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<const IGenerator<T>*> m_composed;
|
|
||||||
std::string m_fileInfo;
|
|
||||||
size_t m_totalSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Generators
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> between( T from, T to ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
generators.add( new BetweenGenerator<T>( from, to ) );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2 ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2, T val3 ){
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
valuesGen->add( val3 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
valuesGen->add( val3 );
|
|
||||||
valuesGen->add( val4 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Generators
|
|
||||||
|
|
||||||
using namespace Generators;
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#define INTERNAL_CATCH_LINESTR2( line ) #line
|
|
||||||
#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line )
|
|
||||||
|
|
||||||
#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" )
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
|
|
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 28/01/2011.
|
|
||||||
* Copyright 2011 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_GENERATORS_IMPL_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_interfaces_generators.h"
|
|
||||||
|
|
||||||
#include "catch_common.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
struct GeneratorInfo : IGeneratorInfo {
|
|
||||||
|
|
||||||
GeneratorInfo( std::size_t size )
|
|
||||||
: m_size( size ),
|
|
||||||
m_currentIndex( 0 )
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool moveNext() {
|
|
||||||
if( ++m_currentIndex == m_size ) {
|
|
||||||
m_currentIndex = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t getCurrentIndex() const {
|
|
||||||
return m_currentIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t m_size;
|
|
||||||
std::size_t m_currentIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class GeneratorsForTest : public IGeneratorsForTest {
|
|
||||||
|
|
||||||
public:
|
|
||||||
~GeneratorsForTest() {
|
|
||||||
deleteAll( m_generatorsInOrder );
|
|
||||||
}
|
|
||||||
|
|
||||||
IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) {
|
|
||||||
std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
|
|
||||||
if( it == m_generatorsByName.end() ) {
|
|
||||||
IGeneratorInfo* info = new GeneratorInfo( size );
|
|
||||||
m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
|
|
||||||
m_generatorsInOrder.push_back( info );
|
|
||||||
return *info;
|
|
||||||
}
|
|
||||||
return *it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool moveNext() {
|
|
||||||
std::vector<IGeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
|
|
||||||
std::vector<IGeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
|
|
||||||
for(; it != itEnd; ++it ) {
|
|
||||||
if( (*it)->moveNext() )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<std::string, IGeneratorInfo*> m_generatorsByName;
|
|
||||||
std::vector<IGeneratorInfo*> m_generatorsInOrder;
|
|
||||||
};
|
|
||||||
|
|
||||||
IGeneratorsForTest* createGeneratorsForTest()
|
|
||||||
{
|
|
||||||
return new GeneratorsForTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
|
|
@@ -19,9 +19,7 @@
|
|||||||
#include "../catch_session.hpp"
|
#include "../catch_session.hpp"
|
||||||
#include "catch_registry_hub.hpp"
|
#include "catch_registry_hub.hpp"
|
||||||
#include "catch_notimplemented_exception.hpp"
|
#include "catch_notimplemented_exception.hpp"
|
||||||
#include "catch_context_impl.hpp"
|
|
||||||
#include "catch_console_colour_impl.hpp"
|
#include "catch_console_colour_impl.hpp"
|
||||||
#include "catch_generators_impl.hpp"
|
|
||||||
#include "catch_assertionresult.hpp"
|
#include "catch_assertionresult.hpp"
|
||||||
#include "catch_test_case_info.hpp"
|
#include "catch_test_case_info.hpp"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
@@ -36,6 +34,7 @@
|
|||||||
#include "catch_result_builder.hpp"
|
#include "catch_result_builder.hpp"
|
||||||
#include "catch_tag_alias_registry.hpp"
|
#include "catch_tag_alias_registry.hpp"
|
||||||
#include "catch_test_case_tracker.hpp"
|
#include "catch_test_case_tracker.hpp"
|
||||||
|
#include "catch_stream.hpp"
|
||||||
|
|
||||||
#include "../reporters/catch_reporter_multi.hpp"
|
#include "../reporters/catch_reporter_multi.hpp"
|
||||||
#include "../reporters/catch_reporter_xml.hpp"
|
#include "../reporters/catch_reporter_xml.hpp"
|
||||||
@@ -49,9 +48,11 @@ namespace Catch {
|
|||||||
NonCopyable::~NonCopyable() {}
|
NonCopyable::~NonCopyable() {}
|
||||||
IShared::~IShared() {}
|
IShared::~IShared() {}
|
||||||
IStream::~IStream() CATCH_NOEXCEPT {}
|
IStream::~IStream() CATCH_NOEXCEPT {}
|
||||||
|
FileStream::~FileStream() CATCH_NOEXCEPT {}
|
||||||
|
CoutStream::~CoutStream() CATCH_NOEXCEPT {}
|
||||||
|
DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {}
|
||||||
StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
|
StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
|
||||||
IContext::~IContext() {}
|
IRunContext::~IRunContext() {}
|
||||||
IResultCapture::~IResultCapture() {}
|
|
||||||
ITestCase::~ITestCase() {}
|
ITestCase::~ITestCase() {}
|
||||||
ITestCaseRegistry::~ITestCaseRegistry() {}
|
ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||||
IRegistryHub::~IRegistryHub() {}
|
IRegistryHub::~IRegistryHub() {}
|
||||||
@@ -73,15 +74,11 @@ namespace Catch {
|
|||||||
StreamingReporterBase::~StreamingReporterBase() {}
|
StreamingReporterBase::~StreamingReporterBase() {}
|
||||||
ConsoleReporter::~ConsoleReporter() {}
|
ConsoleReporter::~ConsoleReporter() {}
|
||||||
CompactReporter::~CompactReporter() {}
|
CompactReporter::~CompactReporter() {}
|
||||||
IRunner::~IRunner() {}
|
|
||||||
IMutableContext::~IMutableContext() {}
|
|
||||||
IConfig::~IConfig() {}
|
IConfig::~IConfig() {}
|
||||||
XmlReporter::~XmlReporter() {}
|
XmlReporter::~XmlReporter() {}
|
||||||
JunitReporter::~JunitReporter() {}
|
JunitReporter::~JunitReporter() {}
|
||||||
TestRegistry::~TestRegistry() {}
|
TestRegistry::~TestRegistry() {}
|
||||||
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||||
IGeneratorInfo::~IGeneratorInfo() {}
|
|
||||||
IGeneratorsForTest::~IGeneratorsForTest() {}
|
|
||||||
WildcardPattern::~WildcardPattern() {}
|
WildcardPattern::~WildcardPattern() {}
|
||||||
TestSpec::Pattern::~Pattern() {}
|
TestSpec::Pattern::~Pattern() {}
|
||||||
TestSpec::NamePattern::~NamePattern() {}
|
TestSpec::NamePattern::~NamePattern() {}
|
||||||
@@ -94,7 +91,7 @@ namespace Catch {
|
|||||||
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||||
|
|
||||||
void Config::dummy() {}
|
void Config::dummy() {}
|
||||||
|
|
||||||
namespace TestCaseTracking {
|
namespace TestCaseTracking {
|
||||||
ITracker::~ITracker() {}
|
ITracker::~ITracker() {}
|
||||||
TrackerBase::~TrackerBase() {}
|
TrackerBase::~TrackerBase() {}
|
||||||
|
@@ -16,32 +16,42 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestCase;
|
class TestCase;
|
||||||
class AssertionResult;
|
class AssertionResult;
|
||||||
|
class ScopedMessageBuilder;
|
||||||
|
|
||||||
struct AssertionInfo;
|
struct AssertionInfo;
|
||||||
struct SectionInfo;
|
struct SectionInfo;
|
||||||
struct SectionEndInfo;
|
struct SectionEndInfo;
|
||||||
struct MessageInfo;
|
struct MessageInfo;
|
||||||
class ScopedMessageBuilder;
|
|
||||||
struct Counts;
|
struct Counts;
|
||||||
|
struct IConfig;
|
||||||
|
|
||||||
struct IResultCapture {
|
struct IRunContext {
|
||||||
|
|
||||||
virtual ~IResultCapture();
|
virtual ~IRunContext();
|
||||||
|
|
||||||
virtual void assertionEnded( AssertionResult const& result ) = 0;
|
virtual void assertionEnded( AssertionResult const& result ) = 0;
|
||||||
|
|
||||||
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
||||||
Counts& assertions ) = 0;
|
Counts& assertions ) = 0;
|
||||||
virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
|
virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
|
||||||
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
|
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
|
||||||
|
|
||||||
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
|
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
|
||||||
virtual void popScopedMessage( MessageInfo const& message ) = 0;
|
virtual void popScopedMessage( MessageInfo const& message ) = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const = 0;
|
|
||||||
virtual const AssertionResult* getLastResult() const = 0;
|
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||||
|
|
||||||
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
|
virtual AssertionResult const* getLastResult() const = 0;
|
||||||
|
virtual bool isAborting() const = 0;
|
||||||
|
|
||||||
|
virtual IConfig const& config() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture();
|
IRunContext* tryGetCurrentRunContext();
|
||||||
|
IRunContext& getCurrentRunContext();
|
||||||
|
|
||||||
|
IConfig const* getCurrentConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
||||||
|
@@ -9,15 +9,20 @@
|
|||||||
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
typedef std::string(*exceptionTranslateFunction)();
|
typedef std::string(*exceptionTranslateFunction)();
|
||||||
|
|
||||||
|
struct IExceptionTranslator;
|
||||||
|
typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
|
||||||
|
|
||||||
struct IExceptionTranslator {
|
struct IExceptionTranslator {
|
||||||
virtual ~IExceptionTranslator();
|
virtual ~IExceptionTranslator();
|
||||||
virtual std::string translate() const = 0;
|
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IExceptionTranslatorRegistry {
|
struct IExceptionTranslatorRegistry {
|
||||||
@@ -35,9 +40,12 @@ namespace Catch {
|
|||||||
: m_translateFunction( translateFunction )
|
: m_translateFunction( translateFunction )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual std::string translate() const {
|
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE {
|
||||||
try {
|
try {
|
||||||
throw;
|
if( it == itEnd )
|
||||||
|
throw;
|
||||||
|
else
|
||||||
|
return (*it)->translate( it+1, itEnd );
|
||||||
}
|
}
|
||||||
catch( T& ex ) {
|
catch( T& ex ) {
|
||||||
return m_translateFunction( ex );
|
return m_translateFunction( ex );
|
||||||
@@ -58,9 +66,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) \
|
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
|
||||||
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ); \
|
static std::string translatorName( signature ); \
|
||||||
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ) ); }\
|
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\
|
||||||
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature )
|
static std::string translatorName( signature )
|
||||||
|
|
||||||
|
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 7/8/2012.
|
|
||||||
* Copyright 2011 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_INTERFACES_GENERATORS_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
struct IGeneratorInfo {
|
|
||||||
virtual ~IGeneratorInfo();
|
|
||||||
virtual bool moveNext() = 0;
|
|
||||||
virtual std::size_t getCurrentIndex() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IGeneratorsForTest {
|
|
||||||
virtual ~IGeneratorsForTest();
|
|
||||||
|
|
||||||
virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
|
|
||||||
virtual bool moveNext() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
IGeneratorsForTest* createGeneratorsForTest();
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
|
|
@@ -240,12 +240,12 @@ namespace Catch
|
|||||||
|
|
||||||
// The return value indicates if the messages buffer should be cleared:
|
// The return value indicates if the messages buffer should be cleared:
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ namespace Catch
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 07/01/2011.
|
|
||||||
* Copyright 2011 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_INTERFACES_RUNNER_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
class TestCase;
|
|
||||||
|
|
||||||
struct IRunner {
|
|
||||||
virtual ~IRunner();
|
|
||||||
virtual bool aborting() const = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
|
@@ -34,7 +34,7 @@ namespace Catch {
|
|||||||
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
|
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
|
||||||
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
|
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
|
||||||
std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
|
std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
||||||
|
@@ -12,6 +12,12 @@ namespace Catch {
|
|||||||
namespace Matchers {
|
namespace Matchers {
|
||||||
namespace Impl {
|
namespace Impl {
|
||||||
|
|
||||||
|
namespace Generic {
|
||||||
|
template<typename ExpressionT> class AllOf;
|
||||||
|
template<typename ExpressionT> class AnyOf;
|
||||||
|
template<typename ExpressionT> class Not;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
struct Matcher : SharedImpl<IShared>
|
struct Matcher : SharedImpl<IShared>
|
||||||
{
|
{
|
||||||
@@ -21,6 +27,10 @@ namespace Matchers {
|
|||||||
virtual Ptr<Matcher> clone() const = 0;
|
virtual Ptr<Matcher> clone() const = 0;
|
||||||
virtual bool match( ExpressionT const& expr ) const = 0;
|
virtual bool match( ExpressionT const& expr ) const = 0;
|
||||||
virtual std::string toString() const = 0;
|
virtual std::string toString() const = 0;
|
||||||
|
|
||||||
|
Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
|
||||||
|
Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
|
||||||
|
Generic::Not<ExpressionT> operator ! () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename DerivedT, typename ExpressionT>
|
template<typename DerivedT, typename ExpressionT>
|
||||||
@@ -33,8 +43,9 @@ namespace Matchers {
|
|||||||
|
|
||||||
namespace Generic {
|
namespace Generic {
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
struct Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
|
class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
|
||||||
Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
|
public:
|
||||||
|
explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
|
||||||
Not( Not const& other ) : m_matcher( other.m_matcher ) {}
|
Not( Not const& other ) : m_matcher( other.m_matcher ) {}
|
||||||
|
|
||||||
virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
|
virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
|
||||||
@@ -44,7 +55,7 @@ namespace Matchers {
|
|||||||
virtual std::string toString() const CATCH_OVERRIDE {
|
virtual std::string toString() const CATCH_OVERRIDE {
|
||||||
return "not " + m_matcher->toString();
|
return "not " + m_matcher->toString();
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
Ptr< Matcher<ExpressionT> > m_matcher;
|
Ptr< Matcher<ExpressionT> > m_matcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,6 +89,12 @@ namespace Matchers {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllOf operator && ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
AllOf allOfExpr( *this );
|
||||||
|
allOfExpr.add( other );
|
||||||
|
return allOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
||||||
};
|
};
|
||||||
@@ -112,11 +129,40 @@ namespace Matchers {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
AnyOf anyOfExpr( *this );
|
||||||
|
anyOfExpr.add( other );
|
||||||
|
return anyOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Generic
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
Generic::AllOf<ExpressionT> allOfExpr;
|
||||||
|
allOfExpr.add( *this );
|
||||||
|
allOfExpr.add( other );
|
||||||
|
return allOfExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
Generic::AnyOf<ExpressionT> anyOfExpr;
|
||||||
|
anyOfExpr.add( *this );
|
||||||
|
anyOfExpr.add( other );
|
||||||
|
return anyOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
|
||||||
|
return Generic::Not<ExpressionT>( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace StdString {
|
namespace StdString {
|
||||||
|
|
||||||
inline std::string makeString( std::string const& str ) { return str; }
|
inline std::string makeString( std::string const& str ) { return str; }
|
||||||
@@ -132,7 +178,7 @@ namespace Matchers {
|
|||||||
return m_caseSensitivity == CaseSensitive::No
|
return m_caseSensitivity == CaseSensitive::No
|
||||||
? toLower( str )
|
? toLower( str )
|
||||||
: str;
|
: str;
|
||||||
|
|
||||||
}
|
}
|
||||||
std::string toStringSuffix() const
|
std::string toStringSuffix() const
|
||||||
{
|
{
|
||||||
@@ -143,7 +189,7 @@ namespace Matchers {
|
|||||||
CaseSensitive::Choice m_caseSensitivity;
|
CaseSensitive::Choice m_caseSensitivity;
|
||||||
std::string m_str;
|
std::string m_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Equals : MatcherImpl<Equals, std::string> {
|
struct Equals : MatcherImpl<Equals, std::string> {
|
||||||
Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
: m_data( str, caseSensitivity )
|
: m_data( str, caseSensitivity )
|
||||||
@@ -182,7 +228,7 @@ namespace Matchers {
|
|||||||
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
||||||
StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
|
||||||
: m_data( substr, caseSensitivity ){}
|
: m_data( substr, caseSensitivity ){}
|
||||||
|
|
||||||
StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
|
StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
|
||||||
|
|
||||||
virtual ~StartsWith();
|
virtual ~StartsWith();
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
|
|
||||||
struct MessageInfo {
|
struct MessageInfo {
|
||||||
MessageInfo( std::string const& _macroName,
|
MessageInfo( std::string const& _macroName,
|
||||||
@@ -58,6 +60,7 @@ namespace Catch {
|
|||||||
ScopedMessage( ScopedMessage const& other );
|
ScopedMessage( ScopedMessage const& other );
|
||||||
~ScopedMessage();
|
~ScopedMessage();
|
||||||
|
|
||||||
|
IRunContext& m_runContext;
|
||||||
MessageInfo m_info;
|
MessageInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -28,17 +28,19 @@ namespace Catch {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
||||||
: m_info( builder.m_info )
|
: m_info( builder.m_info ),
|
||||||
|
m_runContext( getCurrentRunContext() )
|
||||||
{
|
{
|
||||||
m_info.message = builder.m_stream.str();
|
m_info.message = builder.m_stream.str();
|
||||||
getResultCapture().pushScopedMessage( m_info );
|
m_runContext.pushScopedMessage( m_info );
|
||||||
}
|
}
|
||||||
ScopedMessage::ScopedMessage( ScopedMessage const& other )
|
ScopedMessage::ScopedMessage( ScopedMessage const& other )
|
||||||
: m_info( other.m_info )
|
: m_info( other.m_info ),
|
||||||
|
m_runContext( other.m_runContext )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ScopedMessage::~ScopedMessage() {
|
ScopedMessage::~ScopedMessage() {
|
||||||
getResultCapture().popScopedMessage( m_info );
|
m_runContext.popScopedMessage( m_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -74,7 +74,6 @@ namespace Catch {
|
|||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
delete getTheRegistryHub();
|
delete getTheRegistryHub();
|
||||||
getTheRegistryHub() = CATCH_NULL;
|
getTheRegistryHub() = CATCH_NULL;
|
||||||
cleanUpContext();
|
|
||||||
}
|
}
|
||||||
std::string translateActiveException() {
|
std::string translateActiveException() {
|
||||||
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
||||||
|
@@ -64,12 +64,12 @@ namespace Catch {
|
|||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ListenerRegistrar {
|
class ListenerRegistrar {
|
||||||
|
|
||||||
class ListenerFactory : public SharedImpl<IReporterFactory> {
|
class ListenerFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
return new T( config );
|
return new T( config );
|
||||||
}
|
}
|
||||||
@@ -77,9 +77,9 @@ namespace Catch {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ListenerRegistrar() {
|
ListenerRegistrar() {
|
||||||
getMutableRegistryHub().registerListener( new ListenerFactory() );
|
getMutableRegistryHub().registerListener( new ListenerFactory() );
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
struct TestFailureException{};
|
struct TestFailureException{};
|
||||||
|
|
||||||
template<typename T> class ExpressionLhs;
|
template<typename T> class ExpressionLhs;
|
||||||
@@ -77,6 +78,7 @@ namespace Catch {
|
|||||||
bool allowThrows() const;
|
bool allowThrows() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
IRunContext& m_runContext;
|
||||||
AssertionInfo m_assertionInfo;
|
AssertionInfo m_assertionInfo;
|
||||||
AssertionResultData m_data;
|
AssertionResultData m_data;
|
||||||
struct ExprComponents {
|
struct ExprComponents {
|
||||||
@@ -85,7 +87,7 @@ namespace Catch {
|
|||||||
std::string lhs, rhs, op;
|
std::string lhs, rhs, op;
|
||||||
} m_exprComponents;
|
} m_exprComponents;
|
||||||
CopyableStream m_stream;
|
CopyableStream m_stream;
|
||||||
|
|
||||||
bool m_shouldDebugBreak;
|
bool m_shouldDebugBreak;
|
||||||
bool m_shouldThrow;
|
bool m_shouldThrow;
|
||||||
};
|
};
|
||||||
|
@@ -9,9 +9,7 @@
|
|||||||
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_result_builder.h"
|
#include "catch_result_builder.h"
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_interfaces_config.h"
|
#include "catch_interfaces_config.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"
|
#include "catch_wildcard_pattern.hpp"
|
||||||
@@ -28,7 +26,8 @@ namespace Catch {
|
|||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition,
|
ResultDisposition::Flags resultDisposition,
|
||||||
char const* secondArg )
|
char const* secondArg )
|
||||||
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
: m_runContext( getCurrentRunContext() ),
|
||||||
|
m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false )
|
m_shouldThrow( false )
|
||||||
{}
|
{}
|
||||||
@@ -77,12 +76,12 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
|
void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
|
||||||
|
|
||||||
assert( m_exprComponents.testFalse == false );
|
assert( m_exprComponents.testFalse == false );
|
||||||
AssertionResultData data = m_data;
|
AssertionResultData data = m_data;
|
||||||
data.resultType = ResultWas::Ok;
|
data.resultType = ResultWas::Ok;
|
||||||
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||||
|
|
||||||
std::string actualMessage = Catch::translateActiveException();
|
std::string actualMessage = Catch::translateActiveException();
|
||||||
if( !matcher.match( actualMessage ) ) {
|
if( !matcher.match( actualMessage ) ) {
|
||||||
data.resultType = ResultWas::ExpressionFailed;
|
data.resultType = ResultWas::ExpressionFailed;
|
||||||
@@ -98,12 +97,12 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
void ResultBuilder::handleResult( AssertionResult const& result )
|
void ResultBuilder::handleResult( AssertionResult const& result )
|
||||||
{
|
{
|
||||||
getResultCapture().assertionEnded( result );
|
m_runContext.assertionEnded( result );
|
||||||
|
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
if( getCurrentContext().getConfig()->shouldDebugBreak() )
|
if( m_runContext.config().shouldDebugBreak() )
|
||||||
m_shouldDebugBreak = true;
|
m_shouldDebugBreak = true;
|
||||||
if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
|
if( m_runContext.isAborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
|
||||||
m_shouldThrow = true;
|
m_shouldThrow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +112,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
|
bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
|
||||||
bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); }
|
bool ResultBuilder::allowThrows() const { return m_runContext.config().allowThrows(); }
|
||||||
|
|
||||||
AssertionResult ResultBuilder::build() const
|
AssertionResult ResultBuilder::build() const
|
||||||
{
|
{
|
||||||
|
@@ -55,7 +55,7 @@ namespace Catch {
|
|||||||
inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
|
inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
|
||||||
inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
|
inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
|
||||||
inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
|
inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_interfaces_runner.h"
|
#include "catch_interfaces_capture.h"
|
||||||
#include "catch_interfaces_reporter.h"
|
#include "catch_interfaces_reporter.h"
|
||||||
#include "catch_interfaces_exception.h"
|
#include "catch_interfaces_exception.h"
|
||||||
#include "catch_config.hpp"
|
#include "catch_config.hpp"
|
||||||
@@ -52,7 +52,34 @@ namespace Catch {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class RunContext : public IResultCapture, public IRunner {
|
namespace {
|
||||||
|
IRunContext* s_currentRunContext = CATCH_NULL;
|
||||||
|
|
||||||
|
void setCurrentRunContext( IRunContext* context ) {
|
||||||
|
s_currentRunContext = context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IRunContext* tryGetCurrentRunContext() {
|
||||||
|
return s_currentRunContext;
|
||||||
|
}
|
||||||
|
IRunContext& getCurrentRunContext() {
|
||||||
|
if( IRunContext* capture = tryGetCurrentRunContext() )
|
||||||
|
return *capture;
|
||||||
|
else
|
||||||
|
throw std::logic_error( "No current test runner" );
|
||||||
|
}
|
||||||
|
IConfig const* getCurrentConfig() {
|
||||||
|
if( IRunContext* capture = tryGetCurrentRunContext() )
|
||||||
|
return &capture->config();
|
||||||
|
else
|
||||||
|
return CATCH_NULL;
|
||||||
|
}
|
||||||
|
AssertionResult const* getLastResult() {
|
||||||
|
return getCurrentRunContext().getLastResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunContext : public IRunContext {
|
||||||
|
|
||||||
RunContext( RunContext const& );
|
RunContext( RunContext const& );
|
||||||
void operator =( RunContext const& );
|
void operator =( RunContext const& );
|
||||||
@@ -61,81 +88,66 @@ namespace Catch {
|
|||||||
|
|
||||||
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
||||||
: m_runInfo( _config->name() ),
|
: m_runInfo( _config->name() ),
|
||||||
m_context( getCurrentMutableContext() ),
|
|
||||||
m_activeTestCase( CATCH_NULL ),
|
|
||||||
m_config( _config ),
|
m_config( _config ),
|
||||||
m_reporter( reporter )
|
m_reporter( reporter ),
|
||||||
|
m_activeTestCaseInfo( CATCH_NULL )
|
||||||
{
|
{
|
||||||
m_context.setRunner( this );
|
setCurrentRunContext( this );
|
||||||
m_context.setConfig( m_config );
|
|
||||||
m_context.setResultCapture( this );
|
|
||||||
m_reporter->testRunStarting( m_runInfo );
|
m_reporter->testRunStarting( m_runInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~RunContext() {
|
virtual ~RunContext() {
|
||||||
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, isAborting() ) );
|
||||||
|
setCurrentRunContext( CATCH_NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
||||||
m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
|
m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
|
||||||
}
|
}
|
||||||
void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
|
void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
|
||||||
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
|
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, isAborting() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals runTest( TestCase const& testCase ) {
|
Totals runTest( TestCase const& testCase ) {
|
||||||
|
m_activeTestCaseInfo = &testCase;
|
||||||
|
|
||||||
Totals prevTotals = m_totals;
|
Totals prevTotals = m_totals;
|
||||||
|
std::string redirectedCout, redirectedCerr;
|
||||||
|
|
||||||
std::string redirectedCout;
|
m_reporter->testCaseStarting( testCase );
|
||||||
std::string redirectedCerr;
|
|
||||||
|
|
||||||
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
ITracker* m_testCaseTracker;
|
||||||
|
|
||||||
m_reporter->testCaseStarting( testInfo );
|
|
||||||
|
|
||||||
m_activeTestCase = &testCase;
|
|
||||||
|
|
||||||
|
|
||||||
|
m_trackerContext.startRun();
|
||||||
do {
|
do {
|
||||||
m_trackerContext.startRun();
|
m_trackerContext.startCycle();
|
||||||
do {
|
m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testCase.name );
|
||||||
m_trackerContext.startCycle();
|
runTest( testCase, redirectedCout, redirectedCerr );
|
||||||
m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testInfo.name );
|
|
||||||
runCurrentTest( redirectedCout, redirectedCerr );
|
|
||||||
}
|
|
||||||
while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() );
|
|
||||||
}
|
}
|
||||||
// !TBD: deprecated - this will be replaced by indexed trackers
|
while( !m_testCaseTracker->isSuccessfullyCompleted() && !isAborting() );
|
||||||
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
|
||||||
|
|
||||||
|
|
||||||
Totals deltaTotals = m_totals.delta( prevTotals );
|
Totals deltaTotals = m_totals.delta( prevTotals );
|
||||||
m_totals.testCases += deltaTotals.testCases;
|
m_totals.testCases += deltaTotals.testCases;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( testCase,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
redirectedCout,
|
redirectedCout,
|
||||||
redirectedCerr,
|
redirectedCerr,
|
||||||
aborting() ) );
|
isAborting() ) );
|
||||||
|
|
||||||
m_activeTestCase = CATCH_NULL;
|
m_activeTestCaseInfo = CATCH_NULL;
|
||||||
m_testCaseTracker = CATCH_NULL;
|
|
||||||
|
|
||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<IConfig const> config() const {
|
private: // IRunContext
|
||||||
return m_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private: // IResultCapture
|
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionEnded( AssertionResult const& result ) {
|
virtual void assertionEnded( AssertionResult const& result ) CATCH_OVERRIDE {
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok )
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
else if( !result.isOk() )
|
||||||
else if( !result.isOk() ) {
|
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
}
|
|
||||||
|
|
||||||
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
|
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
@@ -145,10 +157,9 @@ namespace Catch {
|
|||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted (
|
virtual bool sectionStarted
|
||||||
SectionInfo const& sectionInfo,
|
( SectionInfo const& sectionInfo,
|
||||||
Counts& assertions
|
Counts& assertions ) CATCH_OVERRIDE
|
||||||
)
|
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
||||||
@@ -157,7 +168,7 @@ namespace Catch {
|
|||||||
if( !sectionTracker.isOpen() )
|
if( !sectionTracker.isOpen() )
|
||||||
return false;
|
return false;
|
||||||
m_activeSections.push_back( §ionTracker );
|
m_activeSections.push_back( §ionTracker );
|
||||||
|
|
||||||
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
||||||
|
|
||||||
m_reporter->sectionStarting( sectionInfo );
|
m_reporter->sectionStarting( sectionInfo );
|
||||||
@@ -169,7 +180,7 @@ namespace Catch {
|
|||||||
bool testForMissingAssertions( Counts& assertions ) {
|
bool testForMissingAssertions( Counts& assertions ) {
|
||||||
if( assertions.total() != 0 )
|
if( assertions.total() != 0 )
|
||||||
return false;
|
return false;
|
||||||
if( m_config->warnAboutMissingAssertions() )
|
if( !m_config->warnAboutMissingAssertions() )
|
||||||
return false;
|
return false;
|
||||||
if( m_trackerContext.currentTracker().hasChildren() )
|
if( m_trackerContext.currentTracker().hasChildren() )
|
||||||
return false;
|
return false;
|
||||||
@@ -177,49 +188,52 @@ namespace Catch {
|
|||||||
assertions.failed++;
|
assertions.failed++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionEndInfo const& endInfo ) {
|
virtual void sectionEnded( SectionEndInfo const& endInfo ) CATCH_OVERRIDE {
|
||||||
Counts assertions = m_totals.assertions - endInfo.prevAssertions;
|
Counts assertions = m_totals.assertions - endInfo.prevAssertions;
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
if( !m_activeSections.empty() ) {
|
if( !m_activeSections.empty() ) {
|
||||||
m_activeSections.back()->close();
|
m_activeSections.back()->close();
|
||||||
m_activeSections.pop_back();
|
m_activeSections.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) );
|
m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) );
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) {
|
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) CATCH_OVERRIDE {
|
||||||
if( m_unfinishedSections.empty() )
|
if( m_unfinishedSections.empty() )
|
||||||
m_activeSections.back()->fail();
|
m_activeSections.back()->fail();
|
||||||
else
|
else
|
||||||
m_activeSections.back()->close();
|
m_activeSections.back()->close();
|
||||||
m_activeSections.pop_back();
|
m_activeSections.pop_back();
|
||||||
|
|
||||||
m_unfinishedSections.push_back( endInfo );
|
m_unfinishedSections.push_back( endInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void pushScopedMessage( MessageInfo const& message ) {
|
virtual void pushScopedMessage( MessageInfo const& message ) CATCH_OVERRIDE {
|
||||||
m_messages.push_back( message );
|
m_messages.push_back( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void popScopedMessage( MessageInfo const& message ) {
|
virtual void popScopedMessage( MessageInfo const& message ) CATCH_OVERRIDE {
|
||||||
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
|
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const {
|
virtual std::string getCurrentTestName() const CATCH_OVERRIDE {
|
||||||
return m_activeTestCase
|
return m_activeTestCaseInfo
|
||||||
? m_activeTestCase->getTestCaseInfo().name
|
? m_activeTestCaseInfo->name
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const AssertionResult* getLastResult() const {
|
virtual AssertionResult const* getLastResult() const CATCH_OVERRIDE {
|
||||||
return &m_lastResult;
|
return &m_lastResult;
|
||||||
}
|
}
|
||||||
|
virtual IConfig const& config() const CATCH_OVERRIDE {
|
||||||
|
return *m_config;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) {
|
virtual void handleFatalErrorCondition( std::string const& message ) CATCH_OVERRIDE {
|
||||||
ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
|
ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
|
||||||
resultBuilder.setResultType( ResultWas::FatalErrorCondition );
|
resultBuilder.setResultType( ResultWas::FatalErrorCondition );
|
||||||
resultBuilder << message;
|
resultBuilder << message;
|
||||||
@@ -228,19 +242,19 @@ namespace Catch {
|
|||||||
handleUnfinishedSections();
|
handleUnfinishedSections();
|
||||||
|
|
||||||
// Recreate section for test case (as we will lose the one that was in scope)
|
// Recreate section for test case (as we will lose the one that was in scope)
|
||||||
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
SectionInfo testCaseSection
|
||||||
SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
|
( m_activeTestCaseInfo->lineInfo,
|
||||||
|
m_activeTestCaseInfo->name,
|
||||||
|
m_activeTestCaseInfo->description );
|
||||||
|
|
||||||
Counts assertions;
|
Counts assertions;
|
||||||
assertions.failed = 1;
|
assertions.failed = 1;
|
||||||
SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
|
SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
|
|
||||||
TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo();
|
|
||||||
|
|
||||||
Totals deltaTotals;
|
Totals deltaTotals;
|
||||||
deltaTotals.testCases.failed = 1;
|
deltaTotals.testCases.failed = 1;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( *m_activeTestCaseInfo,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@@ -252,32 +266,31 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// !TBD We need to do this another way!
|
// !TBD We need to do this another way!
|
||||||
bool aborting() const {
|
bool isAborting() const {
|
||||||
return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
|
return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
|
void runTest( TestCase const& testCase, std::string& redirectedCout, std::string& redirectedCerr ) {
|
||||||
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
SectionInfo testCaseSection( testCase.lineInfo, testCase.name, testCase.description );
|
||||||
SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
|
|
||||||
m_reporter->sectionStarting( testCaseSection );
|
m_reporter->sectionStarting( testCaseSection );
|
||||||
Counts prevAssertions = m_totals.assertions;
|
Counts prevAssertions = m_totals.assertions;
|
||||||
double duration = 0;
|
double duration = 0;
|
||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCase.lineInfo, "", ResultDisposition::Normal );
|
||||||
|
|
||||||
seedRng( *m_config );
|
seedRng( *m_config );
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||||
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
||||||
StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
|
StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
|
||||||
invokeActiveTestCase();
|
invokeTestCase( testCase );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
invokeActiveTestCase();
|
invokeTestCase( testCase );
|
||||||
}
|
}
|
||||||
duration = timer.getElapsedSeconds();
|
duration = timer.getElapsedSeconds();
|
||||||
}
|
}
|
||||||
@@ -287,14 +300,15 @@ namespace Catch {
|
|||||||
catch(...) {
|
catch(...) {
|
||||||
makeUnexpectedResultBuilder().useActiveException();
|
makeUnexpectedResultBuilder().useActiveException();
|
||||||
}
|
}
|
||||||
m_testCaseTracker->close();
|
m_trackerContext.currentTracker().close();
|
||||||
|
|
||||||
handleUnfinishedSections();
|
handleUnfinishedSections();
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
|
|
||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
if( testCaseInfo.okToFail() ) {
|
if( testCase.okToFail() ) {
|
||||||
std::swap( assertions.failedButOk, assertions.failed );
|
std::swap( assertions.failedButOk, assertions.failed );
|
||||||
m_totals.assertions.failed -= assertions.failedButOk;
|
m_totals.assertions.failed -= assertions.failedButOk;
|
||||||
m_totals.assertions.failedButOk += assertions.failedButOk;
|
m_totals.assertions.failedButOk += assertions.failedButOk;
|
||||||
@@ -304,10 +318,9 @@ namespace Catch {
|
|||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
void invokeActiveTestCase() {
|
static void invokeTestCase( TestCase const& testCase ) {
|
||||||
FatalConditionHandler fatalConditionHandler; // Handle signals
|
FatalConditionHandler fatalConditionHandler; // Handle signals
|
||||||
m_activeTestCase->invoke();
|
testCase.invoke();
|
||||||
fatalConditionHandler.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -318,7 +331,7 @@ namespace Catch {
|
|||||||
m_lastAssertionInfo.capturedExpression.c_str(),
|
m_lastAssertionInfo.capturedExpression.c_str(),
|
||||||
m_lastAssertionInfo.resultDisposition );
|
m_lastAssertionInfo.resultDisposition );
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUnfinishedSections() {
|
void handleUnfinishedSections() {
|
||||||
// If sections ended prematurely due to an exception we stored their
|
// If sections ended prematurely due to an exception we stored their
|
||||||
// infos here so we can tear them down outside the unwind process.
|
// infos here so we can tear them down outside the unwind process.
|
||||||
@@ -331,29 +344,21 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestRunInfo m_runInfo;
|
TestRunInfo m_runInfo;
|
||||||
IMutableContext& m_context;
|
|
||||||
TestCase const* m_activeTestCase;
|
|
||||||
ITracker* m_testCaseTracker;
|
|
||||||
ITracker* m_currentSectionTracker;
|
|
||||||
AssertionResult m_lastResult;
|
|
||||||
|
|
||||||
Ptr<IConfig const> m_config;
|
Ptr<IConfig const> m_config;
|
||||||
Totals m_totals;
|
|
||||||
Ptr<IStreamingReporter> m_reporter;
|
Ptr<IStreamingReporter> m_reporter;
|
||||||
std::vector<MessageInfo> m_messages;
|
TrackerContext m_trackerContext;
|
||||||
|
Totals m_totals;
|
||||||
|
|
||||||
|
// Transient state
|
||||||
|
TestCaseInfo const* m_activeTestCaseInfo;
|
||||||
|
AssertionResult m_lastResult;
|
||||||
AssertionInfo m_lastAssertionInfo;
|
AssertionInfo m_lastAssertionInfo;
|
||||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
std::vector<ITracker*> m_activeSections;
|
std::vector<ITracker*> m_activeSections;
|
||||||
TrackerContext m_trackerContext;
|
std::vector<MessageInfo> m_messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture() {
|
|
||||||
if( IResultCapture* capture = getCurrentContext().getResultCapture() )
|
|
||||||
return *capture;
|
|
||||||
else
|
|
||||||
throw std::logic_error( "No result capture instance" );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
|
|
||||||
class Section : NonCopyable {
|
class Section : NonCopyable {
|
||||||
public:
|
public:
|
||||||
Section( SectionInfo const& info );
|
Section( SectionInfo const& info );
|
||||||
@@ -29,6 +31,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
Counts m_assertions;
|
Counts m_assertions;
|
||||||
|
IRunContext& m_runContext;
|
||||||
bool m_sectionIncluded;
|
bool m_sectionIncluded;
|
||||||
Timer m_timer;
|
Timer m_timer;
|
||||||
};
|
};
|
||||||
|
@@ -26,7 +26,8 @@ namespace Catch {
|
|||||||
|
|
||||||
Section::Section( SectionInfo const& info )
|
Section::Section( SectionInfo const& info )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
|
m_runContext( getCurrentRunContext() ),
|
||||||
|
m_sectionIncluded( m_runContext.sectionStarted( m_info, m_assertions ) )
|
||||||
{
|
{
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
@@ -35,9 +36,9 @@ namespace Catch {
|
|||||||
if( m_sectionIncluded ) {
|
if( m_sectionIncluded ) {
|
||||||
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
|
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
|
||||||
if( std::uncaught_exception() )
|
if( std::uncaught_exception() )
|
||||||
getResultCapture().sectionEndedEarly( endInfo );
|
m_runContext.sectionEndedEarly( endInfo );
|
||||||
else
|
else
|
||||||
getResultCapture().sectionEnded( endInfo );
|
m_runContext.sectionEnded( endInfo );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,17 +23,17 @@ namespace Catch {
|
|||||||
std::string description;
|
std::string description;
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SectionEndInfo {
|
struct SectionEndInfo {
|
||||||
SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds )
|
SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds )
|
||||||
: sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
|
: sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SectionInfo sectionInfo;
|
SectionInfo sectionInfo;
|
||||||
Counts prevAssertions;
|
Counts prevAssertions;
|
||||||
double durationInSeconds;
|
double durationInSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
||||||
|
@@ -15,13 +15,14 @@
|
|||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
std::ostream& cout();
|
std::ostream& cout();
|
||||||
std::ostream& cerr();
|
std::ostream& cerr();
|
||||||
|
|
||||||
|
|
||||||
struct IStream {
|
struct IStream {
|
||||||
virtual ~IStream() CATCH_NOEXCEPT;
|
virtual ~IStream() CATCH_NOEXCEPT;
|
||||||
virtual std::ostream& stream() const = 0;
|
virtual std::ostream& stream() const = 0;
|
||||||
@@ -31,26 +32,29 @@ namespace Catch {
|
|||||||
mutable std::ofstream m_ofs;
|
mutable std::ofstream m_ofs;
|
||||||
public:
|
public:
|
||||||
FileStream( std::string const& filename );
|
FileStream( std::string const& filename );
|
||||||
|
virtual ~FileStream() CATCH_NOEXCEPT;
|
||||||
public: // IStream
|
public: // IStream
|
||||||
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CoutStream : public IStream {
|
class CoutStream : public IStream {
|
||||||
mutable std::ostream m_os;
|
mutable std::ostream m_os;
|
||||||
public:
|
public:
|
||||||
CoutStream();
|
CoutStream();
|
||||||
|
virtual ~CoutStream() CATCH_NOEXCEPT;
|
||||||
|
|
||||||
public: // IStream
|
public: // IStream
|
||||||
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DebugOutStream : public IStream {
|
class DebugOutStream : public IStream {
|
||||||
std::auto_ptr<StreamBufBase> m_streamBuf;
|
CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
|
||||||
mutable std::ostream m_os;
|
mutable std::ostream m_os;
|
||||||
public:
|
public:
|
||||||
DebugOutStream();
|
DebugOutStream();
|
||||||
|
virtual ~DebugOutStream() CATCH_NOEXCEPT;
|
||||||
|
|
||||||
public: // IStream
|
public: // IStream
|
||||||
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
|
@@ -65,27 +65,27 @@ namespace Catch {
|
|||||||
throw std::domain_error( oss.str() );
|
throw std::domain_error( oss.str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& FileStream::stream() const {
|
std::ostream& FileStream::stream() const {
|
||||||
return m_ofs;
|
return m_ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OutputDebugWriter {
|
struct OutputDebugWriter {
|
||||||
|
|
||||||
void operator()( std::string const&str ) {
|
void operator()( std::string const&str ) {
|
||||||
writeToDebugConsole( str );
|
writeToDebugConsole( str );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DebugOutStream::DebugOutStream()
|
DebugOutStream::DebugOutStream()
|
||||||
: m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
|
: m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
|
||||||
m_os( m_streamBuf.get() )
|
m_os( m_streamBuf.get() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::ostream& DebugOutStream::stream() const {
|
std::ostream& DebugOutStream::stream() const {
|
||||||
return m_os;
|
return m_os;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the streambuf from cout up-front because
|
// Store the streambuf from cout up-front because
|
||||||
// cout may get redirected when running tests
|
// cout may get redirected when running tests
|
||||||
CoutStream::CoutStream()
|
CoutStream::CoutStream()
|
||||||
@@ -95,8 +95,8 @@ namespace Catch {
|
|||||||
std::ostream& CoutStream::stream() const {
|
std::ostream& CoutStream::stream() const {
|
||||||
return m_os;
|
return m_os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement this functions
|
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement this functions
|
||||||
std::ostream& cout() {
|
std::ostream& cout() {
|
||||||
return std::cout;
|
return std::cout;
|
||||||
|
@@ -31,7 +31,7 @@ namespace Catch {
|
|||||||
MayFail = 1 << 3,
|
MayFail = 1 << 3,
|
||||||
Throws = 1 << 4
|
Throws = 1 << 4
|
||||||
};
|
};
|
||||||
|
|
||||||
TestCaseInfo( std::string const& _name,
|
TestCaseInfo( std::string const& _name,
|
||||||
std::string const& _className,
|
std::string const& _className,
|
||||||
std::string const& _description,
|
std::string const& _description,
|
||||||
@@ -41,7 +41,7 @@ namespace Catch {
|
|||||||
TestCaseInfo( TestCaseInfo const& other );
|
TestCaseInfo( TestCaseInfo const& other );
|
||||||
|
|
||||||
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
|
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
|
||||||
|
|
||||||
bool isHidden() const;
|
bool isHidden() const;
|
||||||
bool throws() const;
|
bool throws() const;
|
||||||
bool okToFail() const;
|
bool okToFail() const;
|
||||||
|
@@ -88,7 +88,7 @@ namespace Catch {
|
|||||||
tags.insert( "hide" );
|
tags.insert( "hide" );
|
||||||
tags.insert( "." );
|
tags.insert( "." );
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
|
TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
|
||||||
return TestCase( _testCase, info );
|
return TestCase( _testCase, info );
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
testCaseInfo.tags = tags;
|
testCaseInfo.tags = tags;
|
||||||
testCaseInfo.lcaseTags.clear();
|
testCaseInfo.lcaseTags.clear();
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
|
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
|
||||||
oss << "[" << *it << "]";
|
oss << "[" << *it << "]";
|
||||||
@@ -107,7 +107,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
testCaseInfo.tagsAsString = oss.str();
|
testCaseInfo.tagsAsString = oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCaseInfo::TestCaseInfo( std::string const& _name,
|
TestCaseInfo::TestCaseInfo( std::string const& _name,
|
||||||
std::string const& _className,
|
std::string const& _className,
|
||||||
std::string const& _description,
|
std::string const& _description,
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "catch_test_registry.hpp"
|
#include "catch_test_registry.hpp"
|
||||||
#include "catch_test_case_info.h"
|
#include "catch_test_case_info.h"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
#include "catch_context.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -27,11 +26,11 @@ namespace Catch {
|
|||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
int operator()( int n ) const { return std::rand() % n; }
|
int operator()( int n ) const { return std::rand() % n; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
||||||
|
|
||||||
std::vector<TestCase> sorted = unsortedTestCases;
|
std::vector<TestCase> sorted = unsortedTestCases;
|
||||||
|
|
||||||
switch( config.runOrder() ) {
|
switch( config.runOrder() ) {
|
||||||
case RunTests::InLexicographicalOrder:
|
case RunTests::InLexicographicalOrder:
|
||||||
std::sort( sorted.begin(), sorted.end(), LexSort() );
|
std::sort( sorted.begin(), sorted.end(), LexSort() );
|
||||||
@@ -39,7 +38,7 @@ namespace Catch {
|
|||||||
case RunTests::InRandomOrder:
|
case RunTests::InRandomOrder:
|
||||||
{
|
{
|
||||||
seedRng( config );
|
seedRng( config );
|
||||||
|
|
||||||
RandomNumberGenerator rng;
|
RandomNumberGenerator rng;
|
||||||
std::random_shuffle( sorted.begin(), sorted.end(), rng );
|
std::random_shuffle( sorted.begin(), sorted.end(), rng );
|
||||||
}
|
}
|
||||||
@@ -70,7 +69,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
|
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
|
||||||
std::vector<TestCase> filtered;
|
std::vector<TestCase> filtered;
|
||||||
filtered.reserve( testCases.size() );
|
filtered.reserve( testCases.size() );
|
||||||
@@ -87,7 +86,10 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestRegistry : public ITestCaseRegistry {
|
class TestRegistry : public ITestCaseRegistry {
|
||||||
public:
|
public:
|
||||||
TestRegistry() : m_unnamedCount( 0 ) {}
|
TestRegistry()
|
||||||
|
: m_currentSortOrder( RunTests::InDeclarationOrder ),
|
||||||
|
m_unnamedCount( 0 )
|
||||||
|
{}
|
||||||
virtual ~TestRegistry();
|
virtual ~TestRegistry();
|
||||||
|
|
||||||
virtual void registerTest( TestCase const& testCase ) {
|
virtual void registerTest( TestCase const& testCase ) {
|
||||||
@@ -152,29 +154,38 @@ namespace Catch {
|
|||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void registerTestCase
|
||||||
|
( ITestCase* testCase,
|
||||||
|
char const* classOrQualifiedMethodName,
|
||||||
|
NameAndDesc const& nameAndDesc,
|
||||||
|
SourceLineInfo const& lineInfo ) {
|
||||||
|
|
||||||
|
getMutableRegistryHub().registerTest
|
||||||
|
( makeTestCase
|
||||||
|
( testCase,
|
||||||
|
extractClassName( classOrQualifiedMethodName ),
|
||||||
|
nameAndDesc.name,
|
||||||
|
nameAndDesc.description,
|
||||||
|
lineInfo ) );
|
||||||
|
}
|
||||||
|
void registerTestCaseFunction
|
||||||
|
( TestFunction function,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc ) {
|
||||||
|
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AutoReg::AutoReg( TestFunction function,
|
AutoReg::AutoReg
|
||||||
SourceLineInfo const& lineInfo,
|
( TestFunction function,
|
||||||
NameAndDesc const& nameAndDesc ) {
|
SourceLineInfo const& lineInfo,
|
||||||
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
|
NameAndDesc const& nameAndDesc ) {
|
||||||
|
registerTestCaseFunction( function, lineInfo, nameAndDesc );
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoReg::~AutoReg() {}
|
AutoReg::~AutoReg() {}
|
||||||
|
|
||||||
void AutoReg::registerTestCase( ITestCase* testCase,
|
|
||||||
char const* classOrQualifiedMethodName,
|
|
||||||
NameAndDesc const& nameAndDesc,
|
|
||||||
SourceLineInfo const& lineInfo ) {
|
|
||||||
|
|
||||||
getMutableRegistryHub().registerTest
|
|
||||||
( makeTestCase( testCase,
|
|
||||||
extractClassName( classOrQualifiedMethodName ),
|
|
||||||
nameAndDesc.name,
|
|
||||||
nameAndDesc.description,
|
|
||||||
lineInfo ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,61 +21,61 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
struct ITracker : SharedImpl<> {
|
struct ITracker : SharedImpl<> {
|
||||||
virtual ~ITracker();
|
virtual ~ITracker();
|
||||||
|
|
||||||
// static queries
|
// static queries
|
||||||
virtual std::string name() const = 0;
|
virtual std::string name() const = 0;
|
||||||
|
|
||||||
// dynamic queries
|
// dynamic queries
|
||||||
virtual bool isComplete() const = 0; // Successfully completed or failed
|
virtual bool isComplete() const = 0; // Successfully completed or failed
|
||||||
virtual bool isSuccessfullyCompleted() const = 0;
|
virtual bool isSuccessfullyCompleted() const = 0;
|
||||||
virtual bool isOpen() const = 0; // Started but not complete
|
virtual bool isOpen() const = 0; // Started but not complete
|
||||||
virtual bool hasChildren() const = 0;
|
virtual bool hasChildren() const = 0;
|
||||||
|
|
||||||
virtual ITracker& parent() = 0;
|
virtual ITracker& parent() = 0;
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
virtual void close() = 0; // Successfully complete
|
virtual void close() = 0; // Successfully complete
|
||||||
virtual void fail() = 0;
|
virtual void fail() = 0;
|
||||||
virtual void markAsNeedingAnotherRun() = 0;
|
virtual void markAsNeedingAnotherRun() = 0;
|
||||||
|
|
||||||
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
||||||
virtual ITracker* findChild( std::string const& name ) = 0;
|
virtual ITracker* findChild( std::string const& name ) = 0;
|
||||||
virtual void openChild() = 0;
|
virtual void openChild() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrackerContext {
|
class TrackerContext {
|
||||||
|
|
||||||
enum RunState {
|
enum RunState {
|
||||||
NotStarted,
|
NotStarted,
|
||||||
Executing,
|
Executing,
|
||||||
CompletedCycle
|
CompletedCycle
|
||||||
};
|
};
|
||||||
|
|
||||||
Ptr<ITracker> m_rootTracker;
|
Ptr<ITracker> m_rootTracker;
|
||||||
ITracker* m_currentTracker;
|
ITracker* m_currentTracker;
|
||||||
RunState m_runState;
|
RunState m_runState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static TrackerContext& instance() {
|
static TrackerContext& instance() {
|
||||||
static TrackerContext s_instance;
|
static TrackerContext s_instance;
|
||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackerContext()
|
TrackerContext()
|
||||||
: m_currentTracker( CATCH_NULL ),
|
: m_currentTracker( CATCH_NULL ),
|
||||||
m_runState( NotStarted )
|
m_runState( NotStarted )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
ITracker& startRun();
|
ITracker& startRun();
|
||||||
|
|
||||||
void endRun() {
|
void endRun() {
|
||||||
m_rootTracker.reset();
|
m_rootTracker.reset();
|
||||||
m_currentTracker = CATCH_NULL;
|
m_currentTracker = CATCH_NULL;
|
||||||
m_runState = NotStarted;
|
m_runState = NotStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startCycle() {
|
void startCycle() {
|
||||||
m_currentTracker = m_rootTracker.get();
|
m_currentTracker = m_rootTracker.get();
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
@@ -83,7 +83,7 @@ namespace TestCaseTracking {
|
|||||||
void completeCycle() {
|
void completeCycle() {
|
||||||
m_runState = CompletedCycle;
|
m_runState = CompletedCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool completedCycle() const {
|
bool completedCycle() const {
|
||||||
return m_runState == CompletedCycle;
|
return m_runState == CompletedCycle;
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ namespace TestCaseTracking {
|
|||||||
m_currentTracker = tracker;
|
m_currentTracker = tracker;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrackerBase : public ITracker {
|
class TrackerBase : public ITracker {
|
||||||
protected:
|
protected:
|
||||||
enum CycleState {
|
enum CycleState {
|
||||||
@@ -127,7 +127,7 @@ namespace TestCaseTracking {
|
|||||||
m_runState( NotStarted )
|
m_runState( NotStarted )
|
||||||
{}
|
{}
|
||||||
virtual ~TrackerBase();
|
virtual ~TrackerBase();
|
||||||
|
|
||||||
virtual std::string name() const CATCH_OVERRIDE {
|
virtual std::string name() const CATCH_OVERRIDE {
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
@@ -143,12 +143,12 @@ namespace TestCaseTracking {
|
|||||||
virtual bool hasChildren() const CATCH_OVERRIDE {
|
virtual bool hasChildren() const CATCH_OVERRIDE {
|
||||||
return !m_children.empty();
|
return !m_children.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
|
virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
|
||||||
m_children.push_back( child );
|
m_children.push_back( child );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
|
virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
|
||||||
Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
|
Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
|
||||||
return( it != m_children.end() )
|
return( it != m_children.end() )
|
||||||
@@ -159,7 +159,7 @@ namespace TestCaseTracking {
|
|||||||
assert( m_parent ); // Should always be non-null except for root
|
assert( m_parent ); // Should always be non-null except for root
|
||||||
return *m_parent;
|
return *m_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void openChild() CATCH_OVERRIDE {
|
virtual void openChild() CATCH_OVERRIDE {
|
||||||
if( m_runState != ExecutingChildren ) {
|
if( m_runState != ExecutingChildren ) {
|
||||||
m_runState = ExecutingChildren;
|
m_runState = ExecutingChildren;
|
||||||
@@ -173,22 +173,22 @@ namespace TestCaseTracking {
|
|||||||
if( m_parent )
|
if( m_parent )
|
||||||
m_parent->openChild();
|
m_parent->openChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void close() CATCH_OVERRIDE {
|
virtual void close() CATCH_OVERRIDE {
|
||||||
|
|
||||||
// Close any still open children (e.g. generators)
|
// Close any still open children (e.g. generators)
|
||||||
while( &m_ctx.currentTracker() != this )
|
while( &m_ctx.currentTracker() != this )
|
||||||
m_ctx.currentTracker().close();
|
m_ctx.currentTracker().close();
|
||||||
|
|
||||||
switch( m_runState ) {
|
switch( m_runState ) {
|
||||||
case NotStarted:
|
case NotStarted:
|
||||||
case CompletedSuccessfully:
|
case CompletedSuccessfully:
|
||||||
case Failed:
|
case Failed:
|
||||||
throw std::logic_error( "Illogical state" );
|
throw std::logic_error( "Illogical state" );
|
||||||
|
|
||||||
case NeedsAnotherRun:
|
case NeedsAnotherRun:
|
||||||
break;;
|
break;;
|
||||||
|
|
||||||
case Executing:
|
case Executing:
|
||||||
m_runState = CompletedSuccessfully;
|
m_runState = CompletedSuccessfully;
|
||||||
break;
|
break;
|
||||||
@@ -196,7 +196,7 @@ namespace TestCaseTracking {
|
|||||||
if( m_children.empty() || m_children.back()->isComplete() )
|
if( m_children.empty() || m_children.back()->isComplete() )
|
||||||
m_runState = CompletedSuccessfully;
|
m_runState = CompletedSuccessfully;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::logic_error( "Unexpected state" );
|
throw std::logic_error( "Unexpected state" );
|
||||||
}
|
}
|
||||||
@@ -222,17 +222,17 @@ namespace TestCaseTracking {
|
|||||||
m_ctx.setCurrentTracker( this );
|
m_ctx.setCurrentTracker( this );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SectionTracker : public TrackerBase {
|
class SectionTracker : public TrackerBase {
|
||||||
public:
|
public:
|
||||||
SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
|
SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
|
||||||
: TrackerBase( name, ctx, parent )
|
: TrackerBase( name, ctx, parent )
|
||||||
{}
|
{}
|
||||||
virtual ~SectionTracker();
|
virtual ~SectionTracker();
|
||||||
|
|
||||||
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
||||||
SectionTracker* section = CATCH_NULL;
|
SectionTracker* section = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
section = dynamic_cast<SectionTracker*>( childTracker );
|
section = dynamic_cast<SectionTracker*>( childTracker );
|
||||||
@@ -243,13 +243,13 @@ namespace TestCaseTracking {
|
|||||||
currentTracker.addChild( section );
|
currentTracker.addChild( section );
|
||||||
}
|
}
|
||||||
if( !ctx.completedCycle() && !section->isComplete() ) {
|
if( !ctx.completedCycle() && !section->isComplete() ) {
|
||||||
|
|
||||||
section->open();
|
section->open();
|
||||||
}
|
}
|
||||||
return *section;
|
return *section;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IndexTracker : public TrackerBase {
|
class IndexTracker : public TrackerBase {
|
||||||
int m_size;
|
int m_size;
|
||||||
int m_index;
|
int m_index;
|
||||||
@@ -260,10 +260,10 @@ namespace TestCaseTracking {
|
|||||||
m_index( -1 )
|
m_index( -1 )
|
||||||
{}
|
{}
|
||||||
virtual ~IndexTracker();
|
virtual ~IndexTracker();
|
||||||
|
|
||||||
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
||||||
IndexTracker* tracker = CATCH_NULL;
|
IndexTracker* tracker = CATCH_NULL;
|
||||||
|
|
||||||
ITracker& currentTracker = ctx.currentTracker();
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
tracker = dynamic_cast<IndexTracker*>( childTracker );
|
tracker = dynamic_cast<IndexTracker*>( childTracker );
|
||||||
@@ -273,39 +273,39 @@ namespace TestCaseTracking {
|
|||||||
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
||||||
currentTracker.addChild( tracker );
|
currentTracker.addChild( tracker );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !ctx.completedCycle() && !tracker->isComplete() ) {
|
if( !ctx.completedCycle() && !tracker->isComplete() ) {
|
||||||
if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )
|
if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )
|
||||||
tracker->moveNext();
|
tracker->moveNext();
|
||||||
tracker->open();
|
tracker->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *tracker;
|
return *tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index() const { return m_index; }
|
int index() const { return m_index; }
|
||||||
|
|
||||||
void moveNext() {
|
void moveNext() {
|
||||||
m_index++;
|
m_index++;
|
||||||
m_children.clear();
|
m_children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void close() CATCH_OVERRIDE {
|
virtual void close() CATCH_OVERRIDE {
|
||||||
TrackerBase::close();
|
TrackerBase::close();
|
||||||
if( m_runState == CompletedSuccessfully && m_index < m_size-1 )
|
if( m_runState == CompletedSuccessfully && m_index < m_size-1 )
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ITracker& TrackerContext::startRun() {
|
inline ITracker& TrackerContext::startRun() {
|
||||||
m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
|
m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
|
||||||
m_currentTracker = CATCH_NULL;
|
m_currentTracker = CATCH_NULL;
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
return *m_rootTracker;
|
return *m_rootTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TestCaseTracking
|
} // namespace TestCaseTracking
|
||||||
|
|
||||||
using TestCaseTracking::ITracker;
|
using TestCaseTracking::ITracker;
|
||||||
using TestCaseTracking::TrackerContext;
|
using TestCaseTracking::TrackerContext;
|
||||||
using TestCaseTracking::SectionTracker;
|
using TestCaseTracking::SectionTracker;
|
||||||
|
@@ -42,27 +42,32 @@ struct NameAndDesc {
|
|||||||
const char* description;
|
const char* description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void registerTestCase
|
||||||
|
( ITestCase* testCase,
|
||||||
|
char const* className,
|
||||||
|
NameAndDesc const& nameAndDesc,
|
||||||
|
SourceLineInfo const& lineInfo );
|
||||||
|
|
||||||
struct AutoReg {
|
struct AutoReg {
|
||||||
|
|
||||||
AutoReg( TestFunction function,
|
AutoReg
|
||||||
SourceLineInfo const& lineInfo,
|
( TestFunction function,
|
||||||
NameAndDesc const& nameAndDesc );
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc );
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
AutoReg( void (C::*method)(),
|
AutoReg
|
||||||
char const* className,
|
( void (C::*method)(),
|
||||||
NameAndDesc const& nameAndDesc,
|
char const* className,
|
||||||
SourceLineInfo const& lineInfo ) {
|
NameAndDesc const& nameAndDesc,
|
||||||
registerTestCase( new MethodTestCase<C>( method ),
|
SourceLineInfo const& lineInfo ) {
|
||||||
className,
|
|
||||||
nameAndDesc,
|
|
||||||
lineInfo );
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerTestCase( ITestCase* testCase,
|
registerTestCase
|
||||||
char const* className,
|
( new MethodTestCase<C>( method ),
|
||||||
NameAndDesc const& nameAndDesc,
|
className,
|
||||||
SourceLineInfo const& lineInfo );
|
nameAndDesc,
|
||||||
|
lineInfo );
|
||||||
|
}
|
||||||
|
|
||||||
~AutoReg();
|
~AutoReg();
|
||||||
|
|
||||||
@@ -71,50 +76,70 @@ private:
|
|||||||
void operator= ( AutoReg const& );
|
void operator= ( AutoReg const& );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void registerTestCaseFunction
|
||||||
|
( TestFunction function,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc );
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
||||||
|
static void TestName(); \
|
||||||
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
|
||||||
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
|
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
|
||||||
namespace{ \
|
namespace{ \
|
||||||
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
|
struct TestName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
|
||||||
} \
|
} \
|
||||||
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
|
void TestName::test()
|
||||||
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
|
||||||
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
||||||
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
||||||
|
static void TestName(); \
|
||||||
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
||||||
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
|
||||||
namespace{ \
|
namespace{ \
|
||||||
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
|
struct TestCaseName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
|
||||||
} \
|
} \
|
||||||
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
|
void TestCaseName::test()
|
||||||
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
|
||||||
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
||||||
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class TestSpec {
|
class TestSpec {
|
||||||
struct Pattern : SharedImpl<> {
|
struct Pattern : SharedImpl<> {
|
||||||
virtual ~Pattern();
|
virtual ~Pattern();
|
||||||
@@ -38,7 +38,7 @@ namespace Catch {
|
|||||||
private:
|
private:
|
||||||
WildcardPattern m_wildcardPattern;
|
WildcardPattern m_wildcardPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 ) ) {}
|
||||||
@@ -49,7 +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 ) {}
|
||||||
|
@@ -67,7 +67,7 @@ std::string toString( std::nullptr_t );
|
|||||||
std::string toString( NSObject* const& nsObject );
|
std::string toString( NSObject* const& nsObject );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
extern const std::string unprintableString;
|
extern const std::string unprintableString;
|
||||||
@@ -78,7 +78,7 @@ namespace Detail {
|
|||||||
|
|
||||||
struct TrueType { char sizer[1]; };
|
struct TrueType { char sizer[1]; };
|
||||||
struct FalseType { char sizer[2]; };
|
struct FalseType { char sizer[2]; };
|
||||||
|
|
||||||
TrueType& testStreamable( std::ostream& );
|
TrueType& testStreamable( std::ostream& );
|
||||||
FalseType testStreamable( FalseType );
|
FalseType testStreamable( FalseType );
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ namespace Catch {
|
|||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
const std::string unprintableString = "{?}";
|
const std::string unprintableString = "{?}";
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const int hexThreshold = 255;
|
const int hexThreshold = 255;
|
||||||
|
|
||||||
@@ -55,10 +55,13 @@ namespace Detail {
|
|||||||
|
|
||||||
std::string toString( std::string const& value ) {
|
std::string toString( std::string const& value ) {
|
||||||
std::string s = value;
|
std::string s = value;
|
||||||
if( getCurrentContext().getConfig()->showInvisibles() ) {
|
IConfig const* config = getCurrentConfig();
|
||||||
|
if( config && config->showInvisibles() ) {
|
||||||
for(size_t i = 0; i < s.size(); ++i ) {
|
for(size_t i = 0; i < s.size(); ++i ) {
|
||||||
std::string subs;
|
std::string subs;
|
||||||
switch( s[i] ) {
|
switch( s[i] ) {
|
||||||
|
case '\r': subs = "\\r"; break;
|
||||||
|
case '\l': subs = "\\l"; break;
|
||||||
case '\n': subs = "\\n"; break;
|
case '\n': subs = "\\n"; break;
|
||||||
case '\t': subs = "\\t"; break;
|
case '\t': subs = "\\t"; break;
|
||||||
default: break;
|
default: break;
|
||||||
@@ -175,7 +178,7 @@ std::string toString( unsigned long long value ) {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
#endif
|
#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";
|
||||||
|
@@ -27,7 +27,7 @@ namespace Catch {
|
|||||||
unsigned int const buildNumber;
|
unsigned int const buildNumber;
|
||||||
|
|
||||||
friend std::ostream& operator << ( std::ostream& os, Version const& version );
|
friend std::ostream& operator << ( std::ostream& os, Version const& version );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void operator=( Version const& );
|
void operator=( Version const& );
|
||||||
};
|
};
|
||||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 2, 1, "develop", 15 );
|
Version libraryVersion( 2, 0, 0, "develop", 2 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,9 +19,9 @@ namespace Catch
|
|||||||
WildcardAtEnd = 2,
|
WildcardAtEnd = 2,
|
||||||
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
|
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
|
WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
|
||||||
: m_caseSensitivity( caseSensitivity ),
|
: m_caseSensitivity( caseSensitivity ),
|
||||||
m_wildcard( NoWildcard ),
|
m_wildcard( NoWildcard ),
|
||||||
@@ -48,7 +48,7 @@ namespace Catch
|
|||||||
case WildcardAtBothEnds:
|
case WildcardAtBothEnds:
|
||||||
return contains( adjustCase( str ), m_pattern );
|
return contains( adjustCase( str ), m_pattern );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
|
@@ -22,23 +22,23 @@ namespace Catch {
|
|||||||
class XmlEncode {
|
class XmlEncode {
|
||||||
public:
|
public:
|
||||||
enum ForWhat { ForTextNodes, ForAttributes };
|
enum ForWhat { ForTextNodes, ForAttributes };
|
||||||
|
|
||||||
XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
|
XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
|
||||||
: m_str( str ),
|
: m_str( str ),
|
||||||
m_forWhat( forWhat )
|
m_forWhat( forWhat )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void encodeTo( std::ostream& os ) const {
|
void encodeTo( std::ostream& os ) const {
|
||||||
|
|
||||||
// Apostrophe escaping not necessary if we always use " to write attributes
|
// Apostrophe escaping not necessary if we always use " to write attributes
|
||||||
// (see: http://www.w3.org/TR/xml/#syntax)
|
// (see: http://www.w3.org/TR/xml/#syntax)
|
||||||
|
|
||||||
for( std::size_t i = 0; i < m_str.size(); ++ i ) {
|
for( std::size_t i = 0; i < m_str.size(); ++ i ) {
|
||||||
char c = m_str[i];
|
char c = m_str[i];
|
||||||
switch( c ) {
|
switch( c ) {
|
||||||
case '<': os << "<"; break;
|
case '<': os << "<"; break;
|
||||||
case '&': os << "&"; break;
|
case '&': os << "&"; break;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
// See: http://www.w3.org/TR/xml/#syntax
|
// See: http://www.w3.org/TR/xml/#syntax
|
||||||
if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
|
if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
|
||||||
@@ -46,14 +46,14 @@ namespace Catch {
|
|||||||
else
|
else
|
||||||
os << c;
|
os << c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\"':
|
case '\"':
|
||||||
if( m_forWhat == ForAttributes )
|
if( m_forWhat == ForAttributes )
|
||||||
os << """;
|
os << """;
|
||||||
else
|
else
|
||||||
os << c;
|
os << c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Escape control chars - based on contribution by @espenalb in PR #465
|
// Escape control chars - based on contribution by @espenalb in PR #465
|
||||||
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
||||||
@@ -68,12 +68,12 @@ namespace Catch {
|
|||||||
xmlEncode.encodeTo( os );
|
xmlEncode.encodeTo( os );
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_str;
|
std::string m_str;
|
||||||
ForWhat m_forWhat;
|
ForWhat m_forWhat;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XmlWriter {
|
class XmlWriter {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@@ -230,18 +230,18 @@ namespace Catch {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TestEventListenerBase : StreamingReporterBase {
|
struct TestEventListenerBase : StreamingReporterBase {
|
||||||
TestEventListenerBase( ReporterConfig const& _config )
|
TestEventListenerBase( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config )
|
: StreamingReporterBase( _config )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
||||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
|
virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||||
|
@@ -104,7 +104,7 @@ namespace Catch {
|
|||||||
SectionNode const& rootSection = *testCaseNode.children.front();
|
SectionNode const& rootSection = *testCaseNode.children.front();
|
||||||
|
|
||||||
std::string className = stats.testInfo.className;
|
std::string className = stats.testInfo.className;
|
||||||
|
|
||||||
if( className.empty() ) {
|
if( className.empty() ) {
|
||||||
if( rootSection.childSections.empty() )
|
if( rootSection.childSections.empty() )
|
||||||
className = "global";
|
className = "global";
|
||||||
@@ -118,7 +118,7 @@ namespace Catch {
|
|||||||
std::string name = trim( sectionNode.stats.sectionInfo.name );
|
std::string name = trim( sectionNode.stats.sectionInfo.name );
|
||||||
if( !rootName.empty() )
|
if( !rootName.empty() )
|
||||||
name = rootName + "/" + name;
|
name = rootName + "/" + name;
|
||||||
|
|
||||||
if( !sectionNode.assertions.empty() ||
|
if( !sectionNode.assertions.empty() ||
|
||||||
!sectionNode.stdOut.empty() ||
|
!sectionNode.stdOut.empty() ||
|
||||||
!sectionNode.stdErr.empty() ) {
|
!sectionNode.stdErr.empty() ) {
|
||||||
@@ -187,7 +187,7 @@ namespace Catch {
|
|||||||
elementName = "internalError";
|
elementName = "internalError";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter::ScopedElement e = xml.scopedElement( elementName );
|
XmlWriter::ScopedElement e = xml.scopedElement( elementName );
|
||||||
|
|
||||||
xml.writeAttribute( "message", result.getExpandedExpression() );
|
xml.writeAttribute( "message", result.getExpandedExpression() );
|
||||||
@@ -216,7 +216,7 @@ namespace Catch {
|
|||||||
unsigned int unexpectedExceptions;
|
unsigned int unexpectedExceptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
@@ -15,18 +15,18 @@ namespace Catch {
|
|||||||
class MultipleReporters : public SharedImpl<IStreamingReporter> {
|
class MultipleReporters : public SharedImpl<IStreamingReporter> {
|
||||||
typedef std::vector<Ptr<IStreamingReporter> > Reporters;
|
typedef std::vector<Ptr<IStreamingReporter> > Reporters;
|
||||||
Reporters m_reporters;
|
Reporters m_reporters;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void add( Ptr<IStreamingReporter> const& reporter ) {
|
void add( Ptr<IStreamingReporter> const& reporter ) {
|
||||||
m_reporters.push_back( reporter );
|
m_reporters.push_back( reporter );
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // IStreamingReporter
|
public: // IStreamingReporter
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
return m_reporters[0]->getPreferences();
|
return m_reporters[0]->getPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
||||||
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@@ -34,7 +34,7 @@ public: // IStreamingReporter
|
|||||||
(*it)->noMatchingTestCases( spec );
|
(*it)->noMatchingTestCases( spec );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
|
virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
|
||||||
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@@ -49,7 +49,7 @@ public: // IStreamingReporter
|
|||||||
(*it)->testGroupStarting( groupInfo );
|
(*it)->testGroupStarting( groupInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@@ -64,7 +64,7 @@ public: // IStreamingReporter
|
|||||||
(*it)->sectionStarting( sectionInfo );
|
(*it)->sectionStarting( sectionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
|
virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
|
||||||
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@@ -72,7 +72,7 @@ public: // IStreamingReporter
|
|||||||
(*it)->assertionStarting( assertionInfo );
|
(*it)->assertionStarting( assertionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The return value indicates if the messages buffer should be cleared:
|
// The return value indicates if the messages buffer should be cleared:
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
bool clearBuffer = false;
|
bool clearBuffer = false;
|
||||||
@@ -111,7 +111,7 @@ public: // IStreamingReporter
|
|||||||
(*it)->testRunEnded( testRunStats );
|
(*it)->testRunEnded( testRunStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@@ -122,7 +122,7 @@ public: // IStreamingReporter
|
|||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
||||||
Ptr<IStreamingReporter> resultingReporter;
|
Ptr<IStreamingReporter> resultingReporter;
|
||||||
|
|
||||||
if( existingReporter ) {
|
if( existingReporter ) {
|
||||||
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
||||||
if( !multi ) {
|
if( !multi ) {
|
||||||
@@ -137,11 +137,11 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
resultingReporter = additionalReporter;
|
resultingReporter = additionalReporter;
|
||||||
|
|
||||||
return resultingReporter;
|
return resultingReporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct TeamCityReporter : StreamingReporterBase {
|
struct TeamCityReporter : StreamingReporterBase {
|
||||||
TeamCityReporter( ReporterConfig const& _config )
|
TeamCityReporter( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config ),
|
: StreamingReporterBase( _config ),
|
||||||
@@ -32,7 +32,7 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
m_reporterPrefs.shouldRedirectStdOut = true;
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string escape( std::string const& str ) {
|
static std::string escape( std::string const& str ) {
|
||||||
std::string escaped = str;
|
std::string escaped = str;
|
||||||
replaceInPlace( escaped, "|", "||" );
|
replaceInPlace( escaped, "|", "||" );
|
||||||
@@ -58,9 +58,9 @@ namespace Catch {
|
|||||||
stream << " message='test skipped because it didn|'t match the test spec'";
|
stream << " message='test skipped because it didn|'t match the test spec'";
|
||||||
stream << "]\n";
|
stream << "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {}
|
virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupStarting( groupInfo );
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
stream << "##teamcity[testSuiteStarted name='"
|
stream << "##teamcity[testSuiteStarted name='"
|
||||||
@@ -72,21 +72,21 @@ namespace Catch {
|
|||||||
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
AssertionResult const& result = assertionStats.assertionResult;
|
AssertionResult const& result = assertionStats.assertionResult;
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
|
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
if( !m_headerPrintedForThisSection )
|
if( !m_headerPrintedForThisSection )
|
||||||
printSectionHeader( msg );
|
printSectionHeader( msg );
|
||||||
m_headerPrintedForThisSection = true;
|
m_headerPrintedForThisSection = true;
|
||||||
|
|
||||||
msg << result.getSourceInfo() << "\n";
|
msg << result.getSourceInfo() << "\n";
|
||||||
|
|
||||||
switch( result.getResultType() ) {
|
switch( result.getResultType() ) {
|
||||||
case ResultWas::ExpressionFailed:
|
case ResultWas::ExpressionFailed:
|
||||||
msg << "expression failed";
|
msg << "expression failed";
|
||||||
@@ -125,15 +125,15 @@ namespace Catch {
|
|||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it )
|
++it )
|
||||||
msg << "\n \"" << it->message << "\"";
|
msg << "\n \"" << it->message << "\"";
|
||||||
|
|
||||||
|
|
||||||
if( result.hasExpression() ) {
|
if( result.hasExpression() ) {
|
||||||
msg <<
|
msg <<
|
||||||
"\n " << result.getExpressionInMacro() << "\n"
|
"\n " << result.getExpressionInMacro() << "\n"
|
||||||
"with expansion:\n" <<
|
"with expansion:\n" <<
|
||||||
" " << result.getExpandedExpression() << "\n";
|
" " << result.getExpandedExpression() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << "##teamcity[testFailed"
|
stream << "##teamcity[testFailed"
|
||||||
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
|
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
|
||||||
<< " message='" << escape( msg.str() ) << "'"
|
<< " message='" << escape( msg.str() ) << "'"
|
||||||
@@ -141,7 +141,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_headerPrintedForThisSection = false;
|
m_headerPrintedForThisSection = false;
|
||||||
StreamingReporterBase::sectionStarting( sectionInfo );
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
@@ -152,7 +152,7 @@ namespace Catch {
|
|||||||
stream << "##teamcity[testStarted name='"
|
stream << "##teamcity[testStarted name='"
|
||||||
<< escape( testInfo.name ) << "']\n";
|
<< escape( testInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( testCaseStats );
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
if( !testCaseStats.stdOut.empty() )
|
if( !testCaseStats.stdOut.empty() )
|
||||||
@@ -181,9 +181,9 @@ namespace Catch {
|
|||||||
printHeaderString( os, it->name );
|
printHeaderString( os, it->name );
|
||||||
os << getLineOfChars<'-'>() << "\n";
|
os << getLineOfChars<'-'>() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
||||||
|
|
||||||
if( !lineInfo.empty() )
|
if( !lineInfo.empty() )
|
||||||
os << lineInfo << "\n";
|
os << lineInfo << "\n";
|
||||||
os << getLineOfChars<'.'>() << "\n\n";
|
os << getLineOfChars<'.'>() << "\n\n";
|
||||||
@@ -203,15 +203,15 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool m_headerPrintedForThisSection;
|
bool m_headerPrintedForThisSection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CATCH_IMPL
|
#ifdef CATCH_IMPL
|
||||||
TeamCityReporter::~TeamCityReporter() {}
|
TeamCityReporter::~TeamCityReporter() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
@@ -26,7 +26,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual ~XmlReporter() CATCH_OVERRIDE;
|
virtual ~XmlReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as an XML document";
|
return "Reports test results as an XML document";
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
||||||
|
|
||||||
// Print any info messages in <Info> tags.
|
// Print any info messages in <Info> tags.
|
||||||
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
||||||
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||||
@@ -134,10 +134,10 @@ namespace Catch {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( assertionResult.hasExpression() )
|
if( assertionResult.hasExpression() )
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ namespace Catch {
|
|||||||
.writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
|
.writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testRunEnded( testRunStats );
|
StreamingReporterBase::testRunEnded( testRunStats );
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
|
@@ -22,7 +22,7 @@ set(SOURCES
|
|||||||
${SELF_TEST_DIR}/GeneratorTests.cpp
|
${SELF_TEST_DIR}/GeneratorTests.cpp
|
||||||
${SELF_TEST_DIR}/MessageTests.cpp
|
${SELF_TEST_DIR}/MessageTests.cpp
|
||||||
${SELF_TEST_DIR}/MiscTests.cpp
|
${SELF_TEST_DIR}/MiscTests.cpp
|
||||||
${SELF_TEST_DIR}/SectionTrackerTests.cpp
|
${SELF_TEST_DIR}/PartTrackerTests.cpp
|
||||||
${SELF_TEST_DIR}/TestMain.cpp
|
${SELF_TEST_DIR}/TestMain.cpp
|
||||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||||
|
@@ -16,7 +16,7 @@ TEST_CASE
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
double d = 1.23;
|
double d = 1.23;
|
||||||
|
|
||||||
REQUIRE( d == Approx( 1.23 ) );
|
REQUIRE( d == Approx( 1.23 ) );
|
||||||
REQUIRE( d != Approx( 1.22 ) );
|
REQUIRE( d != Approx( 1.22 ) );
|
||||||
REQUIRE( d != Approx( 1.24 ) );
|
REQUIRE( d != Approx( 1.24 ) );
|
||||||
@@ -34,7 +34,7 @@ TEST_CASE
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
double d = 1.23;
|
double d = 1.23;
|
||||||
|
|
||||||
REQUIRE( d != Approx( 1.231 ) );
|
REQUIRE( d != Approx( 1.231 ) );
|
||||||
REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) );
|
REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) );
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ TEST_CASE
|
|||||||
const double dZero = 0;
|
const double dZero = 0;
|
||||||
const double dSmall = 0.00001;
|
const double dSmall = 0.00001;
|
||||||
const double dMedium = 1.234;
|
const double dMedium = 1.234;
|
||||||
|
|
||||||
REQUIRE( 1.0f == Approx( 1 ) );
|
REQUIRE( 1.0f == Approx( 1 ) );
|
||||||
REQUIRE( 0 == Approx( dZero) );
|
REQUIRE( 0 == Approx( dZero) );
|
||||||
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) );
|
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) );
|
||||||
@@ -87,14 +87,14 @@ TEST_CASE
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
double d = 1.23;
|
double d = 1.23;
|
||||||
|
|
||||||
Approx approx = Approx::custom().epsilon( 0.005 );
|
Approx approx = Approx::custom().epsilon( 0.005 );
|
||||||
|
|
||||||
REQUIRE( d == approx( 1.23 ) );
|
REQUIRE( d == approx( 1.23 ) );
|
||||||
REQUIRE( d == approx( 1.22 ) );
|
REQUIRE( d == approx( 1.22 ) );
|
||||||
REQUIRE( d == approx( 1.24 ) );
|
REQUIRE( d == approx( 1.24 ) );
|
||||||
REQUIRE( d != approx( 1.25 ) );
|
REQUIRE( d != approx( 1.25 ) );
|
||||||
|
|
||||||
REQUIRE( approx( d ) == 1.23 );
|
REQUIRE( approx( d ) == 1.23 );
|
||||||
REQUIRE( approx( d ) == 1.22 );
|
REQUIRE( approx( d ) == 1.22 );
|
||||||
REQUIRE( approx( d ) == 1.24 );
|
REQUIRE( approx( d ) == 1.24 );
|
||||||
|
@@ -30,13 +30,13 @@ SCENARIO( "Vector resizing affects size and capacity", "[vector][bdd][size][capa
|
|||||||
GIVEN( "an empty vector" ) {
|
GIVEN( "an empty vector" ) {
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
REQUIRE( v.size() == 0 );
|
REQUIRE( v.size() == 0 );
|
||||||
|
|
||||||
WHEN( "it is made larger" ) {
|
WHEN( "it is made larger" ) {
|
||||||
v.resize( 10 );
|
v.resize( 10 );
|
||||||
THEN( "the size and capacity go up" ) {
|
THEN( "the size and capacity go up" ) {
|
||||||
REQUIRE( v.size() == 10 );
|
REQUIRE( v.size() == 10 );
|
||||||
REQUIRE( v.capacity() >= 10 );
|
REQUIRE( v.capacity() >= 10 );
|
||||||
|
|
||||||
AND_WHEN( "it is made smaller again" ) {
|
AND_WHEN( "it is made smaller again" ) {
|
||||||
v.resize( 5 );
|
v.resize( 5 );
|
||||||
THEN( "the size goes down but the capacity stays the same" ) {
|
THEN( "the size goes down but the capacity stays the same" ) {
|
||||||
@@ -46,7 +46,7 @@ SCENARIO( "Vector resizing affects size and capacity", "[vector][bdd][size][capa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WHEN( "we reserve more space" ) {
|
WHEN( "we reserve more space" ) {
|
||||||
v.reserve( 10 );
|
v.reserve( 10 );
|
||||||
THEN( "The capacity is increased but the size remains the same" ) {
|
THEN( "The capacity is increased but the size remains the same" ) {
|
||||||
@@ -76,19 +76,19 @@ struct Fixture
|
|||||||
: d_counter(0)
|
: d_counter(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int counter()
|
int counter()
|
||||||
{
|
{
|
||||||
return d_counter++;
|
return d_counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int d_counter;
|
int d_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCENARIO_METHOD(Fixture,
|
SCENARIO_METHOD(Fixture,
|
||||||
"BDD tests requiring Fixtures to provide commonly-accessed data or methods",
|
"BDD tests requiring Fixtures to provide commonly-accessed data or methods",
|
||||||
"[bdd][fixtures]") {
|
"[bdd][fixtures]") {
|
||||||
const int before(counter());
|
const int before(counter());
|
||||||
GIVEN("No operations precede me") {
|
GIVEN("No operations precede me") {
|
||||||
|
@@ -356,7 +356,7 @@ due to unexpected exception with message:
|
|||||||
expected exception
|
expected exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Unexpected custom exceptions can be translated
|
Non-std exceptions can be translated
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
@@ -365,6 +365,16 @@ ExceptionTests.cpp:<line number>: FAILED:
|
|||||||
due to unexpected exception with message:
|
due to unexpected exception with message:
|
||||||
custom exception
|
custom exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Custom std-exceptions can be custom translated
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
custom std exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Custom exceptions can be translated when testing for nothrow
|
Custom exceptions can be translated when testing for nothrow
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -494,27 +504,7 @@ explicitly with message:
|
|||||||
Message from section two
|
Message from section two
|
||||||
|
|
||||||
Message from section one
|
Message from section one
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Standard output from all sections is reported
|
|
||||||
one
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
MessageTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
|
|
||||||
No assertions in section 'one'
|
|
||||||
|
|
||||||
Message from section two
|
Message from section two
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Standard output from all sections is reported
|
|
||||||
two
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
MessageTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
|
|
||||||
No assertions in section 'two'
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
SCOPED_INFO is reset for each loop
|
SCOPED_INFO is reset for each loop
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -690,7 +680,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() Contains( "not there" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "not there"
|
"this string contains 'abc' as a substring" contains: "not there"
|
||||||
|
|
||||||
@@ -701,7 +691,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() StartsWith( "string" ) )
|
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "string"
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
|
|
||||||
@@ -712,7 +702,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() EndsWith( "this" ) )
|
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ends with: "this"
|
"this string contains 'abc' as a substring" ends with: "this"
|
||||||
|
|
||||||
@@ -723,10 +713,33 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() Equals( "something else" ) )
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" equals: "something else"
|
"this string contains 'abc' as a substring" equals: "something else"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Matchers can be composed with both && and || - failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
||||||
|
contains: "different" ) and contains: "random" )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Matchers can be negated (Not) with the ! operator - failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" not contains: "substring"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Nice descriptive name
|
Nice descriptive name
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -817,6 +830,6 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 159 | 118 passed | 40 failed | 1 failed as expected
|
test cases: 165 | 122 passed | 42 failed | 1 failed as expected
|
||||||
assertions: 907 | 812 passed | 82 failed | 13 failed as expected
|
assertions: 768 | 672 passed | 83 failed | 13 failed as expected
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CatchSelfTest" errors="12" failures="68" tests="905" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="CatchSelfTest" errors="13" failures="72" tests="770" 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}"/>
|
||||||
@@ -226,9 +226,15 @@ expected exception
|
|||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</error>
|
</error>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Unexpected custom exceptions can be translated" time="{duration}">
|
<testcase classname="global" name="Non-std exceptions can be translated" time="{duration}">
|
||||||
<error type="TEST_CASE">
|
<error type="TEST_CASE">
|
||||||
custom exception
|
custom exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Custom std-exceptions can be custom translated" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
custom std exception
|
||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</error>
|
</error>
|
||||||
</testcase>
|
</testcase>
|
||||||
@@ -259,8 +265,6 @@ ExceptionTests.cpp:<line number>
|
|||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<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="INFO and WARN do not abort tests" time="{duration}"/>
|
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
||||||
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
||||||
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
|
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
|
||||||
@@ -438,6 +442,20 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
|
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
|
||||||
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
||||||
<testcase classname="global" name="Equals" time="{duration}"/>
|
<testcase classname="global" name="Equals" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be composed with both && and ||" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be composed with both && and || - failing" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" )" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator - failing" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" not contains: "substring"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
|
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
|
||||||
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
|
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
|
||||||
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
|
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
|
||||||
@@ -527,6 +545,7 @@ hello
|
|||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
|
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
|
||||||
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
|
||||||
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
||||||
<testcase classname="global" name="Where there is more to the expression after the RHS" time="{duration}"/>
|
<testcase classname="global" name="Where there is more to the expression after the RHS" time="{duration}"/>
|
||||||
<testcase classname="global" name="Where the LHS is not a simple value" time="{duration}"/>
|
<testcase classname="global" name="Where the LHS is not a simple value" time="{duration}"/>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -13,18 +13,18 @@ namespace
|
|||||||
class TestClass
|
class TestClass
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestClass()
|
TestClass()
|
||||||
: s( "hello" )
|
: s( "hello" )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void succeedingCase()
|
void succeedingCase()
|
||||||
{
|
{
|
||||||
REQUIRE( s == "hello" );
|
REQUIRE( s == "hello" );
|
||||||
}
|
}
|
||||||
void failingCase()
|
void failingCase()
|
||||||
{
|
{
|
||||||
REQUIRE( s == "world" );
|
REQUIRE( s == "world" );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -38,20 +38,20 @@ METHOD_AS_TEST_CASE( TestClass::failingCase, "A METHOD_AS_TEST_CASE based test r
|
|||||||
struct Fixture
|
struct Fixture
|
||||||
{
|
{
|
||||||
Fixture() : m_a( 1 ) {}
|
Fixture() : m_a( 1 ) {}
|
||||||
|
|
||||||
int m_a;
|
int m_a;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" )
|
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" )
|
||||||
{
|
{
|
||||||
REQUIRE( m_a == 1 );
|
REQUIRE( m_a == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should be able to write our tests within a different namespace
|
// We should be able to write our tests within a different namespace
|
||||||
namespace Inner
|
namespace Inner
|
||||||
{
|
{
|
||||||
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" )
|
TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" )
|
||||||
{
|
{
|
||||||
REQUIRE( m_a == 2 );
|
REQUIRE( m_a == 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ struct TestData {
|
|||||||
float_nine_point_one( 9.1f ),
|
float_nine_point_one( 9.1f ),
|
||||||
double_pi( 3.1415926535 )
|
double_pi( 3.1415926535 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int int_seven;
|
int int_seven;
|
||||||
std::string str_hello;
|
std::string str_hello;
|
||||||
float float_nine_point_one;
|
float float_nine_point_one;
|
||||||
@@ -37,7 +37,7 @@ struct TestDef {
|
|||||||
TestDef& operator[]( const std::string& ) {
|
TestDef& operator[]( const std::string& ) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The "failing" tests all use the CHECK macro, which continues if the specific test fails.
|
// The "failing" tests all use the CHECK macro, which continues if the specific test fails.
|
||||||
@@ -49,14 +49,14 @@ TEST_CASE( "Equality checks that should succeed", "" )
|
|||||||
|
|
||||||
TestDef td;
|
TestDef td;
|
||||||
td + "hello" + "hello";
|
td + "hello" + "hello";
|
||||||
|
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
REQUIRE( data.int_seven == 7 );
|
REQUIRE( data.int_seven == 7 );
|
||||||
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) );
|
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) );
|
||||||
REQUIRE( data.double_pi == Approx( 3.1415926535 ) );
|
REQUIRE( data.double_pi == Approx( 3.1415926535 ) );
|
||||||
REQUIRE( data.str_hello == "hello" );
|
REQUIRE( data.str_hello == "hello" );
|
||||||
REQUIRE( "hello" == data.str_hello );
|
REQUIRE( "hello" == data.str_hello );
|
||||||
REQUIRE( data.str_hello.size() == 5 );
|
REQUIRE( data.str_hello.size() == 5 );
|
||||||
|
|
||||||
double x = 1.1 + 0.1 + 0.1;
|
double x = 1.1 + 0.1 + 0.1;
|
||||||
@@ -66,7 +66,7 @@ TEST_CASE( "Equality checks that should succeed", "" )
|
|||||||
TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
|
TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
|
||||||
{
|
{
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
CHECK( data.int_seven == 6 );
|
CHECK( data.int_seven == 6 );
|
||||||
CHECK( data.int_seven == 8 );
|
CHECK( data.int_seven == 8 );
|
||||||
CHECK( data.int_seven == 0 );
|
CHECK( data.int_seven == 0 );
|
||||||
@@ -87,7 +87,7 @@ TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
|
|||||||
TEST_CASE( "Inequality checks that should succeed", "" )
|
TEST_CASE( "Inequality checks that should succeed", "" )
|
||||||
{
|
{
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
REQUIRE( data.int_seven != 6 );
|
REQUIRE( data.int_seven != 6 );
|
||||||
REQUIRE( data.int_seven != 8 );
|
REQUIRE( data.int_seven != 8 );
|
||||||
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) );
|
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) );
|
||||||
@@ -104,7 +104,7 @@ TEST_CASE( "Inequality checks that should succeed", "" )
|
|||||||
TEST_CASE( "Inequality checks that should fail", "[.][failing]" )
|
TEST_CASE( "Inequality checks that should fail", "[.][failing]" )
|
||||||
{
|
{
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
CHECK( data.int_seven != 7 );
|
CHECK( data.int_seven != 7 );
|
||||||
CHECK( data.float_nine_point_one != Approx( 9.1f ) );
|
CHECK( data.float_nine_point_one != Approx( 9.1f ) );
|
||||||
CHECK( data.double_pi != Approx( 3.1415926535 ) );
|
CHECK( data.double_pi != Approx( 3.1415926535 ) );
|
||||||
@@ -116,7 +116,7 @@ TEST_CASE( "Inequality checks that should fail", "[.][failing]" )
|
|||||||
TEST_CASE( "Ordering comparison checks that should succeed", "" )
|
TEST_CASE( "Ordering comparison checks that should succeed", "" )
|
||||||
{
|
{
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
REQUIRE( data.int_seven < 8 );
|
REQUIRE( data.int_seven < 8 );
|
||||||
REQUIRE( data.int_seven > 6 );
|
REQUIRE( data.int_seven > 6 );
|
||||||
REQUIRE( data.int_seven > 0 );
|
REQUIRE( data.int_seven > 0 );
|
||||||
@@ -126,14 +126,14 @@ TEST_CASE( "Ordering comparison checks that should succeed", "" )
|
|||||||
REQUIRE( data.int_seven >= 6 );
|
REQUIRE( data.int_seven >= 6 );
|
||||||
REQUIRE( data.int_seven <= 7 );
|
REQUIRE( data.int_seven <= 7 );
|
||||||
REQUIRE( data.int_seven <= 8 );
|
REQUIRE( data.int_seven <= 8 );
|
||||||
|
|
||||||
REQUIRE( data.float_nine_point_one > 9 );
|
REQUIRE( data.float_nine_point_one > 9 );
|
||||||
REQUIRE( data.float_nine_point_one < 10 );
|
REQUIRE( data.float_nine_point_one < 10 );
|
||||||
REQUIRE( data.float_nine_point_one < 9.2 );
|
REQUIRE( data.float_nine_point_one < 9.2 );
|
||||||
|
|
||||||
REQUIRE( data.str_hello <= "hello" );
|
REQUIRE( data.str_hello <= "hello" );
|
||||||
REQUIRE( data.str_hello >= "hello" );
|
REQUIRE( data.str_hello >= "hello" );
|
||||||
|
|
||||||
REQUIRE( data.str_hello < "hellp" );
|
REQUIRE( data.str_hello < "hellp" );
|
||||||
REQUIRE( data.str_hello < "zebra" );
|
REQUIRE( data.str_hello < "zebra" );
|
||||||
REQUIRE( data.str_hello > "hellm" );
|
REQUIRE( data.str_hello > "hellm" );
|
||||||
@@ -143,7 +143,7 @@ TEST_CASE( "Ordering comparison checks that should succeed", "" )
|
|||||||
TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
|
TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
|
||||||
{
|
{
|
||||||
TestData data;
|
TestData data;
|
||||||
|
|
||||||
CHECK( data.int_seven > 7 );
|
CHECK( data.int_seven > 7 );
|
||||||
CHECK( data.int_seven < 7 );
|
CHECK( data.int_seven < 7 );
|
||||||
CHECK( data.int_seven > 8 );
|
CHECK( data.int_seven > 8 );
|
||||||
@@ -153,11 +153,11 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
|
|||||||
|
|
||||||
CHECK( data.int_seven >= 8 );
|
CHECK( data.int_seven >= 8 );
|
||||||
CHECK( data.int_seven <= 6 );
|
CHECK( data.int_seven <= 6 );
|
||||||
|
|
||||||
CHECK( data.float_nine_point_one < 9 );
|
CHECK( data.float_nine_point_one < 9 );
|
||||||
CHECK( data.float_nine_point_one > 10 );
|
CHECK( data.float_nine_point_one > 10 );
|
||||||
CHECK( data.float_nine_point_one > 9.2 );
|
CHECK( data.float_nine_point_one > 9.2 );
|
||||||
|
|
||||||
CHECK( data.str_hello > "hello" );
|
CHECK( data.str_hello > "hello" );
|
||||||
CHECK( data.str_hello < "hello" );
|
CHECK( data.str_hello < "hello" );
|
||||||
CHECK( data.str_hello > "hellp" );
|
CHECK( data.str_hello > "hellp" );
|
||||||
@@ -178,7 +178,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne
|
|||||||
unsigned long ul = 4;
|
unsigned long ul = 4;
|
||||||
char c = 5;
|
char c = 5;
|
||||||
unsigned char uc = 6;
|
unsigned char uc = 6;
|
||||||
|
|
||||||
REQUIRE( i == 1 );
|
REQUIRE( i == 1 );
|
||||||
REQUIRE( ui == 2 );
|
REQUIRE( ui == 2 );
|
||||||
REQUIRE( l == 3 );
|
REQUIRE( l == 3 );
|
||||||
@@ -215,7 +215,7 @@ TEST_CASE( "comparisons between int variables", "" )
|
|||||||
unsigned short unsigned_short_var = 1;
|
unsigned short unsigned_short_var = 1;
|
||||||
unsigned int unsigned_int_var = 1;
|
unsigned int unsigned_int_var = 1;
|
||||||
unsigned long unsigned_long_var = 1L;
|
unsigned long unsigned_long_var = 1L;
|
||||||
|
|
||||||
REQUIRE( long_var == unsigned_char_var );
|
REQUIRE( long_var == unsigned_char_var );
|
||||||
REQUIRE( long_var == unsigned_short_var );
|
REQUIRE( long_var == unsigned_short_var );
|
||||||
REQUIRE( long_var == unsigned_int_var );
|
REQUIRE( long_var == unsigned_int_var );
|
||||||
@@ -252,7 +252,7 @@ template<typename T>
|
|||||||
struct Ex
|
struct Ex
|
||||||
{
|
{
|
||||||
Ex( T ){}
|
Ex( T ){}
|
||||||
|
|
||||||
bool operator == ( const T& ) const { return true; }
|
bool operator == ( const T& ) const { return true; }
|
||||||
T operator * ( const T& ) const { return T(); }
|
T operator * ( const T& ) const { return T(); }
|
||||||
};
|
};
|
||||||
@@ -273,13 +273,13 @@ TEST_CASE( "Pointers can be compared to null", "" )
|
|||||||
{
|
{
|
||||||
TestData* p = CATCH_NULL;
|
TestData* p = CATCH_NULL;
|
||||||
TestData* pNULL = CATCH_NULL;
|
TestData* pNULL = CATCH_NULL;
|
||||||
|
|
||||||
REQUIRE( p == CATCH_NULL );
|
REQUIRE( p == CATCH_NULL );
|
||||||
REQUIRE( p == pNULL );
|
REQUIRE( p == pNULL );
|
||||||
|
|
||||||
TestData data;
|
TestData data;
|
||||||
p = &data;
|
p = &data;
|
||||||
|
|
||||||
REQUIRE( p != CATCH_NULL );
|
REQUIRE( p != CATCH_NULL );
|
||||||
|
|
||||||
const TestData* cp = p;
|
const TestData* cp = p;
|
||||||
@@ -290,7 +290,7 @@ TEST_CASE( "Pointers can be compared to null", "" )
|
|||||||
|
|
||||||
REQUIRE( returnsNull() == CATCH_NULL );
|
REQUIRE( returnsNull() == CATCH_NULL );
|
||||||
REQUIRE( returnsConstNull() == CATCH_NULL );
|
REQUIRE( returnsConstNull() == CATCH_NULL );
|
||||||
|
|
||||||
REQUIRE( CATCH_NULL != p );
|
REQUIRE( CATCH_NULL != p );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ TEST_CASE( "Pointers can be compared to null", "" )
|
|||||||
TEST_CASE( "'Not' checks that should succeed", "" )
|
TEST_CASE( "'Not' checks that should succeed", "" )
|
||||||
{
|
{
|
||||||
bool falseValue = false;
|
bool falseValue = false;
|
||||||
|
|
||||||
REQUIRE( false == false );
|
REQUIRE( false == false );
|
||||||
REQUIRE( true == true );
|
REQUIRE( true == true );
|
||||||
REQUIRE( !false );
|
REQUIRE( !false );
|
||||||
@@ -320,15 +320,15 @@ TEST_CASE( "'Not' checks that should succeed", "" )
|
|||||||
TEST_CASE( "'Not' checks that should fail", "[.][failing]" )
|
TEST_CASE( "'Not' checks that should fail", "[.][failing]" )
|
||||||
{
|
{
|
||||||
bool trueValue = true;
|
bool trueValue = true;
|
||||||
|
|
||||||
CHECK( false != false );
|
CHECK( false != false );
|
||||||
CHECK( true != true );
|
CHECK( true != true );
|
||||||
CHECK( !true );
|
CHECK( !true );
|
||||||
CHECK_FALSE( true );
|
CHECK_FALSE( true );
|
||||||
|
|
||||||
CHECK( !trueValue );
|
CHECK( !trueValue );
|
||||||
CHECK_FALSE( trueValue );
|
CHECK_FALSE( trueValue );
|
||||||
|
|
||||||
CHECK( !(1 == 1) );
|
CHECK( !(1 == 1) );
|
||||||
CHECK_FALSE( 1 == 1 );
|
CHECK_FALSE( 1 == 1 );
|
||||||
}
|
}
|
||||||
|
@@ -96,6 +96,23 @@ public:
|
|||||||
CustomException( const std::string& msg )
|
CustomException( const std::string& msg )
|
||||||
: m_msg( msg )
|
: m_msg( msg )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
std::string getMessage() const
|
||||||
|
{
|
||||||
|
return m_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CustomStdException : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CustomStdException( const std::string& msg )
|
||||||
|
: m_msg( msg )
|
||||||
|
{}
|
||||||
|
~CustomStdException() CATCH_NOEXCEPT {}
|
||||||
|
|
||||||
std::string getMessage() const
|
std::string getMessage() const
|
||||||
{
|
{
|
||||||
@@ -106,22 +123,34 @@ private:
|
|||||||
std::string m_msg;
|
std::string m_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
|
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
|
||||||
{
|
{
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex )
|
||||||
|
{
|
||||||
|
return ex.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
CATCH_TRANSLATE_EXCEPTION( double& ex )
|
CATCH_TRANSLATE_EXCEPTION( double& ex )
|
||||||
{
|
{
|
||||||
return Catch::toString( ex );
|
return Catch::toString( ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" )
|
TEST_CASE("Non-std exceptions can be translated", "[.][failing]" )
|
||||||
{
|
{
|
||||||
if( Catch::alwaysTrue() )
|
if( Catch::alwaysTrue() )
|
||||||
throw CustomException( "custom exception" );
|
throw CustomException( "custom exception" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing]" )
|
||||||
|
{
|
||||||
|
if( Catch::alwaysTrue() )
|
||||||
|
throw CustomException( "custom std exception" );
|
||||||
|
}
|
||||||
|
|
||||||
inline void throwCustom() {
|
inline void throwCustom() {
|
||||||
if( Catch::alwaysTrue() )
|
if( Catch::alwaysTrue() )
|
||||||
throw CustomException( "custom exception - not std" );
|
throw CustomException( "custom exception - not std" );
|
||||||
|
@@ -1,42 +1,2 @@
|
|||||||
/*
|
// The old generators have been removed
|
||||||
* Created by Phil on 28/01/2011.
|
// A new generator implementation is coming
|
||||||
* Copyright 2011 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This define means we have to prefix all the CATCH macros with CATCH_
|
|
||||||
// We're using it here to test it out
|
|
||||||
#define CATCH_CONFIG_PREFIX_ALL
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
inline int multiply( int a, int b )
|
|
||||||
{
|
|
||||||
return a*b;
|
|
||||||
}
|
|
||||||
|
|
||||||
CATCH_TEST_CASE( "Generators over two ranges", "[generators]" )
|
|
||||||
{
|
|
||||||
using namespace Catch::Generators;
|
|
||||||
|
|
||||||
int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
|
|
||||||
int j = CATCH_GENERATE( between( 100, 107 ) );
|
|
||||||
|
|
||||||
CATCH_REQUIRE( multiply( i, 2 ) == i*2 );
|
|
||||||
CATCH_REQUIRE( multiply( j, 2 ) == j*2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IntPair { int first, second; };
|
|
||||||
|
|
||||||
CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" )
|
|
||||||
{
|
|
||||||
using namespace Catch::Generators;
|
|
||||||
|
|
||||||
IntPair p[] = { { 0, 1 }, { 2, 3 } };
|
|
||||||
|
|
||||||
IntPair* i = CATCH_GENERATE( between( p, &p[1] ) );
|
|
||||||
|
|
||||||
CATCH_REQUIRE( i->first == i->second-1 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@@ -38,7 +38,7 @@ TEST_CASE( "INFO gets logged on failure, even if captured before successful asse
|
|||||||
CHECK( a == 2 );
|
CHECK( a == 2 );
|
||||||
|
|
||||||
INFO( "this message should be logged" );
|
INFO( "this message should be logged" );
|
||||||
|
|
||||||
CHECK( a == 1 );
|
CHECK( a == 1 );
|
||||||
|
|
||||||
INFO( "and this, but later" );
|
INFO( "and this, but later" );
|
||||||
@@ -85,7 +85,7 @@ TEST_CASE( "Standard output from all sections is reported", "[messages][.]" )
|
|||||||
{
|
{
|
||||||
std::cout << "Message from section one" << std::endl;
|
std::cout << "Message from section one" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "two", "" )
|
SECTION( "two", "" )
|
||||||
{
|
{
|
||||||
std::cout << "Message from section two" << std::endl;
|
std::cout << "Message from section two" << std::endl;
|
||||||
|
@@ -21,7 +21,7 @@ TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
|||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
int b = 2;
|
int b = 2;
|
||||||
|
|
||||||
SECTION( "s1", "doesn't equal" )
|
SECTION( "s1", "doesn't equal" )
|
||||||
{
|
{
|
||||||
REQUIRE( a != b );
|
REQUIRE( a != b );
|
||||||
@@ -38,7 +38,7 @@ TEST_CASE( "nested SECTION tests", "[.][sections][failing]" )
|
|||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
int b = 2;
|
int b = 2;
|
||||||
|
|
||||||
SECTION( "s1", "doesn't equal" )
|
SECTION( "s1", "doesn't equal" )
|
||||||
{
|
{
|
||||||
REQUIRE( a != b );
|
REQUIRE( a != b );
|
||||||
@@ -55,7 +55,7 @@ TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" )
|
|||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
int b = 2;
|
int b = 2;
|
||||||
|
|
||||||
SECTION( "s1", "doesn't equal" )
|
SECTION( "s1", "doesn't equal" )
|
||||||
{
|
{
|
||||||
SECTION( "s2", "equal" )
|
SECTION( "s2", "equal" )
|
||||||
@@ -82,7 +82,7 @@ TEST_CASE( "even more nested SECTION tests", "[sections]" )
|
|||||||
{
|
{
|
||||||
SUCCEED(""); // avoid failing due to no tests
|
SUCCEED(""); // avoid failing due to no tests
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "e (leaf)", "" )
|
SECTION( "e (leaf)", "" )
|
||||||
{
|
{
|
||||||
SUCCEED(""); // avoid failing due to no tests
|
SUCCEED(""); // avoid failing due to no tests
|
||||||
@@ -98,14 +98,14 @@ TEST_CASE( "even more nested SECTION tests", "[sections]" )
|
|||||||
TEST_CASE( "looped SECTION tests", "[.][failing][sections]" )
|
TEST_CASE( "looped SECTION tests", "[.][failing][sections]" )
|
||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
|
|
||||||
for( int b = 0; b < 10; ++b )
|
for( int b = 0; b < 10; ++b )
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "b is currently: " << b;
|
oss << "b is currently: " << b;
|
||||||
SECTION( "s1", oss.str() )
|
SECTION( "s1", oss.str() )
|
||||||
{
|
{
|
||||||
CHECK( b > a );
|
CHECK( b > a );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,18 +113,18 @@ TEST_CASE( "looped SECTION tests", "[.][failing][sections]" )
|
|||||||
TEST_CASE( "looped tests", "[.][failing]" )
|
TEST_CASE( "looped tests", "[.][failing]" )
|
||||||
{
|
{
|
||||||
static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
|
static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
|
||||||
|
|
||||||
for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i )
|
for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i )
|
||||||
{
|
{
|
||||||
INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" );
|
INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" );
|
||||||
CHECK( ( fib[i] % 2 ) == 0 );
|
CHECK( ( fib[i] % 2 ) == 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
|
TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
|
||||||
{
|
{
|
||||||
std::cout << "A string sent directly to stdout" << std::endl;
|
std::cout << "A string sent directly to stdout" << std::endl;
|
||||||
|
|
||||||
std::cerr << "A string sent directly to stderr" << std::endl;
|
std::cerr << "A string sent directly to stderr" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ inline bool testCheckedElse( bool flag )
|
|||||||
{
|
{
|
||||||
CHECKED_ELSE( flag )
|
CHECKED_ELSE( flag )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +191,13 @@ TEST_CASE( "xmlentitycheck", "" )
|
|||||||
TEST_CASE( "send a single char to INFO", "[failing][.]" )
|
TEST_CASE( "send a single char to INFO", "[failing][.]" )
|
||||||
{
|
{
|
||||||
INFO(3);
|
INFO(3);
|
||||||
REQUIRE(false);
|
REQUIRE(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "atomic if", "[failing][0]")
|
TEST_CASE( "atomic if", "[failing][0]")
|
||||||
{
|
{
|
||||||
size_t x = 0;
|
size_t x = 0;
|
||||||
|
|
||||||
if( x )
|
if( x )
|
||||||
REQUIRE(x > 0);
|
REQUIRE(x > 0);
|
||||||
else
|
else
|
||||||
@@ -208,10 +208,16 @@ inline const char* testStringForMatching()
|
|||||||
{
|
{
|
||||||
return "this string contains 'abc' as a substring";
|
return "this string contains 'abc' as a substring";
|
||||||
}
|
}
|
||||||
|
inline const char* testStringForMatching2()
|
||||||
|
{
|
||||||
|
return "some completely different text that contains one common word";
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
TEST_CASE("String matchers", "[matchers]" )
|
TEST_CASE("String matchers", "[matchers]" )
|
||||||
{
|
{
|
||||||
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );
|
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );
|
||||||
CHECK_THAT( testStringForMatching(), Contains( "abc" ) );
|
CHECK_THAT( testStringForMatching(), Contains( "abc" ) );
|
||||||
|
|
||||||
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) );
|
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) );
|
||||||
@@ -256,6 +262,42 @@ TEST_CASE("Equals", "[matchers]")
|
|||||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be (AllOf) composed with the && operator", "[matchers][operators][operator&&]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(),
|
||||||
|
Contains( "string" ) &&
|
||||||
|
Contains( "abc" ) &&
|
||||||
|
Contains( "substring" ) &&
|
||||||
|
Contains( "contains" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be (AnyOf) composed with the || operator", "[matchers][operators][operator||]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||||
|
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be composed with both && and ||", "[matchers][operators][operator||][operator&&]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be composed with both && and || - failing", "[matchers][operators][operator||][operator&&][.failing]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be negated (Not) with the ! operator", "[matchers][operators][not]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "different" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be negated (Not) with the ! operator - failing", "[matchers][operators][not][.failing]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline unsigned int Factorial( unsigned int number )
|
inline unsigned int Factorial( unsigned int number )
|
||||||
{
|
{
|
||||||
// return number <= 1 ? number : Factorial(number-1)*number;
|
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||||
@@ -297,38 +339,38 @@ TEST_CASE( "second tag", "[tag2]" )
|
|||||||
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
||||||
|
|
||||||
std::vector<int> v( 5 );
|
std::vector<int> v( 5 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 5 );
|
REQUIRE( v.size() == 5 );
|
||||||
REQUIRE( v.capacity() >= 5 );
|
REQUIRE( v.capacity() >= 5 );
|
||||||
|
|
||||||
SECTION( "resizing bigger changes size and capacity", "" ) {
|
SECTION( "resizing bigger changes size and capacity", "" ) {
|
||||||
v.resize( 10 );
|
v.resize( 10 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 10 );
|
REQUIRE( v.size() == 10 );
|
||||||
REQUIRE( v.capacity() >= 10 );
|
REQUIRE( v.capacity() >= 10 );
|
||||||
}
|
}
|
||||||
SECTION( "resizing smaller changes size but not capacity", "" ) {
|
SECTION( "resizing smaller changes size but not capacity", "" ) {
|
||||||
v.resize( 0 );
|
v.resize( 0 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 0 );
|
REQUIRE( v.size() == 0 );
|
||||||
REQUIRE( v.capacity() >= 5 );
|
REQUIRE( v.capacity() >= 5 );
|
||||||
|
|
||||||
SECTION( "We can use the 'swap trick' to reset the capacity", "" ) {
|
SECTION( "We can use the 'swap trick' to reset the capacity", "" ) {
|
||||||
std::vector<int> empty;
|
std::vector<int> empty;
|
||||||
empty.swap( v );
|
empty.swap( v );
|
||||||
|
|
||||||
REQUIRE( v.capacity() == 0 );
|
REQUIRE( v.capacity() == 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SECTION( "reserving bigger changes capacity but not size", "" ) {
|
SECTION( "reserving bigger changes capacity but not size", "" ) {
|
||||||
v.reserve( 10 );
|
v.reserve( 10 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 5 );
|
REQUIRE( v.size() == 5 );
|
||||||
REQUIRE( v.capacity() >= 10 );
|
REQUIRE( v.capacity() >= 10 );
|
||||||
}
|
}
|
||||||
SECTION( "reserving smaller does not change size or capacity", "" ) {
|
SECTION( "reserving smaller does not change size or capacity", "" ) {
|
||||||
v.reserve( 0 );
|
v.reserve( 0 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 5 );
|
REQUIRE( v.size() == 5 );
|
||||||
REQUIRE( v.capacity() >= 5 );
|
REQUIRE( v.capacity() >= 5 );
|
||||||
}
|
}
|
||||||
@@ -426,13 +468,15 @@ TEST_CASE( "XmlEncode" ) {
|
|||||||
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
TEST_CASE( "long long" ) {
|
TEST_CASE( "long long" ) {
|
||||||
long long l = std::numeric_limits<long long>::max();
|
long long l = std::numeric_limits<long long>::max();
|
||||||
|
|
||||||
REQUIRE( l == std::numeric_limits<long long>::max() );
|
REQUIRE( l == std::numeric_limits<long long>::max() );
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
// SECTION( "s" ) {
|
||||||
// CHECK( x == 0 );
|
// int x = 10/i; // This should cause the signal to fire
|
||||||
|
// CHECK( x == 0 );
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
|
@@ -12,13 +12,13 @@
|
|||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
class LocalContext {
|
class LocalContext {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackerContext& operator()() const {
|
TrackerContext& operator()() const {
|
||||||
return TrackerContext::instance();
|
return TrackerContext::instance();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
inline Catch::TrackerContext& C_A_T_C_H_Context() {
|
inline Catch::TrackerContext& C_A_T_C_H_Context() {
|
||||||
@@ -37,11 +37,11 @@ using namespace Catch;
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
TEST_CASE( "Tracker", "" ) {
|
TEST_CASE( "Tracker", "" ) {
|
||||||
|
|
||||||
TrackerContext ctx;
|
TrackerContext ctx;
|
||||||
ctx.startRun();
|
ctx.startRun();
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
|
|
||||||
ITracker& testCase = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase.isOpen() );
|
REQUIRE( testCase.isOpen() );
|
||||||
|
|
||||||
@@ -57,13 +57,13 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
REQUIRE( ctx.completedCycle() );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "fail one section", "" ) {
|
SECTION( "fail one section", "" ) {
|
||||||
s1.fail();
|
s1.fail();
|
||||||
REQUIRE( s1.isComplete() );
|
REQUIRE( s1.isComplete() );
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
REQUIRE( testCase.isComplete() == false );
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( ctx.completedCycle() );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||||
@@ -72,10 +72,10 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( ctx.completedCycle() );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isComplete() );
|
REQUIRE( testCase.isComplete() );
|
||||||
@@ -85,7 +85,7 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
@@ -94,19 +94,19 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
|
|
||||||
s2.close();
|
s2.close();
|
||||||
REQUIRE( ctx.completedCycle() );
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase.isComplete() );
|
REQUIRE( testCase.isComplete() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "successfully close one section, then find another", "" ) {
|
SECTION( "successfully close one section, then find another", "" ) {
|
||||||
s1.close();
|
s1.close();
|
||||||
|
|
||||||
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() == false );
|
REQUIRE( s2.isOpen() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isComplete() == false );
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
@@ -122,14 +122,14 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
REQUIRE( s2b.isOpen() );
|
REQUIRE( s2b.isOpen() );
|
||||||
|
|
||||||
REQUIRE( ctx.completedCycle() == false );
|
REQUIRE( ctx.completedCycle() == false );
|
||||||
|
|
||||||
SECTION ("Successfully close S2") {
|
SECTION ("Successfully close S2") {
|
||||||
s2b.close();
|
s2b.close();
|
||||||
REQUIRE( ctx.completedCycle() );
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() );
|
REQUIRE( s2b.isSuccessfullyCompleted() );
|
||||||
REQUIRE( testCase2.isComplete() == false );
|
REQUIRE( testCase2.isComplete() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
|
|
||||||
REQUIRE( s2b.isComplete() );
|
REQUIRE( s2b.isComplete() );
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
@@ -147,19 +147,19 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase3.isOpen() );
|
REQUIRE( testCase3.isOpen() );
|
||||||
|
|
||||||
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1c.isOpen() == false );
|
REQUIRE( s1c.isOpen() == false );
|
||||||
|
|
||||||
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2c.isOpen() == false );
|
REQUIRE( s2c.isOpen() == false );
|
||||||
|
|
||||||
testCase3.close();
|
testCase3.close();
|
||||||
REQUIRE( testCase3.isSuccessfullyCompleted() );
|
REQUIRE( testCase3.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "open a nested section", "" ) {
|
SECTION( "open a nested section", "" ) {
|
||||||
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() );
|
REQUIRE( s2.isOpen() );
|
||||||
@@ -167,15 +167,15 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
s2.close();
|
s2.close();
|
||||||
REQUIRE( s2.isComplete() );
|
REQUIRE( s2.isComplete() );
|
||||||
REQUIRE( s1.isComplete() == false );
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( s1.isComplete() );
|
REQUIRE( s1.isComplete() );
|
||||||
REQUIRE( testCase.isComplete() == false );
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isComplete() );
|
REQUIRE( testCase.isComplete() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "start a generator", "" ) {
|
SECTION( "start a generator", "" ) {
|
||||||
IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1.isOpen() );
|
REQUIRE( g1.isOpen() );
|
||||||
@@ -195,17 +195,17 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() );
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
|
|
||||||
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1b.isOpen() );
|
REQUIRE( g1b.isOpen() );
|
||||||
REQUIRE( g1b.index() == 1 );
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
REQUIRE( s1.isComplete() == false );
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
s1b.close();
|
s1b.close();
|
||||||
REQUIRE( s1b.isComplete() );
|
REQUIRE( s1b.isComplete() );
|
||||||
REQUIRE( g1b.isComplete() );
|
REQUIRE( g1b.isComplete() );
|
||||||
@@ -225,98 +225,98 @@ TEST_CASE( "Tracker", "" ) {
|
|||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isComplete() == false );
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
SECTION( "Re-enter for second generation", "" ) {
|
SECTION( "Re-enter for second generation", "" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() );
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
// generator - next value
|
// generator - next value
|
||||||
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1b.isOpen() );
|
REQUIRE( g1b.isOpen() );
|
||||||
REQUIRE( g1b.index() == 1 );
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
// inner section again
|
// inner section again
|
||||||
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2b.isOpen() );
|
REQUIRE( s2b.isOpen() );
|
||||||
|
|
||||||
s2b.close();
|
s2b.close();
|
||||||
REQUIRE( s2b.isComplete() );
|
REQUIRE( s2b.isComplete() );
|
||||||
|
|
||||||
s1b.close();
|
s1b.close();
|
||||||
REQUIRE( g1b.isComplete() );
|
REQUIRE( g1b.isComplete() );
|
||||||
REQUIRE( s1b.isComplete() );
|
REQUIRE( s1b.isComplete() );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isComplete() );
|
REQUIRE( testCase2.isComplete() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "Fail an inner section", "" ) {
|
SECTION( "Fail an inner section", "" ) {
|
||||||
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() );
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
s2.fail();
|
s2.fail();
|
||||||
REQUIRE( s2.isComplete() );
|
REQUIRE( s2.isComplete() );
|
||||||
REQUIRE( s2.isSuccessfullyCompleted() == false );
|
REQUIRE( s2.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( s1.isComplete() == false );
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isComplete() == false );
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
SECTION( "Re-enter for second generation", "" ) {
|
SECTION( "Re-enter for second generation", "" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() );
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
// generator - still same value
|
// generator - still same value
|
||||||
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1b.isOpen() );
|
REQUIRE( g1b.isOpen() );
|
||||||
REQUIRE( g1b.index() == 0 );
|
REQUIRE( g1b.index() == 0 );
|
||||||
|
|
||||||
// inner section again - this time won't open
|
// inner section again - this time won't open
|
||||||
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2b.isOpen() == false );
|
REQUIRE( s2b.isOpen() == false );
|
||||||
|
|
||||||
s1b.close();
|
s1b.close();
|
||||||
REQUIRE( g1b.isComplete() == false );
|
REQUIRE( g1b.isComplete() == false );
|
||||||
REQUIRE( s1b.isComplete() == false );
|
REQUIRE( s1b.isComplete() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isComplete() == false );
|
REQUIRE( testCase2.isComplete() == false );
|
||||||
|
|
||||||
// Another cycle - now should complete
|
// Another cycle - now should complete
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase3.isOpen() );
|
REQUIRE( testCase3.isOpen() );
|
||||||
|
|
||||||
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1c.isOpen() );
|
REQUIRE( s1c.isOpen() );
|
||||||
|
|
||||||
// generator - now next value
|
// generator - now next value
|
||||||
IndexTracker& g1c = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1c = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1c.isOpen() );
|
REQUIRE( g1c.isOpen() );
|
||||||
REQUIRE( g1c.index() == 1 );
|
REQUIRE( g1c.index() == 1 );
|
||||||
|
|
||||||
// inner section - now should open again
|
// inner section - now should open again
|
||||||
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2c.isOpen() );
|
REQUIRE( s2c.isOpen() );
|
||||||
|
|
||||||
s2c.close();
|
s2c.close();
|
||||||
REQUIRE( s2c.isComplete() );
|
REQUIRE( s2c.isComplete() );
|
||||||
|
|
||||||
s1c.close();
|
s1c.close();
|
||||||
REQUIRE( g1c.isComplete() );
|
REQUIRE( g1c.isComplete() );
|
||||||
REQUIRE( s1c.isComplete() );
|
REQUIRE( s1c.isComplete() );
|
||||||
|
|
||||||
testCase3.close();
|
testCase3.close();
|
||||||
REQUIRE( testCase3.isComplete() );
|
REQUIRE( testCase3.isComplete() );
|
||||||
}
|
}
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
#include "catch_interfaces_generators.h"
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
#include "catch_interfaces_runner.h"
|
|
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
Catch::TagAliasRegistry registry;
|
Catch::TagAliasRegistry registry;
|
||||||
|
|
||||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
||||||
|
@@ -44,18 +44,20 @@ inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){
|
|||||||
|
|
||||||
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
Catch::ConfigData config;
|
Catch::ConfigData config;
|
||||||
|
|
||||||
SECTION( "default - no arguments", "" ) {
|
SECTION( "default - no arguments", "" ) {
|
||||||
const char* argv[] = { "test" };
|
const char* argv[] = { "test" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
CHECK( config.shouldDebugBreak == false );
|
CHECK( config.shouldDebugBreak == false );
|
||||||
CHECK( config.abortAfter == -1 );
|
CHECK( config.abortAfter == -1 );
|
||||||
CHECK( config.noThrow == false );
|
CHECK( config.noThrow == false );
|
||||||
CHECK( config.reporterNames.empty() );
|
CHECK( config.reporterNames.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "test lists", "" ) {
|
SECTION( "test lists", "" ) {
|
||||||
SECTION( "1 test", "Specify one test case using" ) {
|
SECTION( "1 test", "Specify one test case using" ) {
|
||||||
const char* argv[] = { "test", "test1" };
|
const char* argv[] = { "test", "test1" };
|
||||||
@@ -84,24 +86,24 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "reporter", "" ) {
|
SECTION( "reporter", "" ) {
|
||||||
SECTION( "-r/console", "" ) {
|
SECTION( "-r/console", "" ) {
|
||||||
const char* argv[] = { "test", "-r", "console" };
|
const char* argv[] = { "test", "-r", "console" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterNames[0] == "console" );
|
REQUIRE( config.reporterNames[0] == "console" );
|
||||||
}
|
}
|
||||||
SECTION( "-r/xml", "" ) {
|
SECTION( "-r/xml", "" ) {
|
||||||
const char* argv[] = { "test", "-r", "xml" };
|
const char* argv[] = { "test", "-r", "xml" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterNames[0] == "xml" );
|
REQUIRE( config.reporterNames[0] == "xml" );
|
||||||
}
|
}
|
||||||
SECTION( "-r xml and junit", "" ) {
|
SECTION( "-r xml and junit", "" ) {
|
||||||
const char* argv[] = { "test", "-r", "xml", "-r", "junit" };
|
const char* argv[] = { "test", "-r", "xml", "-r", "junit" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterNames.size() == 2 );
|
REQUIRE( config.reporterNames.size() == 2 );
|
||||||
REQUIRE( config.reporterNames[0] == "xml" );
|
REQUIRE( config.reporterNames[0] == "xml" );
|
||||||
REQUIRE( config.reporterNames[1] == "junit" );
|
REQUIRE( config.reporterNames[1] == "junit" );
|
||||||
@@ -109,26 +111,26 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||||||
SECTION( "--reporter/junit", "" ) {
|
SECTION( "--reporter/junit", "" ) {
|
||||||
const char* argv[] = { "test", "--reporter", "junit" };
|
const char* argv[] = { "test", "--reporter", "junit" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterNames[0] == "junit" );
|
REQUIRE( config.reporterNames[0] == "junit" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "debugger", "" ) {
|
SECTION( "debugger", "" ) {
|
||||||
SECTION( "-b", "" ) {
|
SECTION( "-b", "" ) {
|
||||||
const char* argv[] = { "test", "-b" };
|
const char* argv[] = { "test", "-b" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.shouldDebugBreak == true );
|
REQUIRE( config.shouldDebugBreak == true );
|
||||||
}
|
}
|
||||||
SECTION( "--break", "" ) {
|
SECTION( "--break", "" ) {
|
||||||
const char* argv[] = { "test", "--break" };
|
const char* argv[] = { "test", "--break" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.shouldDebugBreak );
|
REQUIRE( config.shouldDebugBreak );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "abort", "" ) {
|
SECTION( "abort", "" ) {
|
||||||
SECTION( "-a aborts after first failure", "" ) {
|
SECTION( "-a aborts after first failure", "" ) {
|
||||||
const char* argv[] = { "test", "-a" };
|
const char* argv[] = { "test", "-a" };
|
||||||
@@ -151,7 +153,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||||||
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) );
|
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "nothrow", "" ) {
|
SECTION( "nothrow", "" ) {
|
||||||
SECTION( "-e", "" ) {
|
SECTION( "-e", "" ) {
|
||||||
const char* argv[] = { "test", "-e" };
|
const char* argv[] = { "test", "-e" };
|
||||||
@@ -217,7 +219,7 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) {
|
|||||||
SECTION( "plain string", "" ) {
|
SECTION( "plain string", "" ) {
|
||||||
// guide: 123456789012345678
|
// guide: 123456789012345678
|
||||||
std::string testString = "one two three four";
|
std::string testString = "one two three four";
|
||||||
|
|
||||||
SECTION( "No wrapping", "" ) {
|
SECTION( "No wrapping", "" ) {
|
||||||
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
||||||
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
||||||
@@ -261,14 +263,14 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) {
|
|||||||
.setInitialIndent( 1 ) );
|
.setInitialIndent( 1 ) );
|
||||||
CHECK( text.toString() == " one two\n three\n four" );
|
CHECK( text.toString() == " one two\n three\n four" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "With newlines", "" ) {
|
SECTION( "With newlines", "" ) {
|
||||||
|
|
||||||
// guide: 1234567890123456789
|
// guide: 1234567890123456789
|
||||||
std::string testString = "one two\nthree four";
|
std::string testString = "one two\nthree four";
|
||||||
|
|
||||||
SECTION( "No wrapping" , "" ) {
|
SECTION( "No wrapping" , "" ) {
|
||||||
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
|
||||||
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
|
||||||
@@ -288,17 +290,17 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) {
|
|||||||
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
|
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "With tabs", "" ) {
|
SECTION( "With tabs", "" ) {
|
||||||
|
|
||||||
// guide: 1234567890123456789
|
// guide: 1234567890123456789
|
||||||
std::string testString = "one two \tthree four five six";
|
std::string testString = "one two \tthree four five six";
|
||||||
|
|
||||||
CHECK( Text( testString, TextAttributes().setWidth( 15 ) ).toString()
|
CHECK( Text( testString, TextAttributes().setWidth( 15 ) ).toString()
|
||||||
== "one two three\n four\n five\n six" );
|
== "one two three\n four\n five\n six" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Catch;
|
using namespace Catch;
|
||||||
@@ -324,7 +326,7 @@ public:
|
|||||||
ColourString( std::string const& _string, std::vector<ColourIndex> const& _colours )
|
ColourString( std::string const& _string, std::vector<ColourIndex> const& _colours )
|
||||||
: string( _string ), colours( _colours )
|
: string( _string ), colours( _colours )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ColourString& addColour( Colour::Code colour, int _index ) {
|
ColourString& addColour( Colour::Code colour, int _index ) {
|
||||||
colours.push_back( ColourIndex( colour,
|
colours.push_back( ColourIndex( colour,
|
||||||
resolveRelativeIndex( _index ),
|
resolveRelativeIndex( _index ),
|
||||||
@@ -337,7 +339,7 @@ public:
|
|||||||
resolveLastRelativeIndex( _toIndex ) ) );
|
resolveLastRelativeIndex( _toIndex ) ) );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeToStream( std::ostream& _stream ) const {
|
void writeToStream( std::ostream& _stream ) const {
|
||||||
std::size_t last = 0;
|
std::size_t last = 0;
|
||||||
for( std::size_t i = 0; i < colours.size(); ++i ) {
|
for( std::size_t i = 0; i < colours.size(); ++i ) {
|
||||||
@@ -351,7 +353,7 @@ public:
|
|||||||
last = index.toIndex;
|
last = index.toIndex;
|
||||||
}
|
}
|
||||||
if( last < string.size() )
|
if( last < string.size() )
|
||||||
_stream << string.substr( last );
|
_stream << string.substr( last );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) {
|
friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) {
|
||||||
_colourString.writeToStream( _stream );
|
_colourString.writeToStream( _stream );
|
||||||
@@ -408,7 +410,7 @@ TEST_CASE( "replaceInPlace", "" ) {
|
|||||||
|
|
||||||
// !TBD: This will be folded into Text class
|
// !TBD: This will be folded into Text class
|
||||||
TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) {
|
TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) {
|
||||||
|
|
||||||
{
|
{
|
||||||
ColourString cs( "hello" );
|
ColourString cs( "hello" );
|
||||||
cs .addColour( Colour::Red, 0 )
|
cs .addColour( Colour::Red, 0 )
|
||||||
@@ -420,19 +422,19 @@ TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) {
|
|||||||
{
|
{
|
||||||
ColourString cs( "hello" );
|
ColourString cs( "hello" );
|
||||||
cs .addColour( Colour::Blue, 1, -2 );
|
cs .addColour( Colour::Blue, 1, -2 );
|
||||||
|
|
||||||
Catch::cout() << cs << std::endl;
|
Catch::cout() << cs << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "Text can be formatted using the Text class", "" ) {
|
TEST_CASE( "Text can be formatted using the Text class", "" ) {
|
||||||
|
|
||||||
CHECK( Text( "hi there" ).toString() == "hi there" );
|
CHECK( Text( "hi there" ).toString() == "hi there" );
|
||||||
|
|
||||||
TextAttributes narrow;
|
TextAttributes narrow;
|
||||||
narrow.setWidth( 6 );
|
narrow.setWidth( 6 );
|
||||||
|
|
||||||
CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" );
|
CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,5 +447,15 @@ TEST_CASE( "Long text is truncted", "[Text][Truncated]" ) {
|
|||||||
oss << longLine << longLine << "\n";
|
oss << longLine << longLine << "\n";
|
||||||
Text t( oss.str() );
|
Text t( oss.str() );
|
||||||
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
|
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void manuallyRegisteredTestFunction() {
|
||||||
|
SUCCEED( "was called" );
|
||||||
|
}
|
||||||
|
struct AutoTestReg {
|
||||||
|
AutoTestReg() {
|
||||||
|
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered", "" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AutoTestReg autoTestReg;
|
||||||
|
@@ -25,7 +25,7 @@ namespace Catch
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "std::pair( " << value.first << ", " << value.second << " )";
|
oss << "std::pair( " << value.first << ", " << value.second << " )";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ TEST_CASE
|
|||||||
{
|
{
|
||||||
std::pair<int, int> aNicePair( 1, 2 );
|
std::pair<int, int> aNicePair( 1, 2 );
|
||||||
|
|
||||||
REQUIRE( (std::pair<int, int>( 1, 2 )) == aNicePair );
|
REQUIRE( (std::pair<int, int>( 1, 2 )) == aNicePair );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -62,7 +62,7 @@ TEST_CASE
|
|||||||
/*
|
/*
|
||||||
int a = 1;
|
int a = 1;
|
||||||
int b = 2;
|
int b = 2;
|
||||||
|
|
||||||
// This only captures part of the expression, but issues a warning about the rest
|
// This only captures part of the expression, but issues a warning about the rest
|
||||||
REQUIRE( a+1 == b-1 );
|
REQUIRE( a+1 == b-1 );
|
||||||
*/
|
*/
|
||||||
@@ -85,38 +85,38 @@ TEST_CASE
|
|||||||
"[Tricky][failing][.]"
|
"[Tricky][failing][.]"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
Opaque o1, o2;
|
Opaque o1, o2;
|
||||||
o1.val = 7;
|
o1.val = 7;
|
||||||
o2.val = 8;
|
o2.val = 8;
|
||||||
|
|
||||||
CHECK( &o1 == &o2 );
|
CHECK( &o1 == &o2 );
|
||||||
CHECK( o1 == o2 );
|
CHECK( o1 == o2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
TEST_CASE
|
TEST_CASE
|
||||||
(
|
(
|
||||||
"string literals of different sizes can be compared",
|
"string literals of different sizes can be compared",
|
||||||
"[Tricky][failing][.]"
|
"[Tricky][failing][.]"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
REQUIRE( std::string( "first" ) == "second" );
|
REQUIRE( std::string( "first" ) == "second" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
TEST_CASE
|
TEST_CASE
|
||||||
(
|
(
|
||||||
"An expression with side-effects should only be evaluated once",
|
"An expression with side-effects should only be evaluated once",
|
||||||
"[Tricky]"
|
"[Tricky]"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i = 7;
|
int i = 7;
|
||||||
|
|
||||||
REQUIRE( i++ == 7 );
|
REQUIRE( i++ == 7 );
|
||||||
REQUIRE( i++ == 8 );
|
REQUIRE( i++ == 8 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace A {
|
namespace A {
|
||||||
@@ -167,8 +167,8 @@ TEST_CASE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace ObjectWithConversions
|
namespace ObjectWithConversions
|
||||||
{
|
{
|
||||||
struct Object
|
struct Object
|
||||||
{
|
{
|
||||||
operator unsigned int() {return 0xc0000000;}
|
operator unsigned int() {return 0xc0000000;}
|
||||||
};
|
};
|
||||||
@@ -179,31 +179,31 @@ namespace ObjectWithConversions
|
|||||||
"Operators at different namespace levels not hijacked by Koenig lookup",
|
"Operators at different namespace levels not hijacked by Koenig lookup",
|
||||||
"[Tricky]"
|
"[Tricky]"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Object o;
|
Object o;
|
||||||
REQUIRE(0xc0000000 == o );
|
REQUIRE(0xc0000000 == o );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ObjectWithNonConstEqualityOperator
|
namespace ObjectWithNonConstEqualityOperator
|
||||||
{
|
{
|
||||||
struct Test
|
struct Test
|
||||||
{
|
{
|
||||||
Test( unsigned int v )
|
Test( unsigned int v )
|
||||||
: m_value(v)
|
: m_value(v)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator==( const Test&rhs )
|
bool operator==( const Test&rhs )
|
||||||
{
|
{
|
||||||
return (m_value == rhs.m_value);
|
return (m_value == rhs.m_value);
|
||||||
}
|
}
|
||||||
bool operator==( const Test&rhs ) const
|
bool operator==( const Test&rhs ) const
|
||||||
{
|
{
|
||||||
return (m_value != rhs.m_value);
|
return (m_value != rhs.m_value);
|
||||||
}
|
}
|
||||||
unsigned int m_value;
|
unsigned int m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" )
|
TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" )
|
||||||
{
|
{
|
||||||
Test t( 1 );
|
Test t( 1 );
|
||||||
@@ -226,7 +226,7 @@ namespace EnumBitFieldTests
|
|||||||
struct Obj
|
struct Obj
|
||||||
{
|
{
|
||||||
Obj():prop(&p){}
|
Obj():prop(&p){}
|
||||||
|
|
||||||
int p;
|
int p;
|
||||||
int* prop;
|
int* prop;
|
||||||
};
|
};
|
||||||
@@ -284,11 +284,11 @@ TEST_CASE( "(unimplemented) static bools can be evaluated", "[Tricky]" )
|
|||||||
/*
|
/*
|
||||||
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -317,13 +317,13 @@ TEST_CASE( "Assertions then sections", "[Tricky]" )
|
|||||||
{
|
{
|
||||||
// This was causing a failure due to the way the console reporter was handling
|
// This was causing a failure due to the way the console reporter was handling
|
||||||
// the current section
|
// the current section
|
||||||
|
|
||||||
REQUIRE( Catch::alwaysTrue() );
|
REQUIRE( Catch::alwaysTrue() );
|
||||||
|
|
||||||
SECTION( "A section", "" )
|
SECTION( "A section", "" )
|
||||||
{
|
{
|
||||||
REQUIRE( Catch::alwaysTrue() );
|
REQUIRE( Catch::alwaysTrue() );
|
||||||
|
|
||||||
SECTION( "Another section", "" )
|
SECTION( "Another section", "" )
|
||||||
{
|
{
|
||||||
REQUIRE( Catch::alwaysTrue() );
|
REQUIRE( Catch::alwaysTrue() );
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
4A45DA2D16161FA2004F8D6B /* catch_interfaces_capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */; };
|
4A45DA2D16161FA2004F8D6B /* catch_interfaces_capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */; };
|
||||||
4A45DA3116161FFC004F8D6B /* catch_interfaces_reporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */; };
|
4A45DA3116161FFC004F8D6B /* catch_interfaces_reporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */; };
|
||||||
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */; };
|
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */; };
|
||||||
4A45DA3516162071004F8D6B /* catch_interfaces_runner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */; };
|
|
||||||
4A6D0C27149B3D3B00DB3EAA /* CatchSelfTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */; };
|
4A6D0C27149B3D3B00DB3EAA /* CatchSelfTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */; };
|
||||||
4A6D0C37149B3D9E00DB3EAA /* ApproxTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */; };
|
4A6D0C37149B3D9E00DB3EAA /* ApproxTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */; };
|
||||||
4A6D0C38149B3D9E00DB3EAA /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */; };
|
4A6D0C38149B3D9E00DB3EAA /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */; };
|
||||||
@@ -120,7 +119,6 @@
|
|||||||
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_capture.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_capture.cpp; sourceTree = "<group>"; };
|
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_capture.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_capture.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_reporter.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp; sourceTree = "<group>"; };
|
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_reporter.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_exception.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_exception.cpp; sourceTree = "<group>"; };
|
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_exception.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_exception.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_runner.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_runner.cpp; sourceTree = "<group>"; };
|
|
||||||
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_notimplemented_exception.h; sourceTree = "<group>"; };
|
4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_notimplemented_exception.h; sourceTree = "<group>"; };
|
||||||
@@ -149,14 +147,9 @@
|
|||||||
4A6D0C4C149B3E3D00DB3EAA /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_default_main.hpp; sourceTree = "<group>"; };
|
4A6D0C4C149B3E3D00DB3EAA /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_default_main.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_evaluate.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_evaluate.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_exception_translator_registry.hpp; sourceTree = "<group>"; };
|
4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_exception_translator_registry.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators_impl.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_context.h; sourceTree = "<group>"; };
|
|
||||||
4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_context_impl.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = "<group>"; };
|
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = "<group>"; };
|
||||||
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_exception.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_exception.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = "<group>"; };
|
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = "<group>"; };
|
||||||
4A6D0C56149B3E3D00DB3EAA /* catch_interfaces_runner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_runner.h; sourceTree = "<group>"; };
|
|
||||||
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_testcase.h; sourceTree = "<group>"; };
|
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_testcase.h; sourceTree = "<group>"; };
|
||||||
4A6D0C58149B3E3D00DB3EAA /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_list.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C58149B3E3D00DB3EAA /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_list.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C59149B3E3D00DB3EAA /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_objc.hpp; sourceTree = "<group>"; };
|
4A6D0C59149B3E3D00DB3EAA /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_objc.hpp; sourceTree = "<group>"; };
|
||||||
@@ -175,7 +168,6 @@
|
|||||||
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
||||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
||||||
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = catch_version.h; path = ../../../../include/internal/catch_version.h; sourceTree = "<group>"; };
|
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = catch_version.h; path = ../../../../include/internal/catch_version.h; sourceTree = "<group>"; };
|
||||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_generators.h; sourceTree = "<group>"; };
|
|
||||||
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_assertionresult.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_assertionresult.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4AA7B8B4165428BA003155F6 /* catch_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_version.hpp; path = ../../../../include/internal/catch_version.hpp; sourceTree = "<group>"; };
|
4AA7B8B4165428BA003155F6 /* catch_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_version.hpp; path = ../../../../include/internal/catch_version.hpp; sourceTree = "<group>"; };
|
||||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
@@ -340,7 +332,6 @@
|
|||||||
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */,
|
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */,
|
||||||
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */,
|
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */,
|
||||||
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */,
|
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */,
|
||||||
4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */,
|
|
||||||
4AB3D99C1616216500C9A0F8 /* catch_interfaces_testcase.cpp */,
|
4AB3D99C1616216500C9A0F8 /* catch_interfaces_testcase.cpp */,
|
||||||
4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */,
|
4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */,
|
||||||
4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */,
|
4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */,
|
||||||
@@ -358,8 +349,6 @@
|
|||||||
263FD06017AF8DF200988A20 /* catch_timer.hpp */,
|
263FD06017AF8DF200988A20 /* catch_timer.hpp */,
|
||||||
4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
|
4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
|
||||||
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */,
|
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */,
|
||||||
4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */,
|
|
||||||
4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */,
|
|
||||||
4A6D0C5E149B3E3D00DB3EAA /* catch_run_context.hpp */,
|
4A6D0C5E149B3E3D00DB3EAA /* catch_run_context.hpp */,
|
||||||
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
||||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
|
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
|
||||||
@@ -379,7 +368,6 @@
|
|||||||
269831E519078C1600BB0CE0 /* catch_tostring.h */,
|
269831E519078C1600BB0CE0 /* catch_tostring.h */,
|
||||||
269831E619078CA200BB0CE0 /* catch_tostring.hpp */,
|
269831E619078CA200BB0CE0 /* catch_tostring.hpp */,
|
||||||
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */,
|
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */,
|
||||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */,
|
|
||||||
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */,
|
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */,
|
||||||
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */,
|
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */,
|
||||||
261488FE184DC32F0041FBEB /* catch_section.h */,
|
261488FE184DC32F0041FBEB /* catch_section.h */,
|
||||||
@@ -412,7 +400,6 @@
|
|||||||
261488FA184C81130041FBEB /* catch_test_spec.hpp */,
|
261488FA184C81130041FBEB /* catch_test_spec.hpp */,
|
||||||
2656C21F1925E5100040DB02 /* catch_test_spec_parser.hpp */,
|
2656C21F1925E5100040DB02 /* catch_test_spec_parser.hpp */,
|
||||||
4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */,
|
4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */,
|
||||||
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */,
|
|
||||||
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
|
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
|
||||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
|
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
|
||||||
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
|
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
|
||||||
@@ -440,10 +427,8 @@
|
|||||||
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */,
|
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */,
|
||||||
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */,
|
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */,
|
||||||
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */,
|
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */,
|
||||||
4A6D0C56149B3E3D00DB3EAA /* catch_interfaces_runner.h */,
|
|
||||||
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */,
|
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */,
|
||||||
4AFC661D157E96A7009D58CF /* catch_interfaces_config.h */,
|
4AFC661D157E96A7009D58CF /* catch_interfaces_config.h */,
|
||||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */,
|
|
||||||
26711C90195D46CD0033EDA2 /* catch_interfaces_tag_alias_registry.h */,
|
26711C90195D46CD0033EDA2 /* catch_interfaces_tag_alias_registry.h */,
|
||||||
);
|
);
|
||||||
name = Interfaces;
|
name = Interfaces;
|
||||||
@@ -566,7 +551,6 @@
|
|||||||
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */,
|
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */,
|
||||||
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */,
|
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */,
|
||||||
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */,
|
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */,
|
||||||
4A45DA3516162071004F8D6B /* catch_interfaces_runner.cpp in Sources */,
|
|
||||||
4AB3D99D1616216500C9A0F8 /* catch_interfaces_testcase.cpp in Sources */,
|
4AB3D99D1616216500C9A0F8 /* catch_interfaces_testcase.cpp in Sources */,
|
||||||
4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */,
|
4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */,
|
||||||
4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */,
|
4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */,
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface iTchRunnerAppDelegate : NSObject <UIApplicationDelegate>
|
@interface iTchRunnerAppDelegate : NSObject <UIApplicationDelegate>
|
||||||
{
|
{
|
||||||
UIWindow *window;
|
UIWindow *window;
|
||||||
}
|
}
|
||||||
@@ -25,15 +25,15 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||||
{
|
{
|
||||||
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
[window setUserInteractionEnabled:YES];
|
[window setUserInteractionEnabled:YES];
|
||||||
[window setMultipleTouchEnabled:YES];
|
[window setMultipleTouchEnabled:YES];
|
||||||
|
|
||||||
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
|
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
|
||||||
iTchRunnerMainView* view = [[iTchRunnerMainView alloc] initWithFrame:screenRect];
|
iTchRunnerMainView* view = [[iTchRunnerMainView alloc] initWithFrame:screenRect];
|
||||||
|
|
||||||
[window addSubview:view];
|
[window addSubview:view];
|
||||||
[window makeKeyAndVisible];
|
[window makeKeyAndVisible];
|
||||||
arcSafeRelease( view );
|
arcSafeRelease( view );
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
#if !CATCH_ARC_ENABLED
|
#if !CATCH_ARC_ENABLED
|
||||||
[window release];
|
[window release];
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillResignActive:(UIApplication *)application
|
- (void)applicationWillResignActive:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||||
@@ -62,17 +62,17 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application
|
- (void)applicationWillTerminate:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Called when the application is about to terminate.
|
Called when the application is about to terminate.
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
|
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
|
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
-(id) initWithFrame:(CGRect)frame
|
-(id) initWithFrame:(CGRect)frame
|
||||||
{
|
{
|
||||||
if ((self = [super initWithFrame:frame]))
|
if ((self = [super initWithFrame:frame]))
|
||||||
{
|
{
|
||||||
// Initialization code
|
// Initialization code
|
||||||
self.backgroundColor = [UIColor blackColor];
|
self.backgroundColor = [UIColor blackColor];
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
-(void) showAlert
|
-(void) showAlert
|
||||||
{
|
{
|
||||||
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:@"Options"
|
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:@"Options"
|
||||||
delegate:self
|
delegate:self
|
||||||
cancelButtonTitle:nil
|
cancelButtonTitle:nil
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
otherButtonTitles:@"Run all tests", nil];
|
otherButtonTitles:@"Run all tests", nil];
|
||||||
[menu showInView: self];
|
[menu showInView: self];
|
||||||
arcSafeRelease( menu );
|
arcSafeRelease( menu );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a copy & paste from Catch::Runner2 to get us bootstrapped (this is due to all be
|
// This is a copy & paste from Catch::Runner2 to get us bootstrapped (this is due to all be
|
||||||
@@ -144,7 +144,7 @@ inline Catch::Totals runTestsForGroup( Catch::RunContext& context, const Catch::
|
|||||||
{
|
{
|
||||||
const Catch::AssertionResult& resultInfo = *pResultInfo;
|
const Catch::AssertionResult& resultInfo = *pResultInfo;
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|
||||||
if( resultInfo.hasExpression() )
|
if( resultInfo.hasExpression() )
|
||||||
{
|
{
|
||||||
oss << resultInfo.getExpression();
|
oss << resultInfo.getExpression();
|
||||||
@@ -174,7 +174,7 @@ inline Catch::Totals runTestsForGroup( Catch::RunContext& context, const Catch::
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( resultInfo.hasExpression() )
|
if( resultInfo.hasExpression() )
|
||||||
{
|
{
|
||||||
oss << " for: " << resultInfo.getExpandedExpression();
|
oss << " for: " << resultInfo.getExpandedExpression();
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
@protocol iTchRunnerDelegate
|
@protocol iTchRunnerDelegate
|
||||||
|
|
||||||
-(void) testWasRun: (const Catch::AssertionResult*) result;
|
-(void) testWasRun: (const Catch::AssertionResult*) result;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -38,14 +38,14 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
static std::string getDescription
|
static std::string getDescription
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
return "Captures results for iOS runner";
|
return "Captures results for iOS runner";
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
size_t getSucceeded
|
size_t getSucceeded
|
||||||
()
|
()
|
||||||
@@ -53,7 +53,7 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
return m_totals.assertions.passed;
|
return m_totals.assertions.passed;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
size_t getFailed
|
size_t getFailed
|
||||||
()
|
()
|
||||||
@@ -61,20 +61,20 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
return m_totals.assertions.failed;
|
return m_totals.assertions.failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
m_totals = Totals();
|
m_totals = Totals();
|
||||||
}
|
}
|
||||||
|
|
||||||
private: // IReporter
|
private: // IReporter
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
virtual void StartTesting
|
virtual void StartTesting
|
||||||
()
|
()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
virtual void EndTesting
|
virtual void EndTesting
|
||||||
(
|
(
|
||||||
@@ -83,7 +83,7 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
m_totals = totals;
|
m_totals = totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
virtual void Result
|
virtual void Result
|
||||||
(
|
(
|
||||||
@@ -92,7 +92,7 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
[m_delegate testWasRun: &result];
|
[m_delegate testWasRun: &result];
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Deliberately unimplemented:
|
// Deliberately unimplemented:
|
||||||
virtual void StartGroup( const std::string& ){}
|
virtual void StartGroup( const std::string& ){}
|
||||||
@@ -107,7 +107,7 @@ namespace Catch
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
|
|
||||||
id<iTchRunnerDelegate> m_delegate;
|
id<iTchRunnerDelegate> m_delegate;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
46
scripts/fixTrailingWhitespace.py
Normal file
46
scripts/fixTrailingWhitespace.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
from scriptCommon import catchPath
|
||||||
|
|
||||||
|
changedFiles = 0
|
||||||
|
|
||||||
|
def isSourceFile( path ):
|
||||||
|
return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" )
|
||||||
|
|
||||||
|
def fixAllFilesInDir( dir ):
|
||||||
|
for f in os.listdir( dir ):
|
||||||
|
path = os.path.join( dir,f )
|
||||||
|
if os.path.isfile( path ):
|
||||||
|
if isSourceFile( path ):
|
||||||
|
fixFile( path )
|
||||||
|
else:
|
||||||
|
fixAllFilesInDir( path )
|
||||||
|
|
||||||
|
def fixFile( path ):
|
||||||
|
f = open( path, 'r' )
|
||||||
|
lines = []
|
||||||
|
changed = 0
|
||||||
|
for line in f:
|
||||||
|
trimmed = line.rstrip() + "\n"
|
||||||
|
if trimmed != line:
|
||||||
|
changed = changed +1
|
||||||
|
lines.append( trimmed )
|
||||||
|
f.close()
|
||||||
|
if changed > 0:
|
||||||
|
global changedFiles
|
||||||
|
changedFiles = changedFiles + 1
|
||||||
|
print( path + ":" )
|
||||||
|
print( " - fixed " + str(changed) + " line(s)" )
|
||||||
|
altPath = path + ".backup"
|
||||||
|
os.rename( path, altPath )
|
||||||
|
f2 = open( path, 'w' )
|
||||||
|
for line in lines:
|
||||||
|
f2.write( line )
|
||||||
|
f2.close()
|
||||||
|
os.remove( altPath )
|
||||||
|
|
||||||
|
fixAllFilesInDir(catchPath)
|
||||||
|
if changedFiles > 0:
|
||||||
|
print( "Fixed " + str(changedFiles) + " file(s)" )
|
||||||
|
else:
|
||||||
|
print( "No trailing whitespace found" )
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user