Browse Source

Catch updated to v2.0.0-dev.6.

main
offa 7 years ago
parent
commit
d731d708f2
1 changed files with 97 additions and 58 deletions
  1. +97
    -58
      test/catch/catch.hpp

+ 97
- 58
test/catch/catch.hpp View File

/* /*
* Catch v2.0.0-develop.5
* Generated: 2017-10-12 13:05:08.135067
* Catch v2.0.0-develop.6
* Generated: 2017-10-31 15:09:47.277913
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved.


// Universal Windows platform does not support SEH // Universal Windows platform does not support SEH
// Or console colours (or console at all...) // Or console colours (or console at all...)
# if (WINAPI_FAMILY == WINAPI_FAMILY_APP)
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
# define CATCH_CONFIG_COLOUR_NONE # define CATCH_CONFIG_COLOUR_NONE
# else # else
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH # define CATCH_INTERNAL_CONFIG_WINDOWS_SEH


//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////


// All supported compilers support COUNTER macro,
//but user still might want to turn it off
#define CATCH_INTERNAL_CONFIG_COUNTER

// Now set the actual defines based on the above + anything the user has configured
// Use of __COUNTER__ is suppressed during code analysis in
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
// handled by it.
// Otherwise all supported compilers support COUNTER macro,
// but user still might want to turn it off
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
#define CATCH_INTERNAL_CONFIG_COUNTER
#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 # define CATCH_CONFIG_COUNTER
#endif #endif
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) #if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)


// Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
template<typename LhsT, typename RhsT> template<typename LhsT, typename RhsT>
auto compareEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs == rhs; };
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return lhs == rhs; };
template<typename T> 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> template<typename T>
ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}


template<typename RhsT> template<typename RhsT>
auto operator == ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
} }
auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const { auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
return BinaryExpr<LhsT, bool>( m_lhs == rhs, m_lhs, "==", rhs ); return BinaryExpr<LhsT, bool>( m_lhs == rhs, m_lhs, "==", rhs );
} }


template<typename RhsT> template<typename RhsT>
auto operator != ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
} }
auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const { auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
return BinaryExpr<LhsT, bool>( m_lhs != rhs, m_lhs, "!=", rhs ); return BinaryExpr<LhsT, bool>( m_lhs != rhs, m_lhs, "!=", rhs );
} }


template<typename RhsT> template<typename RhsT>
auto operator > ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( m_lhs > rhs, m_lhs, ">", rhs );
auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( m_lhs > rhs, m_lhs, ">", rhs );
} }
template<typename RhsT> template<typename RhsT>
auto operator < ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( m_lhs < rhs, m_lhs, "<", rhs );
auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( m_lhs < rhs, m_lhs, "<", rhs );
} }
template<typename RhsT> template<typename RhsT>
auto operator >= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( m_lhs >= rhs, m_lhs, ">=", rhs );
auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( m_lhs >= rhs, m_lhs, ">=", rhs );
} }
template<typename RhsT> template<typename RhsT>
auto operator <= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
return BinaryExpr<LhsT, RhsT&>( m_lhs <= rhs, m_lhs, "<=", rhs );
auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
return BinaryExpr<LhsT, RhsT const&>( m_lhs <= rhs, m_lhs, "<=", rhs );
} }


auto makeUnaryExpr() const -> UnaryExpr<LhsT> { auto makeUnaryExpr() const -> UnaryExpr<LhsT> {


} // end namespace Catch } // end namespace Catch


#ifdef _MSC_VER
#pragma warning(pop)
#endif

// end catch_decomposer.h // end catch_decomposer.h
// start catch_assertioninfo.h // start catch_assertioninfo.h


// end catch_interfaces_exception.h // end catch_interfaces_exception.h
// start catch_approx.h // start catch_approx.h


// start catch_enforce.h

#include <sstream>
#include <stdexcept>

#define CATCH_PREPARE_EXCEPTION( type, msg ) \
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
#define CATCH_INTERNAL_ERROR( msg ) \
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
#define CATCH_ERROR( msg ) \
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
#define CATCH_ENFORCE( condition, msg ) \
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)

// end catch_enforce.h
#include <cmath> #include <cmath>


#include <type_traits> #include <type_traits>
namespace Catch { namespace Catch {
namespace Detail { namespace Detail {


double max(double lhs, double rhs);
double dmax(double lhs, double rhs);


class Approx { class Approx {
public: public:
friend bool operator == ( const T& lhs, Approx const& rhs ) { friend bool operator == ( const T& lhs, Approx const& rhs ) {
// Thanks to Richard Harris for his help refining this formula // Thanks to Richard Harris for his help refining this formula
auto lhs_v = static_cast<double>(lhs); auto lhs_v = static_cast<double>(lhs);
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (max)(std::fabs(lhs_v), std::fabs(rhs.m_value)));
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale +
dmax(std::fabs(lhs_v), std::fabs(rhs.m_value)));
if (relativeOK) { if (relativeOK) {
return true; return true;
} }
return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
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> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
Approx& margin( T const& newMargin ) { Approx& margin( T const& newMargin ) {
m_margin = static_cast<double>(newMargin); m_margin = static_cast<double>(newMargin);
CATCH_ENFORCE(m_margin >= 0, "Invalid Approx::margin: " << m_margin << ", Approx::Margin has to be non-negative.");
return *this; return *this;
} }




// start catch_reporter_bases.hpp // start catch_reporter_bases.hpp


// start catch_enforce.h

#include <sstream>
#include <stdexcept>

#define CATCH_PREPARE_EXCEPTION( type, msg ) \
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
#define CATCH_INTERNAL_ERROR( msg ) \
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
#define CATCH_ERROR( msg ) \
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
#define CATCH_ENFORCE( condition, msg ) \
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)

// end catch_enforce.h
// start catch_interfaces_reporter.h // start catch_interfaces_reporter.h


// start catch_config.hpp // start catch_config.hpp
namespace Catch { namespace Catch {
namespace Detail { namespace Detail {


double max(double lhs, double rhs) {
double dmax(double lhs, double rhs) {
if (lhs < rhs) { if (lhs < rhs) {
return rhs; return rhs;
} }
} }


std::string AssertionResult::getExpression() const { std::string AssertionResult::getExpression() const {
if (isFalseTest(m_info.resultDisposition))
return '!' + std::string(m_info.capturedExpression);
if( isFalseTest( m_info.resultDisposition ) )
return "!(" + std::string(m_info.capturedExpression) + ")";
else else
return m_info.capturedExpression; return m_info.capturedExpression;
} }
#endif #endif


// start clara.hpp // start clara.hpp
// v1.0
// v1.0-develop.2
// See https://github.com/philsquared/Clara // See https://github.com/philsquared/Clara




std::string token; std::string token;
}; };


inline auto isOptPrefix( char c ) -> bool {
return c == '-'
#ifdef CATCH_PLATFORM_WINDOWS
|| c == '/'
#endif
;
}

// Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled
class TokenStream { class TokenStream {
using Iterator = std::vector<std::string>::const_iterator; using Iterator = std::vector<std::string>::const_iterator;


if( it != itEnd ) { if( it != itEnd ) {
auto const &next = *it; auto const &next = *it;
if( next[0] == '-' || next[0] == '/' ) {
if( isOptPrefix( next[0] ) ) {
auto delimiterPos = next.find_first_of( " :=" ); auto delimiterPos = next.find_first_of( " :=" );
if( delimiterPos != std::string::npos ) { if( delimiterPos != std::string::npos ) {
m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );
}; };


inline auto normaliseOpt( std::string const &optName ) -> std::string { inline auto normaliseOpt( std::string const &optName ) -> std::string {
#ifdef CATCH_PLATFORM_WINDOWS
if( optName[0] == '/' ) if( optName[0] == '/' )
return "-" + optName.substr( 1 ); return "-" + optName.substr( 1 );
else else
#endif
return optName; return optName;
} }


} }


auto isMatch( std::string const &optToken ) const -> bool { auto isMatch( std::string const &optToken ) const -> bool {
#ifdef CATCH_PLATFORM_WINDOWS
auto normalisedToken = normaliseOpt( optToken ); auto normalisedToken = normaliseOpt( optToken );
#else
auto const &normalisedToken = optToken;
#endif
for( auto const &name : m_optNames ) { for( auto const &name : m_optNames ) {
if( normaliseOpt( name ) == normalisedToken ) if( normaliseOpt( name ) == normalisedToken )
return true; return true;
for( auto const &name : m_optNames ) { for( auto const &name : m_optNames ) {
if( name.empty() ) if( name.empty() )
return Result::logicError( "Option name cannot be empty" ); return Result::logicError( "Option name cannot be empty" );
#ifdef CATCH_PLATFORM_WINDOWS
if( name[0] != '-' && name[0] != '/' ) if( name[0] != '-' && name[0] != '/' )
return Result::logicError( "Option name must begin with '-' or '/'" ); return Result::logicError( "Option name must begin with '-' or '/'" );
#else
if( name[0] != '-' )
return Result::logicError( "Option name must begin with '-'" );
#endif
} }
return ParserRefImpl::validate(); return ParserRefImpl::validate();
} }
size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;
size_t optWidth = 0; size_t optWidth = 0;
for( auto const &cols : rows ) for( auto const &cols : rows )
optWidth = std::max(optWidth, cols.left.size() + 2);
optWidth = (std::max)(optWidth, cols.left.size() + 2);


for( auto const &cols : rows ) { for( auto const &cols : rows ) {
auto row = auto row =
unsigned int rngSeed(); unsigned int rngSeed();


struct RandomNumberGenerator { struct RandomNumberGenerator {
using result_type = std::ptrdiff_t;
using result_type = unsigned int;


static constexpr result_type min() { return 0; }
static constexpr result_type max() { return 1000000; }
static constexpr result_type (min)() { return 0; }
static constexpr result_type (max)() { return 1000000; }


result_type operator()( result_type n ) const; result_type operator()( result_type n ) const;
result_type operator()() const; result_type operator()() const;
return std::rand() % n; return std::rand() % n;
} }
RandomNumberGenerator::result_type RandomNumberGenerator::operator()() const { RandomNumberGenerator::result_type RandomNumberGenerator::operator()() const {
return std::rand() % max();
return std::rand() % (max)();
} }


} }
} }


Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 0, 0, "develop", 5 );
static Version version( 2, 0, 0, "develop", 6 );
return version; return version;
} }


#include <cfloat> #include <cfloat>
#include <cstdio> #include <cstdio>


#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
// Note that 4062 (not all labels are handled
// and default is missing) is enabled
#endif

namespace Catch { namespace Catch {


namespace { namespace {
ConsoleReporter::~ConsoleReporter() {} ConsoleReporter::~ConsoleReporter() {}


} // end namespace Catch } // end namespace Catch

#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// end catch_reporter_console.cpp // end catch_reporter_console.cpp
// start catch_reporter_junit.cpp // start catch_reporter_junit.cpp


// end catch_reporter_multi.cpp // end catch_reporter_multi.cpp
// start catch_reporter_xml.cpp // start catch_reporter_xml.cpp


#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
// Note that 4062 (not all labels are handled
// and default is missing) is enabled
#endif

namespace Catch { namespace Catch {
class XmlReporter : public StreamingReporterBase<XmlReporter> { class XmlReporter : public StreamingReporterBase<XmlReporter> {
public: public:
CATCH_REGISTER_REPORTER( "xml", XmlReporter ) CATCH_REGISTER_REPORTER( "xml", XmlReporter )


} // end namespace Catch } // end namespace Catch

#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// end catch_reporter_xml.cpp // end catch_reporter_xml.cpp


namespace Catch { namespace Catch {

Loading…
Cancel
Save