| 1 |
Description: <short summary of the patch> |
| 2 |
TODO: Put a short summary on the line above and replace this paragraph |
| 3 |
with a longer explanation of this change. Complete the meta-information |
| 4 |
with other relevant fields (see below for details). To make it easier, the |
| 5 |
information below has been extracted from the changelog. Adjust it or drop |
| 6 |
it. |
| 7 |
. |
| 8 |
sfxr-qt (1.5.0+ds-1) unstable; urgency=medium |
| 9 |
. |
| 10 |
* New upstream version. |
| 11 |
Author: Gürkan Myczko <[email protected]> |
| 12 |
|
| 13 |
--- |
| 14 |
The information above should follow the Patch Tagging Guidelines, please |
| 15 |
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here |
| 16 |
are templates for supplementary fields that you might want to add: |
| 17 |
|
| 18 |
Origin: <vendor|upstream|other>, <url of original patch> |
| 19 |
Bug: <url in upstream bugtracker> |
| 20 |
Bug-Debian: https://bugs.debian.org/<bugnumber> |
| 21 |
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> |
| 22 |
Forwarded: <no|not-needed|url proving that it has been forwarded> |
| 23 |
Reviewed-By: <name and email of someone who approved the patch> |
| 24 |
Last-Update: 2022-08-16 |
| 25 |
|
| 26 |
--- sfxr-qt-1.5.0+ds.orig/3rdparty/catch2/single_include/catch2/catch.hpp |
| 27 |
+++ sfxr-qt-1.5.0+ds/3rdparty/catch2/single_include/catch2/catch.hpp |
| 28 |
@@ -1,9 +1,9 @@ |
| 29 |
/* |
| 30 |
- * Catch v2.9.2 |
| 31 |
- * Generated: 2019-08-08 13:35:12.279703 |
| 32 |
+ * Catch v2.13.9 |
| 33 |
+ * Generated: 2022-04-12 22:37:23.260201 |
| 34 |
* ---------------------------------------------------------- |
| 35 |
* This file has been merged from multiple headers. Please don't edit it directly |
| 36 |
- * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. |
| 37 |
+ * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. |
| 38 |
* |
| 39 |
* Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 40 |
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 41 |
@@ -14,8 +14,8 @@ |
| 42 |
|
| 43 |
|
| 44 |
#define CATCH_VERSION_MAJOR 2 |
| 45 |
-#define CATCH_VERSION_MINOR 9 |
| 46 |
-#define CATCH_VERSION_PATCH 2 |
| 47 |
+#define CATCH_VERSION_MINOR 13 |
| 48 |
+#define CATCH_VERSION_PATCH 9 |
| 49 |
|
| 50 |
#ifdef __clang__ |
| 51 |
# pragma clang system_header |
| 52 |
@@ -66,13 +66,16 @@ |
| 53 |
#if !defined(CATCH_CONFIG_IMPL_ONLY) |
| 54 |
// start catch_platform.h |
| 55 |
|
| 56 |
+// See e.g.: |
| 57 |
+// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html |
| 58 |
#ifdef __APPLE__ |
| 59 |
-# include <TargetConditionals.h> |
| 60 |
-# if TARGET_OS_OSX == 1 |
| 61 |
-# define CATCH_PLATFORM_MAC |
| 62 |
-# elif TARGET_OS_IPHONE == 1 |
| 63 |
-# define CATCH_PLATFORM_IPHONE |
| 64 |
-# endif |
| 65 |
+# include <TargetConditionals.h> |
| 66 |
+# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ |
| 67 |
+ (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) |
| 68 |
+# define CATCH_PLATFORM_MAC |
| 69 |
+# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) |
| 70 |
+# define CATCH_PLATFORM_IPHONE |
| 71 |
+# endif |
| 72 |
|
| 73 |
#elif defined(linux) || defined(__linux) || defined(__linux__) |
| 74 |
# define CATCH_PLATFORM_LINUX |
| 75 |
@@ -132,36 +135,51 @@ namespace Catch { |
| 76 |
|
| 77 |
#endif |
| 78 |
|
| 79 |
-#if defined(CATCH_CPP17_OR_GREATER) |
| 80 |
-# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 81 |
+// Only GCC compiler should be used in this block, so other compilers trying to |
| 82 |
+// mask themselves as GCC should be ignored. |
| 83 |
+#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) |
| 84 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) |
| 85 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) |
| 86 |
+ |
| 87 |
+# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) |
| 88 |
+ |
| 89 |
#endif |
| 90 |
|
| 91 |
-#ifdef __clang__ |
| 92 |
+#if defined(__clang__) |
| 93 |
+ |
| 94 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) |
| 95 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) |
| 96 |
+ |
| 97 |
+// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug |
| 98 |
+// which results in calls to destructors being emitted for each temporary, |
| 99 |
+// without a matching initialization. In practice, this can result in something |
| 100 |
+// like `std::string::~string` being called on an uninitialized value. |
| 101 |
+// |
| 102 |
+// For example, this code will likely segfault under IBM XL: |
| 103 |
+// ``` |
| 104 |
+// REQUIRE(std::string("12") + "34" == "1234") |
| 105 |
+// ``` |
| 106 |
+// |
| 107 |
+// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. |
| 108 |
+# if !defined(__ibmxl__) && !defined(__CUDACC__) |
| 109 |
+# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ |
| 110 |
+# endif |
| 111 |
+ |
| 112 |
+# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 113 |
+ _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ |
| 114 |
+ _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") |
| 115 |
+ |
| 116 |
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ |
| 117 |
+ _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) |
| 118 |
|
| 119 |
-# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 120 |
- _Pragma( "clang diagnostic push" ) \ |
| 121 |
- _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ |
| 122 |
- _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") |
| 123 |
-# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 124 |
- _Pragma( "clang diagnostic pop" ) |
| 125 |
- |
| 126 |
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ |
| 127 |
- _Pragma( "clang diagnostic push" ) \ |
| 128 |
- _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) |
| 129 |
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ |
| 130 |
- _Pragma( "clang diagnostic pop" ) |
| 131 |
- |
| 132 |
-# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ |
| 133 |
- _Pragma( "clang diagnostic push" ) \ |
| 134 |
- _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) |
| 135 |
-# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \ |
| 136 |
- _Pragma( "clang diagnostic pop" ) |
| 137 |
- |
| 138 |
-# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 139 |
- _Pragma( "clang diagnostic push" ) \ |
| 140 |
- _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) |
| 141 |
-# define CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 142 |
- _Pragma( "clang diagnostic pop" ) |
| 143 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ |
| 144 |
+ _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) |
| 145 |
+ |
| 146 |
+# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 147 |
+ _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) |
| 148 |
+ |
| 149 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 150 |
+ _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) |
| 151 |
|
| 152 |
#endif // __clang__ |
| 153 |
|
| 154 |
@@ -186,6 +204,7 @@ namespace Catch { |
| 155 |
// Android somehow still does not support std::to_string |
| 156 |
#if defined(__ANDROID__) |
| 157 |
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING |
| 158 |
+# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE |
| 159 |
#endif |
| 160 |
|
| 161 |
//////////////////////////////////////////////////////////////////////////////// |
| 162 |
@@ -219,11 +238,7 @@ namespace Catch { |
| 163 |
|
| 164 |
//////////////////////////////////////////////////////////////////////////////// |
| 165 |
// Visual C++ |
| 166 |
-#ifdef _MSC_VER |
| 167 |
- |
| 168 |
-# if _MSC_VER >= 1900 // Visual Studio 2015 or newer |
| 169 |
-# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 170 |
-# endif |
| 171 |
+#if defined(_MSC_VER) |
| 172 |
|
| 173 |
// Universal Windows platform does not support SEH |
| 174 |
// Or console colours (or console at all...) |
| 175 |
@@ -233,12 +248,20 @@ namespace Catch { |
| 176 |
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH |
| 177 |
# endif |
| 178 |
|
| 179 |
+# if !defined(__clang__) // Handle Clang masquerading for msvc |
| 180 |
+ |
| 181 |
// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ |
| 182 |
// _MSVC_TRADITIONAL == 0 means new conformant preprocessor |
| 183 |
// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor |
| 184 |
-# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) |
| 185 |
-# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 186 |
-# endif |
| 187 |
+# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) |
| 188 |
+# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 189 |
+# endif // MSVC_TRADITIONAL |
| 190 |
+ |
| 191 |
+// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` |
| 192 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) |
| 193 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) |
| 194 |
+# endif // __clang__ |
| 195 |
+ |
| 196 |
#endif // _MSC_VER |
| 197 |
|
| 198 |
#if defined(_REENTRANT) || defined(_MSC_VER) |
| 199 |
@@ -286,49 +309,46 @@ namespace Catch { |
| 200 |
#define CATCH_CONFIG_COLOUR_NONE |
| 201 |
#endif |
| 202 |
|
| 203 |
-//////////////////////////////////////////////////////////////////////////////// |
| 204 |
-// Check if string_view is available and usable |
| 205 |
-// The check is split apart to work around v140 (VS2015) preprocessor issue... |
| 206 |
-#if defined(__has_include) |
| 207 |
-#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER) |
| 208 |
-# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW |
| 209 |
-#endif |
| 210 |
+#if !defined(_GLIBCXX_USE_C99_MATH_TR1) |
| 211 |
+#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER |
| 212 |
#endif |
| 213 |
|
| 214 |
-//////////////////////////////////////////////////////////////////////////////// |
| 215 |
-// Check if optional is available and usable |
| 216 |
+// Various stdlib support checks that require __has_include |
| 217 |
#if defined(__has_include) |
| 218 |
-# if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) |
| 219 |
-# define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL |
| 220 |
-# endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) |
| 221 |
-#endif // __has_include |
| 222 |
- |
| 223 |
-//////////////////////////////////////////////////////////////////////////////// |
| 224 |
-// Check if byte is available and usable |
| 225 |
-#if defined(__has_include) |
| 226 |
-# if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) |
| 227 |
-# define CATCH_INTERNAL_CONFIG_CPP17_BYTE |
| 228 |
-# endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) |
| 229 |
-#endif // __has_include |
| 230 |
- |
| 231 |
-//////////////////////////////////////////////////////////////////////////////// |
| 232 |
-// Check if variant is available and usable |
| 233 |
-#if defined(__has_include) |
| 234 |
-# if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) |
| 235 |
-# if defined(__clang__) && (__clang_major__ < 8) |
| 236 |
- // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 |
| 237 |
- // fix should be in clang 8, workaround in libstdc++ 8.2 |
| 238 |
-# include <ciso646> |
| 239 |
-# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
| 240 |
-# define CATCH_CONFIG_NO_CPP17_VARIANT |
| 241 |
-# else |
| 242 |
-# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
| 243 |
-# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
| 244 |
-# else |
| 245 |
-# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
| 246 |
-# endif // defined(__clang__) && (__clang_major__ < 8) |
| 247 |
-# endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) |
| 248 |
-#endif // __has_include |
| 249 |
+ // Check if string_view is available and usable |
| 250 |
+ #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER) |
| 251 |
+ # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW |
| 252 |
+ #endif |
| 253 |
+ |
| 254 |
+ // Check if optional is available and usable |
| 255 |
+ # if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) |
| 256 |
+ # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL |
| 257 |
+ # endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) |
| 258 |
+ |
| 259 |
+ // Check if byte is available and usable |
| 260 |
+ # if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) |
| 261 |
+ # include <cstddef> |
| 262 |
+ # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) |
| 263 |
+ # define CATCH_INTERNAL_CONFIG_CPP17_BYTE |
| 264 |
+ # endif |
| 265 |
+ # endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) |
| 266 |
+ |
| 267 |
+ // Check if variant is available and usable |
| 268 |
+ # if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) |
| 269 |
+ # if defined(__clang__) && (__clang_major__ < 8) |
| 270 |
+ // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 |
| 271 |
+ // fix should be in clang 8, workaround in libstdc++ 8.2 |
| 272 |
+ # include <ciso646> |
| 273 |
+ # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
| 274 |
+ # define CATCH_CONFIG_NO_CPP17_VARIANT |
| 275 |
+ # else |
| 276 |
+ # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
| 277 |
+ # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
| 278 |
+ # else |
| 279 |
+ # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
| 280 |
+ # endif // defined(__clang__) && (__clang_major__ < 8) |
| 281 |
+ # endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) |
| 282 |
+#endif // defined(__has_include) |
| 283 |
|
| 284 |
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) |
| 285 |
# define CATCH_CONFIG_COUNTER |
| 286 |
@@ -353,10 +373,6 @@ namespace Catch { |
| 287 |
# define CATCH_CONFIG_CPP17_OPTIONAL |
| 288 |
#endif |
| 289 |
|
| 290 |
-#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
| 291 |
-# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 292 |
-#endif |
| 293 |
- |
| 294 |
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) |
| 295 |
# define CATCH_CONFIG_CPP17_STRING_VIEW |
| 296 |
#endif |
| 297 |
@@ -389,21 +405,49 @@ namespace Catch { |
| 298 |
# define CATCH_CONFIG_USE_ASYNC |
| 299 |
#endif |
| 300 |
|
| 301 |
+#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) |
| 302 |
+# define CATCH_CONFIG_ANDROID_LOGWRITE |
| 303 |
+#endif |
| 304 |
+ |
| 305 |
+#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) |
| 306 |
+# define CATCH_CONFIG_GLOBAL_NEXTAFTER |
| 307 |
+#endif |
| 308 |
+ |
| 309 |
+// Even if we do not think the compiler has that warning, we still have |
| 310 |
+// to provide a macro that can be used by the code. |
| 311 |
+#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) |
| 312 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION |
| 313 |
+#endif |
| 314 |
+#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) |
| 315 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 316 |
+#endif |
| 317 |
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) |
| 318 |
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS |
| 319 |
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS |
| 320 |
#endif |
| 321 |
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) |
| 322 |
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
| 323 |
-# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 324 |
#endif |
| 325 |
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) |
| 326 |
# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS |
| 327 |
-# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS |
| 328 |
#endif |
| 329 |
#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) |
| 330 |
# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS |
| 331 |
-# define CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS |
| 332 |
+#endif |
| 333 |
+ |
| 334 |
+// The goal of this macro is to avoid evaluation of the arguments, but |
| 335 |
+// still have the compiler warn on problems inside... |
| 336 |
+#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) |
| 337 |
+# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) |
| 338 |
+#endif |
| 339 |
+ |
| 340 |
+#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) |
| 341 |
+# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 342 |
+#elif defined(__clang__) && (__clang_major__ < 5) |
| 343 |
+# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 344 |
+#endif |
| 345 |
+ |
| 346 |
+#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) |
| 347 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 348 |
#endif |
| 349 |
|
| 350 |
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 351 |
@@ -468,7 +512,7 @@ namespace Catch { |
| 352 |
SourceLineInfo( SourceLineInfo&& ) noexcept = default; |
| 353 |
SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; |
| 354 |
|
| 355 |
- bool empty() const noexcept; |
| 356 |
+ bool empty() const noexcept { return file[0] == '\0'; } |
| 357 |
bool operator == ( SourceLineInfo const& other ) const noexcept; |
| 358 |
bool operator < ( SourceLineInfo const& other ) const noexcept; |
| 359 |
|
| 360 |
@@ -509,9 +553,10 @@ namespace Catch { |
| 361 |
} // end namespace Catch |
| 362 |
|
| 363 |
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ |
| 364 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 365 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 366 |
namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ |
| 367 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 368 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 369 |
|
| 370 |
// end catch_tag_alias_autoregistrar.h |
| 371 |
// start catch_test_registry.h |
| 372 |
@@ -551,53 +596,30 @@ namespace Catch { |
| 373 |
#include <cstddef> |
| 374 |
#include <string> |
| 375 |
#include <iosfwd> |
| 376 |
+#include <cassert> |
| 377 |
|
| 378 |
namespace Catch { |
| 379 |
|
| 380 |
/// A non-owning string class (similar to the forthcoming std::string_view) |
| 381 |
/// Note that, because a StringRef may be a substring of another string, |
| 382 |
- /// it may not be null terminated. c_str() must return a null terminated |
| 383 |
- /// string, however, and so the StringRef will internally take ownership |
| 384 |
- /// (taking a copy), if necessary. In theory this ownership is not externally |
| 385 |
- /// visible - but it does mean (substring) StringRefs should not be shared between |
| 386 |
- /// threads. |
| 387 |
+ /// it may not be null terminated. |
| 388 |
class StringRef { |
| 389 |
public: |
| 390 |
using size_type = std::size_t; |
| 391 |
+ using const_iterator = const char*; |
| 392 |
|
| 393 |
private: |
| 394 |
- friend struct StringRefTestAccess; |
| 395 |
- |
| 396 |
- char const* m_start; |
| 397 |
- size_type m_size; |
| 398 |
- |
| 399 |
- char* m_data = nullptr; |
| 400 |
- |
| 401 |
- void takeOwnership(); |
| 402 |
- |
| 403 |
static constexpr char const* const s_empty = ""; |
| 404 |
|
| 405 |
- public: // construction/ assignment |
| 406 |
- StringRef() noexcept |
| 407 |
- : StringRef( s_empty, 0 ) |
| 408 |
- {} |
| 409 |
+ char const* m_start = s_empty; |
| 410 |
+ size_type m_size = 0; |
| 411 |
|
| 412 |
- StringRef( StringRef const& other ) noexcept |
| 413 |
- : m_start( other.m_start ), |
| 414 |
- m_size( other.m_size ) |
| 415 |
- {} |
| 416 |
- |
| 417 |
- StringRef( StringRef&& other ) noexcept |
| 418 |
- : m_start( other.m_start ), |
| 419 |
- m_size( other.m_size ), |
| 420 |
- m_data( other.m_data ) |
| 421 |
- { |
| 422 |
- other.m_data = nullptr; |
| 423 |
- } |
| 424 |
+ public: // construction |
| 425 |
+ constexpr StringRef() noexcept = default; |
| 426 |
|
| 427 |
StringRef( char const* rawChars ) noexcept; |
| 428 |
|
| 429 |
- StringRef( char const* rawChars, size_type size ) noexcept |
| 430 |
+ constexpr StringRef( char const* rawChars, size_type size ) noexcept |
| 431 |
: m_start( rawChars ), |
| 432 |
m_size( size ) |
| 433 |
{} |
| 434 |
@@ -607,101 +629,64 @@ namespace Catch { |
| 435 |
m_size( stdString.size() ) |
| 436 |
{} |
| 437 |
|
| 438 |
- ~StringRef() noexcept { |
| 439 |
- delete[] m_data; |
| 440 |
+ explicit operator std::string() const { |
| 441 |
+ return std::string(m_start, m_size); |
| 442 |
} |
| 443 |
|
| 444 |
- auto operator = ( StringRef const &other ) noexcept -> StringRef& { |
| 445 |
- delete[] m_data; |
| 446 |
- m_data = nullptr; |
| 447 |
- m_start = other.m_start; |
| 448 |
- m_size = other.m_size; |
| 449 |
- return *this; |
| 450 |
- } |
| 451 |
- |
| 452 |
- operator std::string() const; |
| 453 |
- |
| 454 |
- void swap( StringRef& other ) noexcept; |
| 455 |
- |
| 456 |
public: // operators |
| 457 |
auto operator == ( StringRef const& other ) const noexcept -> bool; |
| 458 |
- auto operator != ( StringRef const& other ) const noexcept -> bool; |
| 459 |
+ auto operator != (StringRef const& other) const noexcept -> bool { |
| 460 |
+ return !(*this == other); |
| 461 |
+ } |
| 462 |
|
| 463 |
- auto operator[] ( size_type index ) const noexcept -> char; |
| 464 |
+ auto operator[] ( size_type index ) const noexcept -> char { |
| 465 |
+ assert(index < m_size); |
| 466 |
+ return m_start[index]; |
| 467 |
+ } |
| 468 |
|
| 469 |
public: // named queries |
| 470 |
- auto empty() const noexcept -> bool { |
| 471 |
+ constexpr auto empty() const noexcept -> bool { |
| 472 |
return m_size == 0; |
| 473 |
} |
| 474 |
- auto size() const noexcept -> size_type { |
| 475 |
+ constexpr auto size() const noexcept -> size_type { |
| 476 |
return m_size; |
| 477 |
} |
| 478 |
|
| 479 |
- auto numberOfCharacters() const noexcept -> size_type; |
| 480 |
+ // Returns the current start pointer. If the StringRef is not |
| 481 |
+ // null-terminated, throws std::domain_exception |
| 482 |
auto c_str() const -> char const*; |
| 483 |
|
| 484 |
public: // substrings and searches |
| 485 |
- auto substr( size_type start, size_type size ) const noexcept -> StringRef; |
| 486 |
+ // Returns a substring of [start, start + length). |
| 487 |
+ // If start + length > size(), then the substring is [start, size()). |
| 488 |
+ // If start > size(), then the substring is empty. |
| 489 |
+ auto substr( size_type start, size_type length ) const noexcept -> StringRef; |
| 490 |
|
| 491 |
- // Returns the current start pointer. |
| 492 |
- // Note that the pointer can change when if the StringRef is a substring |
| 493 |
- auto currentData() const noexcept -> char const*; |
| 494 |
+ // Returns the current start pointer. May not be null-terminated. |
| 495 |
+ auto data() const noexcept -> char const*; |
| 496 |
|
| 497 |
- private: // ownership queries - may not be consistent between calls |
| 498 |
- auto isOwned() const noexcept -> bool; |
| 499 |
- auto isSubstring() const noexcept -> bool; |
| 500 |
- }; |
| 501 |
+ constexpr auto isNullTerminated() const noexcept -> bool { |
| 502 |
+ return m_start[m_size] == '\0'; |
| 503 |
+ } |
| 504 |
|
| 505 |
- auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; |
| 506 |
- auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; |
| 507 |
- auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; |
| 508 |
+ public: // iterators |
| 509 |
+ constexpr const_iterator begin() const { return m_start; } |
| 510 |
+ constexpr const_iterator end() const { return m_start + m_size; } |
| 511 |
+ }; |
| 512 |
|
| 513 |
auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; |
| 514 |
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; |
| 515 |
|
| 516 |
- inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { |
| 517 |
+ constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { |
| 518 |
return StringRef( rawChars, size ); |
| 519 |
} |
| 520 |
- |
| 521 |
} // namespace Catch |
| 522 |
|
| 523 |
-inline auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { |
| 524 |
+constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { |
| 525 |
return Catch::StringRef( rawChars, size ); |
| 526 |
} |
| 527 |
|
| 528 |
// end catch_stringref.h |
| 529 |
-// start catch_type_traits.hpp |
| 530 |
- |
| 531 |
- |
| 532 |
-#include <type_traits> |
| 533 |
- |
| 534 |
-namespace Catch{ |
| 535 |
- |
| 536 |
-#ifdef CATCH_CPP17_OR_GREATER |
| 537 |
- template <typename...> |
| 538 |
- inline constexpr auto is_unique = std::true_type{}; |
| 539 |
- |
| 540 |
- template <typename T, typename... Rest> |
| 541 |
- inline constexpr auto is_unique<T, Rest...> = std::bool_constant< |
| 542 |
- (!std::is_same_v<T, Rest> && ...) && is_unique<Rest...> |
| 543 |
- >{}; |
| 544 |
-#else |
| 545 |
- |
| 546 |
-template <typename...> |
| 547 |
-struct is_unique : std::true_type{}; |
| 548 |
- |
| 549 |
-template <typename T0, typename T1, typename... Rest> |
| 550 |
-struct is_unique<T0, T1, Rest...> : std::integral_constant |
| 551 |
-<bool, |
| 552 |
- !std::is_same<T0, T1>::value |
| 553 |
- && is_unique<T0, Rest...>::value |
| 554 |
- && is_unique<T1, Rest...>::value |
| 555 |
->{}; |
| 556 |
- |
| 557 |
-#endif |
| 558 |
-} |
| 559 |
- |
| 560 |
-// end catch_type_traits.hpp |
| 561 |
// start catch_preprocessor.hpp |
| 562 |
|
| 563 |
|
| 564 |
@@ -786,7 +771,7 @@ struct is_unique<T0, T1, Rest...> : std: |
| 565 |
#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) |
| 566 |
#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) |
| 567 |
#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) |
| 568 |
-#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) |
| 569 |
+#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) |
| 570 |
#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) |
| 571 |
#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) |
| 572 |
#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) |
| 573 |
@@ -798,35 +783,49 @@ struct is_unique<T0, T1, Rest...> : std: |
| 574 |
template<typename...> struct TypeList {};\ |
| 575 |
template<typename...Ts>\ |
| 576 |
constexpr auto get_wrapper() noexcept -> TypeList<Ts...> { return {}; }\ |
| 577 |
+ template<template<typename...> class...> struct TemplateTypeList{};\ |
| 578 |
+ template<template<typename...> class...Cs>\ |
| 579 |
+ constexpr auto get_wrapper() noexcept -> TemplateTypeList<Cs...> { return {}; }\ |
| 580 |
+ template<typename...>\ |
| 581 |
+ struct append;\ |
| 582 |
+ template<typename...>\ |
| 583 |
+ struct rewrap;\ |
| 584 |
+ template<template<typename...> class, typename...>\ |
| 585 |
+ struct create;\ |
| 586 |
+ template<template<typename...> class, typename>\ |
| 587 |
+ struct convert;\ |
| 588 |
\ |
| 589 |
- template<template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2> \ |
| 590 |
- constexpr auto append(L1<E1...>, L2<E2...>) noexcept -> L1<E1...,E2...> { return {}; }\ |
| 591 |
+ template<typename T> \ |
| 592 |
+ struct append<T> { using type = T; };\ |
| 593 |
template< template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2, typename...Rest>\ |
| 594 |
- constexpr auto append(L1<E1...>, L2<E2...>, Rest...) noexcept -> decltype(append(L1<E1...,E2...>{}, Rest{}...)) { return {}; }\ |
| 595 |
+ struct append<L1<E1...>, L2<E2...>, Rest...> { using type = typename append<L1<E1...,E2...>, Rest...>::type; };\ |
| 596 |
template< template<typename...> class L1, typename...E1, typename...Rest>\ |
| 597 |
- constexpr auto append(L1<E1...>, TypeList<mpl_::na>, Rest...) noexcept -> L1<E1...> { return {}; }\ |
| 598 |
+ struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { using type = L1<E1...>; };\ |
| 599 |
\ |
| 600 |
template< template<typename...> class Container, template<typename...> class List, typename...elems>\ |
| 601 |
- constexpr auto rewrap(List<elems...>) noexcept -> TypeList<Container<elems...>> { return {}; }\ |
| 602 |
+ struct rewrap<TemplateTypeList<Container>, List<elems...>> { using type = TypeList<Container<elems...>>; };\ |
| 603 |
template< template<typename...> class Container, template<typename...> class List, class...Elems, typename...Elements>\ |
| 604 |
- constexpr auto rewrap(List<Elems...>,Elements...) noexcept -> decltype(append(TypeList<Container<Elems...>>{}, rewrap<Container>(Elements{}...))) { return {}; }\ |
| 605 |
+ struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; };\ |
| 606 |
\ |
| 607 |
template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\ |
| 608 |
- constexpr auto create(TypeList<Types...>) noexcept -> decltype(append(Final<>{}, rewrap<Containers>(Types{}...)...)) { return {}; }\ |
| 609 |
+ struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; };\ |
| 610 |
template<template <typename...> class Final, template <typename...> class List, typename...Ts>\ |
| 611 |
- constexpr auto convert(List<Ts...>) noexcept -> decltype(append(Final<>{},TypeList<Ts>{}...)) { return {}; } |
| 612 |
+ struct convert<Final, List<Ts...>> { using type = typename append<Final<>,TypeList<Ts>...>::type; }; |
| 613 |
|
| 614 |
#define INTERNAL_CATCH_NTTP_1(signature, ...)\ |
| 615 |
template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\ |
| 616 |
template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ |
| 617 |
constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \ |
| 618 |
+ template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\ |
| 619 |
+ template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\ |
| 620 |
+ constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \ |
| 621 |
\ |
| 622 |
template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\ |
| 623 |
- constexpr auto rewrap(List<__VA_ARGS__>) noexcept -> TypeList<Container<__VA_ARGS__>> { return {}; }\ |
| 624 |
+ struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\ |
| 625 |
template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\ |
| 626 |
- constexpr auto rewrap(List<__VA_ARGS__>,Elements...elems) noexcept -> decltype(append(TypeList<Container<__VA_ARGS__>>{}, rewrap<Container>(elems...))) { return {}; }\ |
| 627 |
+ struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; };\ |
| 628 |
template<template <typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Containers, typename...Types>\ |
| 629 |
- constexpr auto create(TypeList<Types...>) noexcept -> decltype(append(Final<>{}, rewrap<Containers>(Types{}...)...)) { return {}; } |
| 630 |
+ struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; }; |
| 631 |
|
| 632 |
#define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName) |
| 633 |
#define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\ |
| 634 |
@@ -922,22 +921,33 @@ struct is_unique<T0, T1, Rest...> : std: |
| 635 |
#include <type_traits> |
| 636 |
|
| 637 |
namespace Catch { |
| 638 |
-template<typename T> |
| 639 |
-struct always_false : std::false_type {}; |
| 640 |
+ template<typename T> |
| 641 |
+ struct always_false : std::false_type {}; |
| 642 |
|
| 643 |
-template <typename> struct true_given : std::true_type {}; |
| 644 |
-struct is_callable_tester { |
| 645 |
- template <typename Fun, typename... Args> |
| 646 |
- true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> static test(int); |
| 647 |
- template <typename...> |
| 648 |
- std::false_type static test(...); |
| 649 |
-}; |
| 650 |
+ template <typename> struct true_given : std::true_type {}; |
| 651 |
+ struct is_callable_tester { |
| 652 |
+ template <typename Fun, typename... Args> |
| 653 |
+ true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> static test(int); |
| 654 |
+ template <typename...> |
| 655 |
+ std::false_type static test(...); |
| 656 |
+ }; |
| 657 |
|
| 658 |
-template <typename T> |
| 659 |
-struct is_callable; |
| 660 |
+ template <typename T> |
| 661 |
+ struct is_callable; |
| 662 |
+ |
| 663 |
+ template <typename Fun, typename... Args> |
| 664 |
+ struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {}; |
| 665 |
|
| 666 |
-template <typename Fun, typename... Args> |
| 667 |
-struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {}; |
| 668 |
+#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 |
| 669 |
+ // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is |
| 670 |
+ // replaced with std::invoke_result here. |
| 671 |
+ template <typename Func, typename... U> |
| 672 |
+ using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>; |
| 673 |
+#else |
| 674 |
+ // Keep ::type here because we still support C++11 |
| 675 |
+ template <typename Func, typename... U> |
| 676 |
+ using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U...)>::type>::type>::type; |
| 677 |
+#endif |
| 678 |
|
| 679 |
} // namespace Catch |
| 680 |
|
| 681 |
@@ -1002,55 +1012,58 @@ struct AutoReg : NonCopyable { |
| 682 |
|
| 683 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 684 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ |
| 685 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) |
| 686 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) |
| 687 |
#else |
| 688 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ |
| 689 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) |
| 690 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) |
| 691 |
#endif |
| 692 |
|
| 693 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 694 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ |
| 695 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) |
| 696 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) |
| 697 |
#else |
| 698 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ |
| 699 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 700 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 701 |
#endif |
| 702 |
|
| 703 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 704 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \ |
| 705 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 706 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 707 |
#else |
| 708 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \ |
| 709 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) |
| 710 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) |
| 711 |
#endif |
| 712 |
|
| 713 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 714 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \ |
| 715 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 716 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 717 |
#else |
| 718 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \ |
| 719 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) |
| 720 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) |
| 721 |
#endif |
| 722 |
#endif |
| 723 |
|
| 724 |
/////////////////////////////////////////////////////////////////////////////// |
| 725 |
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ |
| 726 |
static void TestName(); \ |
| 727 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 728 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 729 |
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
| 730 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 731 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 732 |
static void TestName() |
| 733 |
#define INTERNAL_CATCH_TESTCASE( ... ) \ |
| 734 |
- INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) |
| 735 |
+ INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), __VA_ARGS__ ) |
| 736 |
|
| 737 |
/////////////////////////////////////////////////////////////////////////////// |
| 738 |
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ |
| 739 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 740 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 741 |
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
| 742 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 743 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 744 |
|
| 745 |
/////////////////////////////////////////////////////////////////////////////// |
| 746 |
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ |
| 747 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 748 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 749 |
namespace{ \ |
| 750 |
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ |
| 751 |
@@ -1058,21 +1071,24 @@ struct AutoReg : NonCopyable { |
| 752 |
}; \ |
| 753 |
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
| 754 |
} \ |
| 755 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 756 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 757 |
void TestName::test() |
| 758 |
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ |
| 759 |
- INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) |
| 760 |
+ INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), ClassName, __VA_ARGS__ ) |
| 761 |
|
| 762 |
/////////////////////////////////////////////////////////////////////////////// |
| 763 |
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ |
| 764 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 765 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 766 |
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
| 767 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 768 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 769 |
|
| 770 |
/////////////////////////////////////////////////////////////////////////////// |
| 771 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\ |
| 772 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 773 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 774 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 775 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 776 |
INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\ |
| 777 |
namespace {\ |
| 778 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ |
| 779 |
@@ -1085,7 +1101,7 @@ struct AutoReg : NonCopyable { |
| 780 |
int index = 0; \ |
| 781 |
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ |
| 782 |
using expander = int[];\ |
| 783 |
- (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \ |
| 784 |
+ (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ |
| 785 |
}\ |
| 786 |
};\ |
| 787 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ |
| 788 |
@@ -1094,29 +1110,30 @@ struct AutoReg : NonCopyable { |
| 789 |
}();\ |
| 790 |
}\ |
| 791 |
}\ |
| 792 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 793 |
- CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 794 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 795 |
INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature)) |
| 796 |
|
| 797 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 798 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ |
| 799 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) |
| 800 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) |
| 801 |
#else |
| 802 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ |
| 803 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) |
| 804 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) |
| 805 |
#endif |
| 806 |
|
| 807 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 808 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ |
| 809 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) |
| 810 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) |
| 811 |
#else |
| 812 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ |
| 813 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 814 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 815 |
#endif |
| 816 |
|
| 817 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \ |
| 818 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 819 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 820 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 821 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 822 |
template<typename TestType> static void TestFuncName(); \ |
| 823 |
namespace {\ |
| 824 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ |
| 825 |
@@ -1130,40 +1147,41 @@ struct AutoReg : NonCopyable { |
| 826 |
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ |
| 827 |
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ |
| 828 |
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ |
| 829 |
- (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */\ |
| 830 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++)... };/* NOLINT */\ |
| 831 |
} \ |
| 832 |
}; \ |
| 833 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ |
| 834 |
- using TestInit = decltype(create<TestName, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>{})); \ |
| 835 |
+ using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ |
| 836 |
TestInit t; \ |
| 837 |
t.reg_tests(); \ |
| 838 |
return 0; \ |
| 839 |
}(); \ |
| 840 |
} \ |
| 841 |
} \ |
| 842 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 843 |
- CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 844 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 845 |
template<typename TestType> \ |
| 846 |
static void TestFuncName() |
| 847 |
|
| 848 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 849 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ |
| 850 |
- INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T,__VA_ARGS__) |
| 851 |
+ INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename T,__VA_ARGS__) |
| 852 |
#else |
| 853 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ |
| 854 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T, __VA_ARGS__ ) ) |
| 855 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename T, __VA_ARGS__ ) ) |
| 856 |
#endif |
| 857 |
|
| 858 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 859 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\ |
| 860 |
- INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__) |
| 861 |
+ INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__) |
| 862 |
#else |
| 863 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\ |
| 864 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 865 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) |
| 866 |
#endif |
| 867 |
|
| 868 |
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\ |
| 869 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 870 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 871 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 872 |
template<typename TestType> static void TestFunc(); \ |
| 873 |
namespace {\ |
| 874 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ |
| 875 |
@@ -1173,26 +1191,28 @@ struct AutoReg : NonCopyable { |
| 876 |
void reg_tests() { \ |
| 877 |
int index = 0; \ |
| 878 |
using expander = int[]; \ |
| 879 |
- (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */\ |
| 880 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ |
| 881 |
} \ |
| 882 |
};\ |
| 883 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ |
| 884 |
- using TestInit = decltype(convert<TestName>(std::declval<TmplList>())); \ |
| 885 |
+ using TestInit = typename convert<TestName, TmplList>::type; \ |
| 886 |
TestInit t; \ |
| 887 |
t.reg_tests(); \ |
| 888 |
return 0; \ |
| 889 |
- }(); \ |
| 890 |
+ }(); \ |
| 891 |
}}\ |
| 892 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 893 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 894 |
template<typename TestType> \ |
| 895 |
static void TestFunc() |
| 896 |
|
| 897 |
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \ |
| 898 |
- INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, TmplList ) |
| 899 |
+ INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, TmplList ) |
| 900 |
|
| 901 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \ |
| 902 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 903 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 904 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 905 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 906 |
namespace {\ |
| 907 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \ |
| 908 |
INTERNAL_CATCH_TYPE_GEN\ |
| 909 |
@@ -1205,7 +1225,7 @@ struct AutoReg : NonCopyable { |
| 910 |
int index = 0; \ |
| 911 |
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ |
| 912 |
using expander = int[];\ |
| 913 |
- (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \ |
| 914 |
+ (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ |
| 915 |
}\ |
| 916 |
};\ |
| 917 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ |
| 918 |
@@ -1214,29 +1234,30 @@ struct AutoReg : NonCopyable { |
| 919 |
}();\ |
| 920 |
}\ |
| 921 |
}\ |
| 922 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\ |
| 923 |
- CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS\ |
| 924 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 925 |
INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) |
| 926 |
|
| 927 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 928 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \ |
| 929 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 930 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 931 |
#else |
| 932 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \ |
| 933 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) |
| 934 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) |
| 935 |
#endif |
| 936 |
|
| 937 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 938 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \ |
| 939 |
- INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 940 |
+ INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 941 |
#else |
| 942 |
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \ |
| 943 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) |
| 944 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) |
| 945 |
#endif |
| 946 |
|
| 947 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\ |
| 948 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 949 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 950 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 951 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 952 |
template<typename TestType> \ |
| 953 |
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ |
| 954 |
void test();\ |
| 955 |
@@ -1253,40 +1274,41 @@ struct AutoReg : NonCopyable { |
| 956 |
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ |
| 957 |
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ |
| 958 |
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ |
| 959 |
- (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */ \ |
| 960 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++)... };/* NOLINT */ \ |
| 961 |
}\ |
| 962 |
};\ |
| 963 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ |
| 964 |
- using TestInit = decltype(create<TestNameClass, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>{}));\ |
| 965 |
+ using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\ |
| 966 |
TestInit t;\ |
| 967 |
t.reg_tests();\ |
| 968 |
return 0;\ |
| 969 |
}(); \ |
| 970 |
}\ |
| 971 |
}\ |
| 972 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 973 |
- CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 974 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 975 |
template<typename TestType> \ |
| 976 |
void TestName<TestType>::test() |
| 977 |
|
| 978 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 979 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ |
| 980 |
- INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 981 |
+ INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, typename T, __VA_ARGS__ ) |
| 982 |
#else |
| 983 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ |
| 984 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T,__VA_ARGS__ ) ) |
| 985 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, typename T,__VA_ARGS__ ) ) |
| 986 |
#endif |
| 987 |
|
| 988 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 989 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\ |
| 990 |
- INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 991 |
+ INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, Signature, __VA_ARGS__ ) |
| 992 |
#else |
| 993 |
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\ |
| 994 |
- INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature,__VA_ARGS__ ) ) |
| 995 |
+ INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, Signature,__VA_ARGS__ ) ) |
| 996 |
#endif |
| 997 |
|
| 998 |
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \ |
| 999 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 1000 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 1001 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 1002 |
template<typename TestType> \ |
| 1003 |
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ |
| 1004 |
void test();\ |
| 1005 |
@@ -1299,22 +1321,22 @@ struct AutoReg : NonCopyable { |
| 1006 |
void reg_tests(){\ |
| 1007 |
int index = 0;\ |
| 1008 |
using expander = int[];\ |
| 1009 |
- (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */ \ |
| 1010 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ |
| 1011 |
}\ |
| 1012 |
};\ |
| 1013 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ |
| 1014 |
- using TestInit = decltype(convert<TestNameClass>(std::declval<TmplList>()));\ |
| 1015 |
+ using TestInit = typename convert<TestNameClass, TmplList>::type;\ |
| 1016 |
TestInit t;\ |
| 1017 |
t.reg_tests();\ |
| 1018 |
return 0;\ |
| 1019 |
}(); \ |
| 1020 |
}}\ |
| 1021 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 1022 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 1023 |
template<typename TestType> \ |
| 1024 |
void TestName<TestType>::test() |
| 1025 |
|
| 1026 |
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \ |
| 1027 |
- INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, TmplList ) |
| 1028 |
+ INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, TmplList ) |
| 1029 |
|
| 1030 |
// end catch_test_registry.h |
| 1031 |
// start catch_capture.hpp |
| 1032 |
@@ -1415,7 +1437,7 @@ namespace Catch { |
| 1033 |
|
| 1034 |
auto makeStream( StringRef const &filename ) -> IStream const*; |
| 1035 |
|
| 1036 |
- class ReusableStringStream { |
| 1037 |
+ class ReusableStringStream : NonCopyable { |
| 1038 |
std::size_t m_index; |
| 1039 |
std::ostream* m_oss; |
| 1040 |
public: |
| 1041 |
@@ -1443,7 +1465,7 @@ namespace Catch { |
| 1042 |
namespace Detail { |
| 1043 |
struct EnumInfo { |
| 1044 |
StringRef m_name; |
| 1045 |
- std::vector<std::pair<int, std::string>> m_values; |
| 1046 |
+ std::vector<std::pair<int, StringRef>> m_values; |
| 1047 |
|
| 1048 |
~EnumInfo(); |
| 1049 |
|
| 1050 |
@@ -1458,6 +1480,7 @@ namespace Catch { |
| 1051 |
|
| 1052 |
template<typename E> |
| 1053 |
Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list<E> values ) { |
| 1054 |
+ static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int"); |
| 1055 |
std::vector<int> intValues; |
| 1056 |
intValues.reserve( values.size() ); |
| 1057 |
for( auto enumValue : values ) |
| 1058 |
@@ -1539,9 +1562,9 @@ namespace Catch { |
| 1059 |
|
| 1060 |
template<typename T> |
| 1061 |
class IsStreamInsertable { |
| 1062 |
- template<typename SS, typename TT> |
| 1063 |
+ template<typename Stream, typename U> |
| 1064 |
static auto test(int) |
| 1065 |
- -> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type()); |
| 1066 |
+ -> decltype(std::declval<Stream&>() << std::declval<U>(), std::true_type()); |
| 1067 |
|
| 1068 |
template<typename, typename> |
| 1069 |
static auto test(...)->std::false_type; |
| 1070 |
@@ -1802,8 +1825,8 @@ namespace Catch { |
| 1071 |
#endif |
| 1072 |
|
| 1073 |
namespace Detail { |
| 1074 |
- template<typename InputIterator> |
| 1075 |
- std::string rangeToString(InputIterator first, InputIterator last) { |
| 1076 |
+ template<typename InputIterator, typename Sentinel = InputIterator> |
| 1077 |
+ std::string rangeToString(InputIterator first, Sentinel last) { |
| 1078 |
ReusableStringStream rss; |
| 1079 |
rss << "{ "; |
| 1080 |
if (first != last) { |
| 1081 |
@@ -1961,20 +1984,27 @@ namespace Catch { |
| 1082 |
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER |
| 1083 |
|
| 1084 |
namespace Catch { |
| 1085 |
- struct not_this_one {}; // Tag type for detecting which begin/ end are being selected |
| 1086 |
- |
| 1087 |
- // Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace |
| 1088 |
+ // Import begin/ end from std here |
| 1089 |
using std::begin; |
| 1090 |
using std::end; |
| 1091 |
|
| 1092 |
- not_this_one begin( ... ); |
| 1093 |
- not_this_one end( ... ); |
| 1094 |
+ namespace detail { |
| 1095 |
+ template <typename...> |
| 1096 |
+ struct void_type { |
| 1097 |
+ using type = void; |
| 1098 |
+ }; |
| 1099 |
+ |
| 1100 |
+ template <typename T, typename = void> |
| 1101 |
+ struct is_range_impl : std::false_type { |
| 1102 |
+ }; |
| 1103 |
+ |
| 1104 |
+ template <typename T> |
| 1105 |
+ struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type { |
| 1106 |
+ }; |
| 1107 |
+ } // namespace detail |
| 1108 |
|
| 1109 |
template <typename T> |
| 1110 |
- struct is_range { |
| 1111 |
- static const bool value = |
| 1112 |
- !std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value && |
| 1113 |
- !std::is_same<decltype(end(std::declval<T>())), not_this_one>::value; |
| 1114 |
+ struct is_range : detail::is_range_impl<T> { |
| 1115 |
}; |
| 1116 |
|
| 1117 |
#if defined(_MANAGED) // Managed types are never ranges |
| 1118 |
@@ -2144,7 +2174,7 @@ namespace Catch { \ |
| 1119 |
template<> struct StringMaker<enumName> { \ |
| 1120 |
static std::string convert( enumName value ) { \ |
| 1121 |
static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \ |
| 1122 |
- return enumInfo.lookup( static_cast<int>( value ) ); \ |
| 1123 |
+ return static_cast<std::string>(enumInfo.lookup( static_cast<int>( value ) )); \ |
| 1124 |
} \ |
| 1125 |
}; \ |
| 1126 |
} |
| 1127 |
@@ -2342,6 +2372,18 @@ namespace Catch { |
| 1128 |
auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { |
| 1129 |
return { static_cast<bool>(m_lhs <= rhs), m_lhs, "<=", rhs }; |
| 1130 |
} |
| 1131 |
+ template <typename RhsT> |
| 1132 |
+ auto operator | (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { |
| 1133 |
+ return { static_cast<bool>(m_lhs | rhs), m_lhs, "|", rhs }; |
| 1134 |
+ } |
| 1135 |
+ template <typename RhsT> |
| 1136 |
+ auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { |
| 1137 |
+ return { static_cast<bool>(m_lhs & rhs), m_lhs, "&", rhs }; |
| 1138 |
+ } |
| 1139 |
+ template <typename RhsT> |
| 1140 |
+ auto operator ^ (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { |
| 1141 |
+ return { static_cast<bool>(m_lhs ^ rhs), m_lhs, "^", rhs }; |
| 1142 |
+ } |
| 1143 |
|
| 1144 |
template<typename RhsT> |
| 1145 |
auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const { |
| 1146 |
@@ -2422,7 +2464,7 @@ namespace Catch { |
| 1147 |
virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; |
| 1148 |
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; |
| 1149 |
|
| 1150 |
- virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; |
| 1151 |
+ virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; |
| 1152 |
|
| 1153 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 1154 |
virtual void benchmarkPreparing( std::string const& name ) = 0; |
| 1155 |
@@ -2660,15 +2702,16 @@ namespace Catch { |
| 1156 |
/////////////////////////////////////////////////////////////////////////////// |
| 1157 |
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ |
| 1158 |
do { \ |
| 1159 |
+ CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ |
| 1160 |
Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ |
| 1161 |
INTERNAL_CATCH_TRY { \ |
| 1162 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 1163 |
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ |
| 1164 |
catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ |
| 1165 |
- CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ |
| 1166 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 1167 |
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ |
| 1168 |
INTERNAL_CATCH_REACT( catchAssertionHandler ) \ |
| 1169 |
- } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look |
| 1170 |
- // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. |
| 1171 |
+ } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) ) |
| 1172 |
|
| 1173 |
/////////////////////////////////////////////////////////////////////////////// |
| 1174 |
#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ |
| 1175 |
@@ -2885,14 +2928,16 @@ namespace Catch { |
| 1176 |
} // end namespace Catch |
| 1177 |
|
| 1178 |
#define INTERNAL_CATCH_SECTION( ... ) \ |
| 1179 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 1180 |
CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ |
| 1181 |
if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ |
| 1182 |
- CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS |
| 1183 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 1184 |
|
| 1185 |
#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ |
| 1186 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 1187 |
CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ |
| 1188 |
if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ |
| 1189 |
- CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS |
| 1190 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 1191 |
|
| 1192 |
// end catch_section.h |
| 1193 |
// start catch_interfaces_exception.h |
| 1194 |
@@ -2983,6 +3028,9 @@ namespace Catch { |
| 1195 |
{} |
| 1196 |
|
| 1197 |
std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { |
| 1198 |
+#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 1199 |
+ return ""; |
| 1200 |
+#else |
| 1201 |
try { |
| 1202 |
if( it == itEnd ) |
| 1203 |
std::rethrow_exception(std::current_exception()); |
| 1204 |
@@ -2992,6 +3040,7 @@ namespace Catch { |
| 1205 |
catch( T& ex ) { |
| 1206 |
return m_translateFunction( ex ); |
| 1207 |
} |
| 1208 |
+#endif |
| 1209 |
} |
| 1210 |
|
| 1211 |
protected: |
| 1212 |
@@ -3010,9 +3059,10 @@ namespace Catch { |
| 1213 |
/////////////////////////////////////////////////////////////////////////////// |
| 1214 |
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ |
| 1215 |
static std::string translatorName( signature ); \ |
| 1216 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 1217 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 1218 |
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \ |
| 1219 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ |
| 1220 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 1221 |
static std::string translatorName( signature ) |
| 1222 |
|
| 1223 |
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) |
| 1224 |
@@ -3043,7 +3093,7 @@ namespace Detail { |
| 1225 |
Approx operator-() const; |
| 1226 |
|
| 1227 |
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> |
| 1228 |
- Approx operator()( T const& value ) { |
| 1229 |
+ Approx operator()( T const& value ) const { |
| 1230 |
Approx approx( static_cast<double>(value) ); |
| 1231 |
approx.m_epsilon = m_epsilon; |
| 1232 |
approx.m_margin = m_margin; |
| 1233 |
@@ -3154,7 +3204,10 @@ namespace Catch { |
| 1234 |
bool contains( std::string const& s, std::string const& infix ); |
| 1235 |
void toLowerInPlace( std::string& s ); |
| 1236 |
std::string toLower( std::string const& s ); |
| 1237 |
+ //! Returns a new string without whitespace at the start/end |
| 1238 |
std::string trim( std::string const& str ); |
| 1239 |
+ //! Returns a substring of the original ref without whitespace. Beware lifetimes! |
| 1240 |
+ StringRef trim(StringRef ref); |
| 1241 |
|
| 1242 |
// !!! Be aware, returns refs into original string - make sure original string outlives them |
| 1243 |
std::vector<StringRef> splitStringRef( StringRef str, char delimiter ); |
| 1244 |
@@ -3256,9 +3309,10 @@ namespace Matchers { |
| 1245 |
return description; |
| 1246 |
} |
| 1247 |
|
| 1248 |
- MatchAllOf<ArgT>& operator && ( MatcherBase<ArgT> const& other ) { |
| 1249 |
- m_matchers.push_back( &other ); |
| 1250 |
- return *this; |
| 1251 |
+ MatchAllOf<ArgT> operator && ( MatcherBase<ArgT> const& other ) { |
| 1252 |
+ auto copy(*this); |
| 1253 |
+ copy.m_matchers.push_back( &other ); |
| 1254 |
+ return copy; |
| 1255 |
} |
| 1256 |
|
| 1257 |
std::vector<MatcherBase<ArgT> const*> m_matchers; |
| 1258 |
@@ -3289,9 +3343,10 @@ namespace Matchers { |
| 1259 |
return description; |
| 1260 |
} |
| 1261 |
|
| 1262 |
- MatchAnyOf<ArgT>& operator || ( MatcherBase<ArgT> const& other ) { |
| 1263 |
- m_matchers.push_back( &other ); |
| 1264 |
- return *this; |
| 1265 |
+ MatchAnyOf<ArgT> operator || ( MatcherBase<ArgT> const& other ) { |
| 1266 |
+ auto copy(*this); |
| 1267 |
+ copy.m_matchers.push_back( &other ); |
| 1268 |
+ return copy; |
| 1269 |
} |
| 1270 |
|
| 1271 |
std::vector<MatcherBase<ArgT> const*> m_matchers; |
| 1272 |
@@ -3335,10 +3390,34 @@ using Matchers::Impl::MatcherBase; |
| 1273 |
} // namespace Catch |
| 1274 |
|
| 1275 |
// end catch_matchers.h |
| 1276 |
-// start catch_matchers_floating.h |
| 1277 |
+// start catch_matchers_exception.hpp |
| 1278 |
|
| 1279 |
-#include <type_traits> |
| 1280 |
-#include <cmath> |
| 1281 |
+namespace Catch { |
| 1282 |
+namespace Matchers { |
| 1283 |
+namespace Exception { |
| 1284 |
+ |
| 1285 |
+class ExceptionMessageMatcher : public MatcherBase<std::exception> { |
| 1286 |
+ std::string m_message; |
| 1287 |
+public: |
| 1288 |
+ |
| 1289 |
+ ExceptionMessageMatcher(std::string const& message): |
| 1290 |
+ m_message(message) |
| 1291 |
+ {} |
| 1292 |
+ |
| 1293 |
+ bool match(std::exception const& ex) const override; |
| 1294 |
+ |
| 1295 |
+ std::string describe() const override; |
| 1296 |
+}; |
| 1297 |
+ |
| 1298 |
+} // namespace Exception |
| 1299 |
+ |
| 1300 |
+Exception::ExceptionMessageMatcher Message(std::string const& message); |
| 1301 |
+ |
| 1302 |
+} // namespace Matchers |
| 1303 |
+} // namespace Catch |
| 1304 |
+ |
| 1305 |
+// end catch_matchers_exception.hpp |
| 1306 |
+// start catch_matchers_floating.h |
| 1307 |
|
| 1308 |
namespace Catch { |
| 1309 |
namespace Matchers { |
| 1310 |
@@ -3357,22 +3436,43 @@ namespace Matchers { |
| 1311 |
}; |
| 1312 |
|
| 1313 |
struct WithinUlpsMatcher : MatcherBase<double> { |
| 1314 |
- WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType); |
| 1315 |
+ WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType); |
| 1316 |
bool match(double const& matchee) const override; |
| 1317 |
std::string describe() const override; |
| 1318 |
private: |
| 1319 |
double m_target; |
| 1320 |
- int m_ulps; |
| 1321 |
+ uint64_t m_ulps; |
| 1322 |
FloatingPointKind m_type; |
| 1323 |
}; |
| 1324 |
|
| 1325 |
+ // Given IEEE-754 format for floats and doubles, we can assume |
| 1326 |
+ // that float -> double promotion is lossless. Given this, we can |
| 1327 |
+ // assume that if we do the standard relative comparison of |
| 1328 |
+ // |lhs - rhs| <= epsilon * max(fabs(lhs), fabs(rhs)), then we get |
| 1329 |
+ // the same result if we do this for floats, as if we do this for |
| 1330 |
+ // doubles that were promoted from floats. |
| 1331 |
+ struct WithinRelMatcher : MatcherBase<double> { |
| 1332 |
+ WithinRelMatcher(double target, double epsilon); |
| 1333 |
+ bool match(double const& matchee) const override; |
| 1334 |
+ std::string describe() const override; |
| 1335 |
+ private: |
| 1336 |
+ double m_target; |
| 1337 |
+ double m_epsilon; |
| 1338 |
+ }; |
| 1339 |
+ |
| 1340 |
} // namespace Floating |
| 1341 |
|
| 1342 |
// The following functions create the actual matcher objects. |
| 1343 |
// This allows the types to be inferred |
| 1344 |
- Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff); |
| 1345 |
- Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff); |
| 1346 |
+ Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff); |
| 1347 |
+ Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff); |
| 1348 |
Floating::WithinAbsMatcher WithinAbs(double target, double margin); |
| 1349 |
+ Floating::WithinRelMatcher WithinRel(double target, double eps); |
| 1350 |
+ // defaults epsilon to 100*numeric_limits<double>::epsilon() |
| 1351 |
+ Floating::WithinRelMatcher WithinRel(double target); |
| 1352 |
+ Floating::WithinRelMatcher WithinRel(float target, float eps); |
| 1353 |
+ // defaults epsilon to 100*numeric_limits<float>::epsilon() |
| 1354 |
+ Floating::WithinRelMatcher WithinRel(float target); |
| 1355 |
|
| 1356 |
} // namespace Matchers |
| 1357 |
} // namespace Catch |
| 1358 |
@@ -3503,12 +3603,12 @@ namespace Catch { |
| 1359 |
namespace Matchers { |
| 1360 |
|
| 1361 |
namespace Vector { |
| 1362 |
- template<typename T> |
| 1363 |
- struct ContainsElementMatcher : MatcherBase<std::vector<T>> { |
| 1364 |
+ template<typename T, typename Alloc> |
| 1365 |
+ struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> { |
| 1366 |
|
| 1367 |
ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} |
| 1368 |
|
| 1369 |
- bool match(std::vector<T> const &v) const override { |
| 1370 |
+ bool match(std::vector<T, Alloc> const &v) const override { |
| 1371 |
for (auto const& el : v) { |
| 1372 |
if (el == m_comparator) { |
| 1373 |
return true; |
| 1374 |
@@ -3524,12 +3624,12 @@ namespace Matchers { |
| 1375 |
T const& m_comparator; |
| 1376 |
}; |
| 1377 |
|
| 1378 |
- template<typename T> |
| 1379 |
- struct ContainsMatcher : MatcherBase<std::vector<T>> { |
| 1380 |
+ template<typename T, typename AllocComp, typename AllocMatch> |
| 1381 |
+ struct ContainsMatcher : MatcherBase<std::vector<T, AllocMatch>> { |
| 1382 |
|
| 1383 |
- ContainsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {} |
| 1384 |
+ ContainsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {} |
| 1385 |
|
| 1386 |
- bool match(std::vector<T> const &v) const override { |
| 1387 |
+ bool match(std::vector<T, AllocMatch> const &v) const override { |
| 1388 |
// !TBD: see note in EqualsMatcher |
| 1389 |
if (m_comparator.size() > v.size()) |
| 1390 |
return false; |
| 1391 |
@@ -3551,18 +3651,18 @@ namespace Matchers { |
| 1392 |
return "Contains: " + ::Catch::Detail::stringify( m_comparator ); |
| 1393 |
} |
| 1394 |
|
| 1395 |
- std::vector<T> const& m_comparator; |
| 1396 |
+ std::vector<T, AllocComp> const& m_comparator; |
| 1397 |
}; |
| 1398 |
|
| 1399 |
- template<typename T> |
| 1400 |
- struct EqualsMatcher : MatcherBase<std::vector<T>> { |
| 1401 |
+ template<typename T, typename AllocComp, typename AllocMatch> |
| 1402 |
+ struct EqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { |
| 1403 |
|
| 1404 |
- EqualsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {} |
| 1405 |
+ EqualsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {} |
| 1406 |
|
| 1407 |
- bool match(std::vector<T> const &v) const override { |
| 1408 |
+ bool match(std::vector<T, AllocMatch> const &v) const override { |
| 1409 |
// !TBD: This currently works if all elements can be compared using != |
| 1410 |
// - a more general approach would be via a compare template that defaults |
| 1411 |
- // to using !=. but could be specialised for, e.g. std::vector<T> etc |
| 1412 |
+ // to using !=. but could be specialised for, e.g. std::vector<T, Alloc> etc |
| 1413 |
// - then just call that directly |
| 1414 |
if (m_comparator.size() != v.size()) |
| 1415 |
return false; |
| 1416 |
@@ -3574,15 +3674,15 @@ namespace Matchers { |
| 1417 |
std::string describe() const override { |
| 1418 |
return "Equals: " + ::Catch::Detail::stringify( m_comparator ); |
| 1419 |
} |
| 1420 |
- std::vector<T> const& m_comparator; |
| 1421 |
+ std::vector<T, AllocComp> const& m_comparator; |
| 1422 |
}; |
| 1423 |
|
| 1424 |
- template<typename T> |
| 1425 |
- struct ApproxMatcher : MatcherBase<std::vector<T>> { |
| 1426 |
+ template<typename T, typename AllocComp, typename AllocMatch> |
| 1427 |
+ struct ApproxMatcher : MatcherBase<std::vector<T, AllocMatch>> { |
| 1428 |
|
| 1429 |
- ApproxMatcher(std::vector<T> const& comparator) : m_comparator( comparator ) {} |
| 1430 |
+ ApproxMatcher(std::vector<T, AllocComp> const& comparator) : m_comparator( comparator ) {} |
| 1431 |
|
| 1432 |
- bool match(std::vector<T> const &v) const override { |
| 1433 |
+ bool match(std::vector<T, AllocMatch> const &v) const override { |
| 1434 |
if (m_comparator.size() != v.size()) |
| 1435 |
return false; |
| 1436 |
for (std::size_t i = 0; i < v.size(); ++i) |
| 1437 |
@@ -3609,16 +3709,14 @@ namespace Matchers { |
| 1438 |
return *this; |
| 1439 |
} |
| 1440 |
|
| 1441 |
- std::vector<T> const& m_comparator; |
| 1442 |
+ std::vector<T, AllocComp> const& m_comparator; |
| 1443 |
mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); |
| 1444 |
}; |
| 1445 |
|
| 1446 |
- template<typename T> |
| 1447 |
- struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> { |
| 1448 |
- UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(target) {} |
| 1449 |
- bool match(std::vector<T> const& vec) const override { |
| 1450 |
- // Note: This is a reimplementation of std::is_permutation, |
| 1451 |
- // because I don't want to include <algorithm> inside the common path |
| 1452 |
+ template<typename T, typename AllocComp, typename AllocMatch> |
| 1453 |
+ struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { |
| 1454 |
+ UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {} |
| 1455 |
+ bool match(std::vector<T, AllocMatch> const& vec) const override { |
| 1456 |
if (m_target.size() != vec.size()) { |
| 1457 |
return false; |
| 1458 |
} |
| 1459 |
@@ -3629,7 +3727,7 @@ namespace Matchers { |
| 1460 |
return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); |
| 1461 |
} |
| 1462 |
private: |
| 1463 |
- std::vector<T> const& m_target; |
| 1464 |
+ std::vector<T, AllocComp> const& m_target; |
| 1465 |
}; |
| 1466 |
|
| 1467 |
} // namespace Vector |
| 1468 |
@@ -3637,29 +3735,29 @@ namespace Matchers { |
| 1469 |
// The following functions create the actual matcher objects. |
| 1470 |
// This allows the types to be inferred |
| 1471 |
|
| 1472 |
- template<typename T> |
| 1473 |
- Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparator ) { |
| 1474 |
- return Vector::ContainsMatcher<T>( comparator ); |
| 1475 |
+ template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> |
| 1476 |
+ Vector::ContainsMatcher<T, AllocComp, AllocMatch> Contains( std::vector<T, AllocComp> const& comparator ) { |
| 1477 |
+ return Vector::ContainsMatcher<T, AllocComp, AllocMatch>( comparator ); |
| 1478 |
} |
| 1479 |
|
| 1480 |
- template<typename T> |
| 1481 |
- Vector::ContainsElementMatcher<T> VectorContains( T const& comparator ) { |
| 1482 |
- return Vector::ContainsElementMatcher<T>( comparator ); |
| 1483 |
+ template<typename T, typename Alloc = std::allocator<T>> |
| 1484 |
+ Vector::ContainsElementMatcher<T, Alloc> VectorContains( T const& comparator ) { |
| 1485 |
+ return Vector::ContainsElementMatcher<T, Alloc>( comparator ); |
| 1486 |
} |
| 1487 |
|
| 1488 |
- template<typename T> |
| 1489 |
- Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) { |
| 1490 |
- return Vector::EqualsMatcher<T>( comparator ); |
| 1491 |
+ template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> |
| 1492 |
+ Vector::EqualsMatcher<T, AllocComp, AllocMatch> Equals( std::vector<T, AllocComp> const& comparator ) { |
| 1493 |
+ return Vector::EqualsMatcher<T, AllocComp, AllocMatch>( comparator ); |
| 1494 |
} |
| 1495 |
|
| 1496 |
- template<typename T> |
| 1497 |
- Vector::ApproxMatcher<T> Approx( std::vector<T> const& comparator ) { |
| 1498 |
- return Vector::ApproxMatcher<T>( comparator ); |
| 1499 |
+ template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> |
| 1500 |
+ Vector::ApproxMatcher<T, AllocComp, AllocMatch> Approx( std::vector<T, AllocComp> const& comparator ) { |
| 1501 |
+ return Vector::ApproxMatcher<T, AllocComp, AllocMatch>( comparator ); |
| 1502 |
} |
| 1503 |
|
| 1504 |
- template<typename T> |
| 1505 |
- Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> const& target) { |
| 1506 |
- return Vector::UnorderedEqualsMatcher<T>(target); |
| 1507 |
+ template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> |
| 1508 |
+ Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch> UnorderedEquals(std::vector<T, AllocComp> const& target) { |
| 1509 |
+ return Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch>( target ); |
| 1510 |
} |
| 1511 |
|
| 1512 |
} // namespace Matchers |
| 1513 |
@@ -3797,13 +3895,13 @@ namespace Catch { |
| 1514 |
(Catch::ReusableStringStream() << __VA_ARGS__).str() |
| 1515 |
|
| 1516 |
#define CATCH_INTERNAL_ERROR(...) \ |
| 1517 |
- Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__)); |
| 1518 |
+ Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__)) |
| 1519 |
|
| 1520 |
#define CATCH_ERROR(...) \ |
| 1521 |
- Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ )); |
| 1522 |
+ Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ )) |
| 1523 |
|
| 1524 |
#define CATCH_RUNTIME_ERROR(...) \ |
| 1525 |
- Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ )); |
| 1526 |
+ Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ )) |
| 1527 |
|
| 1528 |
#define CATCH_ENFORCE( condition, ... ) \ |
| 1529 |
do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false) |
| 1530 |
@@ -3855,7 +3953,6 @@ namespace Generators { |
| 1531 |
class SingleValueGenerator final : public IGenerator<T> { |
| 1532 |
T m_value; |
| 1533 |
public: |
| 1534 |
- SingleValueGenerator(T const& value) : m_value( value ) {} |
| 1535 |
SingleValueGenerator(T&& value) : m_value(std::move(value)) {} |
| 1536 |
|
| 1537 |
T const& get() const override { |
| 1538 |
@@ -3869,7 +3966,7 @@ namespace Generators { |
| 1539 |
template<typename T> |
| 1540 |
class FixedValuesGenerator final : public IGenerator<T> { |
| 1541 |
static_assert(!std::is_same<T, bool>::value, |
| 1542 |
- "ValuesGenerator does not support bools because of std::vector<bool>" |
| 1543 |
+ "FixedValuesGenerator does not support bools because of std::vector<bool>" |
| 1544 |
"specialization, use SingleValue Generator instead."); |
| 1545 |
std::vector<T> m_values; |
| 1546 |
size_t m_idx = 0; |
| 1547 |
@@ -3918,21 +4015,21 @@ namespace Generators { |
| 1548 |
m_generators.emplace_back(std::move(generator)); |
| 1549 |
} |
| 1550 |
void populate(T&& val) { |
| 1551 |
- m_generators.emplace_back(value(std::move(val))); |
| 1552 |
+ m_generators.emplace_back(value(std::forward<T>(val))); |
| 1553 |
} |
| 1554 |
template<typename U> |
| 1555 |
void populate(U&& val) { |
| 1556 |
- populate(T(std::move(val))); |
| 1557 |
+ populate(T(std::forward<U>(val))); |
| 1558 |
} |
| 1559 |
template<typename U, typename... Gs> |
| 1560 |
- void populate(U&& valueOrGenerator, Gs... moreGenerators) { |
| 1561 |
+ void populate(U&& valueOrGenerator, Gs &&... moreGenerators) { |
| 1562 |
populate(std::forward<U>(valueOrGenerator)); |
| 1563 |
populate(std::forward<Gs>(moreGenerators)...); |
| 1564 |
} |
| 1565 |
|
| 1566 |
public: |
| 1567 |
template <typename... Gs> |
| 1568 |
- Generators(Gs... moreGenerators) { |
| 1569 |
+ Generators(Gs &&... moreGenerators) { |
| 1570 |
m_generators.reserve(sizeof...(Gs)); |
| 1571 |
populate(std::forward<Gs>(moreGenerators)...); |
| 1572 |
} |
| 1573 |
@@ -3963,7 +4060,7 @@ namespace Generators { |
| 1574 |
struct as {}; |
| 1575 |
|
| 1576 |
template<typename T, typename... Gs> |
| 1577 |
- auto makeGenerators( GeneratorWrapper<T>&& generator, Gs... moreGenerators ) -> Generators<T> { |
| 1578 |
+ auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> { |
| 1579 |
return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...); |
| 1580 |
} |
| 1581 |
template<typename T> |
| 1582 |
@@ -3971,24 +4068,24 @@ namespace Generators { |
| 1583 |
return Generators<T>(std::move(generator)); |
| 1584 |
} |
| 1585 |
template<typename T, typename... Gs> |
| 1586 |
- auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> { |
| 1587 |
+ auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<T> { |
| 1588 |
return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... ); |
| 1589 |
} |
| 1590 |
template<typename T, typename U, typename... Gs> |
| 1591 |
- auto makeGenerators( as<T>, U&& val, Gs... moreGenerators ) -> Generators<T> { |
| 1592 |
+ auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> { |
| 1593 |
return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... ); |
| 1594 |
} |
| 1595 |
|
| 1596 |
- auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; |
| 1597 |
+ auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; |
| 1598 |
|
| 1599 |
template<typename L> |
| 1600 |
// Note: The type after -> is weird, because VS2015 cannot parse |
| 1601 |
// the expression used in the typedef inside, when it is in |
| 1602 |
// return type. Yeah. |
| 1603 |
- auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) { |
| 1604 |
+ auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) { |
| 1605 |
using UnderlyingType = typename decltype(generatorExpression())::type; |
| 1606 |
|
| 1607 |
- IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo ); |
| 1608 |
+ IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo ); |
| 1609 |
if (!tracker.hasGenerator()) { |
| 1610 |
tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression())); |
| 1611 |
} |
| 1612 |
@@ -4001,11 +4098,17 @@ namespace Generators { |
| 1613 |
} // namespace Catch |
| 1614 |
|
| 1615 |
#define GENERATE( ... ) \ |
| 1616 |
- Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) |
| 1617 |
+ Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 1618 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 1619 |
+ [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 1620 |
#define GENERATE_COPY( ... ) \ |
| 1621 |
- Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) |
| 1622 |
+ Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 1623 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 1624 |
+ [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 1625 |
#define GENERATE_REF( ... ) \ |
| 1626 |
- Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) |
| 1627 |
+ Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 1628 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 1629 |
+ [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 1630 |
|
| 1631 |
// end catch_generators.hpp |
| 1632 |
// start catch_generators_generic.hpp |
| 1633 |
@@ -4062,7 +4165,7 @@ namespace Generators { |
| 1634 |
if (!m_predicate(m_generator.get())) { |
| 1635 |
// It might happen that there are no values that pass the |
| 1636 |
// filter. In that case we throw an exception. |
| 1637 |
- auto has_initial_value = next(); |
| 1638 |
+ auto has_initial_value = nextImpl(); |
| 1639 |
if (!has_initial_value) { |
| 1640 |
Catch::throw_exception(GeneratorException("No valid value found in filtered generator")); |
| 1641 |
} |
| 1642 |
@@ -4074,6 +4177,11 @@ namespace Generators { |
| 1643 |
} |
| 1644 |
|
| 1645 |
bool next() override { |
| 1646 |
+ return nextImpl(); |
| 1647 |
+ } |
| 1648 |
+ |
| 1649 |
+ private: |
| 1650 |
+ bool nextImpl() { |
| 1651 |
bool success = m_generator.next(); |
| 1652 |
if (!success) { |
| 1653 |
return false; |
| 1654 |
@@ -4171,18 +4279,7 @@ namespace Generators { |
| 1655 |
} |
| 1656 |
}; |
| 1657 |
|
| 1658 |
-#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 |
| 1659 |
- // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is |
| 1660 |
- // replaced with std::invoke_result here. Also *_t format is preferred over |
| 1661 |
- // typename *::type format. |
| 1662 |
- template <typename Func, typename U> |
| 1663 |
- using MapFunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>; |
| 1664 |
-#else |
| 1665 |
- template <typename Func, typename U> |
| 1666 |
- using MapFunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U)>::type>::type>::type; |
| 1667 |
-#endif |
| 1668 |
- |
| 1669 |
- template <typename Func, typename U, typename T = MapFunctionReturnType<Func, U>> |
| 1670 |
+ template <typename Func, typename U, typename T = FunctionReturnType<Func, U>> |
| 1671 |
GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) { |
| 1672 |
return GeneratorWrapper<T>( |
| 1673 |
pf::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator)) |
| 1674 |
@@ -4285,6 +4382,7 @@ namespace Catch { |
| 1675 |
{ |
| 1676 |
if( !IMutableContext::currentContext ) |
| 1677 |
IMutableContext::createContext(); |
| 1678 |
+ // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) |
| 1679 |
return *IMutableContext::currentContext; |
| 1680 |
} |
| 1681 |
|
| 1682 |
@@ -4294,6 +4392,9 @@ namespace Catch { |
| 1683 |
} |
| 1684 |
|
| 1685 |
void cleanUpContext(); |
| 1686 |
+ |
| 1687 |
+ class SimplePcg32; |
| 1688 |
+ SimplePcg32& rng(); |
| 1689 |
} |
| 1690 |
|
| 1691 |
// end catch_context.h |
| 1692 |
@@ -4364,6 +4465,7 @@ namespace Catch { |
| 1693 |
} // end namespace Catch |
| 1694 |
|
| 1695 |
// end catch_option.hpp |
| 1696 |
+#include <chrono> |
| 1697 |
#include <iosfwd> |
| 1698 |
#include <string> |
| 1699 |
#include <vector> |
| 1700 |
@@ -4421,6 +4523,7 @@ namespace Catch { |
| 1701 |
virtual int abortAfter() const = 0; |
| 1702 |
virtual bool showInvisibles() const = 0; |
| 1703 |
virtual ShowDurations::OrNot showDurations() const = 0; |
| 1704 |
+ virtual double minDuration() const = 0; |
| 1705 |
virtual TestSpec const& testSpec() const = 0; |
| 1706 |
virtual bool hasTestFilters() const = 0; |
| 1707 |
virtual std::vector<std::string> const& getTestsOrTags() const = 0; |
| 1708 |
@@ -4434,12 +4537,63 @@ namespace Catch { |
| 1709 |
virtual int benchmarkSamples() const = 0; |
| 1710 |
virtual double benchmarkConfidenceInterval() const = 0; |
| 1711 |
virtual unsigned int benchmarkResamples() const = 0; |
| 1712 |
+ virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; |
| 1713 |
}; |
| 1714 |
|
| 1715 |
using IConfigPtr = std::shared_ptr<IConfig const>; |
| 1716 |
} |
| 1717 |
|
| 1718 |
// end catch_interfaces_config.h |
| 1719 |
+// start catch_random_number_generator.h |
| 1720 |
+ |
| 1721 |
+#include <cstdint> |
| 1722 |
+ |
| 1723 |
+namespace Catch { |
| 1724 |
+ |
| 1725 |
+ // This is a simple implementation of C++11 Uniform Random Number |
| 1726 |
+ // Generator. It does not provide all operators, because Catch2 |
| 1727 |
+ // does not use it, but it should behave as expected inside stdlib's |
| 1728 |
+ // distributions. |
| 1729 |
+ // The implementation is based on the PCG family (http://pcg-random.org) |
| 1730 |
+ class SimplePcg32 { |
| 1731 |
+ using state_type = std::uint64_t; |
| 1732 |
+ public: |
| 1733 |
+ using result_type = std::uint32_t; |
| 1734 |
+ static constexpr result_type (min)() { |
| 1735 |
+ return 0; |
| 1736 |
+ } |
| 1737 |
+ static constexpr result_type (max)() { |
| 1738 |
+ return static_cast<result_type>(-1); |
| 1739 |
+ } |
| 1740 |
+ |
| 1741 |
+ // Provide some default initial state for the default constructor |
| 1742 |
+ SimplePcg32():SimplePcg32(0xed743cc4U) {} |
| 1743 |
+ |
| 1744 |
+ explicit SimplePcg32(result_type seed_); |
| 1745 |
+ |
| 1746 |
+ void seed(result_type seed_); |
| 1747 |
+ void discard(uint64_t skip); |
| 1748 |
+ |
| 1749 |
+ result_type operator()(); |
| 1750 |
+ |
| 1751 |
+ private: |
| 1752 |
+ friend bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs); |
| 1753 |
+ friend bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs); |
| 1754 |
+ |
| 1755 |
+ // In theory we also need operator<< and operator>> |
| 1756 |
+ // In practice we do not use them, so we will skip them for now |
| 1757 |
+ |
| 1758 |
+ std::uint64_t m_state; |
| 1759 |
+ // This part of the state determines which "stream" of the numbers |
| 1760 |
+ // is chosen -- we take it as a constant for Catch2, so we only |
| 1761 |
+ // need to deal with seeding the main state. |
| 1762 |
+ // Picked by reading 8 bytes from `/dev/random` :-) |
| 1763 |
+ static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL; |
| 1764 |
+ }; |
| 1765 |
+ |
| 1766 |
+} // end namespace Catch |
| 1767 |
+ |
| 1768 |
+// end catch_random_number_generator.h |
| 1769 |
#include <random> |
| 1770 |
|
| 1771 |
namespace Catch { |
| 1772 |
@@ -4447,14 +4601,13 @@ namespace Generators { |
| 1773 |
|
| 1774 |
template <typename Float> |
| 1775 |
class RandomFloatingGenerator final : public IGenerator<Float> { |
| 1776 |
- // FIXME: What is the right seed? |
| 1777 |
- std::minstd_rand m_rand; |
| 1778 |
+ Catch::SimplePcg32& m_rng; |
| 1779 |
std::uniform_real_distribution<Float> m_dist; |
| 1780 |
Float m_current_number; |
| 1781 |
public: |
| 1782 |
|
| 1783 |
RandomFloatingGenerator(Float a, Float b): |
| 1784 |
- m_rand(getCurrentContext().getConfig()->rngSeed()), |
| 1785 |
+ m_rng(rng()), |
| 1786 |
m_dist(a, b) { |
| 1787 |
static_cast<void>(next()); |
| 1788 |
} |
| 1789 |
@@ -4463,20 +4616,20 @@ public: |
| 1790 |
return m_current_number; |
| 1791 |
} |
| 1792 |
bool next() override { |
| 1793 |
- m_current_number = m_dist(m_rand); |
| 1794 |
+ m_current_number = m_dist(m_rng); |
| 1795 |
return true; |
| 1796 |
} |
| 1797 |
}; |
| 1798 |
|
| 1799 |
template <typename Integer> |
| 1800 |
class RandomIntegerGenerator final : public IGenerator<Integer> { |
| 1801 |
- std::minstd_rand m_rand; |
| 1802 |
+ Catch::SimplePcg32& m_rng; |
| 1803 |
std::uniform_int_distribution<Integer> m_dist; |
| 1804 |
Integer m_current_number; |
| 1805 |
public: |
| 1806 |
|
| 1807 |
RandomIntegerGenerator(Integer a, Integer b): |
| 1808 |
- m_rand(getCurrentContext().getConfig()->rngSeed()), |
| 1809 |
+ m_rng(rng()), |
| 1810 |
m_dist(a, b) { |
| 1811 |
static_cast<void>(next()); |
| 1812 |
} |
| 1813 |
@@ -4485,7 +4638,7 @@ public: |
| 1814 |
return m_current_number; |
| 1815 |
} |
| 1816 |
bool next() override { |
| 1817 |
- m_current_number = m_dist(m_rand); |
| 1818 |
+ m_current_number = m_dist(m_rng); |
| 1819 |
return true; |
| 1820 |
} |
| 1821 |
}; |
| 1822 |
@@ -4545,7 +4698,7 @@ public: |
| 1823 |
|
| 1824 |
template <typename T> |
| 1825 |
GeneratorWrapper<T> range(T const& start, T const& end, T const& step) { |
| 1826 |
- static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer"); |
| 1827 |
+ static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric"); |
| 1828 |
return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end, step)); |
| 1829 |
} |
| 1830 |
|
| 1831 |
@@ -4555,6 +4708,45 @@ GeneratorWrapper<T> range(T const& start |
| 1832 |
return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end)); |
| 1833 |
} |
| 1834 |
|
| 1835 |
+template <typename T> |
| 1836 |
+class IteratorGenerator final : public IGenerator<T> { |
| 1837 |
+ static_assert(!std::is_same<T, bool>::value, |
| 1838 |
+ "IteratorGenerator currently does not support bools" |
| 1839 |
+ "because of std::vector<bool> specialization"); |
| 1840 |
+ |
| 1841 |
+ std::vector<T> m_elems; |
| 1842 |
+ size_t m_current = 0; |
| 1843 |
+public: |
| 1844 |
+ template <typename InputIterator, typename InputSentinel> |
| 1845 |
+ IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) { |
| 1846 |
+ if (m_elems.empty()) { |
| 1847 |
+ Catch::throw_exception(GeneratorException("IteratorGenerator received no valid values")); |
| 1848 |
+ } |
| 1849 |
+ } |
| 1850 |
+ |
| 1851 |
+ T const& get() const override { |
| 1852 |
+ return m_elems[m_current]; |
| 1853 |
+ } |
| 1854 |
+ |
| 1855 |
+ bool next() override { |
| 1856 |
+ ++m_current; |
| 1857 |
+ return m_current != m_elems.size(); |
| 1858 |
+ } |
| 1859 |
+}; |
| 1860 |
+ |
| 1861 |
+template <typename InputIterator, |
| 1862 |
+ typename InputSentinel, |
| 1863 |
+ typename ResultType = typename std::iterator_traits<InputIterator>::value_type> |
| 1864 |
+GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) { |
| 1865 |
+ return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(from, to)); |
| 1866 |
+} |
| 1867 |
+ |
| 1868 |
+template <typename Container, |
| 1869 |
+ typename ResultType = typename Container::value_type> |
| 1870 |
+GeneratorWrapper<ResultType> from_range(Container const& cnt) { |
| 1871 |
+ return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end())); |
| 1872 |
+} |
| 1873 |
+ |
| 1874 |
} // namespace Generators |
| 1875 |
} // namespace Catch |
| 1876 |
|
| 1877 |
@@ -4900,7 +5092,7 @@ namespace Catch |
| 1878 |
virtual bool matches( std::string const& str ) const; |
| 1879 |
|
| 1880 |
private: |
| 1881 |
- std::string adjustCase( std::string const& str ) const; |
| 1882 |
+ std::string normaliseString( std::string const& str ) const; |
| 1883 |
CaseSensitive::Choice m_caseSensitivity; |
| 1884 |
WildcardPosition m_wildcard = NoWildcard; |
| 1885 |
std::string m_pattern; |
| 1886 |
@@ -4965,14 +5157,16 @@ namespace Catch { |
| 1887 |
std::vector<TestCase const*> tests; |
| 1888 |
}; |
| 1889 |
using Matches = std::vector<FilterMatch>; |
| 1890 |
+ using vectorStrings = std::vector<std::string>; |
| 1891 |
|
| 1892 |
bool hasFilters() const; |
| 1893 |
bool matches( TestCaseInfo const& testCase ) const; |
| 1894 |
Matches matchesByFilter( std::vector<TestCase> const& testCases, IConfig const& config ) const; |
| 1895 |
+ const vectorStrings & getInvalidArgs() const; |
| 1896 |
|
| 1897 |
private: |
| 1898 |
std::vector<Filter> m_filters; |
| 1899 |
- |
| 1900 |
+ std::vector<std::string> m_invalidArgs; |
| 1901 |
friend class TestSpecParser; |
| 1902 |
}; |
| 1903 |
} |
| 1904 |
@@ -5007,8 +5201,10 @@ namespace Catch { |
| 1905 |
class TestSpecParser { |
| 1906 |
enum Mode{ None, Name, QuotedName, Tag, EscapedName }; |
| 1907 |
Mode m_mode = None; |
| 1908 |
+ Mode lastMode = None; |
| 1909 |
bool m_exclusion = false; |
| 1910 |
std::size_t m_pos = 0; |
| 1911 |
+ std::size_t m_realPatternPos = 0; |
| 1912 |
std::string m_arg; |
| 1913 |
std::string m_substring; |
| 1914 |
std::string m_patternName; |
| 1915 |
@@ -5024,7 +5220,7 @@ namespace Catch { |
| 1916 |
TestSpec testSpec(); |
| 1917 |
|
| 1918 |
private: |
| 1919 |
- void visitChar( char c ); |
| 1920 |
+ bool visitChar( char c ); |
| 1921 |
void startNewMode( Mode mode ); |
| 1922 |
bool processNoneChar( char c ); |
| 1923 |
void processNameChar( char c ); |
| 1924 |
@@ -5032,30 +5228,24 @@ namespace Catch { |
| 1925 |
void endMode(); |
| 1926 |
void escape(); |
| 1927 |
bool isControlChar( char c ) const; |
| 1928 |
+ void saveLastMode(); |
| 1929 |
+ void revertBackToLastMode(); |
| 1930 |
+ void addFilter(); |
| 1931 |
+ bool separate(); |
| 1932 |
|
| 1933 |
- template<typename T> |
| 1934 |
- void addPattern() { |
| 1935 |
- std::string token = m_patternName; |
| 1936 |
- for( std::size_t i = 0; i < m_escapeChars.size(); ++i ) |
| 1937 |
- token = token.substr( 0, m_escapeChars[i] - i ) + token.substr( m_escapeChars[i] -i +1 ); |
| 1938 |
- m_escapeChars.clear(); |
| 1939 |
- if( startsWith( token, "exclude:" ) ) { |
| 1940 |
- m_exclusion = true; |
| 1941 |
- token = token.substr( 8 ); |
| 1942 |
- } |
| 1943 |
- if( !token.empty() ) { |
| 1944 |
- TestSpec::PatternPtr pattern = std::make_shared<T>( token, m_substring ); |
| 1945 |
- if( m_exclusion ) |
| 1946 |
- pattern = std::make_shared<TestSpec::ExcludedPattern>( pattern ); |
| 1947 |
- m_currentFilter.m_patterns.push_back( pattern ); |
| 1948 |
- } |
| 1949 |
- m_substring.clear(); |
| 1950 |
- m_patternName.clear(); |
| 1951 |
- m_exclusion = false; |
| 1952 |
- m_mode = None; |
| 1953 |
+ // Handles common preprocessing of the pattern for name/tag patterns |
| 1954 |
+ std::string preprocessPattern(); |
| 1955 |
+ // Adds the current pattern as a test name |
| 1956 |
+ void addNamePattern(); |
| 1957 |
+ // Adds the current pattern as a tag |
| 1958 |
+ void addTagPattern(); |
| 1959 |
+ |
| 1960 |
+ inline void addCharToPattern(char c) { |
| 1961 |
+ m_substring += c; |
| 1962 |
+ m_patternName += c; |
| 1963 |
+ m_realPatternPos++; |
| 1964 |
} |
| 1965 |
|
| 1966 |
- void addFilter(); |
| 1967 |
}; |
| 1968 |
TestSpec parseTestSpec( std::string const& arg ); |
| 1969 |
|
| 1970 |
@@ -5101,10 +5291,12 @@ namespace Catch { |
| 1971 |
unsigned int benchmarkSamples = 100; |
| 1972 |
double benchmarkConfidenceInterval = 0.95; |
| 1973 |
unsigned int benchmarkResamples = 100000; |
| 1974 |
+ std::chrono::milliseconds::rep benchmarkWarmupTime = 100; |
| 1975 |
|
| 1976 |
Verbosity verbosity = Verbosity::Normal; |
| 1977 |
WarnAbout::What warnings = WarnAbout::Nothing; |
| 1978 |
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; |
| 1979 |
+ double minDuration = -1; |
| 1980 |
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; |
| 1981 |
UseColour::YesOrNo useColour = UseColour::Auto; |
| 1982 |
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; |
| 1983 |
@@ -5155,6 +5347,7 @@ namespace Catch { |
| 1984 |
bool warnAboutMissingAssertions() const override; |
| 1985 |
bool warnAboutNoTests() const override; |
| 1986 |
ShowDurations::OrNot showDurations() const override; |
| 1987 |
+ double minDuration() const override; |
| 1988 |
RunTests::InWhatOrder runOrder() const override; |
| 1989 |
unsigned int rngSeed() const override; |
| 1990 |
UseColour::YesOrNo useColour() const override; |
| 1991 |
@@ -5166,6 +5359,7 @@ namespace Catch { |
| 1992 |
int benchmarkSamples() const override; |
| 1993 |
double benchmarkConfidenceInterval() const override; |
| 1994 |
unsigned int benchmarkResamples() const override; |
| 1995 |
+ std::chrono::milliseconds benchmarkWarmupTime() const override; |
| 1996 |
|
| 1997 |
private: |
| 1998 |
|
| 1999 |
@@ -5271,6 +5465,8 @@ namespace Catch { |
| 2000 |
} // namespace Catch |
| 2001 |
|
| 2002 |
// end catch_outlier_classification.hpp |
| 2003 |
+ |
| 2004 |
+#include <iterator> |
| 2005 |
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING |
| 2006 |
|
| 2007 |
#include <string> |
| 2008 |
@@ -5463,6 +5659,8 @@ namespace Catch { |
| 2009 |
|
| 2010 |
virtual void noMatchingTestCases( std::string const& spec ) = 0; |
| 2011 |
|
| 2012 |
+ virtual void reportInvalidArguments(std::string const&) {} |
| 2013 |
+ |
| 2014 |
virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; |
| 2015 |
virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; |
| 2016 |
|
| 2017 |
@@ -5529,6 +5727,9 @@ namespace Catch { |
| 2018 |
// Returns double formatted as %.3f (format expected on output) |
| 2019 |
std::string getFormattedDuration( double duration ); |
| 2020 |
|
| 2021 |
+ //! Should the reporter show |
| 2022 |
+ bool shouldShowDuration( IConfig const& config, double duration ); |
| 2023 |
+ |
| 2024 |
std::string serializeFilters( std::vector<std::string> const& container ); |
| 2025 |
|
| 2026 |
template<typename DerivedT> |
| 2027 |
@@ -5555,6 +5756,8 @@ namespace Catch { |
| 2028 |
|
| 2029 |
void noMatchingTestCases(std::string const&) override {} |
| 2030 |
|
| 2031 |
+ void reportInvalidArguments(std::string const&) override {} |
| 2032 |
+ |
| 2033 |
void testRunStarting(TestRunInfo const& _testRunInfo) override { |
| 2034 |
currentTestRunInfo = _testRunInfo; |
| 2035 |
} |
| 2036 |
@@ -5889,14 +6092,16 @@ namespace Catch { |
| 2037 |
#if !defined(CATCH_CONFIG_DISABLE) |
| 2038 |
|
| 2039 |
#define CATCH_REGISTER_REPORTER( name, reporterType ) \ |
| 2040 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 2041 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 2042 |
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } \ |
| 2043 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 2044 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 2045 |
|
| 2046 |
#define CATCH_REGISTER_LISTENER( listenerType ) \ |
| 2047 |
- CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 2048 |
- namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \ |
| 2049 |
- CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
| 2050 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 2051 |
+ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 2052 |
+ namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \ |
| 2053 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 2054 |
#else // CATCH_CONFIG_DISABLE |
| 2055 |
|
| 2056 |
#define CATCH_REGISTER_REPORTER(name, reporterType) |
| 2057 |
@@ -5918,8 +6123,6 @@ namespace Catch { |
| 2058 |
|
| 2059 |
static std::string getDescription(); |
| 2060 |
|
| 2061 |
- ReporterPreferences getPreferences() const override; |
| 2062 |
- |
| 2063 |
void noMatchingTestCases(std::string const& spec) override; |
| 2064 |
|
| 2065 |
void assertionStarting(AssertionInfo const&) override; |
| 2066 |
@@ -5958,6 +6161,8 @@ namespace Catch { |
| 2067 |
|
| 2068 |
void noMatchingTestCases(std::string const& spec) override; |
| 2069 |
|
| 2070 |
+ void reportInvalidArguments(std::string const&arg) override; |
| 2071 |
+ |
| 2072 |
void assertionStarting(AssertionInfo const&) override; |
| 2073 |
|
| 2074 |
bool assertionEnded(AssertionStats const& _assertionStats) override; |
| 2075 |
@@ -6017,6 +6222,14 @@ namespace Catch { |
| 2076 |
#include <vector> |
| 2077 |
|
| 2078 |
namespace Catch { |
| 2079 |
+ enum class XmlFormatting { |
| 2080 |
+ None = 0x00, |
| 2081 |
+ Indent = 0x01, |
| 2082 |
+ Newline = 0x02, |
| 2083 |
+ }; |
| 2084 |
+ |
| 2085 |
+ XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs); |
| 2086 |
+ XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs); |
| 2087 |
|
| 2088 |
class XmlEncode { |
| 2089 |
public: |
| 2090 |
@@ -6038,14 +6251,14 @@ namespace Catch { |
| 2091 |
|
| 2092 |
class ScopedElement { |
| 2093 |
public: |
| 2094 |
- ScopedElement( XmlWriter* writer ); |
| 2095 |
+ ScopedElement( XmlWriter* writer, XmlFormatting fmt ); |
| 2096 |
|
| 2097 |
ScopedElement( ScopedElement&& other ) noexcept; |
| 2098 |
ScopedElement& operator=( ScopedElement&& other ) noexcept; |
| 2099 |
|
| 2100 |
~ScopedElement(); |
| 2101 |
|
| 2102 |
- ScopedElement& writeText( std::string const& text, bool indent = true ); |
| 2103 |
+ ScopedElement& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); |
| 2104 |
|
| 2105 |
template<typename T> |
| 2106 |
ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { |
| 2107 |
@@ -6055,6 +6268,7 @@ namespace Catch { |
| 2108 |
|
| 2109 |
private: |
| 2110 |
mutable XmlWriter* m_writer = nullptr; |
| 2111 |
+ XmlFormatting m_fmt; |
| 2112 |
}; |
| 2113 |
|
| 2114 |
XmlWriter( std::ostream& os = Catch::cout() ); |
| 2115 |
@@ -6063,11 +6277,11 @@ namespace Catch { |
| 2116 |
XmlWriter( XmlWriter const& ) = delete; |
| 2117 |
XmlWriter& operator=( XmlWriter const& ) = delete; |
| 2118 |
|
| 2119 |
- XmlWriter& startElement( std::string const& name ); |
| 2120 |
+ XmlWriter& startElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 2121 |
|
| 2122 |
- ScopedElement scopedElement( std::string const& name ); |
| 2123 |
+ ScopedElement scopedElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 2124 |
|
| 2125 |
- XmlWriter& endElement(); |
| 2126 |
+ XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 2127 |
|
| 2128 |
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); |
| 2129 |
|
| 2130 |
@@ -6080,9 +6294,9 @@ namespace Catch { |
| 2131 |
return writeAttribute( name, rss.str() ); |
| 2132 |
} |
| 2133 |
|
| 2134 |
- XmlWriter& writeText( std::string const& text, bool indent = true ); |
| 2135 |
+ XmlWriter& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 2136 |
|
| 2137 |
- XmlWriter& writeComment( std::string const& text ); |
| 2138 |
+ XmlWriter& writeComment(std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 2139 |
|
| 2140 |
void writeStylesheetRef( std::string const& url ); |
| 2141 |
|
| 2142 |
@@ -6092,6 +6306,8 @@ namespace Catch { |
| 2143 |
|
| 2144 |
private: |
| 2145 |
|
| 2146 |
+ void applyFormatting(XmlFormatting fmt); |
| 2147 |
+ |
| 2148 |
void writeDeclaration(); |
| 2149 |
|
| 2150 |
void newlineIfNecessary(); |
| 2151 |
@@ -6135,9 +6351,10 @@ namespace Catch { |
| 2152 |
|
| 2153 |
void writeTestCase(TestCaseNode const& testCaseNode); |
| 2154 |
|
| 2155 |
- void writeSection(std::string const& className, |
| 2156 |
- std::string const& rootName, |
| 2157 |
- SectionNode const& sectionNode); |
| 2158 |
+ void writeSection( std::string const& className, |
| 2159 |
+ std::string const& rootName, |
| 2160 |
+ SectionNode const& sectionNode, |
| 2161 |
+ bool testOkToFail ); |
| 2162 |
|
| 2163 |
void writeAssertions(SectionNode const& sectionNode); |
| 2164 |
void writeAssertion(AssertionStats const& stats); |
| 2165 |
@@ -6213,6 +6430,12 @@ namespace Catch { |
| 2166 |
#endif |
| 2167 |
|
| 2168 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 2169 |
+// start catch_benchmarking_all.hpp |
| 2170 |
+ |
| 2171 |
+// A proxy header that includes all of the benchmarking headers to allow |
| 2172 |
+// concise include of the benchmarking features. You should prefer the |
| 2173 |
+// individual includes in standard use. |
| 2174 |
+ |
| 2175 |
// start catch_benchmark.hpp |
| 2176 |
|
| 2177 |
// Benchmark |
| 2178 |
@@ -6348,20 +6571,18 @@ namespace Catch { |
| 2179 |
return {}; |
| 2180 |
} |
| 2181 |
}; |
| 2182 |
- template <typename Sig> |
| 2183 |
- using ResultOf_t = typename std::result_of<Sig>::type; |
| 2184 |
|
| 2185 |
// invoke and not return void :( |
| 2186 |
template <typename Fun, typename... Args> |
| 2187 |
- CompleteType_t<ResultOf_t<Fun(Args...)>> complete_invoke(Fun&& fun, Args&&... args) { |
| 2188 |
- return CompleteInvoker<ResultOf_t<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); |
| 2189 |
+ CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { |
| 2190 |
+ return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); |
| 2191 |
} |
| 2192 |
|
| 2193 |
const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; |
| 2194 |
} // namespace Detail |
| 2195 |
|
| 2196 |
template <typename Fun> |
| 2197 |
- Detail::CompleteType_t<Detail::ResultOf_t<Fun()>> user_code(Fun&& fun) { |
| 2198 |
+ Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { |
| 2199 |
CATCH_TRY{ |
| 2200 |
return Detail::complete_invoke(std::forward<Fun>(fun)); |
| 2201 |
} CATCH_CATCH_ALL{ |
| 2202 |
@@ -6606,8 +6827,8 @@ namespace Catch { |
| 2203 |
Result result; |
| 2204 |
int iterations; |
| 2205 |
}; |
| 2206 |
- template <typename Clock, typename Sig> |
| 2207 |
- using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<Detail::ResultOf_t<Sig>>>; |
| 2208 |
+ template <typename Clock, typename Func, typename... Args> |
| 2209 |
+ using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>; |
| 2210 |
} // namespace Benchmark |
| 2211 |
} // namespace Catch |
| 2212 |
|
| 2213 |
@@ -6618,7 +6839,7 @@ namespace Catch { |
| 2214 |
namespace Benchmark { |
| 2215 |
namespace Detail { |
| 2216 |
template <typename Clock, typename Fun, typename... Args> |
| 2217 |
- TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) { |
| 2218 |
+ TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) { |
| 2219 |
auto start = Clock::now(); |
| 2220 |
auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...); |
| 2221 |
auto end = Clock::now(); |
| 2222 |
@@ -6637,11 +6858,11 @@ namespace Catch { |
| 2223 |
namespace Benchmark { |
| 2224 |
namespace Detail { |
| 2225 |
template <typename Clock, typename Fun> |
| 2226 |
- TimingOf<Clock, Fun(int)> measure_one(Fun&& fun, int iters, std::false_type) { |
| 2227 |
+ TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) { |
| 2228 |
return Detail::measure<Clock>(fun, iters); |
| 2229 |
} |
| 2230 |
template <typename Clock, typename Fun> |
| 2231 |
- TimingOf<Clock, Fun(Chronometer)> measure_one(Fun&& fun, int iters, std::true_type) { |
| 2232 |
+ TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) { |
| 2233 |
Detail::ChronometerModel<Clock> meter; |
| 2234 |
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); |
| 2235 |
|
| 2236 |
@@ -6658,7 +6879,7 @@ namespace Catch { |
| 2237 |
}; |
| 2238 |
|
| 2239 |
template <typename Clock, typename Fun> |
| 2240 |
- TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { |
| 2241 |
+ TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { |
| 2242 |
auto iters = seed; |
| 2243 |
while (iters < (1 << 30)) { |
| 2244 |
auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); |
| 2245 |
@@ -6668,7 +6889,7 @@ namespace Catch { |
| 2246 |
} |
| 2247 |
iters *= 2; |
| 2248 |
} |
| 2249 |
- throw optimized_away_error{}; |
| 2250 |
+ Catch::throw_exception(optimized_away_error{}); |
| 2251 |
} |
| 2252 |
} // namespace Detail |
| 2253 |
} // namespace Benchmark |
| 2254 |
@@ -6676,6 +6897,7 @@ namespace Catch { |
| 2255 |
|
| 2256 |
// end catch_run_for_at_least.hpp |
| 2257 |
#include <algorithm> |
| 2258 |
+#include <iterator> |
| 2259 |
|
| 2260 |
namespace Catch { |
| 2261 |
namespace Benchmark { |
| 2262 |
@@ -6726,11 +6948,13 @@ namespace Catch { |
| 2263 |
#include <algorithm> |
| 2264 |
#include <functional> |
| 2265 |
#include <vector> |
| 2266 |
+#include <iterator> |
| 2267 |
#include <numeric> |
| 2268 |
#include <tuple> |
| 2269 |
#include <cmath> |
| 2270 |
#include <utility> |
| 2271 |
#include <cstddef> |
| 2272 |
+#include <random> |
| 2273 |
|
| 2274 |
namespace Catch { |
| 2275 |
namespace Benchmark { |
| 2276 |
@@ -6844,8 +7068,8 @@ namespace Catch { |
| 2277 |
double b2 = bias - z1; |
| 2278 |
double a1 = a(b1); |
| 2279 |
double a2 = a(b2); |
| 2280 |
- auto lo = std::max(cumn(a1), 0); |
| 2281 |
- auto hi = std::min(cumn(a2), n - 1); |
| 2282 |
+ auto lo = (std::max)(cumn(a1), 0); |
| 2283 |
+ auto hi = (std::min)(cumn(a2), n - 1); |
| 2284 |
|
| 2285 |
return { point, resample[lo], resample[hi], confidence_level }; |
| 2286 |
} |
| 2287 |
@@ -6914,7 +7138,9 @@ namespace Catch { |
| 2288 |
} |
| 2289 |
template <typename Clock> |
| 2290 |
EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) { |
| 2291 |
- auto time_limit = std::min(resolution * clock_cost_estimation_tick_limit, FloatDuration<Clock>(clock_cost_estimation_time_limit)); |
| 2292 |
+ auto time_limit = (std::min)( |
| 2293 |
+ resolution * clock_cost_estimation_tick_limit, |
| 2294 |
+ FloatDuration<Clock>(clock_cost_estimation_time_limit)); |
| 2295 |
auto time_clock = [](int k) { |
| 2296 |
return Detail::measure<Clock>([k] { |
| 2297 |
for (int i = 0; i < k; ++i) { |
| 2298 |
@@ -7080,10 +7306,10 @@ namespace Catch { |
| 2299 |
template <typename Clock> |
| 2300 |
ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const { |
| 2301 |
auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; |
| 2302 |
- auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(Detail::warmup_time)); |
| 2303 |
+ auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime())); |
| 2304 |
auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(run_time), 1, fun); |
| 2305 |
int new_iters = static_cast<int>(std::ceil(min_time * test.iterations / test.elapsed)); |
| 2306 |
- return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(Detail::warmup_time), Detail::warmup_iterations }; |
| 2307 |
+ return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; |
| 2308 |
} |
| 2309 |
|
| 2310 |
template <typename Clock = default_clock> |
| 2311 |
@@ -7115,7 +7341,7 @@ namespace Catch { |
| 2312 |
}); |
| 2313 |
|
| 2314 |
auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); |
| 2315 |
- BenchmarkStats<std::chrono::duration<double, std::nano>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; |
| 2316 |
+ BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; |
| 2317 |
getResultCapture().benchmarkEnded(stats); |
| 2318 |
|
| 2319 |
} CATCH_CATCH_ALL{ |
| 2320 |
@@ -7156,6 +7382,77 @@ namespace Catch { |
| 2321 |
BenchmarkName = [&] |
| 2322 |
|
| 2323 |
// end catch_benchmark.hpp |
| 2324 |
+// start catch_constructor.hpp |
| 2325 |
+ |
| 2326 |
+// Constructor and destructor helpers |
| 2327 |
+ |
| 2328 |
+ |
| 2329 |
+#include <type_traits> |
| 2330 |
+ |
| 2331 |
+namespace Catch { |
| 2332 |
+ namespace Benchmark { |
| 2333 |
+ namespace Detail { |
| 2334 |
+ template <typename T, bool Destruct> |
| 2335 |
+ struct ObjectStorage |
| 2336 |
+ { |
| 2337 |
+ using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type; |
| 2338 |
+ |
| 2339 |
+ ObjectStorage() : data() {} |
| 2340 |
+ |
| 2341 |
+ ObjectStorage(const ObjectStorage& other) |
| 2342 |
+ { |
| 2343 |
+ new(&data) T(other.stored_object()); |
| 2344 |
+ } |
| 2345 |
+ |
| 2346 |
+ ObjectStorage(ObjectStorage&& other) |
| 2347 |
+ { |
| 2348 |
+ new(&data) T(std::move(other.stored_object())); |
| 2349 |
+ } |
| 2350 |
+ |
| 2351 |
+ ~ObjectStorage() { destruct_on_exit<T>(); } |
| 2352 |
+ |
| 2353 |
+ template <typename... Args> |
| 2354 |
+ void construct(Args&&... args) |
| 2355 |
+ { |
| 2356 |
+ new (&data) T(std::forward<Args>(args)...); |
| 2357 |
+ } |
| 2358 |
+ |
| 2359 |
+ template <bool AllowManualDestruction = !Destruct> |
| 2360 |
+ typename std::enable_if<AllowManualDestruction>::type destruct() |
| 2361 |
+ { |
| 2362 |
+ stored_object().~T(); |
| 2363 |
+ } |
| 2364 |
+ |
| 2365 |
+ private: |
| 2366 |
+ // If this is a constructor benchmark, destruct the underlying object |
| 2367 |
+ template <typename U> |
| 2368 |
+ void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); } |
| 2369 |
+ // Otherwise, don't |
| 2370 |
+ template <typename U> |
| 2371 |
+ void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { } |
| 2372 |
+ |
| 2373 |
+ T& stored_object() { |
| 2374 |
+ return *static_cast<T*>(static_cast<void*>(&data)); |
| 2375 |
+ } |
| 2376 |
+ |
| 2377 |
+ T const& stored_object() const { |
| 2378 |
+ return *static_cast<T*>(static_cast<void*>(&data)); |
| 2379 |
+ } |
| 2380 |
+ |
| 2381 |
+ TStorage data; |
| 2382 |
+ }; |
| 2383 |
+ } |
| 2384 |
+ |
| 2385 |
+ template <typename T> |
| 2386 |
+ using storage_for = Detail::ObjectStorage<T, true>; |
| 2387 |
+ |
| 2388 |
+ template <typename T> |
| 2389 |
+ using destructable_object = Detail::ObjectStorage<T, false>; |
| 2390 |
+ } |
| 2391 |
+} |
| 2392 |
+ |
| 2393 |
+// end catch_constructor.hpp |
| 2394 |
+// end catch_benchmarking_all.hpp |
| 2395 |
#endif |
| 2396 |
|
| 2397 |
#endif // ! CATCH_CONFIG_IMPL_ONLY |
| 2398 |
@@ -7183,23 +7480,37 @@ namespace TestCaseTracking { |
| 2399 |
SourceLineInfo location; |
| 2400 |
|
| 2401 |
NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); |
| 2402 |
+ friend bool operator==(NameAndLocation const& lhs, NameAndLocation const& rhs) { |
| 2403 |
+ return lhs.name == rhs.name |
| 2404 |
+ && lhs.location == rhs.location; |
| 2405 |
+ } |
| 2406 |
}; |
| 2407 |
|
| 2408 |
- struct ITracker; |
| 2409 |
+ class ITracker; |
| 2410 |
|
| 2411 |
using ITrackerPtr = std::shared_ptr<ITracker>; |
| 2412 |
|
| 2413 |
- struct ITracker { |
| 2414 |
- virtual ~ITracker(); |
| 2415 |
+ class ITracker { |
| 2416 |
+ NameAndLocation m_nameAndLocation; |
| 2417 |
+ |
| 2418 |
+ public: |
| 2419 |
+ ITracker(NameAndLocation const& nameAndLoc) : |
| 2420 |
+ m_nameAndLocation(nameAndLoc) |
| 2421 |
+ {} |
| 2422 |
|
| 2423 |
// static queries |
| 2424 |
- virtual NameAndLocation const& nameAndLocation() const = 0; |
| 2425 |
+ NameAndLocation const& nameAndLocation() const { |
| 2426 |
+ return m_nameAndLocation; |
| 2427 |
+ } |
| 2428 |
+ |
| 2429 |
+ virtual ~ITracker(); |
| 2430 |
|
| 2431 |
// dynamic queries |
| 2432 |
virtual bool isComplete() const = 0; // Successfully completed or failed |
| 2433 |
virtual bool isSuccessfullyCompleted() const = 0; |
| 2434 |
virtual bool isOpen() const = 0; // Started but not complete |
| 2435 |
virtual bool hasChildren() const = 0; |
| 2436 |
+ virtual bool hasStarted() const = 0; |
| 2437 |
|
| 2438 |
virtual ITracker& parent() = 0; |
| 2439 |
|
| 2440 |
@@ -7254,7 +7565,6 @@ namespace TestCaseTracking { |
| 2441 |
}; |
| 2442 |
|
| 2443 |
using Children = std::vector<ITrackerPtr>; |
| 2444 |
- NameAndLocation m_nameAndLocation; |
| 2445 |
TrackerContext& m_ctx; |
| 2446 |
ITracker* m_parent; |
| 2447 |
Children m_children; |
| 2448 |
@@ -7263,11 +7573,13 @@ namespace TestCaseTracking { |
| 2449 |
public: |
| 2450 |
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 2451 |
|
| 2452 |
- NameAndLocation const& nameAndLocation() const override; |
| 2453 |
bool isComplete() const override; |
| 2454 |
bool isSuccessfullyCompleted() const override; |
| 2455 |
bool isOpen() const override; |
| 2456 |
bool hasChildren() const override; |
| 2457 |
+ bool hasStarted() const override { |
| 2458 |
+ return m_runState != NotStarted; |
| 2459 |
+ } |
| 2460 |
|
| 2461 |
void addChild( ITrackerPtr const& child ) override; |
| 2462 |
|
| 2463 |
@@ -7292,6 +7604,7 @@ namespace TestCaseTracking { |
| 2464 |
|
| 2465 |
class SectionTracker : public TrackerBase { |
| 2466 |
std::vector<std::string> m_filters; |
| 2467 |
+ std::string m_trimmed_name; |
| 2468 |
public: |
| 2469 |
SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 2470 |
|
| 2471 |
@@ -7305,6 +7618,10 @@ namespace TestCaseTracking { |
| 2472 |
|
| 2473 |
void addInitialFilters( std::vector<std::string> const& filters ); |
| 2474 |
void addNextFilters( std::vector<std::string> const& filters ); |
| 2475 |
+ //! Returns filters active in this tracker |
| 2476 |
+ std::vector<std::string> const& getFilters() const; |
| 2477 |
+ //! Returns whitespace-trimmed name of the tracked section |
| 2478 |
+ std::string const& trimmedName() const; |
| 2479 |
}; |
| 2480 |
|
| 2481 |
} // namespace TestCaseTracking |
| 2482 |
@@ -7470,7 +7787,7 @@ namespace Catch { |
| 2483 |
double sb = stddev.point; |
| 2484 |
double mn = mean.point / n; |
| 2485 |
double mg_min = mn / 2.; |
| 2486 |
- double sg = std::min(mg_min / 4., sb / std::sqrt(n)); |
| 2487 |
+ double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); |
| 2488 |
double sg2 = sg * sg; |
| 2489 |
double sb2 = sb * sb; |
| 2490 |
|
| 2491 |
@@ -7489,13 +7806,14 @@ namespace Catch { |
| 2492 |
return (nc / n) * (sb2 - nc * sg2); |
| 2493 |
}; |
| 2494 |
|
| 2495 |
- return std::min(var_out(1), var_out(std::min(c_max(0.), c_max(mg_min)))) / sb2; |
| 2496 |
+ return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; |
| 2497 |
} |
| 2498 |
|
| 2499 |
bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) { |
| 2500 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION |
| 2501 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
| 2502 |
static std::random_device entropy; |
| 2503 |
- CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS |
| 2504 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 2505 |
|
| 2506 |
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++ |
| 2507 |
|
| 2508 |
@@ -7583,7 +7901,8 @@ namespace Detail { |
| 2509 |
bool Approx::equalityComparisonImpl(const double other) const { |
| 2510 |
// First try with fixed margin, then compute margin based on epsilon, scale and Approx's value |
| 2511 |
// Thanks to Richard Harris for his help refining the scaled margin value |
| 2512 |
- return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value))); |
| 2513 |
+ return marginComparison(m_value, other, m_margin) |
| 2514 |
+ || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(std::isinf(m_value)? 0 : m_value))); |
| 2515 |
} |
| 2516 |
|
| 2517 |
void Approx::setMargin(double newMargin) { |
| 2518 |
@@ -7627,7 +7946,24 @@ namespace Catch { |
| 2519 |
|
| 2520 |
#ifdef CATCH_PLATFORM_MAC |
| 2521 |
|
| 2522 |
- #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ |
| 2523 |
+ #if defined(__i386__) || defined(__x86_64__) |
| 2524 |
+ #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ |
| 2525 |
+ #elif defined(__aarch64__) |
| 2526 |
+ #define CATCH_TRAP() __asm__(".inst 0xd4200000") |
| 2527 |
+ #endif |
| 2528 |
+ |
| 2529 |
+#elif defined(CATCH_PLATFORM_IPHONE) |
| 2530 |
+ |
| 2531 |
+ // use inline assembler |
| 2532 |
+ #if defined(__i386__) || defined(__x86_64__) |
| 2533 |
+ #define CATCH_TRAP() __asm__("int $3") |
| 2534 |
+ #elif defined(__aarch64__) |
| 2535 |
+ #define CATCH_TRAP() __asm__(".inst 0xd4200000") |
| 2536 |
+ #elif defined(__arm__) && !defined(__thumb__) |
| 2537 |
+ #define CATCH_TRAP() __asm__(".inst 0xe7f001f0") |
| 2538 |
+ #elif defined(__arm__) && defined(__thumb__) |
| 2539 |
+ #define CATCH_TRAP() __asm__(".inst 0xde01") |
| 2540 |
+ #endif |
| 2541 |
|
| 2542 |
#elif defined(CATCH_PLATFORM_LINUX) |
| 2543 |
// If we can use inline assembler, do it because this allows us to break |
| 2544 |
@@ -7647,10 +7983,12 @@ namespace Catch { |
| 2545 |
#define CATCH_TRAP() DebugBreak() |
| 2546 |
#endif |
| 2547 |
|
| 2548 |
-#ifdef CATCH_TRAP |
| 2549 |
- #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() |
| 2550 |
-#else |
| 2551 |
- #define CATCH_BREAK_INTO_DEBUGGER() []{}() |
| 2552 |
+#ifndef CATCH_BREAK_INTO_DEBUGGER |
| 2553 |
+ #ifdef CATCH_TRAP |
| 2554 |
+ #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() |
| 2555 |
+ #else |
| 2556 |
+ #define CATCH_BREAK_INTO_DEBUGGER() []{}() |
| 2557 |
+ #endif |
| 2558 |
#endif |
| 2559 |
|
| 2560 |
// end catch_debugger.h |
| 2561 |
@@ -7658,86 +7996,58 @@ namespace Catch { |
| 2562 |
|
| 2563 |
// start catch_fatal_condition.h |
| 2564 |
|
| 2565 |
-// start catch_windows_h_proxy.h |
| 2566 |
- |
| 2567 |
- |
| 2568 |
-#if defined(CATCH_PLATFORM_WINDOWS) |
| 2569 |
- |
| 2570 |
-#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) |
| 2571 |
-# define CATCH_DEFINED_NOMINMAX |
| 2572 |
-# define NOMINMAX |
| 2573 |
-#endif |
| 2574 |
-#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) |
| 2575 |
-# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN |
| 2576 |
-# define WIN32_LEAN_AND_MEAN |
| 2577 |
-#endif |
| 2578 |
- |
| 2579 |
-#ifdef __AFXDLL |
| 2580 |
-#include <AfxWin.h> |
| 2581 |
-#else |
| 2582 |
-#include <windows.h> |
| 2583 |
-#endif |
| 2584 |
- |
| 2585 |
-#ifdef CATCH_DEFINED_NOMINMAX |
| 2586 |
-# undef NOMINMAX |
| 2587 |
-#endif |
| 2588 |
-#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN |
| 2589 |
-# undef WIN32_LEAN_AND_MEAN |
| 2590 |
-#endif |
| 2591 |
- |
| 2592 |
-#endif // defined(CATCH_PLATFORM_WINDOWS) |
| 2593 |
- |
| 2594 |
-// end catch_windows_h_proxy.h |
| 2595 |
-#if defined( CATCH_CONFIG_WINDOWS_SEH ) |
| 2596 |
+#include <cassert> |
| 2597 |
|
| 2598 |
namespace Catch { |
| 2599 |
|
| 2600 |
- struct FatalConditionHandler { |
| 2601 |
- |
| 2602 |
- static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo); |
| 2603 |
+ // Wrapper for platform-specific fatal error (signals/SEH) handlers |
| 2604 |
+ // |
| 2605 |
+ // Tries to be cooperative with other handlers, and not step over |
| 2606 |
+ // other handlers. This means that unknown structured exceptions |
| 2607 |
+ // are passed on, previous signal handlers are called, and so on. |
| 2608 |
+ // |
| 2609 |
+ // Can only be instantiated once, and assumes that once a signal |
| 2610 |
+ // is caught, the binary will end up terminating. Thus, there |
| 2611 |
+ class FatalConditionHandler { |
| 2612 |
+ bool m_started = false; |
| 2613 |
+ |
| 2614 |
+ // Install/disengage implementation for specific platform. |
| 2615 |
+ // Should be if-defed to work on current platform, can assume |
| 2616 |
+ // engage-disengage 1:1 pairing. |
| 2617 |
+ void engage_platform(); |
| 2618 |
+ void disengage_platform(); |
| 2619 |
+ public: |
| 2620 |
+ // Should also have platform-specific implementations as needed |
| 2621 |
FatalConditionHandler(); |
| 2622 |
- static void reset(); |
| 2623 |
~FatalConditionHandler(); |
| 2624 |
|
| 2625 |
- private: |
| 2626 |
- static bool isSet; |
| 2627 |
- static ULONG guaranteeSize; |
| 2628 |
- static PVOID exceptionHandlerHandle; |
| 2629 |
- }; |
| 2630 |
- |
| 2631 |
-} // namespace Catch |
| 2632 |
- |
| 2633 |
-#elif defined ( CATCH_CONFIG_POSIX_SIGNALS ) |
| 2634 |
- |
| 2635 |
-#include <signal.h> |
| 2636 |
- |
| 2637 |
-namespace Catch { |
| 2638 |
- |
| 2639 |
- struct FatalConditionHandler { |
| 2640 |
- |
| 2641 |
- static bool isSet; |
| 2642 |
- static struct sigaction oldSigActions[]; |
| 2643 |
- static stack_t oldSigStack; |
| 2644 |
- static char altStackMem[]; |
| 2645 |
- |
| 2646 |
- static void handleSignal( int sig ); |
| 2647 |
+ void engage() { |
| 2648 |
+ assert(!m_started && "Handler cannot be installed twice."); |
| 2649 |
+ m_started = true; |
| 2650 |
+ engage_platform(); |
| 2651 |
+ } |
| 2652 |
|
| 2653 |
- FatalConditionHandler(); |
| 2654 |
- ~FatalConditionHandler(); |
| 2655 |
- static void reset(); |
| 2656 |
+ void disengage() { |
| 2657 |
+ assert(m_started && "Handler cannot be uninstalled without being installed first"); |
| 2658 |
+ m_started = false; |
| 2659 |
+ disengage_platform(); |
| 2660 |
+ } |
| 2661 |
}; |
| 2662 |
|
| 2663 |
-} // namespace Catch |
| 2664 |
- |
| 2665 |
-#else |
| 2666 |
- |
| 2667 |
-namespace Catch { |
| 2668 |
- struct FatalConditionHandler { |
| 2669 |
- void reset(); |
| 2670 |
+ //! Simple RAII guard for (dis)engaging the FatalConditionHandler |
| 2671 |
+ class FatalConditionHandlerGuard { |
| 2672 |
+ FatalConditionHandler* m_handler; |
| 2673 |
+ public: |
| 2674 |
+ FatalConditionHandlerGuard(FatalConditionHandler* handler): |
| 2675 |
+ m_handler(handler) { |
| 2676 |
+ m_handler->engage(); |
| 2677 |
+ } |
| 2678 |
+ ~FatalConditionHandlerGuard() { |
| 2679 |
+ m_handler->disengage(); |
| 2680 |
+ } |
| 2681 |
}; |
| 2682 |
-} |
| 2683 |
|
| 2684 |
-#endif |
| 2685 |
+} // end namespace Catch |
| 2686 |
|
| 2687 |
// end catch_fatal_condition.h |
| 2688 |
#include <string> |
| 2689 |
@@ -7797,7 +8107,7 @@ namespace Catch { |
| 2690 |
void sectionEnded( SectionEndInfo const& endInfo ) override; |
| 2691 |
void sectionEndedEarly( SectionEndInfo const& endInfo ) override; |
| 2692 |
|
| 2693 |
- auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override; |
| 2694 |
+ auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override; |
| 2695 |
|
| 2696 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 2697 |
void benchmarkPreparing( std::string const& name ) override; |
| 2698 |
@@ -7863,11 +8173,14 @@ namespace Catch { |
| 2699 |
std::vector<SectionEndInfo> m_unfinishedSections; |
| 2700 |
std::vector<ITracker*> m_activeSections; |
| 2701 |
TrackerContext m_trackerContext; |
| 2702 |
+ FatalConditionHandler m_fatalConditionhandler; |
| 2703 |
bool m_lastAssertionPassed = false; |
| 2704 |
bool m_shouldReportUnexpected = true; |
| 2705 |
bool m_includeSuccessfulResults; |
| 2706 |
}; |
| 2707 |
|
| 2708 |
+ void seedRng(IConfig const& config); |
| 2709 |
+ unsigned int rngSeed(); |
| 2710 |
} // end namespace Catch |
| 2711 |
|
| 2712 |
// end catch_run_context.h |
| 2713 |
@@ -8014,7 +8327,7 @@ namespace Catch { |
| 2714 |
} |
| 2715 |
|
| 2716 |
bool AssertionResult::hasExpression() const { |
| 2717 |
- return m_info.capturedExpression[0] != 0; |
| 2718 |
+ return !m_info.capturedExpression.empty(); |
| 2719 |
} |
| 2720 |
|
| 2721 |
bool AssertionResult::hasMessage() const { |
| 2722 |
@@ -8022,16 +8335,22 @@ namespace Catch { |
| 2723 |
} |
| 2724 |
|
| 2725 |
std::string AssertionResult::getExpression() const { |
| 2726 |
- if( isFalseTest( m_info.resultDisposition ) ) |
| 2727 |
- return "!(" + m_info.capturedExpression + ")"; |
| 2728 |
- else |
| 2729 |
- return m_info.capturedExpression; |
| 2730 |
+ // Possibly overallocating by 3 characters should be basically free |
| 2731 |
+ std::string expr; expr.reserve(m_info.capturedExpression.size() + 3); |
| 2732 |
+ if (isFalseTest(m_info.resultDisposition)) { |
| 2733 |
+ expr += "!("; |
| 2734 |
+ } |
| 2735 |
+ expr += m_info.capturedExpression; |
| 2736 |
+ if (isFalseTest(m_info.resultDisposition)) { |
| 2737 |
+ expr += ')'; |
| 2738 |
+ } |
| 2739 |
+ return expr; |
| 2740 |
} |
| 2741 |
|
| 2742 |
std::string AssertionResult::getExpressionInMacro() const { |
| 2743 |
std::string expr; |
| 2744 |
- if( m_info.macroName[0] == 0 ) |
| 2745 |
- expr = m_info.capturedExpression; |
| 2746 |
+ if( m_info.macroName.empty() ) |
| 2747 |
+ expr = static_cast<std::string>(m_info.capturedExpression); |
| 2748 |
else { |
| 2749 |
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); |
| 2750 |
expr += m_info.macroName; |
| 2751 |
@@ -8765,7 +9084,7 @@ namespace detail { |
| 2752 |
} |
| 2753 |
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { |
| 2754 |
std::string srcLC = source; |
| 2755 |
- std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( std::tolower(c) ); } ); |
| 2756 |
+ std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower(c) ); } ); |
| 2757 |
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") |
| 2758 |
target = true; |
| 2759 |
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") |
| 2760 |
@@ -9413,9 +9732,14 @@ namespace Catch { |
| 2761 |
if( !line.empty() && !startsWith( line, '#' ) ) { |
| 2762 |
if( !startsWith( line, '"' ) ) |
| 2763 |
line = '"' + line + '"'; |
| 2764 |
- config.testsOrTags.push_back( line + ',' ); |
| 2765 |
+ config.testsOrTags.push_back( line ); |
| 2766 |
+ config.testsOrTags.emplace_back( "," ); |
| 2767 |
} |
| 2768 |
} |
| 2769 |
+ //Remove comma in the end |
| 2770 |
+ if(!config.testsOrTags.empty()) |
| 2771 |
+ config.testsOrTags.erase( config.testsOrTags.end()-1 ); |
| 2772 |
+ |
| 2773 |
return ParserResult::ok( ParseResultType::Matched ); |
| 2774 |
}; |
| 2775 |
auto const setTestOrder = [&]( std::string const& order ) { |
| 2776 |
@@ -9450,14 +9774,16 @@ namespace Catch { |
| 2777 |
}; |
| 2778 |
auto const setWaitForKeypress = [&]( std::string const& keypress ) { |
| 2779 |
auto keypressLc = toLower( keypress ); |
| 2780 |
- if( keypressLc == "start" ) |
| 2781 |
+ if (keypressLc == "never") |
| 2782 |
+ config.waitForKeypress = WaitForKeypress::Never; |
| 2783 |
+ else if( keypressLc == "start" ) |
| 2784 |
config.waitForKeypress = WaitForKeypress::BeforeStart; |
| 2785 |
else if( keypressLc == "exit" ) |
| 2786 |
config.waitForKeypress = WaitForKeypress::BeforeExit; |
| 2787 |
else if( keypressLc == "both" ) |
| 2788 |
config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; |
| 2789 |
else |
| 2790 |
- return ParserResult::runtimeError( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" ); |
| 2791 |
+ return ParserResult::runtimeError( "keypress argument must be one of: never, start, exit or both. '" + keypress + "' not recognised" ); |
| 2792 |
return ParserResult::ok( ParseResultType::Matched ); |
| 2793 |
}; |
| 2794 |
auto const setVerbosity = [&]( std::string const& verbosity ) { |
| 2795 |
@@ -9527,6 +9853,9 @@ namespace Catch { |
| 2796 |
| Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) |
| 2797 |
["-d"]["--durations"] |
| 2798 |
( "show test durations" ) |
| 2799 |
+ | Opt( config.minDuration, "seconds" ) |
| 2800 |
+ ["-D"]["--min-duration"] |
| 2801 |
+ ( "show test durations for tests taking at least the given number of seconds" ) |
| 2802 |
| Opt( loadTestNamesFromFile, "filename" ) |
| 2803 |
["-f"]["--input-file"] |
| 2804 |
( "load test names to run from a file" ) |
| 2805 |
@@ -9557,7 +9886,7 @@ namespace Catch { |
| 2806 |
| Opt( config.libIdentify ) |
| 2807 |
["--libidentify"] |
| 2808 |
( "report name and version according to libidentify standard" ) |
| 2809 |
- | Opt( setWaitForKeypress, "start|exit|both" ) |
| 2810 |
+ | Opt( setWaitForKeypress, "never|start|exit|both" ) |
| 2811 |
["--wait-for-keypress"] |
| 2812 |
( "waits for a keypress before exiting" ) |
| 2813 |
| Opt( config.benchmarkSamples, "samples" ) |
| 2814 |
@@ -9572,7 +9901,10 @@ namespace Catch { |
| 2815 |
| Opt( config.benchmarkNoAnalysis ) |
| 2816 |
["--benchmark-no-analysis"] |
| 2817 |
( "perform only measurements; do not perform any analysis" ) |
| 2818 |
- | Arg( config.testsOrTags, "test name|pattern|tags" ) |
| 2819 |
+ | Opt( config.benchmarkWarmupTime, "benchmarkWarmupTime" ) |
| 2820 |
+ ["--benchmark-warmup-time"] |
| 2821 |
+ ( "amount of time in milliseconds spent on warming up each test (default: 100)" ) |
| 2822 |
+ | Arg( config.testsOrTags, "test name|pattern|tags" ) |
| 2823 |
( "which test or tests to use" ); |
| 2824 |
|
| 2825 |
return cli; |
| 2826 |
@@ -9587,9 +9919,6 @@ namespace Catch { |
| 2827 |
|
| 2828 |
namespace Catch { |
| 2829 |
|
| 2830 |
- bool SourceLineInfo::empty() const noexcept { |
| 2831 |
- return file[0] == '\0'; |
| 2832 |
- } |
| 2833 |
bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { |
| 2834 |
return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); |
| 2835 |
} |
| 2836 |
@@ -9625,11 +9954,23 @@ namespace Catch { |
| 2837 |
: m_data( data ), |
| 2838 |
m_stream( openStream() ) |
| 2839 |
{ |
| 2840 |
+ // We need to trim filter specs to avoid trouble with superfluous |
| 2841 |
+ // whitespace (esp. important for bdd macros, as those are manually |
| 2842 |
+ // aligned with whitespace). |
| 2843 |
+ |
| 2844 |
+ for (auto& elem : m_data.testsOrTags) { |
| 2845 |
+ elem = trim(elem); |
| 2846 |
+ } |
| 2847 |
+ for (auto& elem : m_data.sectionsToRun) { |
| 2848 |
+ elem = trim(elem); |
| 2849 |
+ } |
| 2850 |
+ |
| 2851 |
TestSpecParser parser(ITagAliasRegistry::get()); |
| 2852 |
- if (!data.testsOrTags.empty()) { |
| 2853 |
+ if (!m_data.testsOrTags.empty()) { |
| 2854 |
m_hasTestFilters = true; |
| 2855 |
- for( auto const& testOrTags : data.testsOrTags ) |
| 2856 |
- parser.parse( testOrTags ); |
| 2857 |
+ for (auto const& testOrTags : m_data.testsOrTags) { |
| 2858 |
+ parser.parse(testOrTags); |
| 2859 |
+ } |
| 2860 |
} |
| 2861 |
m_testSpec = parser.testSpec(); |
| 2862 |
} |
| 2863 |
@@ -9662,6 +10003,7 @@ namespace Catch { |
| 2864 |
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } |
| 2865 |
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } |
| 2866 |
ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } |
| 2867 |
+ double Config::minDuration() const { return m_data.minDuration; } |
| 2868 |
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } |
| 2869 |
unsigned int Config::rngSeed() const { return m_data.rngSeed; } |
| 2870 |
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } |
| 2871 |
@@ -9670,10 +10012,11 @@ namespace Catch { |
| 2872 |
bool Config::showInvisibles() const { return m_data.showInvisibles; } |
| 2873 |
Verbosity Config::verbosity() const { return m_data.verbosity; } |
| 2874 |
|
| 2875 |
- bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; } |
| 2876 |
- int Config::benchmarkSamples() const { return m_data.benchmarkSamples; } |
| 2877 |
- double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; } |
| 2878 |
- unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; } |
| 2879 |
+ bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; } |
| 2880 |
+ int Config::benchmarkSamples() const { return m_data.benchmarkSamples; } |
| 2881 |
+ double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; } |
| 2882 |
+ unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; } |
| 2883 |
+ std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); } |
| 2884 |
|
| 2885 |
IStream const* Config::openStream() { |
| 2886 |
return Catch::makeStream(m_data.outputFilename); |
| 2887 |
@@ -9703,6 +10046,36 @@ namespace Catch { |
| 2888 |
} |
| 2889 |
|
| 2890 |
// end catch_errno_guard.h |
| 2891 |
+// start catch_windows_h_proxy.h |
| 2892 |
+ |
| 2893 |
+ |
| 2894 |
+#if defined(CATCH_PLATFORM_WINDOWS) |
| 2895 |
+ |
| 2896 |
+#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) |
| 2897 |
+# define CATCH_DEFINED_NOMINMAX |
| 2898 |
+# define NOMINMAX |
| 2899 |
+#endif |
| 2900 |
+#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) |
| 2901 |
+# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN |
| 2902 |
+# define WIN32_LEAN_AND_MEAN |
| 2903 |
+#endif |
| 2904 |
+ |
| 2905 |
+#ifdef __AFXDLL |
| 2906 |
+#include <AfxWin.h> |
| 2907 |
+#else |
| 2908 |
+#include <windows.h> |
| 2909 |
+#endif |
| 2910 |
+ |
| 2911 |
+#ifdef CATCH_DEFINED_NOMINMAX |
| 2912 |
+# undef NOMINMAX |
| 2913 |
+#endif |
| 2914 |
+#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN |
| 2915 |
+# undef WIN32_LEAN_AND_MEAN |
| 2916 |
+#endif |
| 2917 |
+ |
| 2918 |
+#endif // defined(CATCH_PLATFORM_WINDOWS) |
| 2919 |
+ |
| 2920 |
+// end catch_windows_h_proxy.h |
| 2921 |
#include <sstream> |
| 2922 |
|
| 2923 |
namespace Catch { |
| 2924 |
@@ -9714,7 +10087,7 @@ namespace Catch { |
| 2925 |
}; |
| 2926 |
|
| 2927 |
struct NoColourImpl : IColourImpl { |
| 2928 |
- void use( Colour::Code ) {} |
| 2929 |
+ void use( Colour::Code ) override {} |
| 2930 |
|
| 2931 |
static IColourImpl* instance() { |
| 2932 |
static NoColourImpl s_instance; |
| 2933 |
@@ -9846,7 +10219,7 @@ namespace { |
| 2934 |
|
| 2935 |
bool useColourOnPlatform() { |
| 2936 |
return |
| 2937 |
-#ifdef CATCH_PLATFORM_MAC |
| 2938 |
+#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) |
| 2939 |
!isDebuggerActive() && |
| 2940 |
#endif |
| 2941 |
#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) |
| 2942 |
@@ -9887,13 +10260,13 @@ namespace Catch { |
| 2943 |
namespace Catch { |
| 2944 |
|
| 2945 |
Colour::Colour( Code _colourCode ) { use( _colourCode ); } |
| 2946 |
- Colour::Colour( Colour&& rhs ) noexcept { |
| 2947 |
- m_moved = rhs.m_moved; |
| 2948 |
- rhs.m_moved = true; |
| 2949 |
- } |
| 2950 |
- Colour& Colour::operator=( Colour&& rhs ) noexcept { |
| 2951 |
- m_moved = rhs.m_moved; |
| 2952 |
- rhs.m_moved = true; |
| 2953 |
+ Colour::Colour( Colour&& other ) noexcept { |
| 2954 |
+ m_moved = other.m_moved; |
| 2955 |
+ other.m_moved = true; |
| 2956 |
+ } |
| 2957 |
+ Colour& Colour::operator=( Colour&& other ) noexcept { |
| 2958 |
+ m_moved = other.m_moved; |
| 2959 |
+ other.m_moved = true; |
| 2960 |
return *this; |
| 2961 |
} |
| 2962 |
|
| 2963 |
@@ -9905,7 +10278,7 @@ namespace Catch { |
| 2964 |
// However, under some conditions it does happen (see #1626), |
| 2965 |
// and this change is small enough that we can let practicality |
| 2966 |
// triumph over purity in this case. |
| 2967 |
- if (impl != NULL) { |
| 2968 |
+ if (impl != nullptr) { |
| 2969 |
impl->use( _colourCode ); |
| 2970 |
} |
| 2971 |
} |
| 2972 |
@@ -9974,6 +10347,12 @@ namespace Catch { |
| 2973 |
IContext::~IContext() = default; |
| 2974 |
IMutableContext::~IMutableContext() = default; |
| 2975 |
Context::~Context() = default; |
| 2976 |
+ |
| 2977 |
+ SimplePcg32& rng() { |
| 2978 |
+ static SimplePcg32 s_rng; |
| 2979 |
+ return s_rng; |
| 2980 |
+ } |
| 2981 |
+ |
| 2982 |
} |
| 2983 |
// end catch_context.cpp |
| 2984 |
// start catch_debug_console.cpp |
| 2985 |
@@ -9987,12 +10366,12 @@ namespace Catch { |
| 2986 |
} |
| 2987 |
|
| 2988 |
// end catch_debug_console.h |
| 2989 |
-#if defined(__ANDROID__) |
| 2990 |
+#if defined(CATCH_CONFIG_ANDROID_LOGWRITE) |
| 2991 |
#include <android/log.h> |
| 2992 |
|
| 2993 |
namespace Catch { |
| 2994 |
void writeToDebugConsole( std::string const& text ) { |
| 2995 |
- __android_log_print( ANDROID_LOG_DEBUG, "Catch", text.c_str() ); |
| 2996 |
+ __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() ); |
| 2997 |
} |
| 2998 |
} |
| 2999 |
|
| 3000 |
@@ -10017,10 +10396,9 @@ namespace Catch { |
| 3001 |
// end catch_debug_console.cpp |
| 3002 |
// start catch_debugger.cpp |
| 3003 |
|
| 3004 |
-#ifdef CATCH_PLATFORM_MAC |
| 3005 |
+#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) |
| 3006 |
|
| 3007 |
-# include <assert.h> |
| 3008 |
-# include <stdbool.h> |
| 3009 |
+# include <cassert> |
| 3010 |
# include <sys/types.h> |
| 3011 |
# include <unistd.h> |
| 3012 |
# include <cstddef> |
| 3013 |
@@ -10193,7 +10571,7 @@ namespace Catch { |
| 3014 |
EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override; |
| 3015 |
}; |
| 3016 |
|
| 3017 |
- std::vector<std::string> parseEnums( StringRef enums ); |
| 3018 |
+ std::vector<StringRef> parseEnums( StringRef enums ); |
| 3019 |
|
| 3020 |
} // Detail |
| 3021 |
|
| 3022 |
@@ -10210,13 +10588,25 @@ namespace Catch { |
| 3023 |
|
| 3024 |
namespace Detail { |
| 3025 |
|
| 3026 |
- std::vector<std::string> parseEnums( StringRef enums ) { |
| 3027 |
+ namespace { |
| 3028 |
+ // Extracts the actual name part of an enum instance |
| 3029 |
+ // In other words, it returns the Blue part of Bikeshed::Colour::Blue |
| 3030 |
+ StringRef extractInstanceName(StringRef enumInstance) { |
| 3031 |
+ // Find last occurrence of ":" |
| 3032 |
+ size_t name_start = enumInstance.size(); |
| 3033 |
+ while (name_start > 0 && enumInstance[name_start - 1] != ':') { |
| 3034 |
+ --name_start; |
| 3035 |
+ } |
| 3036 |
+ return enumInstance.substr(name_start, enumInstance.size() - name_start); |
| 3037 |
+ } |
| 3038 |
+ } |
| 3039 |
+ |
| 3040 |
+ std::vector<StringRef> parseEnums( StringRef enums ) { |
| 3041 |
auto enumValues = splitStringRef( enums, ',' ); |
| 3042 |
- std::vector<std::string> parsed; |
| 3043 |
+ std::vector<StringRef> parsed; |
| 3044 |
parsed.reserve( enumValues.size() ); |
| 3045 |
for( auto const& enumValue : enumValues ) { |
| 3046 |
- auto identifiers = splitStringRef( enumValue, ':' ); |
| 3047 |
- parsed.push_back( Catch::trim( identifiers.back() ) ); |
| 3048 |
+ parsed.push_back(trim(extractInstanceName(enumValue))); |
| 3049 |
} |
| 3050 |
return parsed; |
| 3051 |
} |
| 3052 |
@@ -10228,7 +10618,7 @@ namespace Catch { |
| 3053 |
if( valueToName.first == value ) |
| 3054 |
return valueToName.second; |
| 3055 |
} |
| 3056 |
- return "{** unexpected enum value **}"; |
| 3057 |
+ return "{** unexpected enum value **}"_sr; |
| 3058 |
} |
| 3059 |
|
| 3060 |
std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { |
| 3061 |
@@ -10240,16 +10630,14 @@ namespace Catch { |
| 3062 |
assert( valueNames.size() == values.size() ); |
| 3063 |
std::size_t i = 0; |
| 3064 |
for( auto value : values ) |
| 3065 |
- enumInfo->m_values.push_back({ value, valueNames[i++] }); |
| 3066 |
+ enumInfo->m_values.emplace_back(value, valueNames[i++]); |
| 3067 |
|
| 3068 |
return enumInfo; |
| 3069 |
} |
| 3070 |
|
| 3071 |
EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { |
| 3072 |
- auto enumInfo = makeEnumInfo( enumName, allValueNames, values ); |
| 3073 |
- EnumInfo* raw = enumInfo.get(); |
| 3074 |
- m_enumInfos.push_back( std::move( enumInfo ) ); |
| 3075 |
- return *raw; |
| 3076 |
+ m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); |
| 3077 |
+ return *m_enumInfos.back(); |
| 3078 |
} |
| 3079 |
|
| 3080 |
} // Detail |
| 3081 |
@@ -10366,25 +10754,47 @@ namespace Catch { |
| 3082 |
// end catch_exception_translator_registry.cpp |
| 3083 |
// start catch_fatal_condition.cpp |
| 3084 |
|
| 3085 |
-#if defined(__GNUC__) |
| 3086 |
-# pragma GCC diagnostic push |
| 3087 |
-# pragma GCC diagnostic ignored "-Wmissing-field-initializers" |
| 3088 |
-#endif |
| 3089 |
+#include <algorithm> |
| 3090 |
+ |
| 3091 |
+#if !defined( CATCH_CONFIG_WINDOWS_SEH ) && !defined( CATCH_CONFIG_POSIX_SIGNALS ) |
| 3092 |
+ |
| 3093 |
+namespace Catch { |
| 3094 |
+ |
| 3095 |
+ // If neither SEH nor signal handling is required, the handler impls |
| 3096 |
+ // do not have to do anything, and can be empty. |
| 3097 |
+ void FatalConditionHandler::engage_platform() {} |
| 3098 |
+ void FatalConditionHandler::disengage_platform() {} |
| 3099 |
+ FatalConditionHandler::FatalConditionHandler() = default; |
| 3100 |
+ FatalConditionHandler::~FatalConditionHandler() = default; |
| 3101 |
+ |
| 3102 |
+} // end namespace Catch |
| 3103 |
+ |
| 3104 |
+#endif // !CATCH_CONFIG_WINDOWS_SEH && !CATCH_CONFIG_POSIX_SIGNALS |
| 3105 |
+ |
| 3106 |
+#if defined( CATCH_CONFIG_WINDOWS_SEH ) && defined( CATCH_CONFIG_POSIX_SIGNALS ) |
| 3107 |
+#error "Inconsistent configuration: Windows' SEH handling and POSIX signals cannot be enabled at the same time" |
| 3108 |
+#endif // CATCH_CONFIG_WINDOWS_SEH && CATCH_CONFIG_POSIX_SIGNALS |
| 3109 |
|
| 3110 |
#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS ) |
| 3111 |
|
| 3112 |
namespace { |
| 3113 |
- // Report the error condition |
| 3114 |
+ //! Signals fatal error message to the run context |
| 3115 |
void reportFatal( char const * const message ) { |
| 3116 |
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); |
| 3117 |
} |
| 3118 |
-} |
| 3119 |
|
| 3120 |
-#endif // signals/SEH handling |
| 3121 |
+ //! Minimal size Catch2 needs for its own fatal error handling. |
| 3122 |
+ //! Picked anecdotally, so it might not be sufficient on all |
| 3123 |
+ //! platforms, and for all configurations. |
| 3124 |
+ constexpr std::size_t minStackSizeForErrors = 32 * 1024; |
| 3125 |
+} // end unnamed namespace |
| 3126 |
+ |
| 3127 |
+#endif // CATCH_CONFIG_WINDOWS_SEH || CATCH_CONFIG_POSIX_SIGNALS |
| 3128 |
|
| 3129 |
#if defined( CATCH_CONFIG_WINDOWS_SEH ) |
| 3130 |
|
| 3131 |
namespace Catch { |
| 3132 |
+ |
| 3133 |
struct SignalDefs { DWORD id; const char* name; }; |
| 3134 |
|
| 3135 |
// There is no 1-1 mapping between signals and windows exceptions. |
| 3136 |
@@ -10397,7 +10807,7 @@ namespace Catch { |
| 3137 |
{ static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" }, |
| 3138 |
}; |
| 3139 |
|
| 3140 |
- LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { |
| 3141 |
+ static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { |
| 3142 |
for (auto const& def : signalDefs) { |
| 3143 |
if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { |
| 3144 |
reportFatal(def.name); |
| 3145 |
@@ -10408,38 +10818,50 @@ namespace Catch { |
| 3146 |
return EXCEPTION_CONTINUE_SEARCH; |
| 3147 |
} |
| 3148 |
|
| 3149 |
+ // Since we do not support multiple instantiations, we put these |
| 3150 |
+ // into global variables and rely on cleaning them up in outlined |
| 3151 |
+ // constructors/destructors |
| 3152 |
+ static PVOID exceptionHandlerHandle = nullptr; |
| 3153 |
+ |
| 3154 |
+ // For MSVC, we reserve part of the stack memory for handling |
| 3155 |
+ // memory overflow structured exception. |
| 3156 |
FatalConditionHandler::FatalConditionHandler() { |
| 3157 |
- isSet = true; |
| 3158 |
- // 32k seems enough for Catch to handle stack overflow, |
| 3159 |
- // but the value was found experimentally, so there is no strong guarantee |
| 3160 |
- guaranteeSize = 32 * 1024; |
| 3161 |
- exceptionHandlerHandle = nullptr; |
| 3162 |
+ ULONG guaranteeSize = static_cast<ULONG>(minStackSizeForErrors); |
| 3163 |
+ if (!SetThreadStackGuarantee(&guaranteeSize)) { |
| 3164 |
+ // We do not want to fully error out, because needing |
| 3165 |
+ // the stack reserve should be rare enough anyway. |
| 3166 |
+ Catch::cerr() |
| 3167 |
+ << "Failed to reserve piece of stack." |
| 3168 |
+ << " Stack overflows will not be reported successfully."; |
| 3169 |
+ } |
| 3170 |
+ } |
| 3171 |
+ |
| 3172 |
+ // We do not attempt to unset the stack guarantee, because |
| 3173 |
+ // Windows does not support lowering the stack size guarantee. |
| 3174 |
+ FatalConditionHandler::~FatalConditionHandler() = default; |
| 3175 |
+ |
| 3176 |
+ void FatalConditionHandler::engage_platform() { |
| 3177 |
// Register as first handler in current chain |
| 3178 |
exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); |
| 3179 |
- // Pass in guarantee size to be filled |
| 3180 |
- SetThreadStackGuarantee(&guaranteeSize); |
| 3181 |
+ if (!exceptionHandlerHandle) { |
| 3182 |
+ CATCH_RUNTIME_ERROR("Could not register vectored exception handler"); |
| 3183 |
+ } |
| 3184 |
} |
| 3185 |
|
| 3186 |
- void FatalConditionHandler::reset() { |
| 3187 |
- if (isSet) { |
| 3188 |
- RemoveVectoredExceptionHandler(exceptionHandlerHandle); |
| 3189 |
- SetThreadStackGuarantee(&guaranteeSize); |
| 3190 |
- exceptionHandlerHandle = nullptr; |
| 3191 |
- isSet = false; |
| 3192 |
+ void FatalConditionHandler::disengage_platform() { |
| 3193 |
+ if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) { |
| 3194 |
+ CATCH_RUNTIME_ERROR("Could not unregister vectored exception handler"); |
| 3195 |
} |
| 3196 |
+ exceptionHandlerHandle = nullptr; |
| 3197 |
} |
| 3198 |
|
| 3199 |
- FatalConditionHandler::~FatalConditionHandler() { |
| 3200 |
- reset(); |
| 3201 |
- } |
| 3202 |
+} // end namespace Catch |
| 3203 |
|
| 3204 |
-bool FatalConditionHandler::isSet = false; |
| 3205 |
-ULONG FatalConditionHandler::guaranteeSize = 0; |
| 3206 |
-PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; |
| 3207 |
+#endif // CATCH_CONFIG_WINDOWS_SEH |
| 3208 |
|
| 3209 |
-} // namespace Catch |
| 3210 |
+#if defined( CATCH_CONFIG_POSIX_SIGNALS ) |
| 3211 |
|
| 3212 |
-#elif defined( CATCH_CONFIG_POSIX_SIGNALS ) |
| 3213 |
+#include <signal.h> |
| 3214 |
|
| 3215 |
namespace Catch { |
| 3216 |
|
| 3217 |
@@ -10448,10 +10870,6 @@ namespace Catch { |
| 3218 |
const char* name; |
| 3219 |
}; |
| 3220 |
|
| 3221 |
- // 32kb for the alternate stack seems to be sufficient. However, this value |
| 3222 |
- // is experimentally determined, so that's not guaranteed. |
| 3223 |
- static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ; |
| 3224 |
- |
| 3225 |
static SignalDefs signalDefs[] = { |
| 3226 |
{ SIGINT, "SIGINT - Terminal interrupt signal" }, |
| 3227 |
{ SIGILL, "SIGILL - Illegal instruction signal" }, |
| 3228 |
@@ -10461,7 +10879,32 @@ namespace Catch { |
| 3229 |
{ SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } |
| 3230 |
}; |
| 3231 |
|
| 3232 |
- void FatalConditionHandler::handleSignal( int sig ) { |
| 3233 |
+// Older GCCs trigger -Wmissing-field-initializers for T foo = {} |
| 3234 |
+// which is zero initialization, but not explicit. We want to avoid |
| 3235 |
+// that. |
| 3236 |
+#if defined(__GNUC__) |
| 3237 |
+# pragma GCC diagnostic push |
| 3238 |
+# pragma GCC diagnostic ignored "-Wmissing-field-initializers" |
| 3239 |
+#endif |
| 3240 |
+ |
| 3241 |
+ static char* altStackMem = nullptr; |
| 3242 |
+ static std::size_t altStackSize = 0; |
| 3243 |
+ static stack_t oldSigStack{}; |
| 3244 |
+ static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)]{}; |
| 3245 |
+ |
| 3246 |
+ static void restorePreviousSignalHandlers() { |
| 3247 |
+ // We set signal handlers back to the previous ones. Hopefully |
| 3248 |
+ // nobody overwrote them in the meantime, and doesn't expect |
| 3249 |
+ // their signal handlers to live past ours given that they |
| 3250 |
+ // installed them after ours.. |
| 3251 |
+ for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { |
| 3252 |
+ sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); |
| 3253 |
+ } |
| 3254 |
+ // Return the old stack |
| 3255 |
+ sigaltstack(&oldSigStack, nullptr); |
| 3256 |
+ } |
| 3257 |
+ |
| 3258 |
+ static void handleSignal( int sig ) { |
| 3259 |
char const * name = "<unknown signal>"; |
| 3260 |
for (auto const& def : signalDefs) { |
| 3261 |
if (sig == def.id) { |
| 3262 |
@@ -10469,16 +10912,33 @@ namespace Catch { |
| 3263 |
break; |
| 3264 |
} |
| 3265 |
} |
| 3266 |
- reset(); |
| 3267 |
- reportFatal(name); |
| 3268 |
+ // We need to restore previous signal handlers and let them do |
| 3269 |
+ // their thing, so that the users can have the debugger break |
| 3270 |
+ // when a signal is raised, and so on. |
| 3271 |
+ restorePreviousSignalHandlers(); |
| 3272 |
+ reportFatal( name ); |
| 3273 |
raise( sig ); |
| 3274 |
} |
| 3275 |
|
| 3276 |
FatalConditionHandler::FatalConditionHandler() { |
| 3277 |
- isSet = true; |
| 3278 |
+ assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists"); |
| 3279 |
+ if (altStackSize == 0) { |
| 3280 |
+ altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), minStackSizeForErrors); |
| 3281 |
+ } |
| 3282 |
+ altStackMem = new char[altStackSize](); |
| 3283 |
+ } |
| 3284 |
+ |
| 3285 |
+ FatalConditionHandler::~FatalConditionHandler() { |
| 3286 |
+ delete[] altStackMem; |
| 3287 |
+ // We signal that another instance can be constructed by zeroing |
| 3288 |
+ // out the pointer. |
| 3289 |
+ altStackMem = nullptr; |
| 3290 |
+ } |
| 3291 |
+ |
| 3292 |
+ void FatalConditionHandler::engage_platform() { |
| 3293 |
stack_t sigStack; |
| 3294 |
sigStack.ss_sp = altStackMem; |
| 3295 |
- sigStack.ss_size = sigStackSize; |
| 3296 |
+ sigStack.ss_size = altStackSize; |
| 3297 |
sigStack.ss_flags = 0; |
| 3298 |
sigaltstack(&sigStack, &oldSigStack); |
| 3299 |
struct sigaction sa = { }; |
| 3300 |
@@ -10490,59 +10950,20 @@ namespace Catch { |
| 3301 |
} |
| 3302 |
} |
| 3303 |
|
| 3304 |
- FatalConditionHandler::~FatalConditionHandler() { |
| 3305 |
- reset(); |
| 3306 |
- } |
| 3307 |
- |
| 3308 |
- void FatalConditionHandler::reset() { |
| 3309 |
- if( isSet ) { |
| 3310 |
- // Set signals back to previous values -- hopefully nobody overwrote them in the meantime |
| 3311 |
- for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { |
| 3312 |
- sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); |
| 3313 |
- } |
| 3314 |
- // Return the old stack |
| 3315 |
- sigaltstack(&oldSigStack, nullptr); |
| 3316 |
- isSet = false; |
| 3317 |
- } |
| 3318 |
- } |
| 3319 |
- |
| 3320 |
- bool FatalConditionHandler::isSet = false; |
| 3321 |
- struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; |
| 3322 |
- stack_t FatalConditionHandler::oldSigStack = {}; |
| 3323 |
- char FatalConditionHandler::altStackMem[sigStackSize] = {}; |
| 3324 |
- |
| 3325 |
-} // namespace Catch |
| 3326 |
- |
| 3327 |
-#else |
| 3328 |
- |
| 3329 |
-namespace Catch { |
| 3330 |
- void FatalConditionHandler::reset() {} |
| 3331 |
-} |
| 3332 |
- |
| 3333 |
-#endif // signals/SEH handling |
| 3334 |
- |
| 3335 |
#if defined(__GNUC__) |
| 3336 |
# pragma GCC diagnostic pop |
| 3337 |
#endif |
| 3338 |
-// end catch_fatal_condition.cpp |
| 3339 |
-// start catch_generators.cpp |
| 3340 |
- |
| 3341 |
-// start catch_random_number_generator.h |
| 3342 |
- |
| 3343 |
-#include <algorithm> |
| 3344 |
-#include <random> |
| 3345 |
- |
| 3346 |
-namespace Catch { |
| 3347 |
|
| 3348 |
- struct IConfig; |
| 3349 |
+ void FatalConditionHandler::disengage_platform() { |
| 3350 |
+ restorePreviousSignalHandlers(); |
| 3351 |
+ } |
| 3352 |
|
| 3353 |
- std::mt19937& rng(); |
| 3354 |
- void seedRng( IConfig const& config ); |
| 3355 |
- unsigned int rngSeed(); |
| 3356 |
+} // end namespace Catch |
| 3357 |
|
| 3358 |
-} |
| 3359 |
+#endif // CATCH_CONFIG_POSIX_SIGNALS |
| 3360 |
+// end catch_fatal_condition.cpp |
| 3361 |
+// start catch_generators.cpp |
| 3362 |
|
| 3363 |
-// end catch_random_number_generator.h |
| 3364 |
#include <limits> |
| 3365 |
#include <set> |
| 3366 |
|
| 3367 |
@@ -10558,8 +10979,8 @@ namespace Generators { |
| 3368 |
|
| 3369 |
GeneratorUntypedBase::~GeneratorUntypedBase() {} |
| 3370 |
|
| 3371 |
- auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 3372 |
- return getResultCapture().acquireGeneratorTracker( lineInfo ); |
| 3373 |
+ auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 3374 |
+ return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); |
| 3375 |
} |
| 3376 |
|
| 3377 |
} // namespace Generators |
| 3378 |
@@ -10615,6 +11036,8 @@ namespace Catch { |
| 3379 |
|
| 3380 |
void noMatchingTestCases( std::string const& spec ) override; |
| 3381 |
|
| 3382 |
+ void reportInvalidArguments(std::string const&arg) override; |
| 3383 |
+ |
| 3384 |
static std::set<Verbosity> getSupportedVerbosities(); |
| 3385 |
|
| 3386 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 3387 |
@@ -10832,7 +11255,7 @@ namespace Catch { |
| 3388 |
namespace Catch { |
| 3389 |
|
| 3390 |
std::size_t listTests( Config const& config ) { |
| 3391 |
- TestSpec testSpec = config.testSpec(); |
| 3392 |
+ TestSpec const& testSpec = config.testSpec(); |
| 3393 |
if( config.hasTestFilters() ) |
| 3394 |
Catch::cout() << "Matching test cases:\n"; |
| 3395 |
else { |
| 3396 |
@@ -10866,7 +11289,7 @@ namespace Catch { |
| 3397 |
} |
| 3398 |
|
| 3399 |
std::size_t listTestsNamesOnly( Config const& config ) { |
| 3400 |
- TestSpec testSpec = config.testSpec(); |
| 3401 |
+ TestSpec const& testSpec = config.testSpec(); |
| 3402 |
std::size_t matchedTests = 0; |
| 3403 |
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); |
| 3404 |
for( auto const& testCaseInfo : matchedTestCases ) { |
| 3405 |
@@ -10904,7 +11327,7 @@ namespace Catch { |
| 3406 |
} |
| 3407 |
|
| 3408 |
std::size_t listTags( Config const& config ) { |
| 3409 |
- TestSpec testSpec = config.testSpec(); |
| 3410 |
+ TestSpec const& testSpec = config.testSpec(); |
| 3411 |
if( config.hasTestFilters() ) |
| 3412 |
Catch::cout() << "Tags for matching test cases:\n"; |
| 3413 |
else { |
| 3414 |
@@ -10998,6 +11421,29 @@ using Matchers::Impl::MatcherBase; |
| 3415 |
|
| 3416 |
} // namespace Catch |
| 3417 |
// end catch_matchers.cpp |
| 3418 |
+// start catch_matchers_exception.cpp |
| 3419 |
+ |
| 3420 |
+namespace Catch { |
| 3421 |
+namespace Matchers { |
| 3422 |
+namespace Exception { |
| 3423 |
+ |
| 3424 |
+bool ExceptionMessageMatcher::match(std::exception const& ex) const { |
| 3425 |
+ return ex.what() == m_message; |
| 3426 |
+} |
| 3427 |
+ |
| 3428 |
+std::string ExceptionMessageMatcher::describe() const { |
| 3429 |
+ return "exception message matches \"" + m_message + "\""; |
| 3430 |
+} |
| 3431 |
+ |
| 3432 |
+} |
| 3433 |
+Exception::ExceptionMessageMatcher Message(std::string const& message) { |
| 3434 |
+ return Exception::ExceptionMessageMatcher(message); |
| 3435 |
+} |
| 3436 |
+ |
| 3437 |
+// namespace Exception |
| 3438 |
+} // namespace Matchers |
| 3439 |
+} // namespace Catch |
| 3440 |
+// end catch_matchers_exception.cpp |
| 3441 |
// start catch_matchers_floating.cpp |
| 3442 |
|
| 3443 |
// start catch_polyfills.hpp |
| 3444 |
@@ -11026,85 +11472,101 @@ namespace Catch { |
| 3445 |
} // end namespace Catch |
| 3446 |
|
| 3447 |
// end catch_to_string.hpp |
| 3448 |
+#include <algorithm> |
| 3449 |
+#include <cmath> |
| 3450 |
#include <cstdlib> |
| 3451 |
#include <cstdint> |
| 3452 |
#include <cstring> |
| 3453 |
#include <sstream> |
| 3454 |
+#include <type_traits> |
| 3455 |
#include <iomanip> |
| 3456 |
#include <limits> |
| 3457 |
|
| 3458 |
namespace Catch { |
| 3459 |
-namespace Matchers { |
| 3460 |
-namespace Floating { |
| 3461 |
-enum class FloatingPointKind : uint8_t { |
| 3462 |
- Float, |
| 3463 |
- Double |
| 3464 |
-}; |
| 3465 |
-} |
| 3466 |
-} |
| 3467 |
-} |
| 3468 |
- |
| 3469 |
namespace { |
| 3470 |
|
| 3471 |
-template <typename T> |
| 3472 |
-struct Converter; |
| 3473 |
- |
| 3474 |
-template <> |
| 3475 |
-struct Converter<float> { |
| 3476 |
- static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); |
| 3477 |
- Converter(float f) { |
| 3478 |
+ int32_t convert(float f) { |
| 3479 |
+ static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); |
| 3480 |
+ int32_t i; |
| 3481 |
std::memcpy(&i, &f, sizeof(f)); |
| 3482 |
+ return i; |
| 3483 |
} |
| 3484 |
- int32_t i; |
| 3485 |
-}; |
| 3486 |
|
| 3487 |
-template <> |
| 3488 |
-struct Converter<double> { |
| 3489 |
- static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); |
| 3490 |
- Converter(double d) { |
| 3491 |
+ int64_t convert(double d) { |
| 3492 |
+ static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); |
| 3493 |
+ int64_t i; |
| 3494 |
std::memcpy(&i, &d, sizeof(d)); |
| 3495 |
+ return i; |
| 3496 |
} |
| 3497 |
- int64_t i; |
| 3498 |
-}; |
| 3499 |
|
| 3500 |
-template <typename T> |
| 3501 |
-auto convert(T t) -> Converter<T> { |
| 3502 |
- return Converter<T>(t); |
| 3503 |
-} |
| 3504 |
+ template <typename FP> |
| 3505 |
+ bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) { |
| 3506 |
+ // Comparison with NaN should always be false. |
| 3507 |
+ // This way we can rule it out before getting into the ugly details |
| 3508 |
+ if (Catch::isnan(lhs) || Catch::isnan(rhs)) { |
| 3509 |
+ return false; |
| 3510 |
+ } |
| 3511 |
|
| 3512 |
-template <typename FP> |
| 3513 |
-bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) { |
| 3514 |
- // Comparison with NaN should always be false. |
| 3515 |
- // This way we can rule it out before getting into the ugly details |
| 3516 |
- if (Catch::isnan(lhs) || Catch::isnan(rhs)) { |
| 3517 |
- return false; |
| 3518 |
+ auto lc = convert(lhs); |
| 3519 |
+ auto rc = convert(rhs); |
| 3520 |
+ |
| 3521 |
+ if ((lc < 0) != (rc < 0)) { |
| 3522 |
+ // Potentially we can have +0 and -0 |
| 3523 |
+ return lhs == rhs; |
| 3524 |
+ } |
| 3525 |
+ |
| 3526 |
+ // static cast as a workaround for IBM XLC |
| 3527 |
+ auto ulpDiff = std::abs(static_cast<FP>(lc - rc)); |
| 3528 |
+ return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff; |
| 3529 |
} |
| 3530 |
|
| 3531 |
- auto lc = convert(lhs); |
| 3532 |
- auto rc = convert(rhs); |
| 3533 |
+#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) |
| 3534 |
|
| 3535 |
- if ((lc.i < 0) != (rc.i < 0)) { |
| 3536 |
- // Potentially we can have +0 and -0 |
| 3537 |
- return lhs == rhs; |
| 3538 |
+ float nextafter(float x, float y) { |
| 3539 |
+ return ::nextafterf(x, y); |
| 3540 |
} |
| 3541 |
|
| 3542 |
- auto ulpDiff = std::abs(lc.i - rc.i); |
| 3543 |
- return ulpDiff <= maxUlpDiff; |
| 3544 |
-} |
| 3545 |
+ double nextafter(double x, double y) { |
| 3546 |
+ return ::nextafter(x, y); |
| 3547 |
+ } |
| 3548 |
+ |
| 3549 |
+#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ |
| 3550 |
|
| 3551 |
template <typename FP> |
| 3552 |
-FP step(FP start, FP direction, int steps) { |
| 3553 |
- for (int i = 0; i < steps; ++i) { |
| 3554 |
+FP step(FP start, FP direction, uint64_t steps) { |
| 3555 |
+ for (uint64_t i = 0; i < steps; ++i) { |
| 3556 |
+#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) |
| 3557 |
+ start = Catch::nextafter(start, direction); |
| 3558 |
+#else |
| 3559 |
start = std::nextafter(start, direction); |
| 3560 |
+#endif |
| 3561 |
} |
| 3562 |
return start; |
| 3563 |
} |
| 3564 |
|
| 3565 |
+// Performs equivalent check of std::fabs(lhs - rhs) <= margin |
| 3566 |
+// But without the subtraction to allow for INFINITY in comparison |
| 3567 |
+bool marginComparison(double lhs, double rhs, double margin) { |
| 3568 |
+ return (lhs + margin >= rhs) && (rhs + margin >= lhs); |
| 3569 |
+} |
| 3570 |
+ |
| 3571 |
+template <typename FloatingPoint> |
| 3572 |
+void write(std::ostream& out, FloatingPoint num) { |
| 3573 |
+ out << std::scientific |
| 3574 |
+ << std::setprecision(std::numeric_limits<FloatingPoint>::max_digits10 - 1) |
| 3575 |
+ << num; |
| 3576 |
+} |
| 3577 |
+ |
| 3578 |
} // end anonymous namespace |
| 3579 |
|
| 3580 |
-namespace Catch { |
| 3581 |
namespace Matchers { |
| 3582 |
namespace Floating { |
| 3583 |
+ |
| 3584 |
+ enum class FloatingPointKind : uint8_t { |
| 3585 |
+ Float, |
| 3586 |
+ Double |
| 3587 |
+ }; |
| 3588 |
+ |
| 3589 |
WithinAbsMatcher::WithinAbsMatcher(double target, double margin) |
| 3590 |
:m_target{ target }, m_margin{ margin } { |
| 3591 |
CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.' |
| 3592 |
@@ -11121,10 +11583,11 @@ namespace Floating { |
| 3593 |
return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); |
| 3594 |
} |
| 3595 |
|
| 3596 |
- WithinUlpsMatcher::WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType) |
| 3597 |
+ WithinUlpsMatcher::WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType) |
| 3598 |
:m_target{ target }, m_ulps{ ulps }, m_type{ baseType } { |
| 3599 |
- CATCH_ENFORCE(ulps >= 0, "Invalid ULP setting: " << ulps << '.' |
| 3600 |
- << " ULPs have to be non-negative."); |
| 3601 |
+ CATCH_ENFORCE(m_type == FloatingPointKind::Double |
| 3602 |
+ || m_ulps < (std::numeric_limits<uint32_t>::max)(), |
| 3603 |
+ "Provided ULP is impossibly large for a float comparison."); |
| 3604 |
} |
| 3605 |
|
| 3606 |
#if defined(__clang__) |
| 3607 |
@@ -11151,36 +11614,57 @@ namespace Floating { |
| 3608 |
std::string WithinUlpsMatcher::describe() const { |
| 3609 |
std::stringstream ret; |
| 3610 |
|
| 3611 |
- ret << "is within " << m_ulps << " ULPs of " << ::Catch::Detail::stringify(m_target); |
| 3612 |
+ ret << "is within " << m_ulps << " ULPs of "; |
| 3613 |
|
| 3614 |
if (m_type == FloatingPointKind::Float) { |
| 3615 |
+ write(ret, static_cast<float>(m_target)); |
| 3616 |
ret << 'f'; |
| 3617 |
+ } else { |
| 3618 |
+ write(ret, m_target); |
| 3619 |
} |
| 3620 |
|
| 3621 |
ret << " (["; |
| 3622 |
- ret << std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10); |
| 3623 |
if (m_type == FloatingPointKind::Double) { |
| 3624 |
- ret << step(m_target, static_cast<double>(-INFINITY), m_ulps) |
| 3625 |
- << ", " |
| 3626 |
- << step(m_target, static_cast<double>(INFINITY), m_ulps); |
| 3627 |
+ write(ret, step(m_target, static_cast<double>(-INFINITY), m_ulps)); |
| 3628 |
+ ret << ", "; |
| 3629 |
+ write(ret, step(m_target, static_cast<double>( INFINITY), m_ulps)); |
| 3630 |
} else { |
| 3631 |
- ret << step<float>(static_cast<float>(m_target), -INFINITY, m_ulps) |
| 3632 |
- << ", " |
| 3633 |
- << step<float>(static_cast<float>(m_target), INFINITY, m_ulps); |
| 3634 |
+ // We have to cast INFINITY to float because of MinGW, see #1782 |
| 3635 |
+ write(ret, step(static_cast<float>(m_target), static_cast<float>(-INFINITY), m_ulps)); |
| 3636 |
+ ret << ", "; |
| 3637 |
+ write(ret, step(static_cast<float>(m_target), static_cast<float>( INFINITY), m_ulps)); |
| 3638 |
} |
| 3639 |
ret << "])"; |
| 3640 |
|
| 3641 |
return ret.str(); |
| 3642 |
- //return "is within " + Catch::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); |
| 3643 |
+ } |
| 3644 |
+ |
| 3645 |
+ WithinRelMatcher::WithinRelMatcher(double target, double epsilon): |
| 3646 |
+ m_target(target), |
| 3647 |
+ m_epsilon(epsilon){ |
| 3648 |
+ CATCH_ENFORCE(m_epsilon >= 0., "Relative comparison with epsilon < 0 does not make sense."); |
| 3649 |
+ CATCH_ENFORCE(m_epsilon < 1., "Relative comparison with epsilon >= 1 does not make sense."); |
| 3650 |
+ } |
| 3651 |
+ |
| 3652 |
+ bool WithinRelMatcher::match(double const& matchee) const { |
| 3653 |
+ const auto relMargin = m_epsilon * (std::max)(std::fabs(matchee), std::fabs(m_target)); |
| 3654 |
+ return marginComparison(matchee, m_target, |
| 3655 |
+ std::isinf(relMargin)? 0 : relMargin); |
| 3656 |
+ } |
| 3657 |
+ |
| 3658 |
+ std::string WithinRelMatcher::describe() const { |
| 3659 |
+ Catch::ReusableStringStream sstr; |
| 3660 |
+ sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other"; |
| 3661 |
+ return sstr.str(); |
| 3662 |
} |
| 3663 |
|
| 3664 |
}// namespace Floating |
| 3665 |
|
| 3666 |
-Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) { |
| 3667 |
+Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff) { |
| 3668 |
return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double); |
| 3669 |
} |
| 3670 |
|
| 3671 |
-Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) { |
| 3672 |
+Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff) { |
| 3673 |
return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float); |
| 3674 |
} |
| 3675 |
|
| 3676 |
@@ -11188,9 +11672,24 @@ Floating::WithinAbsMatcher WithinAbs(dou |
| 3677 |
return Floating::WithinAbsMatcher(target, margin); |
| 3678 |
} |
| 3679 |
|
| 3680 |
+Floating::WithinRelMatcher WithinRel(double target, double eps) { |
| 3681 |
+ return Floating::WithinRelMatcher(target, eps); |
| 3682 |
+} |
| 3683 |
+ |
| 3684 |
+Floating::WithinRelMatcher WithinRel(double target) { |
| 3685 |
+ return Floating::WithinRelMatcher(target, std::numeric_limits<double>::epsilon() * 100); |
| 3686 |
+} |
| 3687 |
+ |
| 3688 |
+Floating::WithinRelMatcher WithinRel(float target, float eps) { |
| 3689 |
+ return Floating::WithinRelMatcher(target, eps); |
| 3690 |
+} |
| 3691 |
+ |
| 3692 |
+Floating::WithinRelMatcher WithinRel(float target) { |
| 3693 |
+ return Floating::WithinRelMatcher(target, std::numeric_limits<float>::epsilon() * 100); |
| 3694 |
+} |
| 3695 |
+ |
| 3696 |
} // namespace Matchers |
| 3697 |
} // namespace Catch |
| 3698 |
- |
| 3699 |
// end catch_matchers_floating.cpp |
| 3700 |
// start catch_matchers_generic.cpp |
| 3701 |
|
| 3702 |
@@ -11368,10 +11867,10 @@ namespace Catch { |
| 3703 |
|
| 3704 |
Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { |
| 3705 |
auto trimmed = [&] (size_t start, size_t end) { |
| 3706 |
- while (names[start] == ',' || isspace(names[start])) { |
| 3707 |
+ while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) { |
| 3708 |
++start; |
| 3709 |
} |
| 3710 |
- while (names[end] == ',' || isspace(names[end])) { |
| 3711 |
+ while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) { |
| 3712 |
--end; |
| 3713 |
} |
| 3714 |
return names.substr(start, end - start + 1); |
| 3715 |
@@ -11410,17 +11909,17 @@ namespace Catch { |
| 3716 |
pos = skipq(pos, c); |
| 3717 |
break; |
| 3718 |
case ',': |
| 3719 |
- if (start != pos && openings.size() == 0) { |
| 3720 |
+ if (start != pos && openings.empty()) { |
| 3721 |
m_messages.emplace_back(macroName, lineInfo, resultType); |
| 3722 |
- m_messages.back().message = trimmed(start, pos); |
| 3723 |
+ m_messages.back().message = static_cast<std::string>(trimmed(start, pos)); |
| 3724 |
m_messages.back().message += " := "; |
| 3725 |
start = pos; |
| 3726 |
} |
| 3727 |
} |
| 3728 |
} |
| 3729 |
- assert(openings.size() == 0 && "Mismatched openings"); |
| 3730 |
+ assert(openings.empty() && "Mismatched openings"); |
| 3731 |
m_messages.emplace_back(macroName, lineInfo, resultType); |
| 3732 |
- m_messages.back().message = trimmed(start, names.size() - 1); |
| 3733 |
+ m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1)); |
| 3734 |
m_messages.back().message += " := "; |
| 3735 |
} |
| 3736 |
Capturer::~Capturer() { |
| 3737 |
@@ -11606,7 +12105,7 @@ namespace Catch { |
| 3738 |
if (tmpnam_s(m_buffer)) { |
| 3739 |
CATCH_RUNTIME_ERROR("Could not get a temp filename"); |
| 3740 |
} |
| 3741 |
- if (fopen_s(&m_file, m_buffer, "w")) { |
| 3742 |
+ if (fopen_s(&m_file, m_buffer, "w+")) { |
| 3743 |
char buffer[100]; |
| 3744 |
if (strerror_s(buffer, errno)) { |
| 3745 |
CATCH_RUNTIME_ERROR("Could not translate errno to a string"); |
| 3746 |
@@ -11714,20 +12213,61 @@ namespace Catch { |
| 3747 |
|
| 3748 |
namespace Catch { |
| 3749 |
|
| 3750 |
- std::mt19937& rng() { |
| 3751 |
- static std::mt19937 s_rng; |
| 3752 |
- return s_rng; |
| 3753 |
+namespace { |
| 3754 |
+ |
| 3755 |
+#if defined(_MSC_VER) |
| 3756 |
+#pragma warning(push) |
| 3757 |
+#pragma warning(disable:4146) // we negate uint32 during the rotate |
| 3758 |
+#endif |
| 3759 |
+ // Safe rotr implementation thanks to John Regehr |
| 3760 |
+ uint32_t rotate_right(uint32_t val, uint32_t count) { |
| 3761 |
+ const uint32_t mask = 31; |
| 3762 |
+ count &= mask; |
| 3763 |
+ return (val >> count) | (val << (-count & mask)); |
| 3764 |
+ } |
| 3765 |
+ |
| 3766 |
+#if defined(_MSC_VER) |
| 3767 |
+#pragma warning(pop) |
| 3768 |
+#endif |
| 3769 |
+ |
| 3770 |
+} |
| 3771 |
+ |
| 3772 |
+ SimplePcg32::SimplePcg32(result_type seed_) { |
| 3773 |
+ seed(seed_); |
| 3774 |
} |
| 3775 |
|
| 3776 |
- void seedRng( IConfig const& config ) { |
| 3777 |
- if( config.rngSeed() != 0 ) { |
| 3778 |
- std::srand( config.rngSeed() ); |
| 3779 |
- rng().seed( config.rngSeed() ); |
| 3780 |
+ void SimplePcg32::seed(result_type seed_) { |
| 3781 |
+ m_state = 0; |
| 3782 |
+ (*this)(); |
| 3783 |
+ m_state += seed_; |
| 3784 |
+ (*this)(); |
| 3785 |
+ } |
| 3786 |
+ |
| 3787 |
+ void SimplePcg32::discard(uint64_t skip) { |
| 3788 |
+ // We could implement this to run in O(log n) steps, but this |
| 3789 |
+ // should suffice for our use case. |
| 3790 |
+ for (uint64_t s = 0; s < skip; ++s) { |
| 3791 |
+ static_cast<void>((*this)()); |
| 3792 |
} |
| 3793 |
} |
| 3794 |
|
| 3795 |
- unsigned int rngSeed() { |
| 3796 |
- return getCurrentContext().getConfig()->rngSeed(); |
| 3797 |
+ SimplePcg32::result_type SimplePcg32::operator()() { |
| 3798 |
+ // prepare the output value |
| 3799 |
+ const uint32_t xorshifted = static_cast<uint32_t>(((m_state >> 18u) ^ m_state) >> 27u); |
| 3800 |
+ const auto output = rotate_right(xorshifted, m_state >> 59u); |
| 3801 |
+ |
| 3802 |
+ // advance state |
| 3803 |
+ m_state = m_state * 6364136223846793005ULL + s_inc; |
| 3804 |
+ |
| 3805 |
+ return output; |
| 3806 |
+ } |
| 3807 |
+ |
| 3808 |
+ bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs) { |
| 3809 |
+ return lhs.m_state == rhs.m_state; |
| 3810 |
+ } |
| 3811 |
+ |
| 3812 |
+ bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs) { |
| 3813 |
+ return lhs.m_state != rhs.m_state; |
| 3814 |
} |
| 3815 |
} |
| 3816 |
// end catch_random_number_generator.cpp |
| 3817 |
@@ -11860,11 +12400,13 @@ namespace Catch { |
| 3818 |
namespace Catch { |
| 3819 |
|
| 3820 |
class StartupExceptionRegistry { |
| 3821 |
+#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 3822 |
public: |
| 3823 |
void add(std::exception_ptr const& exception) noexcept; |
| 3824 |
std::vector<std::exception_ptr> const& getExceptions() const noexcept; |
| 3825 |
private: |
| 3826 |
std::vector<std::exception_ptr> m_exceptions; |
| 3827 |
+#endif |
| 3828 |
}; |
| 3829 |
|
| 3830 |
} // end namespace Catch |
| 3831 |
@@ -11947,7 +12489,11 @@ namespace Catch { |
| 3832 |
m_tagAliasRegistry.add( alias, tag, lineInfo ); |
| 3833 |
} |
| 3834 |
void registerStartupException() noexcept override { |
| 3835 |
+#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 3836 |
m_exceptionRegistry.add(std::current_exception()); |
| 3837 |
+#else |
| 3838 |
+ CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); |
| 3839 |
+#endif |
| 3840 |
} |
| 3841 |
IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override { |
| 3842 |
return m_enumValuesRegistry; |
| 3843 |
@@ -12051,17 +12597,32 @@ namespace Catch { |
| 3844 |
std::shared_ptr<GeneratorTracker> tracker; |
| 3845 |
|
| 3846 |
ITracker& currentTracker = ctx.currentTracker(); |
| 3847 |
- if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { |
| 3848 |
+ // Under specific circumstances, the generator we want |
| 3849 |
+ // to acquire is also the current tracker. If this is |
| 3850 |
+ // the case, we have to avoid looking through current |
| 3851 |
+ // tracker's children, and instead return the current |
| 3852 |
+ // tracker. |
| 3853 |
+ // A case where this check is important is e.g. |
| 3854 |
+ // for (int i = 0; i < 5; ++i) { |
| 3855 |
+ // int n = GENERATE(1, 2); |
| 3856 |
+ // } |
| 3857 |
+ // |
| 3858 |
+ // without it, the code above creates 5 nested generators. |
| 3859 |
+ if (currentTracker.nameAndLocation() == nameAndLocation) { |
| 3860 |
+ auto thisTracker = currentTracker.parent().findChild(nameAndLocation); |
| 3861 |
+ assert(thisTracker); |
| 3862 |
+ assert(thisTracker->isGeneratorTracker()); |
| 3863 |
+ tracker = std::static_pointer_cast<GeneratorTracker>(thisTracker); |
| 3864 |
+ } else if ( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { |
| 3865 |
assert( childTracker ); |
| 3866 |
assert( childTracker->isGeneratorTracker() ); |
| 3867 |
tracker = std::static_pointer_cast<GeneratorTracker>( childTracker ); |
| 3868 |
- } |
| 3869 |
- else { |
| 3870 |
+ } else { |
| 3871 |
tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, ¤tTracker ); |
| 3872 |
currentTracker.addChild( tracker ); |
| 3873 |
} |
| 3874 |
|
| 3875 |
- if( !ctx.completedCycle() && !tracker->isComplete() ) { |
| 3876 |
+ if( !tracker->isComplete() ) { |
| 3877 |
tracker->open(); |
| 3878 |
} |
| 3879 |
|
| 3880 |
@@ -12075,8 +12636,68 @@ namespace Catch { |
| 3881 |
} |
| 3882 |
void close() override { |
| 3883 |
TrackerBase::close(); |
| 3884 |
- // Generator interface only finds out if it has another item on atual move |
| 3885 |
- if (m_runState == CompletedSuccessfully && m_generator->next()) { |
| 3886 |
+ // If a generator has a child (it is followed by a section) |
| 3887 |
+ // and none of its children have started, then we must wait |
| 3888 |
+ // until later to start consuming its values. |
| 3889 |
+ // This catches cases where `GENERATE` is placed between two |
| 3890 |
+ // `SECTION`s. |
| 3891 |
+ // **The check for m_children.empty cannot be removed**. |
| 3892 |
+ // doing so would break `GENERATE` _not_ followed by `SECTION`s. |
| 3893 |
+ const bool should_wait_for_child = [&]() { |
| 3894 |
+ // No children -> nobody to wait for |
| 3895 |
+ if ( m_children.empty() ) { |
| 3896 |
+ return false; |
| 3897 |
+ } |
| 3898 |
+ // If at least one child started executing, don't wait |
| 3899 |
+ if ( std::find_if( |
| 3900 |
+ m_children.begin(), |
| 3901 |
+ m_children.end(), |
| 3902 |
+ []( TestCaseTracking::ITrackerPtr tracker ) { |
| 3903 |
+ return tracker->hasStarted(); |
| 3904 |
+ } ) != m_children.end() ) { |
| 3905 |
+ return false; |
| 3906 |
+ } |
| 3907 |
+ |
| 3908 |
+ // No children have started. We need to check if they _can_ |
| 3909 |
+ // start, and thus we should wait for them, or they cannot |
| 3910 |
+ // start (due to filters), and we shouldn't wait for them |
| 3911 |
+ auto* parent = m_parent; |
| 3912 |
+ // This is safe: there is always at least one section |
| 3913 |
+ // tracker in a test case tracking tree |
| 3914 |
+ while ( !parent->isSectionTracker() ) { |
| 3915 |
+ parent = &( parent->parent() ); |
| 3916 |
+ } |
| 3917 |
+ assert( parent && |
| 3918 |
+ "Missing root (test case) level section" ); |
| 3919 |
+ |
| 3920 |
+ auto const& parentSection = |
| 3921 |
+ static_cast<SectionTracker&>( *parent ); |
| 3922 |
+ auto const& filters = parentSection.getFilters(); |
| 3923 |
+ // No filters -> no restrictions on running sections |
| 3924 |
+ if ( filters.empty() ) { |
| 3925 |
+ return true; |
| 3926 |
+ } |
| 3927 |
+ |
| 3928 |
+ for ( auto const& child : m_children ) { |
| 3929 |
+ if ( child->isSectionTracker() && |
| 3930 |
+ std::find( filters.begin(), |
| 3931 |
+ filters.end(), |
| 3932 |
+ static_cast<SectionTracker&>( *child ) |
| 3933 |
+ .trimmedName() ) != |
| 3934 |
+ filters.end() ) { |
| 3935 |
+ return true; |
| 3936 |
+ } |
| 3937 |
+ } |
| 3938 |
+ return false; |
| 3939 |
+ }(); |
| 3940 |
+ |
| 3941 |
+ // This check is a bit tricky, because m_generator->next() |
| 3942 |
+ // has a side-effect, where it consumes generator's current |
| 3943 |
+ // value, but we do not want to invoke the side-effect if |
| 3944 |
+ // this generator is still waiting for any child to start. |
| 3945 |
+ if ( should_wait_for_child || |
| 3946 |
+ ( m_runState == CompletedSuccessfully && |
| 3947 |
+ m_generator->next() ) ) { |
| 3948 |
m_children.clear(); |
| 3949 |
m_runState = Executing; |
| 3950 |
} |
| 3951 |
@@ -12212,10 +12833,10 @@ namespace Catch { |
| 3952 |
|
| 3953 |
return true; |
| 3954 |
} |
| 3955 |
- auto RunContext::acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 3956 |
+ auto RunContext::acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 3957 |
using namespace Generators; |
| 3958 |
- GeneratorTracker& tracker = GeneratorTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( "generator", lineInfo ) ); |
| 3959 |
- assert( tracker.isOpen() ); |
| 3960 |
+ GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, |
| 3961 |
+ TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) ); |
| 3962 |
m_lastAssertionInfo.lineInfo = lineInfo; |
| 3963 |
return tracker; |
| 3964 |
} |
| 3965 |
@@ -12258,17 +12879,17 @@ namespace Catch { |
| 3966 |
|
| 3967 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 3968 |
void RunContext::benchmarkPreparing(std::string const& name) { |
| 3969 |
- m_reporter->benchmarkPreparing(name); |
| 3970 |
- } |
| 3971 |
+ m_reporter->benchmarkPreparing(name); |
| 3972 |
+ } |
| 3973 |
void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { |
| 3974 |
m_reporter->benchmarkStarting( info ); |
| 3975 |
} |
| 3976 |
void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) { |
| 3977 |
m_reporter->benchmarkEnded( stats ); |
| 3978 |
} |
| 3979 |
- void RunContext::benchmarkFailed(std::string const & error) { |
| 3980 |
- m_reporter->benchmarkFailed(error); |
| 3981 |
- } |
| 3982 |
+ void RunContext::benchmarkFailed(std::string const & error) { |
| 3983 |
+ m_reporter->benchmarkFailed(error); |
| 3984 |
+ } |
| 3985 |
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING |
| 3986 |
|
| 3987 |
void RunContext::pushScopedMessage(MessageInfo const & message) { |
| 3988 |
@@ -12304,7 +12925,7 @@ namespace Catch { |
| 3989 |
// Don't rebuild the result -- the stringification itself can cause more fatal errors |
| 3990 |
// Instead, fake a result data. |
| 3991 |
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); |
| 3992 |
- tempResult.message = message; |
| 3993 |
+ tempResult.message = static_cast<std::string>(message); |
| 3994 |
AssertionResult result(m_lastAssertionInfo, tempResult); |
| 3995 |
|
| 3996 |
assertionEnded(result); |
| 3997 |
@@ -12402,9 +13023,8 @@ namespace Catch { |
| 3998 |
} |
| 3999 |
|
| 4000 |
void RunContext::invokeActiveTestCase() { |
| 4001 |
- FatalConditionHandler fatalConditionHandler; // Handle signals |
| 4002 |
+ FatalConditionHandlerGuard _(&m_fatalConditionhandler); |
| 4003 |
m_activeTestCase->invoke(); |
| 4004 |
- fatalConditionHandler.reset(); |
| 4005 |
} |
| 4006 |
|
| 4007 |
void RunContext::handleUnfinishedSections() { |
| 4008 |
@@ -12467,7 +13087,7 @@ namespace Catch { |
| 4009 |
m_lastAssertionInfo = info; |
| 4010 |
|
| 4011 |
AssertionResultData data( resultType, LazyExpression( false ) ); |
| 4012 |
- data.message = message; |
| 4013 |
+ data.message = static_cast<std::string>(message); |
| 4014 |
AssertionResult assertionResult{ m_lastAssertionInfo, data }; |
| 4015 |
assertionEnded( assertionResult ); |
| 4016 |
if( !assertionResult.isOk() ) |
| 4017 |
@@ -12530,6 +13150,18 @@ namespace Catch { |
| 4018 |
else |
| 4019 |
CATCH_INTERNAL_ERROR("No result capture instance"); |
| 4020 |
} |
| 4021 |
+ |
| 4022 |
+ void seedRng(IConfig const& config) { |
| 4023 |
+ if (config.rngSeed() != 0) { |
| 4024 |
+ std::srand(config.rngSeed()); |
| 4025 |
+ rng().seed(config.rngSeed()); |
| 4026 |
+ } |
| 4027 |
+ } |
| 4028 |
+ |
| 4029 |
+ unsigned int rngSeed() { |
| 4030 |
+ return getCurrentContext().getConfig()->rngSeed(); |
| 4031 |
+ } |
| 4032 |
+ |
| 4033 |
} |
| 4034 |
// end catch_run_context.cpp |
| 4035 |
// start catch_section.cpp |
| 4036 |
@@ -12701,8 +13333,9 @@ namespace Catch { |
| 4037 |
{ |
| 4038 |
auto const& allTestCases = getAllTestCasesSorted(*m_config); |
| 4039 |
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config); |
| 4040 |
+ auto const& invalidArgs = m_config->testSpec().getInvalidArgs(); |
| 4041 |
|
| 4042 |
- if (m_matches.empty()) { |
| 4043 |
+ if (m_matches.empty() && invalidArgs.empty()) { |
| 4044 |
for (auto const& test : allTestCases) |
| 4045 |
if (!test.isHidden()) |
| 4046 |
m_tests.emplace(&test); |
| 4047 |
@@ -12713,6 +13346,7 @@ namespace Catch { |
| 4048 |
} |
| 4049 |
|
| 4050 |
Totals execute() { |
| 4051 |
+ auto const& invalidArgs = m_config->testSpec().getInvalidArgs(); |
| 4052 |
Totals totals; |
| 4053 |
m_context.testGroupStarting(m_config->name(), 1, 1); |
| 4054 |
for (auto const& testCase : m_tests) { |
| 4055 |
@@ -12728,6 +13362,12 @@ namespace Catch { |
| 4056 |
totals.error = -1; |
| 4057 |
} |
| 4058 |
} |
| 4059 |
+ |
| 4060 |
+ if (!invalidArgs.empty()) { |
| 4061 |
+ for (auto const& invalidArg: invalidArgs) |
| 4062 |
+ m_context.reporter().reportInvalidArguments(invalidArg); |
| 4063 |
+ } |
| 4064 |
+ |
| 4065 |
m_context.testGroupEnded(m_config->name(), totals, 1, 1); |
| 4066 |
return totals; |
| 4067 |
} |
| 4068 |
@@ -12752,6 +13392,10 @@ namespace Catch { |
| 4069 |
filename.erase(0, lastSlash); |
| 4070 |
filename[0] = '#'; |
| 4071 |
} |
| 4072 |
+ else |
| 4073 |
+ { |
| 4074 |
+ filename.insert(0, "#"); |
| 4075 |
+ } |
| 4076 |
|
| 4077 |
auto lastDot = filename.find_last_of('.'); |
| 4078 |
if (lastDot != std::string::npos) { |
| 4079 |
@@ -12808,7 +13452,7 @@ namespace Catch { |
| 4080 |
} |
| 4081 |
void Session::libIdentify() { |
| 4082 |
Catch::cout() |
| 4083 |
- << std::left << std::setw(16) << "description: " << "A Catch test executable\n" |
| 4084 |
+ << std::left << std::setw(16) << "description: " << "A Catch2 test executable\n" |
| 4085 |
<< std::left << std::setw(16) << "category: " << "testframework\n" |
| 4086 |
<< std::left << std::setw(16) << "framework: " << "Catch Test\n" |
| 4087 |
<< std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; |
| 4088 |
@@ -12845,11 +13489,11 @@ namespace Catch { |
| 4089 |
char **utf8Argv = new char *[ argc ]; |
| 4090 |
|
| 4091 |
for ( int i = 0; i < argc; ++i ) { |
| 4092 |
- int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); |
| 4093 |
+ int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, nullptr, 0, nullptr, nullptr ); |
| 4094 |
|
| 4095 |
utf8Argv[ i ] = new char[ bufSize ]; |
| 4096 |
|
| 4097 |
- WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); |
| 4098 |
+ WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, nullptr, nullptr ); |
| 4099 |
} |
| 4100 |
|
| 4101 |
int returnCode = applyCommandLine( argc, utf8Argv ); |
| 4102 |
@@ -12969,6 +13613,7 @@ namespace Catch { |
| 4103 |
// end catch_singletons.cpp |
| 4104 |
// start catch_startup_exception_registry.cpp |
| 4105 |
|
| 4106 |
+#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 4107 |
namespace Catch { |
| 4108 |
void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { |
| 4109 |
CATCH_TRY { |
| 4110 |
@@ -12984,6 +13629,7 @@ void StartupExceptionRegistry::add( std: |
| 4111 |
} |
| 4112 |
|
| 4113 |
} // end namespace Catch |
| 4114 |
+#endif |
| 4115 |
// end catch_startup_exception_registry.cpp |
| 4116 |
// start catch_stream.cpp |
| 4117 |
|
| 4118 |
@@ -13168,7 +13814,7 @@ namespace Catch { |
| 4119 |
|
| 4120 |
namespace { |
| 4121 |
char toLowerCh(char c) { |
| 4122 |
- return static_cast<char>( std::tolower( c ) ); |
| 4123 |
+ return static_cast<char>( std::tolower( static_cast<unsigned char>(c) ) ); |
| 4124 |
} |
| 4125 |
} |
| 4126 |
|
| 4127 |
@@ -13203,6 +13849,18 @@ namespace Catch { |
| 4128 |
return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); |
| 4129 |
} |
| 4130 |
|
| 4131 |
+ StringRef trim(StringRef ref) { |
| 4132 |
+ const auto is_ws = [](char c) { |
| 4133 |
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r'; |
| 4134 |
+ }; |
| 4135 |
+ size_t real_begin = 0; |
| 4136 |
+ while (real_begin < ref.size() && is_ws(ref[real_begin])) { ++real_begin; } |
| 4137 |
+ size_t real_end = ref.size(); |
| 4138 |
+ while (real_end > real_begin && is_ws(ref[real_end - 1])) { --real_end; } |
| 4139 |
+ |
| 4140 |
+ return ref.substr(real_begin, real_end - real_begin); |
| 4141 |
+ } |
| 4142 |
+ |
| 4143 |
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { |
| 4144 |
bool replaced = false; |
| 4145 |
std::size_t i = str.find( replaceThis ); |
| 4146 |
@@ -13248,124 +13906,46 @@ namespace Catch { |
| 4147 |
// end catch_string_manip.cpp |
| 4148 |
// start catch_stringref.cpp |
| 4149 |
|
| 4150 |
-#if defined(__clang__) |
| 4151 |
-# pragma clang diagnostic push |
| 4152 |
-# pragma clang diagnostic ignored "-Wexit-time-destructors" |
| 4153 |
-#endif |
| 4154 |
- |
| 4155 |
+#include <algorithm> |
| 4156 |
#include <ostream> |
| 4157 |
#include <cstring> |
| 4158 |
#include <cstdint> |
| 4159 |
|
| 4160 |
-namespace { |
| 4161 |
- const uint32_t byte_2_lead = 0xC0; |
| 4162 |
- const uint32_t byte_3_lead = 0xE0; |
| 4163 |
- const uint32_t byte_4_lead = 0xF0; |
| 4164 |
-} |
| 4165 |
- |
| 4166 |
namespace Catch { |
| 4167 |
StringRef::StringRef( char const* rawChars ) noexcept |
| 4168 |
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) ) |
| 4169 |
{} |
| 4170 |
|
| 4171 |
- StringRef::operator std::string() const { |
| 4172 |
- return std::string( m_start, m_size ); |
| 4173 |
- } |
| 4174 |
- |
| 4175 |
- void StringRef::swap( StringRef& other ) noexcept { |
| 4176 |
- std::swap( m_start, other.m_start ); |
| 4177 |
- std::swap( m_size, other.m_size ); |
| 4178 |
- std::swap( m_data, other.m_data ); |
| 4179 |
- } |
| 4180 |
- |
| 4181 |
auto StringRef::c_str() const -> char const* { |
| 4182 |
- if( !isSubstring() ) |
| 4183 |
- return m_start; |
| 4184 |
- |
| 4185 |
- const_cast<StringRef *>( this )->takeOwnership(); |
| 4186 |
- return m_data; |
| 4187 |
- } |
| 4188 |
- auto StringRef::currentData() const noexcept -> char const* { |
| 4189 |
+ CATCH_ENFORCE(isNullTerminated(), "Called StringRef::c_str() on a non-null-terminated instance"); |
| 4190 |
return m_start; |
| 4191 |
} |
| 4192 |
- |
| 4193 |
- auto StringRef::isOwned() const noexcept -> bool { |
| 4194 |
- return m_data != nullptr; |
| 4195 |
- } |
| 4196 |
- auto StringRef::isSubstring() const noexcept -> bool { |
| 4197 |
- return m_start[m_size] != '\0'; |
| 4198 |
+ auto StringRef::data() const noexcept -> char const* { |
| 4199 |
+ return m_start; |
| 4200 |
} |
| 4201 |
|
| 4202 |
- void StringRef::takeOwnership() { |
| 4203 |
- if( !isOwned() ) { |
| 4204 |
- m_data = new char[m_size+1]; |
| 4205 |
- memcpy( m_data, m_start, m_size ); |
| 4206 |
- m_data[m_size] = '\0'; |
| 4207 |
- } |
| 4208 |
- } |
| 4209 |
auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef { |
| 4210 |
- if( start < m_size ) |
| 4211 |
- return StringRef( m_start+start, size ); |
| 4212 |
- else |
| 4213 |
+ if (start < m_size) { |
| 4214 |
+ return StringRef(m_start + start, (std::min)(m_size - start, size)); |
| 4215 |
+ } else { |
| 4216 |
return StringRef(); |
| 4217 |
- } |
| 4218 |
- auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { |
| 4219 |
- return |
| 4220 |
- size() == other.size() && |
| 4221 |
- (std::strncmp( m_start, other.m_start, size() ) == 0); |
| 4222 |
- } |
| 4223 |
- auto StringRef::operator != ( StringRef const& other ) const noexcept -> bool { |
| 4224 |
- return !operator==( other ); |
| 4225 |
- } |
| 4226 |
- |
| 4227 |
- auto StringRef::operator[](size_type index) const noexcept -> char { |
| 4228 |
- return m_start[index]; |
| 4229 |
- } |
| 4230 |
- |
| 4231 |
- auto StringRef::numberOfCharacters() const noexcept -> size_type { |
| 4232 |
- size_type noChars = m_size; |
| 4233 |
- // Make adjustments for uft encodings |
| 4234 |
- for( size_type i=0; i < m_size; ++i ) { |
| 4235 |
- char c = m_start[i]; |
| 4236 |
- if( ( c & byte_2_lead ) == byte_2_lead ) { |
| 4237 |
- noChars--; |
| 4238 |
- if (( c & byte_3_lead ) == byte_3_lead ) |
| 4239 |
- noChars--; |
| 4240 |
- if( ( c & byte_4_lead ) == byte_4_lead ) |
| 4241 |
- noChars--; |
| 4242 |
- } |
| 4243 |
} |
| 4244 |
- return noChars; |
| 4245 |
- } |
| 4246 |
- |
| 4247 |
- auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { |
| 4248 |
- std::string str; |
| 4249 |
- str.reserve( lhs.size() + rhs.size() ); |
| 4250 |
- str += lhs; |
| 4251 |
- str += rhs; |
| 4252 |
- return str; |
| 4253 |
} |
| 4254 |
- auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string { |
| 4255 |
- return std::string( lhs ) + std::string( rhs ); |
| 4256 |
- } |
| 4257 |
- auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string { |
| 4258 |
- return std::string( lhs ) + std::string( rhs ); |
| 4259 |
+ auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { |
| 4260 |
+ return m_size == other.m_size |
| 4261 |
+ && (std::memcmp( m_start, other.m_start, m_size ) == 0); |
| 4262 |
} |
| 4263 |
|
| 4264 |
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { |
| 4265 |
- return os.write(str.currentData(), str.size()); |
| 4266 |
+ return os.write(str.data(), str.size()); |
| 4267 |
} |
| 4268 |
|
| 4269 |
auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& { |
| 4270 |
- lhs.append(rhs.currentData(), rhs.size()); |
| 4271 |
+ lhs.append(rhs.data(), rhs.size()); |
| 4272 |
return lhs; |
| 4273 |
} |
| 4274 |
|
| 4275 |
} // namespace Catch |
| 4276 |
- |
| 4277 |
-#if defined(__clang__) |
| 4278 |
-# pragma clang diagnostic pop |
| 4279 |
-#endif |
| 4280 |
// end catch_stringref.cpp |
| 4281 |
// start catch_tag_alias.cpp |
| 4282 |
|
| 4283 |
@@ -13484,8 +14064,7 @@ namespace Catch { |
| 4284 |
std::vector<std::string> tags; |
| 4285 |
std::string desc, tag; |
| 4286 |
bool inTag = false; |
| 4287 |
- std::string _descOrTags = nameAndTags.tags; |
| 4288 |
- for (char c : _descOrTags) { |
| 4289 |
+ for (char c : nameAndTags.tags) { |
| 4290 |
if( !inTag ) { |
| 4291 |
if( c == '[' ) |
| 4292 |
inTag = true; |
| 4293 |
@@ -13515,10 +14094,11 @@ namespace Catch { |
| 4294 |
} |
| 4295 |
} |
| 4296 |
if( isHidden ) { |
| 4297 |
- tags.push_back( "." ); |
| 4298 |
+ // Add all "hidden" tags to make them behave identically |
| 4299 |
+ tags.insert( tags.end(), { ".", "!hide" } ); |
| 4300 |
} |
| 4301 |
|
| 4302 |
- TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo ); |
| 4303 |
+ TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, desc, tags, _lineInfo ); |
| 4304 |
return TestCase( _testCase, std::move(info) ); |
| 4305 |
} |
| 4306 |
|
| 4307 |
@@ -13610,27 +14190,81 @@ namespace Catch { |
| 4308 |
// end catch_test_case_info.cpp |
| 4309 |
// start catch_test_case_registry_impl.cpp |
| 4310 |
|
| 4311 |
+#include <algorithm> |
| 4312 |
#include <sstream> |
| 4313 |
|
| 4314 |
namespace Catch { |
| 4315 |
|
| 4316 |
- std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { |
| 4317 |
+ namespace { |
| 4318 |
+ struct TestHasher { |
| 4319 |
+ using hash_t = uint64_t; |
| 4320 |
|
| 4321 |
- std::vector<TestCase> sorted = unsortedTestCases; |
| 4322 |
+ explicit TestHasher( hash_t hashSuffix ): |
| 4323 |
+ m_hashSuffix{ hashSuffix } {} |
| 4324 |
|
| 4325 |
+ uint32_t operator()( TestCase const& t ) const { |
| 4326 |
+ // FNV-1a hash with multiplication fold. |
| 4327 |
+ const hash_t prime = 1099511628211u; |
| 4328 |
+ hash_t hash = 14695981039346656037u; |
| 4329 |
+ for ( const char c : t.name ) { |
| 4330 |
+ hash ^= c; |
| 4331 |
+ hash *= prime; |
| 4332 |
+ } |
| 4333 |
+ hash ^= m_hashSuffix; |
| 4334 |
+ hash *= prime; |
| 4335 |
+ const uint32_t low{ static_cast<uint32_t>( hash ) }; |
| 4336 |
+ const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) }; |
| 4337 |
+ return low * high; |
| 4338 |
+ } |
| 4339 |
+ |
| 4340 |
+ private: |
| 4341 |
+ hash_t m_hashSuffix; |
| 4342 |
+ }; |
| 4343 |
+ } // end unnamed namespace |
| 4344 |
+ |
| 4345 |
+ std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { |
| 4346 |
switch( config.runOrder() ) { |
| 4347 |
- case RunTests::InLexicographicalOrder: |
| 4348 |
- std::sort( sorted.begin(), sorted.end() ); |
| 4349 |
- break; |
| 4350 |
- case RunTests::InRandomOrder: |
| 4351 |
- seedRng( config ); |
| 4352 |
- std::shuffle( sorted.begin(), sorted.end(), rng() ); |
| 4353 |
- break; |
| 4354 |
case RunTests::InDeclarationOrder: |
| 4355 |
// already in declaration order |
| 4356 |
break; |
| 4357 |
+ |
| 4358 |
+ case RunTests::InLexicographicalOrder: { |
| 4359 |
+ std::vector<TestCase> sorted = unsortedTestCases; |
| 4360 |
+ std::sort( sorted.begin(), sorted.end() ); |
| 4361 |
+ return sorted; |
| 4362 |
+ } |
| 4363 |
+ |
| 4364 |
+ case RunTests::InRandomOrder: { |
| 4365 |
+ seedRng( config ); |
| 4366 |
+ TestHasher h{ config.rngSeed() }; |
| 4367 |
+ |
| 4368 |
+ using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>; |
| 4369 |
+ std::vector<hashedTest> indexed_tests; |
| 4370 |
+ indexed_tests.reserve( unsortedTestCases.size() ); |
| 4371 |
+ |
| 4372 |
+ for (auto const& testCase : unsortedTestCases) { |
| 4373 |
+ indexed_tests.emplace_back(h(testCase), &testCase); |
| 4374 |
+ } |
| 4375 |
+ |
| 4376 |
+ std::sort(indexed_tests.begin(), indexed_tests.end(), |
| 4377 |
+ [](hashedTest const& lhs, hashedTest const& rhs) { |
| 4378 |
+ if (lhs.first == rhs.first) { |
| 4379 |
+ return lhs.second->name < rhs.second->name; |
| 4380 |
+ } |
| 4381 |
+ return lhs.first < rhs.first; |
| 4382 |
+ }); |
| 4383 |
+ |
| 4384 |
+ std::vector<TestCase> sorted; |
| 4385 |
+ sorted.reserve( indexed_tests.size() ); |
| 4386 |
+ |
| 4387 |
+ for (auto const& hashed : indexed_tests) { |
| 4388 |
+ sorted.emplace_back(*hashed.second); |
| 4389 |
+ } |
| 4390 |
+ |
| 4391 |
+ return sorted; |
| 4392 |
+ } |
| 4393 |
} |
| 4394 |
- return sorted; |
| 4395 |
+ return unsortedTestCases; |
| 4396 |
} |
| 4397 |
|
| 4398 |
bool isThrowSafe( TestCase const& testCase, IConfig const& config ) { |
| 4399 |
@@ -13699,7 +14333,7 @@ namespace Catch { |
| 4400 |
} |
| 4401 |
|
| 4402 |
std::string extractClassName( StringRef const& classOrQualifiedMethodName ) { |
| 4403 |
- std::string className = classOrQualifiedMethodName; |
| 4404 |
+ std::string className(classOrQualifiedMethodName); |
| 4405 |
if( startsWith( className, '&' ) ) |
| 4406 |
{ |
| 4407 |
std::size_t lastColons = className.rfind( "::" ); |
| 4408 |
@@ -13767,15 +14401,12 @@ namespace TestCaseTracking { |
| 4409 |
m_currentTracker = tracker; |
| 4410 |
} |
| 4411 |
|
| 4412 |
- TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) |
| 4413 |
- : m_nameAndLocation( nameAndLocation ), |
| 4414 |
+ TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ): |
| 4415 |
+ ITracker(nameAndLocation), |
| 4416 |
m_ctx( ctx ), |
| 4417 |
m_parent( parent ) |
| 4418 |
{} |
| 4419 |
|
| 4420 |
- NameAndLocation const& TrackerBase::nameAndLocation() const { |
| 4421 |
- return m_nameAndLocation; |
| 4422 |
- } |
| 4423 |
bool TrackerBase::isComplete() const { |
| 4424 |
return m_runState == CompletedSuccessfully || m_runState == Failed; |
| 4425 |
} |
| 4426 |
@@ -13876,7 +14507,8 @@ namespace TestCaseTracking { |
| 4427 |
} |
| 4428 |
|
| 4429 |
SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) |
| 4430 |
- : TrackerBase( nameAndLocation, ctx, parent ) |
| 4431 |
+ : TrackerBase( nameAndLocation, ctx, parent ), |
| 4432 |
+ m_trimmed_name(trim(nameAndLocation.name)) |
| 4433 |
{ |
| 4434 |
if( parent ) { |
| 4435 |
while( !parent->isSectionTracker() ) |
| 4436 |
@@ -13890,12 +14522,12 @@ namespace TestCaseTracking { |
| 4437 |
bool SectionTracker::isComplete() const { |
| 4438 |
bool complete = true; |
| 4439 |
|
| 4440 |
- if ((m_filters.empty() || m_filters[0] == "") || |
| 4441 |
- std::find(m_filters.begin(), m_filters.end(), |
| 4442 |
- m_nameAndLocation.name) != m_filters.end()) |
| 4443 |
+ if (m_filters.empty() |
| 4444 |
+ || m_filters[0] == "" |
| 4445 |
+ || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { |
| 4446 |
complete = TrackerBase::isComplete(); |
| 4447 |
+ } |
| 4448 |
return complete; |
| 4449 |
- |
| 4450 |
} |
| 4451 |
|
| 4452 |
bool SectionTracker::isSectionTracker() const { return true; } |
| 4453 |
@@ -13919,20 +14551,29 @@ namespace TestCaseTracking { |
| 4454 |
} |
| 4455 |
|
| 4456 |
void SectionTracker::tryOpen() { |
| 4457 |
- if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) |
| 4458 |
+ if( !isComplete() ) |
| 4459 |
open(); |
| 4460 |
} |
| 4461 |
|
| 4462 |
void SectionTracker::addInitialFilters( std::vector<std::string> const& filters ) { |
| 4463 |
if( !filters.empty() ) { |
| 4464 |
- m_filters.push_back(""); // Root - should never be consulted |
| 4465 |
- m_filters.push_back(""); // Test Case - not a section filter |
| 4466 |
+ m_filters.reserve( m_filters.size() + filters.size() + 2 ); |
| 4467 |
+ m_filters.emplace_back(""); // Root - should never be consulted |
| 4468 |
+ m_filters.emplace_back(""); // Test Case - not a section filter |
| 4469 |
m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); |
| 4470 |
} |
| 4471 |
} |
| 4472 |
void SectionTracker::addNextFilters( std::vector<std::string> const& filters ) { |
| 4473 |
if( filters.size() > 1 ) |
| 4474 |
- m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); |
| 4475 |
+ m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() ); |
| 4476 |
+ } |
| 4477 |
+ |
| 4478 |
+ std::vector<std::string> const& SectionTracker::getFilters() const { |
| 4479 |
+ return m_filters; |
| 4480 |
+ } |
| 4481 |
+ |
| 4482 |
+ std::string const& SectionTracker::trimmedName() const { |
| 4483 |
+ return m_trimmed_name; |
| 4484 |
} |
| 4485 |
|
| 4486 |
} // namespace TestCaseTracking |
| 4487 |
@@ -14000,7 +14641,7 @@ namespace Catch { |
| 4488 |
{} |
| 4489 |
|
| 4490 |
bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const { |
| 4491 |
- return m_wildcardPattern.matches( toLower( testCase.name ) ); |
| 4492 |
+ return m_wildcardPattern.matches( testCase.name ); |
| 4493 |
} |
| 4494 |
|
| 4495 |
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString ) |
| 4496 |
@@ -14055,6 +14696,10 @@ namespace Catch { |
| 4497 |
return matches; |
| 4498 |
} |
| 4499 |
|
| 4500 |
+ const TestSpec::vectorStrings& TestSpec::getInvalidArgs() const{ |
| 4501 |
+ return (m_invalidArgs); |
| 4502 |
+ } |
| 4503 |
+ |
| 4504 |
} |
| 4505 |
// end catch_test_spec.cpp |
| 4506 |
// start catch_test_spec_parser.cpp |
| 4507 |
@@ -14070,8 +14715,14 @@ namespace Catch { |
| 4508 |
m_escapeChars.clear(); |
| 4509 |
m_substring.reserve(m_arg.size()); |
| 4510 |
m_patternName.reserve(m_arg.size()); |
| 4511 |
+ m_realPatternPos = 0; |
| 4512 |
+ |
| 4513 |
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) |
| 4514 |
- visitChar( m_arg[m_pos] ); |
| 4515 |
+ //if visitChar fails |
| 4516 |
+ if( !visitChar( m_arg[m_pos] ) ){ |
| 4517 |
+ m_testSpec.m_invalidArgs.push_back(arg); |
| 4518 |
+ break; |
| 4519 |
+ } |
| 4520 |
endMode(); |
| 4521 |
return *this; |
| 4522 |
} |
| 4523 |
@@ -14079,35 +14730,41 @@ namespace Catch { |
| 4524 |
addFilter(); |
| 4525 |
return m_testSpec; |
| 4526 |
} |
| 4527 |
- void TestSpecParser::visitChar( char c ) { |
| 4528 |
- if( c == ',' ) { |
| 4529 |
- endMode(); |
| 4530 |
- addFilter(); |
| 4531 |
- return; |
| 4532 |
+ bool TestSpecParser::visitChar( char c ) { |
| 4533 |
+ if( (m_mode != EscapedName) && (c == '\\') ) { |
| 4534 |
+ escape(); |
| 4535 |
+ addCharToPattern(c); |
| 4536 |
+ return true; |
| 4537 |
+ }else if((m_mode != EscapedName) && (c == ',') ) { |
| 4538 |
+ return separate(); |
| 4539 |
} |
| 4540 |
|
| 4541 |
switch( m_mode ) { |
| 4542 |
case None: |
| 4543 |
if( processNoneChar( c ) ) |
| 4544 |
- return; |
| 4545 |
+ return true; |
| 4546 |
break; |
| 4547 |
case Name: |
| 4548 |
processNameChar( c ); |
| 4549 |
break; |
| 4550 |
case EscapedName: |
| 4551 |
endMode(); |
| 4552 |
- break; |
| 4553 |
+ addCharToPattern(c); |
| 4554 |
+ return true; |
| 4555 |
default: |
| 4556 |
case Tag: |
| 4557 |
case QuotedName: |
| 4558 |
if( processOtherChar( c ) ) |
| 4559 |
- return; |
| 4560 |
+ return true; |
| 4561 |
break; |
| 4562 |
} |
| 4563 |
|
| 4564 |
m_substring += c; |
| 4565 |
- if( !isControlChar( c ) ) |
| 4566 |
+ if( !isControlChar( c ) ) { |
| 4567 |
m_patternName += c; |
| 4568 |
+ m_realPatternPos++; |
| 4569 |
+ } |
| 4570 |
+ return true; |
| 4571 |
} |
| 4572 |
// Two of the processing methods return true to signal the caller to return |
| 4573 |
// without adding the given character to the current pattern strings |
| 4574 |
@@ -14124,9 +14781,6 @@ namespace Catch { |
| 4575 |
case '"': |
| 4576 |
startNewMode( QuotedName ); |
| 4577 |
return false; |
| 4578 |
- case '\\': |
| 4579 |
- escape(); |
| 4580 |
- return true; |
| 4581 |
default: |
| 4582 |
startNewMode( Name ); |
| 4583 |
return false; |
| 4584 |
@@ -14155,19 +14809,21 @@ namespace Catch { |
| 4585 |
switch( m_mode ) { |
| 4586 |
case Name: |
| 4587 |
case QuotedName: |
| 4588 |
- return addPattern<TestSpec::NamePattern>(); |
| 4589 |
+ return addNamePattern(); |
| 4590 |
case Tag: |
| 4591 |
- return addPattern<TestSpec::TagPattern>(); |
| 4592 |
+ return addTagPattern(); |
| 4593 |
case EscapedName: |
| 4594 |
- return startNewMode( Name ); |
| 4595 |
+ revertBackToLastMode(); |
| 4596 |
+ return; |
| 4597 |
case None: |
| 4598 |
default: |
| 4599 |
return startNewMode( None ); |
| 4600 |
} |
| 4601 |
} |
| 4602 |
void TestSpecParser::escape() { |
| 4603 |
+ saveLastMode(); |
| 4604 |
m_mode = EscapedName; |
| 4605 |
- m_escapeChars.push_back( m_pos ); |
| 4606 |
+ m_escapeChars.push_back(m_realPatternPos); |
| 4607 |
} |
| 4608 |
bool TestSpecParser::isControlChar( char c ) const { |
| 4609 |
switch( m_mode ) { |
| 4610 |
@@ -14193,6 +14849,86 @@ namespace Catch { |
| 4611 |
} |
| 4612 |
} |
| 4613 |
|
| 4614 |
+ void TestSpecParser::saveLastMode() { |
| 4615 |
+ lastMode = m_mode; |
| 4616 |
+ } |
| 4617 |
+ |
| 4618 |
+ void TestSpecParser::revertBackToLastMode() { |
| 4619 |
+ m_mode = lastMode; |
| 4620 |
+ } |
| 4621 |
+ |
| 4622 |
+ bool TestSpecParser::separate() { |
| 4623 |
+ if( (m_mode==QuotedName) || (m_mode==Tag) ){ |
| 4624 |
+ //invalid argument, signal failure to previous scope. |
| 4625 |
+ m_mode = None; |
| 4626 |
+ m_pos = m_arg.size(); |
| 4627 |
+ m_substring.clear(); |
| 4628 |
+ m_patternName.clear(); |
| 4629 |
+ m_realPatternPos = 0; |
| 4630 |
+ return false; |
| 4631 |
+ } |
| 4632 |
+ endMode(); |
| 4633 |
+ addFilter(); |
| 4634 |
+ return true; //success |
| 4635 |
+ } |
| 4636 |
+ |
| 4637 |
+ std::string TestSpecParser::preprocessPattern() { |
| 4638 |
+ std::string token = m_patternName; |
| 4639 |
+ for (std::size_t i = 0; i < m_escapeChars.size(); ++i) |
| 4640 |
+ token = token.substr(0, m_escapeChars[i] - i) + token.substr(m_escapeChars[i] - i + 1); |
| 4641 |
+ m_escapeChars.clear(); |
| 4642 |
+ if (startsWith(token, "exclude:")) { |
| 4643 |
+ m_exclusion = true; |
| 4644 |
+ token = token.substr(8); |
| 4645 |
+ } |
| 4646 |
+ |
| 4647 |
+ m_patternName.clear(); |
| 4648 |
+ m_realPatternPos = 0; |
| 4649 |
+ |
| 4650 |
+ return token; |
| 4651 |
+ } |
| 4652 |
+ |
| 4653 |
+ void TestSpecParser::addNamePattern() { |
| 4654 |
+ auto token = preprocessPattern(); |
| 4655 |
+ |
| 4656 |
+ if (!token.empty()) { |
| 4657 |
+ TestSpec::PatternPtr pattern = std::make_shared<TestSpec::NamePattern>(token, m_substring); |
| 4658 |
+ if (m_exclusion) |
| 4659 |
+ pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); |
| 4660 |
+ m_currentFilter.m_patterns.push_back(pattern); |
| 4661 |
+ } |
| 4662 |
+ m_substring.clear(); |
| 4663 |
+ m_exclusion = false; |
| 4664 |
+ m_mode = None; |
| 4665 |
+ } |
| 4666 |
+ |
| 4667 |
+ void TestSpecParser::addTagPattern() { |
| 4668 |
+ auto token = preprocessPattern(); |
| 4669 |
+ |
| 4670 |
+ if (!token.empty()) { |
| 4671 |
+ // If the tag pattern is the "hide and tag" shorthand (e.g. [.foo]) |
| 4672 |
+ // we have to create a separate hide tag and shorten the real one |
| 4673 |
+ if (token.size() > 1 && token[0] == '.') { |
| 4674 |
+ token.erase(token.begin()); |
| 4675 |
+ TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(".", m_substring); |
| 4676 |
+ if (m_exclusion) { |
| 4677 |
+ pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); |
| 4678 |
+ } |
| 4679 |
+ m_currentFilter.m_patterns.push_back(pattern); |
| 4680 |
+ } |
| 4681 |
+ |
| 4682 |
+ TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(token, m_substring); |
| 4683 |
+ |
| 4684 |
+ if (m_exclusion) { |
| 4685 |
+ pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); |
| 4686 |
+ } |
| 4687 |
+ m_currentFilter.m_patterns.push_back(pattern); |
| 4688 |
+ } |
| 4689 |
+ m_substring.clear(); |
| 4690 |
+ m_exclusion = false; |
| 4691 |
+ m_mode = None; |
| 4692 |
+ } |
| 4693 |
+ |
| 4694 |
TestSpec parseTestSpec( std::string const& arg ) { |
| 4695 |
return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); |
| 4696 |
} |
| 4697 |
@@ -14294,13 +15030,11 @@ namespace Detail { |
| 4698 |
enum Arch { Big, Little }; |
| 4699 |
|
| 4700 |
static Arch which() { |
| 4701 |
- union _{ |
| 4702 |
- int asInt; |
| 4703 |
- char asChar[sizeof (int)]; |
| 4704 |
- } u; |
| 4705 |
- |
| 4706 |
- u.asInt = 1; |
| 4707 |
- return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; |
| 4708 |
+ int one = 1; |
| 4709 |
+ // If the lowest byte we read is non-zero, we can assume |
| 4710 |
+ // that little endian format is used. |
| 4711 |
+ auto value = *reinterpret_cast<char*>(&one); |
| 4712 |
+ return value ? Little : Big; |
| 4713 |
} |
| 4714 |
}; |
| 4715 |
} |
| 4716 |
@@ -14576,11 +15310,48 @@ namespace Catch { |
| 4717 |
// end catch_totals.cpp |
| 4718 |
// start catch_uncaught_exceptions.cpp |
| 4719 |
|
| 4720 |
+// start catch_config_uncaught_exceptions.hpp |
| 4721 |
+ |
| 4722 |
+// Copyright Catch2 Authors |
| 4723 |
+// Distributed under the Boost Software License, Version 1.0. |
| 4724 |
+// (See accompanying file LICENSE_1_0.txt or copy at |
| 4725 |
+// https://www.boost.org/LICENSE_1_0.txt) |
| 4726 |
+ |
| 4727 |
+// SPDX-License-Identifier: BSL-1.0 |
| 4728 |
+ |
| 4729 |
+#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP |
| 4730 |
+#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP |
| 4731 |
+ |
| 4732 |
+#if defined(_MSC_VER) |
| 4733 |
+# if _MSC_VER >= 1900 // Visual Studio 2015 or newer |
| 4734 |
+# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 4735 |
+# endif |
| 4736 |
+#endif |
| 4737 |
+ |
| 4738 |
+#include <exception> |
| 4739 |
+ |
| 4740 |
+#if defined(__cpp_lib_uncaught_exceptions) \ |
| 4741 |
+ && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
| 4742 |
+ |
| 4743 |
+# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 4744 |
+#endif // __cpp_lib_uncaught_exceptions |
| 4745 |
+ |
| 4746 |
+#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ |
| 4747 |
+ && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ |
| 4748 |
+ && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
| 4749 |
+ |
| 4750 |
+# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 4751 |
+#endif |
| 4752 |
+ |
| 4753 |
+#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP |
| 4754 |
+// end catch_config_uncaught_exceptions.hpp |
| 4755 |
#include <exception> |
| 4756 |
|
| 4757 |
namespace Catch { |
| 4758 |
bool uncaught_exceptions() { |
| 4759 |
-#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
| 4760 |
+#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 4761 |
+ return false; |
| 4762 |
+#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
| 4763 |
return std::uncaught_exceptions() > 0; |
| 4764 |
#else |
| 4765 |
return std::uncaught_exception(); |
| 4766 |
@@ -14620,7 +15391,7 @@ namespace Catch { |
| 4767 |
} |
| 4768 |
|
| 4769 |
Version const& libraryVersion() { |
| 4770 |
- static Version version( 2, 9, 2, "", 0 ); |
| 4771 |
+ static Version version( 2, 13, 9, "", 0 ); |
| 4772 |
return version; |
| 4773 |
} |
| 4774 |
|
| 4775 |
@@ -14628,14 +15399,12 @@ namespace Catch { |
| 4776 |
// end catch_version.cpp |
| 4777 |
// start catch_wildcard_pattern.cpp |
| 4778 |
|
| 4779 |
-#include <sstream> |
| 4780 |
- |
| 4781 |
namespace Catch { |
| 4782 |
|
| 4783 |
WildcardPattern::WildcardPattern( std::string const& pattern, |
| 4784 |
CaseSensitive::Choice caseSensitivity ) |
| 4785 |
: m_caseSensitivity( caseSensitivity ), |
| 4786 |
- m_pattern( adjustCase( pattern ) ) |
| 4787 |
+ m_pattern( normaliseString( pattern ) ) |
| 4788 |
{ |
| 4789 |
if( startsWith( m_pattern, '*' ) ) { |
| 4790 |
m_pattern = m_pattern.substr( 1 ); |
| 4791 |
@@ -14650,28 +15419,27 @@ namespace Catch { |
| 4792 |
bool WildcardPattern::matches( std::string const& str ) const { |
| 4793 |
switch( m_wildcard ) { |
| 4794 |
case NoWildcard: |
| 4795 |
- return m_pattern == adjustCase( str ); |
| 4796 |
+ return m_pattern == normaliseString( str ); |
| 4797 |
case WildcardAtStart: |
| 4798 |
- return endsWith( adjustCase( str ), m_pattern ); |
| 4799 |
+ return endsWith( normaliseString( str ), m_pattern ); |
| 4800 |
case WildcardAtEnd: |
| 4801 |
- return startsWith( adjustCase( str ), m_pattern ); |
| 4802 |
+ return startsWith( normaliseString( str ), m_pattern ); |
| 4803 |
case WildcardAtBothEnds: |
| 4804 |
- return contains( adjustCase( str ), m_pattern ); |
| 4805 |
+ return contains( normaliseString( str ), m_pattern ); |
| 4806 |
default: |
| 4807 |
CATCH_INTERNAL_ERROR( "Unknown enum" ); |
| 4808 |
} |
| 4809 |
} |
| 4810 |
|
| 4811 |
- std::string WildcardPattern::adjustCase( std::string const& str ) const { |
| 4812 |
- return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; |
| 4813 |
+ std::string WildcardPattern::normaliseString( std::string const& str ) const { |
| 4814 |
+ return trim( m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str ); |
| 4815 |
} |
| 4816 |
} |
| 4817 |
// end catch_wildcard_pattern.cpp |
| 4818 |
// start catch_xmlwriter.cpp |
| 4819 |
|
| 4820 |
#include <iomanip> |
| 4821 |
- |
| 4822 |
-using uchar = unsigned char; |
| 4823 |
+#include <type_traits> |
| 4824 |
|
| 4825 |
namespace Catch { |
| 4826 |
|
| 4827 |
@@ -14711,8 +15479,30 @@ namespace { |
| 4828 |
os.flags(f); |
| 4829 |
} |
| 4830 |
|
| 4831 |
+ bool shouldNewline(XmlFormatting fmt) { |
| 4832 |
+ return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Newline)); |
| 4833 |
+ } |
| 4834 |
+ |
| 4835 |
+ bool shouldIndent(XmlFormatting fmt) { |
| 4836 |
+ return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Indent)); |
| 4837 |
+ } |
| 4838 |
+ |
| 4839 |
} // anonymous namespace |
| 4840 |
|
| 4841 |
+ XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) { |
| 4842 |
+ return static_cast<XmlFormatting>( |
| 4843 |
+ static_cast<std::underlying_type<XmlFormatting>::type>(lhs) | |
| 4844 |
+ static_cast<std::underlying_type<XmlFormatting>::type>(rhs) |
| 4845 |
+ ); |
| 4846 |
+ } |
| 4847 |
+ |
| 4848 |
+ XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) { |
| 4849 |
+ return static_cast<XmlFormatting>( |
| 4850 |
+ static_cast<std::underlying_type<XmlFormatting>::type>(lhs) & |
| 4851 |
+ static_cast<std::underlying_type<XmlFormatting>::type>(rhs) |
| 4852 |
+ ); |
| 4853 |
+ } |
| 4854 |
+ |
| 4855 |
XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) |
| 4856 |
: m_str( str ), |
| 4857 |
m_forWhat( forWhat ) |
| 4858 |
@@ -14723,7 +15513,7 @@ namespace { |
| 4859 |
// (see: http://www.w3.org/TR/xml/#syntax) |
| 4860 |
|
| 4861 |
for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { |
| 4862 |
- uchar c = m_str[idx]; |
| 4863 |
+ unsigned char c = m_str[idx]; |
| 4864 |
switch (c) { |
| 4865 |
case '<': os << "<"; break; |
| 4866 |
case '&': os << "&"; break; |
| 4867 |
@@ -14783,7 +15573,7 @@ namespace { |
| 4868 |
bool valid = true; |
| 4869 |
uint32_t value = headerValue(c); |
| 4870 |
for (std::size_t n = 1; n < encBytes; ++n) { |
| 4871 |
- uchar nc = m_str[idx + n]; |
| 4872 |
+ unsigned char nc = m_str[idx + n]; |
| 4873 |
valid &= ((nc & 0xC0) == 0x80); |
| 4874 |
value = (value << 6) | (nc & 0x3F); |
| 4875 |
} |
| 4876 |
@@ -14817,13 +15607,17 @@ namespace { |
| 4877 |
return os; |
| 4878 |
} |
| 4879 |
|
| 4880 |
- XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) |
| 4881 |
- : m_writer( writer ) |
| 4882 |
+ XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer, XmlFormatting fmt ) |
| 4883 |
+ : m_writer( writer ), |
| 4884 |
+ m_fmt(fmt) |
| 4885 |
{} |
| 4886 |
|
| 4887 |
XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept |
| 4888 |
- : m_writer( other.m_writer ){ |
| 4889 |
+ : m_writer( other.m_writer ), |
| 4890 |
+ m_fmt(other.m_fmt) |
| 4891 |
+ { |
| 4892 |
other.m_writer = nullptr; |
| 4893 |
+ other.m_fmt = XmlFormatting::None; |
| 4894 |
} |
| 4895 |
XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { |
| 4896 |
if ( m_writer ) { |
| 4897 |
@@ -14831,16 +15625,19 @@ namespace { |
| 4898 |
} |
| 4899 |
m_writer = other.m_writer; |
| 4900 |
other.m_writer = nullptr; |
| 4901 |
+ m_fmt = other.m_fmt; |
| 4902 |
+ other.m_fmt = XmlFormatting::None; |
| 4903 |
return *this; |
| 4904 |
} |
| 4905 |
|
| 4906 |
XmlWriter::ScopedElement::~ScopedElement() { |
| 4907 |
- if( m_writer ) |
| 4908 |
- m_writer->endElement(); |
| 4909 |
+ if (m_writer) { |
| 4910 |
+ m_writer->endElement(m_fmt); |
| 4911 |
+ } |
| 4912 |
} |
| 4913 |
|
| 4914 |
- XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { |
| 4915 |
- m_writer->writeText( text, indent ); |
| 4916 |
+ XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, XmlFormatting fmt ) { |
| 4917 |
+ m_writer->writeText( text, fmt ); |
| 4918 |
return *this; |
| 4919 |
} |
| 4920 |
|
| 4921 |
@@ -14850,37 +15647,47 @@ namespace { |
| 4922 |
} |
| 4923 |
|
| 4924 |
XmlWriter::~XmlWriter() { |
| 4925 |
- while( !m_tags.empty() ) |
| 4926 |
+ while (!m_tags.empty()) { |
| 4927 |
endElement(); |
| 4928 |
+ } |
| 4929 |
+ newlineIfNecessary(); |
| 4930 |
} |
| 4931 |
|
| 4932 |
- XmlWriter& XmlWriter::startElement( std::string const& name ) { |
| 4933 |
+ XmlWriter& XmlWriter::startElement( std::string const& name, XmlFormatting fmt ) { |
| 4934 |
ensureTagClosed(); |
| 4935 |
newlineIfNecessary(); |
| 4936 |
- m_os << m_indent << '<' << name; |
| 4937 |
+ if (shouldIndent(fmt)) { |
| 4938 |
+ m_os << m_indent; |
| 4939 |
+ m_indent += " "; |
| 4940 |
+ } |
| 4941 |
+ m_os << '<' << name; |
| 4942 |
m_tags.push_back( name ); |
| 4943 |
- m_indent += " "; |
| 4944 |
m_tagIsOpen = true; |
| 4945 |
+ applyFormatting(fmt); |
| 4946 |
return *this; |
| 4947 |
} |
| 4948 |
|
| 4949 |
- XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { |
| 4950 |
- ScopedElement scoped( this ); |
| 4951 |
- startElement( name ); |
| 4952 |
+ XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name, XmlFormatting fmt ) { |
| 4953 |
+ ScopedElement scoped( this, fmt ); |
| 4954 |
+ startElement( name, fmt ); |
| 4955 |
return scoped; |
| 4956 |
} |
| 4957 |
|
| 4958 |
- XmlWriter& XmlWriter::endElement() { |
| 4959 |
- newlineIfNecessary(); |
| 4960 |
- m_indent = m_indent.substr( 0, m_indent.size()-2 ); |
| 4961 |
+ XmlWriter& XmlWriter::endElement(XmlFormatting fmt) { |
| 4962 |
+ m_indent = m_indent.substr(0, m_indent.size() - 2); |
| 4963 |
+ |
| 4964 |
if( m_tagIsOpen ) { |
| 4965 |
m_os << "/>"; |
| 4966 |
m_tagIsOpen = false; |
| 4967 |
+ } else { |
| 4968 |
+ newlineIfNecessary(); |
| 4969 |
+ if (shouldIndent(fmt)) { |
| 4970 |
+ m_os << m_indent; |
| 4971 |
+ } |
| 4972 |
+ m_os << "</" << m_tags.back() << ">"; |
| 4973 |
} |
| 4974 |
- else { |
| 4975 |
- m_os << m_indent << "</" << m_tags.back() << ">"; |
| 4976 |
- } |
| 4977 |
- m_os << std::endl; |
| 4978 |
+ m_os << std::flush; |
| 4979 |
+ applyFormatting(fmt); |
| 4980 |
m_tags.pop_back(); |
| 4981 |
return *this; |
| 4982 |
} |
| 4983 |
@@ -14896,22 +15703,26 @@ namespace { |
| 4984 |
return *this; |
| 4985 |
} |
| 4986 |
|
| 4987 |
- XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { |
| 4988 |
+ XmlWriter& XmlWriter::writeText( std::string const& text, XmlFormatting fmt) { |
| 4989 |
if( !text.empty() ){ |
| 4990 |
bool tagWasOpen = m_tagIsOpen; |
| 4991 |
ensureTagClosed(); |
| 4992 |
- if( tagWasOpen && indent ) |
| 4993 |
+ if (tagWasOpen && shouldIndent(fmt)) { |
| 4994 |
m_os << m_indent; |
| 4995 |
+ } |
| 4996 |
m_os << XmlEncode( text ); |
| 4997 |
- m_needsNewline = true; |
| 4998 |
+ applyFormatting(fmt); |
| 4999 |
} |
| 5000 |
return *this; |
| 5001 |
} |
| 5002 |
|
| 5003 |
- XmlWriter& XmlWriter::writeComment( std::string const& text ) { |
| 5004 |
+ XmlWriter& XmlWriter::writeComment( std::string const& text, XmlFormatting fmt) { |
| 5005 |
ensureTagClosed(); |
| 5006 |
- m_os << m_indent << "<!--" << text << "-->"; |
| 5007 |
- m_needsNewline = true; |
| 5008 |
+ if (shouldIndent(fmt)) { |
| 5009 |
+ m_os << m_indent; |
| 5010 |
+ } |
| 5011 |
+ m_os << "<!--" << text << "-->"; |
| 5012 |
+ applyFormatting(fmt); |
| 5013 |
return *this; |
| 5014 |
} |
| 5015 |
|
| 5016 |
@@ -14927,11 +15738,16 @@ namespace { |
| 5017 |
|
| 5018 |
void XmlWriter::ensureTagClosed() { |
| 5019 |
if( m_tagIsOpen ) { |
| 5020 |
- m_os << ">" << std::endl; |
| 5021 |
+ m_os << '>' << std::flush; |
| 5022 |
+ newlineIfNecessary(); |
| 5023 |
m_tagIsOpen = false; |
| 5024 |
} |
| 5025 |
} |
| 5026 |
|
| 5027 |
+ void XmlWriter::applyFormatting(XmlFormatting fmt) { |
| 5028 |
+ m_needsNewline = shouldNewline(fmt); |
| 5029 |
+ } |
| 5030 |
+ |
| 5031 |
void XmlWriter::writeDeclaration() { |
| 5032 |
m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
| 5033 |
} |
| 5034 |
@@ -14977,6 +15793,17 @@ namespace Catch { |
| 5035 |
return std::string(buffer); |
| 5036 |
} |
| 5037 |
|
| 5038 |
+ bool shouldShowDuration( IConfig const& config, double duration ) { |
| 5039 |
+ if ( config.showDurations() == ShowDurations::Always ) { |
| 5040 |
+ return true; |
| 5041 |
+ } |
| 5042 |
+ if ( config.showDurations() == ShowDurations::Never ) { |
| 5043 |
+ return false; |
| 5044 |
+ } |
| 5045 |
+ const double min = config.minDuration(); |
| 5046 |
+ return min >= 0 && duration >= min; |
| 5047 |
+ } |
| 5048 |
+ |
| 5049 |
std::string serializeFilters( std::vector<std::string> const& container ) { |
| 5050 |
ReusableStringStream oss; |
| 5051 |
bool first = true; |
| 5052 |
@@ -15243,10 +16070,6 @@ private: |
| 5053 |
return "Reports test results on a single line, suitable for IDEs"; |
| 5054 |
} |
| 5055 |
|
| 5056 |
- ReporterPreferences CompactReporter::getPreferences() const { |
| 5057 |
- return m_reporterPrefs; |
| 5058 |
- } |
| 5059 |
- |
| 5060 |
void CompactReporter::noMatchingTestCases( std::string const& spec ) { |
| 5061 |
stream << "No test cases matched '" << spec << '\'' << std::endl; |
| 5062 |
} |
| 5063 |
@@ -15273,8 +16096,9 @@ private: |
| 5064 |
} |
| 5065 |
|
| 5066 |
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { |
| 5067 |
- if (m_config->showDurations() == ShowDurations::Always) { |
| 5068 |
- stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; |
| 5069 |
+ double dur = _sectionStats.durationInSeconds; |
| 5070 |
+ if ( shouldShowDuration( *m_config, dur ) ) { |
| 5071 |
+ stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << std::endl; |
| 5072 |
} |
| 5073 |
} |
| 5074 |
|
| 5075 |
@@ -15486,15 +16310,11 @@ class Duration { |
| 5076 |
static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond; |
| 5077 |
static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond; |
| 5078 |
|
| 5079 |
- uint64_t m_inNanoseconds; |
| 5080 |
+ double m_inNanoseconds; |
| 5081 |
Unit m_units; |
| 5082 |
|
| 5083 |
public: |
| 5084 |
- explicit Duration(double inNanoseconds, Unit units = Unit::Auto) |
| 5085 |
- : Duration(static_cast<uint64_t>(inNanoseconds), units) { |
| 5086 |
- } |
| 5087 |
- |
| 5088 |
- explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto) |
| 5089 |
+ explicit Duration(double inNanoseconds, Unit units = Unit::Auto) |
| 5090 |
: m_inNanoseconds(inNanoseconds), |
| 5091 |
m_units(units) { |
| 5092 |
if (m_units == Unit::Auto) { |
| 5093 |
@@ -15523,7 +16343,7 @@ public: |
| 5094 |
case Unit::Minutes: |
| 5095 |
return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute); |
| 5096 |
default: |
| 5097 |
- return static_cast<double>(m_inNanoseconds); |
| 5098 |
+ return m_inNanoseconds; |
| 5099 |
} |
| 5100 |
} |
| 5101 |
auto unitsAsString() const -> std::string { |
| 5102 |
@@ -15544,7 +16364,7 @@ public: |
| 5103 |
|
| 5104 |
} |
| 5105 |
friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& { |
| 5106 |
- return os << duration.value() << " " << duration.unitsAsString(); |
| 5107 |
+ return os << duration.value() << ' ' << duration.unitsAsString(); |
| 5108 |
} |
| 5109 |
}; |
| 5110 |
} // end anon namespace |
| 5111 |
@@ -15576,9 +16396,9 @@ public: |
| 5112 |
headerCols += Column(info.name).width(static_cast<std::size_t>(info.width - 2)); |
| 5113 |
headerCols += spacer; |
| 5114 |
} |
| 5115 |
- m_os << headerCols << "\n"; |
| 5116 |
+ m_os << headerCols << '\n'; |
| 5117 |
|
| 5118 |
- m_os << Catch::getLineOfChars<'-'>() << "\n"; |
| 5119 |
+ m_os << Catch::getLineOfChars<'-'>() << '\n'; |
| 5120 |
} |
| 5121 |
} |
| 5122 |
void close() { |
| 5123 |
@@ -15597,30 +16417,29 @@ public: |
| 5124 |
|
| 5125 |
friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { |
| 5126 |
auto colStr = tp.m_oss.str(); |
| 5127 |
- // This takes account of utf8 encodings |
| 5128 |
- auto strSize = Catch::StringRef(colStr).numberOfCharacters(); |
| 5129 |
+ const auto strSize = colStr.size(); |
| 5130 |
tp.m_oss.str(""); |
| 5131 |
tp.open(); |
| 5132 |
if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) { |
| 5133 |
tp.m_currentColumn = -1; |
| 5134 |
- tp.m_os << "\n"; |
| 5135 |
+ tp.m_os << '\n'; |
| 5136 |
} |
| 5137 |
tp.m_currentColumn++; |
| 5138 |
|
| 5139 |
auto colInfo = tp.m_columnInfos[tp.m_currentColumn]; |
| 5140 |
- auto padding = (strSize + 2 < static_cast<std::size_t>(colInfo.width)) |
| 5141 |
- ? std::string(colInfo.width - (strSize + 2), ' ') |
| 5142 |
+ auto padding = (strSize + 1 < static_cast<std::size_t>(colInfo.width)) |
| 5143 |
+ ? std::string(colInfo.width - (strSize + 1), ' ') |
| 5144 |
: std::string(); |
| 5145 |
if (colInfo.justification == ColumnInfo::Left) |
| 5146 |
- tp.m_os << colStr << padding << " "; |
| 5147 |
+ tp.m_os << colStr << padding << ' '; |
| 5148 |
else |
| 5149 |
- tp.m_os << padding << colStr << " "; |
| 5150 |
+ tp.m_os << padding << colStr << ' '; |
| 5151 |
return tp; |
| 5152 |
} |
| 5153 |
|
| 5154 |
friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { |
| 5155 |
if (tp.m_currentColumn > 0) { |
| 5156 |
- tp.m_os << "\n"; |
| 5157 |
+ tp.m_os << '\n'; |
| 5158 |
tp.m_currentColumn = -1; |
| 5159 |
} |
| 5160 |
return tp; |
| 5161 |
@@ -15630,12 +16449,26 @@ public: |
| 5162 |
ConsoleReporter::ConsoleReporter(ReporterConfig const& config) |
| 5163 |
: StreamingReporterBase(config), |
| 5164 |
m_tablePrinter(new TablePrinter(config.stream(), |
| 5165 |
- { |
| 5166 |
- { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left }, |
| 5167 |
- { "samples mean std dev", 14, ColumnInfo::Right }, |
| 5168 |
- { "iterations low mean low std dev", 14, ColumnInfo::Right }, |
| 5169 |
- { "estimated high mean high std dev", 14, ColumnInfo::Right } |
| 5170 |
- })) {} |
| 5171 |
+ [&config]() -> std::vector<ColumnInfo> { |
| 5172 |
+ if (config.fullConfig()->benchmarkNoAnalysis()) |
| 5173 |
+ { |
| 5174 |
+ return{ |
| 5175 |
+ { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, |
| 5176 |
+ { " samples", 14, ColumnInfo::Right }, |
| 5177 |
+ { " iterations", 14, ColumnInfo::Right }, |
| 5178 |
+ { " mean", 14, ColumnInfo::Right } |
| 5179 |
+ }; |
| 5180 |
+ } |
| 5181 |
+ else |
| 5182 |
+ { |
| 5183 |
+ return{ |
| 5184 |
+ { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, |
| 5185 |
+ { "samples mean std dev", 14, ColumnInfo::Right }, |
| 5186 |
+ { "iterations low mean low std dev", 14, ColumnInfo::Right }, |
| 5187 |
+ { "estimated high mean high std dev", 14, ColumnInfo::Right } |
| 5188 |
+ }; |
| 5189 |
+ } |
| 5190 |
+ }())) {} |
| 5191 |
ConsoleReporter::~ConsoleReporter() = default; |
| 5192 |
|
| 5193 |
std::string ConsoleReporter::getDescription() { |
| 5194 |
@@ -15646,6 +16479,10 @@ void ConsoleReporter::noMatchingTestCase |
| 5195 |
stream << "No test cases matched '" << spec << '\'' << std::endl; |
| 5196 |
} |
| 5197 |
|
| 5198 |
+void ConsoleReporter::reportInvalidArguments(std::string const&arg){ |
| 5199 |
+ stream << "Invalid Filter: " << arg << std::endl; |
| 5200 |
+} |
| 5201 |
+ |
| 5202 |
void ConsoleReporter::assertionStarting(AssertionInfo const&) {} |
| 5203 |
|
| 5204 |
bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) { |
| 5205 |
@@ -15681,8 +16518,9 @@ void ConsoleReporter::sectionEnded(Secti |
| 5206 |
stream << "\nNo assertions in test case"; |
| 5207 |
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; |
| 5208 |
} |
| 5209 |
- if (m_config->showDurations() == ShowDurations::Always) { |
| 5210 |
- stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; |
| 5211 |
+ double dur = _sectionStats.durationInSeconds; |
| 5212 |
+ if (shouldShowDuration(*m_config, dur)) { |
| 5213 |
+ stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << std::endl; |
| 5214 |
} |
| 5215 |
if (m_headerPrinted) { |
| 5216 |
m_headerPrinted = false; |
| 5217 |
@@ -15708,24 +16546,32 @@ void ConsoleReporter::benchmarkPreparing |
| 5218 |
} |
| 5219 |
|
| 5220 |
void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { |
| 5221 |
- (*m_tablePrinter) << info.samples << ColumnBreak() |
| 5222 |
- << info.iterations << ColumnBreak() |
| 5223 |
- << Duration(info.estimatedDuration) << ColumnBreak(); |
| 5224 |
+ (*m_tablePrinter) << info.samples << ColumnBreak() |
| 5225 |
+ << info.iterations << ColumnBreak(); |
| 5226 |
+ if (!m_config->benchmarkNoAnalysis()) |
| 5227 |
+ (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak(); |
| 5228 |
} |
| 5229 |
void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) { |
| 5230 |
- (*m_tablePrinter) << ColumnBreak() |
| 5231 |
- << Duration(stats.mean.point.count()) << ColumnBreak() |
| 5232 |
- << Duration(stats.mean.lower_bound.count()) << ColumnBreak() |
| 5233 |
- << Duration(stats.mean.upper_bound.count()) << ColumnBreak() << ColumnBreak() |
| 5234 |
- << Duration(stats.standardDeviation.point.count()) << ColumnBreak() |
| 5235 |
- << Duration(stats.standardDeviation.lower_bound.count()) << ColumnBreak() |
| 5236 |
- << Duration(stats.standardDeviation.upper_bound.count()) << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak(); |
| 5237 |
+ if (m_config->benchmarkNoAnalysis()) |
| 5238 |
+ { |
| 5239 |
+ (*m_tablePrinter) << Duration(stats.mean.point.count()) << ColumnBreak(); |
| 5240 |
+ } |
| 5241 |
+ else |
| 5242 |
+ { |
| 5243 |
+ (*m_tablePrinter) << ColumnBreak() |
| 5244 |
+ << Duration(stats.mean.point.count()) << ColumnBreak() |
| 5245 |
+ << Duration(stats.mean.lower_bound.count()) << ColumnBreak() |
| 5246 |
+ << Duration(stats.mean.upper_bound.count()) << ColumnBreak() << ColumnBreak() |
| 5247 |
+ << Duration(stats.standardDeviation.point.count()) << ColumnBreak() |
| 5248 |
+ << Duration(stats.standardDeviation.lower_bound.count()) << ColumnBreak() |
| 5249 |
+ << Duration(stats.standardDeviation.upper_bound.count()) << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak(); |
| 5250 |
+ } |
| 5251 |
} |
| 5252 |
|
| 5253 |
void ConsoleReporter::benchmarkFailed(std::string const& error) { |
| 5254 |
Colour colour(Colour::Red); |
| 5255 |
(*m_tablePrinter) |
| 5256 |
- << "Benchmark failed (" << error << ")" |
| 5257 |
+ << "Benchmark failed (" << error << ')' |
| 5258 |
<< ColumnBreak() << RowBreak(); |
| 5259 |
} |
| 5260 |
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING |
| 5261 |
@@ -15807,11 +16653,9 @@ void ConsoleReporter::printTestCaseAndSe |
| 5262 |
|
| 5263 |
SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; |
| 5264 |
|
| 5265 |
- if (!lineInfo.empty()) { |
| 5266 |
- stream << getLineOfChars<'-'>() << '\n'; |
| 5267 |
- Colour colourGuard(Colour::FileName); |
| 5268 |
- stream << lineInfo << '\n'; |
| 5269 |
- } |
| 5270 |
+ stream << getLineOfChars<'-'>() << '\n'; |
| 5271 |
+ Colour colourGuard(Colour::FileName); |
| 5272 |
+ stream << lineInfo << '\n'; |
| 5273 |
stream << getLineOfChars<'.'>() << '\n' << std::endl; |
| 5274 |
} |
| 5275 |
|
| 5276 |
@@ -15936,8 +16780,10 @@ void ConsoleReporter::printSummaryDivide |
| 5277 |
} |
| 5278 |
|
| 5279 |
void ConsoleReporter::printTestFilters() { |
| 5280 |
- if (m_config->testSpec().hasFilters()) |
| 5281 |
- stream << Colour(Colour::BrightYellow) << "Filters: " << serializeFilters( m_config->getTestsOrTags() ) << '\n'; |
| 5282 |
+ if (m_config->testSpec().hasFilters()) { |
| 5283 |
+ Colour guard(Colour::BrightYellow); |
| 5284 |
+ stream << "Filters: " << serializeFilters(m_config->getTestsOrTags()) << '\n'; |
| 5285 |
+ } |
| 5286 |
} |
| 5287 |
|
| 5288 |
CATCH_REGISTER_REPORTER("console", ConsoleReporter) |
| 5289 |
@@ -15958,6 +16804,7 @@ CATCH_REGISTER_REPORTER("console", Conso |
| 5290 |
#include <sstream> |
| 5291 |
#include <ctime> |
| 5292 |
#include <algorithm> |
| 5293 |
+#include <iomanip> |
| 5294 |
|
| 5295 |
namespace Catch { |
| 5296 |
|
| 5297 |
@@ -15985,7 +16832,7 @@ namespace Catch { |
| 5298 |
#else |
| 5299 |
std::strftime(timeStamp, timeStampSize, fmt, timeInfo); |
| 5300 |
#endif |
| 5301 |
- return std::string(timeStamp); |
| 5302 |
+ return std::string(timeStamp, timeStampSize-1); |
| 5303 |
} |
| 5304 |
|
| 5305 |
std::string fileNameTag(const std::vector<std::string> &tags) { |
| 5306 |
@@ -15996,6 +16843,17 @@ namespace Catch { |
| 5307 |
return it->substr(1); |
| 5308 |
return std::string(); |
| 5309 |
} |
| 5310 |
+ |
| 5311 |
+ // Formats the duration in seconds to 3 decimal places. |
| 5312 |
+ // This is done because some genius defined Maven Surefire schema |
| 5313 |
+ // in a way that only accepts 3 decimal places, and tools like |
| 5314 |
+ // Jenkins use that schema for validation JUnit reporter output. |
| 5315 |
+ std::string formatDuration( double seconds ) { |
| 5316 |
+ ReusableStringStream rss; |
| 5317 |
+ rss << std::fixed << std::setprecision( 3 ) << seconds; |
| 5318 |
+ return rss.str(); |
| 5319 |
+ } |
| 5320 |
+ |
| 5321 |
} // anonymous namespace |
| 5322 |
|
| 5323 |
JunitReporter::JunitReporter( ReporterConfig const& _config ) |
| 5324 |
@@ -16065,7 +16923,7 @@ namespace Catch { |
| 5325 |
if( m_config->showDurations() == ShowDurations::Never ) |
| 5326 |
xml.writeAttribute( "time", "" ); |
| 5327 |
else |
| 5328 |
- xml.writeAttribute( "time", suiteTime ); |
| 5329 |
+ xml.writeAttribute( "time", formatDuration( suiteTime ) ); |
| 5330 |
xml.writeAttribute( "timestamp", getCurrentTimestamp() ); |
| 5331 |
|
| 5332 |
// Write properties if there are any |
| 5333 |
@@ -16087,8 +16945,8 @@ namespace Catch { |
| 5334 |
for( auto const& child : groupNode.children ) |
| 5335 |
writeTestCase( *child ); |
| 5336 |
|
| 5337 |
- xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), false ); |
| 5338 |
- xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), false ); |
| 5339 |
+ xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), XmlFormatting::Newline ); |
| 5340 |
+ xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), XmlFormatting::Newline ); |
| 5341 |
} |
| 5342 |
|
| 5343 |
void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) { |
| 5344 |
@@ -16110,12 +16968,13 @@ namespace Catch { |
| 5345 |
if ( !m_config->name().empty() ) |
| 5346 |
className = m_config->name() + "." + className; |
| 5347 |
|
| 5348 |
- writeSection( className, "", rootSection ); |
| 5349 |
+ writeSection( className, "", rootSection, stats.testInfo.okToFail() ); |
| 5350 |
} |
| 5351 |
|
| 5352 |
- void JunitReporter::writeSection( std::string const& className, |
| 5353 |
- std::string const& rootName, |
| 5354 |
- SectionNode const& sectionNode ) { |
| 5355 |
+ void JunitReporter::writeSection( std::string const& className, |
| 5356 |
+ std::string const& rootName, |
| 5357 |
+ SectionNode const& sectionNode, |
| 5358 |
+ bool testOkToFail) { |
| 5359 |
std::string name = trim( sectionNode.stats.sectionInfo.name ); |
| 5360 |
if( !rootName.empty() ) |
| 5361 |
name = rootName + '/' + name; |
| 5362 |
@@ -16132,20 +16991,30 @@ namespace Catch { |
| 5363 |
xml.writeAttribute( "classname", className ); |
| 5364 |
xml.writeAttribute( "name", name ); |
| 5365 |
} |
| 5366 |
- xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); |
| 5367 |
+ xml.writeAttribute( "time", formatDuration( sectionNode.stats.durationInSeconds ) ); |
| 5368 |
+ // This is not ideal, but it should be enough to mimic gtest's |
| 5369 |
+ // junit output. |
| 5370 |
+ // Ideally the JUnit reporter would also handle `skipTest` |
| 5371 |
+ // events and write those out appropriately. |
| 5372 |
+ xml.writeAttribute( "status", "run" ); |
| 5373 |
+ |
| 5374 |
+ if (sectionNode.stats.assertions.failedButOk) { |
| 5375 |
+ xml.scopedElement("skipped") |
| 5376 |
+ .writeAttribute("message", "TEST_CASE tagged with !mayfail"); |
| 5377 |
+ } |
| 5378 |
|
| 5379 |
writeAssertions( sectionNode ); |
| 5380 |
|
| 5381 |
if( !sectionNode.stdOut.empty() ) |
| 5382 |
- xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); |
| 5383 |
+ xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), XmlFormatting::Newline ); |
| 5384 |
if( !sectionNode.stdErr.empty() ) |
| 5385 |
- xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); |
| 5386 |
+ xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), XmlFormatting::Newline ); |
| 5387 |
} |
| 5388 |
for( auto const& childNode : sectionNode.childSections ) |
| 5389 |
if( className.empty() ) |
| 5390 |
- writeSection( name, "", *childNode ); |
| 5391 |
+ writeSection( name, "", *childNode, testOkToFail ); |
| 5392 |
else |
| 5393 |
- writeSection( className, name, *childNode ); |
| 5394 |
+ writeSection( className, name, *childNode, testOkToFail ); |
| 5395 |
} |
| 5396 |
|
| 5397 |
void JunitReporter::writeAssertions( SectionNode const& sectionNode ) { |
| 5398 |
@@ -16163,11 +17032,7 @@ namespace Catch { |
| 5399 |
elementName = "error"; |
| 5400 |
break; |
| 5401 |
case ResultWas::ExplicitFailure: |
| 5402 |
- elementName = "failure"; |
| 5403 |
- break; |
| 5404 |
case ResultWas::ExpressionFailed: |
| 5405 |
- elementName = "failure"; |
| 5406 |
- break; |
| 5407 |
case ResultWas::DidntThrowException: |
| 5408 |
elementName = "failure"; |
| 5409 |
break; |
| 5410 |
@@ -16185,10 +17050,25 @@ namespace Catch { |
| 5411 |
|
| 5412 |
XmlWriter::ScopedElement e = xml.scopedElement( elementName ); |
| 5413 |
|
| 5414 |
- xml.writeAttribute( "message", result.getExpandedExpression() ); |
| 5415 |
+ xml.writeAttribute( "message", result.getExpression() ); |
| 5416 |
xml.writeAttribute( "type", result.getTestMacroName() ); |
| 5417 |
|
| 5418 |
ReusableStringStream rss; |
| 5419 |
+ if (stats.totals.assertions.total() > 0) { |
| 5420 |
+ rss << "FAILED" << ":\n"; |
| 5421 |
+ if (result.hasExpression()) { |
| 5422 |
+ rss << " "; |
| 5423 |
+ rss << result.getExpressionInMacro(); |
| 5424 |
+ rss << '\n'; |
| 5425 |
+ } |
| 5426 |
+ if (result.hasExpandedExpression()) { |
| 5427 |
+ rss << "with expansion:\n"; |
| 5428 |
+ rss << Column(result.getExpandedExpression()).indent(2) << '\n'; |
| 5429 |
+ } |
| 5430 |
+ } else { |
| 5431 |
+ rss << '\n'; |
| 5432 |
+ } |
| 5433 |
+ |
| 5434 |
if( !result.getMessage().empty() ) |
| 5435 |
rss << result.getMessage() << '\n'; |
| 5436 |
for( auto const& msg : stats.infoMessages ) |
| 5437 |
@@ -16196,7 +17076,7 @@ namespace Catch { |
| 5438 |
rss << msg.message << '\n'; |
| 5439 |
|
| 5440 |
rss << "at " << result.getSourceInfo(); |
| 5441 |
- xml.writeText( rss.str(), false ); |
| 5442 |
+ xml.writeText( rss.str(), XmlFormatting::Newline ); |
| 5443 |
} |
| 5444 |
} |
| 5445 |
|
| 5446 |
@@ -16240,6 +17120,13 @@ namespace Catch { |
| 5447 |
m_reporter->noMatchingTestCases( spec ); |
| 5448 |
} |
| 5449 |
|
| 5450 |
+ void ListeningReporter::reportInvalidArguments(std::string const&arg){ |
| 5451 |
+ for ( auto const& listener : m_listeners ) { |
| 5452 |
+ listener->reportInvalidArguments( arg ); |
| 5453 |
+ } |
| 5454 |
+ m_reporter->reportInvalidArguments( arg ); |
| 5455 |
+ } |
| 5456 |
+ |
| 5457 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 5458 |
void ListeningReporter::benchmarkPreparing( std::string const& name ) { |
| 5459 |
for (auto const& listener : m_listeners) { |
| 5460 |
@@ -16535,9 +17422,9 @@ namespace Catch { |
| 5461 |
e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); |
| 5462 |
|
| 5463 |
if( !testCaseStats.stdOut.empty() ) |
| 5464 |
- m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); |
| 5465 |
+ m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), XmlFormatting::Newline ); |
| 5466 |
if( !testCaseStats.stdErr.empty() ) |
| 5467 |
- m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); |
| 5468 |
+ m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), XmlFormatting::Newline ); |
| 5469 |
|
| 5470 |
m_xml.endElement(); |
| 5471 |
} |
| 5472 |
@@ -16549,6 +17436,10 @@ namespace Catch { |
| 5473 |
.writeAttribute( "successes", testGroupStats.totals.assertions.passed ) |
| 5474 |
.writeAttribute( "failures", testGroupStats.totals.assertions.failed ) |
| 5475 |
.writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); |
| 5476 |
+ m_xml.scopedElement( "OverallResultsCases") |
| 5477 |
+ .writeAttribute( "successes", testGroupStats.totals.testCases.passed ) |
| 5478 |
+ .writeAttribute( "failures", testGroupStats.totals.testCases.failed ) |
| 5479 |
+ .writeAttribute( "expectedFailures", testGroupStats.totals.testCases.failedButOk ); |
| 5480 |
m_xml.endElement(); |
| 5481 |
} |
| 5482 |
|
| 5483 |
@@ -16558,6 +17449,10 @@ namespace Catch { |
| 5484 |
.writeAttribute( "successes", testRunStats.totals.assertions.passed ) |
| 5485 |
.writeAttribute( "failures", testRunStats.totals.assertions.failed ) |
| 5486 |
.writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); |
| 5487 |
+ m_xml.scopedElement( "OverallResultsCases") |
| 5488 |
+ .writeAttribute( "successes", testRunStats.totals.testCases.passed ) |
| 5489 |
+ .writeAttribute( "failures", testRunStats.totals.testCases.failed ) |
| 5490 |
+ .writeAttribute( "expectedFailures", testRunStats.totals.testCases.failedButOk ); |
| 5491 |
m_xml.endElement(); |
| 5492 |
} |
| 5493 |
|
| 5494 |
@@ -16571,16 +17466,16 @@ namespace Catch { |
| 5495 |
m_xml.writeAttribute("samples", info.samples) |
| 5496 |
.writeAttribute("resamples", info.resamples) |
| 5497 |
.writeAttribute("iterations", info.iterations) |
| 5498 |
- .writeAttribute("clockResolution", static_cast<uint64_t>(info.clockResolution)) |
| 5499 |
- .writeAttribute("estimatedDuration", static_cast<uint64_t>(info.estimatedDuration)) |
| 5500 |
+ .writeAttribute("clockResolution", info.clockResolution) |
| 5501 |
+ .writeAttribute("estimatedDuration", info.estimatedDuration) |
| 5502 |
.writeComment("All values in nano seconds"); |
| 5503 |
} |
| 5504 |
|
| 5505 |
void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) { |
| 5506 |
m_xml.startElement("mean") |
| 5507 |
- .writeAttribute("value", static_cast<uint64_t>(benchmarkStats.mean.point.count())) |
| 5508 |
- .writeAttribute("lowerBound", static_cast<uint64_t>(benchmarkStats.mean.lower_bound.count())) |
| 5509 |
- .writeAttribute("upperBound", static_cast<uint64_t>(benchmarkStats.mean.upper_bound.count())) |
| 5510 |
+ .writeAttribute("value", benchmarkStats.mean.point.count()) |
| 5511 |
+ .writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count()) |
| 5512 |
+ .writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count()) |
| 5513 |
.writeAttribute("ci", benchmarkStats.mean.confidence_interval); |
| 5514 |
m_xml.endElement(); |
| 5515 |
m_xml.startElement("standardDeviation") |
| 5516 |
@@ -16631,7 +17526,7 @@ namespace Catch { |
| 5517 |
|
| 5518 |
#ifndef __OBJC__ |
| 5519 |
|
| 5520 |
-#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) |
| 5521 |
+#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) |
| 5522 |
// Standard C/C++ Win32 Unicode wmain entry point |
| 5523 |
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { |
| 5524 |
#else |
| 5525 |
@@ -16764,9 +17659,9 @@ int main (int argc, char * const argv[]) |
| 5526 |
|
| 5527 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 5528 |
#define CATCH_BENCHMARK(...) \ |
| 5529 |
- INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) |
| 5530 |
+ INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) |
| 5531 |
#define CATCH_BENCHMARK_ADVANCED(name) \ |
| 5532 |
- INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name) |
| 5533 |
+ INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), name) |
| 5534 |
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING |
| 5535 |
|
| 5536 |
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required |
| 5537 |
@@ -16868,9 +17763,9 @@ int main (int argc, char * const argv[]) |
| 5538 |
|
| 5539 |
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) |
| 5540 |
#define BENCHMARK(...) \ |
| 5541 |
- INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) |
| 5542 |
+ INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) |
| 5543 |
#define BENCHMARK_ADVANCED(name) \ |
| 5544 |
- INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name) |
| 5545 |
+ INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), name) |
| 5546 |
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING |
| 5547 |
|
| 5548 |
using Catch::Detail::Approx; |
| 5549 |
@@ -16917,8 +17812,8 @@ using Catch::Detail::Approx; |
| 5550 |
#define CATCH_WARN( msg ) (void)(0) |
| 5551 |
#define CATCH_CAPTURE( msg ) (void)(0) |
| 5552 |
|
| 5553 |
-#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5554 |
-#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5555 |
+#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5556 |
+#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5557 |
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) |
| 5558 |
#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) |
| 5559 |
#define CATCH_SECTION( ... ) |
| 5560 |
@@ -16927,7 +17822,7 @@ using Catch::Detail::Approx; |
| 5561 |
#define CATCH_FAIL_CHECK( ... ) (void)(0) |
| 5562 |
#define CATCH_SUCCEED( ... ) (void)(0) |
| 5563 |
|
| 5564 |
-#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5565 |
+#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5566 |
|
| 5567 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 5568 |
#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) |
| 5569 |
@@ -16950,8 +17845,8 @@ using Catch::Detail::Approx; |
| 5570 |
#endif |
| 5571 |
|
| 5572 |
// "BDD-style" convenience wrappers |
| 5573 |
-#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5574 |
-#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) |
| 5575 |
+#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5576 |
+#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), className ) |
| 5577 |
#define CATCH_GIVEN( desc ) |
| 5578 |
#define CATCH_AND_GIVEN( desc ) |
| 5579 |
#define CATCH_WHEN( desc ) |
| 5580 |
@@ -16999,10 +17894,10 @@ using Catch::Detail::Approx; |
| 5581 |
#define INFO( msg ) (void)(0) |
| 5582 |
#define UNSCOPED_INFO( msg ) (void)(0) |
| 5583 |
#define WARN( msg ) (void)(0) |
| 5584 |
-#define CAPTURE( msg ) (void)(0) |
| 5585 |
+#define CAPTURE( ... ) (void)(0) |
| 5586 |
|
| 5587 |
-#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5588 |
-#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5589 |
+#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5590 |
+#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5591 |
#define METHOD_AS_TEST_CASE( method, ... ) |
| 5592 |
#define REGISTER_TEST_CASE( Function, ... ) (void)(0) |
| 5593 |
#define SECTION( ... ) |
| 5594 |
@@ -17010,7 +17905,7 @@ using Catch::Detail::Approx; |
| 5595 |
#define FAIL( ... ) (void)(0) |
| 5596 |
#define FAIL_CHECK( ... ) (void)(0) |
| 5597 |
#define SUCCEED( ... ) (void)(0) |
| 5598 |
-#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) |
| 5599 |
+#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) |
| 5600 |
|
| 5601 |
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
| 5602 |
#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) |
| 5603 |
@@ -17040,8 +17935,8 @@ using Catch::Detail::Approx; |
| 5604 |
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) |
| 5605 |
|
| 5606 |
// "BDD-style" convenience wrappers |
| 5607 |
-#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) ) |
| 5608 |
-#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) |
| 5609 |
+#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ) ) |
| 5610 |
+#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), className ) |
| 5611 |
|
| 5612 |
#define GIVEN( desc ) |
| 5613 |
#define AND_GIVEN( desc ) |
| 5614 |
--- /dev/null |
| 5615 |
+++ sfxr-qt-1.5.0+ds/3rdparty/catch2/single_include/catch2/catch_reporter_sonarqube.hpp |
| 5616 |
@@ -0,0 +1,181 @@ |
| 5617 |
+/* |
| 5618 |
+ * Created by Daniel Garcia on 2018-12-04. |
| 5619 |
+ * Copyright Social Point SL. All rights reserved. |
| 5620 |
+ * |
| 5621 |
+ * Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5622 |
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5623 |
+ */ |
| 5624 |
+#ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED |
| 5625 |
+#define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED |
| 5626 |
+ |
| 5627 |
+ |
| 5628 |
+// Don't #include any Catch headers here - we can assume they are already |
| 5629 |
+// included before this header. |
| 5630 |
+// This is not good practice in general but is necessary in this case so this |
| 5631 |
+// file can be distributed as a single header that works with the main |
| 5632 |
+// Catch single header. |
| 5633 |
+ |
| 5634 |
+#include <map> |
| 5635 |
+ |
| 5636 |
+namespace Catch { |
| 5637 |
+ |
| 5638 |
+ struct SonarQubeReporter : CumulativeReporterBase<SonarQubeReporter> { |
| 5639 |
+ |
| 5640 |
+ SonarQubeReporter(ReporterConfig const& config) |
| 5641 |
+ : CumulativeReporterBase(config) |
| 5642 |
+ , xml(config.stream()) { |
| 5643 |
+ m_reporterPrefs.shouldRedirectStdOut = true; |
| 5644 |
+ m_reporterPrefs.shouldReportAllAssertions = true; |
| 5645 |
+ } |
| 5646 |
+ |
| 5647 |
+ ~SonarQubeReporter() override; |
| 5648 |
+ |
| 5649 |
+ static std::string getDescription() { |
| 5650 |
+ return "Reports test results in the Generic Test Data SonarQube XML format"; |
| 5651 |
+ } |
| 5652 |
+ |
| 5653 |
+ static std::set<Verbosity> getSupportedVerbosities() { |
| 5654 |
+ return { Verbosity::Normal }; |
| 5655 |
+ } |
| 5656 |
+ |
| 5657 |
+ void noMatchingTestCases(std::string const& /*spec*/) override {} |
| 5658 |
+ |
| 5659 |
+ void testRunStarting(TestRunInfo const& testRunInfo) override { |
| 5660 |
+ CumulativeReporterBase::testRunStarting(testRunInfo); |
| 5661 |
+ xml.startElement("testExecutions"); |
| 5662 |
+ xml.writeAttribute("version", "1"); |
| 5663 |
+ } |
| 5664 |
+ |
| 5665 |
+ void testGroupEnded(TestGroupStats const& testGroupStats) override { |
| 5666 |
+ CumulativeReporterBase::testGroupEnded(testGroupStats); |
| 5667 |
+ writeGroup(*m_testGroups.back()); |
| 5668 |
+ } |
| 5669 |
+ |
| 5670 |
+ void testRunEndedCumulative() override { |
| 5671 |
+ xml.endElement(); |
| 5672 |
+ } |
| 5673 |
+ |
| 5674 |
+ void writeGroup(TestGroupNode const& groupNode) { |
| 5675 |
+ std::map<std::string, TestGroupNode::ChildNodes> testsPerFile; |
| 5676 |
+ for(auto const& child : groupNode.children) |
| 5677 |
+ testsPerFile[child->value.testInfo.lineInfo.file].push_back(child); |
| 5678 |
+ |
| 5679 |
+ for(auto const& kv : testsPerFile) |
| 5680 |
+ writeTestFile(kv.first.c_str(), kv.second); |
| 5681 |
+ } |
| 5682 |
+ |
| 5683 |
+ void writeTestFile(const char* filename, TestGroupNode::ChildNodes const& testCaseNodes) { |
| 5684 |
+ XmlWriter::ScopedElement e = xml.scopedElement("file"); |
| 5685 |
+ xml.writeAttribute("path", filename); |
| 5686 |
+ |
| 5687 |
+ for(auto const& child : testCaseNodes) |
| 5688 |
+ writeTestCase(*child); |
| 5689 |
+ } |
| 5690 |
+ |
| 5691 |
+ void writeTestCase(TestCaseNode const& testCaseNode) { |
| 5692 |
+ // All test cases have exactly one section - which represents the |
| 5693 |
+ // test case itself. That section may have 0-n nested sections |
| 5694 |
+ assert(testCaseNode.children.size() == 1); |
| 5695 |
+ SectionNode const& rootSection = *testCaseNode.children.front(); |
| 5696 |
+ writeSection("", rootSection, testCaseNode.value.testInfo.okToFail()); |
| 5697 |
+ } |
| 5698 |
+ |
| 5699 |
+ void writeSection(std::string const& rootName, SectionNode const& sectionNode, bool okToFail) { |
| 5700 |
+ std::string name = trim(sectionNode.stats.sectionInfo.name); |
| 5701 |
+ if(!rootName.empty()) |
| 5702 |
+ name = rootName + '/' + name; |
| 5703 |
+ |
| 5704 |
+ if(!sectionNode.assertions.empty() || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty()) { |
| 5705 |
+ XmlWriter::ScopedElement e = xml.scopedElement("testCase"); |
| 5706 |
+ xml.writeAttribute("name", name); |
| 5707 |
+ xml.writeAttribute("duration", static_cast<long>(sectionNode.stats.durationInSeconds * 1000)); |
| 5708 |
+ |
| 5709 |
+ writeAssertions(sectionNode, okToFail); |
| 5710 |
+ } |
| 5711 |
+ |
| 5712 |
+ for(auto const& childNode : sectionNode.childSections) |
| 5713 |
+ writeSection(name, *childNode, okToFail); |
| 5714 |
+ } |
| 5715 |
+ |
| 5716 |
+ void writeAssertions(SectionNode const& sectionNode, bool okToFail) { |
| 5717 |
+ for(auto const& assertion : sectionNode.assertions) |
| 5718 |
+ writeAssertion( assertion, okToFail); |
| 5719 |
+ } |
| 5720 |
+ |
| 5721 |
+ void writeAssertion(AssertionStats const& stats, bool okToFail) { |
| 5722 |
+ AssertionResult const& result = stats.assertionResult; |
| 5723 |
+ if(!result.isOk()) { |
| 5724 |
+ std::string elementName; |
| 5725 |
+ if(okToFail) { |
| 5726 |
+ elementName = "skipped"; |
| 5727 |
+ } |
| 5728 |
+ else { |
| 5729 |
+ switch(result.getResultType()) { |
| 5730 |
+ case ResultWas::ThrewException: |
| 5731 |
+ case ResultWas::FatalErrorCondition: |
| 5732 |
+ elementName = "error"; |
| 5733 |
+ break; |
| 5734 |
+ case ResultWas::ExplicitFailure: |
| 5735 |
+ elementName = "failure"; |
| 5736 |
+ break; |
| 5737 |
+ case ResultWas::ExpressionFailed: |
| 5738 |
+ elementName = "failure"; |
| 5739 |
+ break; |
| 5740 |
+ case ResultWas::DidntThrowException: |
| 5741 |
+ elementName = "failure"; |
| 5742 |
+ break; |
| 5743 |
+ |
| 5744 |
+ // We should never see these here: |
| 5745 |
+ case ResultWas::Info: |
| 5746 |
+ case ResultWas::Warning: |
| 5747 |
+ case ResultWas::Ok: |
| 5748 |
+ case ResultWas::Unknown: |
| 5749 |
+ case ResultWas::FailureBit: |
| 5750 |
+ case ResultWas::Exception: |
| 5751 |
+ elementName = "internalError"; |
| 5752 |
+ break; |
| 5753 |
+ } |
| 5754 |
+ } |
| 5755 |
+ |
| 5756 |
+ XmlWriter::ScopedElement e = xml.scopedElement(elementName); |
| 5757 |
+ |
| 5758 |
+ ReusableStringStream messageRss; |
| 5759 |
+ messageRss << result.getTestMacroName() << "(" << result.getExpression() << ")"; |
| 5760 |
+ xml.writeAttribute("message", messageRss.str()); |
| 5761 |
+ |
| 5762 |
+ ReusableStringStream textRss; |
| 5763 |
+ if (stats.totals.assertions.total() > 0) { |
| 5764 |
+ textRss << "FAILED:\n"; |
| 5765 |
+ if (result.hasExpression()) { |
| 5766 |
+ textRss << "\t" << result.getExpressionInMacro() << "\n"; |
| 5767 |
+ } |
| 5768 |
+ if (result.hasExpandedExpression()) { |
| 5769 |
+ textRss << "with expansion:\n\t" << result.getExpandedExpression() << "\n"; |
| 5770 |
+ } |
| 5771 |
+ } |
| 5772 |
+ |
| 5773 |
+ if(!result.getMessage().empty()) |
| 5774 |
+ textRss << result.getMessage() << "\n"; |
| 5775 |
+ |
| 5776 |
+ for(auto const& msg : stats.infoMessages) |
| 5777 |
+ if(msg.type == ResultWas::Info) |
| 5778 |
+ textRss << msg.message << "\n"; |
| 5779 |
+ |
| 5780 |
+ textRss << "at " << result.getSourceInfo(); |
| 5781 |
+ xml.writeText(textRss.str(), XmlFormatting::Newline); |
| 5782 |
+ } |
| 5783 |
+ } |
| 5784 |
+ |
| 5785 |
+ private: |
| 5786 |
+ XmlWriter xml; |
| 5787 |
+ }; |
| 5788 |
+ |
| 5789 |
+#ifdef CATCH_IMPL |
| 5790 |
+ SonarQubeReporter::~SonarQubeReporter() {} |
| 5791 |
+#endif |
| 5792 |
+ |
| 5793 |
+ CATCH_REGISTER_REPORTER( "sonarqube", SonarQubeReporter ) |
| 5794 |
+ |
| 5795 |
+} // end namespace Catch |
| 5796 |
+ |
| 5797 |
+#endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED |
| 5798 |
\ No newline at end of file |
| 5799 |
--- sfxr-qt-1.5.0+ds.orig/3rdparty/catch2/single_include/catch2/catch_reporter_tap.hpp |
| 5800 |
+++ sfxr-qt-1.5.0+ds/3rdparty/catch2/single_include/catch2/catch_reporter_tap.hpp |
| 5801 |
@@ -23,16 +23,17 @@ namespace Catch { |
| 5802 |
|
| 5803 |
using StreamingReporterBase::StreamingReporterBase; |
| 5804 |
|
| 5805 |
+ TAPReporter( ReporterConfig const& config ): |
| 5806 |
+ StreamingReporterBase( config ) { |
| 5807 |
+ m_reporterPrefs.shouldReportAllAssertions = true; |
| 5808 |
+ } |
| 5809 |
+ |
| 5810 |
~TAPReporter() override; |
| 5811 |
|
| 5812 |
static std::string getDescription() { |
| 5813 |
return "Reports test results in TAP format, suitable for test harnesses"; |
| 5814 |
} |
| 5815 |
|
| 5816 |
- ReporterPreferences getPreferences() const override { |
| 5817 |
- return m_reporterPrefs; |
| 5818 |
- } |
| 5819 |
- |
| 5820 |
void noMatchingTestCases( std::string const& spec ) override { |
| 5821 |
stream << "# No test cases matched '" << spec << "'" << std::endl; |
| 5822 |
} |
| 5823 |
@@ -203,16 +204,15 @@ namespace Catch { |
| 5824 |
return; |
| 5825 |
} |
| 5826 |
|
| 5827 |
- // using messages.end() directly (or auto) yields compilation error: |
| 5828 |
- std::vector<MessageInfo>::const_iterator itEnd = messages.end(); |
| 5829 |
- const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) ); |
| 5830 |
+ const auto itEnd = messages.cend(); |
| 5831 |
+ const auto N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) ); |
| 5832 |
|
| 5833 |
{ |
| 5834 |
Colour colourGuard( colour ); |
| 5835 |
stream << " with " << pluralise( N, "message" ) << ":"; |
| 5836 |
} |
| 5837 |
|
| 5838 |
- for(; itMessage != itEnd; ) { |
| 5839 |
+ while( itMessage != itEnd ) { |
| 5840 |
// If this assertion is a warning ignore any INFO messages |
| 5841 |
if( printInfoMessages || itMessage->type != ResultWas::Info ) { |
| 5842 |
stream << " '" << itMessage->message << "'"; |
| 5843 |
@@ -220,7 +220,9 @@ namespace Catch { |
| 5844 |
Colour colourGuard( dimColour() ); |
| 5845 |
stream << " and"; |
| 5846 |
} |
| 5847 |
+ continue; |
| 5848 |
} |
| 5849 |
+ ++itMessage; |
| 5850 |
} |
| 5851 |
} |
| 5852 |
|
| 5853 |
@@ -234,10 +236,9 @@ namespace Catch { |
| 5854 |
}; |
| 5855 |
|
| 5856 |
void printTotals( const Totals& totals ) const { |
| 5857 |
+ stream << "1.." << totals.assertions.total(); |
| 5858 |
if( totals.testCases.total() == 0 ) { |
| 5859 |
- stream << "1..0 # Skipped: No tests ran."; |
| 5860 |
- } else { |
| 5861 |
- stream << "1.." << counter; |
| 5862 |
+ stream << " # Skipped: No tests ran."; |
| 5863 |
} |
| 5864 |
} |
| 5865 |
}; |
| 5866 |
--- sfxr-qt-1.5.0+ds.orig/3rdparty/catch2/single_include/catch2/catch_reporter_teamcity.hpp |
| 5867 |
+++ sfxr-qt-1.5.0+ds/3rdparty/catch2/single_include/catch2/catch_reporter_teamcity.hpp |
| 5868 |
@@ -183,8 +183,7 @@ namespace Catch { |
| 5869 |
|
| 5870 |
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; |
| 5871 |
|
| 5872 |
- if( !lineInfo.empty() ) |
| 5873 |
- os << lineInfo << "\n"; |
| 5874 |
+ os << lineInfo << "\n"; |
| 5875 |
os << getLineOfChars<'.'>() << "\n\n"; |
| 5876 |
} |
| 5877 |
|