diff options
| author | Phil Nash | 2017-09-19 17:42:20 +0100 |
|---|---|---|
| committer | Phil Nash | 2017-09-19 17:42:20 +0100 |
| commit | bd46f66754f11b5644913f6eb8a1900971f3e0ad (patch) | |
| tree | 0f721cf23587f061cf70ccc85dd0fd5d4b2b7cdd | |
| parent | e9f0773f37e896a17701b57ea6ff83902a713381 (diff) | |
| download | catch3-2.0.0-develop.4.tar.gz | |
dev build 4v2.0.0-develop.4
| -rw-r--r-- | conanfile.py | 2 | ||||
| -rw-r--r-- | include/internal/catch_version.cpp | 2 | ||||
| -rw-r--r-- | single_include/catch.hpp | 3707 | ||||
| -rw-r--r-- | test_package/conanfile.py | 2 |
4 files changed, 1914 insertions, 1799 deletions
diff --git a/conanfile.py b/conanfile.py index 506235ae..d1dfa81d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -4,7 +4,7 @@ from conans import ConanFile class CatchConan(ConanFile): name = "Catch" - version = "2.0.0-develop.3" + version = "2.0.0-develop.4" description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD" author = "philsquared" generators = "cmake" diff --git a/include/internal/catch_version.cpp b/include/internal/catch_version.cpp index 36f58e22..b635800b 100644 --- a/include/internal/catch_version.cpp +++ b/include/internal/catch_version.cpp @@ -37,7 +37,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 0, 0, "develop", 3 ); + static Version version( 2, 0, 0, "develop", 4 ); return version; } diff --git a/single_include/catch.hpp b/single_include/catch.hpp index c775b8db..e5ae6198 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.0.0-develop.3 - * Generated: 2017-08-30 12:15:54.096665 + * Catch v2.0.0-develop.4 + * Generated: 2017-09-19 17:37:34.480115 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. @@ -47,6 +47,9 @@ #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) # define CATCH_IMPL # define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif #endif // start catch_platform.h @@ -106,10 +109,11 @@ #ifdef __clang__ -# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ _Pragma( "clang diagnostic pop" ) # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ @@ -149,7 +153,13 @@ // Visual C++ #ifdef _MSC_VER -#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif #endif // _MSC_VER @@ -179,9 +189,9 @@ # 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 +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS #endif // end catch_compiler_capabilities.h @@ -193,17 +203,12 @@ # 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 <iosfwd> #include <string> #include <cstdint> namespace Catch { - struct IConfig; - struct CaseSensitive { enum Choice { Yes, No @@ -216,7 +221,7 @@ namespace Catch { NonCopyable& operator = ( NonCopyable && ) = delete; protected: - NonCopyable() {} + NonCopyable(); virtual ~NonCopyable(); }; @@ -245,9 +250,6 @@ namespace Catch { bool alwaysTrue(); bool alwaysFalse(); - void seedRng( IConfig const& config ); - unsigned int rngSeed(); - // Use this in variadic streaming macros to allow // >> +StreamEndStop // as well as @@ -276,7 +278,7 @@ namespace Catch { #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } // end catch_tag_alias_autoregistrar.h -// start catch_test_registry.hpp +// start catch_test_registry.h // start catch_interfaces_testcase.h @@ -330,7 +332,7 @@ namespace Catch { class StringRef { friend struct StringRefTestAccess; - using size_type = size_t; + using size_type = std::size_t; char const* m_start; size_type m_size; @@ -412,7 +414,7 @@ struct NameAndTags { struct AutoReg : NonCopyable { AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept; - ~AutoReg() = default; + ~AutoReg(); }; } // end namespace Catch @@ -433,40 +435,40 @@ struct AutoReg : NonCopyable { /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ static void TestName(); \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ 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 \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ namespace{ \ struct TestName : ClassName{ \ void test(); \ }; \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_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_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS -// end catch_test_registry.hpp +// end catch_test_registry.h // start catch_capture.hpp // start catch_assertionhandler.h @@ -528,6 +530,11 @@ inline id performOptionalSelector( id obj, SEL sel ) { // end catch_objc_arc.hpp #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#endif + // We need a dummy global operator<< so we can bring it into Catch namespace later struct Catch_global_namespace_dummy; std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); @@ -801,20 +808,33 @@ namespace Catch { #ifdef __OBJC__ template<> struct StringMaker<NSString*> { - static std::string convert(NSString* nsstring); - }; - template<> - struct StringMaker<NSString* CATCH_ARC_STRONG> { - static std::string convert(NSString * CATCH_ARC_STRONG nsstring); + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } }; template<> - struct StringMaker<NSObject *> { - static std::string convert(NSObject* nsObject); + struct StringMaker<NSObject*> { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + }; -#endif + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker<NSString*>::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ } // namespace Catch +#ifdef _MSC_VER +#pragma warning(pop) +#endif + // end catch_tostring.h #include <ostream> @@ -823,6 +843,7 @@ namespace Catch { #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #pragma warning(disable:4018) // more "signed/unsigned mismatch" #pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning #endif namespace Catch { @@ -834,16 +855,16 @@ namespace Catch { // We don't actually need a virtual destructore, but many static analysers // complain if it's not here :-( - virtual ~ITransientExpression() = default; + virtual ~ITransientExpression(); }; - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, std::string const& op, std::string const& rhs ); + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); template<typename LhsT, typename RhsT> class BinaryExpr : public ITransientExpression { bool m_result; LhsT m_lhs; - std::string m_op; + StringRef m_op; RhsT m_rhs; auto isBinaryExpression() const -> bool override { return true; } @@ -855,8 +876,8 @@ namespace Catch { } public: - BinaryExpr( bool comparisionResult, LhsT lhs, StringRef op, RhsT rhs ) - : m_result( comparisionResult ), + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : m_result( comparisonResult ), m_lhs( lhs ), m_op( op ), m_rhs( rhs ) @@ -880,26 +901,26 @@ namespace Catch { // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) template<typename LhsT, typename RhsT> - auto compareEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return const_cast<LhsT&>( lhs ) == rhs; }; + auto compareEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs == rhs; }; template<typename T> - auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }; + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } template<typename T> - auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }; + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } template<typename T> - auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }; + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } template<typename T> - auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }; + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } template<typename LhsT, typename RhsT> - auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return const_cast<LhsT&>( lhs ) != rhs; }; + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs != rhs; }; template<typename T> - auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }; + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } template<typename T> - auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }; + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } template<typename T> - auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }; + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } template<typename T> - auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }; + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } template<typename LhsT> class ExprLhs { @@ -954,10 +975,6 @@ namespace Catch { struct Decomposer { template<typename T> - auto operator <= ( T& lhs ) -> ExprLhs<T&> { - return ExprLhs<T&>( lhs ); - } - template<typename T> auto operator <= ( T const& lhs ) -> ExprLhs<T const&> { return ExprLhs<T const&>( lhs ); } @@ -968,10 +985,6 @@ namespace Catch { } // end namespace Catch -#ifdef _MSC_VER -#pragma warning(pop) -#endif - // end catch_decomposer.h // start catch_assertioninfo.h @@ -1111,9 +1124,9 @@ namespace Catch { ResultWas::OfType _type ); std::string macroName; + std::string message; SourceLineInfo lineInfo; ResultWas::OfType type; - std::string message; unsigned int sequence; bool operator == ( MessageInfo const& other ) const; @@ -1165,13 +1178,11 @@ namespace Catch { namespace Catch { - class TestCase; class AssertionResult; struct AssertionInfo; struct SectionInfo; struct SectionEndInfo; struct MessageInfo; - class ScopedMessageBuilder; struct Counts; struct BenchmarkInfo; struct BenchmarkStats; @@ -1198,7 +1209,7 @@ namespace Catch { virtual void exceptionEarlyReported() = 0; - virtual void handleFatalErrorCondition( std::string const& message ) = 0; + virtual void handleFatalErrorCondition( StringRef message ) = 0; virtual bool lastAssertionPassed() = 0; virtual void assertionPassed() = 0; @@ -1209,32 +1220,6 @@ namespace Catch { } // end catch_interfaces_capture.h -#if !defined(CATCH_CONFIG_DISABLE) - -#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) - #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ -#else - #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" -#endif - -#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( handler ) \ - handler.reactWithDebugBreak(); - -/////////////////////////////////////////////////////////////////////////////// -// 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_TRY( capturer ) capturer.setExceptionGuard(); -#define INTERNAL_CATCH_CATCH( capturer ) capturer.unsetExceptionGuard(); - -#else // CATCH_CONFIG_FAST_COMPILE - // start catch_debugger.h namespace Catch { @@ -1270,6 +1255,32 @@ namespace Catch { #endif // end catch_debugger.h +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#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( handler ) \ + handler.reactWithDebugBreak(); + +/////////////////////////////////////////////////////////////////////////////// +// 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_TRY( capturer ) capturer.setExceptionGuard(); +#define INTERNAL_CATCH_CATCH( capturer ) capturer.unsetExceptionGuard(); + +#else // CATCH_CONFIG_FAST_COMPILE + /////////////////////////////////////////////////////////////////////////////// // In the event of a failure works out if the debugger needs to be invoked // and/or an exception thrown and takes appropriate action. @@ -1395,7 +1406,7 @@ namespace Catch { // start catch_section_info.h -// start catch_totals.hpp +// start catch_totals.h #include <cstddef> @@ -1426,7 +1437,7 @@ namespace Catch { }; } -// end catch_totals.hpp +// end catch_totals.h #include <string> namespace Catch { @@ -1512,8 +1523,8 @@ namespace Catch { class BenchmarkLooper { std::string m_name; - size_t m_count = 0; - size_t m_iterationsToRun = 1; + std::size_t m_count = 0; + std::size_t m_iterationsToRun = 1; uint64_t m_resolution; Timer m_timer; @@ -1666,7 +1677,7 @@ namespace Catch { #define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) // end catch_interfaces_exception.h -// start catch_approx.hpp +// start catch_approx.h #include <cmath> @@ -1777,31 +1788,39 @@ struct StringMaker<Catch::Detail::Approx> { } // end namespace Catch -// end catch_approx.hpp -// start catch_interfaces_tag_alias_registry.h +// end catch_approx.h +// start catch_string_manip.h #include <string> +#include <iosfwd> namespace Catch { - struct TagAlias; + 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 ); + std::string trim( std::string const& str ); + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); - struct ITagAliasRegistry { - virtual ~ITagAliasRegistry(); - // Nullptr if not present - virtual TagAlias const* find( std::string const& alias ) const = 0; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + struct pluralise { + pluralise( std::size_t count, std::string const& label ); - static ITagAliasRegistry const& get(); - }; + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); -} // end namespace Catch + std::size_t m_count; + std::string m_label; + }; +} -// end catch_interfaces_tag_alias_registry.h +// end catch_string_manip.h #ifndef CATCH_CONFIG_DISABLE_MATCHERS // start catch_capture_matchers.h -// start catch_matchers.hpp +// start catch_matchers.h #include <string> #include <vector> @@ -1822,7 +1841,7 @@ namespace Matchers { std::string toString() const; protected: - virtual ~MatcherUntypedBase() = default; + virtual ~MatcherUntypedBase(); virtual std::string describe() const = 0; mutable std::string m_cachedToString; }; @@ -1940,30 +1959,6 @@ namespace Matchers { } // namespace Impl - // The following functions create the actual matcher objects. - // This allows the types to be inferred - // - deprecated: prefer ||, && and ! - template<typename T> - Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) { - return Impl::MatchNotOf<T>( underlyingMatcher ); - } - template<typename T> - Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) { - return Impl::MatchAllOf<T>() && m1 && m2; - } - template<typename T> - 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 T> - Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) { - return Impl::MatchAnyOf<T>() || m1 || m2; - } - template<typename T> - 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; - } - } // namespace Matchers using namespace Matchers; @@ -1971,7 +1966,7 @@ using Matchers::Impl::MatcherBase; } // namespace Catch -// end catch_matchers.hpp +// end catch_matchers.h // start catch_matchers_string.h #include <string> @@ -2100,7 +2095,7 @@ namespace Matchers { // - then just call that directly if (m_comparator.size() != v.size()) return false; - for (size_t i = 0; i < v.size(); ++i) + for (std::size_t i = 0; i < v.size(); ++i) if (m_comparator[i] != v[i]) return false; return true; @@ -2293,7 +2288,6 @@ namespace Catch { // start catch_interfaces_runner.h namespace Catch { - class TestCase; struct IRunner { virtual ~IRunner(); @@ -2364,8 +2358,8 @@ namespace Catch { } } - inline size_t registerTestMethods() { - size_t noTestMethods = 0; + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; int noClasses = objc_getClassList( nullptr, 0 ); Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); @@ -2385,7 +2379,7 @@ namespace Catch { std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); const char* className = class_getName( cls ); - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo("",0) ) ); noTestMethods++; } } @@ -2412,7 +2406,7 @@ namespace Catch { return false; } - NSString* m_substr; + NSString* CATCH_ARC_STRONG m_substr; }; struct Equals : StringHolder { @@ -2424,7 +2418,7 @@ namespace Catch { } std::string describe() const override { - return "equals string: " + Catch::toString( m_substr ); + return "equals string: " + Catch::Detail::stringify( m_substr ); } }; @@ -2437,7 +2431,7 @@ namespace Catch { } std::string describe() const override { - return "contains string: " + Catch::toString( m_substr ); + return "contains string: " + Catch::Detail::stringify( m_substr ); } }; @@ -2450,7 +2444,7 @@ namespace Catch { } std::string describe() const override { - return "starts with: " + Catch::toString( m_substr ); + return "starts with: " + Catch::Detail::stringify( m_substr ); } }; struct EndsWith : StringHolder { @@ -2462,7 +2456,7 @@ namespace Catch { } std::string describe() const override { - return "ends with: " + Catch::toString( m_substr ); + return "ends with: " + Catch::Detail::stringify( m_substr ); } }; @@ -2490,16 +2484,19 @@ namespace Catch { } // namespace Catch /////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ { \ return @ desc; \ } \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) // end catch_objc.hpp #endif @@ -2528,21 +2525,21 @@ return @ desc; \ // start catch_config.hpp -// start catch_test_spec_parser.hpp +// start catch_test_spec_parser.h #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif -// start catch_test_spec.hpp +// start catch_test_spec.h #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif -// start catch_wildcard_pattern.hpp +// start catch_wildcard_pattern.h namespace Catch { @@ -2568,7 +2565,7 @@ namespace Catch }; } -// end catch_wildcard_pattern.hpp +// end catch_wildcard_pattern.h #include <string> #include <vector> #include <memory> @@ -2577,7 +2574,7 @@ namespace Catch { class TestSpec { struct Pattern { - virtual ~Pattern() = default; + virtual ~Pattern(); virtual bool matches( TestCaseInfo const& testCase ) const = 0; }; using PatternPtr = std::shared_ptr<Pattern>; @@ -2585,7 +2582,7 @@ namespace Catch { class NamePattern : public Pattern { public: NamePattern( std::string const& name ); - virtual ~NamePattern() = default; + virtual ~NamePattern(); virtual bool matches( TestCaseInfo const& testCase ) const override; private: WildcardPattern m_wildcardPattern; @@ -2594,7 +2591,7 @@ namespace Catch { class TagPattern : public Pattern { public: TagPattern( std::string const& tag ); - virtual ~TagPattern() = default; + virtual ~TagPattern(); virtual bool matches( TestCaseInfo const& testCase ) const override; private: std::string m_tag; @@ -2603,7 +2600,7 @@ namespace Catch { class ExcludedPattern : public Pattern { public: ExcludedPattern( PatternPtr const& underlyingPattern ); - virtual ~ExcludedPattern() = default; + virtual ~ExcludedPattern(); virtual bool matches( TestCaseInfo const& testCase ) const override; private: PatternPtr m_underlyingPattern; @@ -2630,35 +2627,27 @@ namespace Catch { #pragma clang diagnostic pop #endif -// end catch_test_spec.hpp -// start catch_string_manip.h +// end catch_test_spec.h +// start catch_interfaces_tag_alias_registry.h #include <string> -#include <iosfwd> 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 ); - std::string trim( std::string const& str ); - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); - - struct pluralise { - pluralise( std::size_t count, std::string const& label ); + struct TagAlias; - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; - std::size_t m_count; - std::string m_label; + static ITagAliasRegistry const& get(); }; -} -// end catch_string_manip.h +} // end namespace Catch + +// end catch_interfaces_tag_alias_registry.h namespace Catch { class TestSpecParser { @@ -2687,7 +2676,7 @@ namespace Catch { template<typename T> void addPattern() { std::string token = subString(); - for( size_t i = 0; i < m_escapeChars.size(); ++i ) + for( std::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:" ) ) { @@ -2714,7 +2703,7 @@ namespace Catch { #pragma clang diagnostic pop #endif -// end catch_test_spec_parser.hpp +// end catch_test_spec_parser.h // start catch_interfaces_config.h #include <iosfwd> @@ -2785,6 +2774,71 @@ namespace Catch { } // end catch_interfaces_config.h +// Libstdc++ doesn't like incomplete classes for unique_ptr +// start catch_stream.h + +// start catch_streambuf.h + +#include <streambuf> + +namespace Catch { + + class StreamBufBase : public std::streambuf { + public: + virtual ~StreamBufBase(); + }; +} + +// end catch_streambuf.h +#include <streambuf> +#include <ostream> +#include <fstream> +#include <memory> + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + + struct IStream { + virtual ~IStream(); + virtual std::ostream& stream() const = 0; + }; + + class FileStream : public IStream { + mutable std::ofstream m_ofs; + public: + FileStream( std::string const& filename ); + ~FileStream() override = default; + public: // IStream + std::ostream& stream() const override; + }; + + class CoutStream : public IStream { + mutable std::ostream m_os; + public: + CoutStream(); + ~CoutStream() override = default; + + public: // IStream + std::ostream& stream() const override; + }; + + class DebugOutStream : public IStream { + std::unique_ptr<StreamBufBase> m_streamBuf; + mutable std::ostream m_os; + public: + DebugOutStream(); + ~DebugOutStream() override = default; + + public: // IStream + std::ostream& stream() const override; + }; +} + +// end catch_stream.h + #include <memory> #include <vector> #include <string> @@ -2832,7 +2886,6 @@ namespace Catch { }; class Config : public IConfig { - virtual void dummy(); public: Config() = default; @@ -2895,13 +2948,12 @@ namespace Catch { AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); - ResultWas::OfType resultType = ResultWas::Unknown; std::string message; - + mutable std::string reconstructedExpression; LazyExpression lazyExpression; |