From 7c9f92bc1c6e82ad5b6af8dff9f97af880fae9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 13 Oct 2019 23:44:18 +0200 Subject: [PATCH] v2.10.0 --- CMakeLists.txt | 2 +- README.md | 4 +- docs/configuration.md | 2 +- docs/generators.md | 4 +- docs/matchers.md | 4 +- docs/release-notes.md | 45 + include/catch.hpp | 4 +- include/internal/catch_version.cpp | 2 +- single_include/catch2/catch.hpp | 950 ++++++++++++------ .../catch2/catch_reporter_teamcity.hpp | 3 +- 10 files changed, 675 insertions(+), 345 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0abdbe82..edb91c43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ if(NOT DEFINED PROJECT_NAME) set(NOT_SUBPROJECT ON) endif() -project(Catch2 LANGUAGES CXX VERSION 2.9.2) +project(Catch2 LANGUAGES CXX VERSION 2.10.0) if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") diff --git a/README.md b/README.md index 98a95034..2b806cd4 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ [![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) [![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) -[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/8YrGVqYqqSC4Sc5R) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/00GdTUbFWaV3bNah) [![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) -The latest version of the single header can be downloaded directly using this link +The latest version of the single header can be downloaded directly using this link ## Catch2 is released! diff --git a/docs/configuration.md b/docs/configuration.md index ec042c23..599bb9ae 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -158,7 +158,7 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`. CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter -> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch X.Y.Z +> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch 2.10.0 Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support. diff --git a/docs/generators.md b/docs/generators.md index 34565a50..61276f3c 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -54,7 +54,7 @@ a test case, > `ChunkGenerator`, `RandomIntegerGenerator`, `RandomFloatGenerator` and `RangeGenerator` were introduced in Catch 2.7.0. -> `IteratorGenerator` was introduced in Catch X.Y.Z. +> `IteratorGenerator` was introduced in Catch 2.10.0. The generators also have associated helper functions that infer their type, making their usage much nicer. These are @@ -76,7 +76,7 @@ type, making their usage much nicer. These are > `chunk()`, `random()` and both `range()` functions were introduced in Catch 2.7.0. -> `from_range` has been introduced in Catch X.Y.Z +> `from_range` has been introduced in Catch 2.10.0 And can be used as shown in the example below to create a generator that returns 100 odd random number: diff --git a/docs/matchers.md b/docs/matchers.md index f10ae918..af2071e3 100644 --- a/docs/matchers.md +++ b/docs/matchers.md @@ -90,7 +90,7 @@ the helpers for this matcher, `WithinRel(double target, double margin)`, `WithinRel(float target)`. The latter two provide a default epsilon of machine epsilon * 100. -> `WithinRel` matcher was introduced in Catch X.Y.Z +> `WithinRel` matcher was introduced in Catch 2.10.0 ### Generic matchers Catch also aims to provide a set of generic matchers. Currently this set @@ -120,7 +120,7 @@ is `ExceptionMessageMatcher`, and we also provide a helper function The matched exception must publicly derive from `std::exception` and the message matching is done _exactly_, including case. -> `ExceptionMessageMatcher` was introduced in Catch X.Y.Z +> `ExceptionMessageMatcher` was introduced in Catch 2.10.0 Example use: ```cpp diff --git a/docs/release-notes.md b/docs/release-notes.md index 204cea34..0af35c67 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ # Release notes **Contents**
+[2.10.0](#2100)
[2.9.2](#292)
[2.9.1](#291)
[2.9.0](#290)
@@ -28,6 +29,50 @@ [Even Older versions](#even-older-versions)
+ +## 2.10.0 + +### Fixes +* `TEMPLATE_LIST_TEST_CASE` now properly handles non-copyable and non-movable types (#1729) +* Fixed compilation error on Solaris caused by a system header defining macro `TT` (#1722, #1723) +* `REGISTER_ENUM` will now fail at compilation time if the registered enum is too large +* Removed use of `std::is_same_v` in C++17 mode (#1757) +* Fixed parsing of escaped special characters when reading test specs from a file (#1767, #1769) + + +### Improvements +* Trailing and leading whitespace in test/section specs are now ignored. +* Writing to Android debug log now uses `__android_log_write` instead of `__android_log_print` +* Android logging support can now be turned on/off at compile time (#1743) + * The toggle is `CATCH_CONFIG_ANDROID_LOGWRITE` +* Added a generator that returns elements of a range + * Use via `from_range(from, to)` or `from_range(container)` +* Added support for CRTs that do not provide `std::nextafter` (#1739) + * They must still provide global `nextafter{f,l,}` + * Enabled via `CATCH_CONFIG_GLOBAL_NEXTAFTER` +* Special cased `Approx(inf)` not to match non-infinite values + * Very strictly speaking this might be a breaking change, but it should match user expectations better +* The output of benchmarking through the Console reporter when `--benchmark-no-analysis` is set is now much simpler (#1768) +* Added a matcher that can be used for checking an exceptions message (#1649, #1728) + * The matcher helper function is called `Message` + * The exception must publicly derive from `std::exception` + * The matching is done exactly, including case and whitespace +* Added a matcher that can be used for checking relative equality of floating point numbers (#1746) + * Unlike `Approx`, it considers both sides when determining the allowed margin + * Special cases `NaN` and `INFINITY` to match user expectations + * The matcher helper function is called `WithinRel` +* The ULP matcher now allows for any possible distance between the two numbers +* The random number generators now use Catch-global instance of RNG (#1734, #1736) + * This means that nested random number generators actually generate different numbers + + +### Miscellaneous +* In-repo PNGs have been optimized to lower overhead of using Catch2 via git clone +* Catch2 now uses its own implementation of the URBG concept + * In the future we also plan to use our own implementation of the distributions from `` to provide cross-platform repeatability of random results + + + ## 2.9.2 ### Fixes diff --git a/include/catch.hpp b/include/catch.hpp index dba005ad..5d38092e 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -10,8 +10,8 @@ #define TWOBLUECUBES_CATCH_HPP_INCLUDED #define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 9 -#define CATCH_VERSION_PATCH 2 +#define CATCH_VERSION_MINOR 10 +#define CATCH_VERSION_PATCH 0 #ifdef __clang__ # pragma clang system_header diff --git a/include/internal/catch_version.cpp b/include/internal/catch_version.cpp index 03fded91..bb5b0616 100644 --- a/include/internal/catch_version.cpp +++ b/include/internal/catch_version.cpp @@ -37,7 +37,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 9, 2, "", 0 ); + static Version version( 2, 10, 0, "", 0 ); return version; } diff --git a/single_include/catch2/catch.hpp b/single_include/catch2/catch.hpp index 5feb2a4b..391db530 100644 --- a/single_include/catch2/catch.hpp +++ b/single_include/catch2/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.9.2 - * Generated: 2019-08-08 13:35:12.279703 + * Catch v2.10.0 + * Generated: 2019-10-13 22:24:46.755734 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. @@ -14,8 +14,8 @@ #define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 9 -#define CATCH_VERSION_PATCH 2 +#define CATCH_VERSION_MINOR 10 +#define CATCH_VERSION_PATCH 0 #ifdef __clang__ # pragma clang system_header @@ -186,6 +186,7 @@ namespace Catch { // Android somehow still does not support std::to_string #if defined(__ANDROID__) # define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE #endif //////////////////////////////////////////////////////////////////////////////// @@ -286,49 +287,43 @@ namespace Catch { #define CATCH_CONFIG_COLOUR_NONE #endif -//////////////////////////////////////////////////////////////////////////////// -// Check if string_view is available and usable -// The check is split apart to work around v140 (VS2015) preprocessor issue... -#if defined(__has_include) -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW -#endif +#if defined(__UCLIBC__) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER #endif -//////////////////////////////////////////////////////////////////////////////// -// Check if optional is available and usable +// Various stdlib support checks that require __has_include #if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include + // Check if string_view is available and usable + #if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif -//////////////////////////////////////////////////////////////////////////////// -// Check if byte is available and usable -#if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_BYTE -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include + // Check if optional is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -//////////////////////////////////////////////////////////////////////////////// -// Check if variant is available and usable -#if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 -# include -# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -# define CATCH_CONFIG_NO_CPP17_VARIANT -# else -# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -# else -# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -# endif // defined(__clang__) && (__clang_major__ < 8) -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include + // Check if byte is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) #if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) # define CATCH_CONFIG_COUNTER @@ -389,6 +384,14 @@ namespace Catch { # define CATCH_CONFIG_USE_ASYNC #endif +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS # define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS @@ -468,7 +471,7 @@ namespace Catch { SourceLineInfo( SourceLineInfo&& ) noexcept = default; SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - bool empty() const noexcept; + bool empty() const noexcept { return file[0] == '\0'; } bool operator == ( SourceLineInfo const& other ) const noexcept; bool operator < ( SourceLineInfo const& other ) const noexcept; @@ -551,6 +554,7 @@ namespace Catch { #include #include #include +#include namespace Catch { @@ -564,6 +568,7 @@ namespace Catch { class StringRef { public: using size_type = std::size_t; + using const_iterator = const char*; private: friend struct StringRefTestAccess; @@ -619,7 +624,9 @@ namespace Catch { return *this; } - operator std::string() const; + explicit operator std::string() const { + return std::string(m_start, m_size); + } void swap( StringRef& other ) noexcept; @@ -627,7 +634,10 @@ namespace Catch { auto operator == ( StringRef const& other ) const noexcept -> bool; auto operator != ( StringRef const& other ) const noexcept -> bool; - auto operator[] ( size_type index ) const noexcept -> char; + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } public: // named queries auto empty() const noexcept -> bool { @@ -637,7 +647,6 @@ namespace Catch { return m_size; } - auto numberOfCharacters() const noexcept -> size_type; auto c_str() const -> char const*; public: // substrings and searches @@ -647,15 +656,15 @@ namespace Catch { // Note that the pointer can change when if the StringRef is a substring auto currentData() const noexcept -> char const*; + public: // iterators + const_iterator begin() const { return m_start; } + const_iterator end() const { return m_start + m_size; } + private: // ownership queries - may not be consistent between calls auto isOwned() const noexcept -> bool; auto isSubstring() const noexcept -> bool; }; - auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; - auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; - auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; @@ -670,38 +679,6 @@ inline auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noex } // end catch_stringref.h -// start catch_type_traits.hpp - - -#include - -namespace Catch{ - -#ifdef CATCH_CPP17_OR_GREATER - template - inline constexpr auto is_unique = std::true_type{}; - - template - inline constexpr auto is_unique = std::bool_constant< - (!std::is_same_v && ...) && is_unique - >{}; -#else - -template -struct is_unique : std::true_type{}; - -template -struct is_unique : std::integral_constant -::value - && is_unique::value - && is_unique::value ->{}; - -#endif -} - -// end catch_type_traits.hpp // start catch_preprocessor.hpp @@ -814,7 +791,7 @@ struct is_unique : std::integral_constant template