Catch v1.9.5

parent c2044205
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# additional flags # additional flags
CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-float-equal CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-float-equal
CPPFLAGS += -I ../src -I . -I thirdparty/catch CPPFLAGS += -I ../src -I . -I thirdparty/catch -DCATCH_CONFIG_FAST_COMPILE
SOURCES = src/unit.cpp \ SOURCES = src/unit.cpp \
src/unit-algorithms.cpp \ src/unit-algorithms.cpp \
......
/* /*
* Catch v1.8.1 * Catch v1.9.5
* Generated: 2017-03-01 16:04:19.016511 * Generated: 2017-06-15 12:03:23.301505
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
...@@ -40,11 +40,7 @@ ...@@ -40,11 +40,7 @@
#elif defined __GNUC__ #elif defined __GNUC__
# pragma GCC diagnostic ignored "-Wvariadic-macros" # pragma GCC diagnostic ignored "-Wvariadic-macros"
# pragma GCC diagnostic ignored "-Wunused-variable" # pragma GCC diagnostic ignored "-Wunused-variable"
// For newer version we can use __Pragma to disable the warnings locally
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ <= 7
# pragma GCC diagnostic ignored "-Wparentheses" # pragma GCC diagnostic ignored "-Wparentheses"
# endif
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpadded" # pragma GCC diagnostic ignored "-Wpadded"
...@@ -124,6 +120,12 @@ ...@@ -124,6 +120,12 @@
# endif # endif
# if defined(CATCH_CPP11_OR_GREATER) # if defined(CATCH_CPP11_OR_GREATER)
# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
_Pragma( "clang diagnostic push" ) \
_Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" )
# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
_Pragma( "clang diagnostic pop" )
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
_Pragma( "clang diagnostic push" ) \ _Pragma( "clang diagnostic push" ) \
_Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
...@@ -134,13 +136,19 @@ ...@@ -134,13 +136,19 @@
#endif // __clang__ #endif // __clang__
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Cygwin // We know some environments not to support full POSIX signals
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__QNX__)
# if !defined(CATCH_CONFIG_POSIX_SIGNALS) # if !defined(CATCH_CONFIG_POSIX_SIGNALS)
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS # define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
# endif # endif
#endif
////////////////////////////////////////////////////////////////////////////////
// Cygwin
#ifdef __CYGWIN__
// Required for some versions of Cygwin to declare gettimeofday // Required for some versions of Cygwin to declare gettimeofday
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin // see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
# define _BSD_SOURCE # define _BSD_SOURCE
...@@ -169,22 +177,10 @@ ...@@ -169,22 +177,10 @@
// GCC // GCC
#ifdef __GNUC__ #ifdef __GNUC__
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
# define CATCH_GCC_HAS_NEW_PRAGMA
# endif
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) # if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif # endif
# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_GCC_HAS_NEW_PRAGMA)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
_Pragma( "GCC diagnostic push" ) \
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
_Pragma( "GCC diagnostic pop" )
# endif
// - otherwise more recent versions define __cplusplus >= 201103L // - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below // and will get picked up below
...@@ -224,7 +220,7 @@ ...@@ -224,7 +220,7 @@
// Use __COUNTER__ if the compiler supports it // Use __COUNTER__ if the compiler supports it
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \ #if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \ ( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
( defined __clang__ && __clang_major__ >= 3 ) ( defined __clang__ && __clang_major__ >= 3 )
#define CATCH_INTERNAL_CONFIG_COUNTER #define CATCH_INTERNAL_CONFIG_COUNTER
...@@ -332,6 +328,10 @@ ...@@ -332,6 +328,10 @@
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS # define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
#endif #endif
#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
#endif
// noexcept support: // noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
...@@ -770,59 +770,76 @@ void registerTestCaseFunction ...@@ -770,59 +770,76 @@ void registerTestCaseFunction
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
static void TestName(); \ static void TestName(); \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\ CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
static void TestName() static void TestName()
#define INTERNAL_CATCH_TESTCASE( ... ) \ #define INTERNAL_CATCH_TESTCASE( ... ) \
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ \ namespace{ \
struct TestName : ClassName{ \ struct TestName : ClassName{ \
void test(); \ void test(); \
}; \ }; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
} \ } \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
void TestName::test() void TestName::test()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
#else #else
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \ #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
static void TestName(); \ static void TestName(); \
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
static void TestName() static void TestName()
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc ) INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\ #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ \ namespace{ \
struct TestCaseName : ClassName{ \ struct TestCaseName : ClassName{ \
void test(); \ void test(); \
}; \ }; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
} \ } \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
void TestCaseName::test() void TestCaseName::test()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\ #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc ) INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \ #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
#endif #endif
// #included from: internal/catch_capture.hpp // #included from: internal/catch_capture.hpp
...@@ -1021,16 +1038,24 @@ namespace Matchers { ...@@ -1021,16 +1038,24 @@ namespace Matchers {
} }
protected: protected:
virtual ~MatcherUntypedBase();
virtual std::string describe() const = 0; virtual std::string describe() const = 0;
mutable std::string m_cachedToString; mutable std::string m_cachedToString;
private: private:
MatcherUntypedBase& operator = ( MatcherUntypedBase const& ); MatcherUntypedBase& operator = ( MatcherUntypedBase const& );
}; };
template<typename ObjectT, typename ComparatorT = ObjectT> template<typename ObjectT>
struct MatcherBase : MatcherUntypedBase { struct MatcherMethod {
virtual bool match( ObjectT const& arg ) const = 0; virtual bool match( ObjectT const& arg ) const = 0;
};
template<typename PtrT>
struct MatcherMethod<PtrT*> {
virtual bool match( PtrT* arg ) const = 0;
};
template<typename ObjectT, typename ComparatorT = ObjectT>
struct MatcherBase : MatcherUntypedBase, MatcherMethod<ObjectT> {
MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const; MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const;
MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const; MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const;
...@@ -1184,6 +1209,7 @@ namespace Catch { ...@@ -1184,6 +1209,7 @@ namespace Catch {
char const* capturedExpression, char const* capturedExpression,
ResultDisposition::Flags resultDisposition, ResultDisposition::Flags resultDisposition,
char const* secondArg = "" ); char const* secondArg = "" );
~ResultBuilder();
template<typename T> template<typename T>
ExpressionLhs<T const&> operator <= ( T const& operand ); ExpressionLhs<T const&> operator <= ( T const& operand );
...@@ -1218,6 +1244,9 @@ namespace Catch { ...@@ -1218,6 +1244,9 @@ namespace Catch {
template<typename ArgT, typename MatcherT> template<typename ArgT, typename MatcherT>
void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString ); void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString );
void setExceptionGuard();
void unsetExceptionGuard();
private: private:
AssertionInfo m_assertionInfo; AssertionInfo m_assertionInfo;
AssertionResultData m_data; AssertionResultData m_data;
...@@ -1225,6 +1254,7 @@ namespace Catch { ...@@ -1225,6 +1254,7 @@ namespace Catch {
bool m_shouldDebugBreak; bool m_shouldDebugBreak;
bool m_shouldThrow; bool m_shouldThrow;
bool m_guardException;
}; };
} // namespace Catch } // namespace Catch
...@@ -1541,7 +1571,7 @@ std::string toString( std::nullptr_t ); ...@@ -1541,7 +1571,7 @@ std::string toString( std::nullptr_t );
#ifdef __OBJC__ #ifdef __OBJC__
std::string toString( NSString const * const& nsstring ); std::string toString( NSString const * const& nsstring );
std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ); std::string toString( NSString * CATCH_ARC_STRONG & nsstring );
std::string toString( NSObject* const& nsObject ); std::string toString( NSObject* const& nsObject );
#endif #endif
...@@ -1549,6 +1579,7 @@ namespace Detail { ...@@ -1549,6 +1579,7 @@ namespace Detail {
extern const std::string unprintableString; extern const std::string unprintableString;
#if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
struct BorgType { struct BorgType {
template<typename T> BorgType( T const& ); template<typename T> BorgType( T const& );
}; };
...@@ -1567,6 +1598,20 @@ namespace Detail { ...@@ -1567,6 +1598,20 @@ namespace Detail {
static T const&t; static T const&t;
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
}; };
#else
template<typename T>
class IsStreamInsertable {
template<typename SS, typename TT>
static auto test(int)
-> decltype( std::declval<SS&>() << std::declval<TT>(), std::true_type() );
template<typename, typename>
static auto test(...) -> std::false_type;
public:
static const bool value = decltype(test<std::ostream,const T&>(0))::value;
};
#endif
#if defined(CATCH_CONFIG_CPP11_IS_ENUM) #if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template<typename T, template<typename T,
...@@ -1810,7 +1855,7 @@ public: ...@@ -1810,7 +1855,7 @@ public:
} }
virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE {
dest = Catch::toString( m_truthy ); dest = Catch::toString( m_lhs );
} }
private: private:
...@@ -2009,6 +2054,8 @@ namespace Catch { ...@@ -2009,6 +2054,8 @@ namespace Catch {
virtual std::string getCurrentTestName() const = 0; virtual std::string getCurrentTestName() const = 0;
virtual const AssertionResult* getLastResult() const = 0; virtual const AssertionResult* getLastResult() const = 0;
virtual void exceptionEarlyReported() = 0;
virtual void handleFatalErrorCondition( std::string const& message ) = 0; virtual void handleFatalErrorCondition( std::string const& message ) = 0;
}; };
...@@ -2093,45 +2140,6 @@ namespace Catch { ...@@ -2093,45 +2140,6 @@ namespace Catch {
}; };
} }
// #included from: catch_type_traits.hpp
#define TWOBLUECUBES_CATCH_TYPE_TRAITS_HPP_INCLUDED
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
#include <type_traits>
#endif
namespace Catch {
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
template <typename T>
using add_lvalue_reference = std::add_lvalue_reference<T>;
template <typename T>
using add_const = std::add_const<T>;
#else
template <typename T>
struct add_const {
typedef const T type;
};
template <typename T>
struct add_lvalue_reference {
typedef T& type;
};
template <typename T>
struct add_lvalue_reference<T&> {
typedef T& type;
};
// No && overload, because that is C++11, in which case we have
// proper type_traits implementation from the standard library
#endif
}
#if defined(CATCH_CONFIG_FAST_COMPILE) #if defined(CATCH_CONFIG_FAST_COMPILE)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// We can speedup compilation significantly by breaking into debugger lower in // We can speedup compilation significantly by breaking into debugger lower in
...@@ -2139,6 +2147,33 @@ namespace Catch { ...@@ -2139,6 +2147,33 @@ namespace Catch {
// macro in each assertion // macro in each assertion
#define INTERNAL_CATCH_REACT( resultBuilder ) \ #define INTERNAL_CATCH_REACT( resultBuilder ) \
resultBuilder.react(); resultBuilder.react();
///////////////////////////////////////////////////////////////////////////////
// Another way to speed-up compilation is to omit local try-catch for REQUIRE*
// macros.
// This can potentially cause false negative, if the test code catches
// the exception before it propagates back up to the runner.
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
__catchResult.setExceptionGuard(); \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
( __catchResult <= expr ).endExpression(); \
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
__catchResult.unsetExceptionGuard(); \
INTERNAL_CATCH_REACT( __catchResult ) \
} while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
__catchResult.setExceptionGuard(); \
__catchResult.captureMatch( arg, matcher, #matcher ); \
__catchResult.unsetExceptionGuard(); \
INTERNAL_CATCH_REACT( __catchResult ) \
} while( Catch::alwaysFalse() )
#else #else
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// In the event of a failure works out if the debugger needs to be invoked // In the event of a failure works out if the debugger needs to be invoked
...@@ -2151,7 +2186,7 @@ namespace Catch { ...@@ -2151,7 +2186,7 @@ namespace Catch {
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \ try { \
...@@ -2167,17 +2202,17 @@ namespace Catch { ...@@ -2167,17 +2202,17 @@ namespace Catch {
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
if( Catch::getResultCapture().getLastResult()->succeeded() ) if( Catch::getResultCapture().getLastResult()->succeeded() )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
if( !Catch::getResultCapture().getLastResult()->succeeded() ) if( !Catch::getResultCapture().getLastResult()->succeeded() )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \ try { \
...@@ -2191,7 +2226,7 @@ namespace Catch { ...@@ -2191,7 +2226,7 @@ namespace Catch {
} while( Catch::alwaysFalse() ) } while( Catch::alwaysFalse() )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \ #define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
if( __catchResult.allowThrows() ) \ if( __catchResult.allowThrows() ) \
...@@ -2208,7 +2243,7 @@ namespace Catch { ...@@ -2208,7 +2243,7 @@ namespace Catch {
} while( Catch::alwaysFalse() ) } while( Catch::alwaysFalse() )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \ #define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
if( __catchResult.allowThrows() ) \ if( __catchResult.allowThrows() ) \
...@@ -2216,7 +2251,7 @@ namespace Catch { ...@@ -2216,7 +2251,7 @@ namespace Catch {
static_cast<void>(expr); \ static_cast<void>(expr); \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \ } \
catch( Catch::add_const<Catch::add_lvalue_reference<exceptionType>::type>::type ) { \ catch( exceptionType ) { \
__catchResult.captureResult( Catch::ResultWas::Ok ); \ __catchResult.captureResult( Catch::ResultWas::Ok ); \
} \ } \
catch( ... ) { \ catch( ... ) { \
...@@ -2229,7 +2264,7 @@ namespace Catch { ...@@ -2229,7 +2264,7 @@ namespace Catch {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \ #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
__catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \ __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \
...@@ -2237,7 +2272,7 @@ namespace Catch { ...@@ -2237,7 +2272,7 @@ namespace Catch {
INTERNAL_CATCH_REACT( __catchResult ) \ INTERNAL_CATCH_REACT( __catchResult ) \
} while( Catch::alwaysFalse() ) } while( Catch::alwaysFalse() )
#else #else
#define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \ #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, log ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
__catchResult << log + ::Catch::StreamEndStop(); \ __catchResult << log + ::Catch::StreamEndStop(); \
...@@ -2247,11 +2282,11 @@ namespace Catch { ...@@ -2247,11 +2282,11 @@ namespace Catch {
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_INFO( log, macroName ) \ #define INTERNAL_CATCH_INFO( macroName, log ) \
Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \ #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
try { \ try { \
...@@ -2368,14 +2403,19 @@ namespace Catch { ...@@ -2368,14 +2403,19 @@ namespace Catch {
// #included from: catch_timer.h // #included from: catch_timer.h
#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED #define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
#ifdef CATCH_PLATFORM_WINDOWS #ifdef _MSC_VER
typedef unsigned long long uint64_t;
namespace Catch {
typedef unsigned long long UInt64;
}
#else #else
#include <stdint.h> #include <stdint.h>
namespace Catch {
typedef uint64_t UInt64;
}
#endif #endif
namespace Catch { namespace Catch {
class Timer { class Timer {
public: public:
Timer() : m_ticks( 0 ) {} Timer() : m_ticks( 0 ) {}
...@@ -2385,7 +2425,7 @@ namespace Catch { ...@@ -2385,7 +2425,7 @@ namespace Catch {
double getElapsedSeconds() const; double getElapsedSeconds() const;
private: private:
uint64_t m_ticks; UInt64 m_ticks;
}; };
} // namespace Catch } // namespace Catch
...@@ -2424,7 +2464,6 @@ namespace Catch { ...@@ -2424,7 +2464,6 @@ namespace Catch {
// #included from: internal/catch_generators.hpp // #included from: internal/catch_generators.hpp
#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
#include <iterator>
#include <vector> #include <vector>
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
...@@ -2538,7 +2577,7 @@ public: ...@@ -2538,7 +2577,7 @@ public:
private: private:
void move( CompositeGenerator& other ) { void move( CompositeGenerator& other ) {
std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) ); m_composed.insert( m_composed.end(), other.m_composed.begin(), other.m_composed.end() );
m_totalSize += other.m_totalSize; m_totalSize += other.m_totalSize;
other.m_composed.clear(); other.m_composed.clear();
} }
...@@ -2620,12 +2659,15 @@ namespace Catch { ...@@ -2620,12 +2659,15 @@ namespace Catch {
struct IExceptionTranslator; struct IExceptionTranslator;
struct IReporterRegistry; struct IReporterRegistry;
struct IReporterFactory; struct IReporterFactory;
struct ITagAliasRegistry;
struct IRegistryHub { struct IRegistryHub {
virtual ~IRegistryHub(); virtual ~IRegistryHub();
virtual IReporterRegistry const& getReporterRegistry() const = 0; virtual IReporterRegistry const& getReporterRegistry() const = 0;
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
}; };
...@@ -2635,6 +2677,7 @@ namespace Catch { ...@@ -2635,6 +2677,7 @@ namespace Catch {
virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0; virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
virtual void registerTest( TestCase const& testInfo ) = 0; virtual void registerTest( TestCase const& testInfo ) = 0;
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
}; };
IRegistryHub& getRegistryHub(); IRegistryHub& getRegistryHub();
...@@ -2737,15 +2780,21 @@ namespace Detail { ...@@ -2737,15 +2780,21 @@ namespace Detail {
return Approx( 0 ); return Approx( 0 );
} }
Approx operator()( double value ) { #if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
Approx approx( value );
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
Approx operator()( T value ) {
Approx approx( static_cast<double>(value) );
approx.epsilon( m_epsilon ); approx.epsilon( m_epsilon );
approx.margin( m_margin ); approx.margin( m_margin );
approx.scale( m_scale ); approx.scale( m_scale );
return approx; return approx;
} }
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
explicit Approx( T value ): Approx(static_cast<double>(value))
{}
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
friend bool operator == ( const T& lhs, Approx const& rhs ) { friend bool operator == ( const T& lhs, Approx const& rhs ) {
// Thanks to Richard Harris for his help refining this formula // Thanks to Richard Harris for his help refining this formula
...@@ -2773,29 +2822,53 @@ namespace Detail { ...@@ -2773,29 +2822,53 @@ namespace Detail {
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
friend bool operator <= ( T lhs, Approx const& rhs ) friend bool operator <= ( T lhs, Approx const& rhs ) {
{
return double(lhs) < rhs.m_value || lhs == rhs; return double(lhs) < rhs.m_value || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
friend bool operator <= ( Approx const& lhs, T rhs ) friend bool operator <= ( Approx const& lhs, T rhs ) {
{
return lhs.m_value < double(rhs) || lhs == rhs; return lhs.m_value < double(rhs) || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
friend bool operator >= ( T lhs, Approx const& rhs ) friend bool operator >= ( T lhs, Approx const& rhs ) {
{
return double(lhs) > rhs.m_value || lhs == rhs; return double(lhs) > rhs.m_value || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
friend bool operator >= ( Approx const& lhs, T rhs ) friend bool operator >= ( Approx const& lhs, T rhs ) {
{
return lhs.m_value > double(rhs) || lhs == rhs; return lhs.m_value > double(rhs) || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
Approx& epsilon( T newEpsilon ) {
m_epsilon = double(newEpsilon);
return *this;
}
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
Approx& margin( T newMargin ) {
m_margin = double(newMargin);
return *this;
}
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
Approx& scale( T newScale ) {
m_scale = double(newScale);
return *this;
}
#else #else
Approx operator()( double value ) {
Approx approx( value );
approx.epsilon( m_epsilon );
approx.margin( m_margin );
approx.scale( m_scale );
return approx;
}
friend bool operator == ( double lhs, Approx const& rhs ) { friend bool operator == ( double lhs, Approx const& rhs ) {
// Thanks to Richard Harris for his help refining this formula // Thanks to Richard Harris for his help refining this formula
bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) ); bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) );
...@@ -2817,26 +2890,21 @@ namespace Detail { ...@@ -2817,26 +2890,21 @@ namespace Detail {
return !operator==( rhs, lhs ); return !operator==( rhs, lhs );
} }
friend bool operator <= ( double lhs, Approx const& rhs ) friend bool operator <= ( double lhs, Approx const& rhs ) {
{
return lhs < rhs.m_value || lhs == rhs; return lhs < rhs.m_value || lhs == rhs;
} }
friend bool operator <= ( Approx const& lhs, double rhs ) friend bool operator <= ( Approx const& lhs, double rhs ) {
{
return lhs.m_value < rhs || lhs == rhs; return lhs.m_value < rhs || lhs == rhs;
} }
friend bool operator >= ( double lhs, Approx const& rhs ) friend bool operator >= ( double lhs, Approx const& rhs ) {
{
return lhs > rhs.m_value || lhs == rhs; return lhs > rhs.m_value || lhs == rhs;
} }
friend bool operator >= ( Approx const& lhs, double rhs ) friend bool operator >= ( Approx const& lhs, double rhs ) {
{
return lhs.m_value > rhs || lhs == rhs; return lhs.m_value > rhs || lhs == rhs;
} }
#endif
Approx& epsilon( double newEpsilon ) { Approx& epsilon( double newEpsilon ) {
m_epsilon = newEpsilon; m_epsilon = newEpsilon;
...@@ -2852,6 +2920,7 @@ namespace Detail { ...@@ -2852,6 +2920,7 @@ namespace Detail {
m_scale = newScale; m_scale = newScale;
return *this; return *this;
} }
#endif
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
...@@ -2893,7 +2962,7 @@ namespace Matchers { ...@@ -2893,7 +2962,7 @@ namespace Matchers {
}; };
struct StringMatcherBase : MatcherBase<std::string> { struct StringMatcherBase : MatcherBase<std::string> {
StringMatcherBase( std::string operation, CasedString const& comparator ); StringMatcherBase( std::string const& operation, CasedString const& comparator );
virtual std::string describe() const CATCH_OVERRIDE; virtual std::string describe() const CATCH_OVERRIDE;
CasedString m_comparator; CasedString m_comparator;
...@@ -3032,7 +3101,7 @@ namespace Matchers { ...@@ -3032,7 +3101,7 @@ namespace Matchers {
namespace Catch { namespace Catch {
struct TagAlias { struct TagAlias {
TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {} TagAlias( std::string const& _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
std::string tag; std::string tag;
SourceLineInfo lineInfo; SourceLineInfo lineInfo;
...@@ -3104,8 +3173,18 @@ namespace Catch { ...@@ -3104,8 +3173,18 @@ namespace Catch {
} }
private: private:
T* nullableValue; T *nullableValue;
union {
char storage[sizeof(T)]; char storage[sizeof(T)];
// These are here to force alignment for the storage
long double dummy1;
void (*dummy2)();
long double dummy3;
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
long long dummy4;
#endif
};
}; };
} // end namespace Catch } // end namespace Catch
...@@ -3304,64 +3383,67 @@ namespace Catch { ...@@ -3304,64 +3383,67 @@ namespace Catch {
namespace Impl { namespace Impl {
namespace NSStringMatchers { namespace NSStringMatchers {
template<typename MatcherT> struct StringHolder : MatcherBase<NSString*>{
struct StringHolder : MatcherImpl<MatcherT, NSString*>{
StringHolder( NSString* substr ) : m_substr( [substr copy] ){} StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
StringHolder() { StringHolder() {
arcSafeRelease( m_substr ); arcSafeRelease( m_substr );
} }
virtual bool match( NSString* arg ) const CATCH_OVERRIDE {
return false;
}
NSString* m_substr; NSString* m_substr;
}; };
struct Equals : StringHolder<Equals> { struct Equals : StringHolder {
Equals( NSString* substr ) : StringHolder( substr ){} Equals( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const { virtual bool match( NSString* str ) const CATCH_OVERRIDE {
return (str != nil || m_substr == nil ) && return (str != nil || m_substr == nil ) &&
[str isEqualToString:m_substr]; [str isEqualToString:m_substr];
} }
virtual std::string toString() const { virtual std::string describe() const CATCH_OVERRIDE {
return "equals string: " + Catch::toString( m_substr ); return "equals string: " + Catch::toString( m_substr );
} }
}; };
struct Contains : StringHolder<Contains> { struct Contains : StringHolder {
Contains( NSString* substr ) : StringHolder( substr ){} Contains( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const { virtual bool match( NSString* str ) const {
return (str != nil || m_substr == nil ) && return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location != NSNotFound; [str rangeOfString:m_substr].location != NSNotFound;
} }
virtual std::string toString() const { virtual std::string describe() const CATCH_OVERRIDE {
return "contains string: " + Catch::toString( m_substr ); return "contains string: " + Catch::toString( m_substr );
} }
}; };
struct StartsWith : StringHolder<StartsWith> { struct StartsWith : StringHolder {
StartsWith( NSString* substr ) : StringHolder( substr ){} StartsWith( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const { virtual bool match( NSString* str ) const {
return (str != nil || m_substr == nil ) && return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == 0; [str rangeOfString:m_substr].location == 0;
} }
virtual std::string toString() const { virtual std::string describe() const CATCH_OVERRIDE {
return "starts with: " + Catch::toString( m_substr ); return "starts with: " + Catch::toString( m_substr );
} }
}; };
struct EndsWith : StringHolder<EndsWith> { struct EndsWith : StringHolder {
EndsWith( NSString* substr ) : StringHolder( substr ){} EndsWith( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const { virtual bool match( NSString* str ) const {
return (str != nil || m_substr == nil ) && return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == [str length] - [m_substr length]; [str rangeOfString:m_substr].location == [str length] - [m_substr length];
} }
virtual std::string toString() const { virtual std::string describe() const CATCH_OVERRIDE {
return "ends with: " + Catch::toString( m_substr ); return "ends with: " + Catch::toString( m_substr );
} }
}; };
...@@ -4020,6 +4102,7 @@ namespace Catch { ...@@ -4020,6 +4102,7 @@ namespace Catch {
#include <vector> #include <vector>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <cctype>
// Use optional outer namespace // Use optional outer namespace
#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE #ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
...@@ -4362,7 +4445,7 @@ namespace Clara { ...@@ -4362,7 +4445,7 @@ namespace Clara {
_dest = _source; _dest = _source;
} }
char toLowerCh(char c) { char toLowerCh(char c) {
return static_cast<char>( ::tolower( c ) ); return static_cast<char>( std::tolower( c ) );
} }
inline void convertInto( std::string const& _source, bool& _dest ) { inline void convertInto( std::string const& _source, bool& _dest ) {
std::string sourceLC = _source; std::string sourceLC = _source;
...@@ -4516,12 +4599,13 @@ namespace Clara { ...@@ -4516,12 +4599,13 @@ namespace Clara {
} }
void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) { void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) {
for( std::size_t i = 0; i <= arg.size(); ++i ) { for( std::size_t i = 0; i < arg.size(); ++i ) {
char c = arg[i]; char c = arg[i];
if( c == '"' ) if( c == '"' )
inQuotes = !inQuotes; inQuotes = !inQuotes;
mode = handleMode( i, c, arg, tokens ); mode = handleMode( i, c, arg, tokens );
} }
mode = handleMode( arg.size(), '\0', arg, tokens );
} }
Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) { Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
switch( mode ) { switch( mode ) {
...@@ -4554,6 +4638,7 @@ namespace Clara { ...@@ -4554,6 +4638,7 @@ namespace Clara {
default: from = i; return ShortOpt; default: from = i; return ShortOpt;
} }
} }
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) { Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) if( std::string( ":=\0", 3 ).find( c ) == std::string::npos )
return mode; return mode;
...@@ -4885,7 +4970,7 @@ namespace Clara { ...@@ -4885,7 +4970,7 @@ namespace Clara {
} }
std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const { std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
std::string processName = args[0]; std::string processName = args.empty() ? std::string() : args[0];
std::size_t lastSlash = processName.find_last_of( "/\\" ); std::size_t lastSlash = processName.find_last_of( "/\\" );
if( lastSlash != std::string::npos ) if( lastSlash != std::string::npos )
processName = processName.substr( lastSlash+1 ); processName = processName.substr( lastSlash+1 );
...@@ -5871,13 +5956,14 @@ namespace Catch { ...@@ -5871,13 +5956,14 @@ namespace Catch {
// #included from: catch_test_case_tracker.hpp // #included from: catch_test_case_tracker.hpp
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
#include <map> #include <algorithm>
#include <string> #include <string>
#include <assert.h> #include <assert.h>
#include <vector> #include <vector>
#include <iterator>
#include <stdexcept> #include <stdexcept>
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
namespace Catch { namespace Catch {
namespace TestCaseTracking { namespace TestCaseTracking {
...@@ -6148,12 +6234,12 @@ namespace TestCaseTracking { ...@@ -6148,12 +6234,12 @@ namespace TestCaseTracking {
if( !filters.empty() ) { if( !filters.empty() ) {
m_filters.push_back(""); // Root - should never be consulted m_filters.push_back(""); // Root - should never be consulted
m_filters.push_back(""); // Test Case - not a section filter m_filters.push_back(""); // Test Case - not a section filter
std::copy( filters.begin(), filters.end(), std::back_inserter( m_filters ) ); m_filters.insert( m_filters.end(), filters.begin(), filters.end() );
} }
} }
void addNextFilters( std::vector<std::string> const& filters ) { void addNextFilters( std::vector<std::string> const& filters ) {
if( filters.size() > 1 ) if( filters.size() > 1 )
std::copy( filters.begin()+1, filters.end(), std::back_inserter( m_filters ) ); m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() );
} }
}; };
...@@ -6223,6 +6309,8 @@ using TestCaseTracking::IndexTracker; ...@@ -6223,6 +6309,8 @@ using TestCaseTracking::IndexTracker;
} // namespace Catch } // namespace Catch
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
// #included from: catch_fatal_condition.hpp // #included from: catch_fatal_condition.hpp
#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
...@@ -6292,7 +6380,6 @@ namespace Catch { ...@@ -6292,7 +6380,6 @@ namespace Catch {
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
reset();
reportFatal(signalDefs[i].name); reportFatal(signalDefs[i].name);
} }
} }
...@@ -6476,7 +6563,8 @@ namespace Catch { ...@@ -6476,7 +6563,8 @@ namespace Catch {
m_context( getCurrentMutableContext() ), m_context( getCurrentMutableContext() ),
m_activeTestCase( CATCH_NULL ), m_activeTestCase( CATCH_NULL ),
m_config( _config ), m_config( _config ),
m_reporter( reporter ) m_reporter( reporter ),
m_shouldReportUnexpected ( true )
{ {
m_context.setRunner( this ); m_context.setRunner( this );
m_context.setConfig( m_config ); m_context.setConfig( m_config );
...@@ -6554,8 +6642,9 @@ namespace Catch { ...@@ -6554,8 +6642,9 @@ namespace Catch {
m_totals.assertions.failed++; m_totals.assertions.failed++;
} }
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) ) // We have no use for the return value (whether messages should be cleared), because messages were made scoped
m_messages.clear(); // and should be let to clear themselves out.
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
// Reset working state // Reset working state
m_lastAssertionInfo = AssertionInfo( std::string(), m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); m_lastAssertionInfo = AssertionInfo( std::string(), m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
...@@ -6633,11 +6722,19 @@ namespace Catch { ...@@ -6633,11 +6722,19 @@ namespace Catch {
return &m_lastResult; return &m_lastResult;
} }
virtual void exceptionEarlyReported() {
m_shouldReportUnexpected = false;
}
virtual void handleFatalErrorCondition( std::string const& message ) { virtual void handleFatalErrorCondition( std::string const& message ) {
ResultBuilder resultBuilder = makeUnexpectedResultBuilder(); // Don't rebuild the result -- the stringification itself can cause more fatal errors
resultBuilder.setResultType( ResultWas::FatalErrorCondition ); // Instead, fake a result data.
resultBuilder << message; AssertionResultData tempResult;
resultBuilder.captureExpression(); tempResult.resultType = ResultWas::FatalErrorCondition;
tempResult.message = message;
AssertionResult result(m_lastAssertionInfo, tempResult);
getResultCapture().assertionEnded(result);
handleUnfinishedSections(); handleUnfinishedSections();
...@@ -6678,6 +6775,7 @@ namespace Catch { ...@@ -6678,6 +6775,7 @@ namespace Catch {
m_reporter->sectionStarting( testCaseSection ); m_reporter->sectionStarting( testCaseSection );
Counts prevAssertions = m_totals.assertions; Counts prevAssertions = m_totals.assertions;
double duration = 0; double duration = 0;
m_shouldReportUnexpected = true;
try { try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, std::string(), ResultDisposition::Normal ); m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, std::string(), ResultDisposition::Normal );
...@@ -6699,8 +6797,12 @@ namespace Catch { ...@@ -6699,8 +6797,12 @@ namespace Catch {
// This just means the test was aborted due to failure // This just means the test was aborted due to failure
} }
catch(...) { catch(...) {
// Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions
// are reported without translation at the point of origin.
if (m_shouldReportUnexpected) {
makeUnexpectedResultBuilder().useActiveException(); makeUnexpectedResultBuilder().useActiveException();
} }
}
m_testCaseTracker->close(); m_testCaseTracker->close();
handleUnfinishedSections(); handleUnfinishedSections();
m_messages.clear(); m_messages.clear();
...@@ -6759,6 +6861,7 @@ namespace Catch { ...@@ -6759,6 +6861,7 @@ namespace Catch {
std::vector<SectionEndInfo> m_unfinishedSections; std::vector<SectionEndInfo> m_unfinishedSections;
std::vector<ITracker*> m_activeSections; std::vector<ITracker*> m_activeSections;
TrackerContext m_trackerContext; TrackerContext m_trackerContext;
bool m_shouldReportUnexpected;
}; };
IResultCapture& getResultCapture() { IResultCapture& getResultCapture() {
...@@ -6780,7 +6883,7 @@ namespace Catch { ...@@ -6780,7 +6883,7 @@ namespace Catch {
Version( unsigned int _majorVersion, Version( unsigned int _majorVersion,
unsigned int _minorVersion, unsigned int _minorVersion,
unsigned int _patchNumber, unsigned int _patchNumber,
std::string const& _branchName, char const * const _branchName,
unsigned int _buildNumber ); unsigned int _buildNumber );
unsigned int const majorVersion; unsigned int const majorVersion;
...@@ -6788,7 +6891,7 @@ namespace Catch { ...@@ -6788,7 +6891,7 @@ namespace Catch {
unsigned int const patchNumber; unsigned int const patchNumber;
// buildNumber is only used if branchName is not null // buildNumber is only used if branchName is not null
std::string const branchName; char const * const branchName;
unsigned int const buildNumber; unsigned int const buildNumber;
friend std::ostream& operator << ( std::ostream& os, Version const& version ); friend std::ostream& operator << ( std::ostream& os, Version const& version );
...@@ -6797,7 +6900,7 @@ namespace Catch { ...@@ -6797,7 +6900,7 @@ namespace Catch {
void operator=( Version const& ); void operator=( Version const& );
}; };
extern Version libraryVersion; inline Version libraryVersion();
} }
#include <fstream> #include <fstream>
...@@ -6909,7 +7012,7 @@ namespace Catch { ...@@ -6909,7 +7012,7 @@ namespace Catch {
} }
void showHelp( std::string const& processName ) { void showHelp( std::string const& processName ) {
Catch::cout() << "\nCatch v" << libraryVersion << "\n"; Catch::cout() << "\nCatch v" << libraryVersion() << "\n";
m_cli.usage( Catch::cout(), processName ); m_cli.usage( Catch::cout(), processName );
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
...@@ -6950,6 +7053,32 @@ namespace Catch { ...@@ -6950,6 +7053,32 @@ namespace Catch {
return returnCode; return returnCode;
} }
#if defined(WIN32) && defined(UNICODE)
int run( int argc, wchar_t const* const* const argv ) {
char **utf8Argv = new char *[ argc ];
for ( int i = 0; i < argc; ++i ) {
int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL );
utf8Argv[ i ] = new char[ bufSize ];
WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL );
}
int returnCode = applyCommandLine( argc, utf8Argv );
if( returnCode == 0 )
returnCode = run();
for ( int i = 0; i < argc; ++i )
delete [] utf8Argv[ i ];
delete [] utf8Argv;
return returnCode;
}
#endif
int run() { int run() {
if( m_configData.showHelp ) if( m_configData.showHelp )
return 0; return 0;
...@@ -7297,6 +7426,26 @@ namespace Catch { ...@@ -7297,6 +7426,26 @@ namespace Catch {
}; };
} }
// #included from: catch_tag_alias_registry.h
#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED
#include <map>
namespace Catch {
class TagAliasRegistry : public ITagAliasRegistry {
public:
virtual ~TagAliasRegistry();
virtual Option<TagAlias> find( std::string const& alias ) const;
virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const;
void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );
private:
std::map<std::string, TagAlias> m_registry;
};
} // end namespace Catch
namespace Catch { namespace Catch {
namespace { namespace {
...@@ -7318,6 +7467,9 @@ namespace Catch { ...@@ -7318,6 +7467,9 @@ namespace Catch {
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE { virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
return m_exceptionTranslatorRegistry; return m_exceptionTranslatorRegistry;
} }
virtual ITagAliasRegistry const& getTagAliasRegistry() const CATCH_OVERRIDE {
return m_tagAliasRegistry;
}
public: // IMutableRegistryHub public: // IMutableRegistryHub
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE { virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
...@@ -7332,11 +7484,15 @@ namespace Catch { ...@@ -7332,11 +7484,15 @@ namespace Catch {
virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE { virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
m_exceptionTranslatorRegistry.registerTranslator( translator ); m_exceptionTranslatorRegistry.registerTranslator( translator );
} }
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) CATCH_OVERRIDE {
m_tagAliasRegistry.add( alias, tag, lineInfo );
}
private: private:
TestRegistry m_testCaseRegistry; TestRegistry m_testCaseRegistry;
ReporterRegistry m_reporterRegistry; ReporterRegistry m_reporterRegistry;
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
TagAliasRegistry m_tagAliasRegistry;
}; };
// Single, global, instance // Single, global, instance
...@@ -7581,6 +7737,23 @@ namespace Catch { ...@@ -7581,6 +7737,23 @@ namespace Catch {
// #included from: catch_console_colour_impl.hpp // #included from: catch_console_colour_impl.hpp
#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED
// #included from: catch_errno_guard.hpp
#define TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED
#include <cerrno>
namespace Catch {
class ErrnoGuard {
public:
ErrnoGuard():m_oldErrno(errno){}
~ErrnoGuard() { errno = m_oldErrno; }
private:
int m_oldErrno;
};
}
namespace Catch { namespace Catch {
namespace { namespace {
...@@ -7716,6 +7889,7 @@ namespace { ...@@ -7716,6 +7889,7 @@ namespace {
}; };
IColourImpl* platformColourInstance() { IColourImpl* platformColourInstance() {
ErrnoGuard guard;
Ptr<IConfig const> config = getCurrentContext().getConfig(); Ptr<IConfig const> config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config UseColour::YesOrNo colourMode = config
? config->useColour() ? config->useColour()
...@@ -7945,17 +8119,13 @@ namespace Catch { ...@@ -7945,17 +8119,13 @@ namespace Catch {
} }
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
if( isReservedTag( tag ) ) { if( isReservedTag( tag ) ) {
{ std::ostringstream ss;
Colour colourGuard( Colour::Red ); ss << Colour(Colour::Red)
Catch::cerr()
<< "Tag name [" << tag << "] not allowed.\n" << "Tag name [" << tag << "] not allowed.\n"
<< "Tag names starting with non alpha-numeric characters are reserved\n"; << "Tag names starting with non alpha-numeric characters are reserved\n"
} << Colour(Colour::FileName)
{ << _lineInfo << '\n';
Colour colourGuard( Colour::FileName ); throw std::runtime_error(ss.str());
Catch::cerr() << _lineInfo << std::endl;
}
exit(1);
} }
} }
...@@ -8117,7 +8287,7 @@ namespace Catch { ...@@ -8117,7 +8287,7 @@ namespace Catch {
( unsigned int _majorVersion, ( unsigned int _majorVersion,
unsigned int _minorVersion, unsigned int _minorVersion,
unsigned int _patchNumber, unsigned int _patchNumber,
std::string const& _branchName, char const * const _branchName,
unsigned int _buildNumber ) unsigned int _buildNumber )
: majorVersion( _majorVersion ), : majorVersion( _majorVersion ),
minorVersion( _minorVersion ), minorVersion( _minorVersion ),
...@@ -8130,15 +8300,18 @@ namespace Catch { ...@@ -8130,15 +8300,18 @@ namespace Catch {
os << version.majorVersion << '.' os << version.majorVersion << '.'
<< version.minorVersion << '.' << version.minorVersion << '.'
<< version.patchNumber; << version.patchNumber;
// branchName is never null -> 0th char is \0 if it is empty
if( !version.branchName.empty() ) { if (version.branchName[0]) {
os << '-' << version.branchName os << '-' << version.branchName
<< '.' << version.buildNumber; << '.' << version.buildNumber;
} }
return os; return os;
} }
Version libraryVersion( 1, 8, 1, "", 0 ); inline Version libraryVersion() {
static Version version( 1, 9, 5, "", 0 );
return version;
}
} }
...@@ -8172,7 +8345,9 @@ namespace Catch { ...@@ -8172,7 +8345,9 @@ namespace Catch {
{} {}
ScopedMessage::~ScopedMessage() { ScopedMessage::~ScopedMessage() {
getResultCapture().popScopedMessage( m_info ); if ( !std::uncaught_exception() ){
getResultCapture().popScopedMessage(m_info);
}
} }
} // end namespace Catch } // end namespace Catch
...@@ -8320,21 +8495,21 @@ namespace Catch { ...@@ -8320,21 +8495,21 @@ namespace Catch {
namespace { namespace {
#ifdef CATCH_PLATFORM_WINDOWS #ifdef CATCH_PLATFORM_WINDOWS
uint64_t getCurrentTicks() { UInt64 getCurrentTicks() {
static uint64_t hz=0, hzo=0; static UInt64 hz=0, hzo=0;
if (!hz) { if (!hz) {
QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) ); QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) );
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) ); QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) );
} }
uint64_t t; UInt64 t;
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) ); QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) );
return ((t-hzo)*1000000)/hz; return ((t-hzo)*1000000)/hz;
} }
#else #else
uint64_t getCurrentTicks() { UInt64 getCurrentTicks() {
timeval t; timeval t;
gettimeofday(&t,CATCH_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.tv_sec ) * 1000000ull + static_cast<UInt64>( t.tv_usec );
} }
#endif #endif
} }
...@@ -8486,6 +8661,10 @@ namespace Catch { ...@@ -8486,6 +8661,10 @@ namespace Catch {
m_timer.start(); m_timer.start();
} }
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
#endif
Section::~Section() { Section::~Section() {
if( m_sectionIncluded ) { if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
...@@ -8495,6 +8674,9 @@ namespace Catch { ...@@ -8495,6 +8674,9 @@ namespace Catch {
getResultCapture().sectionEnded( endInfo ); getResultCapture().sectionEnded( endInfo );
} }
} }
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// This indicates whether the section should be executed or not // This indicates whether the section should be executed or not
Section::operator bool() const { Section::operator bool() const {
...@@ -8567,6 +8749,9 @@ namespace Catch { ...@@ -8567,6 +8749,9 @@ namespace Catch {
// be strace, for example) in /proc/$PID/status, so just get it from // be strace, for example) in /proc/$PID/status, so just get it from
// there instead. // there instead.
bool isDebuggerActive(){ bool isDebuggerActive(){
// Libstdc++ has a bug, where std::ifstream sets errno to 0
// This way our users can properly assert over errno values
ErrnoGuard guard;
std::ifstream in("/proc/self/status"); std::ifstream in("/proc/self/status");
for( std::string line; std::getline(in, line); ) { for( std::string line; std::getline(in, line); ) {
static const int PREFIX_LEN = 11; static const int PREFIX_LEN = 11;
...@@ -8807,7 +8992,7 @@ std::string toString( std::nullptr_t ) { ...@@ -8807,7 +8992,7 @@ std::string toString( std::nullptr_t ) {
return "nil"; return "nil";
return "@" + toString([nsstring UTF8String]); return "@" + toString([nsstring UTF8String]);
} }
std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) { std::string toString( NSString * CATCH_ARC_STRONG & nsstring ) {
if( !nsstring ) if( !nsstring )
return "nil"; return "nil";
return "@" + toString([nsstring UTF8String]); return "@" + toString([nsstring UTF8String]);
...@@ -8836,9 +9021,20 @@ namespace Catch { ...@@ -8836,9 +9021,20 @@ namespace Catch {
char const* secondArg ) char const* secondArg )
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ), : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
m_shouldDebugBreak( false ), m_shouldDebugBreak( false ),
m_shouldThrow( false ) m_shouldThrow( false ),
m_guardException( false )
{} {}
ResultBuilder::~ResultBuilder() {
#if defined(CATCH_CONFIG_FAST_COMPILE)
if ( m_guardException ) {
m_stream.oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
captureResult( ResultWas::ThrewException );
getCurrentContext().getResultCapture()->exceptionEarlyReported();
}
#endif
}
ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) { ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
m_data.resultType = result; m_data.resultType = result;
return *this; return *this;
...@@ -8951,32 +9147,18 @@ namespace Catch { ...@@ -8951,32 +9147,18 @@ namespace Catch {
dest = m_assertionInfo.capturedExpression; dest = m_assertionInfo.capturedExpression;
} }
void ResultBuilder::setExceptionGuard() {
m_guardException = true;
}
void ResultBuilder::unsetExceptionGuard() {
m_guardException = false;
}
} // end namespace Catch } // end namespace Catch
// #included from: catch_tag_alias_registry.hpp // #included from: catch_tag_alias_registry.hpp
#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED
// #included from: catch_tag_alias_registry.h
#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED
#include <map>
namespace Catch {
class TagAliasRegistry : public ITagAliasRegistry {
public:
virtual ~TagAliasRegistry();
virtual Option<TagAlias> find( std::string const& alias ) const;
virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const;
void add( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
static TagAliasRegistry& get();
private:
std::map<std::string, TagAlias> m_registry;
};
} // end namespace Catch
namespace Catch { namespace Catch {
TagAliasRegistry::~TagAliasRegistry() {} TagAliasRegistry::~TagAliasRegistry() {}
...@@ -9004,40 +9186,36 @@ namespace Catch { ...@@ -9004,40 +9186,36 @@ namespace Catch {
return expandedTestSpec; return expandedTestSpec;
} }
void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) {
if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) { if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) {
std::ostringstream oss; std::ostringstream oss;
oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo; oss << Colour( Colour::Red )
<< "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n"
<< Colour( Colour::FileName )
<< lineInfo << '\n';
throw std::domain_error( oss.str().c_str() ); throw std::domain_error( oss.str().c_str() );
} }
if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) { if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
std::ostringstream oss; std::ostringstream oss;
oss << "error: tag alias, \"" << alias << "\" already registered.\n" oss << Colour( Colour::Red )
<< "\tFirst seen at " << find(alias)->lineInfo << '\n' << "error: tag alias, \"" << alias << "\" already registered.\n"
<< "\tRedefined at " << lineInfo; << "\tFirst seen at "
<< Colour( Colour::Red ) << find(alias)->lineInfo << '\n'
<< Colour( Colour::Red ) << "\tRedefined at "
<< Colour( Colour::FileName) << lineInfo << '\n';
throw std::domain_error( oss.str().c_str() ); throw std::domain_error( oss.str().c_str() );
} }
} }
TagAliasRegistry& TagAliasRegistry::get() { ITagAliasRegistry::~ITagAliasRegistry() {}
static TagAliasRegistry instance;
return instance;
ITagAliasRegistry const& ITagAliasRegistry::get() {
return getRegistryHub().getTagAliasRegistry();
} }
ITagAliasRegistry::~ITagAliasRegistry() {}
ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); }
RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
try { getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo );
TagAliasRegistry::get().add( alias, tag, lineInfo );
}
catch( std::exception& ex ) {
Colour colourGuard( Colour::Red );
Catch::cerr() << ex.what() << std::endl;
exit(1);
}
} }
} // end namespace Catch } // end namespace Catch
...@@ -9064,7 +9242,7 @@ namespace Matchers { ...@@ -9064,7 +9242,7 @@ namespace Matchers {
: std::string(); : std::string();
} }
StringMatcherBase::StringMatcherBase( std::string operation, CasedString const& comparator ) StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator )
: m_comparator( comparator ), : m_comparator( comparator ),
m_operation( operation ) { m_operation( operation ) {
} }
...@@ -9265,10 +9443,34 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo ...@@ -9265,10 +9443,34 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
#include <cstring> #include <cstring>
#include <cfloat>
#include <cstdio>
#include <assert.h> #include <assert.h>
namespace Catch { namespace Catch {
namespace {
// Because formatting using c++ streams is stateful, drop down to C is required
// Alternatively we could use stringstream, but its performance is... not good.
std::string getFormattedDuration( double duration ) {
// Max exponent + 1 is required to represent the whole part
// + 1 for decimal point
// + 3 for the 3 decimal places
// + 1 for null terminator
const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
char buffer[maxDoubleSize];
// Save previous errno, to prevent sprintf from overwriting it
ErrnoGuard guard;
#ifdef _MSC_VER
sprintf_s(buffer, "%.3f", duration);
#else
sprintf(buffer, "%.3f", duration);
#endif
return std::string(buffer);
}
}
struct StreamingReporterBase : SharedImpl<IStreamingReporter> { struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
StreamingReporterBase( ReporterConfig const& _config ) StreamingReporterBase( ReporterConfig const& _config )
...@@ -9594,9 +9796,13 @@ namespace Catch { ...@@ -9594,9 +9796,13 @@ namespace Catch {
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \ #define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
// Deprecated - use the form without INTERNAL_
#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \ #define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
#define CATCH_REGISTER_LISTENER( listenerType ) \
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
// #included from: ../internal/catch_xmlwriter.hpp // #included from: ../internal/catch_xmlwriter.hpp
#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
...@@ -9829,20 +10035,6 @@ namespace Catch { ...@@ -9829,20 +10035,6 @@ namespace Catch {
}; };
} }
// #included from: catch_reenable_warnings.h
#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED
#ifdef __clang__
# ifdef __ICC // icpc defines the __clang__ macro
# pragma warning(pop)
# else
# pragma clang diagnostic pop
# endif
#elif defined __GNUC__
# pragma GCC diagnostic pop
#endif
namespace Catch { namespace Catch {
class XmlReporter : public StreamingReporterBase { class XmlReporter : public StreamingReporterBase {
...@@ -9921,10 +10113,13 @@ namespace Catch { ...@@ -9921,10 +10113,13 @@ namespace Catch {
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { } virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
const AssertionResult& assertionResult = assertionStats.assertionResult;
AssertionResult const& result = assertionStats.assertionResult;
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
if( includeResults ) {
// Print any info messages in <Info> tags. // Print any info messages in <Info> tags.
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
it != itEnd; it != itEnd;
++it ) { ++it ) {
...@@ -9939,55 +10134,55 @@ namespace Catch { ...@@ -9939,55 +10134,55 @@ namespace Catch {
} }
// Drop out if result was successful but we're not printing them. // Drop out if result was successful but we're not printing them.
if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) ) if( !includeResults && result.getResultType() != ResultWas::Warning )
return true; return true;
// Print the expression if there is one. // Print the expression if there is one.
if( assertionResult.hasExpression() ) { if( result.hasExpression() ) {
m_xml.startElement( "Expression" ) m_xml.startElement( "Expression" )
.writeAttribute( "success", assertionResult.succeeded() ) .writeAttribute( "success", result.succeeded() )
.writeAttribute( "type", assertionResult.getTestMacroName() ); .writeAttribute( "type", result.getTestMacroName() );
writeSourceInfo( assertionResult.getSourceInfo() ); writeSourceInfo( result.getSourceInfo() );
m_xml.scopedElement( "Original" ) m_xml.scopedElement( "Original" )
.writeText( assertionResult.getExpression() ); .writeText( result.getExpression() );
m_xml.scopedElement( "Expanded" ) m_xml.scopedElement( "Expanded" )
.writeText( assertionResult.getExpandedExpression() ); .writeText( result.getExpandedExpression() );
} }
// And... Print a result applicable to each result type. // And... Print a result applicable to each result type.
switch( assertionResult.getResultType() ) { switch( result.getResultType() ) {
case ResultWas::ThrewException: case ResultWas::ThrewException:
m_xml.startElement( "Exception" ); m_xml.startElement( "Exception" );
writeSourceInfo( assertionResult.getSourceInfo() ); writeSourceInfo( result.getSourceInfo() );
m_xml.writeText( assertionResult.getMessage() ); m_xml.writeText( result.getMessage() );
m_xml.endElement(); m_xml.endElement();
break; break;
case ResultWas::FatalErrorCondition: case ResultWas::FatalErrorCondition:
m_xml.startElement( "FatalErrorCondition" ); m_xml.startElement( "FatalErrorCondition" );
writeSourceInfo( assertionResult.getSourceInfo() ); writeSourceInfo( result.getSourceInfo() );
m_xml.writeText( assertionResult.getMessage() ); m_xml.writeText( result.getMessage() );
m_xml.endElement(); m_xml.endElement();
break; break;
case ResultWas::Info: case ResultWas::Info:
m_xml.scopedElement( "Info" ) m_xml.scopedElement( "Info" )
.writeText( assertionResult.getMessage() ); .writeText( result.getMessage() );
break; break;
case ResultWas::Warning: case ResultWas::Warning:
// Warning will already have been written // Warning will already have been written
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
m_xml.startElement( "Failure" ); m_xml.startElement( "Failure" );
writeSourceInfo( assertionResult.getSourceInfo() ); writeSourceInfo( result.getSourceInfo() );
m_xml.writeText( assertionResult.getMessage() ); m_xml.writeText( result.getMessage() );
m_xml.endElement(); m_xml.endElement();
break; break;
default: default:
break; break;
} }
if( assertionResult.hasExpression() ) if( result.hasExpression() )
m_xml.endElement(); m_xml.endElement();
return true; return true;
...@@ -10093,7 +10288,8 @@ namespace Catch { ...@@ -10093,7 +10288,8 @@ namespace Catch {
public: public:
JunitReporter( ReporterConfig const& _config ) JunitReporter( ReporterConfig const& _config )
: CumulativeReporterBase( _config ), : CumulativeReporterBase( _config ),
xml( _config.stream() ) xml( _config.stream() ),
m_okToFail( false )
{ {
m_reporterPrefs.shouldRedirectStdOut = true; m_reporterPrefs.shouldRedirectStdOut = true;
} }
...@@ -10119,8 +10315,11 @@ namespace Catch { ...@@ -10119,8 +10315,11 @@ namespace Catch {
CumulativeReporterBase::testGroupStarting( groupInfo ); CumulativeReporterBase::testGroupStarting( groupInfo );
} }
virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE {
m_okToFail = testCaseInfo.okToFail();
}
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException ) if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
unexpectedExceptions++; unexpectedExceptions++;
return CumulativeReporterBase::assertionEnded( assertionStats ); return CumulativeReporterBase::assertionEnded( assertionStats );
} }
...@@ -10285,6 +10484,7 @@ namespace Catch { ...@@ -10285,6 +10484,7 @@ namespace Catch {
std::ostringstream stdOutForSuite; std::ostringstream stdOutForSuite;
std::ostringstream stdErrForSuite; std::ostringstream stdErrForSuite;
unsigned int unexpectedExceptions; unsigned int unexpectedExceptions;
bool m_okToFail;
}; };
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
...@@ -10299,25 +10499,6 @@ namespace Catch { ...@@ -10299,25 +10499,6 @@ namespace Catch {
namespace Catch { namespace Catch {
namespace {
// Because formatting using c++ streams is stateful, drop down to C is required
// Alternatively we could use stringstream, but its performance is... not good.
std::string getFormattedDuration( double duration ) {
// Max exponent + 1 is required to represent the whole part
// + 1 for decimal point
// + 3 for the 3 decimal places
// + 1 for null terminator
const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
char buffer[maxDoubleSize];
#ifdef _MSC_VER
sprintf_s(buffer, "%.3f", duration);
#else
sprintf(buffer, "%.3f", duration);
#endif
return std::string(buffer);
}
}
struct ConsoleReporter : StreamingReporterBase { struct ConsoleReporter : StreamingReporterBase {
ConsoleReporter( ReporterConfig const& _config ) ConsoleReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config ), : StreamingReporterBase( _config ),
...@@ -10339,18 +10520,15 @@ namespace Catch { ...@@ -10339,18 +10520,15 @@ namespace Catch {
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE { virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
AssertionResult const& result = _assertionStats.assertionResult; AssertionResult const& result = _assertionStats.assertionResult;
bool printInfoMessages = true; bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
// Drop out if result was successful and we're not printing those // Drop out if result was successful but we're not printing them.
if( !m_config->includeSuccessfulResults() && result.isOk() ) { if( !includeResults && result.getResultType() != ResultWas::Warning )
if( result.getResultType() != ResultWas::Warning )
return false; return false;
printInfoMessages = false;
}
lazyPrint(); lazyPrint();
AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); AssertionPrinter printer( stream, _assertionStats, includeResults );
printer.print(); printer.print();
stream << std::endl; stream << std::endl;
return true; return true;
...@@ -10440,7 +10618,11 @@ namespace Catch { ...@@ -10440,7 +10618,11 @@ namespace Catch {
case ResultWas::ThrewException: case ResultWas::ThrewException:
colour = Colour::Error; colour = Colour::Error;
passOrFail = "FAILED"; passOrFail = "FAILED";
messageLabel = "due to unexpected exception with message"; messageLabel = "due to unexpected exception with ";
if (_stats.infoMessages.size() == 1)
messageLabel += "message";
if (_stats.infoMessages.size() > 1)
messageLabel += "messages";
break; break;
case ResultWas::FatalErrorCondition: case ResultWas::FatalErrorCondition:
colour = Colour::Error; colour = Colour::Error;
...@@ -10556,7 +10738,7 @@ namespace Catch { ...@@ -10556,7 +10738,7 @@ namespace Catch {
stream << '\n' << getLineOfChars<'~'>() << '\n'; stream << '\n' << getLineOfChars<'~'>() << '\n';
Colour colour( Colour::SecondaryText ); Colour colour( Colour::SecondaryText );
stream << currentTestRunInfo->name stream << currentTestRunInfo->name
<< " is a Catch v" << libraryVersion << " host application.\n" << " is a Catch v" << libraryVersion() << " host application.\n"
<< "Run with -? for options\n\n"; << "Run with -? for options\n\n";
if( m_config->rngSeed() != 0 ) if( m_config->rngSeed() != 0 )
...@@ -10769,8 +10951,7 @@ namespace Catch { ...@@ -10769,8 +10951,7 @@ namespace Catch {
stream << "No test cases matched '" << spec << '\'' << std::endl; stream << "No test cases matched '" << spec << '\'' << std::endl;
} }
virtual void assertionStarting( AssertionInfo const& ) { virtual void assertionStarting( AssertionInfo const& ) {}
}
virtual bool assertionEnded( AssertionStats const& _assertionStats ) { virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
AssertionResult const& result = _assertionStats.assertionResult; AssertionResult const& result = _assertionStats.assertionResult;
...@@ -10791,6 +10972,12 @@ namespace Catch { ...@@ -10791,6 +10972,12 @@ namespace Catch {
return true; return true;
} }
virtual void sectionEnded(SectionStats const& _sectionStats) CATCH_OVERRIDE {
if (m_config->showDurations() == ShowDurations::Always) {
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
}
}
virtual void testRunEnded( TestRunStats const& _testRunStats ) { virtual void testRunEnded( TestRunStats const& _testRunStats ) {
printTotals( _testRunStats.totals ); printTotals( _testRunStats.totals );
stream << '\n' << std::endl; stream << '\n' << std::endl;
...@@ -10896,7 +11083,7 @@ namespace Catch { ...@@ -10896,7 +11083,7 @@ namespace Catch {
stream << result.getSourceInfo() << ':'; stream << result.getSourceInfo() << ':';
} }
void printResultType( Colour::Code colour, std::string passOrFail ) const { void printResultType( Colour::Code colour, std::string const& passOrFail ) const {
if( !passOrFail.empty() ) { if( !passOrFail.empty() ) {
{ {
Colour colourGuard( colour ); Colour colourGuard( colour );
...@@ -10906,7 +11093,7 @@ namespace Catch { ...@@ -10906,7 +11093,7 @@ namespace Catch {
} }
} }
void printIssue( std::string issue ) const { void printIssue( std::string const& issue ) const {
stream << ' ' << issue; stream << ' ' << issue;
} }
...@@ -11077,6 +11264,7 @@ namespace Catch { ...@@ -11077,6 +11264,7 @@ namespace Catch {
TestSpec::NamePattern::~NamePattern() {} TestSpec::NamePattern::~NamePattern() {}
TestSpec::TagPattern::~TagPattern() {} TestSpec::TagPattern::~TagPattern() {}
TestSpec::ExcludedPattern::~ExcludedPattern() {} TestSpec::ExcludedPattern::~ExcludedPattern() {}
Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {}
void Config::dummy() {} void Config::dummy() {}
...@@ -11100,8 +11288,14 @@ namespace Catch { ...@@ -11100,8 +11288,14 @@ namespace Catch {
#ifndef __OBJC__ #ifndef __OBJC__
#if defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point // Standard C/C++ main entry point
int main (int argc, char * argv[]) { int main (int argc, char * argv[]) {
#endif
int result = Catch::Session().run( argc, argv ); int result = Catch::Session().run( argc, argv );
return ( result < 0xff ? result : 0xff ); return ( result < 0xff ? result : 0xff );
} }
...@@ -11137,33 +11331,43 @@ int main (int argc, char * const argv[]) { ...@@ -11137,33 +11331,43 @@ int main (int argc, char * const argv[]) {
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ // If this config identifier is defined then all CATCH macros are prefixed with CATCH_
#ifdef CATCH_CONFIG_PREFIX_ALL #ifdef CATCH_CONFIG_PREFIX_ALL
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" ) #if defined(CATCH_CONFIG_FAST_COMPILE)
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" ) #define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr )
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
#else
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr )
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
#endif
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr )
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr )
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" ) #define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" ) #define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" ) #define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" ) #define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr )
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" ) #define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" ) #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" ) #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" ) #define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" )
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CATCH_CHECK_THROWS" ) #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
#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_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" ) #if defined(CATCH_CONFIG_FAST_COMPILE)
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" ) #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
#else
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
#endif
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg ) #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
...@@ -11171,16 +11375,18 @@ int main (int argc, char * const argv[]) { ...@@ -11171,16 +11375,18 @@ int main (int argc, char * const argv[]) {
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ ) #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ ) #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#else #else
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
#define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
#define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description ) #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg ) #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg )
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg ) #define CATCH_FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg )
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg )
#endif #endif
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
...@@ -11206,50 +11412,63 @@ int main (int argc, char * const argv[]) { ...@@ -11206,50 +11412,63 @@ int main (int argc, char * const argv[]) {
// 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
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" ) #if defined(CATCH_CONFIG_FAST_COMPILE)
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" ) #define REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE", Catch::ResultDisposition::Normal, expr )
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" ) #else
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" ) #define REQUIRE( expr ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, expr )
#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" ) #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" ) #endif
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" ) #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr )
#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" ) #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr )
#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( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" ) #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" ) #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr )
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr )
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" ) #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" ) #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr )
#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) #if defined(CATCH_CONFIG_FAST_COMPILE)
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) #else
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
#endif
#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) )
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) )
#ifdef CATCH_CONFIG_VARIADIC_MACROS #ifdef CATCH_CONFIG_VARIADIC_MACROS
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ ) #define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ ) #define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
#else #else
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
#define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
#define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description ) #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg ) #define FAIL( msg ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg )
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg ) #define FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg )
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg )
#endif #endif
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
...@@ -11278,5 +11497,19 @@ int main (int argc, char * const argv[]) { ...@@ -11278,5 +11497,19 @@ int main (int argc, char * const argv[]) {
using Catch::Detail::Approx; using Catch::Detail::Approx;
// #included from: internal/catch_reenable_warnings.h
#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED
#ifdef __clang__
# ifdef __ICC // icpc defines the __clang__ macro
# pragma warning(pop)
# else
# pragma clang diagnostic pop
# endif
#elif defined __GNUC__
# pragma GCC diagnostic pop
#endif
#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment