/srv/osrm/osrm-backend/third_party/variant/test/include
Edit: /srv/osrm/osrm-backend/third_party/variant/test/include/catch.hpp (352026B)
/*
* Catch v1.3.2
* Generated: 2015-12-28 15:07:07.166291
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_HPP_INCLUDED
#ifdef __clang__
#pragma clang system_header
#elif defined __GNUC__
#pragma GCC system_header
#endif
// #included from: internal/catch_suppress_warnings.h
#ifdef __clang__
#ifdef __ICC // icpc defines the __clang__ macro
#pragma warning(push)
#pragma warning(disable : 161 1682)
#else // __ICC
#pragma clang diagnostic ignored "-Wglobal-constructors"
#pragma clang diagnostic ignored "-Wvariadic-macros"
#pragma clang diagnostic ignored "-Wc99-extensions"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wswitch-enum"
#pragma clang diagnostic ignored "-Wcovered-switch-default"
#endif
#elif defined __GNUC__
#pragma GCC diagnostic ignored "-Wvariadic-macros"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
#endif
#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
#define CATCH_IMPL
#endif
#ifdef CATCH_IMPL
#ifndef CLARA_CONFIG_MAIN
#define CLARA_CONFIG_MAIN_NOT_DEFINED
#define CLARA_CONFIG_MAIN
#endif
#endif
// #included from: internal/catch_notimplemented_exception.h
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
// #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)
#define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __LINE__)
#define INTERNAL_CATCH_STRINGIFY2(expr) #expr
#define INTERNAL_CATCH_STRINGIFY(expr) INTERNAL_CATCH_STRINGIFY2(expr)
#include
#include
#include
// #included from: catch_compiler_capabilities.h
#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
// The following features are defined:
//
// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported?
// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
// 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_OR_GREATER : Is C++11 supported?
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// ****************
// Note to maintainers: if new toggles are added please document them
// in configuration.md, too
// ****************
// In general each macro has a _NO_ form
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __clang__
#if __has_feature(cxx_nullptr)
#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
#if __has_feature(cxx_noexcept)
#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#endif
#endif // __clang__
////////////////////////////////////////////////////////////////////////////////
// Borland
#ifdef __BORLANDC__
#endif // __BORLANDC__
////////////////////////////////////////////////////////////////////////////////
// EDG
#ifdef __EDG_VERSION__
#endif // __EDG_VERSION__
////////////////////////////////////////////////////////////////////////////////
// Digital Mars
#ifdef __DMC__
#endif // __DMC__
////////////////////////////////////////////////////////////////////////////////
// GCC
#ifdef __GNUC__
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
// - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below
#endif // __GNUC__
////////////////////////////////////////////////////////////////////////////////
// Visual C++
#ifdef _MSC_VER
#if (_MSC_VER >= 1600)
#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
#endif
#if (_MSC_VER >= 1900) // (VC++ 13 (VS2015))
#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif
#endif // _MSC_VER
////////////////////////////////////////////////////////////////////////////////
// Use variadic macros if the compiler supports them
#if (defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
(defined __WAVE__ && __WAVE_HAS_VARIADICS) || \
(defined __GNUC__ && __GNUC__ >= 3) || \
(!defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L)
#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#endif
////////////////////////////////////////////////////////////////////////////////
// C++ language feature support
// catch all support for C++11
#if defined(__cplusplus) && __cplusplus >= 201103L
#define CATCH_CPP11_OR_GREATER
#if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
#define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
#ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
#endif
#ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif
#ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
#define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
#endif
#ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
#define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
#endif
#ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#endif
#if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
#define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
#endif
#if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
#define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
#endif
#if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
#define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
#endif
#endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_NULLPTR
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_IS_ENUM
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_TUPLE
#endif
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
#define CATCH_CONFIG_VARIADIC_MACROS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_LONG_LONG
#endif
#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_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
#define CATCH_CONFIG_CPP11_UNIQUE_PTR
#endif
// noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
#define CATCH_NOEXCEPT noexcept
#define CATCH_NOEXCEPT_IS(x) noexcept(x)
#else
#define CATCH_NOEXCEPT throw()
#define CATCH_NOEXCEPT_IS(x)
#endif
// nullptr support
#ifdef CATCH_CONFIG_CPP11_NULLPTR
#define CATCH_NULL nullptr
#else
#define CATCH_NULL NULL
#endif
// override support
#ifdef CATCH_CONFIG_CPP11_OVERRIDE
#define CATCH_OVERRIDE override
#else
#define CATCH_OVERRIDE
#endif
// unique_ptr support
#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
#define CATCH_AUTO_PTR(T) std::unique_ptr
#else
#define CATCH_AUTO_PTR(T) std::auto_ptr
#endif
namespace Catch {
struct IConfig;
struct CaseSensitive
{
enum Choice
{
Yes,
No
};
};
class NonCopyable
{
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
NonCopyable(NonCopyable const&) = delete;
NonCopyable(NonCopyable&&) = delete;
NonCopyable& operator=(NonCopyable const&) = delete;
NonCopyable& operator=(NonCopyable&&) = delete;
#else
NonCopyable(NonCopyable const& info);
NonCopyable& operator=(NonCopyable const&);
#endif
protected:
NonCopyable() {}
virtual ~NonCopyable();
};
class SafeBool
{
public:
typedef void (SafeBool::*type)() const;
static type makeSafe(bool value)
{
return value ? &SafeBool::trueValue : 0;
}
private:
void trueValue() const {}
};
template
inline void deleteAll(ContainerT& container)
{
typename ContainerT::const_iterator it = container.begin();
typename ContainerT::const_iterator itEnd = container.end();
for (; it != itEnd; ++it)
delete *it;
}
template
inline void deleteAllValues(AssociativeContainerT& container)
{
typename AssociativeContainerT::const_iterator it = container.begin();
typename AssociativeContainerT::const_iterator itEnd = container.end();
for (; it != itEnd; ++it)
delete it->second;
}
bool startsWith(std::string const& s, std::string const& prefix);
bool endsWith(std::string const& s, std::string const& 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);
friend std::ostream& operator<<(std::ostream& os, pluralise const& pluraliser);
std::size_t m_count;
std::string m_label;
};
struct SourceLineInfo
{
SourceLineInfo();
SourceLineInfo(char const* _file, std::size_t _line);
SourceLineInfo(SourceLineInfo const& other);
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
SourceLineInfo(SourceLineInfo&&) = default;
SourceLineInfo& operator=(SourceLineInfo const&) = default;
SourceLineInfo& operator=(SourceLineInfo&&) = default;
#endif
bool empty() const;
bool operator==(SourceLineInfo const& other) const;
bool operator<(SourceLineInfo const& other) const;
std::string file;
std::size_t line;
};
std::ostream& operator<<(std::ostream& os, SourceLineInfo const& info);
// This is just here to avoid compiler warnings with macro constants and boolean literals
inline bool isTrue(bool value) { return value; }
inline bool alwaysTrue() { return true; }
inline bool alwaysFalse() { return false; }
void throwLogicError(std::string const& message, SourceLineInfo const& locationInfo);
void seedRng(IConfig const& config);
unsigned int rngSeed();
// Use this in variadic streaming macros to allow
// >> +StreamEndStop
// as well as
// >> stuff +StreamEndStop
struct StreamEndStop
{
std::string operator+()
{
return std::string();
}
};
template
T const& operator+(T const& value, StreamEndStop)
{
return value;
}
}
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo(__FILE__, static_cast(__LINE__))
#define CATCH_INTERNAL_ERROR(msg) ::Catch::throwLogicError(msg, CATCH_INTERNAL_LINEINFO);
#include
namespace Catch {
class NotImplementedException : public std::exception
{
public:
NotImplementedException(SourceLineInfo const& lineInfo);
NotImplementedException(NotImplementedException const&) {}
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
virtual const char* what() const CATCH_NOEXCEPT;
private:
std::string m_what;
SourceLineInfo m_lineInfo;
};
} // end namespace Catch
///////////////////////////////////////////////////////////////////////////////
#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException(CATCH_INTERNAL_LINEINFO)
// #included from: internal/catch_context.h
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
// #included from: catch_interfaces_generators.h
#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
#include
namespace Catch {
struct IGeneratorInfo
{
virtual ~IGeneratorInfo();
virtual bool moveNext() = 0;
virtual std::size_t getCurrentIndex() const = 0;
};
struct IGeneratorsForTest
{
virtual ~IGeneratorsForTest();
virtual IGeneratorInfo& getGeneratorInfo(std::string const& fileInfo, std::size_t size) = 0;
virtual bool moveNext() = 0;
};
IGeneratorsForTest* createGeneratorsForTest();
} // end namespace Catch
// #included from: catch_ptr.hpp
#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch {
// An intrusive reference counting smart pointer.
// T must implement addRef() and release() methods
// typically implementing the IShared interface
template
class Ptr
{
public:
Ptr() : m_p(CATCH_NULL) {}
Ptr(T* p) : m_p(p)
{
if (m_p)
m_p->addRef();
}
Ptr(Ptr const& other) : m_p(other.m_p)
{
if (m_p)
m_p->addRef();
}
~Ptr()
{
if (m_p)
m_p->release();
}
void reset()
{
if (m_p)
m_p->release();
m_p = CATCH_NULL;
}
Ptr& operator=(T* p)
{
Ptr temp(p);
swap(temp);
return *this;
}
Ptr& operator=(Ptr const& other)
{
Ptr temp(other);
swap(temp);
return *this;
}
void swap(Ptr& other) { std::swap(m_p, other.m_p); }
T* get() const { return m_p; }
T& operator*() const { return *m_p; }
T* operator->() const { return m_p; }
bool operator!() const { return m_p == CATCH_NULL; }
operator SafeBool::type() const { return SafeBool::makeSafe(m_p != CATCH_NULL); }
private:
T* m_p;
};
struct IShared : NonCopyable
{
virtual ~IShared();
virtual void addRef() const = 0;
virtual void release() const = 0;
};
template
struct SharedImpl : T
{
SharedImpl() : m_rc(0) {}
virtual void addRef() const
{
++m_rc;
}
virtual void release() const
{
if (--m_rc == 0)
delete this;
}
mutable unsigned int m_rc;
};
} // end namespace Catch
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#include
#include
#include
namespace Catch {
class TestCase;
class Stream;
struct IResultCapture;
struct IRunner;
struct IGeneratorsForTest;
struct IConfig;
struct IContext
{
virtual ~IContext();
virtual IResultCapture* getResultCapture() = 0;
virtual IRunner* getRunner() = 0;
virtual size_t getGeneratorIndex(std::string const& fileInfo, size_t totalSize) = 0;
virtual bool advanceGeneratorsForCurrentTest() = 0;
virtual Ptr getConfig() const = 0;
};
struct IMutableContext : IContext
{
virtual ~IMutableContext();
virtual void setResultCapture(IResultCapture* resultCapture) = 0;
virtual void setRunner(IRunner* runner) = 0;
virtual void setConfig(Ptr const& config) = 0;
};
IContext& getCurrentContext();
IMutableContext& getCurrentMutableContext();
void cleanUpContext();
Stream createStream(std::string const& streamName);
}
// #included from: internal/catch_test_registry.hpp
#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
// #included from: catch_interfaces_testcase.h
#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
#include
namespace Catch {
class TestSpec;
struct ITestCase : IShared
{
virtual void invoke() const = 0;
protected:
virtual ~ITestCase();
};
class TestCase;
struct IConfig;
struct ITestCaseRegistry
{
virtual ~ITestCaseRegistry();
virtual std::vector const& getAllTests() const = 0;
virtual std::vector const& getAllTestsSorted(IConfig const& config) const = 0;
};
bool matchTest(TestCase const& testCase, TestSpec const& testSpec, IConfig const& config);
std::vector filterTests(std::vector const& testCases, TestSpec const& testSpec, IConfig const& config);
std::vector const& getAllTestCasesSorted(IConfig const& config);
}
namespace Catch {
template
class MethodTestCase : public SharedImpl
{
public:
MethodTestCase(void (C::*method)()) : m_method(method) {}
virtual void invoke() const
{
C obj;
(obj.*m_method)();
}
private:
virtual ~MethodTestCase() {}
void (C::*m_method)();
};
typedef void (*TestFunction)();
struct NameAndDesc
{
NameAndDesc(const char* _name = "", const char* _description = "")
: name(_name), description(_description)
{
}
const char* name;
const char* description;
};
void registerTestCase(ITestCase* testCase,
char const* className,
NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo);
struct AutoReg
{
AutoReg(TestFunction function,
SourceLineInfo const& lineInfo,
NameAndDesc const& nameAndDesc);
template
AutoReg(void (C::*method)(),
char const* className,
NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo)
{
registerTestCase(new MethodTestCase(method),
className,
nameAndDesc,
lineInfo);
}
~AutoReg();
private:
AutoReg(AutoReg const&);
void operator=(AutoReg const&);
};
void registerTestCaseFunction(TestFunction function,
SourceLineInfo const& lineInfo,
NameAndDesc const& nameAndDesc);
} // end namespace Catch
#ifdef CATCH_CONFIG_VARIADIC_MACROS
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE(...) \
static void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)(); \
namespace { \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(__VA_ARGS__)); \
} \
static void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)()
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE(QualifiedMethod, ...) \
namespace { \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc(__VA_ARGS__), CATCH_INTERNAL_LINEINFO); \
}
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD(ClassName, ...) \
namespace { \
struct INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____) : ClassName \
{ \
void test(); \
}; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)::test, #ClassName, Catch::NameAndDesc(__VA_ARGS__), CATCH_INTERNAL_LINEINFO); \
} \
void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)::test()
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE(Function, ...) \
Catch::AutoReg(Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(__VA_ARGS__));
#else
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE(Name, Desc) \
static void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)(); \
namespace { \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(Name, Desc)); \
} \
static void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)()
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE(QualifiedMethod, Name, Desc) \
namespace { \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc(Name, Desc), CATCH_INTERNAL_LINEINFO); \
}
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST_CASE_METHOD(ClassName, TestName, Desc) \
namespace { \
struct INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____) : ClassName \
{ \
void test(); \
}; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(&INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)::test, #ClassName, Catch::NameAndDesc(TestName, Desc), CATCH_INTERNAL_LINEINFO); \
} \
void INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____T_E_S_T____)::test()
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_REGISTER_TESTCASE(Function, Name, Desc) \
Catch::AutoReg(Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(Name, Desc));
#endif
// #included from: internal/catch_capture.hpp
#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
// #included from: catch_result_builder.h
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
// #included from: catch_result_type.h
#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
namespace Catch {
// ResultWas::OfType enum
struct ResultWas
{
enum OfType
{
Unknown = -1,
Ok = 0,
Info = 1,
Warning = 2,
FailureBit = 0x10,
ExpressionFailed = FailureBit | 1,
ExplicitFailure = FailureBit | 2,
Exception = 0x100 | FailureBit,
ThrewException = Exception | 1,
DidntThrowException = Exception | 2,
FatalErrorCondition = 0x200 | FailureBit
};
};
inline bool isOk(ResultWas::OfType resultType)
{
return (resultType & ResultWas::FailureBit) == 0;
}
inline bool isJustInfo(int flags)
{
return flags == ResultWas::Info;
}
// ResultDisposition::Flags enum
struct ResultDisposition
{
enum Flags
{
Normal = 0x01,
ContinueOnFailure = 0x02, // Failures fail test, but execution continues
FalseTest = 0x04, // Prefix expression with !
SuppressFail = 0x08 // Failures are reported but do not fail the test
};
};
inline ResultDisposition::Flags operator|(ResultDisposition::Flags lhs, ResultDisposition::Flags rhs)
{
return static_cast(static_cast(lhs) | static_cast(rhs));
}
inline bool shouldContinueOnFailure(int flags) { return (flags & ResultDisposition::ContinueOnFailure) != 0; }
inline bool isFalseTest(int flags) { return (flags & ResultDisposition::FalseTest) != 0; }
inline bool shouldSuppressFailure(int flags) { return (flags & ResultDisposition::SuppressFail) != 0; }
} // end namespace Catch
// #included from: catch_assertionresult.h
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
#include
namespace Catch {
struct AssertionInfo
{
AssertionInfo() {}
AssertionInfo(std::string const& _macroName,
SourceLineInfo const& _lineInfo,
std::string const& _capturedExpression,
ResultDisposition::Flags _resultDisposition);
std::string macroName;
SourceLineInfo lineInfo;
std::string capturedExpression;
ResultDisposition::Flags resultDisposition;
};
struct AssertionResultData
{
AssertionResultData() : resultType(ResultWas::Unknown) {}
std::string reconstructedExpression;
std::string message;
ResultWas::OfType resultType;
};
class AssertionResult
{
public:
AssertionResult();
AssertionResult(AssertionInfo const& info, AssertionResultData const& data);
~AssertionResult();
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
AssertionResult(AssertionResult const&) = default;
AssertionResult(AssertionResult&&) = default;
AssertionResult& operator=(AssertionResult const&) = default;
AssertionResult& operator=(AssertionResult&&) = default;
#endif
bool isOk() const;
bool succeeded() const;
ResultWas::OfType getResultType() const;
bool hasExpression() const;
bool hasMessage() const;
std::string getExpression() const;
std::string getExpressionInMacro() const;
bool hasExpandedExpression() const;
std::string getExpandedExpression() const;
std::string getMessage() const;
SourceLineInfo getSourceInfo() const;
std::string getTestMacroName() const;
protected:
AssertionInfo m_info;
AssertionResultData m_resultData;
};
} // end namespace Catch
// #included from: catch_matchers.hpp
#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
namespace Catch {
namespace Matchers {
namespace Impl {
namespace Generic {
template
class AllOf;
template
class AnyOf;
template
class Not;
}
template
struct Matcher : SharedImpl
{
typedef ExpressionT ExpressionType;
virtual ~Matcher() {}
virtual Ptr clone() const = 0;
virtual bool match(ExpressionT const& expr) const = 0;
virtual std::string toString() const = 0;
Generic::AllOf operator&&(Matcher const& other) const;
Generic::AnyOf operator||(Matcher const& other) const;
Generic::Not operator!() const;
};
template
struct MatcherImpl : Matcher
{
virtual Ptr> clone() const
{
return Ptr>(new DerivedT(static_cast(*this)));
}
};
namespace Generic {
template
class Not : public MatcherImpl, ExpressionT>
{
public:
explicit Not(Matcher 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);
}
virtual std::string toString() const CATCH_OVERRIDE
{
return "not " + m_matcher->toString();
}
private:
Ptr> m_matcher;
};
template
class AllOf : public MatcherImpl, ExpressionT>
{
public:
AllOf() {}
AllOf(AllOf const& other) : m_matchers(other.m_matchers) {}
AllOf& add(Matcher 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 toString() const
{
std::ostringstream oss;
oss << "( ";
for (std::size_t i = 0; i < m_matchers.size(); ++i)
{
if (i != 0)
oss << " and ";
oss << m_matchers[i]->toString();
}
oss << " )";
return oss.str();
}
AllOf operator&&(Matcher const& other) const
{
AllOf allOfExpr(*this);
allOfExpr.add(other);
return allOfExpr;
}
private:
std::vector>> m_matchers;
};
template
class AnyOf : public MatcherImpl, ExpressionT>
{
public:
AnyOf() {}
AnyOf(AnyOf const& other) : m_matchers(other.m_matchers) {}
AnyOf& add(Matcher 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 toString() const
{
std::ostringstream oss;
oss << "( ";
for (std::size_t i = 0; i < m_matchers.size(); ++i)
{
if (i != 0)
oss << " or ";
oss << m_matchers[i]->toString();
}
oss << " )";
return oss.str();
}
AnyOf operator||(Matcher const& other) const
{
AnyOf anyOfExpr(*this);
anyOfExpr.add(other);
return anyOfExpr;
}
private:
std::vector>> m_matchers;
};
} // namespace Generic
template
Generic::AllOf Matcher::operator&&(Matcher const& other) const
{
Generic::AllOf allOfExpr;
allOfExpr.add(*this);
allOfExpr.add(other);
return allOfExpr;
}
template
Generic::AnyOf Matcher::operator||(Matcher const& other) const
{
Generic::AnyOf anyOfExpr;
anyOfExpr.add(*this);
anyOfExpr.add(other);
return anyOfExpr;
}
template
Generic::Not Matcher::operator!() const
{
return Generic::Not(*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(); }
struct CasedString
{
CasedString(std::string const& str, CaseSensitive::Choice caseSensitivity)
: m_caseSensitivity(caseSensitivity),
m_str(adjustString(str))
{
}
std::string adjustString(std::string const& str) const
{
return m_caseSensitivity == CaseSensitive::No
? toLower(str)
: str;
}
std::string toStringSuffix() const
{
return m_caseSensitivity == CaseSensitive::No
? " (case insensitive)"
: "";
}
CaseSensitive::Choice m_caseSensitivity;
std::string m_str;
};
struct Equals : MatcherImpl
{
Equals(std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
: m_data(str, caseSensitivity)
{
}
Equals(Equals const& other) : m_data(other.m_data) {}
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();
}
CasedString m_data;
};
struct Contains : MatcherImpl
{
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 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 m_data.adjustString(expr).find(m_data.m_str) == 0;
}
virtual std::string toString() const
{
return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
}
CasedString m_data;
};
struct EndsWith : MatcherImpl
{
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 m_data.adjustString(expr).find(m_data.m_str) == expr.size() - m_data.m_str.size();
}
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
template
inline Impl::Generic::Not Not(Impl::Matcher const& m)
{
return Impl::Generic::Not(m);
}
template
inline Impl::Generic::AllOf AllOf(Impl::Matcher const& m1,
Impl::Matcher const& m2)
{
return Impl::Generic::AllOf().add(m1).add(m2);
}
template
inline Impl::Generic::AllOf AllOf(Impl::Matcher const& m1,
Impl::Matcher const& m2,
Impl::Matcher const& m3)
{
return Impl::Generic::AllOf().add(m1).add(m2).add(m3);
}
template
inline Impl::Generic::AnyOf AnyOf(Impl::Matcher const& m1,
Impl::Matcher const& m2)
{
return Impl::Generic::AnyOf().add(m1).add(m2);
}
template
inline Impl::Generic::AnyOf AnyOf(Impl::Matcher const& m1,
Impl::Matcher const& m2,
Impl::Matcher const& m3)
{
return Impl::Generic::AnyOf().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;
} // namespace Catch
namespace Catch {
struct TestFailureException
{
};
template
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("");
oss << other.oss.str();
return *this;
}
std::ostringstream oss;
};
class ResultBuilder
{
public:
ResultBuilder(char const* macroName,
SourceLineInfo const& lineInfo,
char const* capturedExpression,
ResultDisposition::Flags resultDisposition,
char const* secondArg = "");
template
ExpressionLhs operator<=(T const& operand);
ExpressionLhs operator<=(bool value);
template
ResultBuilder& operator<<(T const& value)
{
m_stream.oss << value;
return *this;
}
template
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator&&(RhsT const&);
template
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();
std::string reconstructExpression() const;
AssertionResult build() 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::Matcher const& matcher);
void handleResult(AssertionResult const& result);
void react();
bool shouldDebugBreak() const;
bool allowThrows() const;
private:
AssertionInfo m_assertionInfo;
AssertionResultData m_data;
struct ExprComponents
{
ExprComponents() : testFalse(false) {}
bool testFalse;
std::string lhs, rhs, op;
} m_exprComponents;
CopyableStream m_stream;
bool m_shouldDebugBreak;
bool m_shouldThrow;
};
} // namespace Catch
// Include after due to circular dependency:
// #included from: catch_expression_lhs.hpp
#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
// #included from: catch_evaluate.hpp
#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4389) // '==' : signed/unsigned mismatch
#endif
#include
namespace Catch {
namespace Internal {
enum Operator
{
IsEqualTo,
IsNotEqualTo,
IsLessThan,
IsGreaterThan,
IsLessThanOrEqualTo,
IsGreaterThanOrEqualTo
};
template
struct OperatorTraits
{
static const char* getName() { return "*error*"; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return "=="; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return "!="; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return "<"; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return ">"; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return "<="; }
};
template <>
struct OperatorTraits
{
static const char* getName() { return ">="; }
};
template
inline T& opCast(T const& t)
{
return const_cast(t);
}
// nullptr_t support based on pull request #154 from Konstantin Baumann
#ifdef CATCH_CONFIG_CPP11_NULLPTR
inline std::nullptr_t opCast(std::nullptr_t)
{
return nullptr;
}
#endif // CATCH_CONFIG_CPP11_NULLPTR
// So the compare overloads can be operator agnostic we convey the operator as a template
// enum, which is used to specialise an Evaluator for doing the comparison.
template
class Evaluator
{
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) == opCast(rhs);
}
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) != opCast(rhs);
}
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) < opCast(rhs);
}
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) > opCast(rhs);
}
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) >= opCast(rhs);
}
};
template
struct Evaluator
{
static bool evaluate(T1 const& lhs, T2 const& rhs)
{
return opCast(lhs) <= opCast(rhs);
}
};
template
bool applyEvaluator(T1 const& lhs, T2 const& rhs)
{
return Evaluator::evaluate(lhs, rhs);
}
// This level of indirection allows us to specialise for integer types
// to avoid signed/ unsigned warnings
// "base" overload
template
bool compare(T1 const& lhs, T2 const& rhs)
{
return Evaluator::evaluate(lhs, rhs);
}
// unsigned X to int
template
bool compare(unsigned int lhs, int rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
template
bool compare(unsigned long lhs, int rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
template
bool compare(unsigned char lhs, int rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
// unsigned X to long
template
bool compare(unsigned int lhs, long rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
template
bool compare(unsigned long lhs, long rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
template
bool compare(unsigned char lhs, long rhs)
{
return applyEvaluator(lhs, static_cast(rhs));
}
// int to unsigned X
template
bool compare(int lhs, unsigned int rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(int lhs, unsigned long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(int lhs, unsigned char rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
// long to unsigned X
template
bool compare(long lhs, unsigned int rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(long lhs, unsigned long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(long lhs, unsigned char rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
// pointer to long (when comparing against NULL)
template
bool compare(long lhs, T* rhs)
{
return Evaluator::evaluate(reinterpret_cast(lhs), rhs);
}
template
bool compare(T* lhs, long rhs)
{
return Evaluator::evaluate(lhs, reinterpret_cast(rhs));
}
// pointer to int (when comparing against NULL)
template
bool compare(int lhs, T* rhs)
{
return Evaluator::evaluate(reinterpret_cast(lhs), rhs);
}
template
bool compare(T* lhs, int rhs)
{
return Evaluator::evaluate(lhs, reinterpret_cast(rhs));
}
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
// long long to unsigned X
template
bool compare(long long lhs, unsigned int rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(long long lhs, unsigned long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(long long lhs, unsigned long long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(long long lhs, unsigned char rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
// unsigned long long to X
template
bool compare(unsigned long long lhs, int rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(unsigned long long lhs, long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(unsigned long long lhs, long long rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
template
bool compare(unsigned long long lhs, char rhs)
{
return applyEvaluator(static_cast(lhs), rhs);
}
// pointer to long long (when comparing against NULL)
template
bool compare(long long lhs, T* rhs)
{
return Evaluator::evaluate(reinterpret_cast(lhs), rhs);
}
template
bool compare(T* lhs, long long rhs)
{
return Evaluator::evaluate(lhs, reinterpret_cast(rhs));
}
#endif // CATCH_CONFIG_CPP11_LONG_LONG
#ifdef CATCH_CONFIG_CPP11_NULLPTR
// pointer to nullptr_t (when comparing against nullptr)
template
bool compare(std::nullptr_t, T* rhs)
{
return Evaluator::evaluate(nullptr, rhs);
}
template
bool compare(T* lhs, std::nullptr_t)
{
return Evaluator::evaluate(lhs, nullptr);
}
#endif // CATCH_CONFIG_CPP11_NULLPTR
} // end of namespace Internal
} // end of namespace Catch
#ifdef _MSC_VER
#pragma warning(pop)
#endif
// #included from: catch_tostring.h
#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
#include
#include
#include
#include
#include
#ifdef __OBJC__
// #included from: catch_objc_arc.hpp
#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
#import
#ifdef __has_feature
#define CATCH_ARC_ENABLED __has_feature(objc_arc)
#else
#define CATCH_ARC_ENABLED 0
#endif
void arcSafeRelease(NSObject* obj);
id performOptionalSelector(id obj, SEL sel);
#if !CATCH_ARC_ENABLED
inline void arcSafeRelease(NSObject* obj)
{
[obj release];
}
inline id performOptionalSelector(id obj, SEL sel)
{
if ([obj respondsToSelector:sel])
return [obj performSelector:sel];
return nil;
}
#define CATCH_UNSAFE_UNRETAINED
#define CATCH_ARC_STRONG
#else
inline void arcSafeRelease(NSObject*)
{
}
inline id performOptionalSelector(id obj, SEL sel)
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
#endif
if ([obj respondsToSelector:sel])
return [obj performSelector:sel];
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return nil;
}
#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
#define CATCH_ARC_STRONG __strong
#endif
#endif
#ifdef CATCH_CONFIG_CPP11_TUPLE
#include
#endif
#ifdef CATCH_CONFIG_CPP11_IS_ENUM
#include
#endif
namespace Catch {
// Why we're here.
template
std::string toString(T const& value);
// Built in overloads
std::string toString(std::string const& value);
std::string toString(std::wstring const& value);
std::string toString(const char* const value);
std::string toString(char* const value);
std::string toString(const wchar_t* const value);
std::string toString(wchar_t* const value);
std::string toString(int value);
std::string toString(unsigned long value);
std::string toString(unsigned int value);
std::string toString(const double value);
std::string toString(const float value);
std::string toString(bool value);
std::string toString(char value);
std::string toString(signed char value);
std::string toString(unsigned char value);
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
std::string toString(long long value);
std::string toString(unsigned long long value);
#endif
#ifdef CATCH_CONFIG_CPP11_NULLPTR
std::string toString(std::nullptr_t);
#endif
#ifdef __OBJC__
std::string toString(NSString const* const& nsstring);
std::string toString(NSString* CATCH_ARC_STRONG const& nsstring);
std::string toString(NSObject* const& nsObject);
#endif
namespace Detail {
extern const std::string unprintableString;
struct BorgType
{
template
BorgType(T const&);
};
struct TrueType
{
char sizer[1];
};
struct FalseType
{
char sizer[2];
};
TrueType& testStreamable(std::ostream&);
FalseType testStreamable(FalseType);
FalseType operator<<(std::ostream const&, BorgType const&);
template
struct IsStreamInsertable
{
static std::ostream& s;
static T const& t;
enum
{
value = sizeof(testStreamable(s << t)) == sizeof(TrueType)
};
};
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template ::value>
struct EnumStringMaker
{
static std::string convert(T const&) { return unprintableString; }
};
template
struct EnumStringMaker
{
static std::string convert(T const& v)
{
return ::Catch::toString(
static_cast::type>(v));
}
};
#endif
template
struct StringMakerBase
{
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
template
static std::string convert(T const& v)
{
return EnumStringMaker::convert(v);
}
#else
template
static std::string convert(T const&)
{
return unprintableString;
}
#endif
};
template <>
struct StringMakerBase
{
template
static std::string convert(T const& _value)
{
std::ostringstream oss;
oss << _value;
return oss.str();
}
};
std::string rawMemoryToString(const void* object, std::size_t size);
template
inline std::string rawMemoryToString(const T& object)
{
return rawMemoryToString(&object, sizeof(object));
}
} // end namespace Detail
template
struct StringMaker : Detail::StringMakerBase::value>
{
};
template
struct StringMaker
{
template
static std::string convert(U* p)
{
if (!p)
return "NULL";
else
return Detail::rawMemoryToString(p);
}
};
template
struct StringMaker
{
static std::string convert(R C::*p)
{
if (!p)
return "NULL";
else
return Detail::rawMemoryToString(p);
}
};
namespace Detail {
template