summaryrefslogtreecommitdiff
path: root/src/test/catch.hpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-07 19:33:07 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-07 19:33:07 +0300
commitc63811a9e419fcd61c4cefb86bbf8d5f5ee7ebeb (patch)
tree9ec93b45bd466ebb6057220f811af056b827bb41 /src/test/catch.hpp
parentc9040fd25b58d74b69418a9badecaf23e4076bf0 (diff)
downloadplus-c63811a9e419fcd61c4cefb86bbf8d5f5ee7ebeb.tar.gz
plus-c63811a9e419fcd61c4cefb86bbf8d5f5ee7ebeb.tar.bz2
plus-c63811a9e419fcd61c4cefb86bbf8d5f5ee7ebeb.tar.xz
plus-c63811a9e419fcd61c4cefb86bbf8d5f5ee7ebeb.zip
Revert "Update catch from git."
This reverts commit ec26c1bfa3d664d3f66d2f15db81dec23cb58800.
Diffstat (limited to 'src/test/catch.hpp')
-rw-r--r--src/test/catch.hpp3110
1 files changed, 1023 insertions, 2087 deletions
diff --git a/src/test/catch.hpp b/src/test/catch.hpp
index 555760450..64d1cafc4 100644
--- a/src/test/catch.hpp
+++ b/src/test/catch.hpp
@@ -1,6 +1,6 @@
/*
- * Catch v1.9.6
- * Generated: 2017-06-27 12:19:54.557875
+ * Catch v1.5.1
+ * Generated: 2016-04-28 08:12:37.387488
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -40,8 +40,6 @@
#elif defined __GNUC__
# pragma GCC diagnostic ignored "-Wvariadic-macros"
# pragma GCC diagnostic ignored "-Wunused-variable"
-# pragma GCC diagnostic ignored "-Wparentheses"
-
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpadded"
#endif
@@ -62,6 +60,27 @@
// #included from: catch_common.h
#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
+#ifdef CATCH_CONFIG_COUNTER
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
+#else
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
+#endif
+
+#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
+#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
+
+#include <sstream>
+#include <stdexcept>
+#include <algorithm>
+
+// stack
+#ifdef HAVE_EXECINFO
+#include <execinfo.h>
+#endif // HAVE_EXECINFO
+// stack
+
// #included from: catch_compiler_capabilities.h
#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
@@ -76,15 +95,11 @@
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
// CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
-// CATCH_CONFIG_CPP11_SHUFFLE : is std::shuffle supported?
-// CATCH_CONFIG_CPP11_TYPE_TRAITS : are type_traits and enable_if supported?
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
-// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
-// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
// ****************
// Note to maintainers: if new toggles are added please document them
// in configuration.md, too
@@ -97,16 +112,8 @@
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
-#ifdef __cplusplus
-
-# if __cplusplus >= 201103L
-# define CATCH_CPP11_OR_GREATER
-# endif
-
-# if __cplusplus >= 201402L
-# define CATCH_CPP14_OR_GREATER
-# endif
-
+#if defined(__cplusplus) && __cplusplus >= 201103L
+# define CATCH_CPP11_OR_GREATER
#endif
#ifdef __clang__
@@ -120,42 +127,12 @@
# endif
# 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 \
- _Pragma( "clang diagnostic push" ) \
- _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
- _Pragma( "clang diagnostic pop" )
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
# endif
#endif // __clang__
////////////////////////////////////////////////////////////////////////////////
-// We know some environments not to support full POSIX signals
-#if defined(__CYGWIN__) || defined(__QNX__)
-
-# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
-# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
-# endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Cygwin
-#ifdef __CYGWIN__
-
-// Required for some versions of Cygwin to declare gettimeofday
-// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
-# define _BSD_SOURCE
-
-#endif // __CYGWIN__
-
-////////////////////////////////////////////////////////////////////////////////
// Borland
#ifdef __BORLANDC__
@@ -181,6 +158,10 @@
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif
+# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
+# endif
+
// - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below
@@ -190,8 +171,6 @@
// Visual C++
#ifdef _MSC_VER
-#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
-
#if (_MSC_VER >= 1600)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
@@ -200,8 +179,6 @@
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
-#define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
#endif
#endif // _MSC_VER
@@ -220,7 +197,7 @@
// Use __COUNTER__ if the compiler supports it
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
- ( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
+ ( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
( defined __clang__ && __clang_major__ >= 3 )
#define CATCH_INTERNAL_CONFIG_COUNTER
@@ -267,12 +244,6 @@
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE)
-# define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
-# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS)
-# define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
-# endif
#endif // __cplusplus >= 201103L
@@ -295,42 +266,21 @@
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
# define CATCH_CONFIG_VARIADIC_MACROS
#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
+#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_LONG_LONG
#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
+#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_OVERRIDE
#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
+#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
#endif
-// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
-// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
-// This does not affect compilation
-#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
+#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
# define CATCH_CONFIG_COUNTER
#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_SHUFFLE
-#endif
-# if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_TYPE_TRAITS
-# endif
-#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)
-# define CATCH_CONFIG_WINDOWS_SEH
-#endif
-// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
-#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
-# define CATCH_CONFIG_POSIX_SIGNALS
-#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
-#endif
-#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
-# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
#endif
// noexcept support:
@@ -363,26 +313,6 @@
# define CATCH_AUTO_PTR( T ) std::auto_ptr<T>
#endif
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
-#ifdef CATCH_CONFIG_COUNTER
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
-#else
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
-#endif
-
-#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
-#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
-
-#include <sstream>
-#include <algorithm>
-
-// stack
-#ifdef HAVE_EXECINFO
-#include <execinfo.h>
-#endif // HAVE_EXECINFO
-// stack
-
namespace Catch {
struct IConfig;
@@ -435,9 +365,7 @@ namespace Catch {
}
bool startsWith( std::string const& s, std::string const& prefix );
- bool startsWith( std::string const& s, char prefix );
bool endsWith( std::string const& s, std::string const& suffix );
- bool endsWith( std::string const& s, char suffix );
bool contains( std::string const& s, std::string const& infix );
void toLowerInPlace( std::string& s );
std::string toLower( std::string const& s );
@@ -457,8 +385,8 @@ namespace Catch {
SourceLineInfo();
SourceLineInfo( char const* _file, std::size_t _line );
+ SourceLineInfo( SourceLineInfo const& other );
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- SourceLineInfo(SourceLineInfo const& other) = default;
SourceLineInfo( SourceLineInfo && ) = default;
SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
SourceLineInfo& operator = ( SourceLineInfo && ) = default;
@@ -467,7 +395,7 @@ namespace Catch {
bool operator == ( SourceLineInfo const& other ) const;
bool operator < ( SourceLineInfo const& other ) const;
- char const* file;
+ std::string file;
std::size_t line;
};
@@ -501,6 +429,8 @@ namespace Catch {
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
+#include <ostream>
+
namespace Catch {
class NotImplementedException : public std::exception
@@ -633,6 +563,10 @@ namespace Catch {
#pragma clang diagnostic pop
#endif
+#include <memory>
+#include <vector>
+#include <stdlib.h>
+
namespace Catch {
class TestCase;
@@ -776,76 +710,59 @@ void registerTestCaseFunction
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
static void TestName(); \
- 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 \
+ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
static void TestName()
#define INTERNAL_CATCH_TESTCASE( ... ) \
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, ... ) \
- 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
+ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ \
struct TestName : ClassName{ \
void test(); \
}; \
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()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
+ Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
#else
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
static void TestName(); \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
static void TestName()
#define INTERNAL_CATCH_TESTCASE( 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 ) \
- 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
+ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
namespace{ \
struct TestCaseName : ClassName{ \
void test(); \
}; \
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()
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
+ Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
#endif
// #included from: internal/catch_capture.hpp
@@ -913,83 +830,27 @@ namespace Catch {
namespace Catch {
- struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
-
- struct DecomposedExpression
- {
- virtual ~DecomposedExpression() {}
- virtual bool isBinaryExpression() const {
- return false;
- }
- virtual void reconstructExpression( std::string& dest ) const = 0;
-
- // Only simple binary comparisons can be decomposed.
- // If more complex check is required then wrap sub-expressions in parentheses.
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator % ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( T const& );
- template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( T const& );
-
- private:
- DecomposedExpression& operator = (DecomposedExpression const&);
- };
-
struct AssertionInfo
{
AssertionInfo() {}
- AssertionInfo( char const * _macroName,
+ AssertionInfo( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
- char const * _capturedExpression,
- ResultDisposition::Flags _resultDisposition,
- char const * _secondArg = "");
+ std::string const& _capturedExpression,
+ ResultDisposition::Flags _resultDisposition );
- char const * macroName;
+ std::string macroName;
SourceLineInfo lineInfo;
- char const * capturedExpression;
+ std::string capturedExpression;
ResultDisposition::Flags resultDisposition;
- char const * secondArg;
};
struct AssertionResultData
{
- AssertionResultData() : decomposedExpression( CATCH_NULL )
- , resultType( ResultWas::Unknown )
- , negated( false )
- , parenthesized( false ) {}
-
- void negate( bool parenthesize ) {
- negated = !negated;
- parenthesized = parenthesize;
- if( resultType == ResultWas::Ok )
- resultType = ResultWas::ExpressionFailed;
- else if( resultType == ResultWas::ExpressionFailed )
- resultType = ResultWas::Ok;
- }
-
- std::string const& reconstructExpression() const {
- if( decomposedExpression != CATCH_NULL ) {
- decomposedExpression->reconstructExpression( reconstructedExpression );
- if( parenthesized ) {
- reconstructedExpression.insert( 0, 1, '(' );
- reconstructedExpression.append( 1, ')' );
- }
- if( negated ) {
- reconstructedExpression.insert( 0, 1, '!' );
- }
- decomposedExpression = CATCH_NULL;
- }
- return reconstructedExpression;
- }
+ AssertionResultData() : resultType( ResultWas::Unknown ) {}
- mutable DecomposedExpression const* decomposedExpression;
- mutable std::string reconstructedExpression;
+ std::string reconstructedExpression;
std::string message;
ResultWas::OfType resultType;
- bool negated;
- bool parenthesized;
};
class AssertionResult {
@@ -1016,8 +877,6 @@ namespace Catch {
std::string getMessage() const;
SourceLineInfo getSourceInfo() const;
std::string getTestMacroName() const;
- void discardDecomposedExpression() const;
- void expandDecomposedExpression() const;
protected:
AssertionInfo m_info;
@@ -1033,161 +892,313 @@ namespace Catch {
namespace Matchers {
namespace Impl {
- template<typename ArgT> struct MatchAllOf;
- template<typename ArgT> struct MatchAnyOf;
- template<typename ArgT> struct MatchNotOf;
+ namespace Generic {
+ template<typename ExpressionT> class AllOf;
+ template<typename ExpressionT> class AnyOf;
+ template<typename ExpressionT> class Not;
+ }
+
+ template<typename ExpressionT>
+ struct Matcher : SharedImpl<IShared>
+ {
+ typedef ExpressionT ExpressionType;
+
+ virtual ~Matcher() {}
+ virtual Ptr<Matcher> clone() const = 0;
+ virtual bool match( ExpressionT const& expr ) const = 0;
+ virtual std::string toString() const = 0;
+
+ Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
+ Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
+ Generic::Not<ExpressionT> operator ! () const;
+ };
+
+ template<typename DerivedT, typename ExpressionT>
+ struct MatcherImpl : Matcher<ExpressionT> {
- class MatcherUntypedBase {
+ virtual Ptr<Matcher<ExpressionT> > clone() const {
+ return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<DerivedT const&>( *this ) ) );
+ }
+ };
+
+ namespace Generic {
+ template<typename ExpressionT>
+ class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
public:
- std::string toString() const {
- if( m_cachedToString.empty() )
- m_cachedToString = describe();
- return m_cachedToString;
+ explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
+ Not( Not const& other ) : m_matcher( other.m_matcher ) {}
+
+ virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
+ return !m_matcher->match( expr );
}
- protected:
- virtual ~MatcherUntypedBase();
- virtual std::string describe() const = 0;
- mutable std::string m_cachedToString;
+ virtual std::string toString() const CATCH_OVERRIDE {
+ return "not " + m_matcher->toString();
+ }
private:
- MatcherUntypedBase& operator = ( MatcherUntypedBase const& );
+ Ptr< Matcher<ExpressionT> > m_matcher;
};
- template<typename ObjectT>
- struct MatcherMethod {
- 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> {
+ template<typename ExpressionT>
+ class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
+ public:
- MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const;
- MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const;
- MatchNotOf<ComparatorT> operator ! () const;
- };
+ AllOf() {}
+ AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
- template<typename ArgT>
- struct MatchAllOf : MatcherBase<ArgT> {
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if (!m_matchers[i]->match(arg))
+ AllOf& add( Matcher<ExpressionT> const& matcher ) {
+ m_matchers.push_back( matcher.clone() );
+ return *this;
+ }
+ virtual bool match( ExpressionT const& expr ) const
+ {
+ for( std::size_t i = 0; i < m_matchers.size(); ++i )
+ if( !m_matchers[i]->match( expr ) )
return false;
- }
return true;
}
- virtual std::string describe() const CATCH_OVERRIDE {
- std::string description;
- description.reserve( 4 + m_matchers.size()*32 );
- description += "( ";
+ virtual std::string toString() const {
+ std::ostringstream oss;
+ oss << "( ";
for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
if( i != 0 )
- description += " and ";
- description += m_matchers[i]->toString();
+ oss << " and ";
+ oss << m_matchers[i]->toString();
}
- description += " )";
- return description;
+ oss << " )";
+ return oss.str();
}
- MatchAllOf<ArgT>& operator && ( MatcherBase<ArgT> const& other ) {
- m_matchers.push_back( &other );
- return *this;
+ AllOf operator && ( Matcher<ExpressionT> const& other ) const {
+ AllOf allOfExpr( *this );
+ allOfExpr.add( other );
+ return allOfExpr;
}
- std::vector<MatcherBase<ArgT> const*> m_matchers;
+ private:
+ std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
};
- template<typename ArgT>
- struct MatchAnyOf : MatcherBase<ArgT> {
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if (m_matchers[i]->match(arg))
+ template<typename ExpressionT>
+ class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
+ public:
+
+ AnyOf() {}
+ AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
+
+ AnyOf& add( Matcher<ExpressionT> const& matcher ) {
+ m_matchers.push_back( matcher.clone() );
+ return *this;
+ }
+ virtual bool match( ExpressionT const& expr ) const
+ {
+ for( std::size_t i = 0; i < m_matchers.size(); ++i )
+ if( m_matchers[i]->match( expr ) )
return true;
- }
return false;
}
- virtual std::string describe() const CATCH_OVERRIDE {
- std::string description;
- description.reserve( 4 + m_matchers.size()*32 );
- description += "( ";
+ virtual std::string toString() const {
+ std::ostringstream oss;
+ oss << "( ";
for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
if( i != 0 )
- description += " or ";
- description += m_matchers[i]->toString();
+ oss << " or ";
+ oss << m_matchers[i]->toString();
}
- description += " )";
- return description;
+ oss << " )";
+ return oss.str();
}
- MatchAnyOf<ArgT>& operator || ( MatcherBase<ArgT> const& other ) {
- m_matchers.push_back( &other );
- return *this;
+ AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
+ AnyOf anyOfExpr( *this );
+ anyOfExpr.add( other );
+ return anyOfExpr;
}
- std::vector<MatcherBase<ArgT> const*> m_matchers;
+ private:
+ std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
};
- template<typename ArgT>
- struct MatchNotOf : MatcherBase<ArgT> {
+ } // namespace Generic
+
+ template<typename ExpressionT>
+ Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
+ Generic::AllOf<ExpressionT> allOfExpr;
+ allOfExpr.add( *this );
+ allOfExpr.add( other );
+ return allOfExpr;
+ }
+
+ template<typename ExpressionT>
+ Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
+ Generic::AnyOf<ExpressionT> anyOfExpr;
+ anyOfExpr.add( *this );
+ anyOfExpr.add( other );
+ return anyOfExpr;
+ }
+
+ template<typename ExpressionT>
+ Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
+ return Generic::Not<ExpressionT>( *this );
+ }
+
+ namespace StdString {
+
+ inline std::string makeString( std::string const& str ) { return str; }
+ inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
- MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {}
+ struct CasedString
+ {
+ CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
+ : m_caseSensitivity( caseSensitivity ),
+ m_str( adjustString( str ) )
+ {}
+ std::string adjustString( std::string const& str ) const {
+ return m_caseSensitivity == CaseSensitive::No
+ ? toLower( str )
+ : str;
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- return !m_underlyingMatcher.match( arg );
}
+ std::string toStringSuffix() const
+ {
+ return m_caseSensitivity == CaseSensitive::No
+ ? " (case insensitive)"
+ : "";
+ }
+ CaseSensitive::Choice m_caseSensitivity;
+ std::string m_str;
+ };
+
+ struct Equals : MatcherImpl<Equals, std::string> {
+ Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
+ : m_data( str, caseSensitivity )
+ {}
+ Equals( Equals const& other ) : m_data( other.m_data ){}
- virtual std::string describe() const CATCH_OVERRIDE {
- return "not " + m_underlyingMatcher.toString();
+ virtual ~Equals();
+
+ virtual bool match( std::string const& expr ) const {
+ return m_data.m_str == m_data.adjustString( expr );;
+ }
+ virtual std::string toString() const {
+ return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
}
- MatcherBase<ArgT> const& m_underlyingMatcher;
+
+ CasedString m_data;
};
- template<typename ObjectT, typename ComparatorT>
- MatchAllOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator && ( MatcherBase const& other ) const {
- return MatchAllOf<ComparatorT>() && *this && other;
- }
- template<typename ObjectT, typename ComparatorT>
- MatchAnyOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator || ( MatcherBase const& other ) const {
- return MatchAnyOf<ComparatorT>() || *this || other;
- }
- template<typename ObjectT, typename ComparatorT>
- MatchNotOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator ! () const {
- return MatchNotOf<ComparatorT>( *this );
- }
+ struct Contains : MatcherImpl<Contains, std::string> {
+ Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
+ : m_data( substr, caseSensitivity ){}
+ Contains( Contains const& other ) : m_data( other.m_data ){}
+
+ virtual ~Contains();
+
+ virtual bool match( std::string const& expr ) const {
+ return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
+ }
+ virtual std::string toString() const {
+ return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
+ }
+
+ CasedString m_data;
+ };
+
+ struct StartsWith : MatcherImpl<StartsWith, std::string> {
+ StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
+ : m_data( substr, caseSensitivity ){}
+
+ StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
+
+ virtual ~StartsWith();
+ virtual bool match( std::string const& expr ) const {
+ return startsWith( m_data.adjustString( expr ), m_data.m_str );
+ }
+ virtual std::string toString() const {
+ return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
+ }
+
+ CasedString m_data;
+ };
+
+ struct EndsWith : MatcherImpl<EndsWith, std::string> {
+ EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
+ : m_data( substr, caseSensitivity ){}
+ EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
+
+ virtual ~EndsWith();
+
+ virtual bool match( std::string const& expr ) const {
+ return endsWith( m_data.adjustString( expr ), m_data.m_str );
+ }
+ virtual std::string toString() const {
+ return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
+ }
+
+ CasedString m_data;
+ };
+ } // namespace StdString
} // namespace Impl
// The following functions create the actual matcher objects.
// This allows the types to be inferred
- // - deprecated: prefer ||, && and !
- template<typename T>
- inline Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
- return Impl::MatchNotOf<T>( underlyingMatcher );
+ template<typename ExpressionT>
+ inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<ExpressionT> const& m ) {
+ return Impl::Generic::Not<ExpressionT>( m );
}
- template<typename T>
- inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
- return Impl::MatchAllOf<T>() && m1 && m2;
+
+ template<typename ExpressionT>
+ inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
+ Impl::Matcher<ExpressionT> const& m2 ) {
+ return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
}
- template<typename T>
- inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
- return Impl::MatchAllOf<T>() && m1 && m2 && m3;
+ template<typename ExpressionT>
+ inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
+ Impl::Matcher<ExpressionT> const& m2,
+ Impl::Matcher<ExpressionT> const& m3 ) {
+ return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
}
- template<typename T>
- inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
- return Impl::MatchAnyOf<T>() || m1 || m2;
+ template<typename ExpressionT>
+ inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
+ Impl::Matcher<ExpressionT> const& m2 ) {
+ return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
}
- template<typename T>
- inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
- return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
+ template<typename ExpressionT>
+ inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
+ Impl::Matcher<ExpressionT> const& m2,
+ Impl::Matcher<ExpressionT> const& m3 ) {
+ return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
+ }
+
+ inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
+ return Impl::StdString::Equals( str, caseSensitivity );
+ }
+ inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
+ return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity );
+ }
+ inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
+ return Impl::StdString::Contains( substr, caseSensitivity );
+ }
+ inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
+ return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity );
+ }
+ inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
+ return Impl::StdString::StartsWith( substr );
+ }
+ inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
+ return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
+ }
+ inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) {
+ return Impl::StdString::EndsWith( substr );
+ }
+ inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
+ return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) );
}
} // namespace Matchers
using namespace Matchers;
-using Matchers::Impl::MatcherBase;
} // namespace Catch
@@ -1197,27 +1208,28 @@ namespace Catch {
template<typename T> class ExpressionLhs;
+ struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
+
struct CopyableStream {
CopyableStream() {}
CopyableStream( CopyableStream const& other ) {
oss << other.oss.str();
}
CopyableStream& operator=( CopyableStream const& other ) {
- oss.str(std::string());
+ oss.str("");
oss << other.oss.str();
return *this;
}
std::ostringstream oss;
};
- class ResultBuilder : public DecomposedExpression {
+ class ResultBuilder {
public:
ResultBuilder( char const* macroName,
SourceLineInfo const& lineInfo,
char const* capturedExpression,
ResultDisposition::Flags resultDisposition,
char const* secondArg = "" );
- ~ResultBuilder();
template<typename T>
ExpressionLhs<T const&> operator <= ( T const& operand );
@@ -1225,49 +1237,46 @@ namespace Catch {
template<typename T>
ResultBuilder& operator << ( T const& value ) {
- m_stream().oss << value;
+ m_stream.oss << value;
return *this;
}
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
+
ResultBuilder& setResultType( ResultWas::OfType result );
ResultBuilder& setResultType( bool result );
+ ResultBuilder& setLhs( std::string const& lhs );
+ ResultBuilder& setRhs( std::string const& rhs );
+ ResultBuilder& setOp( std::string const& op );
- void endExpression( DecomposedExpression const& expr );
-
- virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE;
+ void endExpression();
+ std::string reconstructExpression() const;
AssertionResult build() const;
- AssertionResult build( DecomposedExpression const& expr ) const;
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
void captureResult( ResultWas::OfType resultType );
void captureExpression();
void captureExpectedException( std::string const& expectedMessage );
- void captureExpectedException( Matchers::Impl::MatcherBase<std::string> const& matcher );
+ void captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher );
void handleResult( AssertionResult const& result );
void react();
bool shouldDebugBreak() const;
bool allowThrows() const;
- template<typename ArgT, typename MatcherT>
- void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString );
-
- void setExceptionGuard();
- void unsetExceptionGuard();
-
private:
AssertionInfo m_assertionInfo;
AssertionResultData m_data;
-
- static CopyableStream &m_stream()
- {
- static CopyableStream s;
- return s;
- }
+ struct ExprComponents {
+ ExprComponents() : testFalse( false ) {}
+ bool testFalse;
+ std::string lhs, rhs, op;
+ } m_exprComponents;
+ CopyableStream m_stream;
bool m_shouldDebugBreak;
bool m_shouldThrow;
- bool m_guardException;
};
} // namespace Catch
@@ -1282,7 +1291,6 @@ namespace Catch {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
-#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
#endif
#include <cstddef>
@@ -1584,7 +1592,7 @@ std::string toString( std::nullptr_t );
#ifdef __OBJC__
std::string toString( NSString const * const& nsstring );
- std::string toString( NSString * CATCH_ARC_STRONG & nsstring );
+ std::string toString( NSString * CATCH_ARC_STRONG const& nsstring );
std::string toString( NSObject* const& nsObject );
#endif
@@ -1592,7 +1600,6 @@ namespace Detail {
extern const std::string unprintableString;
- #if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
struct BorgType {
template<typename T> BorgType( T const& );
};
@@ -1611,20 +1618,6 @@ namespace Detail {
static T const&t;
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)
template<typename T,
@@ -1801,159 +1794,90 @@ std::string toString( T const& value ) {
namespace Catch {
-template<typename LhsT, Internal::Operator Op, typename RhsT>
-class BinaryExpression;
-
-template<typename ArgT, typename MatcherT>
-class MatchExpression;
-
-// Wraps the LHS of an expression and overloads comparison operators
-// for also capturing those and RHS (if any)
+// Wraps the LHS of an expression and captures the operator and RHS (if any) -
+// wrapping them all in a ResultBuilder object
template<typename T>
-class ExpressionLhs : public DecomposedExpression {
-public:
- ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ), m_truthy(false) {}
+class ExpressionLhs {
+ ExpressionLhs& operator = ( ExpressionLhs const& );
+# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
+ ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
+# endif
- ExpressionLhs& operator = ( const ExpressionLhs& );
+public:
+ ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
+# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
+ ExpressionLhs( ExpressionLhs const& ) = default;
+ ExpressionLhs( ExpressionLhs && ) = default;
+# endif
template<typename RhsT>
- BinaryExpression<T, Internal::IsEqualTo, RhsT const&>
- operator == ( RhsT const& rhs ) {
+ ResultBuilder& operator == ( RhsT const& rhs ) {
return captureExpression<Internal::IsEqualTo>( rhs );
}
template<typename RhsT>
- BinaryExpression<T, Internal::IsNotEqualTo, RhsT const&>
- operator != ( RhsT const& rhs ) {
+ ResultBuilder& operator != ( RhsT const& rhs ) {
return captureExpression<Internal::IsNotEqualTo>( rhs );
}
template<typename RhsT>
- BinaryExpression<T, Internal::IsLessThan, RhsT const&>
- operator < ( RhsT const& rhs ) {
+ ResultBuilder& operator < ( RhsT const& rhs ) {
return captureExpression<Internal::IsLessThan>( rhs );
}
template<typename RhsT>
- BinaryExpression<T, Internal::IsGreaterThan, RhsT const&>
- operator > ( RhsT const& rhs ) {
+ ResultBuilder& operator > ( RhsT const& rhs ) {
return captureExpression<Internal::IsGreaterThan>( rhs );
}
template<typename RhsT>
- BinaryExpression<T, Internal::IsLessThanOrEqualTo, RhsT const&>
- operator <= ( RhsT const& rhs ) {
+ ResultBuilder& operator <= ( RhsT const& rhs ) {
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
}
template<typename RhsT>
- BinaryExpression<T, Internal::IsGreaterThanOrEqualTo, RhsT const&>
- operator >= ( RhsT const& rhs ) {
+ ResultBuilder& operator >= ( RhsT const& rhs ) {
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
}
- BinaryExpression<T, Internal::IsEqualTo, bool> operator == ( bool rhs ) {
+ ResultBuilder& operator == ( bool rhs ) {
return captureExpression<Internal::IsEqualTo>( rhs );
}
- BinaryExpression<T, Internal::IsNotEqualTo, bool> operator != ( bool rhs ) {
+ ResultBuilder& operator != ( bool rhs ) {
return captureExpression<Internal::IsNotEqualTo>( rhs );
}
void endExpression() {
- m_truthy = m_lhs ? true : false;
+ bool value = m_lhs ? true : false;
m_rb
- .setResultType( m_truthy )
- .endExpression( *this );
+ .setLhs( Catch::toString( value ) )
+ .setResultType( value )
+ .endExpression();
}
- virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE {
- dest = Catch::toString( m_lhs );
- }
+ // Only simple binary expressions are allowed on the LHS.
+ // If more complex compositions are required then place the sub expression in parentheses
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
+ template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
private:
template<Internal::Operator Op, typename RhsT>
- BinaryExpression<T, Op, RhsT&> captureExpression( RhsT& rhs ) const {
- return BinaryExpression<T, Op, RhsT&>( m_rb, m_lhs, rhs );
- }
-
- template<Internal::Operator Op>
- BinaryExpression<T, Op, bool> captureExpression( bool rhs ) const {
- return BinaryExpression<T, Op, bool>( m_rb, m_lhs, rhs );
+ ResultBuilder& captureExpression( RhsT const& rhs ) {
+ return m_rb
+ .setResultType( Internal::compare<Op>( m_lhs, rhs ) )
+ .setLhs( Catch::toString( m_lhs ) )
+ .setRhs( Catch::toString( rhs ) )
+ .setOp( Internal::OperatorTraits<Op>::getName() );
}
private:
ResultBuilder& m_rb;
T m_lhs;
- bool m_truthy;
-};
-
-template<typename LhsT, Internal::Operator Op, typename RhsT>
-class BinaryExpression : public DecomposedExpression {
-public:
- BinaryExpression( ResultBuilder& rb, LhsT lhs, RhsT rhs )
- : m_rb( rb ), m_lhs( lhs ), m_rhs( rhs ) {}
-
- BinaryExpression& operator = ( BinaryExpression& );
-
- void endExpression() const {
- m_rb
- .setResultType( Internal::compare<Op>( m_lhs, m_rhs ) )
- .endExpression( *this );
- }
-
- virtual bool isBinaryExpression() const CATCH_OVERRIDE {
- return true;
- }
-
- virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE {
- std::string lhs = Catch::toString( m_lhs );
- std::string rhs = Catch::toString( m_rhs );
- char delim = lhs.size() + rhs.size() < 40 &&
- lhs.find('\n') == std::string::npos &&
- rhs.find('\n') == std::string::npos ? ' ' : '\n';
- dest.reserve( 7 + lhs.size() + rhs.size() );
- // 2 for spaces around operator
- // 2 for operator
- // 2 for parentheses (conditionally added later)
- // 1 for negation (conditionally added later)
- dest = lhs;
- dest += delim;
- dest += Internal::OperatorTraits<Op>::getName();
- dest += delim;
- dest += rhs;
- }
-
-private:
- ResultBuilder& m_rb;
- LhsT m_lhs;
- RhsT m_rhs;
-};
-
-template<typename ArgT, typename MatcherT>
-class MatchExpression : public DecomposedExpression {
-public:
- MatchExpression( ArgT arg, MatcherT matcher, char const* matcherString )
- : m_arg( arg ), m_matcher( matcher ), m_matcherString( matcherString ) {}
-
- virtual bool isBinaryExpression() const CATCH_OVERRIDE {
- return true;
- }
-
- virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE {
- std::string matcherAsString = m_matcher.toString();
- dest = Catch::toString( m_arg );
- dest += ' ';
- if( matcherAsString == Detail::unprintableString )
- dest += m_matcherString;
- else
- dest += matcherAsString;
- }
-
-private:
- ArgT m_arg;
- MatcherT m_matcher;
- char const* m_matcherString;
};
} // end namespace Catch
@@ -1970,14 +1894,6 @@ namespace Catch {
return ExpressionLhs<bool>( *this, value );
}
- template<typename ArgT, typename MatcherT>
- inline void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
- char const* matcherString ) {
- MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
- setResultType( matcher.match( arg ) );
- endExpression( expr );
- }
-
} // namespace Catch
// #included from: catch_message.h
@@ -2067,8 +1983,6 @@ namespace Catch {
virtual std::string getCurrentTestName() const = 0;
virtual const AssertionResult* getLastResult() const = 0;
- virtual void exceptionEarlyReported() = 0;
-
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
};
@@ -2082,19 +1996,11 @@ namespace Catch {
#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
-# define CATCH_PLATFORM_MAC
+#define CATCH_PLATFORM_MAC
#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
-# define CATCH_PLATFORM_IPHONE
-#elif defined(linux) || defined(__linux) || defined(__linux__)
-# define CATCH_PLATFORM_LINUX
+#define CATCH_PLATFORM_IPHONE
#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
-# define CATCH_PLATFORM_WINDOWS
-# if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)
-# define CATCH_DEFINES_NOMINMAX
-# endif
-# if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN)
-# define CATCH_DEFINES_WIN32_LEAN_AND_MEAN
-# endif
+#define CATCH_PLATFORM_WINDOWS
#endif
#include <string>
@@ -2109,36 +2015,27 @@ namespace Catch{
// The following code snippet based on:
// http://cocoawithlove.com/2008/03/break-into-debugger.html
- #if defined(__ppc64__) || defined(__ppc__)
- #define CATCH_TRAP() \
- __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
- : : : "memory","r0","r3","r4" )
- #else
- #define CATCH_TRAP() __asm__("int $3\n" : : )
+ #ifdef DEBUG
+ #if defined(__ppc64__) || defined(__ppc__)
+ #define CATCH_BREAK_INTO_DEBUGGER() \
+ if( Catch::isDebuggerActive() ) { \
+ __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
+ : : : "memory","r0","r3","r4" ); \
+ }
+ #else
+ #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
+ #endif
#endif
-#elif defined(CATCH_PLATFORM_LINUX)
- // If we can use inline assembler, do it because this allows us to break
- // directly at the location of the failing check instead of breaking inside
- // raise() called from it, i.e. one stack frame below.
- #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
- #define CATCH_TRAP() asm volatile ("int $3")
- #else // Fall back to the generic way.
- #include <signal.h>
-
- #define CATCH_TRAP() raise(SIGTRAP)
- #endif
#elif defined(_MSC_VER)
- #define CATCH_TRAP() __debugbreak()
+ #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); }
#elif defined(__MINGW32__)
extern "C" __declspec(dllimport) void __stdcall DebugBreak();
- #define CATCH_TRAP() DebugBreak()
+ #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); }
#endif
-#ifdef CATCH_TRAP
- #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }
-#else
- #define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
+#ifndef CATCH_BREAK_INTO_DEBUGGER
+#define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
#endif
// #included from: catch_interfaces_runner.h
@@ -2153,41 +2050,6 @@ namespace Catch {
};
}
-#if defined(CATCH_CONFIG_FAST_COMPILE)
-///////////////////////////////////////////////////////////////////////////////
-// We can speedup compilation significantly by breaking into debugger lower in
-// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER
-// macro in each assertion
-#define INTERNAL_CATCH_REACT( resultBuilder ) \
- 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
///////////////////////////////////////////////////////////////////////////////
// In the event of a failure works out if the debugger needs to be invoked
// and/or an exception thrown and takes appropriate action.
@@ -2196,40 +2058,37 @@ namespace Catch {
#define INTERNAL_CATCH_REACT( resultBuilder ) \
if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
resultBuilder.react();
-#endif
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
+#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
( __catchResult <= expr ).endExpression(); \
- CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
} \
catch( ... ) { \
- __catchResult.useActiveException( resultDisposition ); \
+ __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
} \
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 &&.
+ } 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
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
- INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
+#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
+ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
if( Catch::getResultCapture().getLastResult()->succeeded() )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
- INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
+#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
+ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
if( !Catch::getResultCapture().getLastResult()->succeeded() )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
+#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \
- static_cast<void>(expr); \
+ expr; \
__catchResult.captureResult( Catch::ResultWas::Ok ); \
} \
catch( ... ) { \
@@ -2239,12 +2098,12 @@ namespace Catch {
} while( Catch::alwaysFalse() )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
+#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
if( __catchResult.allowThrows() ) \
try { \
- static_cast<void>(expr); \
+ expr; \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \
catch( ... ) { \
@@ -2256,12 +2115,12 @@ namespace Catch {
} while( Catch::alwaysFalse() )
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
+#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
+ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
if( __catchResult.allowThrows() ) \
try { \
- static_cast<void>(expr); \
+ expr; \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \
catch( exceptionType ) { \
@@ -2277,7 +2136,7 @@ namespace Catch {
///////////////////////////////////////////////////////////////////////////////
#ifdef CATCH_CONFIG_VARIADIC_MACROS
- #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
+ #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
__catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \
@@ -2285,7 +2144,7 @@ namespace Catch {
INTERNAL_CATCH_REACT( __catchResult ) \
} while( Catch::alwaysFalse() )
#else
- #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, log ) \
+ #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
__catchResult << log + ::Catch::StreamEndStop(); \
@@ -2295,15 +2154,21 @@ namespace Catch {
#endif
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_INFO( macroName, log ) \
+#define INTERNAL_CATCH_INFO( log, macroName ) \
Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
+#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
try { \
- __catchResult.captureMatch( arg, matcher, #matcher ); \
+ std::string matcherAsString = (matcher).toString(); \
+ __catchResult \
+ .setLhs( Catch::toString( arg ) ) \
+ .setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
+ .setOp( "matches" ) \
+ .setResultType( (matcher).match( arg ) ); \
+ __catchResult.captureExpression(); \
} catch( ... ) { \
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
} \
@@ -2386,8 +2251,6 @@ namespace Catch {
};
}
-#include <string>
-
namespace Catch {
struct SectionInfo {
@@ -2416,19 +2279,14 @@ namespace Catch {
// #included from: catch_timer.h
#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
-#ifdef _MSC_VER
-
-namespace Catch {
- typedef unsigned long long UInt64;
-}
+#ifdef CATCH_PLATFORM_WINDOWS
+typedef unsigned long long uint64_t;
#else
#include <stdint.h>
-namespace Catch {
- typedef uint64_t UInt64;
-}
#endif
namespace Catch {
+
class Timer {
public:
Timer() : m_ticks( 0 ) {}
@@ -2438,7 +2296,7 @@ namespace Catch {
double getElapsedSeconds() const;
private:
- UInt64 m_ticks;
+ uint64_t m_ticks;
};
} // namespace Catch
@@ -2477,6 +2335,7 @@ namespace Catch {
// #included from: internal/catch_generators.hpp
#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
+#include <iterator>
#include <vector>
#include <string>
#include <stdlib.h>
@@ -2590,7 +2449,7 @@ public:
private:
void move( CompositeGenerator& other ) {
- m_composed.insert( m_composed.end(), other.m_composed.begin(), other.m_composed.end() );
+ std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
m_totalSize += other.m_totalSize;
other.m_composed.clear();
}
@@ -2672,15 +2531,12 @@ namespace Catch {
struct IExceptionTranslator;
struct IReporterRegistry;
struct IReporterFactory;
- struct ITagAliasRegistry;
struct IRegistryHub {
virtual ~IRegistryHub();
virtual IReporterRegistry const& getReporterRegistry() const = 0;
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
- virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
-
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
};
@@ -2690,7 +2546,6 @@ namespace Catch {
virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
virtual void registerTest( TestCase const& testInfo ) = 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();
@@ -2766,10 +2621,6 @@ namespace Catch {
#include <cmath>
#include <limits>
-#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
-#include <type_traits>
-#endif
-
namespace Catch {
namespace Detail {
@@ -2777,14 +2628,12 @@ namespace Detail {
public:
explicit Approx ( double value )
: m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
- m_margin( 0.0 ),
m_scale( 1.0 ),
m_value( value )
{}
Approx( Approx const& other )
: m_epsilon( other.m_epsilon ),
- m_margin( other.m_margin ),
m_scale( other.m_scale ),
m_value( other.m_value )
{}
@@ -2793,102 +2642,16 @@ namespace Detail {
return Approx( 0 );
}
-#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
-
- 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.margin( m_margin );
- approx.scale( m_scale );
- return approx;
- }
-
- 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>
- friend bool operator == ( const T& lhs, Approx const& rhs ) {
- // Thanks to Richard Harris for his help refining this formula
- auto lhs_v = double(lhs);
- bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (std::max)(std::fabs(lhs_v), std::fabs(rhs.m_value)));
- if (relativeOK) {
- return true;
- }
- return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator == ( Approx const& lhs, const T& rhs ) {
- return operator==( rhs, lhs );
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator != ( T lhs, Approx const& rhs ) {
- return !operator==( lhs, rhs );
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator != ( Approx const& lhs, T rhs ) {
- return !operator==( rhs, lhs );
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator <= ( T lhs, Approx const& rhs ) {
- return double(lhs) < rhs.m_value || lhs == rhs;
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator <= ( Approx const& lhs, T rhs ) {
- return lhs.m_value < double(rhs) || lhs == rhs;
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator >= ( T lhs, Approx const& rhs ) {
- return double(lhs) > rhs.m_value || lhs == rhs;
- }
-
- template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
- friend bool operator >= ( Approx const& lhs, T 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
-
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 ) {
// 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) ) );
- if (relativeOK) {
- return true;
- }
- return std::fabs(lhs - rhs.m_value) < rhs.m_margin;
+ return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) );
}
friend bool operator == ( Approx const& lhs, double rhs ) {
@@ -2903,37 +2666,15 @@ namespace Detail {
return !operator==( rhs, lhs );
}
- friend bool operator <= ( double lhs, Approx const& rhs ) {
- return lhs < rhs.m_value || lhs == rhs;
- }
-
- friend bool operator <= ( Approx const& lhs, double rhs ) {
- return lhs.m_value < rhs || lhs == rhs;
- }
-
- friend bool operator >= ( double lhs, Approx const& rhs ) {
- return lhs > rhs.m_value || lhs == rhs;
- }
-
- friend bool operator >= ( Approx const& lhs, double rhs ) {
- return lhs.m_value > rhs || lhs == rhs;
- }
-
Approx& epsilon( double newEpsilon ) {
m_epsilon = newEpsilon;
return *this;
}
- Approx& margin( double newMargin ) {
- m_margin = newMargin;
- return *this;
- }
-
Approx& scale( double newScale ) {
m_scale = newScale;
return *this;
}
-#endif
std::string toString() const {
std::ostringstream oss;
@@ -2943,7 +2684,6 @@ namespace Detail {
private:
double m_epsilon;
- double m_margin;
double m_scale;
double m_value;
};
@@ -2956,153 +2696,6 @@ inline std::string toString<Detail::Approx>( Detail::Approx const& value ) {
} // end namespace Catch
-// #included from: internal/catch_matchers_string.h
-#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED
-
-namespace Catch {
-namespace Matchers {
-
- namespace StdString {
-
- struct CasedString
- {
- CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity );
- std::string adjustString( std::string const& str ) const;
- std::string caseSensitivitySuffix() const;
-
- CaseSensitive::Choice m_caseSensitivity;
- std::string m_str;
- };
-
- struct StringMatcherBase : MatcherBase<std::string> {
- StringMatcherBase( std::string const& operation, CasedString const& comparator );
- virtual std::string describe() const CATCH_OVERRIDE;
-
- CasedString m_comparator;
- std::string m_operation;
- };
-
- struct EqualsMatcher : StringMatcherBase {
- EqualsMatcher( CasedString const& comparator );
- virtual bool match( std::string const& source ) const CATCH_OVERRIDE;
- };
- struct ContainsMatcher : StringMatcherBase {
- ContainsMatcher( CasedString const& comparator );
- virtual bool match( std::string const& source ) const CATCH_OVERRIDE;
- };
- struct StartsWithMatcher : StringMatcherBase {
- StartsWithMatcher( CasedString const& comparator );
- virtual bool match( std::string const& source ) const CATCH_OVERRIDE;
- };
- struct EndsWithMatcher : StringMatcherBase {
- EndsWithMatcher( CasedString const& comparator );
- virtual bool match( std::string const& source ) const CATCH_OVERRIDE;
- };
-
- } // namespace StdString
-
- // The following functions create the actual matcher objects.
- // This allows the types to be inferred
-
- StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
- StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
- StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
- StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
-
-} // namespace Matchers
-} // namespace Catch
-
-// #included from: internal/catch_matchers_vector.h
-#define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED
-
-namespace Catch {
-namespace Matchers {
-
- namespace Vector {
-
- template<typename T>
- struct ContainsElementMatcher : MatcherBase<std::vector<T>, T> {
-
- ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}
-
- bool match(std::vector<T> const &v) const CATCH_OVERRIDE {
- return std::find(v.begin(), v.end(), m_comparator) != v.end();
- }
-
- virtual std::string describe() const CATCH_OVERRIDE {
- return "Contains: " + Catch::toString( m_comparator );
- }
-
- T const& m_comparator;
- };
-
- template<typename T>
- struct ContainsMatcher : MatcherBase<std::vector<T>, std::vector<T> > {
-
- ContainsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}
-
- bool match(std::vector<T> const &v) const CATCH_OVERRIDE {
- // !TBD: see note in EqualsMatcher
- if (m_comparator.size() > v.size())
- return false;
- for (size_t i = 0; i < m_comparator.size(); ++i)
- if (std::find(v.begin(), v.end(), m_comparator[i]) == v.end())
- return false;
- return true;
- }
- virtual std::string describe() const CATCH_OVERRIDE {
- return "Contains: " + Catch::toString( m_comparator );
- }
-
- std::vector<T> const& m_comparator;
- };
-
- template<typename T>
- struct EqualsMatcher : MatcherBase<std::vector<T>, std::vector<T> > {
-
- EqualsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}
-
- bool match(std::vector<T> const &v) const CATCH_OVERRIDE {
- // !TBD: This currently works if all elements can be compared using !=
- // - a more general approach would be via a compare template that defaults
- // to using !=. but could be specialised for, e.g. std::vector<T> etc
- // - then just call that directly
- if (m_comparator.size() != v.size())
- return false;
- for (size_t i = 0; i < v.size(); ++i)
- if (m_comparator[i] != v[i])
- return false;
- return true;
- }
- virtual std::string describe() const CATCH_OVERRIDE {
- return "Equals: " + Catch::toString( m_comparator );
- }
- std::vector<T> const& m_comparator;
- };
-
- } // namespace Vector
-
- // The following functions create the actual matcher objects.
- // This allows the types to be inferred
-
- template<typename T>
- Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparator ) {
- return Vector::ContainsMatcher<T>( comparator );
- }
-
- template<typename T>
- Vector::ContainsElementMatcher<T> VectorContains( T const& comparator ) {
- return Vector::ContainsElementMatcher<T>( comparator );
- }
-
- template<typename T>
- Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {
- return Vector::EqualsMatcher<T>( comparator );
- }
-
-} // namespace Matchers
-} // namespace Catch
-
// #included from: internal/catch_interfaces_tag_alias_registry.h
#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED
@@ -3114,7 +2707,7 @@ namespace Matchers {
namespace Catch {
struct TagAlias {
- TagAlias( std::string const& _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
+ TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
std::string tag;
SourceLineInfo lineInfo;
@@ -3186,18 +2779,8 @@ namespace Catch {
}
private:
- T *nullableValue;
- union {
- 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
- };
+ T* nullableValue;
+ char storage[sizeof(T)];
};
} // end namespace Catch
@@ -3237,8 +2820,7 @@ namespace Catch {
IsHidden = 1 << 1,
ShouldFail = 1 << 2,
MayFail = 1 << 3,
- Throws = 1 << 4,
- NonPortable = 1 << 5
+ Throws = 1 << 4
};
TestCaseInfo( std::string const& _name,
@@ -3396,67 +2978,64 @@ namespace Catch {
namespace Impl {
namespace NSStringMatchers {
- struct StringHolder : MatcherBase<NSString*>{
+ template<typename MatcherT>
+ struct StringHolder : MatcherImpl<MatcherT, NSString*>{
StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
StringHolder() {
arcSafeRelease( m_substr );
}
- virtual bool match( NSString* arg ) const CATCH_OVERRIDE {
- return false;
- }
-
NSString* m_substr;
};
- struct Equals : StringHolder {
+ struct Equals : StringHolder<Equals> {
Equals( NSString* substr ) : StringHolder( substr ){}
- virtual bool match( NSString* str ) const CATCH_OVERRIDE {
+ virtual bool match( ExpressionType const& str ) const {
return (str != nil || m_substr == nil ) &&
[str isEqualToString:m_substr];
}
- virtual std::string describe() const CATCH_OVERRIDE {
+ virtual std::string toString() const {
return "equals string: " + Catch::toString( m_substr );
}
};
- struct Contains : StringHolder {
+ struct Contains : StringHolder<Contains> {
Contains( NSString* substr ) : StringHolder( substr ){}
- virtual bool match( NSString* str ) const {
+ virtual bool match( ExpressionType const& str ) const {
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location != NSNotFound;
}
- virtual std::string describe() const CATCH_OVERRIDE {
+ virtual std::string toString() const {
return "contains string: " + Catch::toString( m_substr );
}
};
- struct StartsWith : StringHolder {
+ struct StartsWith : StringHolder<StartsWith> {
StartsWith( NSString* substr ) : StringHolder( substr ){}
- virtual bool match( NSString* str ) const {
+ virtual bool match( ExpressionType const& str ) const {
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == 0;
}
- virtual std::string describe() const CATCH_OVERRIDE {
+ virtual std::string toString() const {
return "starts with: " + Catch::toString( m_substr );
}
};
- struct EndsWith : StringHolder {
+ struct EndsWith : StringHolder<EndsWith> {
EndsWith( NSString* substr ) : StringHolder( substr ){}
- virtual bool match( NSString* str ) const {
+ virtual bool match( ExpressionType const& str ) const {
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == [str length] - [m_substr length];
}
- virtual std::string describe() const CATCH_OVERRIDE {
+ virtual std::string toString() const {
return "ends with: " + Catch::toString( m_substr );
}
};
@@ -3497,29 +3076,6 @@ return @ desc; \
#endif
#ifdef CATCH_IMPL
-
-// !TBD: Move the leak detector code into a separate header
-#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
-#include <crtdbg.h>
-class LeakDetector {
-public:
- LeakDetector() {
- int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
- flag |= _CRTDBG_LEAK_CHECK_DF;
- flag |= _CRTDBG_ALLOC_MEM_DF;
- _CrtSetDbgFlag(flag);
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- // Change this to leaking allocation's number to break there
- _CrtSetBreakAlloc(-1);
- }
-};
-#else
-class LeakDetector {};
-#endif
-
-LeakDetector leakDetector;
-
// #included from: internal/catch_impl.hpp
#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
@@ -3559,8 +3115,6 @@ LeakDetector leakDetector;
// #included from: catch_wildcard_pattern.hpp
#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
-#include <stdexcept>
-
namespace Catch
{
class WildcardPattern {
@@ -3578,11 +3132,11 @@ namespace Catch
m_wildcard( NoWildcard ),
m_pattern( adjustCase( pattern ) )
{
- if( startsWith( m_pattern, '*' ) ) {
+ if( startsWith( m_pattern, "*" ) ) {
m_pattern = m_pattern.substr( 1 );
m_wildcard = WildcardAtStart;
}
- if( endsWith( m_pattern, '*' ) ) {
+ if( endsWith( m_pattern, "*" ) ) {
m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
}
@@ -3667,11 +3221,10 @@ namespace Catch {
bool matches( TestCaseInfo const& testCase ) const {
// All patterns in a filter must match for the filter to be a match
- for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) {
+ for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
if( !(*it)->matches( testCase ) )
return false;
- }
- return true;
+ return true;
}
};
@@ -3701,12 +3254,11 @@ namespace Catch {
namespace Catch {
class TestSpecParser {
- enum Mode{ None, Name, QuotedName, Tag, EscapedName };
+ enum Mode{ None, Name, QuotedName, Tag };
Mode m_mode;
bool m_exclusion;
std::size_t m_start, m_pos;
std::string m_arg;
- std::vector<std::size_t> m_escapeChars;
TestSpec::Filter m_currentFilter;
TestSpec m_testSpec;
ITagAliasRegistry const* m_tagAliases;
@@ -3719,7 +3271,6 @@ namespace Catch {
m_exclusion = false;
m_start = std::string::npos;
m_arg = m_tagAliases->expandAliases( arg );
- m_escapeChars.clear();
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
visitChar( m_arg[m_pos] );
if( m_mode == Name )
@@ -3738,7 +3289,6 @@ namespace Catch {
case '~': m_exclusion = true; return;
case '[': return startNewMode( Tag, ++m_pos );
case '"': return startNewMode( QuotedName, ++m_pos );
- case '\\': return escape();
default: startNewMode( Name, m_pos ); break;
}
}
@@ -3754,11 +3304,7 @@ namespace Catch {
addPattern<TestSpec::NamePattern>();
startNewMode( Tag, ++m_pos );
}
- else if( c == '\\' )
- escape();
}
- else if( m_mode == EscapedName )
- m_mode = Name;
else if( m_mode == QuotedName && c == '"' )
addPattern<TestSpec::NamePattern>();
else if( m_mode == Tag && c == ']' )
@@ -3768,19 +3314,10 @@ namespace Catch {
m_mode = mode;
m_start = start;
}
- void escape() {
- if( m_mode == None )
- m_start = m_pos;
- m_mode = EscapedName;
- m_escapeChars.push_back( m_pos );
- }
std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
template<typename T>
void addPattern() {
std::string token = subString();
- for( size_t i = 0; i < m_escapeChars.size(); ++i )
- token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 );
- m_escapeChars.clear();
if( startsWith( token, "exclude:" ) ) {
m_exclusion = true;
token = token.substr( 8 );
@@ -3814,7 +3351,7 @@ namespace Catch {
// #included from: catch_interfaces_config.h
#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
-#include <iosfwd>
+#include <iostream>
#include <string>
#include <vector>
@@ -3866,8 +3403,6 @@ namespace Catch {
virtual RunTests::InWhatOrder runOrder() const = 0;
virtual unsigned int rngSeed() const = 0;
virtual UseColour::YesOrNo useColour() const = 0;
- virtual std::vector<std::string> const& getSectionsToRun() const = 0;
-
};
}
@@ -3890,7 +3425,6 @@ namespace Catch {
#include <streambuf>
#include <ostream>
#include <fstream>
-#include <memory>
namespace Catch {
@@ -3922,7 +3456,7 @@ namespace Catch {
};
class DebugOutStream : public IStream {
- CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
+ std::auto_ptr<StreamBufBase> m_streamBuf;
mutable std::ostream m_os;
public:
DebugOutStream();
@@ -3936,7 +3470,8 @@ namespace Catch {
#include <memory>
#include <vector>
#include <string>
-#include <stdexcept>
+#include <iostream>
+#include <ctime>
#ifndef CATCH_CONFIG_CONSOLE_WIDTH
#define CATCH_CONFIG_CONSOLE_WIDTH 80
@@ -3951,7 +3486,6 @@ namespace Catch {
listTags( false ),
listReporters( false ),
listTestNamesOnly( false ),
- listExtraInfo( false ),
showSuccessfulTests( false ),
shouldDebugBreak( false ),
noThrow( false ),
@@ -3971,7 +3505,6 @@ namespace Catch {
bool listTags;
bool listReporters;
bool listTestNamesOnly;
- bool listExtraInfo;
bool showSuccessfulTests;
bool shouldDebugBreak;
@@ -3995,7 +3528,6 @@ namespace Catch {
std::vector<std::string> reporterNames;
std::vector<std::string> testsOrTags;
- std::vector<std::string> sectionsToRun;
};
class Config : public SharedImpl<IConfig> {
@@ -4020,7 +3552,8 @@ namespace Catch {
}
}
- virtual ~Config() {}
+ virtual ~Config() {
+ }
std::string const& getFilename() const {
return m_data.outputFilename ;
@@ -4030,30 +3563,30 @@ namespace Catch {
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
bool listTags() const { return m_data.listTags; }
bool listReporters() const { return m_data.listReporters; }
- bool listExtraInfo() const { return m_data.listExtraInfo; }
std::string getProcessName() const { return m_data.processName; }
- std::vector<std::string> const& getReporterNames() const { return m_data.reporterNames; }
- std::vector<std::string> const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; }
+ bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
- virtual TestSpec const& testSpec() const CATCH_OVERRIDE { return m_testSpec; }
+ std::vector<std::string> getReporterNames() const { return m_data.reporterNames; }
+
+ int abortAfter() const { return m_data.abortAfter; }
+
+ TestSpec const& testSpec() const { return m_testSpec; }
bool showHelp() const { return m_data.showHelp; }
+ bool showInvisibles() const { return m_data.showInvisibles; }
// IConfig interface
- virtual bool allowThrows() const CATCH_OVERRIDE { return !m_data.noThrow; }
- virtual std::ostream& stream() const CATCH_OVERRIDE { return m_stream->stream(); }
- virtual std::string name() const CATCH_OVERRIDE { return m_data.name.empty() ? m_data.processName : m_data.name; }
- virtual bool includeSuccessfulResults() const CATCH_OVERRIDE { return m_data.showSuccessfulTests; }
- virtual bool warnAboutMissingAssertions() const CATCH_OVERRIDE { return m_data.warnings & WarnAbout::NoAssertions; }
- virtual ShowDurations::OrNot showDurations() const CATCH_OVERRIDE { return m_data.showDurations; }
- virtual RunTests::InWhatOrder runOrder() const CATCH_OVERRIDE { return m_data.runOrder; }
- virtual unsigned int rngSeed() const CATCH_OVERRIDE { return m_data.rngSeed; }
- virtual UseColour::YesOrNo useColour() const CATCH_OVERRIDE { return m_data.useColour; }
- virtual bool shouldDebugBreak() const CATCH_OVERRIDE { return m_data.shouldDebugBreak; }
- virtual int abortAfter() const CATCH_OVERRIDE { return m_data.abortAfter; }
- virtual bool showInvisibles() const CATCH_OVERRIDE { return m_data.showInvisibles; }
+ virtual bool allowThrows() const { return !m_data.noThrow; }
+ virtual std::ostream& stream() const { return m_stream->stream(); }
+ virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
+ virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
+ virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; }
+ virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
+ virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; }
+ virtual unsigned int rngSeed() const { return m_data.rngSeed; }
+ virtual UseColour::YesOrNo useColour() const { return m_data.useColour; }
private:
@@ -4071,7 +3604,7 @@ namespace Catch {
}
ConfigData m_data;
- CATCH_AUTO_PTR( IStream const ) m_stream;
+ std::auto_ptr<IStream const> m_stream;
TestSpec m_testSpec;
};
@@ -4091,7 +3624,7 @@ namespace Catch {
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
// #included from: ../external/clara.h
-// Version 0.0.2.4
+// Version 0.0.2.3
// Only use header guard if we are not using an outer namespace
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
@@ -4118,7 +3651,6 @@ namespace Catch {
#include <vector>
#include <sstream>
#include <algorithm>
-#include <cctype>
// Use optional outer namespace
#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
@@ -4460,12 +3992,9 @@ namespace Clara {
inline void convertInto( std::string const& _source, std::string& _dest ) {
_dest = _source;
}
- char toLowerCh(char c) {
- return static_cast<char>( std::tolower( c ) );
- }
inline void convertInto( std::string const& _source, bool& _dest ) {
std::string sourceLC = _source;
- std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), toLowerCh );
+ std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
_dest = true;
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
@@ -4615,13 +4144,12 @@ namespace Clara {
}
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];
if( c == '"' )
inQuotes = !inQuotes;
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 ) {
switch( mode ) {
@@ -4654,9 +4182,8 @@ namespace Clara {
default: from = i; return ShortOpt;
}
}
-
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( " \t:=\0", 5 ).find( c ) == std::string::npos )
return mode;
std::string optName = arg.substr( from, i-from );
@@ -4670,7 +4197,7 @@ namespace Clara {
return None;
}
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
- if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos )
+ if( inQuotes || std::string( " \t\0", 3 ).find( c ) == std::string::npos )
return mode;
std::string data = arg.substr( from, i-from );
@@ -4986,7 +4513,7 @@ namespace Clara {
}
std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
- std::string processName = args.empty() ? std::string() : args[0];
+ std::string processName = args[0];
std::size_t lastSlash = processName.find_last_of( "/\\" );
if( lastSlash != std::string::npos )
processName = processName.substr( lastSlash+1 );
@@ -5118,7 +4645,6 @@ STITCH_CLARA_CLOSE_NAMESPACE
#endif
#include <fstream>
-#include <ctime>
namespace Catch {
@@ -5129,14 +4655,13 @@ namespace Catch {
config.abortAfter = x;
}
inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }
- inline void addSectionToRun( ConfigData& config, std::string const& sectionName ) { config.sectionsToRun.push_back( sectionName ); }
inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); }
inline void addWarning( ConfigData& config, std::string const& _warning ) {
if( _warning == "NoAssertions" )
config.warnings = static_cast<WarnAbout::What>( config.warnings | WarnAbout::NoAssertions );
else
- throw std::runtime_error( "Unrecognised warning: '" + _warning + '\'' );
+ throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
}
inline void setOrder( ConfigData& config, std::string const& order ) {
if( startsWith( "declared", order ) )
@@ -5146,7 +4671,7 @@ namespace Catch {
else if( startsWith( "random", order ) )
config.runOrder = RunTests::InRandomOrder;
else
- throw std::runtime_error( "Unrecognised ordering: '" + order + '\'' );
+ throw std::runtime_error( "Unrecognised ordering: '" + order + "'" );
}
inline void setRngSeed( ConfigData& config, std::string const& seed ) {
if( seed == "time" ) {
@@ -5157,7 +4682,7 @@ namespace Catch {
ss << seed;
ss >> config.rngSeed;
if( ss.fail() )
- throw std::runtime_error( "Argument to --rng-seed should be the word 'time' or a number" );
+ throw std::runtime_error( "Argment to --rng-seed should be the word 'time' or a number" );
}
}
inline void setVerbosity( ConfigData& config, int level ) {
@@ -5192,11 +4717,8 @@ namespace Catch {
std::string line;
while( std::getline( f, line ) ) {
line = trim(line);
- if( !line.empty() && !startsWith( line, '#' ) ) {
- if( !startsWith( line, '"' ) )
- line = '"' + line + '"';
- addTestOrTags( config, line + ',' );
- }
+ if( !line.empty() && !startsWith( line, "#" ) )
+ addTestOrTags( config, "\"" + line + "\"," );
}
}
@@ -5283,19 +4805,11 @@ namespace Catch {
.describe( "adds a tag for the filename" )
.bind( &ConfigData::filenamesAsTags );
- cli["-c"]["--section"]
- .describe( "specify section to run" )
- .bind( &addSectionToRun, "section name" );
-
// Less common commands which don't have a short form
cli["--list-test-names-only"]
.describe( "list all/matching test cases names only" )
.bind( &ConfigData::listTestNamesOnly );
- cli["--list-extra-info"]
- .describe( "list all/matching test cases with more info" )
- .bind( &ConfigData::listExtraInfo );
-
cli["--list-reporters"]
.describe( "list all reporters" )
.bind( &ConfigData::listReporters );
@@ -5363,16 +4877,19 @@ namespace Tbc {
TextAttributes()
: initialIndent( std::string::npos ),
indent( 0 ),
- width( consoleWidth-1 )
+ width( consoleWidth-1 ),
+ tabChar( '\t' )
{}
TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
+ TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
std::size_t initialIndent; // indent of first line, or npos
std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
std::size_t width; // maximum width of text, including indent. Longer text will wrap
+ char tabChar; // If this char is seen the indent is changed to current pos
};
class Text {
@@ -5380,78 +4897,64 @@ namespace Tbc {
Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
: attr( _attr )
{
- const std::string wrappableBeforeChars = "[({<\t";
- const std::string wrappableAfterChars = "])}>-,./|\\";
- const std::string wrappableInsteadOfChars = " \n\r";
- std::string indent = _attr.initialIndent != std::string::npos
- ? std::string( _attr.initialIndent, ' ' )
- : std::string( _attr.indent, ' ' );
-
- typedef std::string::const_iterator iterator;
- iterator it = _str.begin();
- const iterator strEnd = _str.end();
-
- while( it != strEnd ) {
+ std::string wrappableChars = " [({.,/|\\-";
+ std::size_t indent = _attr.initialIndent != std::string::npos
+ ? _attr.initialIndent
+ : _attr.indent;
+ std::string remainder = _str;
+ while( !remainder.empty() ) {
if( lines.size() >= 1000 ) {
lines.push_back( "... message truncated due to excessive size" );
return;
}
+ std::size_t tabPos = std::string::npos;
+ std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
+ std::size_t pos = remainder.find_first_of( '\n' );
+ if( pos <= width ) {
+ width = pos;
+ }
+ pos = remainder.find_last_of( _attr.tabChar, width );
+ if( pos != std::string::npos ) {
+ tabPos = pos;
+ if( remainder[width] == '\n' )
+ width--;
+ remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
+ }
- std::string suffix;
- std::size_t width = (std::min)( static_cast<size_t>( strEnd-it ), _attr.width-static_cast<size_t>( indent.size() ) );
- iterator itEnd = it+width;
- iterator itNext = _str.end();
-
- iterator itNewLine = std::find( it, itEnd, '\n' );
- if( itNewLine != itEnd )
- itEnd = itNewLine;
-
- if( itEnd != strEnd ) {
- bool foundWrapPoint = false;
- iterator findIt = itEnd;
- do {
- if( wrappableAfterChars.find( *findIt ) != std::string::npos && findIt != itEnd ) {
- itEnd = findIt+1;
- itNext = findIt+1;
- foundWrapPoint = true;
- }
- else if( findIt > it && wrappableBeforeChars.find( *findIt ) != std::string::npos ) {
- itEnd = findIt;
- itNext = findIt;
- foundWrapPoint = true;
- }
- else if( wrappableInsteadOfChars.find( *findIt ) != std::string::npos ) {
- itNext = findIt+1;
- itEnd = findIt;
- foundWrapPoint = true;
- }
- if( findIt == it )
- break;
- else
- --findIt;
- }
- while( !foundWrapPoint );
-
- if( !foundWrapPoint ) {
- // No good wrap char, so we'll break mid word and add a hyphen
- --itEnd;
- itNext = itEnd;
- suffix = "-";
+ if( width == remainder.size() ) {
+ spliceLine( indent, remainder, width );
+ }
+ else if( remainder[width] == '\n' ) {
+ spliceLine( indent, remainder, width );
+ if( width <= 1 || remainder.size() != 1 )
+ remainder = remainder.substr( 1 );
+ indent = _attr.indent;
+ }
+ else {
+ pos = remainder.find_last_of( wrappableChars, width );
+ if( pos != std::string::npos && pos > 0 ) {
+ spliceLine( indent, remainder, pos );
+ if( remainder[0] == ' ' )
+ remainder = remainder.substr( 1 );
}
else {
- while( itEnd > it && wrappableInsteadOfChars.find( *(itEnd-1) ) != std::string::npos )
- --itEnd;
+ spliceLine( indent, remainder, width-1 );
+ lines.back() += "-";
}
+ if( lines.size() == 1 )
+ indent = _attr.indent;
+ if( tabPos != std::string::npos )
+ indent += tabPos;
}
- lines.push_back( indent + std::string( it, itEnd ) + suffix );
-
- if( indent.size() != _attr.indent )
- indent = std::string( _attr.indent, ' ' );
- it = itNext;
}
}
+ void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
+ lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
+ _remainder = _remainder.substr( _pos );
+ }
+
typedef std::vector<std::string>::const_iterator const_iterator;
const_iterator begin() const { return lines.begin(); }
@@ -5558,6 +5061,7 @@ namespace Catch {
#include <string>
#include <ostream>
#include <map>
+#include <assert.h>
namespace Catch
{
@@ -5824,9 +5328,8 @@ namespace Catch {
}
std::size_t matchedTests = 0;
- TextAttributes nameAttr, descAttr, tagsAttr;
+ TextAttributes nameAttr, tagsAttr;
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
- descAttr.setIndent( 4 );
tagsAttr.setIndent( 6 );
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
@@ -5841,21 +5344,14 @@ namespace Catch {
Colour colourGuard( colour );
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
- if( config.listExtraInfo() ) {
- Catch::cout() << " " << testCaseInfo.lineInfo << std::endl;
- std::string description = testCaseInfo.description;
- if( description.empty() )
- description = "(NO DESCRIPTION)";
- Catch::cout() << Text( description, descAttr ) << std::endl;
- }
if( !testCaseInfo.tags.empty() )
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
}
if( !config.testSpec().hasFilters() )
- Catch::cout() << pluralise( matchedTests, "test case" ) << '\n' << std::endl;
+ Catch::cout() << pluralise( matchedTests, "test case" ) << "\n" << std::endl;
else
- Catch::cout() << pluralise( matchedTests, "matching test case" ) << '\n' << std::endl;
+ Catch::cout() << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl;
return matchedTests;
}
@@ -5870,13 +5366,7 @@ namespace Catch {
++it ) {
matchedTests++;
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
- if( startsWith( testCaseInfo.name, '#' ) )
- Catch::cout() << '"' << testCaseInfo.name << '"';
- else
- Catch::cout() << testCaseInfo.name;
- if ( config.listExtraInfo() )
- Catch::cout() << "\t@" << testCaseInfo.lineInfo;
- Catch::cout() << std::endl;
+ Catch::cout() << testCaseInfo.name << std::endl;
}
return matchedTests;
}
@@ -5937,9 +5427,9 @@ namespace Catch {
.setInitialIndent( 0 )
.setIndent( oss.str().size() )
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
- Catch::cout() << oss.str() << wrapper << '\n';
+ Catch::cout() << oss.str() << wrapper << "\n";
}
- Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl;
+ Catch::cout() << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl;
return tagCounts.size();
}
@@ -5958,9 +5448,9 @@ namespace Catch {
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
Catch::cout() << " "
<< it->first
- << ':'
+ << ":"
<< std::string( maxNameLen - it->first.size() + 2, ' ' )
- << wrapper << '\n';
+ << wrapper << "\n";
}
Catch::cout() << std::endl;
return factories.size();
@@ -5968,7 +5458,7 @@ namespace Catch {
inline Option<std::size_t> list( Config const& config ) {
Option<std::size_t> listedCount;
- if( config.listTests() || ( config.listExtraInfo() && !config.listTestNamesOnly() ) )
+ if( config.listTests() )
listedCount = listedCount.valueOr(0) + listTests( config );
if( config.listTestNamesOnly() )
listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
@@ -5987,32 +5477,19 @@ namespace Catch {
// #included from: catch_test_case_tracker.hpp
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
-#include <algorithm>
+#include <map>
#include <string>
#include <assert.h>
#include <vector>
-#include <stdexcept>
-
-CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
namespace Catch {
namespace TestCaseTracking {
- struct NameAndLocation {
- std::string name;
- SourceLineInfo location;
-
- NameAndLocation( std::string const& _name, SourceLineInfo const& _location )
- : name( _name ),
- location( _location )
- {}
- };
-
struct ITracker : SharedImpl<> {
virtual ~ITracker();
// static queries
- virtual NameAndLocation const& nameAndLocation() const = 0;
+ virtual std::string name() const = 0;
// dynamic queries
virtual bool isComplete() const = 0; // Successfully completed or failed
@@ -6028,7 +5505,7 @@ namespace TestCaseTracking {
virtual void markAsNeedingAnotherRun() = 0;
virtual void addChild( Ptr<ITracker> const& child ) = 0;
- virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) = 0;
+ virtual ITracker* findChild( std::string const& name ) = 0;
virtual void openChild() = 0;
// Debug/ checking
@@ -6036,7 +5513,7 @@ namespace TestCaseTracking {
virtual bool isIndexTracker() const = 0;
};
- class TrackerContext {
+ class TrackerContext {
enum RunState {
NotStarted,
@@ -6098,32 +5575,30 @@ namespace TestCaseTracking {
Failed
};
class TrackerHasName {
- NameAndLocation m_nameAndLocation;
+ std::string m_name;
public:
- TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {}
+ TrackerHasName( std::string const& name ) : m_name( name ) {}
bool operator ()( Ptr<ITracker> const& tracker ) {
- return
- tracker->nameAndLocation().name == m_nameAndLocation.name &&
- tracker->nameAndLocation().location == m_nameAndLocation.location;
+ return tracker->name() == m_name;
}
};
typedef std::vector<Ptr<ITracker> > Children;
- NameAndLocation m_nameAndLocation;
+ std::string m_name;
TrackerContext& m_ctx;
ITracker* m_parent;
Children m_children;
CycleState m_runState;
public:
- TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
- : m_nameAndLocation( nameAndLocation ),
+ TrackerBase( std::string const& name, TrackerContext& ctx, ITracker* parent )
+ : m_name( name ),
m_ctx( ctx ),
m_parent( parent ),
m_runState( NotStarted )
{}
virtual ~TrackerBase();
- virtual NameAndLocation const& nameAndLocation() const CATCH_OVERRIDE {
- return m_nameAndLocation;
+ virtual std::string name() const CATCH_OVERRIDE {
+ return m_name;
}
virtual bool isComplete() const CATCH_OVERRIDE {
return m_runState == CompletedSuccessfully || m_runState == Failed;
@@ -6142,8 +5617,8 @@ namespace TestCaseTracking {
m_children.push_back( child );
}
- virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) CATCH_OVERRIDE {
- Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) );
+ virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
+ Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
return( it != m_children.end() )
? it->get()
: CATCH_NULL;
@@ -6221,56 +5696,32 @@ namespace TestCaseTracking {
};
class SectionTracker : public TrackerBase {
- std::vector<std::string> m_filters;
public:
- SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
- : TrackerBase( nameAndLocation, ctx, parent )
- {
- if( parent ) {
- while( !parent->isSectionTracker() )
- parent = &parent->parent();
-
- SectionTracker& parentSection = static_cast<SectionTracker&>( *parent );
- addNextFilters( parentSection.m_filters );
- }
- }
+ SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
+ : TrackerBase( name, ctx, parent )
+ {}
virtual ~SectionTracker();
virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
- static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) {
+ static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
SectionTracker* section = CATCH_NULL;
ITracker& currentTracker = ctx.currentTracker();
- if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) {
+ if( ITracker* childTracker = currentTracker.findChild( name ) ) {
assert( childTracker );
assert( childTracker->isSectionTracker() );
section = static_cast<SectionTracker*>( childTracker );
}
else {
- section = new SectionTracker( nameAndLocation, ctx, &currentTracker );
+ section = new SectionTracker( name, ctx, &currentTracker );
currentTracker.addChild( section );
}
- if( !ctx.completedCycle() )
- section->tryOpen();
- return *section;
- }
-
- void tryOpen() {
- if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) )
- open();
- }
+ if( !ctx.completedCycle() && !section->isComplete() ) {
- void addInitialFilters( std::vector<std::string> const& filters ) {
- if( !filters.empty() ) {
- m_filters.push_back(""); // Root - should never be consulted
- m_filters.push_back(""); // Test Case - not a section filter
- m_filters.insert( m_filters.end(), filters.begin(), filters.end() );
+ section->open();
}
- }
- void addNextFilters( std::vector<std::string> const& filters ) {
- if( filters.size() > 1 )
- m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() );
+ return *section;
}
};
@@ -6278,8 +5729,8 @@ namespace TestCaseTracking {
int m_size;
int m_index;
public:
- IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size )
- : TrackerBase( nameAndLocation, ctx, parent ),
+ IndexTracker( std::string const& name, TrackerContext& ctx, ITracker* parent, int size )
+ : TrackerBase( name, ctx, parent ),
m_size( size ),
m_index( -1 )
{}
@@ -6287,17 +5738,17 @@ namespace TestCaseTracking {
virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
- static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) {
+ static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
IndexTracker* tracker = CATCH_NULL;
ITracker& currentTracker = ctx.currentTracker();
- if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) {
+ if( ITracker* childTracker = currentTracker.findChild( name ) ) {
assert( childTracker );
assert( childTracker->isIndexTracker() );
tracker = static_cast<IndexTracker*>( childTracker );
}
else {
- tracker = new IndexTracker( nameAndLocation, ctx, &currentTracker, size );
+ tracker = new IndexTracker( name, ctx, &currentTracker, size );
currentTracker.addChild( tracker );
}
@@ -6325,7 +5776,7 @@ namespace TestCaseTracking {
};
inline ITracker& TrackerContext::startRun() {
- m_rootTracker = new SectionTracker( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, CATCH_NULL );
+ m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
m_currentTracker = CATCH_NULL;
m_runState = Executing;
return *m_rootTracker;
@@ -6340,144 +5791,40 @@ using TestCaseTracking::IndexTracker;
} // namespace Catch
-CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
// #included from: catch_fatal_condition.hpp
#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
namespace Catch {
- // Report the error condition
- inline void reportFatal( std::string const& message ) {
+ // Report the error condition then exit the process
+ inline void fatal( std::string const& message, int exitCode ) {
IContext& context = Catch::getCurrentContext();
IResultCapture* resultCapture = context.getResultCapture();
resultCapture->handleFatalErrorCondition( message );
+
+ if( Catch::alwaysTrue() ) // avoids "no return" warnings
+ exit( exitCode );
}
} // namespace Catch
#if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////
-// #included from: catch_windows_h_proxy.h
-
-#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED
-
-#ifdef CATCH_DEFINES_NOMINMAX
-# define NOMINMAX
-#endif
-#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-
-#ifdef __AFXDLL
-#include <AfxWin.h>
-#else
-#include <windows.h>
-#endif
-
-#ifdef CATCH_DEFINES_NOMINMAX
-# undef NOMINMAX
-#endif
-#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
-# undef WIN32_LEAN_AND_MEAN
-#endif
-
-
-# if !defined ( CATCH_CONFIG_WINDOWS_SEH )
namespace Catch {
- struct FatalConditionHandler {
- void reset() {}
- };
-}
-
-# else // CATCH_CONFIG_WINDOWS_SEH is defined
-
-namespace Catch {
-
- struct SignalDefs { DWORD id; const char* name; };
- extern SignalDefs signalDefs[];
- // There is no 1-1 mapping between signals and windows exceptions.
- // Windows can easily distinguish between SO and SigSegV,
- // but SigInt, SigTerm, etc are handled differently.
- SignalDefs signalDefs[] = {
- { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" },
- { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" },
- { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" },
- { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" },
- };
struct FatalConditionHandler {
-
- static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
- for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
- reportFatal(signalDefs[i].name);
- }
- }
- // If its not an exception we care about, pass it along.
- // This stops us from eating debugger breaks etc.
- return EXCEPTION_CONTINUE_SEARCH;
- }
-
- FatalConditionHandler() {
- isSet = true;
- // 32k seems enough for Catch to handle stack overflow,
- // but the value was found experimentally, so there is no strong guarantee
- guaranteeSize = 32 * 1024;
- exceptionHandlerHandle = CATCH_NULL;
- // Register as first handler in current chain
- exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
- // Pass in guarantee size to be filled
- SetThreadStackGuarantee(&guaranteeSize);
- }
-
- static void reset() {
- if (isSet) {
- // Unregister handler and restore the old guarantee
- RemoveVectoredExceptionHandler(exceptionHandlerHandle);
- SetThreadStackGuarantee(&guaranteeSize);
- exceptionHandlerHandle = CATCH_NULL;
- isSet = false;
- }
- }
-
- ~FatalConditionHandler() {
- reset();
- }
- private:
- static bool isSet;
- static ULONG guaranteeSize;
- static PVOID exceptionHandlerHandle;
- };
-
- bool FatalConditionHandler::isSet = false;
- ULONG FatalConditionHandler::guaranteeSize = 0;
- PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL;
+ void reset() {}
+ };
} // namespace Catch
-# endif // CATCH_CONFIG_WINDOWS_SEH
-
#else // Not Windows - assumed to be POSIX compatible //////////////////////////
-# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
-
-namespace Catch {
- struct FatalConditionHandler {
- void reset() {}
- };
-}
-
-# else // CATCH_CONFIG_POSIX_SIGNALS is defined
-
#include <signal.h>
namespace Catch {
- struct SignalDefs {
- int id;
- const char* name;
- };
+ struct SignalDefs { int id; const char* name; };
extern SignalDefs signalDefs[];
SignalDefs signalDefs[] = {
{ SIGINT, "SIGINT - Terminal interrupt signal" },
@@ -6486,70 +5833,37 @@ namespace Catch {
{ SIGSEGV, "SIGSEGV - Segmentation violation signal" },
{ SIGTERM, "SIGTERM - Termination request signal" },
{ SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
- };
+ };
struct FatalConditionHandler {
- static bool isSet;
- static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)];
- static stack_t oldSigStack;
- static char altStackMem[SIGSTKSZ];
-
static void handleSignal( int sig ) {
- std::string name = "<unknown signal>";
- for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- SignalDefs &def = signalDefs[i];
- if (sig == def.id) {
- name = def.name;
- break;
- }
- }
- reset();
- reportFatal(name);
- raise( sig );
+ for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
+ if( sig == signalDefs[i].id )
+ fatal( signalDefs[i].name, -sig );
+ fatal( "<unknown signal>", -sig );
}
- FatalConditionHandler() {
- isSet = true;
- stack_t sigStack;
- sigStack.ss_sp = altStackMem;
- sigStack.ss_size = SIGSTKSZ;
- sigStack.ss_flags = 0;
- sigaltstack(&sigStack, &oldSigStack);
- struct sigaction sa = { 0 };
-
- sa.sa_handler = handleSignal;
- sa.sa_flags = SA_ONSTACK;
- for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) {
- sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
- }
+ FatalConditionHandler() : m_isSet( true ) {
+ for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
+ signal( signalDefs[i].id, handleSignal );
}
-
~FatalConditionHandler() {
reset();
}
- static void reset() {
- if( isSet ) {
- // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
- for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {
- sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL);
- }
- // Return the old stack
- sigaltstack(&oldSigStack, CATCH_NULL);
- isSet = false;
+ void reset() {
+ if( m_isSet ) {
+ for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
+ signal( signalDefs[i].id, SIG_DFL );
+ m_isSet = false;
}
}
- };
- bool FatalConditionHandler::isSet = false;
- struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
- stack_t FatalConditionHandler::oldSigStack = {};
- char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
+ bool m_isSet;
+ };
} // namespace Catch
-# endif // CATCH_CONFIG_POSIX_SIGNALS
-
#endif // not Windows
#include <set>
@@ -6594,8 +5908,7 @@ namespace Catch {
m_context( getCurrentMutableContext() ),
m_activeTestCase( CATCH_NULL ),
m_config( _config ),
- m_reporter( reporter ),
- m_shouldReportUnexpected ( true )
+ m_reporter( reporter )
{
m_context.setRunner( this );
m_context.setConfig( m_config );
@@ -6627,12 +5940,10 @@ namespace Catch {
m_activeTestCase = &testCase;
do {
- ITracker& rootTracker = m_trackerContext.startRun();
- assert( rootTracker.isSectionTracker() );
- static_cast<SectionTracker&>( rootTracker ).addInitialFilters( m_config->getSectionsToRun() );
+ m_trackerContext.startRun();
do {
m_trackerContext.startCycle();
- m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( testInfo.name, testInfo.lineInfo ) );
+ m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testInfo.name );
runCurrentTest( redirectedCout, redirectedCerr );
}
while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() );
@@ -6673,9 +5984,8 @@ namespace Catch {
m_totals.assertions.failed++;
}
- // We have no use for the return value (whether messages should be cleared), because messages were made scoped
- // and should be let to clear themselves out.
- static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
+ if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
+ m_messages.clear();
// Reset working state
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
@@ -6687,7 +5997,10 @@ namespace Catch {
Counts& assertions
)
{
- ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( sectionInfo.name, sectionInfo.lineInfo ) );
+ std::ostringstream oss;
+ oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
+
+ ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, oss.str() );
if( !sectionTracker.isOpen() )
return false;
m_activeSections.push_back( &sectionTracker );
@@ -6746,41 +6059,31 @@ namespace Catch {
virtual std::string getCurrentTestName() const {
return m_activeTestCase
? m_activeTestCase->getTestCaseInfo().name
- : std::string();
+ : "";
}
virtual const AssertionResult* getLastResult() const {
return &m_lastResult;
}
- virtual void exceptionEarlyReported() {
- m_shouldReportUnexpected = false;
- }
-
virtual void handleFatalErrorCondition( std::string const& message ) {
- // Don't rebuild the result -- the stringification itself can cause more fatal errors
- // Instead, fake a result data.
- AssertionResultData tempResult;
- tempResult.resultType = ResultWas::FatalErrorCondition;
-
+ ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
+ resultBuilder.setResultType( ResultWas::FatalErrorCondition );
+ resultBuilder << message;
// stack
#ifdef HAVE_EXECINFO
- std::string message2(message);
{
void *array[15];
const int size = static_cast<int>(backtrace(array, 15));
char **strings = backtrace_symbols(array, size);
for (int i = 0; i < size; i++)
- message2.append(strings[i]).append("\n");
+ resultBuilder << strings[i];
free(strings);
}
#endif // HAVE_EXECINFO
// stack
- tempResult.message = message2;
-
- AssertionResult result(m_lastAssertionInfo, tempResult);
- getResultCapture().assertionEnded(result);
+ resultBuilder.captureExpression();
handleUnfinishedSections();
@@ -6799,11 +6102,11 @@ namespace Catch {
deltaTotals.testCases.failed = 1;
m_reporter->testCaseEnded( TestCaseStats( testInfo,
deltaTotals,
- std::string(),
- std::string(),
+ "",
+ "",
false ) );
m_totals.testCases.failed++;
- testGroupEnded( std::string(), m_totals, 1, 1 );
+ testGroupEnded( "", m_totals, 1, 1 );
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) );
}
@@ -6821,7 +6124,6 @@ namespace Catch {
m_reporter->sectionStarting( testCaseSection );
Counts prevAssertions = m_totals.assertions;
double duration = 0;
- m_shouldReportUnexpected = true;
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
@@ -6843,11 +6145,7 @@ namespace Catch {
// This just means the test was aborted due to failure
}
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();
handleUnfinishedSections();
@@ -6875,9 +6173,9 @@ namespace Catch {
private:
ResultBuilder makeUnexpectedResultBuilder() const {
- return ResultBuilder( m_lastAssertionInfo.macroName,
+ return ResultBuilder( m_lastAssertionInfo.macroName.c_str(),
m_lastAssertionInfo.lineInfo,
- m_lastAssertionInfo.capturedExpression,
+ m_lastAssertionInfo.capturedExpression.c_str(),
m_lastAssertionInfo.resultDisposition );
}
@@ -6907,7 +6205,6 @@ namespace Catch {
std::vector<SectionEndInfo> m_unfinishedSections;
std::vector<ITracker*> m_activeSections;
TrackerContext m_trackerContext;
- bool m_shouldReportUnexpected;
};
IResultCapture& getResultCapture() {
@@ -6929,7 +6226,7 @@ namespace Catch {
Version( unsigned int _majorVersion,
unsigned int _minorVersion,
unsigned int _patchNumber,
- char const * const _branchName,
+ std::string const& _branchName,
unsigned int _buildNumber );
unsigned int const majorVersion;
@@ -6937,7 +6234,7 @@ namespace Catch {
unsigned int const patchNumber;
// buildNumber is only used if branchName is not null
- char const * const branchName;
+ std::string const branchName;
unsigned int const buildNumber;
friend std::ostream& operator << ( std::ostream& os, Version const& version );
@@ -6946,7 +6243,7 @@ namespace Catch {
void operator=( Version const& );
};
- inline Version libraryVersion();
+ extern Version libraryVersion;
}
#include <fstream>
@@ -7058,7 +6355,7 @@ namespace Catch {
}
void showHelp( std::string const& processName ) {
- Catch::cout() << "\nCatch v" << libraryVersion() << "\n";
+ Catch::cout() << "\nCatch v" << libraryVersion << "\n";
m_cli.usage( Catch::cout(), processName );
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
@@ -7099,32 +6396,6 @@ namespace Catch {
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() {
if( m_configData.showHelp )
return 0;
@@ -7184,29 +6455,16 @@ namespace Catch {
#include <vector>
#include <set>
#include <sstream>
+#include <iostream>
#include <algorithm>
namespace Catch {
+ struct LexSort {
+ bool operator() (TestCase i,TestCase j) const { return (i<j);}
+ };
struct RandomNumberGenerator {
- typedef std::ptrdiff_t result_type;
-
- result_type operator()( result_type n ) const { return std::rand() % n; }
-
-#ifdef CATCH_CONFIG_CPP11_SHUFFLE
- static constexpr result_type min() { return 0; }
- static constexpr result_type max() { return 1000000; }
- result_type operator()() const { return std::rand() % max(); }
-#endif
- template<typename V>
- static void shuffle( V& vector ) {
- RandomNumberGenerator rng;
-#ifdef CATCH_CONFIG_CPP11_SHUFFLE
- std::shuffle( vector.begin(), vector.end(), rng );
-#else
- std::random_shuffle( vector.begin(), vector.end(), rng );
-#endif
- }
+ int operator()( int n ) const { return std::rand() % n; }
};
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
@@ -7215,12 +6473,14 @@ namespace Catch {
switch( config.runOrder() ) {
case RunTests::InLexicographicalOrder:
- std::sort( sorted.begin(), sorted.end() );
+ std::sort( sorted.begin(), sorted.end(), LexSort() );
break;
case RunTests::InRandomOrder:
{
seedRng( config );
- RandomNumberGenerator::shuffle( sorted );
+
+ RandomNumberGenerator rng;
+ std::random_shuffle( sorted.begin(), sorted.end(), rng );
}
break;
case RunTests::InDeclarationOrder:
@@ -7239,15 +6499,13 @@ namespace Catch {
it != itEnd;
++it ) {
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
- if( !prev.second ) {
- std::ostringstream ss;
-
- ss << Colour( Colour::Red )
- << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
- << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << '\n'
- << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
-
- throw std::runtime_error(ss.str());
+ if( !prev.second ){
+ Catch::cerr()
+ << Colour( Colour::Red )
+ << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
+ << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
+ << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
+ exit(1);
}
}
}
@@ -7276,7 +6534,7 @@ namespace Catch {
virtual void registerTest( TestCase const& testCase ) {
std::string name = testCase.getTestCaseInfo().name;
- if( name.empty() ) {
+ if( name == "" ) {
std::ostringstream oss;
oss << "Anonymous test case " << ++m_unnamedCount;
return registerTest( testCase.withName( oss.str() ) );
@@ -7325,7 +6583,7 @@ namespace Catch {
inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
std::string className = classOrQualifiedMethodName;
- if( startsWith( className, '&' ) )
+ if( startsWith( className, "&" ) )
{
std::size_t lastColons = className.rfind( "::" );
std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
@@ -7472,26 +6730,6 @@ 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 {
@@ -7513,9 +6751,6 @@ namespace Catch {
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
return m_exceptionTranslatorRegistry;
}
- virtual ITagAliasRegistry const& getTagAliasRegistry() const CATCH_OVERRIDE {
- return m_tagAliasRegistry;
- }
public: // IMutableRegistryHub
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
@@ -7530,15 +6765,11 @@ namespace Catch {
virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
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:
TestRegistry m_testCaseRegistry;
ReporterRegistry m_reporterRegistry;
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
- TagAliasRegistry m_tagAliasRegistry;
};
// Single, global, instance
@@ -7570,7 +6801,7 @@ namespace Catch {
// #included from: catch_notimplemented_exception.hpp
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
-#include <sstream>
+#include <ostream>
namespace Catch {
@@ -7642,7 +6873,7 @@ namespace Catch {
m_ofs.open( filename.c_str() );
if( m_ofs.fail() ) {
std::ostringstream oss;
- oss << "Unable to open file: '" << filename << '\'';
+ oss << "Unable to open file: '" << filename << "'";
throw std::domain_error( oss.str() );
}
}
@@ -7695,11 +6926,6 @@ namespace Catch {
Context( Context const& );
void operator=( Context const& );
- public:
- virtual ~Context() {
- deleteAllValues( m_generatorsByTestName );
- }
-
public: // IContext
virtual IResultCapture* getResultCapture() {
return m_resultCapture;
@@ -7783,23 +7009,6 @@ namespace Catch {
// #included from: catch_console_colour_impl.hpp
#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 {
@@ -7830,6 +7039,16 @@ namespace Catch {
#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) /////////////////////////////////////////
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#ifdef __AFXDLL
+#include <AfxWin.h>
+#else
+#include <windows.h>
+#endif
+
namespace Catch {
namespace {
@@ -7910,7 +7129,7 @@ namespace {
case Colour::White: return setColour( "[0m" );
case Colour::Red: return setColour( "[0;31m" );
case Colour::Green: return setColour( "[0;32m" );
- case Colour::Blue: return setColour( "[0;34m" );
+ case Colour::Blue: return setColour( "[0:34m" );
case Colour::Cyan: return setColour( "[0;36m" );
case Colour::Yellow: return setColour( "[0;33m" );
case Colour::Grey: return setColour( "[1;30m" );
@@ -7935,7 +7154,6 @@ namespace {
};
IColourImpl* platformColourInstance() {
- ErrnoGuard guard;
Ptr<IConfig const> config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config
? config->useColour()
@@ -8054,16 +7272,14 @@ namespace Catch {
namespace Catch {
- AssertionInfo::AssertionInfo( char const * _macroName,
+ AssertionInfo::AssertionInfo( std::string const& _macroName,
SourceLineInfo const& _lineInfo,
- char const * _capturedExpression,
- ResultDisposition::Flags _resultDisposition,
- char const * _secondArg)
+ std::string const& _capturedExpression,
+ ResultDisposition::Flags _resultDisposition )
: macroName( _macroName ),
lineInfo( _lineInfo ),
capturedExpression( _capturedExpression ),
- resultDisposition( _resultDisposition ),
- secondArg( _secondArg )
+ resultDisposition( _resultDisposition )
{}
AssertionResult::AssertionResult() {}
@@ -8090,30 +7306,24 @@ namespace Catch {
}
bool AssertionResult::hasExpression() const {
- return m_info.capturedExpression[0] != 0;
+ return !m_info.capturedExpression.empty();
}
bool AssertionResult::hasMessage() const {
return !m_resultData.message.empty();
}
- std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) {
- return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"')
- ? capturedExpression
- : std::string(capturedExpression) + ", " + secondArg;
- }
-
std::string AssertionResult::getExpression() const {
if( isFalseTest( m_info.resultDisposition ) )
- return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+ return "!" + m_info.capturedExpression;
else
- return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+ return m_info.capturedExpression;
}
std::string AssertionResult::getExpressionInMacro() const {
- if( m_info.macroName[0] == 0 )
- return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+ if( m_info.macroName.empty() )
+ return m_info.capturedExpression;
else
- return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )";
+ return m_info.macroName + "( " + m_info.capturedExpression + " )";
}
bool AssertionResult::hasExpandedExpression() const {
@@ -8121,7 +7331,7 @@ namespace Catch {
}
std::string AssertionResult::getExpandedExpression() const {
- return m_resultData.reconstructExpression();
+ return m_resultData.reconstructedExpression;
}
std::string AssertionResult::getMessage() const {
@@ -8135,25 +7345,15 @@ namespace Catch {
return m_info.macroName;
}
- void AssertionResult::discardDecomposedExpression() const {
- m_resultData.decomposedExpression = CATCH_NULL;
- }
-
- void AssertionResult::expandDecomposedExpression() const {
- m_resultData.reconstructExpression();
- }
-
} // end namespace Catch
// #included from: catch_test_case_info.hpp
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED
-#include <cctype>
-
namespace Catch {
inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
- if( startsWith( tag, '.' ) ||
+ if( startsWith( tag, "." ) ||
tag == "hide" ||
tag == "!hide" )
return TestCaseInfo::IsHidden;
@@ -8163,23 +7363,25 @@ namespace Catch {
return TestCaseInfo::ShouldFail;
else if( tag == "!mayfail" )
return TestCaseInfo::MayFail;
- else if( tag == "!nonportable" )
- return TestCaseInfo::NonPortable;
else
return TestCaseInfo::None;
}
inline bool isReservedTag( std::string const& tag ) {
- return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] );
+ return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] );
}
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
if( isReservedTag( tag ) ) {
- std::ostringstream ss;
- ss << Colour(Colour::Red)
- << "Tag name [" << tag << "] not allowed.\n"
- << "Tag names starting with non alpha-numeric characters are reserved\n"
- << Colour(Colour::FileName)
- << _lineInfo << '\n';
- throw std::runtime_error(ss.str());
+ {
+ Colour colourGuard( Colour::Red );
+ Catch::cerr()
+ << "Tag name [" << tag << "] not allowed.\n"
+ << "Tag names starting with non alpha-numeric characters are reserved\n";
+ }
+ {
+ Colour colourGuard( Colour::FileName );
+ Catch::cerr() << _lineInfo << std::endl;
+ }
+ exit(1);
}
}
@@ -8235,7 +7437,7 @@ namespace Catch {
std::ostringstream oss;
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
- oss << '[' << *it << ']';
+ oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it );
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
testCaseInfo.lcaseTags.insert( lcaseTag );
@@ -8341,7 +7543,7 @@ namespace Catch {
( unsigned int _majorVersion,
unsigned int _minorVersion,
unsigned int _patchNumber,
- char const * const _branchName,
+ std::string const& _branchName,
unsigned int _buildNumber )
: majorVersion( _majorVersion ),
minorVersion( _minorVersion ),
@@ -8351,21 +7553,18 @@ namespace Catch {
{}
std::ostream& operator << ( std::ostream& os, Version const& version ) {
- os << version.majorVersion << '.'
- << version.minorVersion << '.'
+ os << version.majorVersion << "."
+ << version.minorVersion << "."
<< version.patchNumber;
- // branchName is never null -> 0th char is \0 if it is empty
- if (version.branchName[0]) {
- os << '-' << version.branchName
- << '.' << version.buildNumber;
+
+ if( !version.branchName.empty() ) {
+ os << "-" << version.branchName
+ << "." << version.buildNumber;
}
return os;
}
- inline Version libraryVersion() {
- static Version version( 1, 9, 6, "", 0 );
- return version;
- }
+ Version libraryVersion( 1, 5, 1, "", 0 );
}
@@ -8399,9 +7598,7 @@ namespace Catch {
{}
ScopedMessage::~ScopedMessage() {
- if ( !std::uncaught_exception() ){
- getResultCapture().popScopedMessage(m_info);
- }
+ getResultCapture().popScopedMessage( m_info );
}
} // end namespace Catch
@@ -8538,32 +7735,30 @@ namespace Catch
#endif
#ifdef CATCH_PLATFORM_WINDOWS
-
+#include <windows.h>
#else
-
#include <sys/time.h>
-
#endif
namespace Catch {
namespace {
#ifdef CATCH_PLATFORM_WINDOWS
- UInt64 getCurrentTicks() {
- static UInt64 hz=0, hzo=0;
+ uint64_t getCurrentTicks() {
+ static uint64_t hz=0, hzo=0;
if (!hz) {
QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) );
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) );
}
- UInt64 t;
+ uint64_t t;
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) );
return ((t-hzo)*1000000)/hz;
}
#else
- UInt64 getCurrentTicks() {
+ uint64_t getCurrentTicks() {
timeval t;
gettimeofday(&t,CATCH_NULL);
- return static_cast<UInt64>( t.tv_sec ) * 1000000ull + static_cast<UInt64>( t.tv_usec );
+ return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
}
#endif
}
@@ -8589,31 +7784,19 @@ namespace Catch {
// #included from: catch_common.hpp
#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED
-#include <cstring>
-#include <cctype>
-
namespace Catch {
bool startsWith( std::string const& s, std::string const& prefix ) {
- return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
- }
- bool startsWith( std::string const& s, char prefix ) {
- return !s.empty() && s[0] == prefix;
+ return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
}
bool endsWith( std::string const& s, std::string const& suffix ) {
- return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
- }
- bool endsWith( std::string const& s, char suffix ) {
- return !s.empty() && s[s.size()-1] == suffix;
+ return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
}
bool contains( std::string const& s, std::string const& infix ) {
return s.find( infix ) != std::string::npos;
}
- char toLowerCh(char c) {
- return static_cast<char>( std::tolower( c ) );
- }
void toLowerInPlace( std::string& s ) {
- std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
+ std::transform( s.begin(), s.end(), s.begin(), ::tolower );
}
std::string toLower( std::string const& s ) {
std::string lc = s;
@@ -8625,7 +7808,7 @@ namespace Catch {
std::string::size_type start = str.find_first_not_of( whitespaceChars );
std::string::size_type end = str.find_last_not_of( whitespaceChars );
- return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string();
+ return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
}
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
@@ -8648,25 +7831,29 @@ namespace Catch {
{}
std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
- os << pluraliser.m_count << ' ' << pluraliser.m_label;
+ os << pluraliser.m_count << " " << pluraliser.m_label;
if( pluraliser.m_count != 1 )
- os << 's';
+ os << "s";
return os;
}
- SourceLineInfo::SourceLineInfo() : file(""), line( 0 ){}
+ SourceLineInfo::SourceLineInfo() : line( 0 ){}
SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line )
: file( _file ),
line( _line )
{}
+ SourceLineInfo::SourceLineInfo( SourceLineInfo const& other )
+ : file( other.file ),
+ line( other.line )
+ {}
bool SourceLineInfo::empty() const {
- return file[0] == '\0';
+ return file.empty();
}
bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const {
- return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);
+ return line == other.line && file == other.file;
}
bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const {
- return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0));
+ return line < other.line || ( line == other.line && file < other.file );
}
void seedRng( IConfig const& config ) {
@@ -8679,16 +7866,16 @@ namespace Catch {
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
#ifndef __GNUG__
- os << info.file << '(' << info.line << ')';
+ os << info.file << "(" << info.line << ")";
#else
- os << info.file << ':' << info.line;
+ os << info.file << ":" << info.line;
#endif
return os;
}
void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
std::ostringstream oss;
- oss << locationInfo << ": Internal Catch error: '" << message << '\'';
+ oss << locationInfo << ": Internal Catch error: '" << message << "'";
if( alwaysTrue() )
throw std::logic_error( oss.str() );
}
@@ -8715,10 +7902,6 @@ namespace Catch {
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() {
if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
@@ -8728,9 +7911,6 @@ namespace Catch {
getResultCapture().sectionEnded( endInfo );
}
}
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
// This indicates whether the section should be executed or not
Section::operator bool() const {
@@ -8742,6 +7922,8 @@ namespace Catch {
// #included from: catch_debugger.hpp
#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
+#include <iostream>
+
#ifdef CATCH_PLATFORM_MAC
#include <assert.h>
@@ -8790,36 +7972,6 @@ namespace Catch {
}
} // namespace Catch
-#elif defined(CATCH_PLATFORM_LINUX)
- #include <fstream>
- #include <string>
-
- namespace Catch{
- // The standard POSIX way of detecting a debugger is to attempt to
- // ptrace() the process, but this needs to be done from a child and not
- // this process itself to still allow attaching to this process later
- // if wanted, so is rather heavy. Under Linux we have the PID of the
- // "debugger" (which doesn't need to be gdb, of course, it could also
- // be strace, for example) in /proc/$PID/status, so just get it from
- // there instead.
- 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");
- for( std::string line; std::getline(in, line); ) {
- static const int PREFIX_LEN = 11;
- if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) {
- // We're traced if the PID is not 0 and no other PID starts
- // with 0 digit, so it's enough to check for just a single
- // character.
- return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0';
- }
- }
-
- return false;
- }
- } // namespace Catch
#elif defined(_MSC_VER)
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
namespace Catch {
@@ -8841,7 +7993,7 @@ namespace Catch {
#endif // Platform
#ifdef CATCH_PLATFORM_WINDOWS
-
+ extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
namespace Catch {
void writeToDebugConsole( std::string const& text ) {
::OutputDebugStringA( text.c_str() );
@@ -8917,7 +8069,7 @@ std::string toString( std::string const& value ) {
}
}
}
- return '"' + s + '"';
+ return "\"" + s + "\"";
}
std::string toString( std::wstring const& value ) {
@@ -8938,19 +8090,19 @@ std::string toString( char* const value ) {
std::string toString( const wchar_t* const value )
{
- return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
+ return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
}
std::string toString( wchar_t* const value )
{
- return Catch::toString( static_cast<const wchar_t*>( value ) );
+ return Catch::toString( static_cast<const wchar_t*>( value ) );
}
std::string toString( int value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ')';
+ oss << " (0x" << std::hex << value << ")";
return oss.str();
}
@@ -8958,7 +8110,7 @@ std::string toString( unsigned long value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ')';
+ oss << " (0x" << std::hex << value << ")";
return oss.str();
}
@@ -8986,7 +8138,7 @@ std::string toString( const double value ) {
return fpToString( value, 10 );
}
std::string toString( const float value ) {
- return fpToString( value, 5 ) + 'f';
+ return fpToString( value, 5 ) + "f";
}
std::string toString( bool value ) {
@@ -8994,19 +8146,9 @@ std::string toString( bool value ) {
}
std::string toString( char value ) {
- if ( value == '\r' )
- return "'\\r'";
- if ( value == '\f' )
- return "'\\f'";
- if ( value == '\n' )
- return "'\\n'";
- if ( value == '\t' )
- return "'\\t'";
- if ( '\0' <= value && value < ' ' )
- return toString( static_cast<unsigned int>( value ) );
- char chstr[] = "' '";
- chstr[1] = value;
- return chstr;
+ return value < ' '
+ ? toString( static_cast<unsigned int>( value ) )
+ : Detail::makeString( value );
}
std::string toString( signed char value ) {
@@ -9022,14 +8164,14 @@ std::string toString( long long value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ')';
+ oss << " (0x" << std::hex << value << ")";
return oss.str();
}
std::string toString( unsigned long long value ) {
std::ostringstream oss;
oss << value;
if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ')';
+ oss << " (0x" << std::hex << value << ")";
return oss.str();
}
#endif
@@ -9046,7 +8188,7 @@ std::string toString( std::nullptr_t ) {
return "nil";
return "@" + toString([nsstring UTF8String]);
}
- std::string toString( NSString * CATCH_ARC_STRONG & nsstring ) {
+ std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
if( !nsstring )
return "nil";
return "@" + toString([nsstring UTF8String]);
@@ -9063,28 +8205,20 @@ std::string toString( std::nullptr_t ) {
namespace Catch {
+ std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
+ return secondArg.empty() || secondArg == "\"\""
+ ? capturedExpression
+ : capturedExpression + ", " + secondArg;
+ }
ResultBuilder::ResultBuilder( char const* macroName,
SourceLineInfo const& lineInfo,
char const* capturedExpression,
ResultDisposition::Flags resultDisposition,
char const* secondArg )
- : m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
+ : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
m_shouldDebugBreak( false ),
- m_shouldThrow( false ),
- m_guardException( false )
- {
- m_stream().oss.str("");
- }
-
- 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
- }
+ m_shouldThrow( false )
+ {}
ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
m_data.resultType = result;
@@ -9094,15 +8228,27 @@ namespace Catch {
m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed;
return *this;
}
+ ResultBuilder& ResultBuilder::setLhs( std::string const& lhs ) {
+ m_exprComponents.lhs = lhs;
+ return *this;
+ }
+ ResultBuilder& ResultBuilder::setRhs( std::string const& rhs ) {
+ m_exprComponents.rhs = rhs;
+ return *this;
+ }
+ ResultBuilder& ResultBuilder::setOp( std::string const& op ) {
+ m_exprComponents.op = op;
+ return *this;
+ }
- void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
- AssertionResult result = build( expr );
- handleResult( result );
+ void ResultBuilder::endExpression() {
+ m_exprComponents.testFalse = isFalseTest( m_assertionInfo.resultDisposition );
+ captureExpression();
}
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
m_assertionInfo.resultDisposition = resultDisposition;
- m_stream().oss << Catch::translateActiveException();
+ m_stream.oss << Catch::translateActiveException();
captureResult( ResultWas::ThrewException );
}
@@ -9110,20 +8256,19 @@ namespace Catch {
setResultType( resultType );
captureExpression();
}
-
void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
if( expectedMessage.empty() )
- captureExpectedException( Matchers::Impl::MatchAllOf<std::string>() );
+ captureExpectedException( Matchers::Impl::Generic::AllOf<std::string>() );
else
captureExpectedException( Matchers::Equals( expectedMessage ) );
}
- void ResultBuilder::captureExpectedException( Matchers::Impl::MatcherBase<std::string> const& matcher ) {
+ void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
- assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
+ assert( m_exprComponents.testFalse == false );
AssertionResultData data = m_data;
data.resultType = ResultWas::Ok;
- data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
+ data.reconstructedExpression = m_assertionInfo.capturedExpression;
std::string actualMessage = Catch::translateActiveException();
if( !matcher.match( actualMessage ) ) {
@@ -9138,7 +8283,6 @@ namespace Catch {
AssertionResult result = build();
handleResult( result );
}
-
void ResultBuilder::handleResult( AssertionResult const& result )
{
getResultCapture().assertionEnded( result );
@@ -9150,17 +8294,7 @@ namespace Catch {
m_shouldThrow = true;
}
}
-
void ResultBuilder::react() {
-#if defined(CATCH_CONFIG_FAST_COMPILE)
- if (m_shouldDebugBreak) {
- ///////////////////////////////////////////////////////////////////
- // To inspect the state during test, you need to go one level up the callstack
- // To go back to the test and change execution, jump over the throw statement
- ///////////////////////////////////////////////////////////////////
- CATCH_BREAK_INTO_DEBUGGER();
- }
-#endif
if( m_shouldThrow )
throw Catch::TestFailureException();
}
@@ -9170,39 +8304,43 @@ namespace Catch {
AssertionResult ResultBuilder::build() const
{
- return build( *this );
- }
-
- // CAVEAT: The returned AssertionResult stores a pointer to the argument expr,
- // a temporary DecomposedExpression, which in turn holds references to
- // operands, possibly temporary as well.
- // It should immediately be passed to handleResult; if the expression
- // needs to be reported, its string expansion must be composed before
- // the temporaries are destroyed.
- AssertionResult ResultBuilder::build( DecomposedExpression const& expr ) const
- {
assert( m_data.resultType != ResultWas::Unknown );
+
AssertionResultData data = m_data;
- // Flip bool results if FalseTest flag is set
- if( isFalseTest( m_assertionInfo.resultDisposition ) ) {
- data.negate( expr.isBinaryExpression() );
+ // Flip bool results if testFalse is set
+ if( m_exprComponents.testFalse ) {
+ if( data.resultType == ResultWas::Ok )
+ data.resultType = ResultWas::ExpressionFailed;
+ else if( data.resultType == ResultWas::ExpressionFailed )
+ data.resultType = ResultWas::Ok;
}
- data.message = m_stream().oss.str();
- data.decomposedExpression = &expr; // for lazy reconstruction
+ data.message = m_stream.oss.str();
+ data.reconstructedExpression = reconstructExpression();
+ if( m_exprComponents.testFalse ) {
+ if( m_exprComponents.op == "" )
+ data.reconstructedExpression = "!" + data.reconstructedExpression;
+ else
+ data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
+ }
return AssertionResult( m_assertionInfo, data );
}
-
- void ResultBuilder::reconstructExpression( std::string& dest ) const {
- dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
- }
-
- void ResultBuilder::setExceptionGuard() {
- m_guardException = true;
- }
- void ResultBuilder::unsetExceptionGuard() {
- m_guardException = false;
+ std::string ResultBuilder::reconstructExpression() const {
+ if( m_exprComponents.op == "" )
+ return m_exprComponents.lhs.empty() ? m_assertionInfo.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
+ else if( m_exprComponents.op == "matches" )
+ return m_exprComponents.lhs + " " + m_exprComponents.rhs;
+ else if( m_exprComponents.op != "!" ) {
+ if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 &&
+ m_exprComponents.lhs.find("\n") == std::string::npos &&
+ m_exprComponents.rhs.find("\n") == std::string::npos )
+ return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs;
+ else
+ return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs;
+ }
+ else
+ return "{can't expand - use " + m_assertionInfo.macroName + "_FALSE( " + m_assertionInfo.capturedExpression.substr(1) + " ) instead of " + m_assertionInfo.macroName + "( " + m_assertionInfo.capturedExpression + " ) for better diagnostics}";
}
} // end namespace Catch
@@ -9210,6 +8348,30 @@ namespace Catch {
// #included from: catch_tag_alias_registry.hpp
#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
+
+#include <map>
+#include <iostream>
+
namespace Catch {
TagAliasRegistry::~TagAliasRegistry() {}
@@ -9237,120 +8399,44 @@ namespace Catch {
return expandedTestSpec;
}
- void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) {
+ void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
- if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) {
+ if( !startsWith( alias, "[@" ) || !endsWith( alias, "]" ) ) {
std::ostringstream oss;
- oss << Colour( Colour::Red )
- << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n"
- << Colour( Colour::FileName )
- << lineInfo << '\n';
+ oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo;
throw std::domain_error( oss.str().c_str() );
}
if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
std::ostringstream oss;
- oss << Colour( Colour::Red )
- << "error: tag alias, \"" << alias << "\" already registered.\n"
- << "\tFirst seen at "
- << Colour( Colour::Red ) << find(alias)->lineInfo << '\n'
- << Colour( Colour::Red ) << "\tRedefined at "
- << Colour( Colour::FileName) << lineInfo << '\n';
+ oss << "error: tag alias, \"" << alias << "\" already registered.\n"
+ << "\tFirst seen at " << find(alias)->lineInfo << "\n"
+ << "\tRedefined at " << lineInfo;
throw std::domain_error( oss.str().c_str() );
}
}
- ITagAliasRegistry::~ITagAliasRegistry() {}
-
- ITagAliasRegistry const& ITagAliasRegistry::get() {
- return getRegistryHub().getTagAliasRegistry();
- }
+ TagAliasRegistry& TagAliasRegistry::get() {
+ static TagAliasRegistry instance;
+ return instance;
- RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
- getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo );
}
-} // end namespace Catch
-
-// #included from: catch_matchers_string.hpp
-
-namespace Catch {
-namespace Matchers {
-
- namespace StdString {
-
- CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
- : m_caseSensitivity( caseSensitivity ),
- m_str( adjustString( str ) )
- {}
- std::string CasedString::adjustString( std::string const& str ) const {
- return m_caseSensitivity == CaseSensitive::No
- ? toLower( str )
- : str;
- }
- std::string CasedString::caseSensitivitySuffix() const {
- return m_caseSensitivity == CaseSensitive::No
- ? " (case insensitive)"
- : std::string();
- }
-
- StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator )
- : m_comparator( comparator ),
- m_operation( operation ) {
- }
-
- std::string StringMatcherBase::describe() const {
- std::string description;
- description.reserve(5 + m_operation.size() + m_comparator.m_str.size() +
- m_comparator.caseSensitivitySuffix().size());
- description += m_operation;
- description += ": \"";
- description += m_comparator.m_str;
- description += "\"";
- description += m_comparator.caseSensitivitySuffix();
- return description;
- }
-
- EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {}
-
- bool EqualsMatcher::match( std::string const& source ) const {
- return m_comparator.adjustString( source ) == m_comparator.m_str;
- }
-
- ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {}
+ ITagAliasRegistry::~ITagAliasRegistry() {}
+ ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); }
- bool ContainsMatcher::match( std::string const& source ) const {
- return contains( m_comparator.adjustString( source ), m_comparator.m_str );
+ RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
+ try {
+ TagAliasRegistry::get().add( alias, tag, lineInfo );
}
-
- StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {}
-
- bool StartsWithMatcher::match( std::string const& source ) const {
- return startsWith( m_comparator.adjustString( source ), m_comparator.m_str );
+ catch( std::exception& ex ) {
+ Colour colourGuard( Colour::Red );
+ Catch::cerr() << ex.what() << std::endl;
+ exit(1);
}
-
- EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {}
-
- bool EndsWithMatcher::match( std::string const& source ) const {
- return endsWith( m_comparator.adjustString( source ), m_comparator.m_str );
- }
-
- } // namespace StdString
-
- StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
- return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) );
- }
- StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
- return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) );
- }
- StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
- return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) );
- }
- StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
- return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) );
}
-} // namespace Matchers
-} // namespace Catch
+} // end namespace Catch
+
// #included from: ../reporters/catch_reporter_multi.hpp
#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
@@ -9494,34 +8580,9 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
#include <cstring>
-#include <cfloat>
-#include <cstdio>
-#include <assert.h>
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> {
StreamingReporterBase( ReporterConfig const& _config )
@@ -9616,12 +8677,12 @@ namespace Catch {
struct BySectionInfo {
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
- BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
+ BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
bool operator() ( Ptr<SectionNode> const& node ) const {
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
}
private:
- void operator=( BySectionInfo const& );
+ void operator=( BySectionInfo const& );
SectionInfo const& m_other;
};
@@ -9677,12 +8738,6 @@ namespace Catch {
assert( !m_sectionStack.empty() );
SectionNode& sectionNode = *m_sectionStack.back();
sectionNode.assertions.push_back( assertionStats );
- // AssertionResult holds a pointer to a temporary DecomposedExpression,
- // which getExpandedExpression() calls to build the expression string.
- // Our section stack copy of the assertionResult will likely outlive the
- // temporary, so it must be expanded or discarded now to avoid calling
- // a destroyed object later.
- prepareExpandedExpression( sectionNode.assertions.back().assertionResult );
return true;
}
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
@@ -9717,13 +8772,6 @@ namespace Catch {
virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
- virtual void prepareExpandedExpression( AssertionResult& result ) const {
- if( result.isOk() )
- result.discardDecomposedExpression();
- else
- result.expandDecomposedExpression();
- }
-
Ptr<IConfig const> m_config;
std::ostream& stream;
std::vector<AssertionStats> m_assertions;
@@ -9744,7 +8792,7 @@ namespace Catch {
char const* getLineOfChars() {
static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
if( !*line ) {
- std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
+ memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
}
return line;
@@ -9829,7 +8877,7 @@ namespace Catch {
return new T( config );
}
virtual std::string getDescription() const {
- return std::string();
+ return "";
}
};
@@ -9847,13 +8895,9 @@ namespace Catch {
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
-// Deprecated - use the form without INTERNAL_
#define INTERNAL_CATCH_REGISTER_LISTENER( 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
#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
@@ -9900,13 +8944,9 @@ namespace Catch {
break;
default:
- // Escape control chars - based on contribution by @espenalb in PR #465 and
- // by @mrpi PR #588
- if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) {
- // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
- os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2)
- << static_cast<int>( c );
- }
+ // Escape control chars - based on contribution by @espenalb in PR #465
+ if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
+ os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
else
os << c;
}
@@ -9960,18 +9000,14 @@ namespace Catch {
XmlWriter()
: m_tagIsOpen( false ),
m_needsNewline( false ),
- m_os( Catch::cout() )
- {
- writeDeclaration();
- }
+ m_os( &Catch::cout() )
+ {}
XmlWriter( std::ostream& os )
: m_tagIsOpen( false ),
m_needsNewline( false ),
- m_os( os )
- {
- writeDeclaration();
- }
+ m_os( &os )
+ {}
~XmlWriter() {
while( !m_tags.empty() )
@@ -9981,7 +9017,7 @@ namespace Catch {
XmlWriter& startElement( std::string const& name ) {
ensureTagClosed();
newlineIfNecessary();
- m_os << m_indent << '<' << name;
+ stream() << m_indent << "<" << name;
m_tags.push_back( name );
m_indent += " ";
m_tagIsOpen = true;
@@ -9998,25 +9034,24 @@ namespace Catch {
newlineIfNecessary();
m_indent = m_indent.substr( 0, m_indent.size()-2 );
if( m_tagIsOpen ) {
- m_os << "/>";
+ stream() << "/>\n";
m_tagIsOpen = false;
}
else {
- m_os << m_indent << "</" << m_tags.back() << ">";
+ stream() << m_indent << "</" << m_tags.back() << ">\n";
}
- m_os << std::endl;
m_tags.pop_back();
return *this;
}
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
if( !name.empty() && !attribute.empty() )
- m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
+ stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
return *this;
}
XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
- m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
+ stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
return *this;
}
@@ -10032,8 +9067,8 @@ namespace Catch {
bool tagWasOpen = m_tagIsOpen;
ensureTagClosed();
if( tagWasOpen && indent )
- m_os << m_indent;
- m_os << XmlEncode( text );
+ stream() << m_indent;
+ stream() << XmlEncode( text );
m_needsNewline = true;
}
return *this;
@@ -10041,39 +9076,39 @@ namespace Catch {
XmlWriter& writeComment( std::string const& text ) {
ensureTagClosed();
- m_os << m_indent << "<!--" << text << "-->";
+ stream() << m_indent << "<!--" << text << "-->";
m_needsNewline = true;
return *this;
}
- void writeStylesheetRef( std::string const& url ) {
- m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
- }
-
XmlWriter& writeBlankLine() {
ensureTagClosed();
- m_os << '\n';
+ stream() << "\n";
return *this;
}
- void ensureTagClosed() {
- if( m_tagIsOpen ) {
- m_os << ">" << std::endl;
- m_tagIsOpen = false;
- }
+ void setStream( std::ostream& os ) {
+ m_os = &os;
}
private:
XmlWriter( XmlWriter const& );
void operator=( XmlWriter const& );
- void writeDeclaration() {
- m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ std::ostream& stream() {
+ return *m_os;
+ }
+
+ void ensureTagClosed() {
+ if( m_tagIsOpen ) {
+ stream() << ">\n";
+ m_tagIsOpen = false;
+ }
}
void newlineIfNecessary() {
if( m_needsNewline ) {
- m_os << std::endl;
+ stream() << "\n";
m_needsNewline = false;
}
}
@@ -10082,17 +9117,30 @@ namespace Catch {
bool m_needsNewline;
std::vector<std::string> m_tags;
std::string m_indent;
- std::ostream& m_os;
+ std::ostream* m_os;
};
}
+// #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 {
class XmlReporter : public StreamingReporterBase {
public:
XmlReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config ),
- m_xml(_config.stream()),
m_sectionDepth( 0 )
{
m_reporterPrefs.shouldRedirectStdOut = true;
@@ -10104,16 +9152,6 @@ namespace Catch {
return "Reports test results as an XML document";
}
- virtual std::string getStylesheetRef() const {
- return std::string();
- }
-
- void writeSourceInfo( SourceLineInfo const& sourceInfo ) {
- m_xml
- .writeAttribute( "filename", sourceInfo.file )
- .writeAttribute( "line", sourceInfo.line );
- }
-
public: // StreamingReporterBase
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
@@ -10122,9 +9160,7 @@ namespace Catch {
virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
StreamingReporterBase::testRunStarting( testInfo );
- std::string stylesheetRef = getStylesheetRef();
- if( !stylesheetRef.empty() )
- m_xml.writeStylesheetRef( stylesheetRef );
+ m_xml.setStream( stream );
m_xml.startElement( "Catch" );
if( !m_config->name().empty() )
m_xml.writeAttribute( "name", m_config->name() );
@@ -10138,16 +9174,10 @@ namespace Catch {
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
StreamingReporterBase::testCaseStarting(testInfo);
- m_xml.startElement( "TestCase" )
- .writeAttribute( "name", trim( testInfo.name ) )
- .writeAttribute( "description", testInfo.description )
- .writeAttribute( "tags", testInfo.tagsAsString );
-
- writeSourceInfo( testInfo.lineInfo );
+ m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
if ( m_config->showDurations() == ShowDurations::Always )
m_testCaseTimer.start();
- m_xml.ensureTagClosed();
}
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
@@ -10156,84 +9186,77 @@ namespace Catch {
m_xml.startElement( "Section" )
.writeAttribute( "name", trim( sectionInfo.name ) )
.writeAttribute( "description", sectionInfo.description );
- writeSourceInfo( sectionInfo.lineInfo );
- m_xml.ensureTagClosed();
}
}
virtual void assertionStarting( AssertionInfo const& ) 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();
- it != itEnd;
- ++it ) {
+ it != itEnd;
+ ++it ) {
if( it->type == ResultWas::Info ) {
m_xml.scopedElement( "Info" )
- .writeText( it->message );
+ .writeText( it->message );
} else if ( it->type == ResultWas::Warning ) {
m_xml.scopedElement( "Warning" )
- .writeText( it->message );
+ .writeText( it->message );
}
}
}
// Drop out if result was successful but we're not printing them.
- if( !includeResults && result.getResultType() != ResultWas::Warning )
+ if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
return true;
// Print the expression if there is one.
- if( result.hasExpression() ) {
+ if( assertionResult.hasExpression() ) {
m_xml.startElement( "Expression" )
- .writeAttribute( "success", result.succeeded() )
- .writeAttribute( "type", result.getTestMacroName() );
-
- writeSourceInfo( result.getSourceInfo() );
+ .writeAttribute( "success", assertionResult.succeeded() )
+ .writeAttribute( "type", assertionResult.getTestMacroName() )
+ .writeAttribute( "filename", assertionResult.getSourceInfo().file )
+ .writeAttribute( "line", assertionResult.getSourceInfo().line );
m_xml.scopedElement( "Original" )
- .writeText( result.getExpression() );
+ .writeText( assertionResult.getExpression() );
m_xml.scopedElement( "Expanded" )
- .writeText( result.getExpandedExpression() );
+ .writeText( assertionResult.getExpandedExpression() );
}
// And... Print a result applicable to each result type.
- switch( result.getResultType() ) {
+ switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException:
- m_xml.startElement( "Exception" );
- writeSourceInfo( result.getSourceInfo() );
- m_xml.writeText( result.getMessage() );
- m_xml.endElement();
+ m_xml.scopedElement( "Exception" )
+ .writeAttribute( "filename", assertionResult.getSourceInfo().file )
+ .writeAttribute( "line", assertionResult.getSourceInfo().line )
+ .writeText( assertionResult.getMessage() );
break;
case ResultWas::FatalErrorCondition:
- m_xml.startElement( "FatalErrorCondition" );
- writeSourceInfo( result.getSourceInfo() );
- m_xml.writeText( result.getMessage() );
- m_xml.endElement();
+ m_xml.scopedElement( "Fatal Error Condition" )
+ .writeAttribute( "filename", assertionResult.getSourceInfo().file )
+ .writeAttribute( "line", assertionResult.getSourceInfo().line )
+ .writeText( assertionResult.getMessage() );
break;
case ResultWas::Info:
m_xml.scopedElement( "Info" )
- .writeText( result.getMessage() );
+ .writeText( assertionResult.getMessage() );
break;
case ResultWas::Warning:
// Warning will already have been written
break;
case ResultWas::ExplicitFailure:
- m_xml.startElement( "Failure" );
- writeSourceInfo( result.getSourceInfo() );
- m_xml.writeText( result.getMessage() );
- m_xml.endElement();
+ m_xml.scopedElement( "Failure" )
+ .writeText( assertionResult.getMessage() );
break;
default:
break;
}
- if( result.hasExpression() )
+ if( assertionResult.hasExpression() )
m_xml.endElement();
return true;
@@ -10262,11 +9285,6 @@ namespace Catch {
if ( m_config->showDurations() == ShowDurations::Always )
e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
- if( !testCaseStats.stdOut.empty() )
- m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false );
- if( !testCaseStats.stdErr.empty() )
- m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false );
-
m_xml.endElement();
}
@@ -10306,41 +9324,11 @@ namespace Catch {
namespace Catch {
- namespace {
- std::string getCurrentTimestamp() {
- // Beware, this is not reentrant because of backward compatibility issues
- // Also, UTC only, again because of backward compatibility (%z is C++11)
- time_t rawtime;
- std::time(&rawtime);
- const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z");
-
-#ifdef _MSC_VER
- std::tm timeInfo = {};
- gmtime_s(&timeInfo, &rawtime);
-#else
- std::tm* timeInfo;
- timeInfo = std::gmtime(&rawtime);
-#endif
-
- char timeStamp[timeStampSize];
- const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
-
-#ifdef _MSC_VER
- std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
-#else
- std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
-#endif
- return std::string(timeStamp);
- }
-
- }
-
class JunitReporter : public CumulativeReporterBase {
public:
JunitReporter( ReporterConfig const& _config )
: CumulativeReporterBase( _config ),
- xml( _config.stream() ),
- m_okToFail( false )
+ xml( _config.stream() )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
@@ -10366,11 +9354,8 @@ namespace Catch {
CumulativeReporterBase::testGroupStarting( groupInfo );
}
- virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE {
- m_okToFail = testCaseInfo.okToFail();
- }
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
- if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
+ if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
unexpectedExceptions++;
return CumulativeReporterBase::assertionEnded( assertionStats );
}
@@ -10403,7 +9388,7 @@ namespace Catch {
xml.writeAttribute( "time", "" );
else
xml.writeAttribute( "time", suiteTime );
- xml.writeAttribute( "timestamp", getCurrentTimestamp() );
+ xml.writeAttribute( "timestamp", "tbd" ); // !TBD
// Write test cases
for( TestGroupNode::ChildNodes::const_iterator
@@ -10438,7 +9423,7 @@ namespace Catch {
SectionNode const& sectionNode ) {
std::string name = trim( sectionNode.stats.sectionInfo.name );
if( !rootName.empty() )
- name = rootName + '/' + name;
+ name = rootName + "/" + name;
if( !sectionNode.assertions.empty() ||
!sectionNode.stdOut.empty() ||
@@ -10516,14 +9501,14 @@ namespace Catch {
std::ostringstream oss;
if( !result.getMessage().empty() )
- oss << result.getMessage() << '\n';
+ oss << result.getMessage() << "\n";
for( std::vector<MessageInfo>::const_iterator
it = stats.infoMessages.begin(),
itEnd = stats.infoMessages.end();
it != itEnd;
++it )
if( it->type == ResultWas::Info )
- oss << it->message << '\n';
+ oss << it->message << "\n";
oss << "at " << result.getSourceInfo();
xml.writeText( oss.str(), false );
@@ -10535,7 +9520,6 @@ namespace Catch {
std::ostringstream stdOutForSuite;
std::ostringstream stdErrForSuite;
unsigned int unexpectedExceptions;
- bool m_okToFail;
};
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
@@ -10545,9 +9529,6 @@ namespace Catch {
// #included from: ../reporters/catch_reporter_console.hpp
#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
-#include <cfloat>
-#include <cstdio>
-
namespace Catch {
struct ConsoleReporter : StreamingReporterBase {
@@ -10562,7 +9543,7 @@ namespace Catch {
}
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
- stream << "No test cases matched '" << spec << '\'' << std::endl;
+ stream << "No test cases matched '" << spec << "'" << std::endl;
}
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
@@ -10571,15 +9552,18 @@ namespace Catch {
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
AssertionResult const& result = _assertionStats.assertionResult;
- bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
+ bool printInfoMessages = true;
- // Drop out if result was successful but we're not printing them.
- if( !includeResults && result.getResultType() != ResultWas::Warning )
- return false;
+ // Drop out if result was successful and we're not printing those
+ if( !m_config->includeSuccessfulResults() && result.isOk() ) {
+ if( result.getResultType() != ResultWas::Warning )
+ return false;
+ printInfoMessages = false;
+ }
lazyPrint();
- AssertionPrinter printer( stream, _assertionStats, includeResults );
+ AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
printer.print();
stream << std::endl;
return true;
@@ -10599,12 +9583,15 @@ namespace Catch {
stream << "\nNo assertions in test case";
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
}
- if( m_config->showDurations() == ShowDurations::Always ) {
- stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
- }
if( m_headerPrinted ) {
+ if( m_config->showDurations() == ShowDurations::Always )
+ stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
m_headerPrinted = false;
}
+ else {
+ if( m_config->showDurations() == ShowDurations::Always )
+ stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
+ }
StreamingReporterBase::sectionEnded( _sectionStats );
}
@@ -10617,7 +9604,7 @@ namespace Catch {
printSummaryDivider();
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
printTotals( _testGroupStats.totals );
- stream << '\n' << std::endl;
+ stream << "\n" << std::endl;
}
StreamingReporterBase::testGroupEnded( _testGroupStats );
}
@@ -10669,11 +9656,7 @@ namespace Catch {
case ResultWas::ThrewException:
colour = Colour::Error;
passOrFail = "FAILED";
- messageLabel = "due to unexpected exception with ";
- if (_stats.infoMessages.size() == 1)
- messageLabel += "message";
- if (_stats.infoMessages.size() > 1)
- messageLabel += "messages";
+ messageLabel = "due to unexpected exception with message";
break;
case ResultWas::FatalErrorCondition:
colour = Colour::Error;
@@ -10713,13 +9696,13 @@ namespace Catch {
printSourceInfo();
if( stats.totals.assertions.total() > 0 ) {
if( result.isOk() )
- stream << '\n';
+ stream << "\n";
printResultType();
printOriginalExpression();
printReconstructedExpression();
}
else {
- stream << '\n';
+ stream << "\n";
}
printMessage();
}
@@ -10736,25 +9719,25 @@ namespace Catch {
Colour colourGuard( Colour::OriginalExpression );
stream << " ";
stream << result.getExpressionInMacro();
- stream << '\n';
+ stream << "\n";
}
}
void printReconstructedExpression() const {
if( result.hasExpandedExpression() ) {
stream << "with expansion:\n";
Colour colourGuard( Colour::ReconstructedExpression );
- stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << '\n';
+ stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n";
}
}
void printMessage() const {
if( !messageLabel.empty() )
- stream << messageLabel << ':' << '\n';
+ stream << messageLabel << ":" << "\n";
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
it != itEnd;
++it ) {
// If this assertion is a warning ignore any INFO messages
if( printInfoMessages || it->type != ResultWas::Info )
- stream << Text( it->message, TextAttributes().setIndent(2) ) << '\n';
+ stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
}
}
void printSourceInfo() const {
@@ -10786,10 +9769,10 @@ namespace Catch {
}
}
void lazyPrintRunInfo() {
- stream << '\n' << getLineOfChars<'~'>() << '\n';
+ stream << "\n" << getLineOfChars<'~'>() << "\n";
Colour colour( Colour::SecondaryText );
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";
if( m_config->rngSeed() != 0 )
@@ -10817,22 +9800,22 @@ namespace Catch {
printHeaderString( it->name, 2 );
}
- SourceLineInfo lineInfo = m_sectionStack.back().lineInfo;
+ SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
if( !lineInfo.empty() ){
- stream << getLineOfChars<'-'>() << '\n';
+ stream << getLineOfChars<'-'>() << "\n";
Colour colourGuard( Colour::FileName );
- stream << lineInfo << '\n';
+ stream << lineInfo << "\n";
}
- stream << getLineOfChars<'.'>() << '\n' << std::endl;
+ stream << getLineOfChars<'.'>() << "\n" << std::endl;
}
void printClosedHeader( std::string const& _name ) {
printOpenHeader( _name );
- stream << getLineOfChars<'.'>() << '\n';
+ stream << getLineOfChars<'.'>() << "\n";
}
void printOpenHeader( std::string const& _name ) {
- stream << getLineOfChars<'-'>() << '\n';
+ stream << getLineOfChars<'-'>() << "\n";
{
Colour colourGuard( Colour::Headers );
printHeaderString( _name );
@@ -10849,7 +9832,7 @@ namespace Catch {
i = 0;
stream << Text( _string, TextAttributes()
.setIndent( indent+i)
- .setInitialIndent( indent ) ) << '\n';
+ .setInitialIndent( indent ) ) << "\n";
}
struct SummaryColumn {
@@ -10864,9 +9847,9 @@ namespace Catch {
std::string row = oss.str();
for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
while( it->size() < row.size() )
- *it = ' ' + *it;
+ *it = " " + *it;
while( it->size() > row.size() )
- row = ' ' + row;
+ row = " " + row;
}
rows.push_back( row );
return *this;
@@ -10886,8 +9869,8 @@ namespace Catch {
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
stream << " ("
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
- << pluralise( totals.testCases.passed, "test case" ) << ')'
- << '\n';
+ << pluralise( totals.testCases.passed, "test case" ) << ")"
+ << "\n";
}
else {
@@ -10922,10 +9905,10 @@ namespace Catch {
else if( value != "0" ) {
stream << Colour( Colour::LightGrey ) << " | ";
stream << Colour( it->colour )
- << value << ' ' << it->label;
+ << value << " " << it->label;
}
}
- stream << '\n';
+ stream << "\n";
}
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
@@ -10961,10 +9944,10 @@ namespace Catch {
else {
stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
}
- stream << '\n';
+ stream << "\n";
}
void printSummaryDivider() {
- stream << getLineOfChars<'-'>() << '\n';
+ stream << getLineOfChars<'-'>() << "\n";
}
private:
@@ -10999,10 +9982,11 @@ namespace Catch {
}
virtual void noMatchingTestCases( std::string const& spec ) {
- 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 ) {
AssertionResult const& result = _assertionStats.assertionResult;
@@ -11023,15 +10007,9 @@ namespace Catch {
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 ) {
printTotals( _testRunStats.totals );
- stream << '\n' << std::endl;
+ stream << "\n" << std::endl;
StreamingReporterBase::testRunEnded( _testRunStats );
}
@@ -11131,26 +10109,26 @@ namespace Catch {
void printSourceInfo() const {
Colour colourGuard( Colour::FileName );
- stream << result.getSourceInfo() << ':';
+ stream << result.getSourceInfo() << ":";
}
- void printResultType( Colour::Code colour, std::string const& passOrFail ) const {
+ void printResultType( Colour::Code colour, std::string passOrFail ) const {
if( !passOrFail.empty() ) {
{
Colour colourGuard( colour );
- stream << ' ' << passOrFail;
+ stream << " " << passOrFail;
}
- stream << ':';
+ stream << ":";
}
}
- void printIssue( std::string const& issue ) const {
- stream << ' ' << issue;
+ void printIssue( std::string issue ) const {
+ stream << " " << issue;
}
void printExpressionWas() {
if( result.hasExpression() ) {
- stream << ';';
+ stream << ";";
{
Colour colour( dimColour() );
stream << " expression was:";
@@ -11161,7 +10139,7 @@ namespace Catch {
void printOriginalExpression() const {
if( result.hasExpression() ) {
- stream << ' ' << result.getExpression();
+ stream << " " << result.getExpression();
}
}
@@ -11177,7 +10155,7 @@ namespace Catch {
void printMessage() {
if ( itMessage != messages.end() ) {
- stream << " '" << itMessage->message << '\'';
+ stream << " '" << itMessage->message << "'";
++itMessage;
}
}
@@ -11192,13 +10170,13 @@ namespace Catch {
{
Colour colourGuard( colour );
- stream << " with " << pluralise( N, "message" ) << ':';
+ stream << " with " << pluralise( N, "message" ) << ":";
}
for(; itMessage != itEnd; ) {
// If this assertion is a warning ignore any INFO messages
if( printInfoMessages || itMessage->type != ResultWas::Info ) {
- stream << " '" << itMessage->message << '\'';
+ stream << " '" << itMessage->message << "'";
if ( ++itMessage != itEnd ) {
Colour colourGuard( dimColour() );
stream << " and";
@@ -11224,7 +10202,7 @@ namespace Catch {
// - green: Passed [both/all] N tests cases with M assertions.
std::string bothOrAll( std::size_t count ) const {
- return count == 1 ? std::string() : count == 2 ? "both " : "all " ;
+ return count == 1 ? "" : count == 2 ? "both " : "all " ;
}
void printTotals( const Totals& totals ) const {
@@ -11235,12 +10213,12 @@ namespace Catch {
Colour colour( Colour::ResultError );
const std::string qualify_assertions_failed =
totals.assertions.failed == totals.assertions.total() ?
- bothOrAll( totals.assertions.failed ) : std::string();
+ bothOrAll( totals.assertions.failed ) : "";
stream <<
"Failed " << bothOrAll( totals.testCases.failed )
<< pluralise( totals.testCases.failed, "test case" ) << ", "
"failed " << qualify_assertions_failed <<
- pluralise( totals.assertions.failed, "assertion" ) << '.';
+ pluralise( totals.assertions.failed, "assertion" ) << ".";
}
else if( totals.assertions.total() == 0 ) {
stream <<
@@ -11252,14 +10230,14 @@ namespace Catch {
Colour colour( Colour::ResultError );
stream <<
"Failed " << pluralise( totals.testCases.failed, "test case" ) << ", "
- "failed " << pluralise( totals.assertions.failed, "assertion" ) << '.';
+ "failed " << pluralise( totals.assertions.failed, "assertion" ) << ".";
}
else {
Colour colour( Colour::ResultSuccess );
stream <<
"Passed " << bothOrAll( totals.testCases.passed )
<< pluralise( totals.testCases.passed, "test case" ) <<
- " with " << pluralise( totals.assertions.passed, "assertion" ) << '.';
+ " with " << pluralise( totals.assertions.passed, "assertion" ) << ".";
}
}
};
@@ -11315,7 +10293,11 @@ namespace Catch {
TestSpec::NamePattern::~NamePattern() {}
TestSpec::TagPattern::~TagPattern() {}
TestSpec::ExcludedPattern::~ExcludedPattern() {}
- Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {}
+
+ Matchers::Impl::StdString::Equals::~Equals() {}
+ Matchers::Impl::StdString::Contains::~Contains() {}
+ Matchers::Impl::StdString::StartsWith::~StartsWith() {}
+ Matchers::Impl::StdString::EndsWith::~EndsWith() {}
void Config::dummy() {}
@@ -11339,16 +10321,9 @@ namespace Catch {
#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
int main (int argc, char * argv[]) {
-#endif
-
- int result = Catch::Session().run( argc, argv );
- return ( result < 0xff ? result : 0xff );
+ return Catch::Session().run( argc, argv );
}
#else // __OBJC__
@@ -11366,7 +10341,7 @@ int main (int argc, char * const argv[]) {
[pool drain];
#endif
- return ( result < 0xff ? result : 0xff );
+ return result;
}
#endif // __OBJC__
@@ -11382,43 +10357,33 @@ int main (int argc, char * const argv[]) {
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
#ifdef CATCH_CONFIG_PREFIX_ALL
-#if defined(CATCH_CONFIG_FAST_COMPILE)
-#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( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
+#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
-#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "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_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
+#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
+#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
-#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
-#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
-#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
-#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_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" )
+#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" )
+#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" )
+#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( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
-#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
-#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
-#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr )
+#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
+#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
+#define CATCH_CHECK_THROWS_WITH( expr, 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( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
+#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
+#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
-#if defined(CATCH_CONFIG_FAST_COMPILE)
-#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( "CATCH_INFO", 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( "CATCH_INFO", msg )
-#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
-#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
+#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
+#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg )
+#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
+#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
+#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
@@ -11426,18 +10391,16 @@ 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_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
- #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __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__ )
+ #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
+ #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
#else
#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_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
#define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
- #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, 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 )
+ #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
+ #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
#endif
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
@@ -11463,63 +10426,50 @@ int main (int argc, char * const argv[]) {
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
#else
-#if defined(CATCH_CONFIG_FAST_COMPILE)
-#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( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
+#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
-#else
-#define REQUIRE( expr ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, expr )
-#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
-#endif
+#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
+#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
+#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
+#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
-#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr )
-#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
-#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
-#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr )
+#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
+#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" )
+#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" )
+#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
+#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
-#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
-#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
-#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
-#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_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
+#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
+#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
+#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
-#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
-#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 CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
+#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
-#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
-
-#if defined(CATCH_CONFIG_FAST_COMPILE)
-#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
-#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) )
+#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
+#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
+#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
+#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
+#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
#ifdef CATCH_CONFIG_VARIADIC_MACROS
-#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __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 REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
-#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
-#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __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__ )
+ #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __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 REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
+ #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
+ #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
+ #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
#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 METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
#define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
- #define FAIL( msg ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, 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 )
+ #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
+ #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
#endif
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
@@ -11548,19 +10498,5 @@ int main (int argc, char * const argv[]) {
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