mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Reorganised C+11 feature detection a bit
and added CATCH_CONFIG_CPP11_NULLPTR for VS2015
This commit is contained in:
parent
bfa3f863d6
commit
e86daf8bdd
@ -222,7 +222,7 @@ Scenario: vectors can be sized and resized
|
||||
<a id="scaling-up"></a>
|
||||
## Scaling up
|
||||
|
||||
To keep the tutorial simple we put all our code in a single file. This is fine to get started - and makes jumping into Catch even quicker and easier. As you write more real world tests, though, this is not really the best approach.
|
||||
To keep the tutorial simple we put all our code in a single file. This is fine to get started - and makes jumping into Catch even quicker and easier. As you write more real-world tests, though, this is not really the best approach.
|
||||
|
||||
The requirement is that the following block of code ([or equivalent](own-main.md)):
|
||||
|
||||
|
2
include/external/clara.h
vendored
2
include/external/clara.h
vendored
@ -251,7 +251,7 @@ namespace Clara {
|
||||
template<typename ConfigT>
|
||||
struct IArgFunction {
|
||||
virtual ~IArgFunction() {}
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
IArgFunction() = default;
|
||||
IArgFunction( IArgFunction const& ) = default;
|
||||
# endif
|
||||
|
@ -41,7 +41,7 @@ namespace Catch {
|
||||
AssertionResult();
|
||||
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
||||
~AssertionResult();
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
AssertionResult( AssertionResult const& ) = default;
|
||||
AssertionResult( AssertionResult && ) = default;
|
||||
AssertionResult& operator = ( AssertionResult const& ) = default;
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace Catch {
|
||||
|
||||
class NonCopyable {
|
||||
#ifdef CATCH_CPP11_OR_GREATER
|
||||
#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
NonCopyable( NonCopyable const& ) = delete;
|
||||
NonCopyable( NonCopyable && ) = delete;
|
||||
NonCopyable& operator = ( NonCopyable const& ) = delete;
|
||||
@ -87,7 +87,7 @@ namespace Catch {
|
||||
SourceLineInfo();
|
||||
SourceLineInfo( char const* _file, std::size_t _line );
|
||||
SourceLineInfo( SourceLineInfo const& other );
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
SourceLineInfo( SourceLineInfo && ) = default;
|
||||
SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
|
||||
SourceLineInfo& operator = ( SourceLineInfo && ) = default;
|
||||
|
@ -8,7 +8,22 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||
|
||||
// Much of the following code is based on Boost (1.53)
|
||||
// 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_OR_GREATER : Is C++11 supported?
|
||||
|
||||
// CATCH_CONFIG_SFINAE : is basic (C++03) SFINAE supported?
|
||||
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
|
||||
|
||||
|
||||
// A lot of this code is based on Boost (1.53)
|
||||
|
||||
#ifdef __clang__
|
||||
|
||||
@ -88,6 +103,13 @@
|
||||
//#define CATCH_CONFIG_SFINAE // Not confirmed
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
|
||||
#define CATCH_CONFIG_CPP11_NOEXCEPT
|
||||
#define CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
#define CATCH_CONFIG_CPP11_NULLPTR
|
||||
//#define CATCH_CONFIG_SFINAE // Don't use, for now
|
||||
#endif
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
// Use variadic macros if the compiler supports them
|
||||
@ -105,14 +127,41 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// C++ language feature support
|
||||
|
||||
// detect language version:
|
||||
#if (__cplusplus == 201103L)
|
||||
# define CATCH_CPP11
|
||||
# define CATCH_CPP11_OR_GREATER
|
||||
#elif (__cplusplus >= 201103L)
|
||||
// catch all support for C++11
|
||||
#if (__cplusplus >= 201103L)
|
||||
|
||||
# define CATCH_CPP11_OR_GREATER
|
||||
|
||||
# ifndef CATCH_CONFIG_CPP11_NULLPTR
|
||||
# define CATCH_CONFIG_CPP11_NULLPTR
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_CPP11_NOEXCEPT
|
||||
# define CATCH_CONFIG_CPP11_NOEXCEPT
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
# define CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_CPP11_IS_ENUM
|
||||
# define CATCH_CONFIG_CPP11_IS_ENUM
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_CPP11_TUPLE
|
||||
# define CATCH_CONFIG_CPP11_TUPLE
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_SFINAE
|
||||
//# define CATCH_CONFIG_SFINAE // Don't use, for now
|
||||
# endif
|
||||
|
||||
# ifndef CATCH_CONFIG_VARIADIC_MACROS
|
||||
# define CATCH_CONFIG_VARIADIC_MACROS
|
||||
# endif
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
|
||||
// noexcept support:
|
||||
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
|
||||
# define CATCH_NOEXCEPT noexcept
|
||||
|
@ -19,13 +19,13 @@ namespace Catch {
|
||||
template<typename T>
|
||||
class ExpressionLhs {
|
||||
ExpressionLhs& operator = ( ExpressionLhs const& );
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
|
||||
# endif
|
||||
|
||||
public:
|
||||
ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
ExpressionLhs( ExpressionLhs const& ) = default;
|
||||
ExpressionLhs( ExpressionLhs && ) = default;
|
||||
# endif
|
||||
|
@ -101,7 +101,7 @@ namespace Catch
|
||||
}
|
||||
virtual ~AssertionStats();
|
||||
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
AssertionStats( AssertionStats const& ) = default;
|
||||
AssertionStats( AssertionStats && ) = default;
|
||||
AssertionStats& operator = ( AssertionStats const& ) = default;
|
||||
@ -124,7 +124,7 @@ namespace Catch
|
||||
missingAssertions( _missingAssertions )
|
||||
{}
|
||||
virtual ~SectionStats();
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
SectionStats( SectionStats const& ) = default;
|
||||
SectionStats( SectionStats && ) = default;
|
||||
SectionStats& operator = ( SectionStats const& ) = default;
|
||||
@ -151,7 +151,7 @@ namespace Catch
|
||||
{}
|
||||
virtual ~TestCaseStats();
|
||||
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
TestCaseStats( TestCaseStats const& ) = default;
|
||||
TestCaseStats( TestCaseStats && ) = default;
|
||||
TestCaseStats& operator = ( TestCaseStats const& ) = default;
|
||||
@ -179,7 +179,7 @@ namespace Catch
|
||||
{}
|
||||
virtual ~TestGroupStats();
|
||||
|
||||
# ifdef CATCH_CPP11_OR_GREATER
|
||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
TestGroupStats( TestGroupStats const& ) = default;
|
||||
TestGroupStats( TestGroupStats && ) = default;
|
||||
TestGroupStats& operator = ( TestGroupStats const& ) = default;
|
||||
@ -201,7 +201,7 @@ namespace Catch
|
||||
{}
|
||||
virtual ~TestRunStats();
|
||||
|
||||
# ifndef CATCH_CPP11_OR_GREATER
|
||||
# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||
TestRunStats( TestRunStats const& _other )
|
||||
: runInfo( _other.runInfo ),
|
||||
totals( _other.totals ),
|
||||
|
@ -21,8 +21,11 @@
|
||||
#include "catch_objc_arc.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef CATCH_CPP11_OR_GREATER
|
||||
#ifdef CATCH_CONFIG_CPP11_TUPLE
|
||||
#include <tuple>
|
||||
#endif
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP11_IS_ENUM
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
@ -105,7 +108,7 @@ namespace Detail {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CPP11_OR_GREATER)
|
||||
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
|
||||
template<typename T,
|
||||
bool IsEnum = std::is_enum<T>::value
|
||||
>
|
||||
@ -127,7 +130,7 @@ namespace Detail {
|
||||
#endif
|
||||
template<bool C>
|
||||
struct StringMakerBase {
|
||||
#if defined(CATCH_CPP11_OR_GREATER)
|
||||
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
|
||||
template<typename T>
|
||||
static std::string convert( T const& v )
|
||||
{
|
||||
@ -201,7 +204,7 @@ std::string toString( std::vector<T,Allocator> const& v ) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef CATCH_CPP11_OR_GREATER
|
||||
#ifdef CATCH_CONFIG_CPP11_TUPLE
|
||||
|
||||
// toString for tuples
|
||||
namespace TupleDetail {
|
||||
@ -241,7 +244,7 @@ struct StringMaker<std::tuple<Types...>> {
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif // CATCH_CONFIG_CPP11_TUPLE
|
||||
|
||||
namespace Detail {
|
||||
template<typename T>
|
||||
|
@ -67,27 +67,6 @@ namespace Catch {
|
||||
endElement();
|
||||
}
|
||||
|
||||
//# ifndef CATCH_CPP11_OR_GREATER
|
||||
// XmlWriter& operator = ( XmlWriter const& other ) {
|
||||
// XmlWriter temp( other );
|
||||
// swap( temp );
|
||||
// return *this;
|
||||
// }
|
||||
//# else
|
||||
// XmlWriter( XmlWriter const& ) = default;
|
||||
// XmlWriter( XmlWriter && ) = default;
|
||||
// XmlWriter& operator = ( XmlWriter const& ) = default;
|
||||
// XmlWriter& operator = ( XmlWriter && ) = default;
|
||||
//# endif
|
||||
//
|
||||
// void swap( XmlWriter& other ) {
|
||||
// std::swap( m_tagIsOpen, other.m_tagIsOpen );
|
||||
// std::swap( m_needsNewline, other.m_needsNewline );
|
||||
// std::swap( m_tags, other.m_tags );
|
||||
// std::swap( m_indent, other.m_indent );
|
||||
// std::swap( m_os, other.m_os );
|
||||
// }
|
||||
|
||||
XmlWriter& startElement( std::string const& name ) {
|
||||
ensureTagClosed();
|
||||
newlineIfNecessary();
|
||||
|
Loading…
Reference in New Issue
Block a user