mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-11 07:55:39 +02:00
Compare commits
18 Commits
v1.2.1
...
v1.2.1-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
93a842e2f0 | ||
![]() |
85de743d70 | ||
![]() |
5d5ed5a283 | ||
![]() |
57df3ba998 | ||
![]() |
e6b365dc8c | ||
![]() |
02e1966db3 | ||
![]() |
584032dfa4 | ||
![]() |
18acff62d3 | ||
![]() |
c1ca0fdabe | ||
![]() |
d6f1446e4e | ||
![]() |
62e517f833 | ||
![]() |
6160a2b079 | ||
![]() |
8f66e3495b | ||
![]() |
d87e551efa | ||
![]() |
b971fe785b | ||
![]() |
088c5bc53e | ||
![]() |
680b1a881b | ||
![]() |
805de43a3d |
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
*v1.2.1*
|
||||
*v1.2.1-develop.6*
|
||||
|
||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
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.
|
||||
|
||||
### 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
|
||||
|
||||
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.
|
||||
|
@@ -70,8 +70,9 @@
|
||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
|
||||
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
|
||||
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" )
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, expectedMessage, "CATCH_REQUIRE_THROWS_WITH" )
|
||||
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
|
||||
|
||||
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
|
||||
@@ -82,6 +83,7 @@
|
||||
|
||||
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, expectedMessage, "CATCH_CHECK_THROWS_WITH" )
|
||||
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
|
||||
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
||||
@@ -135,8 +137,9 @@
|
||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
|
||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
|
||||
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "REQUIRE_THROWS" )
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
|
||||
#define REQUIRE_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, expectedMessage, "REQUIRE_THROWS_WITH" )
|
||||
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
|
||||
|
||||
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
|
||||
@@ -145,8 +148,9 @@
|
||||
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
|
||||
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
|
||||
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" )
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
|
||||
#define CHECK_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, expectedMessage, "CHECK_THROWS_WITH" )
|
||||
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
|
||||
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
||||
|
@@ -104,6 +104,26 @@ namespace Catch {
|
||||
Ptr<IStreamingReporter> m_reporter;
|
||||
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 {
|
||||
static bool alreadyInstantiated;
|
||||
@@ -175,7 +195,10 @@ namespace Catch {
|
||||
{
|
||||
config(); // Force config to be constructed
|
||||
|
||||
std::srand( m_configData.rngSeed );
|
||||
if( m_configData.filenamesAsTags )
|
||||
applyFilenamesAsTags();
|
||||
|
||||
seedRng( *m_config );
|
||||
|
||||
Runner runner( m_config );
|
||||
|
||||
|
18
include/external/clara.h
vendored
18
include/external/clara.h
vendored
@@ -264,11 +264,11 @@ namespace Clara {
|
||||
template<typename ConfigT>
|
||||
class BoundArgFunction {
|
||||
public:
|
||||
BoundArgFunction() : functionObj( NULL ) {}
|
||||
BoundArgFunction() : functionObj( CATCH_NULL ) {}
|
||||
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {}
|
||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CATCH_NULL ) {}
|
||||
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
|
||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL;
|
||||
delete functionObj;
|
||||
functionObj = newFunctionObj;
|
||||
return *this;
|
||||
@@ -284,7 +284,7 @@ namespace Clara {
|
||||
bool takesArg() const { return functionObj->takesArg(); }
|
||||
|
||||
bool isSet() const {
|
||||
return functionObj != NULL;
|
||||
return functionObj != CATCH_NULL;
|
||||
}
|
||||
private:
|
||||
IArgFunction<ConfigT>* functionObj;
|
||||
@@ -585,8 +585,8 @@ namespace Clara {
|
||||
m_arg->description = description;
|
||||
return *this;
|
||||
}
|
||||
ArgBuilder& detail( std::string const& detail ) {
|
||||
m_arg->detail = detail;
|
||||
ArgBuilder& detail( std::string const& _detail ) {
|
||||
m_arg->detail = _detail;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -670,14 +670,14 @@ namespace Clara {
|
||||
maxWidth = (std::max)( maxWidth, it->commands().size() );
|
||||
|
||||
for( it = itBegin; it != itEnd; ++it ) {
|
||||
Detail::Text usage( it->commands(), Detail::TextAttributes()
|
||||
Detail::Text usageText( it->commands(), Detail::TextAttributes()
|
||||
.setWidth( maxWidth+indent )
|
||||
.setIndent( indent ) );
|
||||
Detail::Text desc( it->description, Detail::TextAttributes()
|
||||
.setWidth( width - maxWidth - 3 ) );
|
||||
|
||||
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
|
||||
std::string usageCol = i < usage.size() ? usage[i] : "";
|
||||
for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
|
||||
std::string usageCol = i < usageText.size() ? usageText[i] : "";
|
||||
os << usageCol;
|
||||
|
||||
if( i < desc.size() && !desc[i].empty() )
|
||||
|
@@ -66,16 +66,16 @@
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, expectedMessage, macroName ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, expectedMessage ); \
|
||||
if( __catchResult.allowThrows() ) \
|
||||
try { \
|
||||
expr; \
|
||||
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||
__catchResult.captureExpectedException( expectedMessage ); \
|
||||
} \
|
||||
else \
|
||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||
|
@@ -153,6 +153,10 @@ namespace Catch {
|
||||
.describe( "load test names to run from a file" )
|
||||
.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
|
||||
cli["--list-test-names-only"]
|
||||
.describe( "list all/matching test cases names only" )
|
||||
@@ -173,7 +177,7 @@ namespace Catch {
|
||||
cli["--force-colour"]
|
||||
.describe( "force colourised output" )
|
||||
.bind( &ConfigData::forceColour );
|
||||
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include "catch_compiler_capabilities.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct IConfig;
|
||||
|
||||
class NonCopyable {
|
||||
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
@@ -109,6 +111,9 @@ namespace Catch {
|
||||
|
||||
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
|
||||
// >> +StreamEndStop
|
||||
// as well as
|
||||
|
@@ -82,6 +82,14 @@ namespace Catch {
|
||||
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 ) {
|
||||
#ifndef __GNUG__
|
||||
os << info.file << "(" << info.line << ")";
|
||||
|
@@ -162,6 +162,12 @@
|
||||
# define CATCH_NOEXCEPT_IS(x)
|
||||
#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
|
||||
|
||||
|
@@ -38,6 +38,7 @@ namespace Catch {
|
||||
showHelp( false ),
|
||||
showInvisibles( false ),
|
||||
forceColour( false ),
|
||||
filenamesAsTags( false ),
|
||||
abortAfter( -1 ),
|
||||
rngSeed( 0 ),
|
||||
verbosity( Verbosity::Normal ),
|
||||
@@ -57,6 +58,7 @@ namespace Catch {
|
||||
bool showHelp;
|
||||
bool showInvisibles;
|
||||
bool forceColour;
|
||||
bool filenamesAsTags;
|
||||
|
||||
int abortAfter;
|
||||
unsigned int rngSeed;
|
||||
|
@@ -60,12 +60,13 @@ namespace {
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO 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 ) {
|
||||
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::Red: return setTextAttribute( FOREGROUND_RED );
|
||||
case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
|
||||
@@ -85,10 +86,11 @@ namespace {
|
||||
|
||||
private:
|
||||
void setTextAttribute( WORD _textAttribute ) {
|
||||
SetConsoleTextAttribute( stdoutHandle, _textAttribute );
|
||||
SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
|
||||
}
|
||||
HANDLE stdoutHandle;
|
||||
WORD originalAttributes;
|
||||
WORD originalForegroundAttributes;
|
||||
WORD originalBackgroundAttributes;
|
||||
};
|
||||
|
||||
IColourImpl* platformColourInstance() {
|
||||
|
@@ -17,7 +17,7 @@ namespace Catch {
|
||||
|
||||
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& );
|
||||
void operator=( Context const& );
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Catch {
|
||||
m_generatorsByTestName.find( testName );
|
||||
return it != m_generatorsByTestName.end()
|
||||
? it->second
|
||||
: NULL;
|
||||
: CATCH_NULL;
|
||||
}
|
||||
|
||||
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
||||
@@ -84,7 +84,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
namespace {
|
||||
Context* currentContext = NULL;
|
||||
Context* currentContext = CATCH_NULL;
|
||||
}
|
||||
IMutableContext& getCurrentMutableContext() {
|
||||
if( !currentContext )
|
||||
@@ -105,7 +105,7 @@ namespace Catch {
|
||||
|
||||
void cleanUpContext() {
|
||||
delete currentContext;
|
||||
currentContext = NULL;
|
||||
currentContext = CATCH_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@
|
||||
// Call sysctl.
|
||||
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@@ -163,10 +163,10 @@ namespace Internal {
|
||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||
// pointer to nullptr_t (when comparing against nullptr)
|
||||
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( CATCH_NULL, rhs );
|
||||
}
|
||||
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, CATCH_NULL );
|
||||
}
|
||||
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
||||
|
||||
|
@@ -72,7 +72,7 @@ namespace Catch {
|
||||
|
||||
inline size_t registerTestMethods() {
|
||||
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);
|
||||
objc_getClassList( classes, noClasses );
|
||||
|
@@ -16,12 +16,12 @@ namespace Catch {
|
||||
template<typename T>
|
||||
class Option {
|
||||
public:
|
||||
Option() : nullableValue( NULL ) {}
|
||||
Option() : nullableValue( CATCH_NULL ) {}
|
||||
Option( T const& _value )
|
||||
: nullableValue( new( storage ) T( _value ) )
|
||||
{}
|
||||
Option( Option const& _other )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : NULL )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
|
||||
{}
|
||||
|
||||
~Option() {
|
||||
@@ -45,7 +45,7 @@ namespace Catch {
|
||||
void reset() {
|
||||
if( nullableValue )
|
||||
nullableValue->~T();
|
||||
nullableValue = NULL;
|
||||
nullableValue = CATCH_NULL;
|
||||
}
|
||||
|
||||
T& operator*() { return *nullableValue; }
|
||||
@@ -57,10 +57,10 @@ namespace Catch {
|
||||
return nullableValue ? *nullableValue : defaultValue;
|
||||
}
|
||||
|
||||
bool some() const { return nullableValue != NULL; }
|
||||
bool none() const { return nullableValue == NULL; }
|
||||
bool some() const { return nullableValue != CATCH_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 {
|
||||
return SafeBool::makeSafe( some() );
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ namespace Catch {
|
||||
template<typename T>
|
||||
class Ptr {
|
||||
public:
|
||||
Ptr() : m_p( NULL ){}
|
||||
Ptr() : m_p( CATCH_NULL ){}
|
||||
Ptr( T* p ) : m_p( p ){
|
||||
if( m_p )
|
||||
m_p->addRef();
|
||||
@@ -39,7 +39,7 @@ namespace Catch {
|
||||
void reset() {
|
||||
if( m_p )
|
||||
m_p->release();
|
||||
m_p = NULL;
|
||||
m_p = CATCH_NULL;
|
||||
}
|
||||
Ptr& operator = ( T* p ){
|
||||
Ptr temp( p );
|
||||
@@ -56,8 +56,8 @@ namespace Catch {
|
||||
const T* get() const{ return m_p; }
|
||||
T& operator*() const { return *m_p; }
|
||||
T* operator->() const { return m_p; }
|
||||
bool operator !() const { return m_p == NULL; }
|
||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); }
|
||||
bool operator !() const { return m_p == CATCH_NULL; }
|
||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
|
||||
|
||||
private:
|
||||
T* m_p;
|
||||
|
@@ -55,7 +55,7 @@ namespace Catch {
|
||||
|
||||
// Single, global, instance
|
||||
inline RegistryHub*& getTheRegistryHub() {
|
||||
static RegistryHub* theRegistryHub = NULL;
|
||||
static RegistryHub* theRegistryHub = CATCH_NULL;
|
||||
if( !theRegistryHub )
|
||||
theRegistryHub = new RegistryHub();
|
||||
return theRegistryHub;
|
||||
@@ -70,7 +70,7 @@ namespace Catch {
|
||||
}
|
||||
void cleanUp() {
|
||||
delete getTheRegistryHub();
|
||||
getTheRegistryHub() = NULL;
|
||||
getTheRegistryHub() = CATCH_NULL;
|
||||
cleanUpContext();
|
||||
}
|
||||
std::string translateActiveException() {
|
||||
|
@@ -25,7 +25,7 @@ namespace Catch {
|
||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
||||
FactoryMap::const_iterator it = m_factories.find( name );
|
||||
if( it == m_factories.end() )
|
||||
return NULL;
|
||||
return CATCH_NULL;
|
||||
return it->second->create( ReporterConfig( config ) );
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,8 @@ namespace Catch {
|
||||
ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition );
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg = "" );
|
||||
|
||||
template<typename T>
|
||||
ExpressionLhs<T const&> operator <= ( T const& operand );
|
||||
@@ -67,6 +68,8 @@ namespace Catch {
|
||||
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
|
||||
void captureResult( ResultWas::OfType resultType );
|
||||
void captureExpression();
|
||||
void captureExpectedException( std::string const& expectedMessage );
|
||||
void handleResult( AssertionResult const& result );
|
||||
void react();
|
||||
bool shouldDebugBreak() const;
|
||||
bool allowThrows() const;
|
||||
|
@@ -18,11 +18,17 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
|
||||
return secondArg.empty()
|
||||
? capturedExpression
|
||||
: capturedExpression + ", \"" + secondArg + "\"";
|
||||
}
|
||||
ResultBuilder::ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition )
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition ),
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg )
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||
m_shouldDebugBreak( false ),
|
||||
m_shouldThrow( false )
|
||||
{}
|
||||
@@ -64,10 +70,31 @@ namespace Catch {
|
||||
captureExpression();
|
||||
}
|
||||
|
||||
void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
|
||||
assert( m_exprComponents.testFalse == false );
|
||||
AssertionResultData data = m_data;
|
||||
data.resultType = ResultWas::Ok;
|
||||
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||
if( expectedMessage != "" ) {
|
||||
|
||||
std::string actualMessage = Catch::translateActiveException();
|
||||
if( expectedMessage != actualMessage ) {
|
||||
data.resultType = ResultWas::ExpressionFailed;
|
||||
data.reconstructedExpression = actualMessage;
|
||||
}
|
||||
}
|
||||
AssertionResult result( m_assertionInfo, data );
|
||||
handleResult( result );
|
||||
}
|
||||
|
||||
void ResultBuilder::captureExpression() {
|
||||
AssertionResult result = build();
|
||||
handleResult( result );
|
||||
}
|
||||
void ResultBuilder::handleResult( AssertionResult const& result )
|
||||
{
|
||||
getResultCapture().assertionEnded( result );
|
||||
|
||||
|
||||
if( !result.isOk() ) {
|
||||
if( getCurrentContext().getConfig()->shouldDebugBreak() )
|
||||
m_shouldDebugBreak = true;
|
||||
|
@@ -59,11 +59,11 @@ namespace Catch {
|
||||
|
||||
public:
|
||||
|
||||
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
||||
: m_runInfo( config->name() ),
|
||||
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
||||
: m_runInfo( _config->name() ),
|
||||
m_context( getCurrentMutableContext() ),
|
||||
m_activeTestCase( NULL ),
|
||||
m_config( config ),
|
||||
m_activeTestCase( CATCH_NULL ),
|
||||
m_config( _config ),
|
||||
m_reporter( reporter ),
|
||||
m_prevRunner( m_context.getRunner() ),
|
||||
m_prevResultCapture( m_context.getResultCapture() ),
|
||||
@@ -78,7 +78,7 @@ namespace Catch {
|
||||
virtual ~RunContext() {
|
||||
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
||||
m_context.setRunner( m_prevRunner );
|
||||
m_context.setConfig( NULL );
|
||||
m_context.setConfig( Ptr<IConfig const>() );
|
||||
m_context.setResultCapture( m_prevResultCapture );
|
||||
m_context.setConfig( m_prevConfig );
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace Catch {
|
||||
redirectedCerr,
|
||||
aborting() ) );
|
||||
|
||||
m_activeTestCase = NULL;
|
||||
m_activeTestCase = CATCH_NULL;
|
||||
m_testCaseTracker.reset();
|
||||
|
||||
return deltaTotals;
|
||||
@@ -259,6 +259,8 @@ namespace Catch {
|
||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
||||
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
||||
|
||||
seedRng( *m_config );
|
||||
|
||||
Timer timer;
|
||||
timer.start();
|
||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||
|
@@ -36,7 +36,7 @@ namespace Catch {
|
||||
|
||||
RunningSection( std::string const& name )
|
||||
: m_state( Root ),
|
||||
m_parent( NULL ),
|
||||
m_parent( CATCH_NULL ),
|
||||
m_name( name )
|
||||
{}
|
||||
|
||||
|
@@ -65,7 +65,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
Stream::Stream()
|
||||
: streamBuf( NULL ), isOwned( false )
|
||||
: streamBuf( CATCH_NULL ), isOwned( false )
|
||||
{}
|
||||
|
||||
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
|
||||
@@ -75,7 +75,7 @@ namespace Catch {
|
||||
void Stream::release() {
|
||||
if( isOwned ) {
|
||||
delete streamBuf;
|
||||
streamBuf = NULL;
|
||||
streamBuf = CATCH_NULL;
|
||||
isOwned = false;
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,8 @@ namespace Catch {
|
||||
|
||||
TestCaseInfo( TestCaseInfo const& other );
|
||||
|
||||
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
|
||||
|
||||
bool isHidden() const;
|
||||
bool throws() const;
|
||||
bool okToFail() const;
|
||||
|
@@ -88,11 +88,26 @@ namespace Catch {
|
||||
tags.insert( "hide" );
|
||||
tags.insert( "." );
|
||||
}
|
||||
|
||||
|
||||
TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
|
||||
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,
|
||||
std::string const& _className,
|
||||
std::string const& _description,
|
||||
@@ -101,18 +116,10 @@ namespace Catch {
|
||||
: name( _name ),
|
||||
className( _className ),
|
||||
description( _description ),
|
||||
tags( _tags ),
|
||||
lineInfo( _lineInfo ),
|
||||
properties( None )
|
||||
{
|
||||
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 );
|
||||
properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
|
||||
lcaseTags.insert( lcaseTag );
|
||||
}
|
||||
tagsAsString = oss.str();
|
||||
setTags( *this, _tags );
|
||||
}
|
||||
|
||||
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
|
||||
|
@@ -90,6 +90,8 @@ namespace Catch {
|
||||
break;
|
||||
case RunTests::InRandomOrder:
|
||||
{
|
||||
seedRng( config );
|
||||
|
||||
RandomNumberGenerator rng;
|
||||
std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
|
||||
}
|
||||
@@ -103,6 +105,7 @@ namespace Catch {
|
||||
std::vector<TestCase> m_functionsInOrder;
|
||||
std::vector<TestCase> m_nonHiddenFunctions;
|
||||
size_t m_unnamedCount;
|
||||
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||
|
||||
#include "catch_compiler_capabilities.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
@@ -60,7 +62,7 @@ namespace SectionTracking {
|
||||
TrackedSections::iterator it = m_children.find( childName );
|
||||
return it != m_children.end()
|
||||
? &it->second
|
||||
: NULL;
|
||||
: CATCH_NULL;
|
||||
}
|
||||
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
||||
if( TrackedSection* child = findChild( childName ) )
|
||||
@@ -82,7 +84,7 @@ namespace SectionTracking {
|
||||
class TestCaseTracker {
|
||||
public:
|
||||
TestCaseTracker( std::string const& testCaseName )
|
||||
: m_testCase( testCaseName, NULL ),
|
||||
: m_testCase( testCaseName, CATCH_NULL ),
|
||||
m_currentSection( &m_testCase ),
|
||||
m_completedASectionThisRun( false )
|
||||
{}
|
||||
@@ -99,7 +101,7 @@ namespace SectionTracking {
|
||||
void leaveSection() {
|
||||
m_currentSection->leave();
|
||||
m_currentSection = m_currentSection->getParent();
|
||||
assert( m_currentSection != NULL );
|
||||
assert( m_currentSection != CATCH_NULL );
|
||||
m_completedASectionThisRun = true;
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
||||
#else
|
||||
uint64_t getCurrentTicks() {
|
||||
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 );
|
||||
}
|
||||
#endif
|
||||
|
@@ -148,7 +148,7 @@ struct StringMaker<T*> {
|
||||
template<typename U>
|
||||
static std::string convert( U* p ) {
|
||||
if( !p )
|
||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
||||
return "NULL";
|
||||
else
|
||||
return Detail::rawMemoryToString( p );
|
||||
}
|
||||
@@ -158,7 +158,7 @@ template<typename R, typename C>
|
||||
struct StringMaker<R C::*> {
|
||||
static std::string convert( R C::* p ) {
|
||||
if( !p )
|
||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
||||
return "NULL";
|
||||
else
|
||||
return Detail::rawMemoryToString( p );
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
||||
return os;
|
||||
}
|
||||
|
||||
Version libraryVersion( 1, 2, 1, "", 0 );
|
||||
Version libraryVersion( 1, 2, 1, "develop", 6 );
|
||||
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,8 @@
|
||||
#ifndef 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 <sstream>
|
||||
#include <string>
|
||||
@@ -27,7 +28,7 @@ namespace Catch {
|
||||
|
||||
ScopedElement( ScopedElement const& other )
|
||||
: m_writer( other.m_writer ){
|
||||
other.m_writer = NULL;
|
||||
other.m_writer = CATCH_NULL;
|
||||
}
|
||||
|
||||
~ScopedElement() {
|
||||
|
@@ -397,6 +397,17 @@ ExceptionTests.cpp:<line number>: FAILED:
|
||||
due to unexpected exception with message:
|
||||
3.14
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Exception messages can be tested for
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -786,6 +797,6 @@ with expansion:
|
||||
"first" == "second"
|
||||
|
||||
===============================================================================
|
||||
test cases: 155 | 116 passed | 38 failed | 1 failed as expected
|
||||
assertions: 765 | 673 passed | 79 failed | 13 failed as expected
|
||||
test cases: 156 | 116 passed | 39 failed | 1 failed as expected
|
||||
assertions: 767 | 674 passed | 80 failed | 13 failed as expected
|
||||
|
||||
|
@@ -973,51 +973,51 @@ ConditionTests.cpp:<line number>
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( p == __null )
|
||||
REQUIRE( p == nullptr )
|
||||
with expansion:
|
||||
__null == 0
|
||||
NULL == nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( p == pNULL )
|
||||
with expansion:
|
||||
__null == __null
|
||||
NULL == NULL
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( p != __null )
|
||||
REQUIRE( p != nullptr )
|
||||
with expansion:
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( cp != __null )
|
||||
REQUIRE( cp != nullptr )
|
||||
with expansion:
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( cpc != __null )
|
||||
REQUIRE( cpc != nullptr )
|
||||
with expansion:
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( returnsNull() == __null )
|
||||
REQUIRE( returnsNull() == nullptr )
|
||||
with expansion:
|
||||
{null string} == 0
|
||||
{null string} == nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( returnsConstNull() == __null )
|
||||
REQUIRE( returnsConstNull() == nullptr )
|
||||
with expansion:
|
||||
{null string} == 0
|
||||
{null string} == nullptr
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( __null != p )
|
||||
REQUIRE( nullptr != p )
|
||||
with expansion:
|
||||
0 != 0x<hex digits>
|
||||
nullptr != 0x<hex digits>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
'Not' checks that should succeed
|
||||
@@ -1277,6 +1277,21 @@ ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Exception messages can be tested for
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -3113,13 +3128,13 @@ MiscTests.cpp:<line number>
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( makeString( false ) != static_cast<char*>(__null) )
|
||||
REQUIRE( makeString( false ) != static_cast<char*>(nullptr) )
|
||||
with expansion:
|
||||
"valid string" != {null string}
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( makeString( true ) == static_cast<char*>(__null) )
|
||||
REQUIRE( makeString( true ) == static_cast<char*>(nullptr) )
|
||||
with expansion:
|
||||
{null string} == {null string}
|
||||
|
||||
@@ -3316,7 +3331,7 @@ MiscTests.cpp:<line number>
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THAT( "" Equals(__null) )
|
||||
REQUIRE_THAT( "" Equals(nullptr) )
|
||||
with expansion:
|
||||
"" equals: ""
|
||||
|
||||
@@ -5863,9 +5878,9 @@ TrickyTests.cpp:<line number>
|
||||
|
||||
TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( obj.prop != __null )
|
||||
REQUIRE( obj.prop != nullptr )
|
||||
with expansion:
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
(unimplemented) static bools can be evaluated
|
||||
@@ -6106,7 +6121,7 @@ TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( p == 0 )
|
||||
with expansion:
|
||||
__null == 0
|
||||
NULL == 0
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
null_ptr
|
||||
@@ -6118,7 +6133,7 @@ TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( ptr.get() == nullptr )
|
||||
with expansion:
|
||||
__null == nullptr
|
||||
NULL == nullptr
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
X/level/0/a
|
||||
@@ -7944,6 +7959,6 @@ with expansion:
|
||||
true
|
||||
|
||||
===============================================================================
|
||||
test cases: 155 | 100 passed | 54 failed | 1 failed as expected
|
||||
assertions: 785 | 673 passed | 99 failed | 13 failed as expected
|
||||
test cases: 156 | 100 passed | 55 failed | 1 failed as expected
|
||||
assertions: 787 | 674 passed | 100 failed | 13 failed as expected
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<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="787" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||
@@ -251,6 +251,11 @@ ExceptionTests.cpp:<line number>
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
|
||||
<testcase classname="global" name="Exception messages can be tested for" 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="Generator over a range of pairs" time="{duration}"/>
|
||||
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
||||
|
@@ -1205,10 +1205,10 @@
|
||||
<TestCase name="Pointers can be compared to null">
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
p == __null
|
||||
p == nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
__null == 0
|
||||
NULL == nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
@@ -1216,55 +1216,55 @@
|
||||
p == pNULL
|
||||
</Original>
|
||||
<Expanded>
|
||||
__null == __null
|
||||
NULL == NULL
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
p != __null
|
||||
p != nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
cp != __null
|
||||
cp != nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
cpc != __null
|
||||
cpc != nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
returnsNull() == __null
|
||||
returnsNull() == nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
{null string} == 0
|
||||
{null string} == nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
returnsConstNull() == __null
|
||||
returnsConstNull() == nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
{null string} == 0
|
||||
{null string} == nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
|
||||
<Original>
|
||||
__null != p
|
||||
nullptr != p
|
||||
</Original>
|
||||
<Expanded>
|
||||
0 != 0x<hex digits>
|
||||
nullptr != 0x<hex digits>
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
@@ -1596,6 +1596,25 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Exception messages can be tested for">
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "expected exception"
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "expected exception"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="false" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "should fail"
|
||||
</Original>
|
||||
<Expanded>
|
||||
expected exception
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Generators over two ranges">
|
||||
<Expression success="true" type="CATCH_REQUIRE" filename="projects/SelfTest/GeneratorTests.cpp" >
|
||||
<Original>
|
||||
@@ -3226,7 +3245,7 @@
|
||||
<TestCase name="null strings">
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||
<Original>
|
||||
makeString( false ) != static_cast<char*>(__null)
|
||||
makeString( false ) != static_cast<char*>(nullptr)
|
||||
</Original>
|
||||
<Expanded>
|
||||
"valid string" != {null string}
|
||||
@@ -3234,7 +3253,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||
<Original>
|
||||
makeString( true ) == static_cast<char*>(__null)
|
||||
makeString( true ) == static_cast<char*>(nullptr)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{null string} == {null string}
|
||||
@@ -3434,7 +3453,7 @@
|
||||
<TestCase name="Equals string matcher, with NULL">
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" >
|
||||
<Original>
|
||||
"" Equals(__null)
|
||||
"" Equals(nullptr)
|
||||
</Original>
|
||||
<Expanded>
|
||||
"" equals: ""
|
||||
@@ -6041,10 +6060,10 @@ there"
|
||||
<TestCase name="boolean member">
|
||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TrickyTests.cpp" >
|
||||
<Original>
|
||||
obj.prop != __null
|
||||
obj.prop != nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
0x<hex digits> != 0
|
||||
0x<hex digits> != nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
@@ -6270,7 +6289,7 @@ there"
|
||||
p == 0
|
||||
</Original>
|
||||
<Expanded>
|
||||
__null == 0
|
||||
NULL == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
@@ -6281,7 +6300,7 @@ there"
|
||||
ptr.get() == nullptr
|
||||
</Original>
|
||||
<Expanded>
|
||||
__null == nullptr
|
||||
NULL == nullptr
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
@@ -8220,7 +8239,7 @@ there"
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="673" failures="99" expectedFailures="13"/>
|
||||
<OverallResults successes="674" failures="100" expectedFailures="13"/>
|
||||
</Group>
|
||||
<OverallResults successes="673" failures="99" expectedFailures="13"/>
|
||||
<OverallResults successes="674" failures="100" expectedFailures="13"/>
|
||||
</Catch>
|
||||
|
@@ -9,8 +9,11 @@
|
||||
#include "catch.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", "" ) {
|
||||
|
||||
|
@@ -6,7 +6,8 @@
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#endif
|
||||
|
||||
#include "catch.hpp"
|
||||
@@ -265,32 +266,32 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" )
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
inline const char* returnsConstNull(){ return NULL; }
|
||||
inline char* returnsNull(){ return NULL; }
|
||||
inline const char* returnsConstNull(){ return CATCH_NULL; }
|
||||
inline char* returnsNull(){ return CATCH_NULL; }
|
||||
|
||||
TEST_CASE( "Pointers can be compared to null", "" )
|
||||
{
|
||||
TestData* p = NULL;
|
||||
TestData* pNULL = NULL;
|
||||
TestData* p = CATCH_NULL;
|
||||
TestData* pNULL = CATCH_NULL;
|
||||
|
||||
REQUIRE( p == NULL );
|
||||
REQUIRE( p == CATCH_NULL );
|
||||
REQUIRE( p == pNULL );
|
||||
|
||||
TestData data;
|
||||
p = &data;
|
||||
|
||||
REQUIRE( p != NULL );
|
||||
REQUIRE( p != CATCH_NULL );
|
||||
|
||||
const TestData* cp = p;
|
||||
REQUIRE( cp != NULL );
|
||||
REQUIRE( cp != CATCH_NULL );
|
||||
|
||||
const TestData* const cpc = p;
|
||||
REQUIRE( cpc != NULL );
|
||||
REQUIRE( cpc != CATCH_NULL );
|
||||
|
||||
REQUIRE( returnsNull() == NULL );
|
||||
REQUIRE( returnsConstNull() == NULL );
|
||||
REQUIRE( returnsNull() == CATCH_NULL );
|
||||
REQUIRE( returnsConstNull() == CATCH_NULL );
|
||||
|
||||
REQUIRE( NULL != p );
|
||||
REQUIRE( CATCH_NULL != p );
|
||||
}
|
||||
|
||||
// Not (!) tests
|
||||
|
@@ -152,3 +152,8 @@ TEST_CASE( "NotImplemented exception", "" )
|
||||
{
|
||||
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "Exception messages can be tested for", "[.][failing]" ) {
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||
}
|
||||
|
@@ -124,13 +124,13 @@ TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
|
||||
|
||||
inline const char* makeString( bool makeNull )
|
||||
{
|
||||
return makeNull ? NULL : "valid string";
|
||||
return makeNull ? CATCH_NULL : "valid string";
|
||||
}
|
||||
|
||||
TEST_CASE( "null strings", "" )
|
||||
{
|
||||
REQUIRE( makeString( false ) != static_cast<char*>(NULL));
|
||||
REQUIRE( makeString( true ) == static_cast<char*>(NULL));
|
||||
REQUIRE( makeString( false ) != static_cast<char*>(CATCH_NULL));
|
||||
REQUIRE( makeString( true ) == static_cast<char*>(CATCH_NULL));
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
||||
}
|
||||
TEST_CASE("Equals string matcher, with NULL", "[matchers]")
|
||||
{
|
||||
REQUIRE_THAT("", Equals(NULL));
|
||||
REQUIRE_THAT("", Equals(CATCH_NULL));
|
||||
}
|
||||
TEST_CASE("AllOf matcher", "[matchers]")
|
||||
{
|
||||
|
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#endif
|
||||
|
||||
#include "internal/catch_test_case_tracker.hpp"
|
||||
|
@@ -1,2 +1,4 @@
|
||||
// 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_reenable_warnings.h"
|
||||
|
@@ -16,8 +16,9 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
|
||||
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
# pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,7 +40,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
|
||||
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]" ) {
|
||||
|
||||
|
@@ -42,12 +42,14 @@ TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
||||
CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) );
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
||||
type value { nullptr, 42, "Catch me" };
|
||||
CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
|
@@ -234,7 +234,7 @@ struct Obj
|
||||
TEST_CASE("boolean member", "[Tricky]")
|
||||
{
|
||||
Obj obj;
|
||||
REQUIRE( obj.prop != NULL );
|
||||
REQUIRE( obj.prop != CATCH_NULL );
|
||||
}
|
||||
|
||||
// Tests for a problem submitted by Ralph McArdell
|
||||
|
@@ -91,7 +91,6 @@
|
||||
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>"; };
|
||||
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; };
|
||||
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>"; };
|
||||
@@ -453,6 +452,7 @@
|
||||
266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */,
|
||||
266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */,
|
||||
4A6D0C49149B3E3D00DB3EAA /* catch_common.h */,
|
||||
262E739A1846759000CAC268 /* catch_common.hpp */,
|
||||
4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */,
|
||||
261488FF184DC4A20041FBEB /* catch_debugger.h */,
|
||||
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */,
|
||||
@@ -461,12 +461,10 @@
|
||||
4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */,
|
||||
4AEE0326161431070071E950 /* catch_streambuf.h */,
|
||||
4ACE21C8166CA19700FB5509 /* catch_option.hpp */,
|
||||
26759472171C72A400A84BD1 /* catch_sfinae.hpp */,
|
||||
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */,
|
||||
26DACF2F17206D3400A21326 /* catch_text.h */,
|
||||
263FD06117AF8DF200988A20 /* catch_timer.h */,
|
||||
26AEAF1617BEA18E009E32C9 /* catch_platform.h */,
|
||||
262E739A1846759000CAC268 /* catch_common.hpp */,
|
||||
261488FC184D1DC10041FBEB /* catch_stream.h */,
|
||||
268F47B018A93F7800D8C14F /* catch_clara.h */,
|
||||
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,
|
||||
|
@@ -15,7 +15,8 @@ pathParser = re.compile( r'(.*?)/(.*\..pp)(.*)' )
|
||||
lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' )
|
||||
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
|
||||
durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' )
|
||||
versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9].?( .*)' )
|
||||
versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)' )
|
||||
devVersionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)' )
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
cmdPath = sys.argv[1]
|
||||
@@ -41,9 +42,13 @@ def filterLine( line ):
|
||||
if path.startswith( catchPath ):
|
||||
path = path[1+len(catchPath):]
|
||||
line = m.group(1) + path + m.group(3)
|
||||
m = versionParser.match( line )
|
||||
m = devVersionParser.match( line )
|
||||
if m:
|
||||
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:
|
||||
m = hexParser.match( line )
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Catch v1.2.1
|
||||
* Generated: 2015-06-30 18:23:27.961086
|
||||
* Catch v1.2.1-develop.6
|
||||
* Generated: 2015-07-13 06:35:13.441019
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
@@ -224,8 +224,17 @@
|
||||
# define CATCH_NOEXCEPT_IS(x)
|
||||
#endif
|
||||
|
||||
// nullptr support
|
||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||
# define CATCH_NULL nullptr
|
||||
#else
|
||||
# define CATCH_NULL NULL
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct IConfig;
|
||||
|
||||
class NonCopyable {
|
||||
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
NonCopyable( NonCopyable const& ) = delete;
|
||||
@@ -312,6 +321,9 @@ namespace Catch {
|
||||
|
||||
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
|
||||
// >> +StreamEndStop
|
||||
// as well as
|
||||
@@ -397,7 +409,7 @@ namespace Catch {
|
||||
template<typename T>
|
||||
class Ptr {
|
||||
public:
|
||||
Ptr() : m_p( NULL ){}
|
||||
Ptr() : m_p( CATCH_NULL ){}
|
||||
Ptr( T* p ) : m_p( p ){
|
||||
if( m_p )
|
||||
m_p->addRef();
|
||||
@@ -413,7 +425,7 @@ namespace Catch {
|
||||
void reset() {
|
||||
if( m_p )
|
||||
m_p->release();
|
||||
m_p = NULL;
|
||||
m_p = CATCH_NULL;
|
||||
}
|
||||
Ptr& operator = ( T* p ){
|
||||
Ptr temp( p );
|
||||
@@ -430,8 +442,8 @@ namespace Catch {
|
||||
const T* get() const{ return m_p; }
|
||||
T& operator*() const { return *m_p; }
|
||||
T* operator->() const { return m_p; }
|
||||
bool operator !() const { return m_p == NULL; }
|
||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); }
|
||||
bool operator !() const { return m_p == CATCH_NULL; }
|
||||
operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
|
||||
|
||||
private:
|
||||
T* m_p;
|
||||
@@ -784,7 +796,8 @@ namespace Catch {
|
||||
ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition );
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg = "" );
|
||||
|
||||
template<typename T>
|
||||
ExpressionLhs<T const&> operator <= ( T const& operand );
|
||||
@@ -813,6 +826,8 @@ namespace Catch {
|
||||
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
|
||||
void captureResult( ResultWas::OfType resultType );
|
||||
void captureExpression();
|
||||
void captureExpectedException( std::string const& expectedMessage );
|
||||
void handleResult( AssertionResult const& result );
|
||||
void react();
|
||||
bool shouldDebugBreak() const;
|
||||
bool allowThrows() const;
|
||||
@@ -994,10 +1009,10 @@ namespace Internal {
|
||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||
// pointer to nullptr_t (when comparing against nullptr)
|
||||
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( CATCH_NULL, rhs );
|
||||
}
|
||||
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, CATCH_NULL );
|
||||
}
|
||||
#endif // CATCH_CONFIG_CPP11_NULLPTR
|
||||
|
||||
@@ -1190,7 +1205,7 @@ struct StringMaker<T*> {
|
||||
template<typename U>
|
||||
static std::string convert( U* p ) {
|
||||
if( !p )
|
||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
||||
return "NULL";
|
||||
else
|
||||
return Detail::rawMemoryToString( p );
|
||||
}
|
||||
@@ -1200,7 +1215,7 @@ template<typename R, typename C>
|
||||
struct StringMaker<R C::*> {
|
||||
static std::string convert( R C::* p ) {
|
||||
if( !p )
|
||||
return INTERNAL_CATCH_STRINGIFY( NULL );
|
||||
return "NULL";
|
||||
else
|
||||
return Detail::rawMemoryToString( p );
|
||||
}
|
||||
@@ -1604,16 +1619,16 @@ namespace Catch {
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, expectedMessage, macroName ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, expectedMessage ); \
|
||||
if( __catchResult.allowThrows() ) \
|
||||
try { \
|
||||
expr; \
|
||||
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||
__catchResult.captureExpectedException( expectedMessage ); \
|
||||
} \
|
||||
else \
|
||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||
@@ -2440,12 +2455,12 @@ namespace Catch {
|
||||
template<typename T>
|
||||
class Option {
|
||||
public:
|
||||
Option() : nullableValue( NULL ) {}
|
||||
Option() : nullableValue( CATCH_NULL ) {}
|
||||
Option( T const& _value )
|
||||
: nullableValue( new( storage ) T( _value ) )
|
||||
{}
|
||||
Option( Option const& _other )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : NULL )
|
||||
: nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
|
||||
{}
|
||||
|
||||
~Option() {
|
||||
@@ -2469,7 +2484,7 @@ namespace Catch {
|
||||
void reset() {
|
||||
if( nullableValue )
|
||||
nullableValue->~T();
|
||||
nullableValue = NULL;
|
||||
nullableValue = CATCH_NULL;
|
||||
}
|
||||
|
||||
T& operator*() { return *nullableValue; }
|
||||
@@ -2481,10 +2496,10 @@ namespace Catch {
|
||||
return nullableValue ? *nullableValue : defaultValue;
|
||||
}
|
||||
|
||||
bool some() const { return nullableValue != NULL; }
|
||||
bool none() const { return nullableValue == NULL; }
|
||||
bool some() const { return nullableValue != CATCH_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 {
|
||||
return SafeBool::makeSafe( some() );
|
||||
}
|
||||
@@ -2542,6 +2557,8 @@ namespace Catch {
|
||||
|
||||
TestCaseInfo( TestCaseInfo const& other );
|
||||
|
||||
friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
|
||||
|
||||
bool isHidden() const;
|
||||
bool throws() const;
|
||||
bool okToFail() const;
|
||||
@@ -2654,7 +2671,7 @@ namespace Catch {
|
||||
|
||||
inline size_t registerTestMethods() {
|
||||
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);
|
||||
objc_getClassList( classes, noClasses );
|
||||
@@ -3132,6 +3149,7 @@ namespace Catch {
|
||||
showHelp( false ),
|
||||
showInvisibles( false ),
|
||||
forceColour( false ),
|
||||
filenamesAsTags( false ),
|
||||
abortAfter( -1 ),
|
||||
rngSeed( 0 ),
|
||||
verbosity( Verbosity::Normal ),
|
||||
@@ -3151,6 +3169,7 @@ namespace Catch {
|
||||
bool showHelp;
|
||||
bool showInvisibles;
|
||||
bool forceColour;
|
||||
bool filenamesAsTags;
|
||||
|
||||
int abortAfter;
|
||||
unsigned int rngSeed;
|
||||
@@ -3517,11 +3536,11 @@ namespace Clara {
|
||||
template<typename ConfigT>
|
||||
class BoundArgFunction {
|
||||
public:
|
||||
BoundArgFunction() : functionObj( NULL ) {}
|
||||
BoundArgFunction() : functionObj( CATCH_NULL ) {}
|
||||
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {}
|
||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CATCH_NULL ) {}
|
||||
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
|
||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL;
|
||||
delete functionObj;
|
||||
functionObj = newFunctionObj;
|
||||
return *this;
|
||||
@@ -3537,7 +3556,7 @@ namespace Clara {
|
||||
bool takesArg() const { return functionObj->takesArg(); }
|
||||
|
||||
bool isSet() const {
|
||||
return functionObj != NULL;
|
||||
return functionObj != CATCH_NULL;
|
||||
}
|
||||
private:
|
||||
IArgFunction<ConfigT>* functionObj;
|
||||
@@ -3836,8 +3855,8 @@ namespace Clara {
|
||||
m_arg->description = description;
|
||||
return *this;
|
||||
}
|
||||
ArgBuilder& detail( std::string const& detail ) {
|
||||
m_arg->detail = detail;
|
||||
ArgBuilder& detail( std::string const& _detail ) {
|
||||
m_arg->detail = _detail;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -3920,14 +3939,14 @@ namespace Clara {
|
||||
maxWidth = (std::max)( maxWidth, it->commands().size() );
|
||||
|
||||
for( it = itBegin; it != itEnd; ++it ) {
|
||||
Detail::Text usage( it->commands(), Detail::TextAttributes()
|
||||
Detail::Text usageText( it->commands(), Detail::TextAttributes()
|
||||
.setWidth( maxWidth+indent )
|
||||
.setIndent( indent ) );
|
||||
Detail::Text desc( it->description, Detail::TextAttributes()
|
||||
.setWidth( width - maxWidth - 3 ) );
|
||||
|
||||
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
|
||||
std::string usageCol = i < usage.size() ? usage[i] : "";
|
||||
for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) {
|
||||
std::string usageCol = i < usageText.size() ? usageText[i] : "";
|
||||
os << usageCol;
|
||||
|
||||
if( i < desc.size() && !desc[i].empty() )
|
||||
@@ -4263,6 +4282,10 @@ namespace Catch {
|
||||
.describe( "load test names to run from a file" )
|
||||
.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
|
||||
cli["--list-test-names-only"]
|
||||
.describe( "list all/matching test cases names only" )
|
||||
@@ -4977,7 +5000,7 @@ namespace SectionTracking {
|
||||
TrackedSections::iterator it = m_children.find( childName );
|
||||
return it != m_children.end()
|
||||
? &it->second
|
||||
: NULL;
|
||||
: CATCH_NULL;
|
||||
}
|
||||
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
||||
if( TrackedSection* child = findChild( childName ) )
|
||||
@@ -4999,7 +5022,7 @@ namespace SectionTracking {
|
||||
class TestCaseTracker {
|
||||
public:
|
||||
TestCaseTracker( std::string const& testCaseName )
|
||||
: m_testCase( testCaseName, NULL ),
|
||||
: m_testCase( testCaseName, CATCH_NULL ),
|
||||
m_currentSection( &m_testCase ),
|
||||
m_completedASectionThisRun( false )
|
||||
{}
|
||||
@@ -5016,7 +5039,7 @@ namespace SectionTracking {
|
||||
void leaveSection() {
|
||||
m_currentSection->leave();
|
||||
m_currentSection = m_currentSection->getParent();
|
||||
assert( m_currentSection != NULL );
|
||||
assert( m_currentSection != CATCH_NULL );
|
||||
m_completedASectionThisRun = true;
|
||||
}
|
||||
|
||||
@@ -5174,11 +5197,11 @@ namespace Catch {
|
||||
|
||||
public:
|
||||
|
||||
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
||||
: m_runInfo( config->name() ),
|
||||
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
||||
: m_runInfo( _config->name() ),
|
||||
m_context( getCurrentMutableContext() ),
|
||||
m_activeTestCase( NULL ),
|
||||
m_config( config ),
|
||||
m_activeTestCase( CATCH_NULL ),
|
||||
m_config( _config ),
|
||||
m_reporter( reporter ),
|
||||
m_prevRunner( m_context.getRunner() ),
|
||||
m_prevResultCapture( m_context.getResultCapture() ),
|
||||
@@ -5193,7 +5216,7 @@ namespace Catch {
|
||||
virtual ~RunContext() {
|
||||
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
||||
m_context.setRunner( m_prevRunner );
|
||||
m_context.setConfig( NULL );
|
||||
m_context.setConfig( Ptr<IConfig const>() );
|
||||
m_context.setResultCapture( m_prevResultCapture );
|
||||
m_context.setConfig( m_prevConfig );
|
||||
}
|
||||
@@ -5234,7 +5257,7 @@ namespace Catch {
|
||||
redirectedCerr,
|
||||
aborting() ) );
|
||||
|
||||
m_activeTestCase = NULL;
|
||||
m_activeTestCase = CATCH_NULL;
|
||||
m_testCaseTracker.reset();
|
||||
|
||||
return deltaTotals;
|
||||
@@ -5373,6 +5396,8 @@ namespace Catch {
|
||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
||||
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
||||
|
||||
seedRng( *m_config );
|
||||
|
||||
Timer timer;
|
||||
timer.start();
|
||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||
@@ -5589,6 +5614,26 @@ namespace Catch {
|
||||
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 {
|
||||
static bool alreadyInstantiated;
|
||||
|
||||
@@ -5659,7 +5704,10 @@ namespace Catch {
|
||||
{
|
||||
config(); // Force config to be constructed
|
||||
|
||||
std::srand( m_configData.rngSeed );
|
||||
if( m_configData.filenamesAsTags )
|
||||
applyFilenamesAsTags();
|
||||
|
||||
seedRng( *m_config );
|
||||
|
||||
Runner runner( m_config );
|
||||
|
||||
@@ -5784,6 +5832,8 @@ namespace Catch {
|
||||
break;
|
||||
case RunTests::InRandomOrder:
|
||||
{
|
||||
seedRng( config );
|
||||
|
||||
RandomNumberGenerator rng;
|
||||
std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
|
||||
}
|
||||
@@ -5797,6 +5847,7 @@ namespace Catch {
|
||||
std::vector<TestCase> m_functionsInOrder;
|
||||
std::vector<TestCase> m_nonHiddenFunctions;
|
||||
size_t m_unnamedCount;
|
||||
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -5872,7 +5923,7 @@ namespace Catch {
|
||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
||||
FactoryMap::const_iterator it = m_factories.find( name );
|
||||
if( it == m_factories.end() )
|
||||
return NULL;
|
||||
return CATCH_NULL;
|
||||
return it->second->create( ReporterConfig( config ) );
|
||||
}
|
||||
|
||||
@@ -5997,7 +6048,7 @@ namespace Catch {
|
||||
|
||||
// Single, global, instance
|
||||
inline RegistryHub*& getTheRegistryHub() {
|
||||
static RegistryHub* theRegistryHub = NULL;
|
||||
static RegistryHub* theRegistryHub = CATCH_NULL;
|
||||
if( !theRegistryHub )
|
||||
theRegistryHub = new RegistryHub();
|
||||
return theRegistryHub;
|
||||
@@ -6012,7 +6063,7 @@ namespace Catch {
|
||||
}
|
||||
void cleanUp() {
|
||||
delete getTheRegistryHub();
|
||||
getTheRegistryHub() = NULL;
|
||||
getTheRegistryHub() = CATCH_NULL;
|
||||
cleanUpContext();
|
||||
}
|
||||
std::string translateActiveException() {
|
||||
@@ -6113,7 +6164,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
Stream::Stream()
|
||||
: streamBuf( NULL ), isOwned( false )
|
||||
: streamBuf( CATCH_NULL ), isOwned( false )
|
||||
{}
|
||||
|
||||
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
|
||||
@@ -6123,7 +6174,7 @@ namespace Catch {
|
||||
void Stream::release() {
|
||||
if( isOwned ) {
|
||||
delete streamBuf;
|
||||
streamBuf = NULL;
|
||||
streamBuf = CATCH_NULL;
|
||||
isOwned = false;
|
||||
}
|
||||
}
|
||||
@@ -6142,7 +6193,7 @@ namespace Catch {
|
||||
|
||||
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& );
|
||||
void operator=( Context const& );
|
||||
|
||||
@@ -6188,7 +6239,7 @@ namespace Catch {
|
||||
m_generatorsByTestName.find( testName );
|
||||
return it != m_generatorsByTestName.end()
|
||||
? it->second
|
||||
: NULL;
|
||||
: CATCH_NULL;
|
||||
}
|
||||
|
||||
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
||||
@@ -6209,7 +6260,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
namespace {
|
||||
Context* currentContext = NULL;
|
||||
Context* currentContext = CATCH_NULL;
|
||||
}
|
||||
IMutableContext& getCurrentMutableContext() {
|
||||
if( !currentContext )
|
||||
@@ -6230,7 +6281,7 @@ namespace Catch {
|
||||
|
||||
void cleanUpContext() {
|
||||
delete currentContext;
|
||||
currentContext = NULL;
|
||||
currentContext = CATCH_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6286,12 +6337,13 @@ namespace {
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO 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 ) {
|
||||
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::Red: return setTextAttribute( FOREGROUND_RED );
|
||||
case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
|
||||
@@ -6311,10 +6363,11 @@ namespace {
|
||||
|
||||
private:
|
||||
void setTextAttribute( WORD _textAttribute ) {
|
||||
SetConsoleTextAttribute( stdoutHandle, _textAttribute );
|
||||
SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
|
||||
}
|
||||
HANDLE stdoutHandle;
|
||||
WORD originalAttributes;
|
||||
WORD originalForegroundAttributes;
|
||||
WORD originalBackgroundAttributes;
|
||||
};
|
||||
|
||||
IColourImpl* platformColourInstance() {
|
||||
@@ -6640,6 +6693,21 @@ namespace Catch {
|
||||
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,
|
||||
std::string const& _className,
|
||||
std::string const& _description,
|
||||
@@ -6648,18 +6716,10 @@ namespace Catch {
|
||||
: name( _name ),
|
||||
className( _className ),
|
||||
description( _description ),
|
||||
tags( _tags ),
|
||||
lineInfo( _lineInfo ),
|
||||
properties( None )
|
||||
{
|
||||
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 );
|
||||
properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
|
||||
lcaseTags.insert( lcaseTag );
|
||||
}
|
||||
tagsAsString = oss.str();
|
||||
setTags( *this, _tags );
|
||||
}
|
||||
|
||||
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
|
||||
@@ -6767,7 +6827,7 @@ namespace Catch {
|
||||
return os;
|
||||
}
|
||||
|
||||
Version libraryVersion( 1, 2, 1, "", 0 );
|
||||
Version libraryVersion( 1, 2, 1, "develop", 6 );
|
||||
|
||||
}
|
||||
|
||||
@@ -6960,7 +7020,7 @@ namespace Catch {
|
||||
#else
|
||||
uint64_t getCurrentTicks() {
|
||||
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 );
|
||||
}
|
||||
#endif
|
||||
@@ -7059,6 +7119,14 @@ namespace Catch {
|
||||
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 ) {
|
||||
#ifndef __GNUG__
|
||||
os << info.file << "(" << info.line << ")";
|
||||
@@ -7151,7 +7219,7 @@ namespace Catch {
|
||||
// Call sysctl.
|
||||
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
@@ -7376,11 +7444,17 @@ std::string toString( std::nullptr_t ) {
|
||||
|
||||
namespace Catch {
|
||||
|
||||
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
|
||||
return secondArg.empty()
|
||||
? capturedExpression
|
||||
: capturedExpression + ", \"" + secondArg + "\"";
|
||||
}
|
||||
ResultBuilder::ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition )
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition ),
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg )
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||
m_shouldDebugBreak( false ),
|
||||
m_shouldThrow( false )
|
||||
{}
|
||||
@@ -7422,8 +7496,29 @@ namespace Catch {
|
||||
captureExpression();
|
||||
}
|
||||
|
||||
void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
|
||||
assert( m_exprComponents.testFalse == false );
|
||||
AssertionResultData data = m_data;
|
||||
data.resultType = ResultWas::Ok;
|
||||
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||
if( expectedMessage != "" ) {
|
||||
|
||||
std::string actualMessage = Catch::translateActiveException();
|
||||
if( expectedMessage != actualMessage ) {
|
||||
data.resultType = ResultWas::ExpressionFailed;
|
||||
data.reconstructedExpression = actualMessage;
|
||||
}
|
||||
}
|
||||
AssertionResult result( m_assertionInfo, data );
|
||||
handleResult( result );
|
||||
}
|
||||
|
||||
void ResultBuilder::captureExpression() {
|
||||
AssertionResult result = build();
|
||||
handleResult( result );
|
||||
}
|
||||
void ResultBuilder::handleResult( AssertionResult const& result )
|
||||
{
|
||||
getResultCapture().assertionEnded( result );
|
||||
|
||||
if( !result.isOk() ) {
|
||||
@@ -7872,7 +7967,7 @@ namespace Catch {
|
||||
|
||||
ScopedElement( ScopedElement const& other )
|
||||
: m_writer( other.m_writer ){
|
||||
other.m_writer = NULL;
|
||||
other.m_writer = CATCH_NULL;
|
||||
}
|
||||
|
||||
~ScopedElement() {
|
||||
@@ -9268,8 +9363,9 @@ int main (int argc, char * const argv[]) {
|
||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
|
||||
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
|
||||
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" )
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, expectedMessage, "CATCH_REQUIRE_THROWS_WITH" )
|
||||
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
|
||||
|
||||
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
|
||||
@@ -9280,6 +9376,7 @@ int main (int argc, char * const argv[]) {
|
||||
|
||||
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, expectedMessage, "CATCH_CHECK_THROWS_WITH" )
|
||||
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
|
||||
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
||||
@@ -9333,8 +9430,9 @@ int main (int argc, char * const argv[]) {
|
||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
|
||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
|
||||
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "REQUIRE_THROWS" )
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
|
||||
#define REQUIRE_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, expectedMessage, "REQUIRE_THROWS_WITH" )
|
||||
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
|
||||
|
||||
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
|
||||
@@ -9343,8 +9441,9 @@ int main (int argc, char * const argv[]) {
|
||||
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
|
||||
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
|
||||
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" )
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
|
||||
#define CHECK_THROWS_WITH( expr, expectedMessage ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, expectedMessage, "CHECK_THROWS_WITH" )
|
||||
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
|
||||
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
||||
|
Reference in New Issue
Block a user