From a74d760d7454119e281c870393296b01cb495d5f Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 8 Jun 2016 19:14:54 +0100 Subject: [PATCH 1/6] Switched remaining std::auto_ptrs to use CATCH_AUTO_PTR --- include/internal/catch_config.hpp | 2 +- include/internal/catch_stream.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 2665f474..72b0f6c7 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -151,7 +151,7 @@ namespace Catch { } ConfigData m_data; - std::auto_ptr m_stream; + CATCH_AUTO_PTR( IStream const ) m_stream; TestSpec m_testSpec; }; diff --git a/include/internal/catch_stream.h b/include/internal/catch_stream.h index 5f22ad67..1bf5ee18 100644 --- a/include/internal/catch_stream.h +++ b/include/internal/catch_stream.h @@ -49,7 +49,7 @@ namespace Catch { class DebugOutStream : public IStream { - std::auto_ptr m_streamBuf; + CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; mutable std::ostream m_os; public: DebugOutStream(); From be3570ef22a450e7e040913822828468f70d7f81 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 9 Jun 2016 08:15:57 +0100 Subject: [PATCH 2/6] Use std::shuffle instead of (deprecated) std::random_shuffle if C++14 detected --- .../internal/catch_compiler_capabilities.h | 12 +++++-- .../catch_test_case_registry_impl.hpp | 33 ++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index ed4aa52b..5af1e76a 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -36,8 +36,16 @@ // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 -#if defined(__cplusplus) && __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER +#ifdef __cplusplus + +# if __cplusplus >= 201103L +# define CATCH_CPP11_OR_GREATER +# endif + +# if __cplusplus >= 201402L +# define CATCH_CPP14_OR_GREATER +# endif + #endif #ifdef __clang__ diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index cc48d917..7f49d692 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -19,13 +19,30 @@ #include #include -namespace Catch { +#ifdef CATCH_CPP14_OR_GREATER +#include +#endif - struct LexSort { - bool operator() (TestCase i,TestCase j) const { return (i + static void shuffle( V& vector ) { +#ifdef CATCH_CPP14_OR_GREATER + std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); +#else + std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); +#endif + } }; inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { @@ -34,14 +51,12 @@ namespace Catch { switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end(), LexSort() ); + std::sort( sorted.begin(), sorted.end() ); break; case RunTests::InRandomOrder: { seedRng( config ); - - RandomNumberGenerator rng; - std::random_shuffle( sorted.begin(), sorted.end(), rng ); + RandomNumberGenerator::shuffle( sorted ); } break; case RunTests::InDeclarationOrder: From ac220289a617481b05b4d7821a19a89ba20d282c Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 9 Jun 2016 08:19:23 +0100 Subject: [PATCH 3/6] v1.5.5: Deal with auto_ptr and random_shuffle hard deprecations in C++14 --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- single_include/catch.hpp | 53 +++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9f4c2583..a57c21fe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.5.4* +*v1.5.5* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 35997681..eebb3791 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -37,7 +37,7 @@ namespace Catch { return os; } - Version libraryVersion( 1, 5, 4, "", 0 ); + Version libraryVersion( 1, 5, 5, "", 0 ); } diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 7df2fd09..79570fb4 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v1.5.4 - * Generated: 2016-05-12 19:16:01.957320 + * Catch v1.5.5 + * Generated: 2016-06-09 08:17:50.409622 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -106,8 +106,16 @@ // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 -#if defined(__cplusplus) && __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER +#ifdef __cplusplus + +# if __cplusplus >= 201103L +# define CATCH_CPP11_OR_GREATER +# endif + +# if __cplusplus >= 201402L +# define CATCH_CPP14_OR_GREATER +# endif + #endif #ifdef __clang__ @@ -3450,7 +3458,7 @@ namespace Catch { }; class DebugOutStream : public IStream { - std::auto_ptr m_streamBuf; + CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; mutable std::ostream m_os; public: DebugOutStream(); @@ -3598,7 +3606,7 @@ namespace Catch { } ConfigData m_data; - std::auto_ptr m_stream; + CATCH_AUTO_PTR( IStream const ) m_stream; TestSpec m_testSpec; }; @@ -6439,13 +6447,30 @@ namespace Catch { #include #include +#ifdef CATCH_CPP14_OR_GREATER +#include +#endif + namespace Catch { - struct LexSort { - bool operator() (TestCase i,TestCase j) const { return (i + static void shuffle( V& vector ) { +#ifdef CATCH_CPP14_OR_GREATER + std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); +#else + std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); +#endif + } }; inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { @@ -6454,14 +6479,12 @@ namespace Catch { switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end(), LexSort() ); + std::sort( sorted.begin(), sorted.end() ); break; case RunTests::InRandomOrder: { seedRng( config ); - - RandomNumberGenerator rng; - std::random_shuffle( sorted.begin(), sorted.end(), rng ); + RandomNumberGenerator::shuffle( sorted ); } break; case RunTests::InDeclarationOrder: @@ -7547,7 +7570,7 @@ namespace Catch { return os; } - Version libraryVersion( 1, 5, 4, "", 0 ); + Version libraryVersion( 1, 5, 5, "", 0 ); } From 1aa6c91e6428d3f25bc4329ef6eb7938cd53a157 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 9 Jun 2016 19:07:05 +0100 Subject: [PATCH 4/6] Fixed RNG issue with pre C++14 compilers --- include/internal/catch_test_case_registry_impl.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index 7f49d692..04bd37fc 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -37,10 +37,11 @@ namespace Catch { #endif template static void shuffle( V& vector ) { + RandomNumberGenerator rng; #ifdef CATCH_CPP14_OR_GREATER - std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); + std::shuffle( vector.begin(), vector.end(), rng ); #else - std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); + std::random_shuffle( vector.begin(), vector.end(), rng ); #endif } }; From 742457cbcf4756271eb12c86140100e64e35dac6 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 9 Jun 2016 19:19:55 +0100 Subject: [PATCH 5/6] Use Clara v0.0.2.4 (updated) - fix for string lengths --- include/external/clara.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/external/clara.h b/include/external/clara.h index 6ab30136..369c1b76 100644 --- a/include/external/clara.h +++ b/include/external/clara.h @@ -589,7 +589,7 @@ namespace Clara { } } Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( std::string( ":=\0", 5 ).find( c ) == std::string::npos ) + if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) return mode; std::string optName = arg.substr( from, i-from ); @@ -603,7 +603,7 @@ namespace Clara { return None; } Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos ) + if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos ) return mode; std::string data = arg.substr( from, i-from ); From 35f510545d55a831372d3113747bf1314ff4f2ef Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 9 Jun 2016 19:21:09 +0100 Subject: [PATCH 6/6] v1.5.6 --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- single_include/catch.hpp | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a57c21fe..d9a588a4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.5.5* +*v1.5.6* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index eebb3791..ad9322ef 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -37,7 +37,7 @@ namespace Catch { return os; } - Version libraryVersion( 1, 5, 5, "", 0 ); + Version libraryVersion( 1, 5, 6, "", 0 ); } diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 79570fb4..879fc5b1 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v1.5.5 - * Generated: 2016-06-09 08:17:50.409622 + * Catch v1.5.6 + * Generated: 2016-06-09 19:20:41.460328 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -4185,7 +4185,7 @@ namespace Clara { } } Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( std::string( ":=\0", 5 ).find( c ) == std::string::npos ) + if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) return mode; std::string optName = arg.substr( from, i-from ); @@ -4199,7 +4199,7 @@ namespace Clara { return None; } Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos ) + if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos ) return mode; std::string data = arg.substr( from, i-from ); @@ -6465,10 +6465,11 @@ namespace Catch { #endif template static void shuffle( V& vector ) { + RandomNumberGenerator rng; #ifdef CATCH_CPP14_OR_GREATER - std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); + std::shuffle( vector.begin(), vector.end(), rng ); #else - std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() ); + std::random_shuffle( vector.begin(), vector.end(), rng ); #endif } }; @@ -7570,7 +7571,7 @@ namespace Catch { return os; } - Version libraryVersion( 1, 5, 5, "", 0 ); + Version libraryVersion( 1, 5, 6, "", 0 ); }