⬆️ updated Catch to v1.7.2

This commit is contained in:
Niels Lohmann 2017-02-13 18:55:11 +01:00
parent ed8516dc39
commit c95ff863bf
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69

View file

@ -1,6 +1,6 @@
/* /*
* Catch v1.7.0 * Catch v1.7.2
* Generated: 2017-02-01 21:32:13.239291 * Generated: 2017-02-13 15:57:33.350226
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -81,6 +81,7 @@
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? // CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
// **************** // ****************
// Note to maintainers: if new toggles are added please document them // Note to maintainers: if new toggles are added please document them
// in configuration.md, too // in configuration.md, too
@ -160,6 +161,8 @@
// Visual C++ // Visual C++
#ifdef _MSC_VER #ifdef _MSC_VER
#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
#if (_MSC_VER >= 1600) #if (_MSC_VER >= 1600)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR # define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
@ -284,6 +287,9 @@
# 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) # 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 # define CATCH_CONFIG_CPP11_TYPE_TRAITS
# endif # 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
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
@ -331,7 +337,6 @@
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
#include <sstream> #include <sstream>
#include <stdexcept>
#include <algorithm> #include <algorithm>
namespace Catch { namespace Catch {
@ -390,7 +395,6 @@ namespace Catch {
bool endsWith( std::string const& s, std::string const& suffix ); bool endsWith( std::string const& s, std::string const& suffix );
bool endsWith( std::string const& s, char suffix ); bool endsWith( std::string const& s, char suffix );
bool contains( std::string const& s, std::string const& infix ); bool contains( std::string const& s, std::string const& infix );
bool contains( std::string const& s, std::string const& infix );
void toLowerInPlace( std::string& s ); void toLowerInPlace( std::string& s );
std::string toLower( std::string const& s ); std::string toLower( std::string const& s );
std::string trim( std::string const& str ); std::string trim( std::string const& str );
@ -453,8 +457,6 @@ namespace Catch {
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); #define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
#include <ostream>
namespace Catch { namespace Catch {
class NotImplementedException : public std::exception class NotImplementedException : public std::exception
@ -587,10 +589,6 @@ namespace Catch {
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
#include <memory>
#include <vector>
#include <stdlib.h>
namespace Catch { namespace Catch {
class TestCase; class TestCase;
@ -1878,45 +1876,45 @@ public:
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsEqualTo, RhsT const&> BinaryExpression<T, Internal::IsEqualTo, RhsT const&>
operator == ( RhsT const& rhs ) const { operator == ( RhsT const& rhs ) {
return captureExpression<Internal::IsEqualTo>( rhs ); return captureExpression<Internal::IsEqualTo>( rhs );
} }
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsNotEqualTo, RhsT const&> BinaryExpression<T, Internal::IsNotEqualTo, RhsT const&>
operator != ( RhsT const& rhs ) const { operator != ( RhsT const& rhs ) {
return captureExpression<Internal::IsNotEqualTo>( rhs ); return captureExpression<Internal::IsNotEqualTo>( rhs );
} }
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsLessThan, RhsT const&> BinaryExpression<T, Internal::IsLessThan, RhsT const&>
operator < ( RhsT const& rhs ) const { operator < ( RhsT const& rhs ) {
return captureExpression<Internal::IsLessThan>( rhs ); return captureExpression<Internal::IsLessThan>( rhs );
} }
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsGreaterThan, RhsT const&> BinaryExpression<T, Internal::IsGreaterThan, RhsT const&>
operator > ( RhsT const& rhs ) const { operator > ( RhsT const& rhs ) {
return captureExpression<Internal::IsGreaterThan>( rhs ); return captureExpression<Internal::IsGreaterThan>( rhs );
} }
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsLessThanOrEqualTo, RhsT const&> BinaryExpression<T, Internal::IsLessThanOrEqualTo, RhsT const&>
operator <= ( RhsT const& rhs ) const { operator <= ( RhsT const& rhs ) {
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs ); return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
} }
template<typename RhsT> template<typename RhsT>
BinaryExpression<T, Internal::IsGreaterThanOrEqualTo, RhsT const&> BinaryExpression<T, Internal::IsGreaterThanOrEqualTo, RhsT const&>
operator >= ( RhsT const& rhs ) const { operator >= ( RhsT const& rhs ) {
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs ); return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
} }
BinaryExpression<T, Internal::IsEqualTo, bool> operator == ( bool rhs ) const { BinaryExpression<T, Internal::IsEqualTo, bool> operator == ( bool rhs ) {
return captureExpression<Internal::IsEqualTo>( rhs ); return captureExpression<Internal::IsEqualTo>( rhs );
} }
BinaryExpression<T, Internal::IsNotEqualTo, bool> operator != ( bool rhs ) const { BinaryExpression<T, Internal::IsNotEqualTo, bool> operator != ( bool rhs ) {
return captureExpression<Internal::IsNotEqualTo>( rhs ); return captureExpression<Internal::IsNotEqualTo>( rhs );
} }
@ -2209,6 +2207,45 @@ namespace Catch {
}; };
} }
// #included from: catch_type_traits.hpp
#define TWOBLUECUBES_CATCH_TYPE_TRAITS_HPP_INCLUDED
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
#include <type_traits>
#endif
namespace Catch {
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
template <typename T>
using add_lvalue_reference = std::add_lvalue_reference<T>;
template <typename T>
using add_const = std::add_const<T>;
#else
template <typename T>
struct add_const {
typedef const T type;
};
template <typename T>
struct add_lvalue_reference {
typedef T& type;
};
template <typename T>
struct add_lvalue_reference<T&> {
typedef T& type;
};
// No && overload, because that is C++11, in which case we have
// proper type_traits implementation from the standard library
#endif
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// In the event of a failure works out if the debugger needs to be invoked // In the event of a failure works out if the debugger needs to be invoked
// and/or an exception thrown and takes appropriate action. // and/or an exception thrown and takes appropriate action.
@ -2277,13 +2314,13 @@ namespace Catch {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \ #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
if( __catchResult.allowThrows() ) \ if( __catchResult.allowThrows() ) \
try { \ try { \
static_cast<void>(expr); \ static_cast<void>(expr); \
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
} \ } \
catch( exceptionType ) { \ catch( Catch::add_const<Catch::add_lvalue_reference<exceptionType>::type>::type ) { \
__catchResult.captureResult( Catch::ResultWas::Ok ); \ __catchResult.captureResult( Catch::ResultWas::Ok ); \
} \ } \
catch( ... ) { \ catch( ... ) { \
@ -2405,6 +2442,8 @@ namespace Catch {
}; };
} }
#include <string>
namespace Catch { namespace Catch {
struct SectionInfo { struct SectionInfo {
@ -2812,7 +2851,7 @@ namespace Detail {
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 = double(lhs); auto lhs_v = double(lhs);
return fabs( lhs_v - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs_v), fabs(rhs.m_value) ) ); return std::fabs( lhs_v - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs_v), std::fabs(rhs.m_value) ) );
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
@ -2856,7 +2895,7 @@ namespace Detail {
#else #else
friend bool operator == ( double lhs, Approx const& rhs ) { friend bool operator == ( double lhs, Approx const& rhs ) {
// Thanks to Richard Harris for his help refining this formula // Thanks to Richard Harris for his help refining this formula
return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) ); return std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) );
} }
friend bool operator == ( Approx const& lhs, double rhs ) { friend bool operator == ( Approx const& lhs, double rhs ) {
@ -3342,6 +3381,8 @@ return @ desc; \
// #included from: catch_wildcard_pattern.hpp // #included from: catch_wildcard_pattern.hpp
#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED #define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
#include <stdexcept>
namespace Catch namespace Catch
{ {
class WildcardPattern { class WildcardPattern {
@ -3595,7 +3636,7 @@ namespace Catch {
// #included from: catch_interfaces_config.h // #included from: catch_interfaces_config.h
#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
#include <iostream> #include <iosfwd>
#include <string> #include <string>
#include <vector> #include <vector>
@ -3717,8 +3758,7 @@ namespace Catch {
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <string> #include <string>
#include <iostream> #include <stdexcept>
#include <ctime>
#ifndef CATCH_CONFIG_CONSOLE_WIDTH #ifndef CATCH_CONFIG_CONSOLE_WIDTH
#define CATCH_CONFIG_CONSOLE_WIDTH 80 #define CATCH_CONFIG_CONSOLE_WIDTH 80
@ -3800,8 +3840,7 @@ namespace Catch {
} }
} }
virtual ~Config() { virtual ~Config() {}
}
std::string const& getFilename() const { std::string const& getFilename() const {
return m_data.outputFilename ; return m_data.outputFilename ;
@ -3814,28 +3853,26 @@ namespace Catch {
std::string getProcessName() const { return m_data.processName; } std::string getProcessName() const { return m_data.processName; }
bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
std::vector<std::string> const& getReporterNames() const { return m_data.reporterNames; } std::vector<std::string> const& getReporterNames() const { return m_data.reporterNames; }
std::vector<std::string> const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; } std::vector<std::string> const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; }
int abortAfter() const { return m_data.abortAfter; } virtual TestSpec const& testSpec() const CATCH_OVERRIDE { return m_testSpec; }
TestSpec const& testSpec() const { return m_testSpec; }
bool showHelp() const { return m_data.showHelp; } bool showHelp() const { return m_data.showHelp; }
bool showInvisibles() const { return m_data.showInvisibles; }
// IConfig interface // IConfig interface
virtual bool allowThrows() const { return !m_data.noThrow; } virtual bool allowThrows() const CATCH_OVERRIDE { return !m_data.noThrow; }
virtual std::ostream& stream() const { return m_stream->stream(); } virtual std::ostream& stream() const CATCH_OVERRIDE { return m_stream->stream(); }
virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } virtual std::string name() const CATCH_OVERRIDE { return m_data.name.empty() ? m_data.processName : m_data.name; }
virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } virtual bool includeSuccessfulResults() const CATCH_OVERRIDE { return m_data.showSuccessfulTests; }
virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } virtual bool warnAboutMissingAssertions() const CATCH_OVERRIDE { return m_data.warnings & WarnAbout::NoAssertions; }
virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } virtual ShowDurations::OrNot showDurations() const CATCH_OVERRIDE { return m_data.showDurations; }
virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; } virtual RunTests::InWhatOrder runOrder() const CATCH_OVERRIDE { return m_data.runOrder; }
virtual unsigned int rngSeed() const { return m_data.rngSeed; } virtual unsigned int rngSeed() const CATCH_OVERRIDE { return m_data.rngSeed; }
virtual UseColour::YesOrNo useColour() const { return m_data.useColour; } 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; }
private: private:
@ -4897,6 +4934,7 @@ STITCH_CLARA_CLOSE_NAMESPACE
#endif #endif
#include <fstream> #include <fstream>
#include <ctime>
namespace Catch { namespace Catch {
@ -4935,7 +4973,7 @@ namespace Catch {
ss << seed; ss << seed;
ss >> config.rngSeed; ss >> config.rngSeed;
if( ss.fail() ) if( ss.fail() )
throw std::runtime_error( "Argment to --rng-seed should be the word 'time' or a number" ); throw std::runtime_error( "Argument to --rng-seed should be the word 'time' or a number" );
} }
} }
inline void setVerbosity( ConfigData& config, int level ) { inline void setVerbosity( ConfigData& config, int level ) {
@ -5332,7 +5370,6 @@ namespace Catch {
#include <string> #include <string>
#include <ostream> #include <ostream>
#include <map> #include <map>
#include <assert.h>
namespace Catch namespace Catch
{ {
@ -5756,6 +5793,7 @@ namespace Catch {
#include <assert.h> #include <assert.h>
#include <vector> #include <vector>
#include <iterator> #include <iterator>
#include <stdexcept>
namespace Catch { namespace Catch {
namespace TestCaseTracking { namespace TestCaseTracking {
@ -6117,12 +6155,40 @@ namespace Catch {
} // namespace Catch } // namespace Catch
#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// #if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////
// #included from: catch_windows_h_proxy.h
#define NOMINMAX #define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED
#define WIN32_LEAN_AND_MEAN
#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> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #endif
#undef NOMINMAX
#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 { namespace Catch {
@ -6143,6 +6209,7 @@ namespace Catch {
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
reset();
reportFatal(signalDefs[i].name); reportFatal(signalDefs[i].name);
} }
} }
@ -6151,22 +6218,25 @@ namespace Catch {
return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_CONTINUE_SEARCH;
} }
FatalConditionHandler() {
isSet = true;
// 32k seems enough for Catch to handle stack overflow, // 32k seems enough for Catch to handle stack overflow,
// but the value was found experimentally, so there is no strong guarantee // but the value was found experimentally, so there is no strong guarantee
FatalConditionHandler():m_isSet(true), m_guaranteeSize(32 * 1024), m_exceptionHandlerHandle(CATCH_NULL) { guaranteeSize = 32 * 1024;
exceptionHandlerHandle = CATCH_NULL;
// Register as first handler in current chain // Register as first handler in current chain
m_exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
// Pass in guarantee size to be filled // Pass in guarantee size to be filled
SetThreadStackGuarantee(&m_guaranteeSize); SetThreadStackGuarantee(&guaranteeSize);
} }
void reset() { static void reset() {
if (m_isSet) { if (isSet) {
// Unregister handler and restore the old guarantee // Unregister handler and restore the old guarantee
RemoveVectoredExceptionHandler(m_exceptionHandlerHandle); RemoveVectoredExceptionHandler(exceptionHandlerHandle);
SetThreadStackGuarantee(&m_guaranteeSize); SetThreadStackGuarantee(&guaranteeSize);
m_exceptionHandlerHandle = CATCH_NULL; exceptionHandlerHandle = CATCH_NULL;
m_isSet = false; isSet = false;
} }
} }
@ -6174,13 +6244,19 @@ namespace Catch {
reset(); reset();
} }
private: private:
bool m_isSet; static bool isSet;
ULONG m_guaranteeSize; static ULONG guaranteeSize;
PVOID m_exceptionHandlerHandle; static PVOID exceptionHandlerHandle;
}; };
bool FatalConditionHandler::isSet = false;
ULONG FatalConditionHandler::guaranteeSize = 0;
PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL;
} // namespace Catch } // namespace Catch
# endif // CATCH_CONFIG_WINDOWS_SEH
#else // Not Windows - assumed to be POSIX compatible ////////////////////////// #else // Not Windows - assumed to be POSIX compatible //////////////////////////
#include <signal.h> #include <signal.h>
@ -6338,7 +6414,8 @@ namespace Catch {
do { do {
ITracker& rootTracker = m_trackerContext.startRun(); ITracker& rootTracker = m_trackerContext.startRun();
dynamic_cast<SectionTracker&>( rootTracker ).addInitialFilters( m_config->getSectionsToRun() ); assert( rootTracker.isSectionTracker() );
static_cast<SectionTracker&>( rootTracker ).addInitialFilters( m_config->getSectionsToRun() );
do { do {
m_trackerContext.startCycle(); m_trackerContext.startCycle();
m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( testInfo.name, testInfo.lineInfo ) ); m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( testInfo.name, testInfo.lineInfo ) );
@ -6837,7 +6914,6 @@ namespace Catch {
#include <vector> #include <vector>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <iostream>
#include <algorithm> #include <algorithm>
namespace Catch { namespace Catch {
@ -7197,7 +7273,7 @@ namespace Catch {
// #included from: catch_notimplemented_exception.hpp // #included from: catch_notimplemented_exception.hpp
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
#include <ostream> #include <sstream>
namespace Catch { namespace Catch {
@ -7440,30 +7516,6 @@ namespace Catch {
#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// #if defined ( CATCH_CONFIG_COLOUR_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
namespace Catch { namespace Catch {
namespace { namespace {
@ -7773,6 +7825,8 @@ namespace Catch {
// #included from: catch_test_case_info.hpp // #included from: catch_test_case_info.hpp
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED
#include <cctype>
namespace Catch { namespace Catch {
inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
@ -7792,7 +7846,7 @@ namespace Catch {
return TestCaseInfo::None; return TestCaseInfo::None;
} }
inline bool isReservedTag( std::string const& tag ) { inline bool isReservedTag( std::string const& tag ) {
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] ); return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] );
} }
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
if( isReservedTag( tag ) ) { if( isReservedTag( tag ) ) {
@ -7989,7 +8043,7 @@ namespace Catch {
return os; return os;
} }
Version libraryVersion( 1, 7, 0, "", 0 ); Version libraryVersion( 1, 7, 2, "", 0 );
} }
@ -8209,6 +8263,7 @@ namespace Catch {
#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED #define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED
#include <cstring> #include <cstring>
#include <cctype>
namespace Catch { namespace Catch {
@ -8227,11 +8282,8 @@ namespace Catch {
bool contains( std::string const& s, std::string const& infix ) { bool contains( std::string const& s, std::string const& infix ) {
return s.find( infix ) != std::string::npos; return s.find( infix ) != std::string::npos;
} }
bool contains( std::string const& s, char infix ) {
return s.find(infix) != std::string::npos;
}
char toLowerCh(char c) { char toLowerCh(char c) {
return static_cast<char>( ::tolower( c ) ); return static_cast<char>( std::tolower( c ) );
} }
void toLowerInPlace( std::string& s ) { void toLowerInPlace( std::string& s ) {
std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
@ -8356,8 +8408,6 @@ namespace Catch {
// #included from: catch_debugger.hpp // #included from: catch_debugger.hpp
#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
#include <iostream>
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC
#include <assert.h> #include <assert.h>
@ -8454,7 +8504,7 @@ namespace Catch {
#endif // Platform #endif // Platform
#ifdef CATCH_PLATFORM_WINDOWS #ifdef CATCH_PLATFORM_WINDOWS
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
namespace Catch { namespace Catch {
void writeToDebugConsole( std::string const& text ) { void writeToDebugConsole( std::string const& text ) {
::OutputDebugStringA( text.c_str() ); ::OutputDebugStringA( text.c_str() );
@ -8820,9 +8870,6 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#include <map>
#include <iostream>
namespace Catch { namespace Catch {
TagAliasRegistry::~TagAliasRegistry() {} TagAliasRegistry::~TagAliasRegistry() {}
@ -9256,7 +9303,7 @@ namespace Catch {
char const* getLineOfChars() { char const* getLineOfChars() {
static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
if( !*line ) { if( !*line ) {
memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
} }
return line; return line;
@ -9410,8 +9457,11 @@ namespace Catch {
default: default:
// Escape control chars - based on contribution by @espenalb in PR #465 and // Escape control chars - based on contribution by @espenalb in PR #465 and
// by @mrpi PR #588 // by @mrpi PR #588
if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) {
os << "&#x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>( c ) << ';'; // 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 );
}
else else
os << c; os << c;
} }
@ -9465,20 +9515,17 @@ namespace Catch {
XmlWriter() XmlWriter()
: m_tagIsOpen( false ), : m_tagIsOpen( false ),
m_needsNewline( false ), m_needsNewline( false ),
m_os( &Catch::cout() ) m_os( Catch::cout() )
{ {
// We encode control characters, which requires writeDeclaration();
// XML 1.1
// see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n";
} }
XmlWriter( std::ostream& os ) XmlWriter( std::ostream& os )
: m_tagIsOpen( false ), : m_tagIsOpen( false ),
m_needsNewline( false ), m_needsNewline( false ),
m_os( &os ) m_os( os )
{ {
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n"; writeDeclaration();
} }
~XmlWriter() { ~XmlWriter() {
@ -9489,7 +9536,7 @@ namespace Catch {
XmlWriter& startElement( std::string const& name ) { XmlWriter& startElement( std::string const& name ) {
ensureTagClosed(); ensureTagClosed();
newlineIfNecessary(); newlineIfNecessary();
stream() << m_indent << '<' << name; m_os << m_indent << '<' << name;
m_tags.push_back( name ); m_tags.push_back( name );
m_indent += " "; m_indent += " ";
m_tagIsOpen = true; m_tagIsOpen = true;
@ -9506,24 +9553,25 @@ namespace Catch {
newlineIfNecessary(); newlineIfNecessary();
m_indent = m_indent.substr( 0, m_indent.size()-2 ); m_indent = m_indent.substr( 0, m_indent.size()-2 );
if( m_tagIsOpen ) { if( m_tagIsOpen ) {
stream() << "/>\n"; m_os << "/>";
m_tagIsOpen = false; m_tagIsOpen = false;
} }
else { else {
stream() << m_indent << "</" << m_tags.back() << ">\n"; m_os << m_indent << "</" << m_tags.back() << ">";
} }
m_os << std::endl;
m_tags.pop_back(); m_tags.pop_back();
return *this; return *this;
} }
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
if( !name.empty() && !attribute.empty() ) if( !name.empty() && !attribute.empty() )
stream() << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
return *this; return *this;
} }
XmlWriter& writeAttribute( std::string const& name, bool attribute ) { XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
stream() << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
return *this; return *this;
} }
@ -9539,8 +9587,8 @@ namespace Catch {
bool tagWasOpen = m_tagIsOpen; bool tagWasOpen = m_tagIsOpen;
ensureTagClosed(); ensureTagClosed();
if( tagWasOpen && indent ) if( tagWasOpen && indent )
stream() << m_indent; m_os << m_indent;
stream() << XmlEncode( text ); m_os << XmlEncode( text );
m_needsNewline = true; m_needsNewline = true;
} }
return *this; return *this;
@ -9548,39 +9596,39 @@ namespace Catch {
XmlWriter& writeComment( std::string const& text ) { XmlWriter& writeComment( std::string const& text ) {
ensureTagClosed(); ensureTagClosed();
stream() << m_indent << "<!--" << text << "-->"; m_os << m_indent << "<!--" << text << "-->";
m_needsNewline = true; m_needsNewline = true;
return *this; return *this;
} }
void writeStylesheetRef( std::string const& url ) {
m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
}
XmlWriter& writeBlankLine() { XmlWriter& writeBlankLine() {
ensureTagClosed(); ensureTagClosed();
stream() << '\n'; m_os << '\n';
return *this; return *this;
} }
void setStream( std::ostream& os ) { void ensureTagClosed() {
m_os = &os; if( m_tagIsOpen ) {
m_os << ">" << std::endl;
m_tagIsOpen = false;
}
} }
private: private:
XmlWriter( XmlWriter const& ); XmlWriter( XmlWriter const& );
void operator=( XmlWriter const& ); void operator=( XmlWriter const& );
std::ostream& stream() { void writeDeclaration() {
return *m_os; m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
void ensureTagClosed() {
if( m_tagIsOpen ) {
stream() << ">\n";
m_tagIsOpen = false;
}
} }
void newlineIfNecessary() { void newlineIfNecessary() {
if( m_needsNewline ) { if( m_needsNewline ) {
stream() << '\n'; m_os << std::endl;
m_needsNewline = false; m_needsNewline = false;
} }
} }
@ -9589,7 +9637,7 @@ namespace Catch {
bool m_needsNewline; bool m_needsNewline;
std::vector<std::string> m_tags; std::vector<std::string> m_tags;
std::string m_indent; std::string m_indent;
std::ostream* m_os; std::ostream& m_os;
}; };
} }
@ -9625,6 +9673,10 @@ namespace Catch {
return "Reports test results as an XML document"; return "Reports test results as an XML document";
} }
virtual std::string getStylesheetRef() const {
return std::string();
}
public: // StreamingReporterBase public: // StreamingReporterBase
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE { virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
@ -9633,6 +9685,9 @@ namespace Catch {
virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE { virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
StreamingReporterBase::testRunStarting( testInfo ); StreamingReporterBase::testRunStarting( testInfo );
std::string stylesheetRef = getStylesheetRef();
if( !stylesheetRef.empty() )
m_xml.writeStylesheetRef( stylesheetRef );
m_xml.startElement( "Catch" ); m_xml.startElement( "Catch" );
if( !m_config->name().empty() ) if( !m_config->name().empty() )
m_xml.writeAttribute( "name", m_config->name() ); m_xml.writeAttribute( "name", m_config->name() );
@ -9646,10 +9701,14 @@ namespace Catch {
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
StreamingReporterBase::testCaseStarting(testInfo); StreamingReporterBase::testCaseStarting(testInfo);
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name ); m_xml.startElement( "TestCase" )
.writeAttribute( "name", trim( testInfo.name ) )
.writeAttribute( "description", testInfo.description )
.writeAttribute( "tags", testInfo.tagsAsString );
if ( m_config->showDurations() == ShowDurations::Always ) if ( m_config->showDurations() == ShowDurations::Always )
m_testCaseTimer.start(); m_testCaseTimer.start();
m_xml.ensureTagClosed();
} }
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
@ -9658,6 +9717,7 @@ namespace Catch {
m_xml.startElement( "Section" ) m_xml.startElement( "Section" )
.writeAttribute( "name", trim( sectionInfo.name ) ) .writeAttribute( "name", trim( sectionInfo.name ) )
.writeAttribute( "description", sectionInfo.description ); .writeAttribute( "description", sectionInfo.description );
m_xml.ensureTagClosed();
} }
} }
@ -9757,6 +9817,11 @@ namespace Catch {
if ( m_config->showDurations() == ShowDurations::Always ) if ( m_config->showDurations() == ShowDurations::Always )
e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); 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(); m_xml.endElement();
} }
@ -9804,7 +9869,7 @@ namespace Catch {
std::time(&rawtime); std::time(&rawtime);
const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z");
#ifdef CATCH_PLATFORM_WINDOWS #ifdef _MSC_VER
std::tm timeInfo = {}; std::tm timeInfo = {};
gmtime_s(&timeInfo, &rawtime); gmtime_s(&timeInfo, &rawtime);
#else #else
@ -9815,7 +9880,7 @@ namespace Catch {
char timeStamp[timeStampSize]; char timeStamp[timeStampSize];
const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
#ifdef CATCH_PLATFORM_WINDOWS #ifdef _MSC_VER
std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
#else #else
std::strftime(timeStamp, timeStampSize, fmt, timeInfo); std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
@ -10301,7 +10366,7 @@ namespace Catch {
printHeaderString( it->name, 2 ); printHeaderString( it->name, 2 );
} }
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; SourceLineInfo lineInfo = m_sectionStack.back().lineInfo;
if( !lineInfo.empty() ){ if( !lineInfo.empty() ){
stream << getLineOfChars<'-'>() << '\n'; stream << getLineOfChars<'-'>() << '\n';