Compare commits

..

31 Commits

Author SHA1 Message Date
Phil Nash
2f6371f2ec dev build 9 2015-07-23 23:06:26 +01:00
Phil Nash
70975517b3 rebased approvals for long long test 2015-07-23 23:05:52 +01:00
Phil Nash
733ebb6024 Added CATCH_CONFIG_CPP11_LONG_LONG support 2015-07-23 23:05:05 +01:00
Phil Nash
d6e59cd56f Fixed Xml encoding
- don't encode apostrophes
- only encode quotes in attributes
- encode control characters (as in PR #465)
2015-07-23 18:45:31 +01:00
Phil Nash
6de135c63a Given, When, Then prefixes are now std::strings
(and so can be prepended to std::strings themselves)
see #455
2015-07-22 18:07:28 +01:00
Phil Nash
5bbdc8fd38 Dev build 8 2015-07-15 23:03:11 +01:00
Phil Nash
72868920bb Exception message assertions now work with matchers 2015-07-15 23:02:25 +01:00
Phil Nash
8342ae8dfb dev build 7 2015-07-13 15:03:26 +01:00
Phil Nash
2104ca2aa4 Exception message testing now supports wildcards
- extracted WildcardPattern from TestSpec::NamePattern
2015-07-13 15:03:04 +01:00
Phil Nash
93a842e2f0 dev build 6 2015-07-13 06:36:07 +01:00
Phil Nash
85de743d70 Added _THROWS_WITH macros
- asserts on exception message
2015-07-13 06:34:41 +01:00
Phil Nash
5d5ed5a283 Updated approvalTests script to allow for modified version strings 2015-07-10 08:08:37 +01:00
Phil Nash
57df3ba998 Force cout/ cerr to be initialised before errors in test registry are printed
- see #461
2015-07-10 07:44:37 +01:00
Phil Nash
e6b365dc8c dev build 5 2015-07-07 08:25:15 +01:00
Phil Nash
02e1966db3 Changed --filenames-as-tags prefix to #, added -# as short form and updated docs 2015-07-06 18:46:50 +01:00
Phil Nash
584032dfa4 dev build 4
- undisturbed background colour (windows), from PR #456
2015-07-06 06:23:13 +01:00
Phil Nash
18acff62d3 Merge branch 'develop' of git://github.com/RandomInEqualities/Catch into RandomInEqualities-develop 2015-07-06 06:13:56 +01:00
Phil Nash
c1ca0fdabe dev build 3 2015-07-03 18:30:25 +01:00
Phil Nash
d6f1446e4e Fixed an issue on some compilers with implicit conversion from nullptr to Ptr
- also cleaned up some warnings to do with CATCH_NULL
2015-07-03 18:27:36 +01:00
Phil Nash
62e517f833 Fixed backslash detection in filenames-as-tags 2015-07-03 18:07:13 +01:00
csa
6160a2b079 Fix for white background in windows powershell when using colour output.
This commit fixes the white background that appears in windows powershell
when catch outputs messages with colour. The previous implementation
ignored the original background colour and defaulted to a white background.
2015-07-03 12:02:40 +02:00
Phil Nash
8f66e3495b dev build 2 2015-07-02 23:03:13 +01:00
Phil Nash
d87e551efa reseeds rng before each test case and provides access to seed through Catch::rngSeed() function 2015-07-02 23:02:35 +01:00
Phil Nash
b971fe785b develop build 1 2015-07-02 08:21:38 +01:00
Phil Nash
088c5bc53e --filenames-as-tags 2015-07-02 08:20:18 +01:00
Phil Nash
680b1a881b Squashed some warnings about local variables shadowing members
- see #444
2015-07-01 07:50:53 +01:00
Phil Nash
805de43a3d Use CATCH_NULL instead of NULL
- expands to nullptr if CATCH_CONFIG_CPP11_NULLPTR is defined (see #444)
2015-07-01 07:33:27 +01:00
Phil Nash
3b18d9e962 build for v1.2.1 2015-06-30 18:26:09 +01:00
Phil Nash
6d5797231c Split imply from TrackedSection class to avoid use of incomplete type
- see #450
2015-06-30 18:25:49 +01:00
Phil Nash
804896cdfa Fixed approval tests script for new version number formatting 2015-06-30 18:24:59 +01:00
Phil Nash
7ab3b5aefb Added compiler feature suppression macros
_NO_ forms to disable detection of features - particularly C++11 features.
Also removed SFINAE detection (and use in tostring)
2015-06-30 08:41:55 +01:00
56 changed files with 2319 additions and 1362 deletions

View File

@@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.2.0* *v1.2.1-develop.9*
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)

View File

@@ -52,14 +52,18 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
# C++ conformance toggles # C++ conformance toggles
CATCH_CONFIG_CPP11_NULLPTR CATCH_CONFIG_CPP11_NULLPTR // nullptr is supported?
CATCH_CONFIG_CPP11_NOEXCEPT CATCH_CONFIG_CPP11_NOEXCEPT // noexcept is supported?
CATCH_CONFIG_SFINAE // Basic, C++03, support for SFINAE CATCH_CONFIG_CPP11_GENERATED_METHODS // delete and default keywords for methods
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
CATCH_CONFIG_NO_VARIADIC_MACROS // Suppress if Catch is too eager to enable it CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative. Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support. So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.
You may also suppress any of these features by using the `_NO_` form, e.g. `CATCH_CONFIG_CPP11_NO_NULLPTR`.
All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11`
--- ---

View File

@@ -28,10 +28,36 @@ The tag expression, ```"[widget]"``` selects A, B & D. ```"[gadget]"``` selects
For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run) For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run)
A special tag name, ```[hide]``` causes test cases to be skipped from the default list (ie when no test cases have been explicitly selected through tag expressions or name wildcards). ```[.]``` is an alias for ```[hide]```.
Tag names are not case sensitive. Tag names are not case sensitive.
### Special Tags
All tag names beginning with non-alphanumeric characters are reserved by Catch. Catch defines a number of "special" tags, which have meaning to the test runner itself. These special tags all begin with a symbol character. Following is a list of currently defined special tags and their meanings.
* `[!hide]` or `[.]` (or, for legacy reasons, `[hide]`) - causes test cases to be skipped from the default list (ie when no test cases have been explicitly selected through tag expressions or name wildcards). The hide tag is often combined with another, user, tag (for example `[.][integration]` - so all integration tests are excluded from the default run but can be run by passing `[integration]` on the command line). As a short-cut you can combine these by simply prefixing your user tag with a `.` - e.g. `[.integration]`. Because the hide tag has evolved to have several forms, all forms are added as tags if you use one of them.
* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be exluded when running with `-e` or `--nothrow`.
* `[!shouldfail]` - reverse the failing logic of the test: if the test is successful if it fails, and vice-versa.
* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in the your tests.
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped) as a tag. e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
* `[@<alias>]` - tag aliases all begin with `@` (see below).
## Tag aliases
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. this can be done, in code, using the following form:
CATCH_REGISTER_TAG_ALIAS( <alias string>, <tag expression> )
Aliases must begining with the `@` character. An example of a tag alias is:
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
Now when `[@nhf]` is used on the command line this matches all tests that are tagged `[failing]`, but which are not also hidden.
## BDD-style test cases ## BDD-style test cases
In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with. In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with.

View File

@@ -70,8 +70,9 @@
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" ) #define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" ) #define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" ) #define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" ) #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" ) #define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" ) #define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
@@ -82,6 +83,7 @@
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" ) #define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" ) #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" )
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" ) #define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" ) #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
@@ -123,11 +125,11 @@
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) #define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif #endif
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" ) #define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" ) #define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" ) #define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" ) #define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " desc, "" ) #define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
#else #else
@@ -135,8 +137,9 @@
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" ) #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" ) #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "REQUIRE_THROWS" ) #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" ) #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" ) #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" ) #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
@@ -145,8 +148,9 @@
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) #define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" ) #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" ) #define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" ) #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
@@ -192,11 +196,11 @@
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
#endif #endif
#define GIVEN( desc ) SECTION( " Given: " desc, "" ) #define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" ) #define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
#define AND_WHEN( desc ) SECTION( "And when: " desc, "" ) #define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
#define THEN( desc ) SECTION( " Then: " desc, "" ) #define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
#define AND_THEN( desc ) SECTION( " And: " desc, "" ) #define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
using Catch::Detail::Approx; using Catch::Detail::Approx;

View File

@@ -104,6 +104,26 @@ namespace Catch {
Ptr<IStreamingReporter> m_reporter; Ptr<IStreamingReporter> m_reporter;
std::set<TestCase> m_testsAlreadyRun; std::set<TestCase> m_testsAlreadyRun;
}; };
void applyFilenamesAsTags() {
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
for(std::size_t i = 0; i < tests.size(); ++i ) {
TestCase& test = const_cast<TestCase&>( tests[i] );
std::set<std::string> tags = test.tags;
std::string filename = test.lineInfo.file;
std::string::size_type lastSlash = filename.find_last_of( "\\/" );
if( lastSlash != std::string::npos )
filename = filename.substr( lastSlash+1 );
std::string::size_type lastDot = filename.find_last_of( "." );
if( lastDot != std::string::npos )
filename = filename.substr( 0, lastDot );
tags.insert( "#" + filename );
setTags( test, tags );
}
}
class Session : NonCopyable { class Session : NonCopyable {
static bool alreadyInstantiated; static bool alreadyInstantiated;
@@ -175,7 +195,10 @@ namespace Catch {
{ {
config(); // Force config to be constructed config(); // Force config to be constructed
std::srand( m_configData.rngSeed ); if( m_configData.filenamesAsTags )
applyFilenamesAsTags();
seedRng( *m_config );
Runner runner( m_config ); Runner runner( m_config );

View File

@@ -264,11 +264,11 @@ namespace Clara {
template<typename ConfigT> template<typename ConfigT>
class BoundArgFunction { class BoundArgFunction {
public: public:
BoundArgFunction() : functionObj( NULL ) {} BoundArgFunction() : functionObj( CATCH_NULL ) {}
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {} BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {} BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CATCH_NULL ) {}
BoundArgFunction& operator = ( BoundArgFunction const& other ) { BoundArgFunction& operator = ( BoundArgFunction const& other ) {
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL; IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL;
delete functionObj; delete functionObj;
functionObj = newFunctionObj; functionObj = newFunctionObj;
return *this; return *this;
@@ -284,7 +284,7 @@ namespace Clara {
bool takesArg() const { return functionObj->takesArg(); } bool takesArg() const { return functionObj->takesArg(); }
bool isSet() const { bool isSet() const {
return functionObj != NULL; return functionObj != CATCH_NULL;
} }
private: private:
IArgFunction<ConfigT>* functionObj; IArgFunction<ConfigT>* functionObj;
@@ -585,8 +585,8 @@ namespace Clara {
m_arg->description = description; m_arg->description = description;
return *this; return *this;
} }
ArgBuilder& detail( std::string const& detail ) { ArgBuilder& detail( std::string const& _detail ) {
m_arg->detail = detail; m_arg->detail = _detail;
return *this; return *this;
} }
@@ -670,14 +670,14 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() ); maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) { for( it = itBegin; it != itEnd; ++it ) {
Detail::Text usage( it->commands(), Detail::TextAttributes() Detail::Text usageText( it->commands(), Detail::TextAttributes()
.setWidth( maxWidth+indent ) .setWidth( maxWidth+indent )
.setIndent( indent ) ); .setIndent( indent ) );
Detail::Text desc( it->description, Detail::TextAttributes() Detail::Text desc( it->description, Detail::TextAttributes()
.setWidth( width - maxWidth - 3 ) ); .setWidth( width - maxWidth - 3 ) );
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
std::string usageCol = i < usage.size() ? usage[i] : ""; std::string usageCol = i < usageText.size() ? usageText[i] : "";
os << usageCol; os << usageCol;
if( i < desc.size() && !desc[i].empty() ) if( i < desc.size() && !desc[i].empty() )

View File

@@ -66,16 +66,16 @@
} while( Catch::alwaysFalse() ) } while( Catch::alwaysFalse() )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
if( __catchResult.allowThrows() ) \ if( __catchResult.allowThrows() ) \
try { \ try { \
expr; \ expr; \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \ } \
catch( ... ) { \ catch( ... ) { \
__catchResult.captureResult( Catch::ResultWas::Ok ); \ __catchResult.captureExpectedException( matcher ); \
} \ } \
else \ else \
__catchResult.captureResult( Catch::ResultWas::Ok ); \ __catchResult.captureResult( Catch::ResultWas::Ok ); \

View File

@@ -153,6 +153,10 @@ namespace Catch {
.describe( "load test names to run from a file" ) .describe( "load test names to run from a file" )
.bind( &loadTestNamesFromFile, "filename" ); .bind( &loadTestNamesFromFile, "filename" );
cli["-#"]["--filenames-as-tags"]
.describe( "adds a tag for the filename" )
.bind( &ConfigData::filenamesAsTags );
// Less common commands which don't have a short form // Less common commands which don't have a short form
cli["--list-test-names-only"] cli["--list-test-names-only"]
.describe( "list all/matching test cases names only" ) .describe( "list all/matching test cases names only" )
@@ -173,7 +177,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;
} }

View File

@@ -22,7 +22,14 @@
#include "catch_compiler_capabilities.h" #include "catch_compiler_capabilities.h"
namespace Catch { namespace Catch {
struct IConfig;
struct CaseSensitive { enum Choice {
Yes,
No
}; };
class NonCopyable { class NonCopyable {
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS #ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
NonCopyable( NonCopyable const& ) = delete; NonCopyable( NonCopyable const& ) = delete;
@@ -109,6 +116,9 @@ namespace Catch {
void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
void seedRng( IConfig const& config );
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

View File

@@ -82,6 +82,14 @@ namespace Catch {
return line < other.line || ( line == other.line && file < other.file ); return line < other.line || ( line == other.line && file < other.file );
} }
void seedRng( IConfig const& config ) {
if( config.rngSeed() != 0 )
std::srand( config.rngSeed() );
}
unsigned int rngSeed() {
return getCurrentContext().getConfig()->rngSeed();
}
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
#ifndef __GNUG__ #ifndef __GNUG__
os << info.file << "(" << info.line << ")"; os << info.file << "(" << info.line << ")";

View File

@@ -16,23 +16,28 @@
// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods // CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? // CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported // CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_SFINAE : is basic (C++03) SFINAE supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// A lot of this code is based on Boost (1.53) // In general each macro has a _NO_<feature name> form
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __clang__ #ifdef __clang__
# if __has_feature(cxx_nullptr) # if __has_feature(cxx_nullptr)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# if __has_feature(cxx_noexcept) # if __has_feature(cxx_noexcept)
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
#endif // __clang__ #endif // __clang__
@@ -41,9 +46,6 @@
// Borland // Borland
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#if (__BORLANDC__ > 0x582 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __BORLANDC__ #endif // __BORLANDC__
@@ -51,9 +53,6 @@
// EDG // EDG
#ifdef __EDG_VERSION__ #ifdef __EDG_VERSION__
#if (__EDG_VERSION__ > 238 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __EDG_VERSION__ #endif // __EDG_VERSION__
@@ -61,9 +60,6 @@
// Digital Mars // Digital Mars
#ifdef __DMC__ #ifdef __DMC__
#if (__DMC__ > 0x840 )
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#endif // __DMC__ #endif // __DMC__
@@ -71,21 +67,8 @@
// GCC // GCC
#ifdef __GNUC__ #ifdef __GNUC__
#if __GNUC__ < 3
#if (__GNUC_MINOR__ >= 96 )
//#define CATCH_CONFIG_SFINAE
#endif
#elif __GNUC__ >= 3
// #define CATCH_CONFIG_SFINAE // Taking this out completely for now
#endif // __GNUC__ < 3
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) ) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#define CATCH_CONFIG_CPP11_NULLPTR
#endif #endif
@@ -95,17 +78,13 @@
// Visual C++ // Visual C++
#ifdef _MSC_VER #ifdef _MSC_VER
#if (_MSC_VER >= 1310 ) // (VC++ 7.0+)
//#define CATCH_CONFIG_SFINAE // Not confirmed
#endif
#if (_MSC_VER >= 1600) #if (_MSC_VER >= 1600)
#define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif #endif
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) #if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CATCH_CONFIG_CPP11_NOEXCEPT #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_CONFIG_CPP11_GENERATED_METHODS #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif #endif
#endif // _MSC_VER #endif // _MSC_VER
@@ -116,9 +95,7 @@
( defined __GNUC__ && __GNUC__ >= 3 ) || \ ( defined __GNUC__ && __GNUC__ >= 3 ) || \
( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
#ifndef CATCH_CONFIG_NO_VARIADIC_MACROS #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#define CATCH_CONFIG_VARIADIC_MACROS
#endif
#endif #endif
@@ -130,36 +107,60 @@
# define CATCH_CPP11_OR_GREATER # define CATCH_CPP11_OR_GREATER
# ifndef CATCH_CONFIG_CPP11_NULLPTR # if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# ifndef CATCH_CONFIG_CPP11_NOEXCEPT # ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# define CATCH_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS # ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# define CATCH_CONFIG_CPP11_GENERATED_METHODS # define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
# endif # endif
# ifndef CATCH_CONFIG_CPP11_IS_ENUM # ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# define CATCH_CONFIG_CPP11_IS_ENUM # define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
# endif # endif
# ifndef CATCH_CONFIG_CPP11_TUPLE # ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# define CATCH_CONFIG_CPP11_TUPLE # define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
# endif # endif
# ifndef CATCH_CONFIG_SFINAE # ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
//# define CATCH_CONFIG_SFINAE // Don't use, for now # define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
# endif # endif
# ifndef CATCH_CONFIG_VARIADIC_MACROS # if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
# define CATCH_CONFIG_VARIADIC_MACROS # define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
# endif # endif
#endif // __cplusplus >= 201103L #endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NULLPTR
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_IS_ENUM
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_TUPLE
#endif
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
# define CATCH_CONFIG_VARIADIC_MACROS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG)
# define CATCH_CONFIG_CPP11_LONG_LONG
#endif
// noexcept support: // noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
# define CATCH_NOEXCEPT noexcept # define CATCH_NOEXCEPT noexcept
@@ -169,5 +170,12 @@
# define CATCH_NOEXCEPT_IS(x) # define CATCH_NOEXCEPT_IS(x)
#endif #endif
// nullptr support
#ifdef CATCH_CONFIG_CPP11_NULLPTR
# define CATCH_NULL nullptr
#else
# define CATCH_NULL NULL
#endif
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED

View File

@@ -38,6 +38,7 @@ namespace Catch {
showHelp( false ), showHelp( false ),
showInvisibles( false ), showInvisibles( false ),
forceColour( false ), forceColour( false ),
filenamesAsTags( false ),
abortAfter( -1 ), abortAfter( -1 ),
rngSeed( 0 ), rngSeed( 0 ),
verbosity( Verbosity::Normal ), verbosity( Verbosity::Normal ),
@@ -57,6 +58,7 @@ namespace Catch {
bool showHelp; bool showHelp;
bool showInvisibles; bool showInvisibles;
bool forceColour; bool forceColour;
bool filenamesAsTags;
int abortAfter; int abortAfter;
unsigned int rngSeed; unsigned int rngSeed;

View File

@@ -60,12 +60,13 @@ namespace {
{ {
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );
originalAttributes = csbiInfo.wAttributes; originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );
originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
} }
virtual void use( Colour::Code _colourCode ) { virtual void use( Colour::Code _colourCode ) {
switch( _colourCode ) { switch( _colourCode ) {
case Colour::None: return setTextAttribute( originalAttributes ); case Colour::None: return setTextAttribute( originalForegroundAttributes );
case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
case Colour::Red: return setTextAttribute( FOREGROUND_RED ); case Colour::Red: return setTextAttribute( FOREGROUND_RED );
case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
@@ -85,10 +86,11 @@ namespace {
private: private:
void setTextAttribute( WORD _textAttribute ) { void setTextAttribute( WORD _textAttribute ) {
SetConsoleTextAttribute( stdoutHandle, _textAttribute ); SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
} }
HANDLE stdoutHandle; HANDLE stdoutHandle;
WORD originalAttributes; WORD originalForegroundAttributes;
WORD originalBackgroundAttributes;
}; };
IColourImpl* platformColourInstance() { IColourImpl* platformColourInstance() {

View File

@@ -17,7 +17,7 @@ namespace Catch {
class Context : public IMutableContext { class Context : public IMutableContext {
Context() : m_config( NULL ), m_runner( NULL ), m_resultCapture( NULL ) {} Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
Context( Context const& ); Context( Context const& );
void operator=( Context const& ); void operator=( Context const& );
@@ -63,7 +63,7 @@ namespace Catch {
m_generatorsByTestName.find( testName ); m_generatorsByTestName.find( testName );
return it != m_generatorsByTestName.end() return it != m_generatorsByTestName.end()
? it->second ? it->second
: NULL; : CATCH_NULL;
} }
IGeneratorsForTest& getGeneratorsForCurrentTest() { IGeneratorsForTest& getGeneratorsForCurrentTest() {
@@ -84,7 +84,7 @@ namespace Catch {
}; };
namespace { namespace {
Context* currentContext = NULL; Context* currentContext = CATCH_NULL;
} }
IMutableContext& getCurrentMutableContext() { IMutableContext& getCurrentMutableContext() {
if( !currentContext ) if( !currentContext )
@@ -105,7 +105,7 @@ namespace Catch {
void cleanUpContext() { void cleanUpContext() {
delete currentContext; delete currentContext;
currentContext = NULL; currentContext = CATCH_NULL;
} }
} }

View File

@@ -50,7 +50,7 @@
// Call sysctl. // Call sysctl.
size = sizeof(info); size = sizeof(info);
if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) != 0 ) { if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) {
Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
return false; return false;
} }

View File

@@ -160,13 +160,51 @@ namespace Internal {
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
} }
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
// long long to unsigned X
template<Operator Op> bool compare( long long lhs, unsigned int rhs ) {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
}
template<Operator Op> bool compare( long long lhs, unsigned long rhs ) {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
}
template<Operator Op> bool compare( long long lhs, unsigned long long rhs ) {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
}
template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
}
// unsigned long long to X
template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
}
template<Operator Op> bool compare( unsigned long long lhs, long rhs ) {
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
}
template<Operator Op> bool compare( unsigned long long lhs, long long rhs ) {
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
}
template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
}
// pointer to long long (when comparing against NULL)
template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
}
template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
}
#endif // CATCH_CONFIG_CPP11_LONG_LONG
#ifdef CATCH_CONFIG_CPP11_NULLPTR #ifdef CATCH_CONFIG_CPP11_NULLPTR
// pointer to nullptr_t (when comparing against nullptr) // pointer to nullptr_t (when comparing against nullptr)
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) { template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
return Evaluator<T*, T*, Op>::evaluate( NULL, rhs ); return Evaluator<T*, T*, Op>::evaluate( nullptr, rhs );
} }
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) { template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
return Evaluator<T*, T*, Op>::evaluate( lhs, NULL ); return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr );
} }
#endif // CATCH_CONFIG_CPP11_NULLPTR #endif // CATCH_CONFIG_CPP11_NULLPTR

View File

@@ -77,6 +77,7 @@ namespace Catch {
FreeFunctionTestCase::~FreeFunctionTestCase() {} FreeFunctionTestCase::~FreeFunctionTestCase() {}
IGeneratorInfo::~IGeneratorInfo() {} IGeneratorInfo::~IGeneratorInfo() {}
IGeneratorsForTest::~IGeneratorsForTest() {} IGeneratorsForTest::~IGeneratorsForTest() {}
WildcardPattern::~WildcardPattern() {}
TestSpec::Pattern::~Pattern() {} TestSpec::Pattern::~Pattern() {}
TestSpec::NamePattern::~NamePattern() {} TestSpec::NamePattern::~NamePattern() {}
TestSpec::TagPattern::~TagPattern() {} TestSpec::TagPattern::~TagPattern() {}

View File

@@ -108,68 +108,96 @@ namespace Matchers {
inline std::string makeString( std::string const& str ) { return str; } inline std::string makeString( std::string const& str ) { return str; }
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); } inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
struct CasedString
{
CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
: m_caseSensitivity( caseSensitivity ),
m_str( adjustString( str ) )
{}
std::string adjustString( std::string const& str ) const {
return m_caseSensitivity == CaseSensitive::No
? toLower( str )
: str;
}
std::string toStringSuffix() const
{
return m_caseSensitivity == CaseSensitive::No
? " (case insensitive)"
: "";
}
CaseSensitive::Choice m_caseSensitivity;
std::string m_str;
};
struct Equals : MatcherImpl<Equals, std::string> { struct Equals : MatcherImpl<Equals, std::string> {
Equals( std::string const& str ) : m_str( str ){} Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
Equals( Equals const& other ) : m_str( other.m_str ){} : m_data( str, caseSensitivity )
{}
Equals( Equals const& other ) : m_data( other.m_data ){}
virtual ~Equals(); virtual ~Equals();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return m_str == expr; return m_data.m_str == m_data.adjustString( expr );;
} }
virtual std::string toString() const { virtual std::string toString() const {
return "equals: \"" + m_str + "\""; return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
} }
std::string m_str; CasedString m_data;
}; };
struct Contains : MatcherImpl<Contains, std::string> { struct Contains : MatcherImpl<Contains, std::string> {
Contains( std::string const& substr ) : m_substr( substr ){} Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
Contains( Contains const& other ) : m_substr( other.m_substr ){} : m_data( substr, caseSensitivity ){}
Contains( Contains const& other ) : m_data( other.m_data ){}
virtual ~Contains(); virtual ~Contains();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return expr.find( m_substr ) != std::string::npos; return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
} }
virtual std::string toString() const { virtual std::string toString() const {
return "contains: \"" + m_substr + "\""; return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
} }
std::string m_substr; CasedString m_data;
}; };
struct StartsWith : MatcherImpl<StartsWith, std::string> { struct StartsWith : MatcherImpl<StartsWith, std::string> {
StartsWith( std::string const& substr ) : m_substr( substr ){} StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
StartsWith( StartsWith const& other ) : m_substr( other.m_substr ){} : m_data( substr, caseSensitivity ){}
StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
virtual ~StartsWith(); virtual ~StartsWith();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return expr.find( m_substr ) == 0; return m_data.adjustString( expr ).find( m_data.m_str ) == 0;
} }
virtual std::string toString() const { virtual std::string toString() const {
return "starts with: \"" + m_substr + "\""; return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
} }
std::string m_substr; CasedString m_data;
}; };
struct EndsWith : MatcherImpl<EndsWith, std::string> { struct EndsWith : MatcherImpl<EndsWith, std::string> {
EndsWith( std::string const& substr ) : m_substr( substr ){} EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
EndsWith( EndsWith const& other ) : m_substr( other.m_substr ){} : m_data( substr, caseSensitivity ){}
EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
virtual ~EndsWith(); virtual ~EndsWith();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return expr.find( m_substr ) == expr.size() - m_substr.size(); return m_data.adjustString( expr ).find( m_data.m_str ) == expr.size() - m_data.m_str.size();
} }
virtual std::string toString() const { virtual std::string toString() const {
return "ends with: \"" + m_substr + "\""; return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
} }
std::string m_substr; CasedString m_data;
}; };
} // namespace StdString } // namespace StdString
} // namespace Impl } // namespace Impl
@@ -199,17 +227,17 @@ namespace Matchers {
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 ); return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
} }
inline Impl::StdString::Equals Equals( std::string const& str ) { inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
return Impl::StdString::Equals( str ); return Impl::StdString::Equals( str, caseSensitivity );
} }
inline Impl::StdString::Equals Equals( const char* str ) { inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
return Impl::StdString::Equals( Impl::StdString::makeString( str ) ); return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity );
} }
inline Impl::StdString::Contains Contains( std::string const& substr ) { inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
return Impl::StdString::Contains( substr ); return Impl::StdString::Contains( substr, caseSensitivity );
} }
inline Impl::StdString::Contains Contains( const char* substr ) { inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
return Impl::StdString::Contains( Impl::StdString::makeString( substr ) ); return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity );
} }
inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) { inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
return Impl::StdString::StartsWith( substr ); return Impl::StdString::StartsWith( substr );

View File

@@ -72,7 +72,7 @@ namespace Catch {
inline size_t registerTestMethods() { inline size_t registerTestMethods() {
size_t noTestMethods = 0; size_t noTestMethods = 0;
int noClasses = objc_getClassList( NULL, 0 ); int noClasses = objc_getClassList( CATCH_NULL, 0 );
Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
objc_getClassList( classes, noClasses ); objc_getClassList( classes, noClasses );

View File

@@ -16,12 +16,12 @@ namespace Catch {
template<typename T> template<typename T>
class Option { class Option {
public: public:
Option() : nullableValue( NULL ) {} Option() : nullableValue( CATCH_NULL ) {}
Option( T const& _value ) Option( T const& _value )
: nullableValue( new( storage ) T( _value ) ) : nullableValue( new( storage ) T( _value ) )
{} {}
Option( Option const& _other ) Option( Option const& _other )
: nullableValue( _other ? new( storage ) T( *_other ) : NULL ) : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
{} {}
~Option() { ~Option() {
@@ -45,7 +45,7 @@ namespace Catch {
void reset() { void reset() {
if( nullableValue ) if( nullableValue )
nullableValue->~T(); nullableValue->~T();
nullableValue = NULL; nullableValue = CATCH_NULL;
} }
T& operator*() { return *nullableValue; } T& operator*() { return *nullableValue; }
@@ -57,10 +57,10 @@ namespace Catch {
return nullableValue ? *nullableValue : defaultValue; return nullableValue ? *nullableValue : defaultValue;
} }
bool some() const { return nullableValue != NULL; } bool some() const { return nullableValue != CATCH_NULL; }
bool none() const { return nullableValue == NULL; } bool none() const { return nullableValue == CATCH_NULL; }
bool operator !() const { return nullableValue == NULL; } bool operator !() const { return nullableValue == CATCH_NULL; }
operator SafeBool::type() const { operator SafeBool::type() const {
return SafeBool::makeSafe( some() ); return SafeBool::makeSafe( some() );
} }

View File

@@ -23,7 +23,7 @@ namespace Catch {
template<typename T> template<typename T>
class Ptr { class Ptr {
public: public:
Ptr() : m_p( NULL ){} Ptr() : m_p( CATCH_NULL ){}
Ptr( T* p ) : m_p( p ){ Ptr( T* p ) : m_p( p ){
if( m_p ) if( m_p )
m_p->addRef(); m_p->addRef();
@@ -39,7 +39,7 @@ namespace Catch {
void reset() { void reset() {
if( m_p ) if( m_p )
m_p->release(); m_p->release();
m_p = NULL; m_p = CATCH_NULL;
} }
Ptr& operator = ( T* p ){ Ptr& operator = ( T* p ){
Ptr temp( p ); Ptr temp( p );
@@ -56,8 +56,8 @@ namespace Catch {
const T* get() const{ return m_p; } const T* get() const{ return m_p; }
T& operator*() const { return *m_p; } T& operator*() const { return *m_p; }
T* operator->() const { return m_p; } T* operator->() const { return m_p; }
bool operator !() const { return m_p == NULL; } bool operator !() const { return m_p == CATCH_NULL; }
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); } operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
private: private:
T* m_p; T* m_p;

View File

@@ -55,7 +55,7 @@ namespace Catch {
// Single, global, instance // Single, global, instance
inline RegistryHub*& getTheRegistryHub() { inline RegistryHub*& getTheRegistryHub() {
static RegistryHub* theRegistryHub = NULL; static RegistryHub* theRegistryHub = CATCH_NULL;
if( !theRegistryHub ) if( !theRegistryHub )
theRegistryHub = new RegistryHub(); theRegistryHub = new RegistryHub();
return theRegistryHub; return theRegistryHub;
@@ -70,7 +70,7 @@ namespace Catch {
} }
void cleanUp() { void cleanUp() {
delete getTheRegistryHub(); delete getTheRegistryHub();
getTheRegistryHub() = NULL; getTheRegistryHub() = CATCH_NULL;
cleanUpContext(); cleanUpContext();
} }
std::string translateActiveException() { std::string translateActiveException() {

View File

@@ -25,7 +25,7 @@ namespace Catch {
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const { virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
FactoryMap::const_iterator it = m_factories.find( name ); FactoryMap::const_iterator it = m_factories.find( name );
if( it == m_factories.end() ) if( it == m_factories.end() )
return NULL; return CATCH_NULL;
return it->second->create( ReporterConfig( config ) ); return it->second->create( ReporterConfig( config ) );
} }

View File

@@ -11,6 +11,7 @@
#include "catch_result_type.h" #include "catch_result_type.h"
#include "catch_assertionresult.h" #include "catch_assertionresult.h"
#include "catch_common.h" #include "catch_common.h"
#include "catch_matchers.hpp"
namespace Catch { namespace Catch {
@@ -38,7 +39,8 @@ namespace Catch {
ResultBuilder( char const* macroName, ResultBuilder( char const* macroName,
SourceLineInfo const& lineInfo, SourceLineInfo const& lineInfo,
char const* capturedExpression, char const* capturedExpression,
ResultDisposition::Flags resultDisposition ); ResultDisposition::Flags resultDisposition,
char const* secondArg = "" );
template<typename T> template<typename T>
ExpressionLhs<T const&> operator <= ( T const& operand ); ExpressionLhs<T const&> operator <= ( T const& operand );
@@ -67,6 +69,9 @@ namespace Catch {
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal ); void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
void captureResult( ResultWas::OfType resultType ); void captureResult( ResultWas::OfType resultType );
void captureExpression(); void captureExpression();
void captureExpectedException( std::string const& expectedMessage );
void captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher );
void handleResult( AssertionResult const& result );
void react(); void react();
bool shouldDebugBreak() const; bool shouldDebugBreak() const;
bool allowThrows() const; bool allowThrows() const;

View File

@@ -14,15 +14,21 @@
#include "catch_interfaces_runner.h" #include "catch_interfaces_runner.h"
#include "catch_interfaces_capture.h" #include "catch_interfaces_capture.h"
#include "catch_interfaces_registry_hub.h" #include "catch_interfaces_registry_hub.h"
#include "catch_wildcard_pattern.hpp"
namespace Catch { namespace Catch {
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
return secondArg.empty() || secondArg == "\"\""
? capturedExpression
: capturedExpression + ", " + secondArg;
}
ResultBuilder::ResultBuilder( char const* macroName, ResultBuilder::ResultBuilder( char const* macroName,
SourceLineInfo const& lineInfo, SourceLineInfo const& lineInfo,
char const* capturedExpression, char const* capturedExpression,
ResultDisposition::Flags resultDisposition ) ResultDisposition::Flags resultDisposition,
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition ), char const* secondArg )
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
m_shouldDebugBreak( false ), m_shouldDebugBreak( false ),
m_shouldThrow( false ) m_shouldThrow( false )
{} {}
@@ -63,11 +69,37 @@ namespace Catch {
setResultType( resultType ); setResultType( resultType );
captureExpression(); captureExpression();
} }
void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
if( expectedMessage.empty() )
captureExpectedException( Matchers::Impl::Generic::AllOf<std::string>() );
else
captureExpectedException( Matchers::Equals( expectedMessage ) );
}
void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
assert( m_exprComponents.testFalse == false );
AssertionResultData data = m_data;
data.resultType = ResultWas::Ok;
data.reconstructedExpression = m_assertionInfo.capturedExpression;
std::string actualMessage = Catch::translateActiveException();
if( !matcher.match( actualMessage ) ) {
data.resultType = ResultWas::ExpressionFailed;
data.reconstructedExpression = actualMessage;
}
AssertionResult result( m_assertionInfo, data );
handleResult( result );
}
void ResultBuilder::captureExpression() { void ResultBuilder::captureExpression() {
AssertionResult result = build(); AssertionResult result = build();
handleResult( result );
}
void ResultBuilder::handleResult( AssertionResult const& result )
{
getResultCapture().assertionEnded( result ); getResultCapture().assertionEnded( result );
if( !result.isOk() ) { if( !result.isOk() ) {
if( getCurrentContext().getConfig()->shouldDebugBreak() ) if( getCurrentContext().getConfig()->shouldDebugBreak() )
m_shouldDebugBreak = true; m_shouldDebugBreak = true;

View File

@@ -59,11 +59,11 @@ namespace Catch {
public: public:
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter ) explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( config->name() ), : m_runInfo( _config->name() ),
m_context( getCurrentMutableContext() ), m_context( getCurrentMutableContext() ),
m_activeTestCase( NULL ), m_activeTestCase( CATCH_NULL ),
m_config( config ), m_config( _config ),
m_reporter( reporter ), m_reporter( reporter ),
m_prevRunner( m_context.getRunner() ), m_prevRunner( m_context.getRunner() ),
m_prevResultCapture( m_context.getResultCapture() ), m_prevResultCapture( m_context.getResultCapture() ),
@@ -78,7 +78,7 @@ namespace Catch {
virtual ~RunContext() { virtual ~RunContext() {
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
m_context.setRunner( m_prevRunner ); m_context.setRunner( m_prevRunner );
m_context.setConfig( NULL ); m_context.setConfig( Ptr<IConfig const>() );
m_context.setResultCapture( m_prevResultCapture ); m_context.setResultCapture( m_prevResultCapture );
m_context.setConfig( m_prevConfig ); m_context.setConfig( m_prevConfig );
} }
@@ -119,7 +119,7 @@ namespace Catch {
redirectedCerr, redirectedCerr,
aborting() ) ); aborting() ) );
m_activeTestCase = NULL; m_activeTestCase = CATCH_NULL;
m_testCaseTracker.reset(); m_testCaseTracker.reset();
return deltaTotals; return deltaTotals;
@@ -259,6 +259,8 @@ namespace Catch {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
TestCaseTracker::Guard guard( *m_testCaseTracker ); TestCaseTracker::Guard guard( *m_testCaseTracker );
seedRng( *m_config );
Timer timer; Timer timer;
timer.start(); timer.start();
if( m_reporter->getPreferences().shouldRedirectStdOut ) { if( m_reporter->getPreferences().shouldRedirectStdOut ) {

View File

@@ -36,7 +36,7 @@ namespace Catch {
RunningSection( std::string const& name ) RunningSection( std::string const& name )
: m_state( Root ), : m_state( Root ),
m_parent( NULL ), m_parent( CATCH_NULL ),
m_name( name ) m_name( name )
{} {}

View File

@@ -1,44 +0,0 @@
/*
* Created by Phil on 15/04/2013.
* Copyright 2013 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_SFINAE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED
// Try to detect if the current compiler supports SFINAE
#include "catch_compiler_capabilities.h"
namespace Catch {
struct TrueType {
static const bool value = true;
typedef void Enable;
char sizer[1];
};
struct FalseType {
static const bool value = false;
typedef void Disable;
char sizer[2];
};
#ifdef CATCH_CONFIG_SFINAE
template<bool> struct NotABooleanExpression;
template<bool c> struct If : NotABooleanExpression<c> {};
template<> struct If<true> : TrueType {};
template<> struct If<false> : FalseType {};
template<int size> struct SizedIf;
template<> struct SizedIf<sizeof(TrueType)> : TrueType {};
template<> struct SizedIf<sizeof(FalseType)> : FalseType {};
#endif // CATCH_CONFIG_SFINAE
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED

View File

@@ -65,7 +65,7 @@ namespace Catch {
}; };
Stream::Stream() Stream::Stream()
: streamBuf( NULL ), isOwned( false ) : streamBuf( CATCH_NULL ), isOwned( false )
{} {}
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned ) Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
@@ -75,7 +75,7 @@ namespace Catch {
void Stream::release() { void Stream::release() {
if( isOwned ) { if( isOwned ) {
delete streamBuf; delete streamBuf;
streamBuf = NULL; streamBuf = CATCH_NULL;
isOwned = false; isOwned = false;
} }
} }

View File

@@ -40,6 +40,8 @@ namespace Catch {
TestCaseInfo( TestCaseInfo const& other ); TestCaseInfo( TestCaseInfo const& other );
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
bool isHidden() const; bool isHidden() const;
bool throws() const; bool throws() const;
bool okToFail() const; bool okToFail() const;

View File

@@ -88,11 +88,26 @@ 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 );
} }
void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags )
{
testCaseInfo.tags = tags;
testCaseInfo.lcaseTags.clear();
std::ostringstream oss;
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
testCaseInfo.lcaseTags.insert( lcaseTag );
}
testCaseInfo.tagsAsString = oss.str();
}
TestCaseInfo::TestCaseInfo( std::string const& _name, TestCaseInfo::TestCaseInfo( std::string const& _name,
std::string const& _className, std::string const& _className,
std::string const& _description, std::string const& _description,
@@ -101,18 +116,10 @@ namespace Catch {
: name( _name ), : name( _name ),
className( _className ), className( _className ),
description( _description ), description( _description ),
tags( _tags ),
lineInfo( _lineInfo ), lineInfo( _lineInfo ),
properties( None ) properties( None )
{ {
std::ostringstream oss; setTags( *this, _tags );
for( std::set<std::string>::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
lcaseTags.insert( lcaseTag );
}
tagsAsString = oss.str();
} }
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )

View File

@@ -90,6 +90,8 @@ namespace Catch {
break; break;
case RunTests::InRandomOrder: case RunTests::InRandomOrder:
{ {
seedRng( config );
RandomNumberGenerator rng; RandomNumberGenerator rng;
std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng ); std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
} }
@@ -103,6 +105,7 @@ namespace Catch {
std::vector<TestCase> m_functionsInOrder; std::vector<TestCase> m_functionsInOrder;
std::vector<TestCase> m_nonHiddenFunctions; std::vector<TestCase> m_nonHiddenFunctions;
size_t m_unnamedCount; size_t m_unnamedCount;
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@@ -8,6 +8,8 @@
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
#include "catch_compiler_capabilities.h"
#include <map> #include <map>
#include <string> #include <string>
#include <assert.h> #include <assert.h>
@@ -16,9 +18,9 @@ namespace Catch {
namespace SectionTracking { namespace SectionTracking {
class TrackedSection { class TrackedSection {
typedef std::map<std::string, TrackedSection> TrackedSections; typedef std::map<std::string, TrackedSection> TrackedSections;
public: public:
enum RunState { enum RunState {
NotStarted, NotStarted,
@@ -26,58 +28,63 @@ namespace SectionTracking {
ExecutingChildren, ExecutingChildren,
Completed Completed
}; };
TrackedSection( std::string const& name, TrackedSection* parent ) TrackedSection( std::string const& name, TrackedSection* parent )
: m_name( name ), m_runState( NotStarted ), m_parent( parent ) : m_name( name ), m_runState( NotStarted ), m_parent( parent )
{} {}
RunState runState() const { return m_runState; } RunState runState() const { return m_runState; }
TrackedSection* findChild( std::string const& childName );
TrackedSection* acquireChild( std::string const& childName );
TrackedSection* findChild( std::string const& childName ) {
TrackedSections::iterator it = m_children.find( childName );
return it != m_children.end()
? &it->second
: NULL;
}
TrackedSection* acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
void enter() { void enter() {
if( m_runState == NotStarted ) if( m_runState == NotStarted )
m_runState = Executing; m_runState = Executing;
} }
void leave() { void leave();
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
TrackedSection* getParent() { TrackedSection* getParent() {
return m_parent; return m_parent;
} }
bool hasChildren() const { bool hasChildren() const {
return !m_children.empty(); return !m_children.empty();
} }
private: private:
std::string m_name; std::string m_name;
RunState m_runState; RunState m_runState;
TrackedSections m_children; TrackedSections m_children;
TrackedSection* m_parent; TrackedSection* m_parent;
}; };
inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
TrackedSections::iterator it = m_children.find( childName );
return it != m_children.end()
? &it->second
: CATCH_NULL;
}
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
if( TrackedSection* child = findChild( childName ) )
return child;
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
return findChild( childName );
}
inline void TrackedSection::leave() {
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
it != itEnd;
++it )
if( it->second.runState() != Completed ) {
m_runState = ExecutingChildren;
return;
}
m_runState = Completed;
}
class TestCaseTracker { class TestCaseTracker {
public: public:
TestCaseTracker( std::string const& testCaseName ) TestCaseTracker( std::string const& testCaseName )
: m_testCase( testCaseName, NULL ), : m_testCase( testCaseName, CATCH_NULL ),
m_currentSection( &m_testCase ), m_currentSection( &m_testCase ),
m_completedASectionThisRun( false ) m_completedASectionThisRun( false )
{} {}
@@ -94,7 +101,7 @@ namespace SectionTracking {
void leaveSection() { void leaveSection() {
m_currentSection->leave(); m_currentSection->leave();
m_currentSection = m_currentSection->getParent(); m_currentSection = m_currentSection->getParent();
assert( m_currentSection != NULL ); assert( m_currentSection != CATCH_NULL );
m_completedASectionThisRun = true; m_completedASectionThisRun = true;
} }

View File

@@ -13,63 +13,32 @@
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif
#include "catch_wildcard_pattern.hpp"
#include "catch_test_case_info.h" #include "catch_test_case_info.h"
#include <string> #include <string>
#include <vector> #include <vector>
namespace Catch { namespace Catch {
class TestSpec { class TestSpec {
struct Pattern : SharedImpl<> { struct Pattern : SharedImpl<> {
virtual ~Pattern(); virtual ~Pattern();
virtual bool matches( TestCaseInfo const& testCase ) const = 0; virtual bool matches( TestCaseInfo const& testCase ) const = 0;
}; };
class NamePattern : public Pattern { class NamePattern : public Pattern {
enum WildcardPosition {
NoWildcard = 0,
WildcardAtStart = 1,
WildcardAtEnd = 2,
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
};
public: public:
NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) { NamePattern( std::string const& name )
if( startsWith( m_name, "*" ) ) { : m_wildcardPattern( toLower( name ), CaseSensitive::No )
m_name = m_name.substr( 1 ); {}
m_wildcard = WildcardAtStart;
}
if( endsWith( m_name, "*" ) ) {
m_name = m_name.substr( 0, m_name.size()-1 );
m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
}
}
virtual ~NamePattern(); virtual ~NamePattern();
virtual bool matches( TestCaseInfo const& testCase ) const { virtual bool matches( TestCaseInfo const& testCase ) const {
switch( m_wildcard ) { return m_wildcardPattern.matches( toLower( testCase.name ) );
case NoWildcard:
return m_name == toLower( testCase.name );
case WildcardAtStart:
return endsWith( toLower( testCase.name ), m_name );
case WildcardAtEnd:
return startsWith( toLower( testCase.name ), m_name );
case WildcardAtBothEnds:
return contains( toLower( testCase.name ), m_name );
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#endif
throw std::logic_error( "Unknown enum" );
#ifdef __clang__
#pragma clang diagnostic pop
#endif
} }
private: private:
std::string m_name; WildcardPattern m_wildcardPattern;
WildcardPosition m_wildcard;
}; };
class TagPattern : public Pattern { class TagPattern : public Pattern {
public: public:
TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
@@ -80,6 +49,7 @@ namespace Catch {
private: private:
std::string m_tag; std::string m_tag;
}; };
class ExcludedPattern : public Pattern { class ExcludedPattern : public Pattern {
public: public:
ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}

View File

@@ -37,7 +37,7 @@ namespace Catch {
#else #else
uint64_t getCurrentTicks() { uint64_t getCurrentTicks() {
timeval t; timeval t;
gettimeofday(&t,NULL); gettimeofday(&t,CATCH_NULL);
return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec ); return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
} }
#endif #endif

View File

@@ -9,7 +9,6 @@
#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED #define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
#include "catch_common.h" #include "catch_common.h"
#include "catch_sfinae.hpp"
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
@@ -53,6 +52,11 @@ std::string toString( char value );
std::string toString( signed char value ); std::string toString( signed char value );
std::string toString( unsigned char value ); std::string toString( unsigned char value );
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
std::string toString( long long value );
std::string toString( unsigned long long value );
#endif
#ifdef CATCH_CONFIG_CPP11_NULLPTR #ifdef CATCH_CONFIG_CPP11_NULLPTR
std::string toString( std::nullptr_t ); std::string toString( std::nullptr_t );
#endif #endif
@@ -66,34 +70,15 @@ std::string toString( std::nullptr_t );
namespace Detail { namespace Detail {
extern std::string unprintableString; extern const std::string unprintableString;
// SFINAE is currently disabled by default for all compilers.
// If the non SFINAE version of IsStreamInsertable is ambiguous for you
// and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE
#ifdef CATCH_CONFIG_SFINAE
template<typename T>
class IsStreamInsertableHelper {
template<int N> struct TrueIfSizeable : TrueType {};
template<typename T2>
static TrueIfSizeable<sizeof((*(std::ostream*)0) << *((T2 const*)0))> dummy(T2*);
static FalseType dummy(...);
public:
typedef SizedIf<sizeof(dummy((T*)0))> type;
};
template<typename T>
struct IsStreamInsertable : IsStreamInsertableHelper<T>::type {};
#else
struct BorgType { struct BorgType {
template<typename T> BorgType( T const& ); template<typename T> BorgType( T const& );
}; };
struct TrueType { char sizer[1]; };
struct FalseType { char sizer[2]; };
TrueType& testStreamable( std::ostream& ); TrueType& testStreamable( std::ostream& );
FalseType testStreamable( FalseType ); FalseType testStreamable( FalseType );
@@ -106,8 +91,6 @@ namespace Detail {
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
}; };
#endif
#if defined(CATCH_CONFIG_CPP11_IS_ENUM) #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template<typename T, template<typename T,
bool IsEnum = std::is_enum<T>::value bool IsEnum = std::is_enum<T>::value
@@ -170,7 +153,7 @@ struct StringMaker<T*> {
template<typename U> template<typename U>
static std::string convert( U* p ) { static std::string convert( U* p ) {
if( !p ) if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL ); return "NULL";
else else
return Detail::rawMemoryToString( p ); return Detail::rawMemoryToString( p );
} }
@@ -180,7 +163,7 @@ template<typename R, typename C>
struct StringMaker<R C::*> { struct StringMaker<R C::*> {
static std::string convert( R C::* p ) { static std::string convert( R C::* p ) {
if( !p ) if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL ); return "NULL";
else else
return Detail::rawMemoryToString( p ); return Detail::rawMemoryToString( p );
} }

View File

@@ -15,9 +15,11 @@ namespace Catch {
namespace Detail { namespace Detail {
std::string unprintableString = "{?}"; const std::string unprintableString = "{?}";
namespace { namespace {
const int hexThreshold = 255;
struct Endianness { struct Endianness {
enum Arch { Big, Little }; enum Arch { Big, Little };
@@ -99,7 +101,7 @@ std::string toString( wchar_t* const value )
std::string toString( int value ) { std::string toString( int value ) {
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
if( value >= 255 ) if( value > Detail::hexThreshold )
oss << " (0x" << std::hex << value << ")"; oss << " (0x" << std::hex << value << ")";
return oss.str(); return oss.str();
} }
@@ -107,7 +109,7 @@ std::string toString( int value ) {
std::string toString( unsigned long value ) { std::string toString( unsigned long value ) {
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
if( value >= 255 ) if( value > Detail::hexThreshold )
oss << " (0x" << std::hex << value << ")"; oss << " (0x" << std::hex << value << ")";
return oss.str(); return oss.str();
} }
@@ -157,6 +159,23 @@ std::string toString( unsigned char value ) {
return toString( static_cast<char>( value ) ); return toString( static_cast<char>( value ) );
} }
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
std::string toString( long long value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
oss << " (0x" << std::hex << value << ")";
return oss.str();
}
std::string toString( unsigned long long value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
oss << " (0x" << std::hex << value << ")";
return oss.str();
}
#endif
#ifdef CATCH_CONFIG_CPP11_NULLPTR #ifdef CATCH_CONFIG_CPP11_NULLPTR
std::string toString( std::nullptr_t ) { std::string toString( std::nullptr_t ) {
return "nullptr"; return "nullptr";

View File

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

View File

@@ -0,0 +1,71 @@
/*
* Created by Phil on 13/7/2015.
* Copyright 2015 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
#include "catch_common.h"
namespace Catch
{
class WildcardPattern {
enum WildcardPosition {
NoWildcard = 0,
WildcardAtStart = 1,
WildcardAtEnd = 2,
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
};
public:
WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
: m_caseSensitivity( caseSensitivity ),
m_wildcard( NoWildcard ),
m_pattern( adjustCase( pattern ) )
{
if( startsWith( m_pattern, "*" ) ) {
m_pattern = m_pattern.substr( 1 );
m_wildcard = WildcardAtStart;
}
if( endsWith( m_pattern, "*" ) ) {
m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
}
}
virtual ~WildcardPattern();
virtual bool matches( std::string const& str ) const {
switch( m_wildcard ) {
case NoWildcard:
return m_pattern == adjustCase( str );
case WildcardAtStart:
return endsWith( adjustCase( str ), m_pattern );
case WildcardAtEnd:
return startsWith( adjustCase( str ), m_pattern );
case WildcardAtBothEnds:
return contains( adjustCase( str ), m_pattern );
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#endif
throw std::logic_error( "Unknown enum" );
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
private:
std::string adjustCase( std::string const& str ) const {
return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;
}
CaseSensitive::Choice m_caseSensitivity;
WildcardPosition m_wildcard;
std::string m_pattern;
};
}
#endif // TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED

View File

@@ -8,14 +8,72 @@
#ifndef TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
#include "../internal/catch_stream.h" #include "catch_stream.h"
#include "catch_compiler_capabilities.h"
#include "catch_suppress_warnings.h"
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <iomanip>
namespace Catch { namespace Catch {
class XmlEncode {
public:
enum ForWhat { ForTextNodes, ForAttributes };
XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
: m_str( str ),
m_forWhat( forWhat )
{}
void encodeTo( std::ostream& os ) const {
// Apostrophe escaping not necessary if we always use " to write attributes
// (see: http://www.w3.org/TR/xml/#syntax)
for( std::size_t i = 0; i < m_str.size(); ++ i ) {
char c = m_str[i];
switch( c ) {
case '<': os << "&lt;"; break;
case '&': os << "&amp;"; break;
case '>':
// See: http://www.w3.org/TR/xml/#syntax
if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
os << "&gt;";
else
os << c;
break;
case '\"':
if( m_forWhat == ForAttributes )
os << "&quot;";
else
os << c;
break;
default:
// Escape control chars - based on contribution by @espenalb in PR #465
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
else
os << c;
}
}
}
friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
xmlEncode.encodeTo( os );
return os;
}
private:
std::string m_str;
ForWhat m_forWhat;
};
class XmlWriter { class XmlWriter {
public: public:
@@ -27,7 +85,7 @@ namespace Catch {
ScopedElement( ScopedElement const& other ) ScopedElement( ScopedElement const& other )
: m_writer( other.m_writer ){ : m_writer( other.m_writer ){
other.m_writer = NULL; other.m_writer = CATCH_NULL;
} }
~ScopedElement() { ~ScopedElement() {
@@ -98,11 +156,8 @@ namespace Catch {
} }
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
if( !name.empty() && !attribute.empty() ) { if( !name.empty() && !attribute.empty() )
stream() << " " << name << "=\""; stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
writeEncodedText( attribute );
stream() << "\"";
}
return *this; return *this;
} }
@@ -113,9 +168,9 @@ namespace Catch {
template<typename T> template<typename T>
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
if( !name.empty() ) std::ostringstream oss;
stream() << " " << name << "=\"" << attribute << "\""; oss << attribute;
return *this; return writeAttribute( name, oss.str() );
} }
XmlWriter& writeText( std::string const& text, bool indent = true ) { XmlWriter& writeText( std::string const& text, bool indent = true ) {
@@ -124,7 +179,7 @@ namespace Catch {
ensureTagClosed(); ensureTagClosed();
if( tagWasOpen && indent ) if( tagWasOpen && indent )
stream() << m_indent; stream() << m_indent;
writeEncodedText( text ); stream() << XmlEncode( text );
m_needsNewline = true; m_needsNewline = true;
} }
return *this; return *this;
@@ -169,30 +224,6 @@ namespace Catch {
} }
} }
void writeEncodedText( std::string const& text ) {
static const char* charsToEncode = "<&\"";
std::string mtext = text;
std::string::size_type pos = mtext.find_first_of( charsToEncode );
while( pos != std::string::npos ) {
stream() << mtext.substr( 0, pos );
switch( mtext[pos] ) {
case '<':
stream() << "&lt;";
break;
case '&':
stream() << "&amp;";
break;
case '\"':
stream() << "&quot;";
break;
}
mtext = mtext.substr( pos+1 );
pos = mtext.find_first_of( charsToEncode );
}
stream() << mtext;
}
bool m_tagIsOpen; bool m_tagIsOpen;
bool m_needsNewline; bool m_needsNewline;
std::vector<std::string> m_tags; std::vector<std::string> m_tags;
@@ -201,4 +232,6 @@ namespace Catch {
}; };
} }
#include "catch_reenable_warnings.h"
#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED

View File

@@ -397,6 +397,17 @@ ExceptionTests.cpp:<line number>: FAILED:
due to unexpected exception with message: due to unexpected exception with message:
3.14 3.14
-------------------------------------------------------------------------------
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
with expansion:
expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
INFO and WARN do not abort tests INFO and WARN do not abort tests
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -786,6 +797,6 @@ with expansion:
"first" == "second" "first" == "second"
=============================================================================== ===============================================================================
test cases: 155 | 116 passed | 38 failed | 1 failed as expected test cases: 159 | 119 passed | 39 failed | 1 failed as expected
assertions: 765 | 673 passed | 79 failed | 13 failed as expected assertions: 784 | 691 passed | 80 failed | 13 failed as expected

View File

@@ -846,9 +846,7 @@ ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul ) REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul )
with expansion: with expansion:
18446744073709551615 (0x<hex digits>) 4294967295 (0x<hex digits>) > 4
>
4
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
comparisons between int variables comparisons between int variables
@@ -973,51 +971,51 @@ ConditionTests.cpp:<line number>
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( p == __null ) REQUIRE( p == nullptr )
with expansion: with expansion:
__null == 0 NULL == nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( p == pNULL ) REQUIRE( p == pNULL )
with expansion: with expansion:
__null == __null NULL == NULL
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( p != __null ) REQUIRE( p != nullptr )
with expansion: with expansion:
0x<hex digits> != 0 0x<hex digits> != nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( cp != __null ) REQUIRE( cp != nullptr )
with expansion: with expansion:
0x<hex digits> != 0 0x<hex digits> != nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( cpc != __null ) REQUIRE( cpc != nullptr )
with expansion: with expansion:
0x<hex digits> != 0 0x<hex digits> != nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( returnsNull() == __null ) REQUIRE( returnsNull() == nullptr )
with expansion: with expansion:
{null string} == 0 {null string} == nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( returnsConstNull() == __null ) REQUIRE( returnsConstNull() == nullptr )
with expansion: with expansion:
{null string} == 0 {null string} == nullptr
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( __null != p ) REQUIRE( nullptr != p )
with expansion: with expansion:
0 != 0x<hex digits> nullptr != 0x<hex digits>
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
'Not' checks that should succeed 'Not' checks that should succeed
@@ -1277,6 +1275,66 @@ ExceptionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ) REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) )
-------------------------------------------------------------------------------
Exception messages can be tested for
exact match
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
-------------------------------------------------------------------------------
Exception messages can be tested for
different case
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) )
-------------------------------------------------------------------------------
Exception messages can be tested for
wildcarded
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) )
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) )
-------------------------------------------------------------------------------
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
with expansion:
expected exception
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Generators over two ranges Generators over two ranges
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -3113,13 +3171,13 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( makeString( false ) != static_cast<char*>(__null) ) REQUIRE( makeString( false ) != static_cast<char*>(nullptr) )
with expansion: with expansion:
"valid string" != {null string} "valid string" != {null string}
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( makeString( true ) == static_cast<char*>(__null) ) REQUIRE( makeString( true ) == static_cast<char*>(nullptr) )
with expansion: with expansion:
{null string} == {null string} {null string} == {null string}
@@ -3316,7 +3374,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( "" Equals(__null) ) REQUIRE_THAT( "" Equals(nullptr) )
with expansion: with expansion:
"" equals: "" "" equals: ""
@@ -3702,6 +3760,142 @@ PASSED:
with expansion: with expansion:
""wide load"" == ""wide load"" ""wide load"" == ""wide load""
-------------------------------------------------------------------------------
XmlEncode
normal string
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "normal string" ) == "normal string" )
with expansion:
"normal string" == "normal string"
-------------------------------------------------------------------------------
XmlEncode
empty string
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "" ) == "" )
with expansion:
"" == ""
-------------------------------------------------------------------------------
XmlEncode
string with ampersand
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "smith & jones" ) == "smith &amp; jones" )
with expansion:
"smith &amp; jones" == "smith &amp; jones"
-------------------------------------------------------------------------------
XmlEncode
string with less-than
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "smith < jones" ) == "smith &lt; jones" )
with expansion:
"smith &lt; jones" == "smith &lt; jones"
-------------------------------------------------------------------------------
XmlEncode
string with greater-than
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "smith > jones" ) == "smith > jones" )
with expansion:
"smith > jones" == "smith > jones"
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]&gt; jones" )
with expansion:
"smith ]]&gt; jones"
==
"smith ]]&gt; jones"
-------------------------------------------------------------------------------
XmlEncode
string with quotes
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes )
with expansion:
"don't "quote" me on that"
==
"don't "quote" me on that"
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't &quot;quote&quot; me on that" )
with expansion:
"don't &quot;quote&quot; me on that"
==
"don't &quot;quote&quot; me on that"
-------------------------------------------------------------------------------
XmlEncode
string with control char (1)
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "[\x01]" ) == "[&#x1]" )
with expansion:
"[&#x1]" == "[&#x1]"
-------------------------------------------------------------------------------
XmlEncode
string with control char (x7F)
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( encode( "[\x7F]" ) == "[&#x7F]" )
with expansion:
"[&#x7F]" == "[&#x7F]"
-------------------------------------------------------------------------------
long long
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( l == std::numeric_limits<long long>::max() )
with expansion:
9223372036854775807 (0x<hex digits>)
==
9223372036854775807 (0x<hex digits>)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Process can be configured on command line Process can be configured on command line
default - no arguments default - no arguments
@@ -5863,9 +6057,9 @@ TrickyTests.cpp:<line number>
TrickyTests.cpp:<line number>: TrickyTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( obj.prop != __null ) REQUIRE( obj.prop != nullptr )
with expansion: with expansion:
0x<hex digits> != 0 0x<hex digits> != nullptr
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
(unimplemented) static bools can be evaluated (unimplemented) static bools can be evaluated
@@ -6092,9 +6286,7 @@ TrickyTests.cpp:<line number>:
PASSED: PASSED:
CHECK( m == &S::f ) CHECK( m == &S::f )
with expansion: with expansion:
0x<hex digits> 0x<hex digits> == 0x<hex digits>
==
0x<hex digits>
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
pointer to class pointer to class
@@ -6106,7 +6298,7 @@ TrickyTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( p == 0 ) REQUIRE( p == 0 )
with expansion: with expansion:
__null == 0 NULL == 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
null_ptr null_ptr
@@ -6118,7 +6310,7 @@ TrickyTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( ptr.get() == nullptr ) REQUIRE( ptr.get() == nullptr )
with expansion: with expansion:
__null == nullptr NULL == nullptr
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
X/level/0/a X/level/0/a
@@ -7944,6 +8136,6 @@ with expansion:
true true
=============================================================================== ===============================================================================
test cases: 155 | 100 passed | 54 failed | 1 failed as expected test cases: 159 | 103 passed | 55 failed | 1 failed as expected
assertions: 785 | 673 passed | 99 failed | 13 failed as expected assertions: 804 | 691 passed | 100 failed | 13 failed as expected

View File

@@ -1,5 +1,5 @@
<testsuites> <testsuites>
<testsuite name="all tests" errors="12" failures="87" tests="785" hostname="tbd" time="{duration}" timestamp="tbd"> <testsuite name="all tests" errors="12" failures="88" tests="804" hostname="tbd" time="{duration}" timestamp="tbd">
<testcase classname="global" name="toString(enum)" time="{duration}"/> <testcase classname="global" name="toString(enum)" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/> <testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum class)" time="{duration}"/> <testcase classname="global" name="toString(enum class)" time="{duration}"/>
@@ -251,6 +251,14 @@ ExceptionTests.cpp:<line number>
</error> </error>
</testcase> </testcase>
<testcase classname="global" name="NotImplemented exception" time="{duration}"/> <testcase classname="global" name="NotImplemented exception" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
ExceptionTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Generators over two ranges" time="{duration}"/> <testcase classname="global" name="Generators over two ranges" time="{duration}"/>
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/> <testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/> <testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
@@ -455,6 +463,15 @@ MiscTests.cpp:<line number>
<testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/> <testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/> <testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/> <testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/>
<testcase classname="XmlEncode" name="normal string" time="{duration}"/>
<testcase classname="XmlEncode" name="empty string" time="{duration}"/>
<testcase classname="XmlEncode" name="string with ampersand" time="{duration}"/>
<testcase classname="XmlEncode" name="string with less-than" time="{duration}"/>
<testcase classname="XmlEncode" name="string with greater-than" time="{duration}"/>
<testcase classname="XmlEncode" name="string with quotes" time="{duration}"/>
<testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/>
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
<testcase classname="global" name="long long" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/> <testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,11 @@
#include "catch.hpp" #include "catch.hpp"
#include "catch_test_spec_parser.hpp" #include "catch_test_spec_parser.hpp"
#ifdef __clang__
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
TEST_CASE( "Parse test names and tags", "" ) { TEST_CASE( "Parse test names and tags", "" ) {

View File

@@ -6,7 +6,8 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/ */
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif #endif
#include "catch.hpp" #include "catch.hpp"
@@ -265,32 +266,32 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" )
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
inline const char* returnsConstNull(){ return NULL; } inline const char* returnsConstNull(){ return CATCH_NULL; }
inline char* returnsNull(){ return NULL; } inline char* returnsNull(){ return CATCH_NULL; }
TEST_CASE( "Pointers can be compared to null", "" ) TEST_CASE( "Pointers can be compared to null", "" )
{ {
TestData* p = NULL; TestData* p = CATCH_NULL;
TestData* pNULL = NULL; TestData* pNULL = CATCH_NULL;
REQUIRE( p == NULL ); REQUIRE( p == CATCH_NULL );
REQUIRE( p == pNULL ); REQUIRE( p == pNULL );
TestData data; TestData data;
p = &data; p = &data;
REQUIRE( p != NULL ); REQUIRE( p != CATCH_NULL );
const TestData* cp = p; const TestData* cp = p;
REQUIRE( cp != NULL ); REQUIRE( cp != CATCH_NULL );
const TestData* const cpc = p; const TestData* const cpc = p;
REQUIRE( cpc != NULL ); REQUIRE( cpc != CATCH_NULL );
REQUIRE( returnsNull() == NULL ); REQUIRE( returnsNull() == CATCH_NULL );
REQUIRE( returnsConstNull() == NULL ); REQUIRE( returnsConstNull() == CATCH_NULL );
REQUIRE( NULL != p ); REQUIRE( CATCH_NULL != p );
} }
// Not (!) tests // Not (!) tests

View File

@@ -152,3 +152,23 @@ TEST_CASE( "NotImplemented exception", "" )
{ {
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ); REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
} }
TEST_CASE( "Exception messages can be tested for", "" ) {
using namespace Catch::Matchers;
SECTION( "exact match" )
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
SECTION( "different case" )
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) );
SECTION( "wildcarded" ) {
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) );
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) );
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) );
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) );
}
}
TEST_CASE( "Mismatching exception messages failing the test", "[.][failing]" ) {
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
}

View File

@@ -7,6 +7,7 @@
*/ */
#include "catch.hpp" #include "catch.hpp"
#include "catch_xmlwriter.hpp"
#include <iostream> #include <iostream>
@@ -124,13 +125,13 @@ TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
inline const char* makeString( bool makeNull ) inline const char* makeString( bool makeNull )
{ {
return makeNull ? NULL : "valid string"; return makeNull ? CATCH_NULL : "valid string";
} }
TEST_CASE( "null strings", "" ) TEST_CASE( "null strings", "" )
{ {
REQUIRE( makeString( false ) != static_cast<char*>(NULL)); REQUIRE( makeString( false ) != static_cast<char*>(CATCH_NULL));
REQUIRE( makeString( true ) == static_cast<char*>(NULL)); REQUIRE( makeString( true ) == static_cast<char*>(CATCH_NULL));
} }
@@ -233,7 +234,7 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]")
} }
TEST_CASE("Equals string matcher, with NULL", "[matchers]") TEST_CASE("Equals string matcher, with NULL", "[matchers]")
{ {
REQUIRE_THAT("", Equals(NULL)); REQUIRE_THAT("", Equals(CATCH_NULL));
} }
TEST_CASE("AllOf matcher", "[matchers]") TEST_CASE("AllOf matcher", "[matchers]")
{ {
@@ -381,6 +382,50 @@ TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
CHECK( result == "\"wide load\"" ); CHECK( result == "\"wide load\"" );
} }
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
std::ostringstream oss;
oss << Catch::XmlEncode( str, forWhat );
return oss.str();
}
TEST_CASE( "XmlEncode" ) {
SECTION( "normal string" ) {
REQUIRE( encode( "normal string" ) == "normal string" );
}
SECTION( "empty string" ) {
REQUIRE( encode( "" ) == "" );
}
SECTION( "string with ampersand" ) {
REQUIRE( encode( "smith & jones" ) == "smith &amp; jones" );
}
SECTION( "string with less-than" ) {
REQUIRE( encode( "smith < jones" ) == "smith &lt; jones" );
}
SECTION( "string with greater-than" ) {
REQUIRE( encode( "smith > jones" ) == "smith > jones" );
REQUIRE( encode( "smith ]]> jones" ) == "smith ]]&gt; jones" );
}
SECTION( "string with quotes" ) {
std::string stringWithQuotes = "don't \"quote\" me on that";
REQUIRE( encode( stringWithQuotes ) == stringWithQuotes );
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't &quot;quote&quot; me on that" );
}
SECTION( "string with control char (1)" ) {
REQUIRE( encode( "[\x01]" ) == "[&#x1]" );
}
SECTION( "string with control char (x7F)" ) {
REQUIRE( encode( "[\x7F]" ) == "[&#x7F]" );
}
}
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
TEST_CASE( "long long" ) {
long long l = std::numeric_limits<long long>::max();
REQUIRE( l == std::numeric_limits<long long>::max() );
}
#endif
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) { //TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
// int i = 0; // int i = 0;
// int x = 10/i; // This should cause the signal to fire // int x = 10/i; // This should cause the signal to fire

View File

@@ -7,7 +7,8 @@
*/ */
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif #endif
#include "internal/catch_test_case_tracker.hpp" #include "internal/catch_test_case_tracker.hpp"

View File

@@ -1,2 +1,4 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header // This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "catch_suppress_warnings.h"
#include "catch_xmlwriter.hpp" #include "catch_xmlwriter.hpp"
#include "catch_reenable_warnings.h"

View File

@@ -16,8 +16,9 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
#pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif #endif
@@ -39,7 +40,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
return ""; return "";
} }
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); } inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) { TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {

View File

@@ -42,12 +42,14 @@ TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) ); CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) );
} }
#ifdef CATCH_CONFIG_CPP11_NULLPTR
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" ) TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
{ {
typedef std::tuple<std::nullptr_t,int,const char *> type; typedef std::tuple<std::nullptr_t,int,const char *> type;
type value { nullptr, 42, "Catch me" }; type value { nullptr, 42, "Catch me" };
CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) ); CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) );
} }
#endif
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@@ -234,7 +234,7 @@ struct Obj
TEST_CASE("boolean member", "[Tricky]") TEST_CASE("boolean member", "[Tricky]")
{ {
Obj obj; Obj obj;
REQUIRE( obj.prop != NULL ); REQUIRE( obj.prop != CATCH_NULL );
} }
// Tests for a problem submitted by Ralph McArdell // Tests for a problem submitted by Ralph McArdell

View File

@@ -91,7 +91,6 @@
26711C91195D47820033EDA2 /* catch_tag_alias.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias.h; sourceTree = "<group>"; }; 26711C91195D47820033EDA2 /* catch_tag_alias.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias.h; sourceTree = "<group>"; };
26711C92195D48F60033EDA2 /* catch_tag_alias_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_tag_alias_registry.hpp; sourceTree = "<group>"; }; 26711C92195D48F60033EDA2 /* catch_tag_alias_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_tag_alias_registry.hpp; sourceTree = "<group>"; };
26711C94195D4B120033EDA2 /* catch_tag_alias_registry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias_registry.h; sourceTree = "<group>"; }; 26711C94195D4B120033EDA2 /* catch_tag_alias_registry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tag_alias_registry.h; sourceTree = "<group>"; };
26759472171C72A400A84BD1 /* catch_sfinae.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_sfinae.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_compiler_capabilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_compiler_capabilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; }; 26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; };
26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; }; 26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; };
@@ -109,6 +108,7 @@
269831E719121CA500BB0CE0 /* catch_reporter_compact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_compact.hpp; sourceTree = "<group>"; }; 269831E719121CA500BB0CE0 /* catch_reporter_compact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_compact.hpp; sourceTree = "<group>"; };
26AEAF1617BEA18E009E32C9 /* catch_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_platform.h; sourceTree = "<group>"; }; 26AEAF1617BEA18E009E32C9 /* catch_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_platform.h; sourceTree = "<group>"; };
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; }; 26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_wildcard_pattern.hpp; sourceTree = "<group>"; };
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; }; 26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; }; 4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; }; 4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
@@ -453,6 +453,7 @@
266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */, 266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */,
266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */, 266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */,
4A6D0C49149B3E3D00DB3EAA /* catch_common.h */, 4A6D0C49149B3E3D00DB3EAA /* catch_common.h */,
262E739A1846759000CAC268 /* catch_common.hpp */,
4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */, 4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */,
261488FF184DC4A20041FBEB /* catch_debugger.h */, 261488FF184DC4A20041FBEB /* catch_debugger.h */,
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */, 4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */,
@@ -461,17 +462,16 @@
4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */, 4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */,
4AEE0326161431070071E950 /* catch_streambuf.h */, 4AEE0326161431070071E950 /* catch_streambuf.h */,
4ACE21C8166CA19700FB5509 /* catch_option.hpp */, 4ACE21C8166CA19700FB5509 /* catch_option.hpp */,
26759472171C72A400A84BD1 /* catch_sfinae.hpp */,
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */, 26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */,
26DACF2F17206D3400A21326 /* catch_text.h */, 26DACF2F17206D3400A21326 /* catch_text.h */,
263FD06117AF8DF200988A20 /* catch_timer.h */, 263FD06117AF8DF200988A20 /* catch_timer.h */,
26AEAF1617BEA18E009E32C9 /* catch_platform.h */, 26AEAF1617BEA18E009E32C9 /* catch_platform.h */,
262E739A1846759000CAC268 /* catch_common.hpp */,
261488FC184D1DC10041FBEB /* catch_stream.h */, 261488FC184D1DC10041FBEB /* catch_stream.h */,
268F47B018A93F7800D8C14F /* catch_clara.h */, 268F47B018A93F7800D8C14F /* catch_clara.h */,
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */, 2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,
2656C227192A78410040DB02 /* catch_reenable_warnings.h */, 2656C227192A78410040DB02 /* catch_reenable_warnings.h */,
263F7A4519A66608009474C2 /* catch_fatal_condition.hpp */, 263F7A4519A66608009474C2 /* catch_fatal_condition.hpp */,
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */,
); );
name = Infrastructure; name = Infrastructure;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@@ -15,7 +15,8 @@ pathParser = re.compile( r'(.*?)/(.*\..pp)(.*)' )
lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' ) lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' )
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' ) hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' ) durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' )
versionParser = re.compile( r'(.*?)Catch v[0-9]*.[0-9]* b[0-9]*(.*)' ) versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)' )
devVersionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)' )
if len(sys.argv) == 2: if len(sys.argv) == 2:
cmdPath = sys.argv[1] cmdPath = sys.argv[1]
@@ -41,9 +42,13 @@ def filterLine( line ):
if path.startswith( catchPath ): if path.startswith( catchPath ):
path = path[1+len(catchPath):] path = path[1+len(catchPath):]
line = m.group(1) + path + m.group(3) line = m.group(1) + path + m.group(3)
m = versionParser.match( line ) m = devVersionParser.match( line )
if m: if m:
line = m.group(1) + "<version>" + m.group(2) line = m.group(1) + "<version>" + m.group(2)
else:
m = versionParser.match( line )
if m:
line = m.group(1) + "<version>" + m.group(2)
while True: while True:
m = hexParser.match( line ) m = hexParser.match( line )

File diff suppressed because it is too large Load Diff