| 1 |
From d2cd095abbd2d7c51c7f6bea0d305f22cd7a755c Mon Sep 17 00:00:00 2001 |
| 2 |
From: Roman Siromakha <[email protected]> |
| 3 |
Date: Fri, 21 Jul 2023 23:31:58 +0200 |
| 4 |
Subject: [PATCH 03/36] Update catch to v3.4.0 (#648) |
| 5 |
|
| 6 |
--- |
| 7 |
Tests/Contrib/catch2/catch_all.hpp | 3911 ++++++++++++-------- |
| 8 |
Tests/Contrib/catch2/catch_amalgamated.cpp | 2212 ++++++----- |
| 9 |
2 files changed, 3703 insertions(+), 2420 deletions(-) |
| 10 |
|
| 11 |
diff --git a/Tests/Contrib/catch2/catch_all.hpp b/Tests/Contrib/catch2/catch_all.hpp |
| 12 |
index cff2ced..694fe1e 100644 |
| 13 |
--- a/Tests/Contrib/catch2/catch_all.hpp |
| 14 |
+++ b/Tests/Contrib/catch2/catch_all.hpp |
| 15 |
@@ -1,12 +1,12 @@ |
| 16 |
// Copyright Catch2 Authors |
| 17 |
// Distributed under the Boost Software License, Version 1.0. |
| 18 |
-// (See accompanying file LICENSE_1_0.txt or copy at |
| 19 |
+// (See accompanying file LICENSE.txt or copy at |
| 20 |
// https://www.boost.org/LICENSE_1_0.txt) |
| 21 |
|
| 22 |
// SPDX-License-Identifier: BSL-1.0 |
| 23 |
|
| 24 |
-// Catch v3.1.1 |
| 25 |
-// Generated: 2022-10-17 18:47:20.510385 |
| 26 |
+// Catch v3.4.0 |
| 27 |
+// Generated: 2023-07-13 13:23:07.577770 |
| 28 |
// ---------------------------------------------------------- |
| 29 |
// This file is an amalgamation of multiple different files. |
| 30 |
// You probably shouldn't edit it directly. |
| 31 |
@@ -59,233 +59,6 @@ |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
-#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 36 |
-#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 37 |
- |
| 38 |
- |
| 39 |
- |
| 40 |
-#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED |
| 41 |
-#define CATCH_NONCOPYABLE_HPP_INCLUDED |
| 42 |
- |
| 43 |
-namespace Catch { |
| 44 |
- namespace Detail { |
| 45 |
- |
| 46 |
- //! Deriving classes become noncopyable and nonmovable |
| 47 |
- class NonCopyable { |
| 48 |
- NonCopyable( NonCopyable const& ) = delete; |
| 49 |
- NonCopyable( NonCopyable&& ) = delete; |
| 50 |
- NonCopyable& operator=( NonCopyable const& ) = delete; |
| 51 |
- NonCopyable& operator=( NonCopyable&& ) = delete; |
| 52 |
- |
| 53 |
- protected: |
| 54 |
- NonCopyable() noexcept = default; |
| 55 |
- }; |
| 56 |
- |
| 57 |
- } // namespace Detail |
| 58 |
-} // namespace Catch |
| 59 |
- |
| 60 |
-#endif // CATCH_NONCOPYABLE_HPP_INCLUDED |
| 61 |
- |
| 62 |
- |
| 63 |
-#ifndef CATCH_STRINGREF_HPP_INCLUDED |
| 64 |
-#define CATCH_STRINGREF_HPP_INCLUDED |
| 65 |
- |
| 66 |
-#include <cstddef> |
| 67 |
-#include <string> |
| 68 |
-#include <iosfwd> |
| 69 |
-#include <cassert> |
| 70 |
- |
| 71 |
-namespace Catch { |
| 72 |
- |
| 73 |
- /// A non-owning string class (similar to the forthcoming std::string_view) |
| 74 |
- /// Note that, because a StringRef may be a substring of another string, |
| 75 |
- /// it may not be null terminated. |
| 76 |
- class StringRef { |
| 77 |
- public: |
| 78 |
- using size_type = std::size_t; |
| 79 |
- using const_iterator = const char*; |
| 80 |
- |
| 81 |
- private: |
| 82 |
- static constexpr char const* const s_empty = ""; |
| 83 |
- |
| 84 |
- char const* m_start = s_empty; |
| 85 |
- size_type m_size = 0; |
| 86 |
- |
| 87 |
- public: // construction |
| 88 |
- constexpr StringRef() noexcept = default; |
| 89 |
- |
| 90 |
- StringRef( char const* rawChars ) noexcept; |
| 91 |
- |
| 92 |
- constexpr StringRef( char const* rawChars, size_type size ) noexcept |
| 93 |
- : m_start( rawChars ), |
| 94 |
- m_size( size ) |
| 95 |
- {} |
| 96 |
- |
| 97 |
- StringRef( std::string const& stdString ) noexcept |
| 98 |
- : m_start( stdString.c_str() ), |
| 99 |
- m_size( stdString.size() ) |
| 100 |
- {} |
| 101 |
- |
| 102 |
- explicit operator std::string() const { |
| 103 |
- return std::string(m_start, m_size); |
| 104 |
- } |
| 105 |
- |
| 106 |
- public: // operators |
| 107 |
- auto operator == ( StringRef other ) const noexcept -> bool; |
| 108 |
- auto operator != (StringRef other) const noexcept -> bool { |
| 109 |
- return !(*this == other); |
| 110 |
- } |
| 111 |
- |
| 112 |
- constexpr auto operator[] ( size_type index ) const noexcept -> char { |
| 113 |
- assert(index < m_size); |
| 114 |
- return m_start[index]; |
| 115 |
- } |
| 116 |
- |
| 117 |
- bool operator<(StringRef rhs) const noexcept; |
| 118 |
- |
| 119 |
- public: // named queries |
| 120 |
- constexpr auto empty() const noexcept -> bool { |
| 121 |
- return m_size == 0; |
| 122 |
- } |
| 123 |
- constexpr auto size() const noexcept -> size_type { |
| 124 |
- return m_size; |
| 125 |
- } |
| 126 |
- |
| 127 |
- // Returns a substring of [start, start + length). |
| 128 |
- // If start + length > size(), then the substring is [start, start + size()). |
| 129 |
- // If start > size(), then the substring is empty. |
| 130 |
- constexpr StringRef substr(size_type start, size_type length) const noexcept { |
| 131 |
- if (start < m_size) { |
| 132 |
- const auto shortened_size = m_size - start; |
| 133 |
- return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length); |
| 134 |
- } else { |
| 135 |
- return StringRef(); |
| 136 |
- } |
| 137 |
- } |
| 138 |
- |
| 139 |
- // Returns the current start pointer. May not be null-terminated. |
| 140 |
- constexpr char const* data() const noexcept { |
| 141 |
- return m_start; |
| 142 |
- } |
| 143 |
- |
| 144 |
- constexpr const_iterator begin() const { return m_start; } |
| 145 |
- constexpr const_iterator end() const { return m_start + m_size; } |
| 146 |
- |
| 147 |
- |
| 148 |
- friend std::string& operator += (std::string& lhs, StringRef sr); |
| 149 |
- friend std::ostream& operator << (std::ostream& os, StringRef sr); |
| 150 |
- friend std::string operator+(StringRef lhs, StringRef rhs); |
| 151 |
- |
| 152 |
- /** |
| 153 |
- * Provides a three-way comparison with rhs |
| 154 |
- * |
| 155 |
- * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive |
| 156 |
- * number if lhs > rhs |
| 157 |
- */ |
| 158 |
- int compare( StringRef rhs ) const; |
| 159 |
- }; |
| 160 |
- |
| 161 |
- |
| 162 |
- constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { |
| 163 |
- return StringRef( rawChars, size ); |
| 164 |
- } |
| 165 |
-} // namespace Catch |
| 166 |
- |
| 167 |
-constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { |
| 168 |
- return Catch::StringRef( rawChars, size ); |
| 169 |
-} |
| 170 |
- |
| 171 |
-#endif // CATCH_STRINGREF_HPP_INCLUDED |
| 172 |
- |
| 173 |
-#include <chrono> |
| 174 |
-#include <iosfwd> |
| 175 |
-#include <string> |
| 176 |
-#include <vector> |
| 177 |
- |
| 178 |
-namespace Catch { |
| 179 |
- |
| 180 |
- enum class Verbosity { |
| 181 |
- Quiet = 0, |
| 182 |
- Normal, |
| 183 |
- High |
| 184 |
- }; |
| 185 |
- |
| 186 |
- struct WarnAbout { enum What { |
| 187 |
- Nothing = 0x00, |
| 188 |
- //! A test case or leaf section did not run any assertions |
| 189 |
- NoAssertions = 0x01, |
| 190 |
- //! A command line test spec matched no test cases |
| 191 |
- UnmatchedTestSpec = 0x02, |
| 192 |
- }; }; |
| 193 |
- |
| 194 |
- enum class ShowDurations { |
| 195 |
- DefaultForReporter, |
| 196 |
- Always, |
| 197 |
- Never |
| 198 |
- }; |
| 199 |
- enum class TestRunOrder { |
| 200 |
- Declared, |
| 201 |
- LexicographicallySorted, |
| 202 |
- Randomized |
| 203 |
- }; |
| 204 |
- enum class ColourMode : std::uint8_t { |
| 205 |
- //! Let Catch2 pick implementation based on platform detection |
| 206 |
- PlatformDefault, |
| 207 |
- //! Use ANSI colour code escapes |
| 208 |
- ANSI, |
| 209 |
- //! Use Win32 console colour API |
| 210 |
- Win32, |
| 211 |
- //! Don't use any colour |
| 212 |
- None |
| 213 |
- }; |
| 214 |
- struct WaitForKeypress { enum When { |
| 215 |
- Never, |
| 216 |
- BeforeStart = 1, |
| 217 |
- BeforeExit = 2, |
| 218 |
- BeforeStartAndExit = BeforeStart | BeforeExit |
| 219 |
- }; }; |
| 220 |
- |
| 221 |
- class TestSpec; |
| 222 |
- class IStream; |
| 223 |
- |
| 224 |
- class IConfig : public Detail::NonCopyable { |
| 225 |
- public: |
| 226 |
- virtual ~IConfig(); |
| 227 |
- |
| 228 |
- virtual bool allowThrows() const = 0; |
| 229 |
- virtual StringRef name() const = 0; |
| 230 |
- virtual bool includeSuccessfulResults() const = 0; |
| 231 |
- virtual bool shouldDebugBreak() const = 0; |
| 232 |
- virtual bool warnAboutMissingAssertions() const = 0; |
| 233 |
- virtual bool warnAboutUnmatchedTestSpecs() const = 0; |
| 234 |
- virtual bool zeroTestsCountAsSuccess() const = 0; |
| 235 |
- virtual int abortAfter() const = 0; |
| 236 |
- virtual bool showInvisibles() const = 0; |
| 237 |
- virtual ShowDurations showDurations() const = 0; |
| 238 |
- virtual double minDuration() const = 0; |
| 239 |
- virtual TestSpec const& testSpec() const = 0; |
| 240 |
- virtual bool hasTestFilters() const = 0; |
| 241 |
- virtual std::vector<std::string> const& getTestsOrTags() const = 0; |
| 242 |
- virtual TestRunOrder runOrder() const = 0; |
| 243 |
- virtual uint32_t rngSeed() const = 0; |
| 244 |
- virtual unsigned int shardCount() const = 0; |
| 245 |
- virtual unsigned int shardIndex() const = 0; |
| 246 |
- virtual ColourMode defaultColourMode() const = 0; |
| 247 |
- virtual std::vector<std::string> const& getSectionsToRun() const = 0; |
| 248 |
- virtual Verbosity verbosity() const = 0; |
| 249 |
- |
| 250 |
- virtual bool skipBenchmarks() const = 0; |
| 251 |
- virtual bool benchmarkNoAnalysis() const = 0; |
| 252 |
- virtual unsigned int benchmarkSamples() const = 0; |
| 253 |
- virtual double benchmarkConfidenceInterval() const = 0; |
| 254 |
- virtual unsigned int benchmarkResamples() const = 0; |
| 255 |
- virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; |
| 256 |
- }; |
| 257 |
-} |
| 258 |
- |
| 259 |
-#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 260 |
- |
| 261 |
- |
| 262 |
#ifndef CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED |
| 263 |
#define CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED |
| 264 |
|
| 265 |
@@ -330,6 +103,10 @@ namespace Catch { |
| 266 |
# if defined( WINAPI_FAMILY ) && ( WINAPI_FAMILY == WINAPI_FAMILY_APP ) |
| 267 |
# define CATCH_PLATFORM_WINDOWS_UWP |
| 268 |
# endif |
| 269 |
+ |
| 270 |
+#elif defined(__ORBIS__) || defined(__PROSPERO__) |
| 271 |
+# define CATCH_PLATFORM_PLAYSTATION |
| 272 |
+ |
| 273 |
#endif |
| 274 |
|
| 275 |
#endif // CATCH_PLATFORM_HPP_INCLUDED |
| 276 |
@@ -348,7 +125,7 @@ namespace Catch { |
| 277 |
|
| 278 |
// Only GCC compiler should be used in this block, so other compilers trying to |
| 279 |
// mask themselves as GCC should be ignored. |
| 280 |
-#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) |
| 281 |
+#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) && !defined(__NVCOMPILER) |
| 282 |
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) |
| 283 |
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) |
| 284 |
|
| 285 |
@@ -357,20 +134,37 @@ namespace Catch { |
| 286 |
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ |
| 287 |
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" ) |
| 288 |
|
| 289 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ |
| 290 |
+ _Pragma( "GCC diagnostic ignored \"-Wunused-result\"" ) |
| 291 |
+ |
| 292 |
# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 293 |
_Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" ) |
| 294 |
|
| 295 |
# define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ |
| 296 |
_Pragma( "GCC diagnostic ignored \"-Wuseless-cast\"" ) |
| 297 |
|
| 298 |
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ |
| 299 |
+ _Pragma( "GCC diagnostic ignored \"-Wshadow\"" ) |
| 300 |
+ |
| 301 |
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) |
| 302 |
|
| 303 |
#endif |
| 304 |
|
| 305 |
+#if defined(__NVCOMPILER) |
| 306 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "diag push" ) |
| 307 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "diag pop" ) |
| 308 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma( "diag_suppress declared_but_not_referenced" ) |
| 309 |
+#endif |
| 310 |
+ |
| 311 |
#if defined(__CUDACC__) && !defined(__clang__) |
| 312 |
+# ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ |
| 313 |
+// New pragmas introduced in CUDA 11.5+ |
| 314 |
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "nv_diagnostic push" ) |
| 315 |
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "nv_diagnostic pop" ) |
| 316 |
# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma( "nv_diag_suppress 177" ) |
| 317 |
+# else |
| 318 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma( "diag_suppress 177" ) |
| 319 |
+# endif |
| 320 |
#endif |
| 321 |
|
| 322 |
// clang-cl defines _MSC_VER as well as __clang__, which could cause the |
| 323 |
@@ -421,23 +215,35 @@ namespace Catch { |
| 324 |
# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 325 |
_Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) |
| 326 |
|
| 327 |
-#endif // __clang__ |
| 328 |
+# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ |
| 329 |
+ _Pragma( "clang diagnostic ignored \"-Wcomma\"" ) |
| 330 |
|
| 331 |
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ |
| 332 |
+ _Pragma( "clang diagnostic ignored \"-Wshadow\"" ) |
| 333 |
+ |
| 334 |
+#endif // __clang__ |
| 335 |
|
| 336 |
-//////////////////////////////////////////////////////////////////////////////// |
| 337 |
-// Assume that non-Windows platforms support posix signals by default |
| 338 |
-#if !defined(CATCH_PLATFORM_WINDOWS) |
| 339 |
- #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS |
| 340 |
-#endif |
| 341 |
|
| 342 |
//////////////////////////////////////////////////////////////////////////////// |
| 343 |
// We know some environments not to support full POSIX signals |
| 344 |
-#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) |
| 345 |
- #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS |
| 346 |
+#if defined( CATCH_PLATFORM_WINDOWS ) || \ |
| 347 |
+ defined( CATCH_PLATFORM_PLAYSTATION ) || \ |
| 348 |
+ defined( __CYGWIN__ ) || \ |
| 349 |
+ defined( __QNX__ ) || \ |
| 350 |
+ defined( __EMSCRIPTEN__ ) || \ |
| 351 |
+ defined( __DJGPP__ ) || \ |
| 352 |
+ defined( __OS400__ ) |
| 353 |
+# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS |
| 354 |
+#else |
| 355 |
+# define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS |
| 356 |
#endif |
| 357 |
|
| 358 |
-#ifdef __OS400__ |
| 359 |
-# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS |
| 360 |
+//////////////////////////////////////////////////////////////////////////////// |
| 361 |
+// Assume that some platforms do not support getenv. |
| 362 |
+#if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION) |
| 363 |
+# define CATCH_INTERNAL_CONFIG_NO_GETENV |
| 364 |
+#else |
| 365 |
+# define CATCH_INTERNAL_CONFIG_GETENV |
| 366 |
#endif |
| 367 |
|
| 368 |
//////////////////////////////////////////////////////////////////////////////// |
| 369 |
@@ -479,8 +285,14 @@ namespace Catch { |
| 370 |
// Visual C++ |
| 371 |
#if defined(_MSC_VER) |
| 372 |
|
| 373 |
-# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) |
| 374 |
-# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) |
| 375 |
+// We want to defer to nvcc-specific warning suppression if we are compiled |
| 376 |
+// with nvcc masquerading for MSVC. |
| 377 |
+# if !defined( __CUDACC__ ) |
| 378 |
+# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 379 |
+ __pragma( warning( push ) ) |
| 380 |
+# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 381 |
+ __pragma( warning( pop ) ) |
| 382 |
+# endif |
| 383 |
|
| 384 |
// Universal Windows platform does not support SEH |
| 385 |
// Or console colours (or console at all...) |
| 386 |
@@ -580,6 +392,10 @@ namespace Catch { |
| 387 |
# define CATCH_CONFIG_POSIX_SIGNALS |
| 388 |
#endif |
| 389 |
|
| 390 |
+#if defined(CATCH_INTERNAL_CONFIG_GETENV) && !defined(CATCH_INTERNAL_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_GETENV) |
| 391 |
+# define CATCH_CONFIG_GETENV |
| 392 |
+#endif |
| 393 |
+ |
| 394 |
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) |
| 395 |
# define CATCH_CONFIG_CPP11_TO_STRING |
| 396 |
#endif |
| 397 |
@@ -642,6 +458,9 @@ namespace Catch { |
| 398 |
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) |
| 399 |
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
| 400 |
#endif |
| 401 |
+#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT) |
| 402 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT |
| 403 |
+#endif |
| 404 |
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS) |
| 405 |
# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS |
| 406 |
#endif |
| 407 |
@@ -651,6 +470,16 @@ namespace Catch { |
| 408 |
#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) |
| 409 |
# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS |
| 410 |
#endif |
| 411 |
+#if !defined( CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS ) |
| 412 |
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 413 |
+#endif |
| 414 |
+#if !defined( CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS ) |
| 415 |
+# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS |
| 416 |
+#endif |
| 417 |
+#if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS ) |
| 418 |
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS |
| 419 |
+#endif |
| 420 |
+ |
| 421 |
|
| 422 |
// The goal of this macro is to avoid evaluation of the arguments, but |
| 423 |
// still have the compiler warn on problems inside... |
| 424 |
@@ -664,9 +493,6 @@ namespace Catch { |
| 425 |
# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 426 |
#endif |
| 427 |
|
| 428 |
-#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) |
| 429 |
-# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
| 430 |
-#endif |
| 431 |
|
| 432 |
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 433 |
#define CATCH_TRY if ((true)) |
| 434 |
@@ -712,38 +538,31 @@ namespace Catch { |
| 435 |
class IResultCapture; |
| 436 |
class IConfig; |
| 437 |
|
| 438 |
- class IContext { |
| 439 |
- public: |
| 440 |
- virtual ~IContext(); // = default |
| 441 |
+ class Context { |
| 442 |
+ IConfig const* m_config = nullptr; |
| 443 |
+ IResultCapture* m_resultCapture = nullptr; |
| 444 |
|
| 445 |
- virtual IResultCapture* getResultCapture() = 0; |
| 446 |
- virtual IConfig const* getConfig() const = 0; |
| 447 |
- }; |
| 448 |
+ CATCH_EXPORT static Context* currentContext; |
| 449 |
+ friend Context& getCurrentMutableContext(); |
| 450 |
+ friend Context const& getCurrentContext(); |
| 451 |
+ static void createContext(); |
| 452 |
+ friend void cleanUpContext(); |
| 453 |
|
| 454 |
- class IMutableContext : public IContext { |
| 455 |
public: |
| 456 |
- ~IMutableContext() override; // = default |
| 457 |
- virtual void setResultCapture( IResultCapture* resultCapture ) = 0; |
| 458 |
- virtual void setConfig( IConfig const* config ) = 0; |
| 459 |
+ IResultCapture* getResultCapture() const { return m_resultCapture; } |
| 460 |
+ IConfig const* getConfig() const { return m_config; } |
| 461 |
+ void setResultCapture( IResultCapture* resultCapture ); |
| 462 |
+ void setConfig( IConfig const* config ); |
| 463 |
+ }; |
| 464 |
|
| 465 |
- private: |
| 466 |
- CATCH_EXPORT static IMutableContext* currentContext; |
| 467 |
- friend IMutableContext& getCurrentMutableContext(); |
| 468 |
- friend void cleanUpContext(); |
| 469 |
- static void createContext(); |
| 470 |
- }; |
| 471 |
+ Context& getCurrentMutableContext(); |
| 472 |
|
| 473 |
- inline IMutableContext& getCurrentMutableContext() |
| 474 |
- { |
| 475 |
- if( !IMutableContext::currentContext ) |
| 476 |
- IMutableContext::createContext(); |
| 477 |
+ inline Context const& getCurrentContext() { |
| 478 |
+ // We duplicate the logic from `getCurrentMutableContext` here, |
| 479 |
+ // to avoid paying the call overhead in debug mode. |
| 480 |
+ if ( !Context::currentContext ) { Context::createContext(); } |
| 481 |
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) |
| 482 |
- return *IMutableContext::currentContext; |
| 483 |
- } |
| 484 |
- |
| 485 |
- inline IContext& getCurrentContext() |
| 486 |
- { |
| 487 |
- return getCurrentMutableContext(); |
| 488 |
+ return *Context::currentContext; |
| 489 |
} |
| 490 |
|
| 491 |
void cleanUpContext(); |
| 492 |
@@ -755,16 +574,6 @@ namespace Catch { |
| 493 |
#endif // CATCH_CONTEXT_HPP_INCLUDED |
| 494 |
|
| 495 |
|
| 496 |
-#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 497 |
-#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 498 |
- |
| 499 |
- |
| 500 |
- |
| 501 |
-#ifndef CATCH_SECTION_INFO_HPP_INCLUDED |
| 502 |
-#define CATCH_SECTION_INFO_HPP_INCLUDED |
| 503 |
- |
| 504 |
- |
| 505 |
- |
| 506 |
#ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED |
| 507 |
#define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED |
| 508 |
|
| 509 |
@@ -779,109 +588,199 @@ namespace Catch { |
| 510 |
#endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED |
| 511 |
|
| 512 |
|
| 513 |
-#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 514 |
-#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 515 |
- |
| 516 |
-#include <cstddef> |
| 517 |
-#include <iosfwd> |
| 518 |
+#ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 519 |
+#define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 520 |
|
| 521 |
namespace Catch { |
| 522 |
|
| 523 |
- struct SourceLineInfo { |
| 524 |
+ //! Used to signal that an assertion macro failed |
| 525 |
+ struct TestFailureException{}; |
| 526 |
+ //! Used to signal that the remainder of a test should be skipped |
| 527 |
+ struct TestSkipException {}; |
| 528 |
|
| 529 |
- SourceLineInfo() = delete; |
| 530 |
- constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: |
| 531 |
- file( _file ), |
| 532 |
- line( _line ) |
| 533 |
- {} |
| 534 |
+ /** |
| 535 |
+ * Outlines throwing of `TestFailureException` into a single TU |
| 536 |
+ * |
| 537 |
+ * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. |
| 538 |
+ */ |
| 539 |
+ [[noreturn]] void throw_test_failure_exception(); |
| 540 |
|
| 541 |
- bool operator == ( SourceLineInfo const& other ) const noexcept; |
| 542 |
- bool operator < ( SourceLineInfo const& other ) const noexcept; |
| 543 |
+ /** |
| 544 |
+ * Outlines throwing of `TestSkipException` into a single TU |
| 545 |
+ * |
| 546 |
+ * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. |
| 547 |
+ */ |
| 548 |
+ [[noreturn]] void throw_test_skip_exception(); |
| 549 |
|
| 550 |
- char const* file; |
| 551 |
- std::size_t line; |
| 552 |
+} // namespace Catch |
| 553 |
|
| 554 |
- friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); |
| 555 |
- }; |
| 556 |
-} |
| 557 |
+#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 558 |
|
| 559 |
-#define CATCH_INTERNAL_LINEINFO \ |
| 560 |
- ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) |
| 561 |
|
| 562 |
-#endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 563 |
+#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 564 |
+#define CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 565 |
|
| 566 |
|
| 567 |
-#ifndef CATCH_TOTALS_HPP_INCLUDED |
| 568 |
-#define CATCH_TOTALS_HPP_INCLUDED |
| 569 |
|
| 570 |
-#include <cstdint> |
| 571 |
|
| 572 |
-namespace Catch { |
| 573 |
+/** \file |
| 574 |
+ * Wrapper for the CONFIG configuration option |
| 575 |
+ * |
| 576 |
+ * When generating internal unique names, there are two options. Either |
| 577 |
+ * we mix in the current line number, or mix in an incrementing number. |
| 578 |
+ * We prefer the latter, using `__COUNTER__`, but users might want to |
| 579 |
+ * use the former. |
| 580 |
+ */ |
| 581 |
|
| 582 |
- struct Counts { |
| 583 |
- Counts operator - ( Counts const& other ) const; |
| 584 |
- Counts& operator += ( Counts const& other ); |
| 585 |
+#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 586 |
+#define CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 587 |
|
| 588 |
- std::uint64_t total() const; |
| 589 |
- bool allPassed() const; |
| 590 |
- bool allOk() const; |
| 591 |
|
| 592 |
- std::uint64_t passed = 0; |
| 593 |
- std::uint64_t failed = 0; |
| 594 |
- std::uint64_t failedButOk = 0; |
| 595 |
- }; |
| 596 |
+#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) |
| 597 |
+ #define CATCH_INTERNAL_CONFIG_COUNTER |
| 598 |
+#endif |
| 599 |
|
| 600 |
- struct Totals { |
| 601 |
+#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ |
| 602 |
+ !defined( CATCH_CONFIG_NO_COUNTER ) && \ |
| 603 |
+ !defined( CATCH_CONFIG_COUNTER ) |
| 604 |
+# define CATCH_CONFIG_COUNTER |
| 605 |
+#endif |
| 606 |
|
| 607 |
- Totals operator - ( Totals const& other ) const; |
| 608 |
- Totals& operator += ( Totals const& other ); |
| 609 |
|
| 610 |
- Totals delta( Totals const& prevTotals ) const; |
| 611 |
+#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 612 |
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line |
| 613 |
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) |
| 614 |
+#ifdef CATCH_CONFIG_COUNTER |
| 615 |
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) |
| 616 |
+#else |
| 617 |
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) |
| 618 |
+#endif |
| 619 |
|
| 620 |
- Counts assertions; |
| 621 |
- Counts testCases; |
| 622 |
- }; |
| 623 |
-} |
| 624 |
+#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 625 |
|
| 626 |
-#endif // CATCH_TOTALS_HPP_INCLUDED |
| 627 |
|
| 628 |
+#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 629 |
+#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 630 |
+ |
| 631 |
+#include <string> |
| 632 |
+#include <chrono> |
| 633 |
+ |
| 634 |
+ |
| 635 |
+ |
| 636 |
+#ifndef CATCH_STRINGREF_HPP_INCLUDED |
| 637 |
+#define CATCH_STRINGREF_HPP_INCLUDED |
| 638 |
+ |
| 639 |
+#include <cstddef> |
| 640 |
#include <string> |
| 641 |
+#include <iosfwd> |
| 642 |
+#include <cassert> |
| 643 |
+ |
| 644 |
+#include <cstring> |
| 645 |
|
| 646 |
namespace Catch { |
| 647 |
|
| 648 |
- struct SectionInfo { |
| 649 |
- // The last argument is ignored, so that people can write |
| 650 |
- // SECTION("ShortName", "Proper description that is long") and |
| 651 |
- // still use the `-c` flag comfortably. |
| 652 |
- SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, |
| 653 |
- const char* const = nullptr ): |
| 654 |
- name(CATCH_MOVE(_name)), |
| 655 |
- lineInfo(_lineInfo) |
| 656 |
- {} |
| 657 |
+ /// A non-owning string class (similar to the forthcoming std::string_view) |
| 658 |
+ /// Note that, because a StringRef may be a substring of another string, |
| 659 |
+ /// it may not be null terminated. |
| 660 |
+ class StringRef { |
| 661 |
+ public: |
| 662 |
+ using size_type = std::size_t; |
| 663 |
+ using const_iterator = const char*; |
| 664 |
|
| 665 |
- std::string name; |
| 666 |
- SourceLineInfo lineInfo; |
| 667 |
- }; |
| 668 |
+ private: |
| 669 |
+ static constexpr char const* const s_empty = ""; |
| 670 |
|
| 671 |
- struct SectionEndInfo { |
| 672 |
- SectionInfo sectionInfo; |
| 673 |
- Counts prevAssertions; |
| 674 |
- double durationInSeconds; |
| 675 |
- }; |
| 676 |
+ char const* m_start = s_empty; |
| 677 |
+ size_type m_size = 0; |
| 678 |
|
| 679 |
-} // end namespace Catch |
| 680 |
+ public: // construction |
| 681 |
+ constexpr StringRef() noexcept = default; |
| 682 |
|
| 683 |
-#endif // CATCH_SECTION_INFO_HPP_INCLUDED |
| 684 |
+ StringRef( char const* rawChars ) noexcept; |
| 685 |
|
| 686 |
+ constexpr StringRef( char const* rawChars, size_type size ) noexcept |
| 687 |
+ : m_start( rawChars ), |
| 688 |
+ m_size( size ) |
| 689 |
+ {} |
| 690 |
|
| 691 |
-#ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 692 |
-#define CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 693 |
+ StringRef( std::string const& stdString ) noexcept |
| 694 |
+ : m_start( stdString.c_str() ), |
| 695 |
+ m_size( stdString.size() ) |
| 696 |
+ {} |
| 697 |
|
| 698 |
+ explicit operator std::string() const { |
| 699 |
+ return std::string(m_start, m_size); |
| 700 |
+ } |
| 701 |
|
| 702 |
+ public: // operators |
| 703 |
+ auto operator == ( StringRef other ) const noexcept -> bool { |
| 704 |
+ return m_size == other.m_size |
| 705 |
+ && (std::memcmp( m_start, other.m_start, m_size ) == 0); |
| 706 |
+ } |
| 707 |
+ auto operator != (StringRef other) const noexcept -> bool { |
| 708 |
+ return !(*this == other); |
| 709 |
+ } |
| 710 |
|
| 711 |
-#ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 712 |
-#define CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 713 |
+ constexpr auto operator[] ( size_type index ) const noexcept -> char { |
| 714 |
+ assert(index < m_size); |
| 715 |
+ return m_start[index]; |
| 716 |
+ } |
| 717 |
+ |
| 718 |
+ bool operator<(StringRef rhs) const noexcept; |
| 719 |
+ |
| 720 |
+ public: // named queries |
| 721 |
+ constexpr auto empty() const noexcept -> bool { |
| 722 |
+ return m_size == 0; |
| 723 |
+ } |
| 724 |
+ constexpr auto size() const noexcept -> size_type { |
| 725 |
+ return m_size; |
| 726 |
+ } |
| 727 |
+ |
| 728 |
+ // Returns a substring of [start, start + length). |
| 729 |
+ // If start + length > size(), then the substring is [start, start + size()). |
| 730 |
+ // If start > size(), then the substring is empty. |
| 731 |
+ constexpr StringRef substr(size_type start, size_type length) const noexcept { |
| 732 |
+ if (start < m_size) { |
| 733 |
+ const auto shortened_size = m_size - start; |
| 734 |
+ return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length); |
| 735 |
+ } else { |
| 736 |
+ return StringRef(); |
| 737 |
+ } |
| 738 |
+ } |
| 739 |
+ |
| 740 |
+ // Returns the current start pointer. May not be null-terminated. |
| 741 |
+ constexpr char const* data() const noexcept { |
| 742 |
+ return m_start; |
| 743 |
+ } |
| 744 |
+ |
| 745 |
+ constexpr const_iterator begin() const { return m_start; } |
| 746 |
+ constexpr const_iterator end() const { return m_start + m_size; } |
| 747 |
+ |
| 748 |
+ |
| 749 |
+ friend std::string& operator += (std::string& lhs, StringRef sr); |
| 750 |
+ friend std::ostream& operator << (std::ostream& os, StringRef sr); |
| 751 |
+ friend std::string operator+(StringRef lhs, StringRef rhs); |
| 752 |
+ |
| 753 |
+ /** |
| 754 |
+ * Provides a three-way comparison with rhs |
| 755 |
+ * |
| 756 |
+ * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive |
| 757 |
+ * number if lhs > rhs |
| 758 |
+ */ |
| 759 |
+ int compare( StringRef rhs ) const; |
| 760 |
+ }; |
| 761 |
+ |
| 762 |
+ |
| 763 |
+ constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { |
| 764 |
+ return StringRef( rawChars, size ); |
| 765 |
+ } |
| 766 |
+} // namespace Catch |
| 767 |
+ |
| 768 |
+constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { |
| 769 |
+ return Catch::StringRef( rawChars, size ); |
| 770 |
+} |
| 771 |
|
| 772 |
+#endif // CATCH_STRINGREF_HPP_INCLUDED |
| 773 |
|
| 774 |
|
| 775 |
#ifndef CATCH_RESULT_TYPE_HPP_INCLUDED |
| 776 |
@@ -895,6 +794,8 @@ namespace Catch { |
| 777 |
Ok = 0, |
| 778 |
Info = 1, |
| 779 |
Warning = 2, |
| 780 |
+ // TODO: Should explicit skip be considered "not OK" (cf. isOk)? I.e., should it have the failure bit? |
| 781 |
+ ExplicitSkip = 4, |
| 782 |
|
| 783 |
FailureBit = 0x10, |
| 784 |
|
| 785 |
@@ -933,230 +834,12 @@ namespace Catch { |
| 786 |
|
| 787 |
#endif // CATCH_RESULT_TYPE_HPP_INCLUDED |
| 788 |
|
| 789 |
-namespace Catch { |
| 790 |
- |
| 791 |
- struct AssertionInfo { |
| 792 |
- // AssertionInfo() = delete; |
| 793 |
- |
| 794 |
- StringRef macroName; |
| 795 |
- SourceLineInfo lineInfo; |
| 796 |
- StringRef capturedExpression; |
| 797 |
- ResultDisposition::Flags resultDisposition; |
| 798 |
- }; |
| 799 |
- |
| 800 |
-} // end namespace Catch |
| 801 |
- |
| 802 |
-#endif // CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 803 |
|
| 804 |
+#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED |
| 805 |
+#define CATCH_UNIQUE_PTR_HPP_INCLUDED |
| 806 |
|
| 807 |
-#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED |
| 808 |
-#define CATCH_LAZY_EXPR_HPP_INCLUDED |
| 809 |
- |
| 810 |
-#include <iosfwd> |
| 811 |
- |
| 812 |
-namespace Catch { |
| 813 |
- |
| 814 |
- class ITransientExpression; |
| 815 |
- |
| 816 |
- class LazyExpression { |
| 817 |
- friend class AssertionHandler; |
| 818 |
- friend struct AssertionStats; |
| 819 |
- friend class RunContext; |
| 820 |
- |
| 821 |
- ITransientExpression const* m_transientExpression = nullptr; |
| 822 |
- bool m_isNegated; |
| 823 |
- public: |
| 824 |
- LazyExpression( bool isNegated ): |
| 825 |
- m_isNegated(isNegated) |
| 826 |
- {} |
| 827 |
- LazyExpression(LazyExpression const& other) = default; |
| 828 |
- LazyExpression& operator = ( LazyExpression const& ) = delete; |
| 829 |
- |
| 830 |
- explicit operator bool() const { |
| 831 |
- return m_transientExpression != nullptr; |
| 832 |
- } |
| 833 |
- |
| 834 |
- friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; |
| 835 |
- }; |
| 836 |
- |
| 837 |
-} // namespace Catch |
| 838 |
- |
| 839 |
-#endif // CATCH_LAZY_EXPR_HPP_INCLUDED |
| 840 |
- |
| 841 |
-#include <string> |
| 842 |
- |
| 843 |
-namespace Catch { |
| 844 |
- |
| 845 |
- struct AssertionResultData |
| 846 |
- { |
| 847 |
- AssertionResultData() = delete; |
| 848 |
- |
| 849 |
- AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); |
| 850 |
- |
| 851 |
- std::string message; |
| 852 |
- mutable std::string reconstructedExpression; |
| 853 |
- LazyExpression lazyExpression; |
| 854 |
- ResultWas::OfType resultType; |
| 855 |
- |
| 856 |
- std::string reconstructExpression() const; |
| 857 |
- }; |
| 858 |
- |
| 859 |
- class AssertionResult { |
| 860 |
- public: |
| 861 |
- AssertionResult() = delete; |
| 862 |
- AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); |
| 863 |
- |
| 864 |
- bool isOk() const; |
| 865 |
- bool succeeded() const; |
| 866 |
- ResultWas::OfType getResultType() const; |
| 867 |
- bool hasExpression() const; |
| 868 |
- bool hasMessage() const; |
| 869 |
- std::string getExpression() const; |
| 870 |
- std::string getExpressionInMacro() const; |
| 871 |
- bool hasExpandedExpression() const; |
| 872 |
- std::string getExpandedExpression() const; |
| 873 |
- StringRef getMessage() const; |
| 874 |
- SourceLineInfo getSourceInfo() const; |
| 875 |
- StringRef getTestMacroName() const; |
| 876 |
- |
| 877 |
- //protected: |
| 878 |
- AssertionInfo m_info; |
| 879 |
- AssertionResultData m_resultData; |
| 880 |
- }; |
| 881 |
- |
| 882 |
-} // end namespace Catch |
| 883 |
- |
| 884 |
-#endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 885 |
- |
| 886 |
- |
| 887 |
-#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 888 |
-#define CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 889 |
- |
| 890 |
- |
| 891 |
- |
| 892 |
-#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 893 |
-#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 894 |
- |
| 895 |
-#include <string> |
| 896 |
-#include <chrono> |
| 897 |
- |
| 898 |
- |
| 899 |
-namespace Catch { |
| 900 |
- |
| 901 |
- class AssertionResult; |
| 902 |
- struct AssertionInfo; |
| 903 |
- struct SectionInfo; |
| 904 |
- struct SectionEndInfo; |
| 905 |
- struct MessageInfo; |
| 906 |
- struct MessageBuilder; |
| 907 |
- struct Counts; |
| 908 |
- struct AssertionReaction; |
| 909 |
- struct SourceLineInfo; |
| 910 |
- |
| 911 |
- class ITransientExpression; |
| 912 |
- class IGeneratorTracker; |
| 913 |
- |
| 914 |
- struct BenchmarkInfo; |
| 915 |
- template <typename Duration = std::chrono::duration<double, std::nano>> |
| 916 |
- struct BenchmarkStats; |
| 917 |
- |
| 918 |
- class IResultCapture { |
| 919 |
- public: |
| 920 |
- virtual ~IResultCapture(); |
| 921 |
- |
| 922 |
- virtual bool sectionStarted( SectionInfo const& sectionInfo, |
| 923 |
- Counts& assertions ) = 0; |
| 924 |
- virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; |
| 925 |
- virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; |
| 926 |
- |
| 927 |
- virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; |
| 928 |
- |
| 929 |
- virtual void benchmarkPreparing( StringRef name ) = 0; |
| 930 |
- virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; |
| 931 |
- virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; |
| 932 |
- virtual void benchmarkFailed( StringRef error ) = 0; |
| 933 |
- |
| 934 |
- virtual void pushScopedMessage( MessageInfo const& message ) = 0; |
| 935 |
- virtual void popScopedMessage( MessageInfo const& message ) = 0; |
| 936 |
- |
| 937 |
- virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0; |
| 938 |
- |
| 939 |
- virtual void handleFatalErrorCondition( StringRef message ) = 0; |
| 940 |
- |
| 941 |
- virtual void handleExpr |
| 942 |
- ( AssertionInfo const& info, |
| 943 |
- ITransientExpression const& expr, |
| 944 |
- AssertionReaction& reaction ) = 0; |
| 945 |
- virtual void handleMessage |
| 946 |
- ( AssertionInfo const& info, |
| 947 |
- ResultWas::OfType resultType, |
| 948 |
- StringRef message, |
| 949 |
- AssertionReaction& reaction ) = 0; |
| 950 |
- virtual void handleUnexpectedExceptionNotThrown |
| 951 |
- ( AssertionInfo const& info, |
| 952 |
- AssertionReaction& reaction ) = 0; |
| 953 |
- virtual void handleUnexpectedInflightException |
| 954 |
- ( AssertionInfo const& info, |
| 955 |
- std::string const& message, |
| 956 |
- AssertionReaction& reaction ) = 0; |
| 957 |
- virtual void handleIncomplete |
| 958 |
- ( AssertionInfo const& info ) = 0; |
| 959 |
- virtual void handleNonExpr |
| 960 |
- ( AssertionInfo const &info, |
| 961 |
- ResultWas::OfType resultType, |
| 962 |
- AssertionReaction &reaction ) = 0; |
| 963 |
- |
| 964 |
- |
| 965 |
- |
| 966 |
- virtual bool lastAssertionPassed() = 0; |
| 967 |
- virtual void assertionPassed() = 0; |
| 968 |
- |
| 969 |
- // Deprecated, do not use: |
| 970 |
- virtual std::string getCurrentTestName() const = 0; |
| 971 |
- virtual const AssertionResult* getLastResult() const = 0; |
| 972 |
- virtual void exceptionEarlyReported() = 0; |
| 973 |
- }; |
| 974 |
- |
| 975 |
- IResultCapture& getResultCapture(); |
| 976 |
-} |
| 977 |
- |
| 978 |
-#endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 979 |
- |
| 980 |
-#include <string> |
| 981 |
- |
| 982 |
-namespace Catch { |
| 983 |
- |
| 984 |
- struct MessageInfo { |
| 985 |
- MessageInfo( StringRef _macroName, |
| 986 |
- SourceLineInfo const& _lineInfo, |
| 987 |
- ResultWas::OfType _type ); |
| 988 |
- |
| 989 |
- StringRef macroName; |
| 990 |
- std::string message; |
| 991 |
- SourceLineInfo lineInfo; |
| 992 |
- ResultWas::OfType type; |
| 993 |
- unsigned int sequence; |
| 994 |
- |
| 995 |
- bool operator == (MessageInfo const& other) const { |
| 996 |
- return sequence == other.sequence; |
| 997 |
- } |
| 998 |
- bool operator < (MessageInfo const& other) const { |
| 999 |
- return sequence < other.sequence; |
| 1000 |
- } |
| 1001 |
- private: |
| 1002 |
- static unsigned int globalCount; |
| 1003 |
- }; |
| 1004 |
- |
| 1005 |
-} // end namespace Catch |
| 1006 |
- |
| 1007 |
-#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 1008 |
- |
| 1009 |
- |
| 1010 |
-#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED |
| 1011 |
-#define CATCH_UNIQUE_PTR_HPP_INCLUDED |
| 1012 |
- |
| 1013 |
-#include <cassert> |
| 1014 |
-#include <type_traits> |
| 1015 |
+#include <cassert> |
| 1016 |
+#include <type_traits> |
| 1017 |
|
| 1018 |
|
| 1019 |
namespace Catch { |
| 1020 |
@@ -1264,346 +947,395 @@ namespace Detail { |
| 1021 |
#endif // CATCH_UNIQUE_PTR_HPP_INCLUDED |
| 1022 |
|
| 1023 |
|
| 1024 |
-// Adapted from donated nonius code. |
| 1025 |
+#ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED |
| 1026 |
+#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED |
| 1027 |
|
| 1028 |
-#ifndef CATCH_ESTIMATE_HPP_INCLUDED |
| 1029 |
-#define CATCH_ESTIMATE_HPP_INCLUDED |
| 1030 |
+#include <chrono> |
| 1031 |
|
| 1032 |
namespace Catch { |
| 1033 |
- namespace Benchmark { |
| 1034 |
- template <typename Duration> |
| 1035 |
- struct Estimate { |
| 1036 |
- Duration point; |
| 1037 |
- Duration lower_bound; |
| 1038 |
- Duration upper_bound; |
| 1039 |
- double confidence_interval; |
| 1040 |
- |
| 1041 |
- template <typename Duration2> |
| 1042 |
- operator Estimate<Duration2>() const { |
| 1043 |
- return { point, lower_bound, upper_bound, confidence_interval }; |
| 1044 |
- } |
| 1045 |
- }; |
| 1046 |
- } // namespace Benchmark |
| 1047 |
-} // namespace Catch |
| 1048 |
- |
| 1049 |
-#endif // CATCH_ESTIMATE_HPP_INCLUDED |
| 1050 |
|
| 1051 |
+ // We cannot forward declare the type with default template argument |
| 1052 |
+ // multiple times, so it is split out into a separate header so that |
| 1053 |
+ // we can prevent multiple declarations in dependees |
| 1054 |
+ template <typename Duration = std::chrono::duration<double, std::nano>> |
| 1055 |
+ struct BenchmarkStats; |
| 1056 |
|
| 1057 |
-// Adapted from donated nonius code. |
| 1058 |
+} // end namespace Catch |
| 1059 |
|
| 1060 |
-#ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED |
| 1061 |
-#define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED |
| 1062 |
+#endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED |
| 1063 |
|
| 1064 |
namespace Catch { |
| 1065 |
- namespace Benchmark { |
| 1066 |
- struct OutlierClassification { |
| 1067 |
- int samples_seen = 0; |
| 1068 |
- int low_severe = 0; // more than 3 times IQR below Q1 |
| 1069 |
- int low_mild = 0; // 1.5 to 3 times IQR below Q1 |
| 1070 |
- int high_mild = 0; // 1.5 to 3 times IQR above Q3 |
| 1071 |
- int high_severe = 0; // more than 3 times IQR above Q3 |
| 1072 |
|
| 1073 |
- int total() const { |
| 1074 |
- return low_severe + low_mild + high_mild + high_severe; |
| 1075 |
- } |
| 1076 |
- }; |
| 1077 |
- } // namespace Benchmark |
| 1078 |
-} // namespace Catch |
| 1079 |
+ class AssertionResult; |
| 1080 |
+ struct AssertionInfo; |
| 1081 |
+ struct SectionInfo; |
| 1082 |
+ struct SectionEndInfo; |
| 1083 |
+ struct MessageInfo; |
| 1084 |
+ struct MessageBuilder; |
| 1085 |
+ struct Counts; |
| 1086 |
+ struct AssertionReaction; |
| 1087 |
+ struct SourceLineInfo; |
| 1088 |
|
| 1089 |
-#endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED |
| 1090 |
+ class ITransientExpression; |
| 1091 |
+ class IGeneratorTracker; |
| 1092 |
|
| 1093 |
+ struct BenchmarkInfo; |
| 1094 |
|
| 1095 |
-#include <map> |
| 1096 |
-#include <string> |
| 1097 |
-#include <vector> |
| 1098 |
-#include <iosfwd> |
| 1099 |
+ namespace Generators { |
| 1100 |
+ class GeneratorUntypedBase; |
| 1101 |
+ using GeneratorBasePtr = Catch::Detail::unique_ptr<GeneratorUntypedBase>; |
| 1102 |
+ } |
| 1103 |
|
| 1104 |
-namespace Catch { |
| 1105 |
|
| 1106 |
- struct ReporterDescription; |
| 1107 |
- struct ListenerDescription; |
| 1108 |
- struct TagInfo; |
| 1109 |
- struct TestCaseInfo; |
| 1110 |
- class TestCaseHandle; |
| 1111 |
- class IConfig; |
| 1112 |
- class IStream; |
| 1113 |
- enum class ColourMode : std::uint8_t; |
| 1114 |
+ class IResultCapture { |
| 1115 |
+ public: |
| 1116 |
+ virtual ~IResultCapture(); |
| 1117 |
|
| 1118 |
- struct ReporterConfig { |
| 1119 |
- ReporterConfig( IConfig const* _fullConfig, |
| 1120 |
- Detail::unique_ptr<IStream> _stream, |
| 1121 |
- ColourMode colourMode, |
| 1122 |
- std::map<std::string, std::string> customOptions ); |
| 1123 |
+ virtual void notifyAssertionStarted( AssertionInfo const& info ) = 0; |
| 1124 |
+ virtual bool sectionStarted( StringRef sectionName, |
| 1125 |
+ SourceLineInfo const& sectionLineInfo, |
| 1126 |
+ Counts& assertions ) = 0; |
| 1127 |
+ virtual void sectionEnded( SectionEndInfo&& endInfo ) = 0; |
| 1128 |
+ virtual void sectionEndedEarly( SectionEndInfo&& endInfo ) = 0; |
| 1129 |
+ |
| 1130 |
+ virtual IGeneratorTracker* |
| 1131 |
+ acquireGeneratorTracker( StringRef generatorName, |
| 1132 |
+ SourceLineInfo const& lineInfo ) = 0; |
| 1133 |
+ virtual IGeneratorTracker* |
| 1134 |
+ createGeneratorTracker( StringRef generatorName, |
| 1135 |
+ SourceLineInfo lineInfo, |
| 1136 |
+ Generators::GeneratorBasePtr&& generator ) = 0; |
| 1137 |
|
| 1138 |
- ReporterConfig( ReporterConfig&& ) = default; |
| 1139 |
- ReporterConfig& operator=( ReporterConfig&& ) = default; |
| 1140 |
- ~ReporterConfig(); // = default |
| 1141 |
+ virtual void benchmarkPreparing( StringRef name ) = 0; |
| 1142 |
+ virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; |
| 1143 |
+ virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; |
| 1144 |
+ virtual void benchmarkFailed( StringRef error ) = 0; |
| 1145 |
|
| 1146 |
- Detail::unique_ptr<IStream> takeStream() &&; |
| 1147 |
- IConfig const* fullConfig() const; |
| 1148 |
- ColourMode colourMode() const; |
| 1149 |
- std::map<std::string, std::string> const& customOptions() const; |
| 1150 |
+ virtual void pushScopedMessage( MessageInfo const& message ) = 0; |
| 1151 |
+ virtual void popScopedMessage( MessageInfo const& message ) = 0; |
| 1152 |
|
| 1153 |
- private: |
| 1154 |
- Detail::unique_ptr<IStream> m_stream; |
| 1155 |
- IConfig const* m_fullConfig; |
| 1156 |
- ColourMode m_colourMode; |
| 1157 |
- std::map<std::string, std::string> m_customOptions; |
| 1158 |
- }; |
| 1159 |
+ virtual void emplaceUnscopedMessage( MessageBuilder&& builder ) = 0; |
| 1160 |
|
| 1161 |
- struct TestRunInfo { |
| 1162 |
- constexpr TestRunInfo(StringRef _name) : name(_name) {} |
| 1163 |
- StringRef name; |
| 1164 |
- }; |
| 1165 |
+ virtual void handleFatalErrorCondition( StringRef message ) = 0; |
| 1166 |
|
| 1167 |
- struct AssertionStats { |
| 1168 |
- AssertionStats( AssertionResult const& _assertionResult, |
| 1169 |
- std::vector<MessageInfo> const& _infoMessages, |
| 1170 |
- Totals const& _totals ); |
| 1171 |
+ virtual void handleExpr |
| 1172 |
+ ( AssertionInfo const& info, |
| 1173 |
+ ITransientExpression const& expr, |
| 1174 |
+ AssertionReaction& reaction ) = 0; |
| 1175 |
+ virtual void handleMessage |
| 1176 |
+ ( AssertionInfo const& info, |
| 1177 |
+ ResultWas::OfType resultType, |
| 1178 |
+ StringRef message, |
| 1179 |
+ AssertionReaction& reaction ) = 0; |
| 1180 |
+ virtual void handleUnexpectedExceptionNotThrown |
| 1181 |
+ ( AssertionInfo const& info, |
| 1182 |
+ AssertionReaction& reaction ) = 0; |
| 1183 |
+ virtual void handleUnexpectedInflightException |
| 1184 |
+ ( AssertionInfo const& info, |
| 1185 |
+ std::string&& message, |
| 1186 |
+ AssertionReaction& reaction ) = 0; |
| 1187 |
+ virtual void handleIncomplete |
| 1188 |
+ ( AssertionInfo const& info ) = 0; |
| 1189 |
+ virtual void handleNonExpr |
| 1190 |
+ ( AssertionInfo const &info, |
| 1191 |
+ ResultWas::OfType resultType, |
| 1192 |
+ AssertionReaction &reaction ) = 0; |
| 1193 |
|
| 1194 |
- AssertionStats( AssertionStats const& ) = default; |
| 1195 |
- AssertionStats( AssertionStats && ) = default; |
| 1196 |
- AssertionStats& operator = ( AssertionStats const& ) = delete; |
| 1197 |
- AssertionStats& operator = ( AssertionStats && ) = delete; |
| 1198 |
|
| 1199 |
- AssertionResult assertionResult; |
| 1200 |
- std::vector<MessageInfo> infoMessages; |
| 1201 |
- Totals totals; |
| 1202 |
- }; |
| 1203 |
|
| 1204 |
- struct SectionStats { |
| 1205 |
- SectionStats( SectionInfo const& _sectionInfo, |
| 1206 |
- Counts const& _assertions, |
| 1207 |
- double _durationInSeconds, |
| 1208 |
- bool _missingAssertions ); |
| 1209 |
+ virtual bool lastAssertionPassed() = 0; |
| 1210 |
+ virtual void assertionPassed() = 0; |
| 1211 |
|
| 1212 |
- SectionInfo sectionInfo; |
| 1213 |
- Counts assertions; |
| 1214 |
- double durationInSeconds; |
| 1215 |
- bool missingAssertions; |
| 1216 |
+ // Deprecated, do not use: |
| 1217 |
+ virtual std::string getCurrentTestName() const = 0; |
| 1218 |
+ virtual const AssertionResult* getLastResult() const = 0; |
| 1219 |
+ virtual void exceptionEarlyReported() = 0; |
| 1220 |
}; |
| 1221 |
|
| 1222 |
- struct TestCaseStats { |
| 1223 |
- TestCaseStats( TestCaseInfo const& _testInfo, |
| 1224 |
- Totals const& _totals, |
| 1225 |
- std::string const& _stdOut, |
| 1226 |
- std::string const& _stdErr, |
| 1227 |
- bool _aborting ); |
| 1228 |
+ IResultCapture& getResultCapture(); |
| 1229 |
+} |
| 1230 |
|
| 1231 |
- TestCaseInfo const * testInfo; |
| 1232 |
- Totals totals; |
| 1233 |
- std::string stdOut; |
| 1234 |
- std::string stdErr; |
| 1235 |
- bool aborting; |
| 1236 |
- }; |
| 1237 |
+#endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED |
| 1238 |
|
| 1239 |
- struct TestRunStats { |
| 1240 |
- TestRunStats( TestRunInfo const& _runInfo, |
| 1241 |
- Totals const& _totals, |
| 1242 |
- bool _aborting ); |
| 1243 |
|
| 1244 |
- TestRunInfo runInfo; |
| 1245 |
- Totals totals; |
| 1246 |
- bool aborting; |
| 1247 |
- }; |
| 1248 |
+#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 1249 |
+#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 1250 |
|
| 1251 |
|
| 1252 |
- struct BenchmarkInfo { |
| 1253 |
- std::string name; |
| 1254 |
- double estimatedDuration; |
| 1255 |
- int iterations; |
| 1256 |
- unsigned int samples; |
| 1257 |
- unsigned int resamples; |
| 1258 |
- double clockResolution; |
| 1259 |
- double clockCost; |
| 1260 |
- }; |
| 1261 |
|
| 1262 |
- template <class Duration> |
| 1263 |
- struct BenchmarkStats { |
| 1264 |
- BenchmarkInfo info; |
| 1265 |
+#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED |
| 1266 |
+#define CATCH_NONCOPYABLE_HPP_INCLUDED |
| 1267 |
|
| 1268 |
- std::vector<Duration> samples; |
| 1269 |
- Benchmark::Estimate<Duration> mean; |
| 1270 |
- Benchmark::Estimate<Duration> standardDeviation; |
| 1271 |
- Benchmark::OutlierClassification outliers; |
| 1272 |
- double outlierVariance; |
| 1273 |
+namespace Catch { |
| 1274 |
+ namespace Detail { |
| 1275 |
|
| 1276 |
- template <typename Duration2> |
| 1277 |
- operator BenchmarkStats<Duration2>() const { |
| 1278 |
- std::vector<Duration2> samples2; |
| 1279 |
- samples2.reserve(samples.size()); |
| 1280 |
- for (auto const& sample : samples) { |
| 1281 |
- samples2.push_back(Duration2(sample)); |
| 1282 |
- } |
| 1283 |
- return { |
| 1284 |
- info, |
| 1285 |
- CATCH_MOVE(samples2), |
| 1286 |
- mean, |
| 1287 |
- standardDeviation, |
| 1288 |
- outliers, |
| 1289 |
- outlierVariance, |
| 1290 |
- }; |
| 1291 |
- } |
| 1292 |
+ //! Deriving classes become noncopyable and nonmovable |
| 1293 |
+ class NonCopyable { |
| 1294 |
+ NonCopyable( NonCopyable const& ) = delete; |
| 1295 |
+ NonCopyable( NonCopyable&& ) = delete; |
| 1296 |
+ NonCopyable& operator=( NonCopyable const& ) = delete; |
| 1297 |
+ NonCopyable& operator=( NonCopyable&& ) = delete; |
| 1298 |
+ |
| 1299 |
+ protected: |
| 1300 |
+ NonCopyable() noexcept = default; |
| 1301 |
+ }; |
| 1302 |
+ |
| 1303 |
+ } // namespace Detail |
| 1304 |
+} // namespace Catch |
| 1305 |
+ |
| 1306 |
+#endif // CATCH_NONCOPYABLE_HPP_INCLUDED |
| 1307 |
+ |
| 1308 |
+#include <chrono> |
| 1309 |
+#include <iosfwd> |
| 1310 |
+#include <string> |
| 1311 |
+#include <vector> |
| 1312 |
+ |
| 1313 |
+namespace Catch { |
| 1314 |
+ |
| 1315 |
+ enum class Verbosity { |
| 1316 |
+ Quiet = 0, |
| 1317 |
+ Normal, |
| 1318 |
+ High |
| 1319 |
}; |
| 1320 |
|
| 1321 |
- //! By setting up its preferences, a reporter can modify Catch2's behaviour |
| 1322 |
- //! in some regards, e.g. it can request Catch2 to capture writes to |
| 1323 |
- //! stdout/stderr during test execution, and pass them to the reporter. |
| 1324 |
- struct ReporterPreferences { |
| 1325 |
- //! Catch2 should redirect writes to stdout and pass them to the |
| 1326 |
- //! reporter |
| 1327 |
- bool shouldRedirectStdOut = false; |
| 1328 |
- //! Catch2 should call `Reporter::assertionEnded` even for passing |
| 1329 |
- //! assertions |
| 1330 |
- bool shouldReportAllAssertions = false; |
| 1331 |
+ struct WarnAbout { enum What { |
| 1332 |
+ Nothing = 0x00, |
| 1333 |
+ //! A test case or leaf section did not run any assertions |
| 1334 |
+ NoAssertions = 0x01, |
| 1335 |
+ //! A command line test spec matched no test cases |
| 1336 |
+ UnmatchedTestSpec = 0x02, |
| 1337 |
+ }; }; |
| 1338 |
+ |
| 1339 |
+ enum class ShowDurations { |
| 1340 |
+ DefaultForReporter, |
| 1341 |
+ Always, |
| 1342 |
+ Never |
| 1343 |
+ }; |
| 1344 |
+ enum class TestRunOrder { |
| 1345 |
+ Declared, |
| 1346 |
+ LexicographicallySorted, |
| 1347 |
+ Randomized |
| 1348 |
+ }; |
| 1349 |
+ enum class ColourMode : std::uint8_t { |
| 1350 |
+ //! Let Catch2 pick implementation based on platform detection |
| 1351 |
+ PlatformDefault, |
| 1352 |
+ //! Use ANSI colour code escapes |
| 1353 |
+ ANSI, |
| 1354 |
+ //! Use Win32 console colour API |
| 1355 |
+ Win32, |
| 1356 |
+ //! Don't use any colour |
| 1357 |
+ None |
| 1358 |
}; |
| 1359 |
+ struct WaitForKeypress { enum When { |
| 1360 |
+ Never, |
| 1361 |
+ BeforeStart = 1, |
| 1362 |
+ BeforeExit = 2, |
| 1363 |
+ BeforeStartAndExit = BeforeStart | BeforeExit |
| 1364 |
+ }; }; |
| 1365 |
|
| 1366 |
- /** |
| 1367 |
- * The common base for all reporters and event listeners |
| 1368 |
- * |
| 1369 |
- * Implementing classes must also implement: |
| 1370 |
- * |
| 1371 |
- * //! User-friendly description of the reporter/listener type |
| 1372 |
- * static std::string getDescription() |
| 1373 |
- * |
| 1374 |
- * Generally shouldn't be derived from by users of Catch2 directly, |
| 1375 |
- * instead they should derive from one of the utility bases that |
| 1376 |
- * derive from this class. |
| 1377 |
- */ |
| 1378 |
- class IEventListener { |
| 1379 |
- protected: |
| 1380 |
- //! Derived classes can set up their preferences here |
| 1381 |
- ReporterPreferences m_preferences; |
| 1382 |
- //! The test run's config as filled in from CLI and defaults |
| 1383 |
- IConfig const* m_config; |
| 1384 |
+ class TestSpec; |
| 1385 |
+ class IStream; |
| 1386 |
|
| 1387 |
+ class IConfig : public Detail::NonCopyable { |
| 1388 |
public: |
| 1389 |
- IEventListener( IConfig const* config ): m_config( config ) {} |
| 1390 |
+ virtual ~IConfig(); |
| 1391 |
|
| 1392 |
- virtual ~IEventListener(); // = default; |
| 1393 |
+ virtual bool allowThrows() const = 0; |
| 1394 |
+ virtual StringRef name() const = 0; |
| 1395 |
+ virtual bool includeSuccessfulResults() const = 0; |
| 1396 |
+ virtual bool shouldDebugBreak() const = 0; |
| 1397 |
+ virtual bool warnAboutMissingAssertions() const = 0; |
| 1398 |
+ virtual bool warnAboutUnmatchedTestSpecs() const = 0; |
| 1399 |
+ virtual bool zeroTestsCountAsSuccess() const = 0; |
| 1400 |
+ virtual int abortAfter() const = 0; |
| 1401 |
+ virtual bool showInvisibles() const = 0; |
| 1402 |
+ virtual ShowDurations showDurations() const = 0; |
| 1403 |
+ virtual double minDuration() const = 0; |
| 1404 |
+ virtual TestSpec const& testSpec() const = 0; |
| 1405 |
+ virtual bool hasTestFilters() const = 0; |
| 1406 |
+ virtual std::vector<std::string> const& getTestsOrTags() const = 0; |
| 1407 |
+ virtual TestRunOrder runOrder() const = 0; |
| 1408 |
+ virtual uint32_t rngSeed() const = 0; |
| 1409 |
+ virtual unsigned int shardCount() const = 0; |
| 1410 |
+ virtual unsigned int shardIndex() const = 0; |
| 1411 |
+ virtual ColourMode defaultColourMode() const = 0; |
| 1412 |
+ virtual std::vector<std::string> const& getSectionsToRun() const = 0; |
| 1413 |
+ virtual Verbosity verbosity() const = 0; |
| 1414 |
|
| 1415 |
- // Implementing class must also provide the following static methods: |
| 1416 |
- // static std::string getDescription(); |
| 1417 |
+ virtual bool skipBenchmarks() const = 0; |
| 1418 |
+ virtual bool benchmarkNoAnalysis() const = 0; |
| 1419 |
+ virtual unsigned int benchmarkSamples() const = 0; |
| 1420 |
+ virtual double benchmarkConfidenceInterval() const = 0; |
| 1421 |
+ virtual unsigned int benchmarkResamples() const = 0; |
| 1422 |
+ virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; |
| 1423 |
+ }; |
| 1424 |
+} |
| 1425 |
|
| 1426 |
- ReporterPreferences const& getPreferences() const { |
| 1427 |
- return m_preferences; |
| 1428 |
- } |
| 1429 |
+#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED |
| 1430 |
|
| 1431 |
- //! Called when no test cases match provided test spec |
| 1432 |
- virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; |
| 1433 |
- //! Called for all invalid test specs from the cli |
| 1434 |
- virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0; |
| 1435 |
|
| 1436 |
- /** |
| 1437 |
- * Called once in a testing run before tests are started |
| 1438 |
- * |
| 1439 |
- * Not called if tests won't be run (e.g. only listing will happen) |
| 1440 |
- */ |
| 1441 |
- virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; |
| 1442 |
+#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1443 |
+#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1444 |
|
| 1445 |
- //! Called _once_ for each TEST_CASE, no matter how many times it is entered |
| 1446 |
- virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; |
| 1447 |
- //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
| 1448 |
- virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0; |
| 1449 |
- //! Called when a `SECTION` is being entered. Not called for skipped sections |
| 1450 |
- virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; |
| 1451 |
|
| 1452 |
- //! Called when user-code is being probed before the actual benchmark runs |
| 1453 |
- virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; |
| 1454 |
- //! Called after probe but before the user-code is being benchmarked |
| 1455 |
- virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; |
| 1456 |
- //! Called with the benchmark results if benchmark successfully finishes |
| 1457 |
- virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; |
| 1458 |
- //! Called if running the benchmarks fails for any reason |
| 1459 |
- virtual void benchmarkFailed( StringRef benchmarkName ) = 0; |
| 1460 |
+#include <string> |
| 1461 |
|
| 1462 |
- //! Called before assertion success/failure is evaluated |
| 1463 |
- virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; |
| 1464 |
+namespace Catch { |
| 1465 |
|
| 1466 |
- //! Called after assertion was fully evaluated |
| 1467 |
- virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; |
| 1468 |
+ class TestCaseHandle; |
| 1469 |
+ struct TestCaseInfo; |
| 1470 |
+ class ITestCaseRegistry; |
| 1471 |
+ class IExceptionTranslatorRegistry; |
| 1472 |
+ class IExceptionTranslator; |
| 1473 |
+ class ReporterRegistry; |
| 1474 |
+ class IReporterFactory; |
| 1475 |
+ class ITagAliasRegistry; |
| 1476 |
+ class ITestInvoker; |
| 1477 |
+ class IMutableEnumValuesRegistry; |
| 1478 |
+ struct SourceLineInfo; |
| 1479 |
|
| 1480 |
- //! Called after a `SECTION` has finished running |
| 1481 |
- virtual void sectionEnded( SectionStats const& sectionStats ) = 0; |
| 1482 |
- //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
| 1483 |
- virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0; |
| 1484 |
- //! Called _once_ for each TEST_CASE, no matter how many times it is entered |
| 1485 |
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; |
| 1486 |
- /** |
| 1487 |
- * Called once after all tests in a testing run are finished |
| 1488 |
- * |
| 1489 |
- * Not called if tests weren't run (e.g. only listings happened) |
| 1490 |
- */ |
| 1491 |
- virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; |
| 1492 |
+ class StartupExceptionRegistry; |
| 1493 |
+ class EventListenerFactory; |
| 1494 |
|
| 1495 |
- //! Called with test cases that are skipped due to the test run aborting |
| 1496 |
- virtual void skipTest( TestCaseInfo const& testInfo ) = 0; |
| 1497 |
+ using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; |
| 1498 |
|
| 1499 |
- //! Called if a fatal error (signal/structured exception) occured |
| 1500 |
- virtual void fatalErrorEncountered( StringRef error ) = 0; |
| 1501 |
+ class IRegistryHub { |
| 1502 |
+ public: |
| 1503 |
+ virtual ~IRegistryHub(); // = default |
| 1504 |
|
| 1505 |
- //! Writes out information about provided reporters using reporter-specific format |
| 1506 |
- virtual void listReporters(std::vector<ReporterDescription> const& descriptions) = 0; |
| 1507 |
- //! Writes out the provided listeners descriptions using reporter-specific format |
| 1508 |
- virtual void listListeners(std::vector<ListenerDescription> const& descriptions) = 0; |
| 1509 |
- //! Writes out information about provided tests using reporter-specific format |
| 1510 |
- virtual void listTests(std::vector<TestCaseHandle> const& tests) = 0; |
| 1511 |
- //! Writes out information about the provided tags using reporter-specific format |
| 1512 |
- virtual void listTags(std::vector<TagInfo> const& tags) = 0; |
| 1513 |
+ virtual ReporterRegistry const& getReporterRegistry() const = 0; |
| 1514 |
+ virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; |
| 1515 |
+ virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; |
| 1516 |
+ virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; |
| 1517 |
+ |
| 1518 |
+ |
| 1519 |
+ virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; |
| 1520 |
}; |
| 1521 |
- using IEventListenerPtr = Detail::unique_ptr<IEventListener>; |
| 1522 |
|
| 1523 |
-} // end namespace Catch |
| 1524 |
+ class IMutableRegistryHub { |
| 1525 |
+ public: |
| 1526 |
+ virtual ~IMutableRegistryHub(); // = default |
| 1527 |
+ virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; |
| 1528 |
+ virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0; |
| 1529 |
+ virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0; |
| 1530 |
+ virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0; |
| 1531 |
+ virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; |
| 1532 |
+ virtual void registerStartupException() noexcept = 0; |
| 1533 |
+ virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; |
| 1534 |
+ }; |
| 1535 |
|
| 1536 |
-#endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 1537 |
+ IRegistryHub const& getRegistryHub(); |
| 1538 |
+ IMutableRegistryHub& getMutableRegistryHub(); |
| 1539 |
+ void cleanUp(); |
| 1540 |
+ std::string translateActiveException(); |
| 1541 |
|
| 1542 |
+} |
| 1543 |
|
| 1544 |
-#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 1545 |
-#define CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 1546 |
+#endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1547 |
|
| 1548 |
|
| 1549 |
+#ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED |
| 1550 |
+#define CATCH_BENCHMARK_STATS_HPP_INCLUDED |
| 1551 |
|
| 1552 |
|
| 1553 |
-/** \file |
| 1554 |
- * Wrapper for the CONFIG configuration option |
| 1555 |
- * |
| 1556 |
- * When generating internal unique names, there are two options. Either |
| 1557 |
- * we mix in the current line number, or mix in an incrementing number. |
| 1558 |
- * We prefer the latter, using `__COUNTER__`, but users might want to |
| 1559 |
- * use the former. |
| 1560 |
- */ |
| 1561 |
|
| 1562 |
-#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 1563 |
-#define CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 1564 |
+// Adapted from donated nonius code. |
| 1565 |
+ |
| 1566 |
+#ifndef CATCH_ESTIMATE_HPP_INCLUDED |
| 1567 |
+#define CATCH_ESTIMATE_HPP_INCLUDED |
| 1568 |
+ |
| 1569 |
+namespace Catch { |
| 1570 |
+ namespace Benchmark { |
| 1571 |
+ template <typename Duration> |
| 1572 |
+ struct Estimate { |
| 1573 |
+ Duration point; |
| 1574 |
+ Duration lower_bound; |
| 1575 |
+ Duration upper_bound; |
| 1576 |
+ double confidence_interval; |
| 1577 |
+ |
| 1578 |
+ template <typename Duration2> |
| 1579 |
+ operator Estimate<Duration2>() const { |
| 1580 |
+ return { point, lower_bound, upper_bound, confidence_interval }; |
| 1581 |
+ } |
| 1582 |
+ }; |
| 1583 |
+ } // namespace Benchmark |
| 1584 |
+} // namespace Catch |
| 1585 |
+ |
| 1586 |
+#endif // CATCH_ESTIMATE_HPP_INCLUDED |
| 1587 |
+ |
| 1588 |
+ |
| 1589 |
+// Adapted from donated nonius code. |
| 1590 |
+ |
| 1591 |
+#ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED |
| 1592 |
+#define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED |
| 1593 |
+ |
| 1594 |
+namespace Catch { |
| 1595 |
+ namespace Benchmark { |
| 1596 |
+ struct OutlierClassification { |
| 1597 |
+ int samples_seen = 0; |
| 1598 |
+ int low_severe = 0; // more than 3 times IQR below Q1 |
| 1599 |
+ int low_mild = 0; // 1.5 to 3 times IQR below Q1 |
| 1600 |
+ int high_mild = 0; // 1.5 to 3 times IQR above Q3 |
| 1601 |
+ int high_severe = 0; // more than 3 times IQR above Q3 |
| 1602 |
+ |
| 1603 |
+ int total() const { |
| 1604 |
+ return low_severe + low_mild + high_mild + high_severe; |
| 1605 |
+ } |
| 1606 |
+ }; |
| 1607 |
+ } // namespace Benchmark |
| 1608 |
+} // namespace Catch |
| 1609 |
|
| 1610 |
-#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) |
| 1611 |
- #define CATCH_INTERNAL_CONFIG_COUNTER |
| 1612 |
-#endif |
| 1613 |
+#endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED |
| 1614 |
+// The fwd decl & default specialization needs to be seen by VS2017 before |
| 1615 |
+// BenchmarkStats itself, or VS2017 will report compilation error. |
| 1616 |
|
| 1617 |
-#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ |
| 1618 |
- !defined( CATCH_CONFIG_NO_COUNTER ) && \ |
| 1619 |
- !defined( CATCH_CONFIG_COUNTER ) |
| 1620 |
-# define CATCH_CONFIG_COUNTER |
| 1621 |
-#endif |
| 1622 |
+#include <string> |
| 1623 |
+#include <vector> |
| 1624 |
|
| 1625 |
+namespace Catch { |
| 1626 |
|
| 1627 |
-#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED |
| 1628 |
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line |
| 1629 |
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) |
| 1630 |
-#ifdef CATCH_CONFIG_COUNTER |
| 1631 |
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) |
| 1632 |
-#else |
| 1633 |
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) |
| 1634 |
-#endif |
| 1635 |
+ struct BenchmarkInfo { |
| 1636 |
+ std::string name; |
| 1637 |
+ double estimatedDuration; |
| 1638 |
+ int iterations; |
| 1639 |
+ unsigned int samples; |
| 1640 |
+ unsigned int resamples; |
| 1641 |
+ double clockResolution; |
| 1642 |
+ double clockCost; |
| 1643 |
+ }; |
| 1644 |
|
| 1645 |
-#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED |
| 1646 |
+ template <class Duration> |
| 1647 |
+ struct BenchmarkStats { |
| 1648 |
+ BenchmarkInfo info; |
| 1649 |
|
| 1650 |
+ std::vector<Duration> samples; |
| 1651 |
+ Benchmark::Estimate<Duration> mean; |
| 1652 |
+ Benchmark::Estimate<Duration> standardDeviation; |
| 1653 |
+ Benchmark::OutlierClassification outliers; |
| 1654 |
+ double outlierVariance; |
| 1655 |
|
| 1656 |
-// Adapted from donated nonius code. |
| 1657 |
+ template <typename Duration2> |
| 1658 |
+ operator BenchmarkStats<Duration2>() const { |
| 1659 |
+ std::vector<Duration2> samples2; |
| 1660 |
+ samples2.reserve(samples.size()); |
| 1661 |
+ for (auto const& sample : samples) { |
| 1662 |
+ samples2.push_back(Duration2(sample)); |
| 1663 |
+ } |
| 1664 |
+ return { |
| 1665 |
+ info, |
| 1666 |
+ CATCH_MOVE(samples2), |
| 1667 |
+ mean, |
| 1668 |
+ standardDeviation, |
| 1669 |
+ outliers, |
| 1670 |
+ outlierVariance, |
| 1671 |
+ }; |
| 1672 |
+ } |
| 1673 |
+ }; |
| 1674 |
|
| 1675 |
-#ifndef CATCH_CHRONOMETER_HPP_INCLUDED |
| 1676 |
-#define CATCH_CHRONOMETER_HPP_INCLUDED |
| 1677 |
|
| 1678 |
+} // end namespace Catch |
| 1679 |
+ |
| 1680 |
+#endif // CATCH_BENCHMARK_STATS_HPP_INCLUDED |
| 1681 |
|
| 1682 |
|
| 1683 |
// Adapted from donated nonius code. |
| 1684 |
@@ -1640,12 +1372,63 @@ namespace Catch { |
| 1685 |
#endif // CATCH_CLOCK_HPP_INCLUDED |
| 1686 |
|
| 1687 |
|
| 1688 |
+// Adapted from donated nonius code. |
| 1689 |
+ |
| 1690 |
+#ifndef CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1691 |
+#define CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1692 |
+ |
| 1693 |
+ |
| 1694 |
+namespace Catch { |
| 1695 |
+ namespace Benchmark { |
| 1696 |
+ template <typename Duration> |
| 1697 |
+ struct EnvironmentEstimate { |
| 1698 |
+ Duration mean; |
| 1699 |
+ OutlierClassification outliers; |
| 1700 |
+ |
| 1701 |
+ template <typename Duration2> |
| 1702 |
+ operator EnvironmentEstimate<Duration2>() const { |
| 1703 |
+ return { mean, outliers }; |
| 1704 |
+ } |
| 1705 |
+ }; |
| 1706 |
+ template <typename Clock> |
| 1707 |
+ struct Environment { |
| 1708 |
+ using clock_type = Clock; |
| 1709 |
+ EnvironmentEstimate<FloatDuration<Clock>> clock_resolution; |
| 1710 |
+ EnvironmentEstimate<FloatDuration<Clock>> clock_cost; |
| 1711 |
+ }; |
| 1712 |
+ } // namespace Benchmark |
| 1713 |
+} // namespace Catch |
| 1714 |
+ |
| 1715 |
+#endif // CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1716 |
+ |
| 1717 |
+ |
| 1718 |
+// Adapted from donated nonius code. |
| 1719 |
+ |
| 1720 |
+#ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED |
| 1721 |
+#define CATCH_EXECUTION_PLAN_HPP_INCLUDED |
| 1722 |
+ |
| 1723 |
+ |
| 1724 |
+ |
| 1725 |
+// Adapted from donated nonius code. |
| 1726 |
+ |
| 1727 |
+#ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED |
| 1728 |
+#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED |
| 1729 |
+ |
| 1730 |
+ |
| 1731 |
+ |
| 1732 |
+// Adapted from donated nonius code. |
| 1733 |
+ |
| 1734 |
+#ifndef CATCH_CHRONOMETER_HPP_INCLUDED |
| 1735 |
+#define CATCH_CHRONOMETER_HPP_INCLUDED |
| 1736 |
+ |
| 1737 |
+ |
| 1738 |
+ |
| 1739 |
// Adapted from donated nonius code. |
| 1740 |
|
| 1741 |
#ifndef CATCH_OPTIMIZER_HPP_INCLUDED |
| 1742 |
#define CATCH_OPTIMIZER_HPP_INCLUDED |
| 1743 |
|
| 1744 |
-#if defined(_MSC_VER) |
| 1745 |
+#if defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) |
| 1746 |
# include <atomic> // atomic_thread_fence |
| 1747 |
#endif |
| 1748 |
|
| 1749 |
@@ -1666,16 +1449,23 @@ namespace Catch { |
| 1750 |
namespace Detail { |
| 1751 |
inline void optimizer_barrier() { keep_memory(); } |
| 1752 |
} // namespace Detail |
| 1753 |
-#elif defined(_MSC_VER) |
| 1754 |
+#elif defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) |
| 1755 |
|
| 1756 |
+#if defined(_MSVC_VER) |
| 1757 |
#pragma optimize("", off) |
| 1758 |
+#elif defined(__IAR_SYSTEMS_ICC__) |
| 1759 |
+// For IAR the pragma only affects the following function |
| 1760 |
+#pragma optimize=disable |
| 1761 |
+#endif |
| 1762 |
template <typename T> |
| 1763 |
inline void keep_memory(T* p) { |
| 1764 |
// thanks @milleniumbug |
| 1765 |
*reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p); |
| 1766 |
} |
| 1767 |
// TODO equivalent keep_memory() |
| 1768 |
+#if defined(_MSVC_VER) |
| 1769 |
#pragma optimize("", on) |
| 1770 |
+#endif |
| 1771 |
|
| 1772 |
namespace Detail { |
| 1773 |
inline void optimizer_barrier() { |
| 1774 |
@@ -1705,36 +1495,15 @@ namespace Catch { |
| 1775 |
#endif // CATCH_OPTIMIZER_HPP_INCLUDED |
| 1776 |
|
| 1777 |
|
| 1778 |
-// Adapted from donated nonius code. |
| 1779 |
- |
| 1780 |
-#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 1781 |
-#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 1782 |
- |
| 1783 |
- |
| 1784 |
- |
| 1785 |
-#ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 1786 |
-#define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 1787 |
- |
| 1788 |
-namespace Catch { |
| 1789 |
- |
| 1790 |
- //! Used to signal that an assertion macro failed |
| 1791 |
- struct TestFailureException{}; |
| 1792 |
- |
| 1793 |
-} // namespace Catch |
| 1794 |
- |
| 1795 |
-#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED |
| 1796 |
- |
| 1797 |
- |
| 1798 |
#ifndef CATCH_META_HPP_INCLUDED |
| 1799 |
#define CATCH_META_HPP_INCLUDED |
| 1800 |
|
| 1801 |
#include <type_traits> |
| 1802 |
|
| 1803 |
namespace Catch { |
| 1804 |
- template<typename T> |
| 1805 |
- struct always_false : std::false_type {}; |
| 1806 |
+ template <typename> |
| 1807 |
+ struct true_given : std::true_type {}; |
| 1808 |
|
| 1809 |
- template <typename> struct true_given : std::true_type {}; |
| 1810 |
struct is_callable_tester { |
| 1811 |
template <typename Fun, typename... Args> |
| 1812 |
static true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> test(int); |
| 1813 |
@@ -1757,121 +1526,15 @@ namespace Catch { |
| 1814 |
#else |
| 1815 |
template <typename Func, typename... U> |
| 1816 |
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::result_of_t<Func(U...)>>>; |
| 1817 |
-#endif |
| 1818 |
- |
| 1819 |
-} // namespace Catch |
| 1820 |
- |
| 1821 |
-namespace mpl_{ |
| 1822 |
- struct na; |
| 1823 |
-} |
| 1824 |
- |
| 1825 |
-#endif // CATCH_META_HPP_INCLUDED |
| 1826 |
- |
| 1827 |
- |
| 1828 |
-#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1829 |
-#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1830 |
- |
| 1831 |
- |
| 1832 |
-#include <string> |
| 1833 |
- |
| 1834 |
-namespace Catch { |
| 1835 |
- |
| 1836 |
- class TestCaseHandle; |
| 1837 |
- struct TestCaseInfo; |
| 1838 |
- class ITestCaseRegistry; |
| 1839 |
- class IExceptionTranslatorRegistry; |
| 1840 |
- class IExceptionTranslator; |
| 1841 |
- class IReporterRegistry; |
| 1842 |
- class IReporterFactory; |
| 1843 |
- class ITagAliasRegistry; |
| 1844 |
- class ITestInvoker; |
| 1845 |
- class IMutableEnumValuesRegistry; |
| 1846 |
- struct SourceLineInfo; |
| 1847 |
- |
| 1848 |
- class StartupExceptionRegistry; |
| 1849 |
- class EventListenerFactory; |
| 1850 |
- |
| 1851 |
- using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; |
| 1852 |
- |
| 1853 |
- class IRegistryHub { |
| 1854 |
- public: |
| 1855 |
- virtual ~IRegistryHub(); // = default |
| 1856 |
- |
| 1857 |
- virtual IReporterRegistry const& getReporterRegistry() const = 0; |
| 1858 |
- virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; |
| 1859 |
- virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; |
| 1860 |
- virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; |
| 1861 |
- |
| 1862 |
- |
| 1863 |
- virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; |
| 1864 |
- }; |
| 1865 |
- |
| 1866 |
- class IMutableRegistryHub { |
| 1867 |
- public: |
| 1868 |
- virtual ~IMutableRegistryHub(); // = default |
| 1869 |
- virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; |
| 1870 |
- virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0; |
| 1871 |
- virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0; |
| 1872 |
- virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0; |
| 1873 |
- virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; |
| 1874 |
- virtual void registerStartupException() noexcept = 0; |
| 1875 |
- virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; |
| 1876 |
- }; |
| 1877 |
- |
| 1878 |
- IRegistryHub const& getRegistryHub(); |
| 1879 |
- IMutableRegistryHub& getMutableRegistryHub(); |
| 1880 |
- void cleanUp(); |
| 1881 |
- std::string translateActiveException(); |
| 1882 |
- |
| 1883 |
-} |
| 1884 |
- |
| 1885 |
-#endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED |
| 1886 |
- |
| 1887 |
-#include <type_traits> |
| 1888 |
- |
| 1889 |
-namespace Catch { |
| 1890 |
- namespace Benchmark { |
| 1891 |
- namespace Detail { |
| 1892 |
- template <typename T> |
| 1893 |
- struct CompleteType { using type = T; }; |
| 1894 |
- template <> |
| 1895 |
- struct CompleteType<void> { struct type {}; }; |
| 1896 |
- |
| 1897 |
- template <typename T> |
| 1898 |
- using CompleteType_t = typename CompleteType<T>::type; |
| 1899 |
- |
| 1900 |
- template <typename Result> |
| 1901 |
- struct CompleteInvoker { |
| 1902 |
- template <typename Fun, typename... Args> |
| 1903 |
- static Result invoke(Fun&& fun, Args&&... args) { |
| 1904 |
- return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); |
| 1905 |
- } |
| 1906 |
- }; |
| 1907 |
- template <> |
| 1908 |
- struct CompleteInvoker<void> { |
| 1909 |
- template <typename Fun, typename... Args> |
| 1910 |
- static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) { |
| 1911 |
- CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); |
| 1912 |
- return {}; |
| 1913 |
- } |
| 1914 |
- }; |
| 1915 |
- |
| 1916 |
- // invoke and not return void :( |
| 1917 |
- template <typename Fun, typename... Args> |
| 1918 |
- CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { |
| 1919 |
- return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); |
| 1920 |
- } |
| 1921 |
- |
| 1922 |
- } // namespace Detail |
| 1923 |
- |
| 1924 |
- template <typename Fun> |
| 1925 |
- Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { |
| 1926 |
- return Detail::complete_invoke(CATCH_FORWARD(fun)); |
| 1927 |
- } |
| 1928 |
- } // namespace Benchmark |
| 1929 |
+#endif |
| 1930 |
+ |
| 1931 |
} // namespace Catch |
| 1932 |
|
| 1933 |
-#endif // CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 1934 |
+namespace mpl_{ |
| 1935 |
+ struct na; |
| 1936 |
+} |
| 1937 |
+ |
| 1938 |
+#endif // CATCH_META_HPP_INCLUDED |
| 1939 |
|
| 1940 |
namespace Catch { |
| 1941 |
namespace Benchmark { |
| 1942 |
@@ -1931,50 +1594,6 @@ namespace Catch { |
| 1943 |
|
| 1944 |
#endif // CATCH_CHRONOMETER_HPP_INCLUDED |
| 1945 |
|
| 1946 |
- |
| 1947 |
-// Adapted from donated nonius code. |
| 1948 |
- |
| 1949 |
-#ifndef CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1950 |
-#define CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1951 |
- |
| 1952 |
- |
| 1953 |
-namespace Catch { |
| 1954 |
- namespace Benchmark { |
| 1955 |
- template <typename Duration> |
| 1956 |
- struct EnvironmentEstimate { |
| 1957 |
- Duration mean; |
| 1958 |
- OutlierClassification outliers; |
| 1959 |
- |
| 1960 |
- template <typename Duration2> |
| 1961 |
- operator EnvironmentEstimate<Duration2>() const { |
| 1962 |
- return { mean, outliers }; |
| 1963 |
- } |
| 1964 |
- }; |
| 1965 |
- template <typename Clock> |
| 1966 |
- struct Environment { |
| 1967 |
- using clock_type = Clock; |
| 1968 |
- EnvironmentEstimate<FloatDuration<Clock>> clock_resolution; |
| 1969 |
- EnvironmentEstimate<FloatDuration<Clock>> clock_cost; |
| 1970 |
- }; |
| 1971 |
- } // namespace Benchmark |
| 1972 |
-} // namespace Catch |
| 1973 |
- |
| 1974 |
-#endif // CATCH_ENVIRONMENT_HPP_INCLUDED |
| 1975 |
- |
| 1976 |
- |
| 1977 |
-// Adapted from donated nonius code. |
| 1978 |
- |
| 1979 |
-#ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED |
| 1980 |
-#define CATCH_EXECUTION_PLAN_HPP_INCLUDED |
| 1981 |
- |
| 1982 |
- |
| 1983 |
- |
| 1984 |
-// Adapted from donated nonius code. |
| 1985 |
- |
| 1986 |
-#ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED |
| 1987 |
-#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED |
| 1988 |
- |
| 1989 |
- |
| 1990 |
#include <type_traits> |
| 1991 |
|
| 1992 |
namespace Catch { |
| 1993 |
@@ -2111,6 +1730,57 @@ namespace Catch { |
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
+// Adapted from donated nonius code. |
| 1998 |
+ |
| 1999 |
+#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 2000 |
+#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 2001 |
+ |
| 2002 |
+ |
| 2003 |
+namespace Catch { |
| 2004 |
+ namespace Benchmark { |
| 2005 |
+ namespace Detail { |
| 2006 |
+ template <typename T> |
| 2007 |
+ struct CompleteType { using type = T; }; |
| 2008 |
+ template <> |
| 2009 |
+ struct CompleteType<void> { struct type {}; }; |
| 2010 |
+ |
| 2011 |
+ template <typename T> |
| 2012 |
+ using CompleteType_t = typename CompleteType<T>::type; |
| 2013 |
+ |
| 2014 |
+ template <typename Result> |
| 2015 |
+ struct CompleteInvoker { |
| 2016 |
+ template <typename Fun, typename... Args> |
| 2017 |
+ static Result invoke(Fun&& fun, Args&&... args) { |
| 2018 |
+ return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); |
| 2019 |
+ } |
| 2020 |
+ }; |
| 2021 |
+ template <> |
| 2022 |
+ struct CompleteInvoker<void> { |
| 2023 |
+ template <typename Fun, typename... Args> |
| 2024 |
+ static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) { |
| 2025 |
+ CATCH_FORWARD(fun)(CATCH_FORWARD(args)...); |
| 2026 |
+ return {}; |
| 2027 |
+ } |
| 2028 |
+ }; |
| 2029 |
+ |
| 2030 |
+ // invoke and not return void :( |
| 2031 |
+ template <typename Fun, typename... Args> |
| 2032 |
+ CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { |
| 2033 |
+ return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); |
| 2034 |
+ } |
| 2035 |
+ |
| 2036 |
+ } // namespace Detail |
| 2037 |
+ |
| 2038 |
+ template <typename Fun> |
| 2039 |
+ Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { |
| 2040 |
+ return Detail::complete_invoke(CATCH_FORWARD(fun)); |
| 2041 |
+ } |
| 2042 |
+ } // namespace Benchmark |
| 2043 |
+} // namespace Catch |
| 2044 |
+ |
| 2045 |
+#endif // CATCH_COMPLETE_INVOKE_HPP_INCLUDED |
| 2046 |
+ |
| 2047 |
+ |
| 2048 |
// Adapted from donated nonius code. |
| 2049 |
|
| 2050 |
#ifndef CATCH_TIMING_HPP_INCLUDED |
| 2051 |
@@ -2197,8 +1867,7 @@ namespace Catch { |
| 2052 |
|
| 2053 |
#endif // CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED |
| 2054 |
|
| 2055 |
-#include <algorithm> |
| 2056 |
-#include <iterator> |
| 2057 |
+#include <vector> |
| 2058 |
|
| 2059 |
namespace Catch { |
| 2060 |
namespace Benchmark { |
| 2061 |
@@ -2221,14 +1890,17 @@ namespace Catch { |
| 2062 |
Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{})); |
| 2063 |
|
| 2064 |
std::vector<FloatDuration<Clock>> times; |
| 2065 |
- times.reserve(cfg.benchmarkSamples()); |
| 2066 |
- std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { |
| 2067 |
+ const auto num_samples = cfg.benchmarkSamples(); |
| 2068 |
+ times.reserve( num_samples ); |
| 2069 |
+ for ( size_t i = 0; i < num_samples; ++i ) { |
| 2070 |
Detail::ChronometerModel<Clock> model; |
| 2071 |
- this->benchmark(Chronometer(model, iterations_per_sample)); |
| 2072 |
+ this->benchmark( Chronometer( model, iterations_per_sample ) ); |
| 2073 |
auto sample_time = model.elapsed() - env.clock_cost.mean; |
| 2074 |
- if (sample_time < FloatDuration<Clock>::zero()) sample_time = FloatDuration<Clock>::zero(); |
| 2075 |
- return sample_time / iterations_per_sample; |
| 2076 |
- }); |
| 2077 |
+ if ( sample_time < FloatDuration<Clock>::zero() ) { |
| 2078 |
+ sample_time = FloatDuration<Clock>::zero(); |
| 2079 |
+ } |
| 2080 |
+ times.push_back(sample_time / iterations_per_sample); |
| 2081 |
+ } |
| 2082 |
return times; |
| 2083 |
} |
| 2084 |
}; |
| 2085 |
@@ -2253,8 +1925,6 @@ namespace Catch { |
| 2086 |
|
| 2087 |
#include <algorithm> |
| 2088 |
#include <vector> |
| 2089 |
-#include <numeric> |
| 2090 |
-#include <tuple> |
| 2091 |
#include <cmath> |
| 2092 |
|
| 2093 |
namespace Catch { |
| 2094 |
@@ -2268,39 +1938,17 @@ namespace Catch { |
| 2095 |
|
| 2096 |
double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last); |
| 2097 |
|
| 2098 |
- template <typename Iterator> |
| 2099 |
- OutlierClassification classify_outliers(Iterator first, Iterator last) { |
| 2100 |
- std::vector<double> copy(first, last); |
| 2101 |
- |
| 2102 |
- auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end()); |
| 2103 |
- auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end()); |
| 2104 |
- auto iqr = q3 - q1; |
| 2105 |
- auto los = q1 - (iqr * 3.); |
| 2106 |
- auto lom = q1 - (iqr * 1.5); |
| 2107 |
- auto him = q3 + (iqr * 1.5); |
| 2108 |
- auto his = q3 + (iqr * 3.); |
| 2109 |
- |
| 2110 |
- OutlierClassification o; |
| 2111 |
- for (; first != last; ++first) { |
| 2112 |
- auto&& t = *first; |
| 2113 |
- if (t < los) ++o.low_severe; |
| 2114 |
- else if (t < lom) ++o.low_mild; |
| 2115 |
- else if (t > his) ++o.high_severe; |
| 2116 |
- else if (t > him) ++o.high_mild; |
| 2117 |
- ++o.samples_seen; |
| 2118 |
- } |
| 2119 |
- return o; |
| 2120 |
- } |
| 2121 |
+ OutlierClassification |
| 2122 |
+ classify_outliers( std::vector<double>::const_iterator first, |
| 2123 |
+ std::vector<double>::const_iterator last ); |
| 2124 |
|
| 2125 |
- template <typename Iterator> |
| 2126 |
- double mean(Iterator first, Iterator last) { |
| 2127 |
- auto count = last - first; |
| 2128 |
- double sum = std::accumulate(first, last, 0.); |
| 2129 |
- return sum / static_cast<double>(count); |
| 2130 |
- } |
| 2131 |
+ double mean( std::vector<double>::const_iterator first, |
| 2132 |
+ std::vector<double>::const_iterator last ); |
| 2133 |
|
| 2134 |
- template <typename Estimator, typename Iterator> |
| 2135 |
- sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { |
| 2136 |
+ template <typename Estimator> |
| 2137 |
+ sample jackknife(Estimator&& estimator, |
| 2138 |
+ std::vector<double>::iterator first, |
| 2139 |
+ std::vector<double>::iterator last) { |
| 2140 |
auto n = static_cast<size_t>(last - first); |
| 2141 |
auto second = first; |
| 2142 |
++second; |
| 2143 |
@@ -2323,8 +1971,12 @@ namespace Catch { |
| 2144 |
|
| 2145 |
double normal_quantile(double p); |
| 2146 |
|
| 2147 |
- template <typename Iterator, typename Estimator> |
| 2148 |
- Estimate<double> bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { |
| 2149 |
+ template <typename Estimator> |
| 2150 |
+ Estimate<double> bootstrap( double confidence_level, |
| 2151 |
+ std::vector<double>::iterator first, |
| 2152 |
+ std::vector<double>::iterator last, |
| 2153 |
+ sample const& resample, |
| 2154 |
+ Estimator&& estimator ) { |
| 2155 |
auto n_samples = last - first; |
| 2156 |
|
| 2157 |
double point = estimator(first, last); |
| 2158 |
@@ -2333,13 +1985,13 @@ namespace Catch { |
| 2159 |
|
| 2160 |
sample jack = jackknife(estimator, first, last); |
| 2161 |
double jack_mean = mean(jack.begin(), jack.end()); |
| 2162 |
- double sum_squares, sum_cubes; |
| 2163 |
- std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair<double, double> sqcb, double x) -> std::pair<double, double> { |
| 2164 |
- auto d = jack_mean - x; |
| 2165 |
- auto d2 = d * d; |
| 2166 |
- auto d3 = d2 * d; |
| 2167 |
- return { sqcb.first + d2, sqcb.second + d3 }; |
| 2168 |
- }); |
| 2169 |
+ double sum_squares = 0, sum_cubes = 0; |
| 2170 |
+ for (double x : jack) { |
| 2171 |
+ auto difference = jack_mean - x; |
| 2172 |
+ auto square = difference * difference; |
| 2173 |
+ auto cube = square * difference; |
| 2174 |
+ sum_squares += square; sum_cubes += cube; |
| 2175 |
+ } |
| 2176 |
|
| 2177 |
double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5)); |
| 2178 |
long n = static_cast<long>(resample.size()); |
| 2179 |
@@ -2366,15 +2018,16 @@ namespace Catch { |
| 2180 |
return { point, resample[lo], resample[hi], confidence_level }; |
| 2181 |
} |
| 2182 |
|
| 2183 |
- double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n); |
| 2184 |
- |
| 2185 |
struct bootstrap_analysis { |
| 2186 |
Estimate<double> mean; |
| 2187 |
Estimate<double> standard_deviation; |
| 2188 |
double outlier_variance; |
| 2189 |
}; |
| 2190 |
|
| 2191 |
- bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last); |
| 2192 |
+ bootstrap_analysis analyse_samples(double confidence_level, |
| 2193 |
+ unsigned int n_resamples, |
| 2194 |
+ std::vector<double>::iterator first, |
| 2195 |
+ std::vector<double>::iterator last); |
| 2196 |
} // namespace Detail |
| 2197 |
} // namespace Benchmark |
| 2198 |
} // namespace Catch |
| 2199 |
@@ -2382,7 +2035,6 @@ namespace Catch { |
| 2200 |
#endif // CATCH_STATS_HPP_INCLUDED |
| 2201 |
|
| 2202 |
#include <algorithm> |
| 2203 |
-#include <iterator> |
| 2204 |
#include <vector> |
| 2205 |
#include <cmath> |
| 2206 |
|
| 2207 |
@@ -2393,26 +2045,29 @@ namespace Catch { |
| 2208 |
std::vector<double> resolution(int k) { |
| 2209 |
std::vector<TimePoint<Clock>> times; |
| 2210 |
times.reserve(static_cast<size_t>(k + 1)); |
| 2211 |
- std::generate_n(std::back_inserter(times), k + 1, now<Clock>{}); |
| 2212 |
+ for ( int i = 0; i < k + 1; ++i ) { |
| 2213 |
+ times.push_back( Clock::now() ); |
| 2214 |
+ } |
| 2215 |
|
| 2216 |
std::vector<double> deltas; |
| 2217 |
deltas.reserve(static_cast<size_t>(k)); |
| 2218 |
- std::transform(std::next(times.begin()), times.end(), times.begin(), |
| 2219 |
- std::back_inserter(deltas), |
| 2220 |
- [](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); }); |
| 2221 |
+ for ( size_t idx = 1; idx < times.size(); ++idx ) { |
| 2222 |
+ deltas.push_back( static_cast<double>( |
| 2223 |
+ ( times[idx] - times[idx - 1] ).count() ) ); |
| 2224 |
+ } |
| 2225 |
|
| 2226 |
return deltas; |
| 2227 |
} |
| 2228 |
|
| 2229 |
- const auto warmup_iterations = 10000; |
| 2230 |
- const auto warmup_time = std::chrono::milliseconds(100); |
| 2231 |
- const auto minimum_ticks = 1000; |
| 2232 |
- const auto warmup_seed = 10000; |
| 2233 |
- const auto clock_resolution_estimation_time = std::chrono::milliseconds(500); |
| 2234 |
- const auto clock_cost_estimation_time_limit = std::chrono::seconds(1); |
| 2235 |
- const auto clock_cost_estimation_tick_limit = 100000; |
| 2236 |
- const auto clock_cost_estimation_time = std::chrono::milliseconds(10); |
| 2237 |
- const auto clock_cost_estimation_iterations = 10000; |
| 2238 |
+ constexpr auto warmup_iterations = 10000; |
| 2239 |
+ constexpr auto warmup_time = std::chrono::milliseconds(100); |
| 2240 |
+ constexpr auto minimum_ticks = 1000; |
| 2241 |
+ constexpr auto warmup_seed = 10000; |
| 2242 |
+ constexpr auto clock_resolution_estimation_time = std::chrono::milliseconds(500); |
| 2243 |
+ constexpr auto clock_cost_estimation_time_limit = std::chrono::seconds(1); |
| 2244 |
+ constexpr auto clock_cost_estimation_tick_limit = 100000; |
| 2245 |
+ constexpr auto clock_cost_estimation_time = std::chrono::milliseconds(10); |
| 2246 |
+ constexpr auto clock_cost_estimation_iterations = 10000; |
| 2247 |
|
| 2248 |
template <typename Clock> |
| 2249 |
int warmup() { |
| 2250 |
@@ -2447,9 +2102,11 @@ namespace Catch { |
| 2251 |
std::vector<double> times; |
| 2252 |
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed)); |
| 2253 |
times.reserve(static_cast<size_t>(nsamples)); |
| 2254 |
- std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] { |
| 2255 |
- return static_cast<double>((time_clock(r.iterations) / r.iterations).count()); |
| 2256 |
- }); |
| 2257 |
+ for ( int s = 0; s < nsamples; ++s ) { |
| 2258 |
+ times.push_back( static_cast<double>( |
| 2259 |
+ ( time_clock( r.iterations ) / r.iterations ) |
| 2260 |
+ .count() ) ); |
| 2261 |
+ } |
| 2262 |
return { |
| 2263 |
FloatDuration<Clock>(mean(times.begin(), times.end())), |
| 2264 |
classify_outliers(times.begin(), times.end()), |
| 2265 |
@@ -2497,9 +2154,7 @@ namespace Catch { |
| 2266 |
#define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED |
| 2267 |
|
| 2268 |
|
| 2269 |
-#include <algorithm> |
| 2270 |
#include <vector> |
| 2271 |
-#include <iterator> |
| 2272 |
|
| 2273 |
namespace Catch { |
| 2274 |
namespace Benchmark { |
| 2275 |
@@ -2515,7 +2170,9 @@ namespace Catch { |
| 2276 |
operator SampleAnalysis<Duration2>() const { |
| 2277 |
std::vector<Duration2> samples2; |
| 2278 |
samples2.reserve(samples.size()); |
| 2279 |
- std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); |
| 2280 |
+ for (auto const& d : samples) { |
| 2281 |
+ samples2.push_back(Duration2(d)); |
| 2282 |
+ } |
| 2283 |
return { |
| 2284 |
CATCH_MOVE(samples2), |
| 2285 |
mean, |
| 2286 |
@@ -2530,8 +2187,6 @@ namespace Catch { |
| 2287 |
|
| 2288 |
#endif // CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED |
| 2289 |
|
| 2290 |
-#include <algorithm> |
| 2291 |
-#include <iterator> |
| 2292 |
#include <vector> |
| 2293 |
|
| 2294 |
namespace Catch { |
| 2295 |
@@ -2542,7 +2197,9 @@ namespace Catch { |
| 2296 |
if (!cfg.benchmarkNoAnalysis()) { |
| 2297 |
std::vector<double> samples; |
| 2298 |
samples.reserve(static_cast<size_t>(last - first)); |
| 2299 |
- std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); |
| 2300 |
+ for (auto current = first; current != last; ++current) { |
| 2301 |
+ samples.push_back( current->count() ); |
| 2302 |
+ } |
| 2303 |
|
| 2304 |
auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); |
| 2305 |
auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); |
| 2306 |
@@ -2557,7 +2214,10 @@ namespace Catch { |
| 2307 |
}; |
| 2308 |
std::vector<Duration> samples2; |
| 2309 |
samples2.reserve(samples.size()); |
| 2310 |
- std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); |
| 2311 |
+ for (auto s : samples) { |
| 2312 |
+ samples2.push_back( Duration( s ) ); |
| 2313 |
+ } |
| 2314 |
+ |
| 2315 |
return { |
| 2316 |
CATCH_MOVE(samples2), |
| 2317 |
wrap_estimate(analysis.mean), |
| 2318 |
@@ -2593,6 +2253,8 @@ namespace Catch { |
| 2319 |
#endif // CATCH_ANALYSE_HPP_INCLUDED |
| 2320 |
|
| 2321 |
#include <algorithm> |
| 2322 |
+#include <chrono> |
| 2323 |
+#include <exception> |
| 2324 |
#include <functional> |
| 2325 |
#include <string> |
| 2326 |
#include <vector> |
| 2327 |
@@ -2630,7 +2292,7 @@ namespace Catch { |
| 2328 |
}); |
| 2329 |
|
| 2330 |
BenchmarkInfo info { |
| 2331 |
- name, |
| 2332 |
+ CATCH_MOVE(name), |
| 2333 |
plan.estimated_duration.count(), |
| 2334 |
plan.iterations_per_sample, |
| 2335 |
cfg->benchmarkSamples(), |
| 2336 |
@@ -2646,9 +2308,9 @@ namespace Catch { |
| 2337 |
}); |
| 2338 |
|
| 2339 |
auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); |
| 2340 |
- BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; |
| 2341 |
+ BenchmarkStats<FloatDuration<Clock>> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; |
| 2342 |
getResultCapture().benchmarkEnded(stats); |
| 2343 |
- } CATCH_CATCH_ANON (TestFailureException) { |
| 2344 |
+ } CATCH_CATCH_ANON (TestFailureException const&) { |
| 2345 |
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr); |
| 2346 |
} CATCH_CATCH_ALL{ |
| 2347 |
getResultCapture().benchmarkFailed(translateActiveException()); |
| 2348 |
@@ -2816,6 +2478,7 @@ namespace Catch { |
| 2349 |
#ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED |
| 2350 |
#define CATCH_CONFIG_WCHAR_HPP_INCLUDED |
| 2351 |
|
| 2352 |
+ |
| 2353 |
// We assume that WCHAR should be enabled by default, and only disabled |
| 2354 |
// for a shortlist (so far only DJGPP) of compilers. |
| 2355 |
|
| 2356 |
@@ -3039,7 +2702,6 @@ namespace Catch { |
| 2357 |
} // namespace Detail |
| 2358 |
|
| 2359 |
|
| 2360 |
- // If we decide for C++14, change these to enable_if_ts |
| 2361 |
template <typename T, typename = void> |
| 2362 |
struct StringMaker { |
| 2363 |
template <typename Fake = T> |
| 2364 |
@@ -3693,19 +3355,156 @@ namespace Catch { |
| 2365 |
double m_value; |
| 2366 |
}; |
| 2367 |
|
| 2368 |
-namespace literals { |
| 2369 |
- Approx operator ""_a(long double val); |
| 2370 |
- Approx operator ""_a(unsigned long long val); |
| 2371 |
-} // end namespace literals |
| 2372 |
+namespace literals { |
| 2373 |
+ Approx operator ""_a(long double val); |
| 2374 |
+ Approx operator ""_a(unsigned long long val); |
| 2375 |
+} // end namespace literals |
| 2376 |
+ |
| 2377 |
+template<> |
| 2378 |
+struct StringMaker<Catch::Approx> { |
| 2379 |
+ static std::string convert(Catch::Approx const& value); |
| 2380 |
+}; |
| 2381 |
+ |
| 2382 |
+} // end namespace Catch |
| 2383 |
+ |
| 2384 |
+#endif // CATCH_APPROX_HPP_INCLUDED |
| 2385 |
+ |
| 2386 |
+ |
| 2387 |
+#ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 2388 |
+#define CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 2389 |
+ |
| 2390 |
+ |
| 2391 |
+ |
| 2392 |
+#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 2393 |
+#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 2394 |
+ |
| 2395 |
+#include <cstddef> |
| 2396 |
+#include <iosfwd> |
| 2397 |
+ |
| 2398 |
+namespace Catch { |
| 2399 |
+ |
| 2400 |
+ struct SourceLineInfo { |
| 2401 |
+ |
| 2402 |
+ SourceLineInfo() = delete; |
| 2403 |
+ constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: |
| 2404 |
+ file( _file ), |
| 2405 |
+ line( _line ) |
| 2406 |
+ {} |
| 2407 |
+ |
| 2408 |
+ bool operator == ( SourceLineInfo const& other ) const noexcept; |
| 2409 |
+ bool operator < ( SourceLineInfo const& other ) const noexcept; |
| 2410 |
+ |
| 2411 |
+ char const* file; |
| 2412 |
+ std::size_t line; |
| 2413 |
+ |
| 2414 |
+ friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); |
| 2415 |
+ }; |
| 2416 |
+} |
| 2417 |
+ |
| 2418 |
+#define CATCH_INTERNAL_LINEINFO \ |
| 2419 |
+ ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) |
| 2420 |
+ |
| 2421 |
+#endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED |
| 2422 |
+ |
| 2423 |
+namespace Catch { |
| 2424 |
+ |
| 2425 |
+ struct AssertionInfo { |
| 2426 |
+ // AssertionInfo() = delete; |
| 2427 |
+ |
| 2428 |
+ StringRef macroName; |
| 2429 |
+ SourceLineInfo lineInfo; |
| 2430 |
+ StringRef capturedExpression; |
| 2431 |
+ ResultDisposition::Flags resultDisposition; |
| 2432 |
+ }; |
| 2433 |
+ |
| 2434 |
+} // end namespace Catch |
| 2435 |
+ |
| 2436 |
+#endif // CATCH_ASSERTION_INFO_HPP_INCLUDED |
| 2437 |
+ |
| 2438 |
+ |
| 2439 |
+#ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 2440 |
+#define CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 2441 |
+ |
| 2442 |
+ |
| 2443 |
+ |
| 2444 |
+#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED |
| 2445 |
+#define CATCH_LAZY_EXPR_HPP_INCLUDED |
| 2446 |
+ |
| 2447 |
+#include <iosfwd> |
| 2448 |
+ |
| 2449 |
+namespace Catch { |
| 2450 |
+ |
| 2451 |
+ class ITransientExpression; |
| 2452 |
+ |
| 2453 |
+ class LazyExpression { |
| 2454 |
+ friend class AssertionHandler; |
| 2455 |
+ friend struct AssertionStats; |
| 2456 |
+ friend class RunContext; |
| 2457 |
+ |
| 2458 |
+ ITransientExpression const* m_transientExpression = nullptr; |
| 2459 |
+ bool m_isNegated; |
| 2460 |
+ public: |
| 2461 |
+ LazyExpression( bool isNegated ): |
| 2462 |
+ m_isNegated(isNegated) |
| 2463 |
+ {} |
| 2464 |
+ LazyExpression(LazyExpression const& other) = default; |
| 2465 |
+ LazyExpression& operator = ( LazyExpression const& ) = delete; |
| 2466 |
+ |
| 2467 |
+ explicit operator bool() const { |
| 2468 |
+ return m_transientExpression != nullptr; |
| 2469 |
+ } |
| 2470 |
+ |
| 2471 |
+ friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; |
| 2472 |
+ }; |
| 2473 |
+ |
| 2474 |
+} // namespace Catch |
| 2475 |
+ |
| 2476 |
+#endif // CATCH_LAZY_EXPR_HPP_INCLUDED |
| 2477 |
+ |
| 2478 |
+#include <string> |
| 2479 |
+ |
| 2480 |
+namespace Catch { |
| 2481 |
+ |
| 2482 |
+ struct AssertionResultData |
| 2483 |
+ { |
| 2484 |
+ AssertionResultData() = delete; |
| 2485 |
+ |
| 2486 |
+ AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); |
| 2487 |
+ |
| 2488 |
+ std::string message; |
| 2489 |
+ mutable std::string reconstructedExpression; |
| 2490 |
+ LazyExpression lazyExpression; |
| 2491 |
+ ResultWas::OfType resultType; |
| 2492 |
+ |
| 2493 |
+ std::string reconstructExpression() const; |
| 2494 |
+ }; |
| 2495 |
+ |
| 2496 |
+ class AssertionResult { |
| 2497 |
+ public: |
| 2498 |
+ AssertionResult() = delete; |
| 2499 |
+ AssertionResult( AssertionInfo const& info, AssertionResultData&& data ); |
| 2500 |
+ |
| 2501 |
+ bool isOk() const; |
| 2502 |
+ bool succeeded() const; |
| 2503 |
+ ResultWas::OfType getResultType() const; |
| 2504 |
+ bool hasExpression() const; |
| 2505 |
+ bool hasMessage() const; |
| 2506 |
+ std::string getExpression() const; |
| 2507 |
+ std::string getExpressionInMacro() const; |
| 2508 |
+ bool hasExpandedExpression() const; |
| 2509 |
+ std::string getExpandedExpression() const; |
| 2510 |
+ StringRef getMessage() const; |
| 2511 |
+ SourceLineInfo getSourceInfo() const; |
| 2512 |
+ StringRef getTestMacroName() const; |
| 2513 |
|
| 2514 |
-template<> |
| 2515 |
-struct StringMaker<Catch::Approx> { |
| 2516 |
- static std::string convert(Catch::Approx const& value); |
| 2517 |
-}; |
| 2518 |
+ //protected: |
| 2519 |
+ AssertionInfo m_info; |
| 2520 |
+ AssertionResultData m_resultData; |
| 2521 |
+ }; |
| 2522 |
|
| 2523 |
} // end namespace Catch |
| 2524 |
|
| 2525 |
-#endif // CATCH_APPROX_HPP_INCLUDED |
| 2526 |
+#endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED |
| 2527 |
|
| 2528 |
|
| 2529 |
#ifndef CATCH_CONFIG_HPP_INCLUDED |
| 2530 |
@@ -3766,6 +3565,7 @@ namespace Catch |
| 2531 |
|
| 2532 |
#endif // CATCH_WILDCARD_PATTERN_HPP_INCLUDED |
| 2533 |
|
| 2534 |
+#include <iosfwd> |
| 2535 |
#include <string> |
| 2536 |
#include <vector> |
| 2537 |
|
| 2538 |
@@ -3784,6 +3584,14 @@ namespace Catch { |
| 2539 |
virtual bool matches( TestCaseInfo const& testCase ) const = 0; |
| 2540 |
std::string const& name() const; |
| 2541 |
private: |
| 2542 |
+ virtual void serializeTo( std::ostream& out ) const = 0; |
| 2543 |
+ // Writes string that would be reparsed into the pattern |
| 2544 |
+ friend std::ostream& operator<<(std::ostream& out, |
| 2545 |
+ Pattern const& pattern) { |
| 2546 |
+ pattern.serializeTo( out ); |
| 2547 |
+ return out; |
| 2548 |
+ } |
| 2549 |
+ |
| 2550 |
std::string const m_name; |
| 2551 |
}; |
| 2552 |
|
| 2553 |
@@ -3792,6 +3600,8 @@ namespace Catch { |
| 2554 |
explicit NamePattern( std::string const& name, std::string const& filterString ); |
| 2555 |
bool matches( TestCaseInfo const& testCase ) const override; |
| 2556 |
private: |
| 2557 |
+ void serializeTo( std::ostream& out ) const override; |
| 2558 |
+ |
| 2559 |
WildcardPattern m_wildcardPattern; |
| 2560 |
}; |
| 2561 |
|
| 2562 |
@@ -3800,6 +3610,8 @@ namespace Catch { |
| 2563 |
explicit TagPattern( std::string const& tag, std::string const& filterString ); |
| 2564 |
bool matches( TestCaseInfo const& testCase ) const override; |
| 2565 |
private: |
| 2566 |
+ void serializeTo( std::ostream& out ) const override; |
| 2567 |
+ |
| 2568 |
std::string m_tag; |
| 2569 |
}; |
| 2570 |
|
| 2571 |
@@ -3807,10 +3619,19 @@ namespace Catch { |
| 2572 |
std::vector<Detail::unique_ptr<Pattern>> m_required; |
| 2573 |
std::vector<Detail::unique_ptr<Pattern>> m_forbidden; |
| 2574 |
|
| 2575 |
+ //! Serializes this filter into a string that would be parsed into |
| 2576 |
+ //! an equivalent filter |
| 2577 |
+ void serializeTo( std::ostream& out ) const; |
| 2578 |
+ friend std::ostream& operator<<(std::ostream& out, Filter const& f) { |
| 2579 |
+ f.serializeTo( out ); |
| 2580 |
+ return out; |
| 2581 |
+ } |
| 2582 |
+ |
| 2583 |
bool matches( TestCaseInfo const& testCase ) const; |
| 2584 |
- std::string name() const; |
| 2585 |
}; |
| 2586 |
|
| 2587 |
+ static std::string extractFilterName( Filter const& filter ); |
| 2588 |
+ |
| 2589 |
public: |
| 2590 |
struct FilterMatch { |
| 2591 |
std::string name; |
| 2592 |
@@ -3827,7 +3648,16 @@ namespace Catch { |
| 2593 |
private: |
| 2594 |
std::vector<Filter> m_filters; |
| 2595 |
std::vector<std::string> m_invalidSpecs; |
| 2596 |
+ |
| 2597 |
friend class TestSpecParser; |
| 2598 |
+ //! Serializes this test spec into a string that would be parsed into |
| 2599 |
+ //! equivalent test spec |
| 2600 |
+ void serializeTo( std::ostream& out ) const; |
| 2601 |
+ friend std::ostream& operator<<(std::ostream& out, |
| 2602 |
+ TestSpec const& spec) { |
| 2603 |
+ spec.serializeTo( out ); |
| 2604 |
+ return out; |
| 2605 |
+ } |
| 2606 |
}; |
| 2607 |
} |
| 2608 |
|
| 2609 |
@@ -3841,6 +3671,7 @@ namespace Catch { |
| 2610 |
#ifndef CATCH_OPTIONAL_HPP_INCLUDED |
| 2611 |
#define CATCH_OPTIONAL_HPP_INCLUDED |
| 2612 |
|
| 2613 |
+ |
| 2614 |
#include <cassert> |
| 2615 |
|
| 2616 |
namespace Catch { |
| 2617 |
@@ -3849,35 +3680,50 @@ namespace Catch { |
| 2618 |
template<typename T> |
| 2619 |
class Optional { |
| 2620 |
public: |
| 2621 |
- Optional() : nullableValue( nullptr ) {} |
| 2622 |
- Optional( T const& _value ) |
| 2623 |
- : nullableValue( new( storage ) T( _value ) ) |
| 2624 |
- {} |
| 2625 |
- Optional( Optional const& _other ) |
| 2626 |
- : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) |
| 2627 |
- {} |
| 2628 |
+ Optional(): nullableValue( nullptr ) {} |
| 2629 |
+ ~Optional() { reset(); } |
| 2630 |
+ |
| 2631 |
+ Optional( T const& _value ): |
| 2632 |
+ nullableValue( new ( storage ) T( _value ) ) {} |
| 2633 |
+ Optional( T&& _value ): |
| 2634 |
+ nullableValue( new ( storage ) T( CATCH_MOVE( _value ) ) ) {} |
| 2635 |
|
| 2636 |
- ~Optional() { |
| 2637 |
+ Optional& operator=( T const& _value ) { |
| 2638 |
+ reset(); |
| 2639 |
+ nullableValue = new ( storage ) T( _value ); |
| 2640 |
+ return *this; |
| 2641 |
+ } |
| 2642 |
+ Optional& operator=( T&& _value ) { |
| 2643 |
reset(); |
| 2644 |
+ nullableValue = new ( storage ) T( CATCH_MOVE( _value ) ); |
| 2645 |
+ return *this; |
| 2646 |
} |
| 2647 |
|
| 2648 |
- Optional& operator= ( Optional const& _other ) { |
| 2649 |
- if( &_other != this ) { |
| 2650 |
+ Optional( Optional const& _other ): |
| 2651 |
+ nullableValue( _other ? new ( storage ) T( *_other ) : nullptr ) {} |
| 2652 |
+ Optional( Optional&& _other ): |
| 2653 |
+ nullableValue( _other ? new ( storage ) T( CATCH_MOVE( *_other ) ) |
| 2654 |
+ : nullptr ) {} |
| 2655 |
+ |
| 2656 |
+ Optional& operator=( Optional const& _other ) { |
| 2657 |
+ if ( &_other != this ) { |
| 2658 |
reset(); |
| 2659 |
- if( _other ) |
| 2660 |
- nullableValue = new( storage ) T( *_other ); |
| 2661 |
+ if ( _other ) { nullableValue = new ( storage ) T( *_other ); } |
| 2662 |
} |
| 2663 |
return *this; |
| 2664 |
} |
| 2665 |
- Optional& operator = ( T const& _value ) { |
| 2666 |
- reset(); |
| 2667 |
- nullableValue = new( storage ) T( _value ); |
| 2668 |
+ Optional& operator=( Optional&& _other ) { |
| 2669 |
+ if ( &_other != this ) { |
| 2670 |
+ reset(); |
| 2671 |
+ if ( _other ) { |
| 2672 |
+ nullableValue = new ( storage ) T( CATCH_MOVE( *_other ) ); |
| 2673 |
+ } |
| 2674 |
+ } |
| 2675 |
return *this; |
| 2676 |
} |
| 2677 |
|
| 2678 |
void reset() { |
| 2679 |
- if( nullableValue ) |
| 2680 |
- nullableValue->~T(); |
| 2681 |
+ if ( nullableValue ) { nullableValue->~T(); } |
| 2682 |
nullableValue = nullptr; |
| 2683 |
} |
| 2684 |
|
| 2685 |
@@ -3924,7 +3770,7 @@ namespace Catch { |
| 2686 |
} |
| 2687 |
|
| 2688 |
private: |
| 2689 |
- T *nullableValue; |
| 2690 |
+ T* nullableValue; |
| 2691 |
alignas(alignof(T)) char storage[sizeof(T)]; |
| 2692 |
}; |
| 2693 |
|
| 2694 |
@@ -4000,6 +3846,7 @@ namespace Catch { |
| 2695 |
|
| 2696 |
Error = BrightRed, |
| 2697 |
Success = Green, |
| 2698 |
+ Skip = LightGrey, |
| 2699 |
|
| 2700 |
OriginalExpression = Cyan, |
| 2701 |
ReconstructedExpression = BrightYellow, |
| 2702 |
@@ -4288,6 +4135,9 @@ namespace Catch { |
| 2703 |
std::chrono::milliseconds benchmarkWarmupTime() const override; |
| 2704 |
|
| 2705 |
private: |
| 2706 |
+ // Reads Bazel env vars and applies them to the config |
| 2707 |
+ void readBazelEnvVars(); |
| 2708 |
+ |
| 2709 |
ConfigData m_data; |
| 2710 |
std::vector<ProcessedReporterSpec> m_processedReporterSpecs; |
| 2711 |
TestSpec m_testSpec; |
| 2712 |
@@ -4327,10 +4177,10 @@ namespace Catch { |
| 2713 |
// as well as |
| 2714 |
// << stuff +StreamEndStop |
| 2715 |
struct StreamEndStop { |
| 2716 |
- StringRef operator+() const { return StringRef(); } |
| 2717 |
+ constexpr StringRef operator+() const { return StringRef(); } |
| 2718 |
|
| 2719 |
template <typename T> |
| 2720 |
- friend T const& operator+( T const& value, StreamEndStop ) { |
| 2721 |
+ constexpr friend T const& operator+( T const& value, StreamEndStop ) { |
| 2722 |
return value; |
| 2723 |
} |
| 2724 |
}; |
| 2725 |
@@ -4339,12 +4189,47 @@ namespace Catch { |
| 2726 |
|
| 2727 |
#endif // CATCH_STREAM_END_STOP_HPP_INCLUDED |
| 2728 |
|
| 2729 |
+ |
| 2730 |
+#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 2731 |
+#define CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 2732 |
+ |
| 2733 |
+ |
| 2734 |
+#include <string> |
| 2735 |
+ |
| 2736 |
+namespace Catch { |
| 2737 |
+ |
| 2738 |
+ struct MessageInfo { |
| 2739 |
+ MessageInfo( StringRef _macroName, |
| 2740 |
+ SourceLineInfo const& _lineInfo, |
| 2741 |
+ ResultWas::OfType _type ); |
| 2742 |
+ |
| 2743 |
+ StringRef macroName; |
| 2744 |
+ std::string message; |
| 2745 |
+ SourceLineInfo lineInfo; |
| 2746 |
+ ResultWas::OfType type; |
| 2747 |
+ unsigned int sequence; |
| 2748 |
+ |
| 2749 |
+ bool operator == (MessageInfo const& other) const { |
| 2750 |
+ return sequence == other.sequence; |
| 2751 |
+ } |
| 2752 |
+ bool operator < (MessageInfo const& other) const { |
| 2753 |
+ return sequence < other.sequence; |
| 2754 |
+ } |
| 2755 |
+ private: |
| 2756 |
+ static unsigned int globalCount; |
| 2757 |
+ }; |
| 2758 |
+ |
| 2759 |
+} // end namespace Catch |
| 2760 |
+ |
| 2761 |
+#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED |
| 2762 |
+ |
| 2763 |
#include <string> |
| 2764 |
#include <vector> |
| 2765 |
|
| 2766 |
namespace Catch { |
| 2767 |
|
| 2768 |
struct SourceLineInfo; |
| 2769 |
+ class IResultCapture; |
| 2770 |
|
| 2771 |
struct MessageStream { |
| 2772 |
|
| 2773 |
@@ -4363,11 +4248,10 @@ namespace Catch { |
| 2774 |
ResultWas::OfType type ): |
| 2775 |
m_info(macroName, lineInfo, type) {} |
| 2776 |
|
| 2777 |
- |
| 2778 |
template<typename T> |
| 2779 |
- MessageBuilder& operator << ( T const& value ) { |
| 2780 |
+ MessageBuilder&& operator << ( T const& value ) && { |
| 2781 |
m_stream << value; |
| 2782 |
- return *this; |
| 2783 |
+ return CATCH_MOVE(*this); |
| 2784 |
} |
| 2785 |
|
| 2786 |
MessageInfo m_info; |
| 2787 |
@@ -4375,7 +4259,7 @@ namespace Catch { |
| 2788 |
|
| 2789 |
class ScopedMessage { |
| 2790 |
public: |
| 2791 |
- explicit ScopedMessage( MessageBuilder const& builder ); |
| 2792 |
+ explicit ScopedMessage( MessageBuilder&& builder ); |
| 2793 |
ScopedMessage( ScopedMessage& duplicate ) = delete; |
| 2794 |
ScopedMessage( ScopedMessage&& old ) noexcept; |
| 2795 |
~ScopedMessage(); |
| 2796 |
@@ -4386,7 +4270,7 @@ namespace Catch { |
| 2797 |
|
| 2798 |
class Capturer { |
| 2799 |
std::vector<MessageInfo> m_messages; |
| 2800 |
- IResultCapture& m_resultCapture = getResultCapture(); |
| 2801 |
+ IResultCapture& m_resultCapture; |
| 2802 |
size_t m_captured = 0; |
| 2803 |
public: |
| 2804 |
Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); |
| 2805 |
@@ -4422,12 +4306,15 @@ namespace Catch { |
| 2806 |
|
| 2807 |
/////////////////////////////////////////////////////////////////////////////// |
| 2808 |
#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \ |
| 2809 |
- Catch::Capturer varName( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \ |
| 2810 |
+ Catch::Capturer varName( macroName##_catch_sr, \ |
| 2811 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 2812 |
+ Catch::ResultWas::Info, \ |
| 2813 |
+ #__VA_ARGS__##_catch_sr ); \ |
| 2814 |
varName.captureValues( 0, __VA_ARGS__ ) |
| 2815 |
|
| 2816 |
/////////////////////////////////////////////////////////////////////////////// |
| 2817 |
#define INTERNAL_CATCH_INFO( macroName, log ) \ |
| 2818 |
- Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) |
| 2819 |
+ const Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) |
| 2820 |
|
| 2821 |
/////////////////////////////////////////////////////////////////////////////// |
| 2822 |
#define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \ |
| 2823 |
@@ -4470,6 +4357,75 @@ namespace Catch { |
| 2824 |
#endif // CATCH_MESSAGE_HPP_INCLUDED |
| 2825 |
|
| 2826 |
|
| 2827 |
+#ifndef CATCH_SECTION_INFO_HPP_INCLUDED |
| 2828 |
+#define CATCH_SECTION_INFO_HPP_INCLUDED |
| 2829 |
+ |
| 2830 |
+ |
| 2831 |
+ |
| 2832 |
+#ifndef CATCH_TOTALS_HPP_INCLUDED |
| 2833 |
+#define CATCH_TOTALS_HPP_INCLUDED |
| 2834 |
+ |
| 2835 |
+#include <cstdint> |
| 2836 |
+ |
| 2837 |
+namespace Catch { |
| 2838 |
+ |
| 2839 |
+ struct Counts { |
| 2840 |
+ Counts operator - ( Counts const& other ) const; |
| 2841 |
+ Counts& operator += ( Counts const& other ); |
| 2842 |
+ |
| 2843 |
+ std::uint64_t total() const; |
| 2844 |
+ bool allPassed() const; |
| 2845 |
+ bool allOk() const; |
| 2846 |
+ |
| 2847 |
+ std::uint64_t passed = 0; |
| 2848 |
+ std::uint64_t failed = 0; |
| 2849 |
+ std::uint64_t failedButOk = 0; |
| 2850 |
+ std::uint64_t skipped = 0; |
| 2851 |
+ }; |
| 2852 |
+ |
| 2853 |
+ struct Totals { |
| 2854 |
+ |
| 2855 |
+ Totals operator - ( Totals const& other ) const; |
| 2856 |
+ Totals& operator += ( Totals const& other ); |
| 2857 |
+ |
| 2858 |
+ Totals delta( Totals const& prevTotals ) const; |
| 2859 |
+ |
| 2860 |
+ Counts assertions; |
| 2861 |
+ Counts testCases; |
| 2862 |
+ }; |
| 2863 |
+} |
| 2864 |
+ |
| 2865 |
+#endif // CATCH_TOTALS_HPP_INCLUDED |
| 2866 |
+ |
| 2867 |
+#include <string> |
| 2868 |
+ |
| 2869 |
+namespace Catch { |
| 2870 |
+ |
| 2871 |
+ struct SectionInfo { |
| 2872 |
+ // The last argument is ignored, so that people can write |
| 2873 |
+ // SECTION("ShortName", "Proper description that is long") and |
| 2874 |
+ // still use the `-c` flag comfortably. |
| 2875 |
+ SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, |
| 2876 |
+ const char* const = nullptr ): |
| 2877 |
+ name(CATCH_MOVE(_name)), |
| 2878 |
+ lineInfo(_lineInfo) |
| 2879 |
+ {} |
| 2880 |
+ |
| 2881 |
+ std::string name; |
| 2882 |
+ SourceLineInfo lineInfo; |
| 2883 |
+ }; |
| 2884 |
+ |
| 2885 |
+ struct SectionEndInfo { |
| 2886 |
+ SectionInfo sectionInfo; |
| 2887 |
+ Counts prevAssertions; |
| 2888 |
+ double durationInSeconds; |
| 2889 |
+ }; |
| 2890 |
+ |
| 2891 |
+} // end namespace Catch |
| 2892 |
+ |
| 2893 |
+#endif // CATCH_SECTION_INFO_HPP_INCLUDED |
| 2894 |
+ |
| 2895 |
+ |
| 2896 |
#ifndef CATCH_SESSION_HPP_INCLUDED |
| 2897 |
#define CATCH_SESSION_HPP_INCLUDED |
| 2898 |
|
| 2899 |
@@ -5308,6 +5264,115 @@ namespace Catch { |
| 2900 |
#define CATCH_DECOMPOSER_HPP_INCLUDED |
| 2901 |
|
| 2902 |
|
| 2903 |
+ |
| 2904 |
+#ifndef CATCH_COMPARE_TRAITS_HPP_INCLUDED |
| 2905 |
+#define CATCH_COMPARE_TRAITS_HPP_INCLUDED |
| 2906 |
+ |
| 2907 |
+ |
| 2908 |
+#include <type_traits> |
| 2909 |
+ |
| 2910 |
+namespace Catch { |
| 2911 |
+ namespace Detail { |
| 2912 |
+ |
| 2913 |
+#if defined( __GNUC__ ) && !defined( __clang__ ) |
| 2914 |
+# pragma GCC diagnostic push |
| 2915 |
+ // GCC likes to complain about comparing bool with 0, in the decltype() |
| 2916 |
+ // that defines the comparable traits below. |
| 2917 |
+# pragma GCC diagnostic ignored "-Wbool-compare" |
| 2918 |
+ // "ordered comparison of pointer with integer zero" same as above, |
| 2919 |
+ // but it does not have a separate warning flag to suppress |
| 2920 |
+# pragma GCC diagnostic ignored "-Wextra" |
| 2921 |
+ // Did you know that comparing floats with `0` directly |
| 2922 |
+ // is super-duper dangerous in unevaluated context? |
| 2923 |
+# pragma GCC diagnostic ignored "-Wfloat-equal" |
| 2924 |
+#endif |
| 2925 |
+ |
| 2926 |
+#if defined( __clang__ ) |
| 2927 |
+# pragma clang diagnostic push |
| 2928 |
+ // Did you know that comparing floats with `0` directly |
| 2929 |
+ // is super-duper dangerous in unevaluated context? |
| 2930 |
+# pragma clang diagnostic ignored "-Wfloat-equal" |
| 2931 |
+#endif |
| 2932 |
+ |
| 2933 |
+#define CATCH_DEFINE_COMPARABLE_TRAIT( id, op ) \ |
| 2934 |
+ template <typename, typename, typename = void> \ |
| 2935 |
+ struct is_##id##_comparable : std::false_type {}; \ |
| 2936 |
+ template <typename T, typename U> \ |
| 2937 |
+ struct is_##id##_comparable< \ |
| 2938 |
+ T, \ |
| 2939 |
+ U, \ |
| 2940 |
+ void_t<decltype( std::declval<T>() op std::declval<U>() )>> \ |
| 2941 |
+ : std::true_type {}; \ |
| 2942 |
+ template <typename, typename = void> \ |
| 2943 |
+ struct is_##id##_0_comparable : std::false_type {}; \ |
| 2944 |
+ template <typename T> \ |
| 2945 |
+ struct is_##id##_0_comparable<T, \ |
| 2946 |
+ void_t<decltype( std::declval<T>() op 0 )>> \ |
| 2947 |
+ : std::true_type {}; |
| 2948 |
+ |
| 2949 |
+ // We need all 6 pre-spaceship comparison ops: <, <=, >, >=, ==, != |
| 2950 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( lt, < ) |
| 2951 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( le, <= ) |
| 2952 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( gt, > ) |
| 2953 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( ge, >= ) |
| 2954 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( eq, == ) |
| 2955 |
+ CATCH_DEFINE_COMPARABLE_TRAIT( ne, != ) |
| 2956 |
+ |
| 2957 |
+#undef CATCH_DEFINE_COMPARABLE_TRAIT |
| 2958 |
+ |
| 2959 |
+#if defined( __GNUC__ ) && !defined( __clang__ ) |
| 2960 |
+# pragma GCC diagnostic pop |
| 2961 |
+#endif |
| 2962 |
+#if defined( __clang__ ) |
| 2963 |
+# pragma clang diagnostic pop |
| 2964 |
+#endif |
| 2965 |
+ |
| 2966 |
+ |
| 2967 |
+ } // namespace Detail |
| 2968 |
+} // namespace Catch |
| 2969 |
+ |
| 2970 |
+#endif // CATCH_COMPARE_TRAITS_HPP_INCLUDED |
| 2971 |
+ |
| 2972 |
+ |
| 2973 |
+#ifndef CATCH_LOGICAL_TRAITS_HPP_INCLUDED |
| 2974 |
+#define CATCH_LOGICAL_TRAITS_HPP_INCLUDED |
| 2975 |
+ |
| 2976 |
+#include <type_traits> |
| 2977 |
+ |
| 2978 |
+namespace Catch { |
| 2979 |
+namespace Detail { |
| 2980 |
+ |
| 2981 |
+#if defined( __cpp_lib_logical_traits ) && __cpp_lib_logical_traits >= 201510 |
| 2982 |
+ |
| 2983 |
+ using std::conjunction; |
| 2984 |
+ using std::disjunction; |
| 2985 |
+ using std::negation; |
| 2986 |
+ |
| 2987 |
+#else |
| 2988 |
+ |
| 2989 |
+ template <class...> struct conjunction : std::true_type {}; |
| 2990 |
+ template <class B1> struct conjunction<B1> : B1 {}; |
| 2991 |
+ template <class B1, class... Bn> |
| 2992 |
+ struct conjunction<B1, Bn...> |
| 2993 |
+ : std::conditional_t<bool( B1::value ), conjunction<Bn...>, B1> {}; |
| 2994 |
+ |
| 2995 |
+ template <class...> struct disjunction : std::false_type {}; |
| 2996 |
+ template <class B1> struct disjunction<B1> : B1 {}; |
| 2997 |
+ template <class B1, class... Bn> |
| 2998 |
+ struct disjunction<B1, Bn...> |
| 2999 |
+ : std::conditional_t<bool( B1::value ), B1, disjunction<Bn...>> {}; |
| 3000 |
+ |
| 3001 |
+ template <class B> |
| 3002 |
+ struct negation : std::integral_constant<bool, !bool(B::value)> {}; |
| 3003 |
+ |
| 3004 |
+#endif |
| 3005 |
+ |
| 3006 |
+} // namespace Detail |
| 3007 |
+} // namespace Catch |
| 3008 |
+ |
| 3009 |
+#endif // CATCH_LOGICAL_TRAITS_HPP_INCLUDED |
| 3010 |
+ |
| 3011 |
+#include <type_traits> |
| 3012 |
#include <iosfwd> |
| 3013 |
|
| 3014 |
#ifdef _MSC_VER |
| 3015 |
@@ -5329,6 +5394,9 @@ namespace Catch { |
| 3016 |
|
| 3017 |
namespace Catch { |
| 3018 |
|
| 3019 |
+ template <typename T> |
| 3020 |
+ struct always_false : std::false_type {}; |
| 3021 |
+ |
| 3022 |
class ITransientExpression { |
| 3023 |
bool m_isBinaryExpression; |
| 3024 |
bool m_result; |
| 3025 |
@@ -5451,68 +5519,134 @@ namespace Catch { |
| 3026 |
}; |
| 3027 |
|
| 3028 |
|
| 3029 |
- // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) |
| 3030 |
- template<typename LhsT, typename RhsT> |
| 3031 |
- auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); } |
| 3032 |
- template<typename T> |
| 3033 |
- auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } |
| 3034 |
- template<typename T> |
| 3035 |
- auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } |
| 3036 |
- template<typename T> |
| 3037 |
- auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } |
| 3038 |
- template<typename T> |
| 3039 |
- auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } |
| 3040 |
- |
| 3041 |
- template<typename LhsT, typename RhsT> |
| 3042 |
- auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); } |
| 3043 |
- template<typename T> |
| 3044 |
- auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } |
| 3045 |
- template<typename T> |
| 3046 |
- auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } |
| 3047 |
- template<typename T> |
| 3048 |
- auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } |
| 3049 |
- template<typename T> |
| 3050 |
- auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } |
| 3051 |
- |
| 3052 |
- |
| 3053 |
template<typename LhsT> |
| 3054 |
class ExprLhs { |
| 3055 |
LhsT m_lhs; |
| 3056 |
public: |
| 3057 |
explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} |
| 3058 |
|
| 3059 |
- template<typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, int> = 0> |
| 3060 |
- friend auto operator == ( ExprLhs && lhs, RhsT && rhs ) -> BinaryExpr<LhsT, RhsT const&> { |
| 3061 |
- return { compareEqual( lhs.m_lhs, rhs ), lhs.m_lhs, "=="_sr, rhs }; |
| 3062 |
- } |
| 3063 |
- template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value, int> = 0> |
| 3064 |
- friend auto operator == ( ExprLhs && lhs, RhsT rhs ) -> BinaryExpr<LhsT, RhsT> { |
| 3065 |
- return { compareEqual( lhs.m_lhs, rhs ), lhs.m_lhs, "=="_sr, rhs }; |
| 3066 |
- } |
| 3067 |
+#define CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( id, op ) \ |
| 3068 |
+ template <typename RhsT> \ |
| 3069 |
+ friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ |
| 3070 |
+ ->std::enable_if_t< \ |
| 3071 |
+ Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ |
| 3072 |
+ Detail::negation<std::is_arithmetic< \ |
| 3073 |
+ std::remove_reference_t<RhsT>>>>::value, \ |
| 3074 |
+ BinaryExpr<LhsT, RhsT const&>> { \ |
| 3075 |
+ return { \ |
| 3076 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3077 |
+ } \ |
| 3078 |
+ template <typename RhsT> \ |
| 3079 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3080 |
+ ->std::enable_if_t< \ |
| 3081 |
+ Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ |
| 3082 |
+ std::is_arithmetic<RhsT>>::value, \ |
| 3083 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3084 |
+ return { \ |
| 3085 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3086 |
+ } \ |
| 3087 |
+ template <typename RhsT> \ |
| 3088 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3089 |
+ ->std::enable_if_t< \ |
| 3090 |
+ Detail::conjunction< \ |
| 3091 |
+ Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ |
| 3092 |
+ Detail::is_eq_0_comparable<LhsT>, \ |
| 3093 |
+ /* We allow long because we want `ptr op NULL` to be accepted */ \ |
| 3094 |
+ Detail::disjunction<std::is_same<RhsT, int>, \ |
| 3095 |
+ std::is_same<RhsT, long>>>::value, \ |
| 3096 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3097 |
+ if ( rhs != 0 ) { throw_test_failure_exception(); } \ |
| 3098 |
+ return { \ |
| 3099 |
+ static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3100 |
+ } \ |
| 3101 |
+ template <typename RhsT> \ |
| 3102 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3103 |
+ ->std::enable_if_t< \ |
| 3104 |
+ Detail::conjunction< \ |
| 3105 |
+ Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ |
| 3106 |
+ Detail::is_eq_0_comparable<RhsT>, \ |
| 3107 |
+ /* We allow long because we want `ptr op NULL` to be accepted */ \ |
| 3108 |
+ Detail::disjunction<std::is_same<LhsT, int>, \ |
| 3109 |
+ std::is_same<LhsT, long>>>::value, \ |
| 3110 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3111 |
+ if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \ |
| 3112 |
+ return { static_cast<bool>( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3113 |
+ } |
| 3114 |
|
| 3115 |
- template<typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, int> = 0> |
| 3116 |
- friend auto operator != ( ExprLhs && lhs, RhsT && rhs ) -> BinaryExpr<LhsT, RhsT const&> { |
| 3117 |
- return { compareNotEqual( lhs.m_lhs, rhs ), lhs.m_lhs, "!="_sr, rhs }; |
| 3118 |
- } |
| 3119 |
- template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value, int> = 0> |
| 3120 |
- friend auto operator != ( ExprLhs && lhs, RhsT rhs ) -> BinaryExpr<LhsT, RhsT> { |
| 3121 |
- return { compareNotEqual( lhs.m_lhs, rhs ), lhs.m_lhs, "!="_sr, rhs }; |
| 3122 |
- } |
| 3123 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( eq, == ) |
| 3124 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( ne, != ) |
| 3125 |
+ |
| 3126 |
+ #undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR |
| 3127 |
+ |
| 3128 |
+#define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( id, op ) \ |
| 3129 |
+ template <typename RhsT> \ |
| 3130 |
+ friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ |
| 3131 |
+ ->std::enable_if_t< \ |
| 3132 |
+ Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ |
| 3133 |
+ Detail::negation<std::is_arithmetic< \ |
| 3134 |
+ std::remove_reference_t<RhsT>>>>::value, \ |
| 3135 |
+ BinaryExpr<LhsT, RhsT const&>> { \ |
| 3136 |
+ return { \ |
| 3137 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3138 |
+ } \ |
| 3139 |
+ template <typename RhsT> \ |
| 3140 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3141 |
+ ->std::enable_if_t< \ |
| 3142 |
+ Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ |
| 3143 |
+ std::is_arithmetic<RhsT>>::value, \ |
| 3144 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3145 |
+ return { \ |
| 3146 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3147 |
+ } \ |
| 3148 |
+ template <typename RhsT> \ |
| 3149 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3150 |
+ ->std::enable_if_t< \ |
| 3151 |
+ Detail::conjunction< \ |
| 3152 |
+ Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ |
| 3153 |
+ Detail::is_##id##_0_comparable<LhsT>, \ |
| 3154 |
+ std::is_same<RhsT, int>>::value, \ |
| 3155 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3156 |
+ if ( rhs != 0 ) { throw_test_failure_exception(); } \ |
| 3157 |
+ return { \ |
| 3158 |
+ static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3159 |
+ } \ |
| 3160 |
+ template <typename RhsT> \ |
| 3161 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3162 |
+ ->std::enable_if_t< \ |
| 3163 |
+ Detail::conjunction< \ |
| 3164 |
+ Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ |
| 3165 |
+ Detail::is_##id##_0_comparable<RhsT>, \ |
| 3166 |
+ std::is_same<LhsT, int>>::value, \ |
| 3167 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3168 |
+ if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \ |
| 3169 |
+ return { static_cast<bool>( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3170 |
+ } |
| 3171 |
|
| 3172 |
- #define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(op) \ |
| 3173 |
- template<typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, int> = 0> \ |
| 3174 |
- friend auto operator op ( ExprLhs && lhs, RhsT && rhs ) -> BinaryExpr<LhsT, RhsT const&> { \ |
| 3175 |
- return { static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3176 |
- } \ |
| 3177 |
- template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value, int> = 0> \ |
| 3178 |
- friend auto operator op ( ExprLhs && lhs, RhsT rhs ) -> BinaryExpr<LhsT, RhsT> { \ |
| 3179 |
- return { static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3180 |
- } |
| 3181 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( lt, < ) |
| 3182 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( le, <= ) |
| 3183 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( gt, > ) |
| 3184 |
+ CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( ge, >= ) |
| 3185 |
+ |
| 3186 |
+ #undef CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR |
| 3187 |
+ |
| 3188 |
+ |
| 3189 |
+#define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR( op ) \ |
| 3190 |
+ template <typename RhsT> \ |
| 3191 |
+ friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ |
| 3192 |
+ ->std::enable_if_t< \ |
| 3193 |
+ !std::is_arithmetic<std::remove_reference_t<RhsT>>::value, \ |
| 3194 |
+ BinaryExpr<LhsT, RhsT const&>> { \ |
| 3195 |
+ return { \ |
| 3196 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3197 |
+ } \ |
| 3198 |
+ template <typename RhsT> \ |
| 3199 |
+ friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ |
| 3200 |
+ ->std::enable_if_t<std::is_arithmetic<RhsT>::value, \ |
| 3201 |
+ BinaryExpr<LhsT, RhsT>> { \ |
| 3202 |
+ return { \ |
| 3203 |
+ static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ |
| 3204 |
+ } |
| 3205 |
|
| 3206 |
- CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(<) |
| 3207 |
- CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(>) |
| 3208 |
- CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(<=) |
| 3209 |
- CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(>=) |
| 3210 |
CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(|) |
| 3211 |
CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(&) |
| 3212 |
CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(^) |
| 3213 |
@@ -5567,11 +5701,10 @@ namespace Catch { |
| 3214 |
|
| 3215 |
namespace Catch { |
| 3216 |
|
| 3217 |
- class IResultCapture; |
| 3218 |
- |
| 3219 |
struct AssertionReaction { |
| 3220 |
bool shouldDebugBreak = false; |
| 3221 |
bool shouldThrow = false; |
| 3222 |
+ bool shouldSkip = false; |
| 3223 |
}; |
| 3224 |
|
| 3225 |
class AssertionHandler { |
| 3226 |
@@ -5608,18 +5741,30 @@ namespace Catch { |
| 3227 |
void handleUnexpectedInflightException(); |
| 3228 |
|
| 3229 |
void complete(); |
| 3230 |
- void setCompleted(); |
| 3231 |
|
| 3232 |
// query |
| 3233 |
auto allowThrows() const -> bool; |
| 3234 |
}; |
| 3235 |
|
| 3236 |
- void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ); |
| 3237 |
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str ); |
| 3238 |
|
| 3239 |
} // namespace Catch |
| 3240 |
|
| 3241 |
#endif // CATCH_ASSERTION_HANDLER_HPP_INCLUDED |
| 3242 |
|
| 3243 |
+ |
| 3244 |
+#ifndef CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED |
| 3245 |
+#define CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED |
| 3246 |
+ |
| 3247 |
+ |
| 3248 |
+#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) |
| 3249 |
+ #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr |
| 3250 |
+#else |
| 3251 |
+ #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr |
| 3252 |
+#endif |
| 3253 |
+ |
| 3254 |
+#endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED |
| 3255 |
+ |
| 3256 |
// We need this suppression to leak, because it took until GCC 10 |
| 3257 |
// for the front end to handle local suppression via _Pragma properly |
| 3258 |
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ <= 9 |
| 3259 |
@@ -5628,12 +5773,6 @@ namespace Catch { |
| 3260 |
|
| 3261 |
#if !defined(CATCH_CONFIG_DISABLE) |
| 3262 |
|
| 3263 |
-#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) |
| 3264 |
- #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ |
| 3265 |
-#else |
| 3266 |
- #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" |
| 3267 |
-#endif |
| 3268 |
- |
| 3269 |
#if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 3270 |
|
| 3271 |
/////////////////////////////////////////////////////////////////////////////// |
| 3272 |
@@ -5701,6 +5840,7 @@ namespace Catch { |
| 3273 |
if( catchAssertionHandler.allowThrows() ) \ |
| 3274 |
try { \ |
| 3275 |
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3276 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ |
| 3277 |
CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ |
| 3278 |
static_cast<void>(__VA_ARGS__); \ |
| 3279 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 3280 |
@@ -5721,6 +5861,7 @@ namespace Catch { |
| 3281 |
if( catchAssertionHandler.allowThrows() ) \ |
| 3282 |
try { \ |
| 3283 |
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3284 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ |
| 3285 |
CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ |
| 3286 |
static_cast<void>(expr); \ |
| 3287 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 3288 |
@@ -5747,27 +5888,56 @@ namespace Catch { |
| 3289 |
if( catchAssertionHandler.allowThrows() ) \ |
| 3290 |
try { \ |
| 3291 |
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3292 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ |
| 3293 |
CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ |
| 3294 |
static_cast<void>(__VA_ARGS__); \ |
| 3295 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 3296 |
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ |
| 3297 |
} \ |
| 3298 |
catch( ... ) { \ |
| 3299 |
- Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \ |
| 3300 |
+ Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher ); \ |
| 3301 |
} \ |
| 3302 |
else \ |
| 3303 |
catchAssertionHandler.handleThrowingCallSkipped(); \ |
| 3304 |
INTERNAL_CATCH_REACT( catchAssertionHandler ) \ |
| 3305 |
} while( false ) |
| 3306 |
|
| 3307 |
-#endif // CATCH_CONFIG_DISABLE |
| 3308 |
+#endif // CATCH_CONFIG_DISABLE |
| 3309 |
+ |
| 3310 |
+#endif // CATCH_TEST_MACRO_IMPL_HPP_INCLUDED |
| 3311 |
+ |
| 3312 |
+ |
| 3313 |
+#ifndef CATCH_SECTION_HPP_INCLUDED |
| 3314 |
+#define CATCH_SECTION_HPP_INCLUDED |
| 3315 |
+ |
| 3316 |
+ |
| 3317 |
+ |
| 3318 |
|
| 3319 |
-#endif // CATCH_TEST_MACRO_IMPL_HPP_INCLUDED |
| 3320 |
+/** \file |
| 3321 |
+ * Wrapper for the STATIC_ANALYSIS_SUPPORT configuration option |
| 3322 |
+ * |
| 3323 |
+ * Some of Catch2's macros can be defined differently to work better with |
| 3324 |
+ * static analysis tools, like clang-tidy or coverity. |
| 3325 |
+ * Currently the main use case is to show that `SECTION`s are executed |
| 3326 |
+ * exclusively, and not all in one run of a `TEST_CASE`. |
| 3327 |
+ */ |
| 3328 |
|
| 3329 |
+#ifndef CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED |
| 3330 |
+#define CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED |
| 3331 |
+ |
| 3332 |
+ |
| 3333 |
+#if defined(__clang_analyzer__) || defined(__COVERITY__) |
| 3334 |
+ #define CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT |
| 3335 |
+#endif |
| 3336 |
+ |
| 3337 |
+#if defined( CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT ) && \ |
| 3338 |
+ !defined( CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) && \ |
| 3339 |
+ !defined( CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) |
| 3340 |
+# define CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT |
| 3341 |
+#endif |
| 3342 |
|
| 3343 |
-#ifndef CATCH_SECTION_HPP_INCLUDED |
| 3344 |
-#define CATCH_SECTION_HPP_INCLUDED |
| 3345 |
|
| 3346 |
+#endif // CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED |
| 3347 |
|
| 3348 |
|
| 3349 |
#ifndef CATCH_TIMER_HPP_INCLUDED |
| 3350 |
@@ -5796,6 +5966,9 @@ namespace Catch { |
| 3351 |
class Section : Detail::NonCopyable { |
| 3352 |
public: |
| 3353 |
Section( SectionInfo&& info ); |
| 3354 |
+ Section( SourceLineInfo const& _lineInfo, |
| 3355 |
+ StringRef _name, |
| 3356 |
+ const char* const = nullptr ); |
| 3357 |
~Section(); |
| 3358 |
|
| 3359 |
// This indicates whether the section should be executed or not |
| 3360 |
@@ -5811,17 +5984,63 @@ namespace Catch { |
| 3361 |
|
| 3362 |
} // end namespace Catch |
| 3363 |
|
| 3364 |
-#define INTERNAL_CATCH_SECTION( ... ) \ |
| 3365 |
- CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3366 |
- CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3367 |
- if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ |
| 3368 |
- CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3369 |
+#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) |
| 3370 |
+# define INTERNAL_CATCH_SECTION( ... ) \ |
| 3371 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3372 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3373 |
+ if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ |
| 3374 |
+ catch_internal_Section ) = \ |
| 3375 |
+ Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ |
| 3376 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3377 |
+ |
| 3378 |
+# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ |
| 3379 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3380 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3381 |
+ if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \ |
| 3382 |
+ catch_internal_Section ) = \ |
| 3383 |
+ Catch::SectionInfo( \ |
| 3384 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 3385 |
+ ( Catch::ReusableStringStream() << __VA_ARGS__ ) \ |
| 3386 |
+ .str() ) ) \ |
| 3387 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3388 |
+ |
| 3389 |
+#else |
| 3390 |
+ |
| 3391 |
+// These section definitions imply that at most one section at one level |
| 3392 |
+// will be intered (because only one section's __LINE__ can be equal to |
| 3393 |
+// the dummy `catchInternalSectionHint` variable from `TEST_CASE`). |
| 3394 |
+ |
| 3395 |
+namespace Catch { |
| 3396 |
+ namespace Detail { |
| 3397 |
+ // Intentionally without linkage, as it should only be used as a dummy |
| 3398 |
+ // symbol for static analysis. |
| 3399 |
+ int GetNewSectionHint(); |
| 3400 |
+ } // namespace Detail |
| 3401 |
+} // namespace Catch |
| 3402 |
+ |
| 3403 |
+ |
| 3404 |
+# define INTERNAL_CATCH_SECTION( ... ) \ |
| 3405 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3406 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3407 |
+ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ |
| 3408 |
+ if ( [[maybe_unused]] int catchInternalPreviousSectionHint = \ |
| 3409 |
+ catchInternalSectionHint, \ |
| 3410 |
+ catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ |
| 3411 |
+ catchInternalPreviousSectionHint == __LINE__ ) \ |
| 3412 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3413 |
+ |
| 3414 |
+# define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ |
| 3415 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3416 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3417 |
+ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ |
| 3418 |
+ if ( [[maybe_unused]] int catchInternalPreviousSectionHint = \ |
| 3419 |
+ catchInternalSectionHint, \ |
| 3420 |
+ catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ |
| 3421 |
+ catchInternalPreviousSectionHint == __LINE__ ) \ |
| 3422 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3423 |
+ |
| 3424 |
+#endif |
| 3425 |
|
| 3426 |
-#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ |
| 3427 |
- CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3428 |
- CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3429 |
- if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ |
| 3430 |
- CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3431 |
|
| 3432 |
#endif // CATCH_SECTION_HPP_INCLUDED |
| 3433 |
|
| 3434 |
@@ -5831,42 +6050,20 @@ namespace Catch { |
| 3435 |
|
| 3436 |
|
| 3437 |
|
| 3438 |
-#ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 3439 |
-#define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 3440 |
- |
| 3441 |
-#include <vector> |
| 3442 |
+#ifndef CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED |
| 3443 |
+#define CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED |
| 3444 |
|
| 3445 |
namespace Catch { |
| 3446 |
|
| 3447 |
- class TestSpec; |
| 3448 |
- struct TestCaseInfo; |
| 3449 |
- |
| 3450 |
class ITestInvoker { |
| 3451 |
public: |
| 3452 |
- virtual void invoke () const = 0; |
| 3453 |
+ virtual void invoke() const = 0; |
| 3454 |
virtual ~ITestInvoker(); // = default |
| 3455 |
}; |
| 3456 |
|
| 3457 |
- class TestCaseHandle; |
| 3458 |
- class IConfig; |
| 3459 |
- |
| 3460 |
- class ITestCaseRegistry { |
| 3461 |
- public: |
| 3462 |
- virtual ~ITestCaseRegistry(); // = default |
| 3463 |
- // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later |
| 3464 |
- virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0; |
| 3465 |
- virtual std::vector<TestCaseHandle> const& getAllTests() const = 0; |
| 3466 |
- virtual std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const = 0; |
| 3467 |
- }; |
| 3468 |
- |
| 3469 |
- bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); |
| 3470 |
- bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); |
| 3471 |
- std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle> const& testCases, TestSpec const& testSpec, IConfig const& config ); |
| 3472 |
- std::vector<TestCaseHandle> const& getAllTestCasesSorted( IConfig const& config ); |
| 3473 |
- |
| 3474 |
-} |
| 3475 |
+} // namespace Catch |
| 3476 |
|
| 3477 |
-#endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 3478 |
+#endif // CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED |
| 3479 |
|
| 3480 |
|
| 3481 |
#ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED |
| 3482 |
@@ -5938,25 +6135,55 @@ struct AutoReg : Detail::NonCopyable { |
| 3483 |
void TestName::test() |
| 3484 |
#endif |
| 3485 |
|
| 3486 |
+ |
| 3487 |
+#if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) |
| 3488 |
+ |
| 3489 |
/////////////////////////////////////////////////////////////////////////////// |
| 3490 |
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ |
| 3491 |
static void TestName(); \ |
| 3492 |
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3493 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3494 |
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3495 |
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
| 3496 |
+ namespace{ const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
| 3497 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 3498 |
static void TestName() |
| 3499 |
#define INTERNAL_CATCH_TESTCASE( ... ) \ |
| 3500 |
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ ) |
| 3501 |
|
| 3502 |
- /////////////////////////////////////////////////////////////////////////////// |
| 3503 |
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ |
| 3504 |
- CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3505 |
- CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3506 |
- CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3507 |
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
| 3508 |
- CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3509 |
+#else // ^^ !CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT | vv CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT |
| 3510 |
+ |
| 3511 |
+ |
| 3512 |
+// Dummy registrator for the dumy test case macros |
| 3513 |
+namespace Catch { |
| 3514 |
+ namespace Detail { |
| 3515 |
+ struct DummyUse { |
| 3516 |
+ DummyUse( void ( * )( int ) ); |
| 3517 |
+ }; |
| 3518 |
+ } // namespace Detail |
| 3519 |
+} // namespace Catch |
| 3520 |
+ |
| 3521 |
+// Note that both the presence of the argument and its exact name are |
| 3522 |
+// necessary for the section support. |
| 3523 |
+ |
| 3524 |
+// We provide a shadowed variable so that a `SECTION` inside non-`TEST_CASE` |
| 3525 |
+// tests can compile. The redefined `TEST_CASE` shadows this with param. |
| 3526 |
+static int catchInternalSectionHint = 0; |
| 3527 |
+ |
| 3528 |
+# define INTERNAL_CATCH_TESTCASE2( fname ) \ |
| 3529 |
+ static void fname( int ); \ |
| 3530 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3531 |
+ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3532 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3533 |
+ static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ |
| 3534 |
+ dummyUser )( &fname ); \ |
| 3535 |
+ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ |
| 3536 |
+ static void fname( [[maybe_unused]] int catchInternalSectionHint ) \ |
| 3537 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3538 |
+# define INTERNAL_CATCH_TESTCASE( ... ) \ |
| 3539 |
+ INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ) ) |
| 3540 |
+ |
| 3541 |
+ |
| 3542 |
+#endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT |
| 3543 |
|
| 3544 |
/////////////////////////////////////////////////////////////////////////////// |
| 3545 |
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ |
| 3546 |
@@ -5967,13 +6194,33 @@ struct AutoReg : Detail::NonCopyable { |
| 3547 |
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ |
| 3548 |
void test(); \ |
| 3549 |
}; \ |
| 3550 |
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
| 3551 |
+ const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ |
| 3552 |
+ Catch::makeTestInvoker( &TestName::test ), \ |
| 3553 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 3554 |
+ #ClassName##_catch_sr, \ |
| 3555 |
+ Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
| 3556 |
} \ |
| 3557 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
| 3558 |
void TestName::test() |
| 3559 |
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ |
| 3560 |
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) |
| 3561 |
|
| 3562 |
+ |
| 3563 |
+ /////////////////////////////////////////////////////////////////////////////// |
| 3564 |
+ #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ |
| 3565 |
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
| 3566 |
+ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3567 |
+ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3568 |
+ namespace { \ |
| 3569 |
+ const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ |
| 3570 |
+ Catch::makeTestInvoker( &QualifiedMethod ), \ |
| 3571 |
+ CATCH_INTERNAL_LINEINFO, \ |
| 3572 |
+ "&" #QualifiedMethod##_catch_sr, \ |
| 3573 |
+ Catch::NameAndTags{ __VA_ARGS__ } ); \ |
| 3574 |
+ } /* NOLINT */ \ |
| 3575 |
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 3576 |
+ |
| 3577 |
+ |
| 3578 |
/////////////////////////////////////////////////////////////////////////////// |
| 3579 |
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ |
| 3580 |
do { \ |
| 3581 |
@@ -6021,6 +6268,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3582 |
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 3583 |
#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 3584 |
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 3585 |
+ #define CATCH_SKIP( ... ) INTERNAL_CATCH_MSG( "SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 3586 |
|
| 3587 |
|
| 3588 |
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) |
| 3589 |
@@ -6074,6 +6322,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3590 |
#define CATCH_FAIL( ... ) (void)(0) |
| 3591 |
#define CATCH_FAIL_CHECK( ... ) (void)(0) |
| 3592 |
#define CATCH_SUCCEED( ... ) (void)(0) |
| 3593 |
+ #define CATCH_SKIP( ... ) (void)(0) |
| 3594 |
|
| 3595 |
#define CATCH_STATIC_REQUIRE( ... ) (void)(0) |
| 3596 |
#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0) |
| 3597 |
@@ -6118,6 +6367,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3598 |
#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 3599 |
#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 3600 |
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 3601 |
+ #define SKIP( ... ) INTERNAL_CATCH_MSG( "SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 3602 |
|
| 3603 |
|
| 3604 |
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) |
| 3605 |
@@ -6170,6 +6420,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3606 |
#define FAIL( ... ) (void)(0) |
| 3607 |
#define FAIL_CHECK( ... ) (void)(0) |
| 3608 |
#define SUCCEED( ... ) (void)(0) |
| 3609 |
+ #define SKIP( ... ) (void)(0) |
| 3610 |
|
| 3611 |
#define STATIC_REQUIRE( ... ) (void)(0) |
| 3612 |
#define STATIC_REQUIRE_FALSE( ... ) (void)(0) |
| 3613 |
@@ -6489,6 +6740,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3614 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 3615 |
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 3616 |
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3617 |
+ CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ |
| 3618 |
INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\ |
| 3619 |
namespace {\ |
| 3620 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ |
| 3621 |
@@ -6535,6 +6787,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3622 |
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
| 3623 |
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 3624 |
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3625 |
+ CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ |
| 3626 |
template<typename TestType> static void TestFuncName(); \ |
| 3627 |
namespace {\ |
| 3628 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ |
| 3629 |
@@ -6584,6 +6837,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3630 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3631 |
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 3632 |
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3633 |
+ CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ |
| 3634 |
template<typename TestType> static void TestFunc(); \ |
| 3635 |
namespace {\ |
| 3636 |
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ |
| 3637 |
@@ -6593,7 +6847,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3638 |
void reg_tests() { \ |
| 3639 |
size_t index = 0; \ |
| 3640 |
using expander = size_t[]; \ |
| 3641 |
- (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 */\ |
| 3642 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ |
| 3643 |
} \ |
| 3644 |
};\ |
| 3645 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ |
| 3646 |
@@ -6715,6 +6969,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3647 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 3648 |
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
| 3649 |
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ |
| 3650 |
+ CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ |
| 3651 |
template<typename TestType> \ |
| 3652 |
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ |
| 3653 |
void test();\ |
| 3654 |
@@ -6727,7 +6982,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3655 |
void reg_tests(){\ |
| 3656 |
size_t index = 0;\ |
| 3657 |
using expander = size_t[];\ |
| 3658 |
- (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 */ \ |
| 3659 |
+ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName##_catch_sr, Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ |
| 3660 |
}\ |
| 3661 |
};\ |
| 3662 |
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ |
| 3663 |
@@ -6855,6 +7110,7 @@ struct AutoReg : Detail::NonCopyable { |
| 3664 |
|
| 3665 |
|
| 3666 |
|
| 3667 |
+#include <cstdint> |
| 3668 |
#include <string> |
| 3669 |
#include <vector> |
| 3670 |
|
| 3671 |
@@ -7007,6 +7263,10 @@ namespace Catch { |
| 3672 |
#include <exception> |
| 3673 |
|
| 3674 |
namespace Catch { |
| 3675 |
+ namespace Detail { |
| 3676 |
+ void registerTranslatorImpl( |
| 3677 |
+ Detail::unique_ptr<IExceptionTranslator>&& translator ); |
| 3678 |
+ } |
| 3679 |
|
| 3680 |
class ExceptionTranslatorRegistrar { |
| 3681 |
template<typename T> |
| 3682 |
@@ -7040,9 +7300,9 @@ namespace Catch { |
| 3683 |
public: |
| 3684 |
template<typename T> |
| 3685 |
ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) { |
| 3686 |
- getMutableRegistryHub().registerTranslator( |
| 3687 |
- Detail::make_unique<ExceptionTranslator<T>>(translateFunction) |
| 3688 |
- ); |
| 3689 |
+ Detail::registerTranslatorImpl( |
| 3690 |
+ Detail::make_unique<ExceptionTranslator<T>>( |
| 3691 |
+ translateFunction ) ); |
| 3692 |
} |
| 3693 |
}; |
| 3694 |
|
| 3695 |
@@ -7114,8 +7374,8 @@ namespace Catch { |
| 3696 |
#define CATCH_VERSION_MACROS_HPP_INCLUDED |
| 3697 |
|
| 3698 |
#define CATCH_VERSION_MAJOR 3 |
| 3699 |
-#define CATCH_VERSION_MINOR 1 |
| 3700 |
-#define CATCH_VERSION_PATCH 1 |
| 3701 |
+#define CATCH_VERSION_MINOR 4 |
| 3702 |
+#define CATCH_VERSION_PATCH 0 |
| 3703 |
|
| 3704 |
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED |
| 3705 |
|
| 3706 |
@@ -7439,37 +7699,47 @@ namespace Detail { |
| 3707 |
return makeGenerators( value( T( CATCH_FORWARD( val ) ) ), CATCH_FORWARD( moreGenerators )... ); |
| 3708 |
} |
| 3709 |
|
| 3710 |
- auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; |
| 3711 |
+ IGeneratorTracker* acquireGeneratorTracker( StringRef generatorName, |
| 3712 |
+ SourceLineInfo const& lineInfo ); |
| 3713 |
+ IGeneratorTracker* createGeneratorTracker( StringRef generatorName, |
| 3714 |
+ SourceLineInfo lineInfo, |
| 3715 |
+ GeneratorBasePtr&& generator ); |
| 3716 |
|
| 3717 |
template<typename L> |
| 3718 |
- // Note: The type after -> is weird, because VS2015 cannot parse |
| 3719 |
- // the expression used in the typedef inside, when it is in |
| 3720 |
- // return type. Yeah. |
| 3721 |
- auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) { |
| 3722 |
+ auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> typename decltype(generatorExpression())::type { |
| 3723 |
using UnderlyingType = typename decltype(generatorExpression())::type; |
| 3724 |
|
| 3725 |
- IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo ); |
| 3726 |
- if (!tracker.hasGenerator()) { |
| 3727 |
- tracker.setGenerator(Catch::Detail::make_unique<Generators<UnderlyingType>>(generatorExpression())); |
| 3728 |
+ IGeneratorTracker* tracker = acquireGeneratorTracker( generatorName, lineInfo ); |
| 3729 |
+ // Creation of tracker is delayed after generator creation, so |
| 3730 |
+ // that constructing generator can fail without breaking everything. |
| 3731 |
+ if (!tracker) { |
| 3732 |
+ tracker = createGeneratorTracker( |
| 3733 |
+ generatorName, |
| 3734 |
+ lineInfo, |
| 3735 |
+ Catch::Detail::make_unique<Generators<UnderlyingType>>( |
| 3736 |
+ generatorExpression() ) ); |
| 3737 |
} |
| 3738 |
|
| 3739 |
- auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() ); |
| 3740 |
+ auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker->getGenerator() ); |
| 3741 |
return generator.get(); |
| 3742 |
} |
| 3743 |
|
| 3744 |
} // namespace Generators |
| 3745 |
} // namespace Catch |
| 3746 |
|
| 3747 |
+#define CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL( ... ) #__VA_ARGS__##_catch_sr |
| 3748 |
+#define CATCH_INTERNAL_GENERATOR_STRINGIZE(...) CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL(__VA_ARGS__) |
| 3749 |
+ |
| 3750 |
#define GENERATE( ... ) \ |
| 3751 |
- Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3752 |
+ Catch::Generators::generate( CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3753 |
CATCH_INTERNAL_LINEINFO, \ |
| 3754 |
[ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 3755 |
#define GENERATE_COPY( ... ) \ |
| 3756 |
- Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3757 |
+ Catch::Generators::generate( CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3758 |
CATCH_INTERNAL_LINEINFO, \ |
| 3759 |
[=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 3760 |
#define GENERATE_REF( ... ) \ |
| 3761 |
- Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3762 |
+ Catch::Generators::generate( CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ |
| 3763 |
CATCH_INTERNAL_LINEINFO, \ |
| 3764 |
[&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) |
| 3765 |
|
| 3766 |
@@ -7883,99 +8153,325 @@ public: |
| 3767 |
assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) && "Step moves away from end"); |
| 3768 |
} |
| 3769 |
|
| 3770 |
- RangeGenerator(T const& start, T const& end): |
| 3771 |
- RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) |
| 3772 |
- {} |
| 3773 |
+ RangeGenerator(T const& start, T const& end): |
| 3774 |
+ RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) |
| 3775 |
+ {} |
| 3776 |
+ |
| 3777 |
+ T const& get() const override { |
| 3778 |
+ return m_current; |
| 3779 |
+ } |
| 3780 |
+ |
| 3781 |
+ bool next() override { |
| 3782 |
+ m_current += m_step; |
| 3783 |
+ return (m_positive) ? (m_current < m_end) : (m_current > m_end); |
| 3784 |
+ } |
| 3785 |
+}; |
| 3786 |
+ |
| 3787 |
+template <typename T> |
| 3788 |
+GeneratorWrapper<T> range(T const& start, T const& end, T const& step) { |
| 3789 |
+ static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric"); |
| 3790 |
+ return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end, step)); |
| 3791 |
+} |
| 3792 |
+ |
| 3793 |
+template <typename T> |
| 3794 |
+GeneratorWrapper<T> range(T const& start, T const& end) { |
| 3795 |
+ static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer"); |
| 3796 |
+ return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end)); |
| 3797 |
+} |
| 3798 |
+ |
| 3799 |
+ |
| 3800 |
+template <typename T> |
| 3801 |
+class IteratorGenerator final : public IGenerator<T> { |
| 3802 |
+ static_assert(!std::is_same<T, bool>::value, |
| 3803 |
+ "IteratorGenerator currently does not support bools" |
| 3804 |
+ "because of std::vector<bool> specialization"); |
| 3805 |
+ |
| 3806 |
+ std::vector<T> m_elems; |
| 3807 |
+ size_t m_current = 0; |
| 3808 |
+public: |
| 3809 |
+ template <typename InputIterator, typename InputSentinel> |
| 3810 |
+ IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) { |
| 3811 |
+ if (m_elems.empty()) { |
| 3812 |
+ Detail::throw_generator_exception("IteratorGenerator received no valid values"); |
| 3813 |
+ } |
| 3814 |
+ } |
| 3815 |
+ |
| 3816 |
+ T const& get() const override { |
| 3817 |
+ return m_elems[m_current]; |
| 3818 |
+ } |
| 3819 |
+ |
| 3820 |
+ bool next() override { |
| 3821 |
+ ++m_current; |
| 3822 |
+ return m_current != m_elems.size(); |
| 3823 |
+ } |
| 3824 |
+}; |
| 3825 |
+ |
| 3826 |
+template <typename InputIterator, |
| 3827 |
+ typename InputSentinel, |
| 3828 |
+ typename ResultType = typename std::iterator_traits<InputIterator>::value_type> |
| 3829 |
+GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) { |
| 3830 |
+ return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(from, to)); |
| 3831 |
+} |
| 3832 |
+ |
| 3833 |
+template <typename Container, |
| 3834 |
+ typename ResultType = typename Container::value_type> |
| 3835 |
+GeneratorWrapper<ResultType> from_range(Container const& cnt) { |
| 3836 |
+ return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end())); |
| 3837 |
+} |
| 3838 |
+ |
| 3839 |
+ |
| 3840 |
+} // namespace Generators |
| 3841 |
+} // namespace Catch |
| 3842 |
+ |
| 3843 |
+ |
| 3844 |
+#endif // CATCH_GENERATORS_RANGE_HPP_INCLUDED |
| 3845 |
+ |
| 3846 |
+#endif // CATCH_GENERATORS_ALL_HPP_INCLUDED |
| 3847 |
+ |
| 3848 |
+ |
| 3849 |
+/** \file |
| 3850 |
+ * This is a convenience header for Catch2's interfaces. It includes |
| 3851 |
+ * **all** of Catch2 headers related to interfaces. |
| 3852 |
+ * |
| 3853 |
+ * Generally the Catch2 users should use specific includes they need, |
| 3854 |
+ * but this header can be used instead for ease-of-experimentation, or |
| 3855 |
+ * just plain convenience, at the cost of somewhat increased compilation |
| 3856 |
+ * times. |
| 3857 |
+ * |
| 3858 |
+ * When a new header is added to either the `interfaces` folder, or to |
| 3859 |
+ * the corresponding internal subfolder, it should be added here. |
| 3860 |
+ */ |
| 3861 |
+ |
| 3862 |
+ |
| 3863 |
+#ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 3864 |
+#define CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 3865 |
+ |
| 3866 |
+ |
| 3867 |
+ |
| 3868 |
+#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 3869 |
+#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 3870 |
+ |
| 3871 |
+ |
| 3872 |
+ |
| 3873 |
+#ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED |
| 3874 |
+#define CATCH_TEST_RUN_INFO_HPP_INCLUDED |
| 3875 |
+ |
| 3876 |
+ |
| 3877 |
+namespace Catch { |
| 3878 |
+ |
| 3879 |
+ struct TestRunInfo { |
| 3880 |
+ constexpr TestRunInfo(StringRef _name) : name(_name) {} |
| 3881 |
+ StringRef name; |
| 3882 |
+ }; |
| 3883 |
+ |
| 3884 |
+} // end namespace Catch |
| 3885 |
+ |
| 3886 |
+#endif // CATCH_TEST_RUN_INFO_HPP_INCLUDED |
| 3887 |
+ |
| 3888 |
+#include <map> |
| 3889 |
+#include <string> |
| 3890 |
+#include <vector> |
| 3891 |
+#include <iosfwd> |
| 3892 |
+ |
| 3893 |
+namespace Catch { |
| 3894 |
+ |
| 3895 |
+ struct ReporterDescription; |
| 3896 |
+ struct ListenerDescription; |
| 3897 |
+ struct TagInfo; |
| 3898 |
+ struct TestCaseInfo; |
| 3899 |
+ class TestCaseHandle; |
| 3900 |
+ class IConfig; |
| 3901 |
+ class IStream; |
| 3902 |
+ enum class ColourMode : std::uint8_t; |
| 3903 |
+ |
| 3904 |
+ struct ReporterConfig { |
| 3905 |
+ ReporterConfig( IConfig const* _fullConfig, |
| 3906 |
+ Detail::unique_ptr<IStream> _stream, |
| 3907 |
+ ColourMode colourMode, |
| 3908 |
+ std::map<std::string, std::string> customOptions ); |
| 3909 |
+ |
| 3910 |
+ ReporterConfig( ReporterConfig&& ) = default; |
| 3911 |
+ ReporterConfig& operator=( ReporterConfig&& ) = default; |
| 3912 |
+ ~ReporterConfig(); // = default |
| 3913 |
+ |
| 3914 |
+ Detail::unique_ptr<IStream> takeStream() &&; |
| 3915 |
+ IConfig const* fullConfig() const; |
| 3916 |
+ ColourMode colourMode() const; |
| 3917 |
+ std::map<std::string, std::string> const& customOptions() const; |
| 3918 |
+ |
| 3919 |
+ private: |
| 3920 |
+ Detail::unique_ptr<IStream> m_stream; |
| 3921 |
+ IConfig const* m_fullConfig; |
| 3922 |
+ ColourMode m_colourMode; |
| 3923 |
+ std::map<std::string, std::string> m_customOptions; |
| 3924 |
+ }; |
| 3925 |
+ |
| 3926 |
+ struct AssertionStats { |
| 3927 |
+ AssertionStats( AssertionResult const& _assertionResult, |
| 3928 |
+ std::vector<MessageInfo> const& _infoMessages, |
| 3929 |
+ Totals const& _totals ); |
| 3930 |
+ |
| 3931 |
+ AssertionStats( AssertionStats const& ) = default; |
| 3932 |
+ AssertionStats( AssertionStats && ) = default; |
| 3933 |
+ AssertionStats& operator = ( AssertionStats const& ) = delete; |
| 3934 |
+ AssertionStats& operator = ( AssertionStats && ) = delete; |
| 3935 |
+ |
| 3936 |
+ AssertionResult assertionResult; |
| 3937 |
+ std::vector<MessageInfo> infoMessages; |
| 3938 |
+ Totals totals; |
| 3939 |
+ }; |
| 3940 |
+ |
| 3941 |
+ struct SectionStats { |
| 3942 |
+ SectionStats( SectionInfo&& _sectionInfo, |
| 3943 |
+ Counts const& _assertions, |
| 3944 |
+ double _durationInSeconds, |
| 3945 |
+ bool _missingAssertions ); |
| 3946 |
|
| 3947 |
- T const& get() const override { |
| 3948 |
- return m_current; |
| 3949 |
- } |
| 3950 |
+ SectionInfo sectionInfo; |
| 3951 |
+ Counts assertions; |
| 3952 |
+ double durationInSeconds; |
| 3953 |
+ bool missingAssertions; |
| 3954 |
+ }; |
| 3955 |
|
| 3956 |
- bool next() override { |
| 3957 |
- m_current += m_step; |
| 3958 |
- return (m_positive) ? (m_current < m_end) : (m_current > m_end); |
| 3959 |
- } |
| 3960 |
-}; |
| 3961 |
+ struct TestCaseStats { |
| 3962 |
+ TestCaseStats( TestCaseInfo const& _testInfo, |
| 3963 |
+ Totals const& _totals, |
| 3964 |
+ std::string&& _stdOut, |
| 3965 |
+ std::string&& _stdErr, |
| 3966 |
+ bool _aborting ); |
| 3967 |
|
| 3968 |
-template <typename T> |
| 3969 |
-GeneratorWrapper<T> range(T const& start, T const& end, T const& step) { |
| 3970 |
- static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric"); |
| 3971 |
- return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end, step)); |
| 3972 |
-} |
| 3973 |
+ TestCaseInfo const * testInfo; |
| 3974 |
+ Totals totals; |
| 3975 |
+ std::string stdOut; |
| 3976 |
+ std::string stdErr; |
| 3977 |
+ bool aborting; |
| 3978 |
+ }; |
| 3979 |
|
| 3980 |
-template <typename T> |
| 3981 |
-GeneratorWrapper<T> range(T const& start, T const& end) { |
| 3982 |
- static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer"); |
| 3983 |
- return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end)); |
| 3984 |
-} |
| 3985 |
+ struct TestRunStats { |
| 3986 |
+ TestRunStats( TestRunInfo const& _runInfo, |
| 3987 |
+ Totals const& _totals, |
| 3988 |
+ bool _aborting ); |
| 3989 |
|
| 3990 |
+ TestRunInfo runInfo; |
| 3991 |
+ Totals totals; |
| 3992 |
+ bool aborting; |
| 3993 |
+ }; |
| 3994 |
|
| 3995 |
-template <typename T> |
| 3996 |
-class IteratorGenerator final : public IGenerator<T> { |
| 3997 |
- static_assert(!std::is_same<T, bool>::value, |
| 3998 |
- "IteratorGenerator currently does not support bools" |
| 3999 |
- "because of std::vector<bool> specialization"); |
| 4000 |
+ //! By setting up its preferences, a reporter can modify Catch2's behaviour |
| 4001 |
+ //! in some regards, e.g. it can request Catch2 to capture writes to |
| 4002 |
+ //! stdout/stderr during test execution, and pass them to the reporter. |
| 4003 |
+ struct ReporterPreferences { |
| 4004 |
+ //! Catch2 should redirect writes to stdout and pass them to the |
| 4005 |
+ //! reporter |
| 4006 |
+ bool shouldRedirectStdOut = false; |
| 4007 |
+ //! Catch2 should call `Reporter::assertionEnded` even for passing |
| 4008 |
+ //! assertions |
| 4009 |
+ bool shouldReportAllAssertions = false; |
| 4010 |
+ }; |
| 4011 |
|
| 4012 |
- std::vector<T> m_elems; |
| 4013 |
- size_t m_current = 0; |
| 4014 |
-public: |
| 4015 |
- template <typename InputIterator, typename InputSentinel> |
| 4016 |
- IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) { |
| 4017 |
- if (m_elems.empty()) { |
| 4018 |
- Detail::throw_generator_exception("IteratorGenerator received no valid values"); |
| 4019 |
- } |
| 4020 |
- } |
| 4021 |
+ /** |
| 4022 |
+ * The common base for all reporters and event listeners |
| 4023 |
+ * |
| 4024 |
+ * Implementing classes must also implement: |
| 4025 |
+ * |
| 4026 |
+ * //! User-friendly description of the reporter/listener type |
| 4027 |
+ * static std::string getDescription() |
| 4028 |
+ * |
| 4029 |
+ * Generally shouldn't be derived from by users of Catch2 directly, |
| 4030 |
+ * instead they should derive from one of the utility bases that |
| 4031 |
+ * derive from this class. |
| 4032 |
+ */ |
| 4033 |
+ class IEventListener { |
| 4034 |
+ protected: |
| 4035 |
+ //! Derived classes can set up their preferences here |
| 4036 |
+ ReporterPreferences m_preferences; |
| 4037 |
+ //! The test run's config as filled in from CLI and defaults |
| 4038 |
+ IConfig const* m_config; |
| 4039 |
|
| 4040 |
- T const& get() const override { |
| 4041 |
- return m_elems[m_current]; |
| 4042 |
- } |
| 4043 |
+ public: |
| 4044 |
+ IEventListener( IConfig const* config ): m_config( config ) {} |
| 4045 |
|
| 4046 |
- bool next() override { |
| 4047 |
- ++m_current; |
| 4048 |
- return m_current != m_elems.size(); |
| 4049 |
- } |
| 4050 |
-}; |
| 4051 |
+ virtual ~IEventListener(); // = default; |
| 4052 |
|
| 4053 |
-template <typename InputIterator, |
| 4054 |
- typename InputSentinel, |
| 4055 |
- typename ResultType = typename std::iterator_traits<InputIterator>::value_type> |
| 4056 |
-GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) { |
| 4057 |
- return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(from, to)); |
| 4058 |
-} |
| 4059 |
+ // Implementing class must also provide the following static methods: |
| 4060 |
+ // static std::string getDescription(); |
| 4061 |
|
| 4062 |
-template <typename Container, |
| 4063 |
- typename ResultType = typename Container::value_type> |
| 4064 |
-GeneratorWrapper<ResultType> from_range(Container const& cnt) { |
| 4065 |
- return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end())); |
| 4066 |
-} |
| 4067 |
+ ReporterPreferences const& getPreferences() const { |
| 4068 |
+ return m_preferences; |
| 4069 |
+ } |
| 4070 |
|
| 4071 |
+ //! Called when no test cases match provided test spec |
| 4072 |
+ virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; |
| 4073 |
+ //! Called for all invalid test specs from the cli |
| 4074 |
+ virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0; |
| 4075 |
|
| 4076 |
-} // namespace Generators |
| 4077 |
-} // namespace Catch |
| 4078 |
+ /** |
| 4079 |
+ * Called once in a testing run before tests are started |
| 4080 |
+ * |
| 4081 |
+ * Not called if tests won't be run (e.g. only listing will happen) |
| 4082 |
+ */ |
| 4083 |
+ virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; |
| 4084 |
|
| 4085 |
+ //! Called _once_ for each TEST_CASE, no matter how many times it is entered |
| 4086 |
+ virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; |
| 4087 |
+ //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
| 4088 |
+ virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0; |
| 4089 |
+ //! Called when a `SECTION` is being entered. Not called for skipped sections |
| 4090 |
+ virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; |
| 4091 |
|
| 4092 |
-#endif // CATCH_GENERATORS_RANGE_HPP_INCLUDED |
| 4093 |
+ //! Called when user-code is being probed before the actual benchmark runs |
| 4094 |
+ virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; |
| 4095 |
+ //! Called after probe but before the user-code is being benchmarked |
| 4096 |
+ virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; |
| 4097 |
+ //! Called with the benchmark results if benchmark successfully finishes |
| 4098 |
+ virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; |
| 4099 |
+ //! Called if running the benchmarks fails for any reason |
| 4100 |
+ virtual void benchmarkFailed( StringRef benchmarkName ) = 0; |
| 4101 |
|
| 4102 |
-#endif // CATCH_GENERATORS_ALL_HPP_INCLUDED |
| 4103 |
+ //! Called before assertion success/failure is evaluated |
| 4104 |
+ virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; |
| 4105 |
|
| 4106 |
+ //! Called after assertion was fully evaluated |
| 4107 |
+ virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; |
| 4108 |
|
| 4109 |
-/** \file |
| 4110 |
- * This is a convenience header for Catch2's interfaces. It includes |
| 4111 |
- * **all** of Catch2 headers related to interfaces. |
| 4112 |
- * |
| 4113 |
- * Generally the Catch2 users should use specific includes they need, |
| 4114 |
- * but this header can be used instead for ease-of-experimentation, or |
| 4115 |
- * just plain convenience, at the cost of somewhat increased compilation |
| 4116 |
- * times. |
| 4117 |
- * |
| 4118 |
- * When a new header is added to either the `interfaces` folder, or to |
| 4119 |
- * the corresponding internal subfolder, it should be added here. |
| 4120 |
- */ |
| 4121 |
+ //! Called after a `SECTION` has finished running |
| 4122 |
+ virtual void sectionEnded( SectionStats const& sectionStats ) = 0; |
| 4123 |
+ //! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
| 4124 |
+ virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0; |
| 4125 |
+ //! Called _once_ for each TEST_CASE, no matter how many times it is entered |
| 4126 |
+ virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; |
| 4127 |
+ /** |
| 4128 |
+ * Called once after all tests in a testing run are finished |
| 4129 |
+ * |
| 4130 |
+ * Not called if tests weren't run (e.g. only listings happened) |
| 4131 |
+ */ |
| 4132 |
+ virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; |
| 4133 |
|
| 4134 |
+ /** |
| 4135 |
+ * Called with test cases that are skipped due to the test run aborting. |
| 4136 |
+ * NOT called for test cases that are explicitly skipped using the `SKIP` macro. |
| 4137 |
+ * |
| 4138 |
+ * Deprecated - will be removed in the next major release. |
| 4139 |
+ */ |
| 4140 |
+ virtual void skipTest( TestCaseInfo const& testInfo ) = 0; |
| 4141 |
|
| 4142 |
-#ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 4143 |
-#define CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 4144 |
+ //! Called if a fatal error (signal/structured exception) occurred |
| 4145 |
+ virtual void fatalErrorEncountered( StringRef error ) = 0; |
| 4146 |
+ |
| 4147 |
+ //! Writes out information about provided reporters using reporter-specific format |
| 4148 |
+ virtual void listReporters(std::vector<ReporterDescription> const& descriptions) = 0; |
| 4149 |
+ //! Writes out the provided listeners descriptions using reporter-specific format |
| 4150 |
+ virtual void listListeners(std::vector<ListenerDescription> const& descriptions) = 0; |
| 4151 |
+ //! Writes out information about provided tests using reporter-specific format |
| 4152 |
+ virtual void listTests(std::vector<TestCaseHandle> const& tests) = 0; |
| 4153 |
+ //! Writes out information about the provided tags using reporter-specific format |
| 4154 |
+ virtual void listTags(std::vector<TagInfo> const& tags) = 0; |
| 4155 |
+ }; |
| 4156 |
+ using IEventListenerPtr = Detail::unique_ptr<IEventListener>; |
| 4157 |
+ |
| 4158 |
+} // end namespace Catch |
| 4159 |
|
| 4160 |
+#endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
| 4161 |
|
| 4162 |
|
| 4163 |
#ifndef CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED |
| 4164 |
@@ -8016,89 +8512,79 @@ namespace Catch { |
| 4165 |
#endif // CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED |
| 4166 |
|
| 4167 |
|
| 4168 |
-#ifndef CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED |
| 4169 |
-#define CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED |
| 4170 |
+#ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4171 |
+#define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4172 |
|
| 4173 |
+#include <string> |
| 4174 |
|
| 4175 |
+namespace Catch { |
| 4176 |
|
| 4177 |
-#ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4178 |
-#define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4179 |
+ struct TagAlias; |
| 4180 |
|
| 4181 |
+ class ITagAliasRegistry { |
| 4182 |
+ public: |
| 4183 |
+ virtual ~ITagAliasRegistry(); // = default |
| 4184 |
+ // Nullptr if not present |
| 4185 |
+ virtual TagAlias const* find( std::string const& alias ) const = 0; |
| 4186 |
+ virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; |
| 4187 |
|
| 4188 |
-namespace Catch { |
| 4189 |
- namespace Detail { |
| 4190 |
- //! Provides case-insensitive `op<` semantics when called |
| 4191 |
- struct CaseInsensitiveLess { |
| 4192 |
- bool operator()( StringRef lhs, |
| 4193 |
- StringRef rhs ) const; |
| 4194 |
- }; |
| 4195 |
+ static ITagAliasRegistry const& get(); |
| 4196 |
+ }; |
| 4197 |
|
| 4198 |
- //! Provides case-insensitive `op==` semantics when called |
| 4199 |
- struct CaseInsensitiveEqualTo { |
| 4200 |
- bool operator()( StringRef lhs, |
| 4201 |
- StringRef rhs ) const; |
| 4202 |
- }; |
| 4203 |
+} // end namespace Catch |
| 4204 |
|
| 4205 |
- } // namespace Detail |
| 4206 |
-} // namespace Catch |
| 4207 |
+#endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4208 |
|
| 4209 |
-#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4210 |
|
| 4211 |
-#include <string> |
| 4212 |
+#ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 4213 |
+#define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 4214 |
+ |
| 4215 |
#include <vector> |
| 4216 |
-#include <map> |
| 4217 |
|
| 4218 |
namespace Catch { |
| 4219 |
|
| 4220 |
+ struct TestCaseInfo; |
| 4221 |
+ class TestCaseHandle; |
| 4222 |
class IConfig; |
| 4223 |
|
| 4224 |
- class IEventListener; |
| 4225 |
- using IEventListenerPtr = Detail::unique_ptr<IEventListener>; |
| 4226 |
- class IReporterFactory; |
| 4227 |
- using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; |
| 4228 |
- struct ReporterConfig; |
| 4229 |
- class EventListenerFactory; |
| 4230 |
- |
| 4231 |
- class IReporterRegistry { |
| 4232 |
+ class ITestCaseRegistry { |
| 4233 |
public: |
| 4234 |
- using FactoryMap = std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess>; |
| 4235 |
- using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>; |
| 4236 |
- |
| 4237 |
- virtual ~IReporterRegistry(); // = default |
| 4238 |
- virtual IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const = 0; |
| 4239 |
- virtual FactoryMap const& getFactories() const = 0; |
| 4240 |
- virtual Listeners const& getListeners() const = 0; |
| 4241 |
+ virtual ~ITestCaseRegistry(); // = default |
| 4242 |
+ // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later |
| 4243 |
+ virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0; |
| 4244 |
+ virtual std::vector<TestCaseHandle> const& getAllTests() const = 0; |
| 4245 |
+ virtual std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const = 0; |
| 4246 |
}; |
| 4247 |
|
| 4248 |
-} // end namespace Catch |
| 4249 |
- |
| 4250 |
-#endif // CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED |
| 4251 |
- |
| 4252 |
+} |
| 4253 |
|
| 4254 |
-#ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4255 |
-#define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4256 |
+#endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED |
| 4257 |
|
| 4258 |
-#include <string> |
| 4259 |
+#endif // CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 4260 |
|
| 4261 |
-namespace Catch { |
| 4262 |
|
| 4263 |
- struct TagAlias; |
| 4264 |
+#ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4265 |
+#define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4266 |
|
| 4267 |
- class ITagAliasRegistry { |
| 4268 |
- public: |
| 4269 |
- virtual ~ITagAliasRegistry(); // = default |
| 4270 |
- // Nullptr if not present |
| 4271 |
- virtual TagAlias const* find( std::string const& alias ) const = 0; |
| 4272 |
- virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; |
| 4273 |
|
| 4274 |
- static ITagAliasRegistry const& get(); |
| 4275 |
- }; |
| 4276 |
+namespace Catch { |
| 4277 |
+ namespace Detail { |
| 4278 |
+ //! Provides case-insensitive `op<` semantics when called |
| 4279 |
+ struct CaseInsensitiveLess { |
| 4280 |
+ bool operator()( StringRef lhs, |
| 4281 |
+ StringRef rhs ) const; |
| 4282 |
+ }; |
| 4283 |
|
| 4284 |
-} // end namespace Catch |
| 4285 |
+ //! Provides case-insensitive `op==` semantics when called |
| 4286 |
+ struct CaseInsensitiveEqualTo { |
| 4287 |
+ bool operator()( StringRef lhs, |
| 4288 |
+ StringRef rhs ) const; |
| 4289 |
+ }; |
| 4290 |
|
| 4291 |
-#endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED |
| 4292 |
+ } // namespace Detail |
| 4293 |
+} // namespace Catch |
| 4294 |
|
| 4295 |
-#endif // CATCH_INTERFACES_ALL_HPP_INCLUDED |
| 4296 |
+#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED |
| 4297 |
|
| 4298 |
|
| 4299 |
|
| 4300 |
@@ -8140,6 +8626,7 @@ namespace Catch { |
| 4301 |
#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED |
| 4302 |
#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED |
| 4303 |
|
| 4304 |
+ |
| 4305 |
#if defined(_MSC_VER) |
| 4306 |
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer |
| 4307 |
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
| 4308 |
@@ -8272,7 +8759,10 @@ namespace Catch { |
| 4309 |
#if defined(__i386__) || defined(__x86_64__) |
| 4310 |
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ |
| 4311 |
#elif defined(__aarch64__) |
| 4312 |
- #define CATCH_TRAP() __asm__(".inst 0xd43e0000") |
| 4313 |
+ #define CATCH_TRAP() __asm__(".inst 0xd43e0000") |
| 4314 |
+ #elif defined(__POWERPC__) |
| 4315 |
+ #define CATCH_TRAP() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ |
| 4316 |
+ : : : "memory","r0","r3","r4" ) /* NOLINT */ |
| 4317 |
#endif |
| 4318 |
|
| 4319 |
#elif defined(CATCH_PLATFORM_IPHONE) |
| 4320 |
@@ -8427,7 +8917,6 @@ namespace Catch { |
| 4321 |
~ExceptionTranslatorRegistry() override; |
| 4322 |
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ); |
| 4323 |
std::string translateActiveException() const override; |
| 4324 |
- std::string tryTranslators() const; |
| 4325 |
|
| 4326 |
private: |
| 4327 |
ExceptionTranslators m_translators; |
| 4328 |
@@ -8607,6 +9096,154 @@ namespace Catch { |
| 4329 |
#endif // CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED |
| 4330 |
|
| 4331 |
|
| 4332 |
+#ifndef CATCH_GETENV_HPP_INCLUDED |
| 4333 |
+#define CATCH_GETENV_HPP_INCLUDED |
| 4334 |
+ |
| 4335 |
+namespace Catch { |
| 4336 |
+namespace Detail { |
| 4337 |
+ |
| 4338 |
+ //! Wrapper over `std::getenv` that compiles on UWP (and always returns nullptr there) |
| 4339 |
+ char const* getEnv(char const* varName); |
| 4340 |
+ |
| 4341 |
+} |
| 4342 |
+} |
| 4343 |
+ |
| 4344 |
+#endif // CATCH_GETENV_HPP_INCLUDED |
| 4345 |
+ |
| 4346 |
+ |
| 4347 |
+#ifndef CATCH_IS_PERMUTATION_HPP_INCLUDED |
| 4348 |
+#define CATCH_IS_PERMUTATION_HPP_INCLUDED |
| 4349 |
+ |
| 4350 |
+#include <algorithm> |
| 4351 |
+#include <iterator> |
| 4352 |
+ |
| 4353 |
+namespace Catch { |
| 4354 |
+ namespace Detail { |
| 4355 |
+ |
| 4356 |
+ template <typename ForwardIter, |
| 4357 |
+ typename Sentinel, |
| 4358 |
+ typename T, |
| 4359 |
+ typename Comparator> |
| 4360 |
+ ForwardIter find_sentinel( ForwardIter start, |
| 4361 |
+ Sentinel sentinel, |
| 4362 |
+ T const& value, |
| 4363 |
+ Comparator cmp ) { |
| 4364 |
+ while ( start != sentinel ) { |
| 4365 |
+ if ( cmp( *start, value ) ) { break; } |
| 4366 |
+ ++start; |
| 4367 |
+ } |
| 4368 |
+ return start; |
| 4369 |
+ } |
| 4370 |
+ |
| 4371 |
+ template <typename ForwardIter, |
| 4372 |
+ typename Sentinel, |
| 4373 |
+ typename T, |
| 4374 |
+ typename Comparator> |
| 4375 |
+ std::ptrdiff_t count_sentinel( ForwardIter start, |
| 4376 |
+ Sentinel sentinel, |
| 4377 |
+ T const& value, |
| 4378 |
+ Comparator cmp ) { |
| 4379 |
+ std::ptrdiff_t count = 0; |
| 4380 |
+ while ( start != sentinel ) { |
| 4381 |
+ if ( cmp( *start, value ) ) { ++count; } |
| 4382 |
+ ++start; |
| 4383 |
+ } |
| 4384 |
+ return count; |
| 4385 |
+ } |
| 4386 |
+ |
| 4387 |
+ template <typename ForwardIter, typename Sentinel> |
| 4388 |
+ std::enable_if_t<!std::is_same<ForwardIter, Sentinel>::value, |
| 4389 |
+ std::ptrdiff_t> |
| 4390 |
+ sentinel_distance( ForwardIter iter, const Sentinel sentinel ) { |
| 4391 |
+ std::ptrdiff_t dist = 0; |
| 4392 |
+ while ( iter != sentinel ) { |
| 4393 |
+ ++iter; |
| 4394 |
+ ++dist; |
| 4395 |
+ } |
| 4396 |
+ return dist; |
| 4397 |
+ } |
| 4398 |
+ |
| 4399 |
+ template <typename ForwardIter> |
| 4400 |
+ std::ptrdiff_t sentinel_distance( ForwardIter first, |
| 4401 |
+ ForwardIter last ) { |
| 4402 |
+ return std::distance( first, last ); |
| 4403 |
+ } |
| 4404 |
+ |
| 4405 |
+ template <typename ForwardIter1, |
| 4406 |
+ typename Sentinel1, |
| 4407 |
+ typename ForwardIter2, |
| 4408 |
+ typename Sentinel2, |
| 4409 |
+ typename Comparator> |
| 4410 |
+ bool check_element_counts( ForwardIter1 first_1, |
| 4411 |
+ const Sentinel1 end_1, |
| 4412 |
+ ForwardIter2 first_2, |
| 4413 |
+ const Sentinel2 end_2, |
| 4414 |
+ Comparator cmp ) { |
| 4415 |
+ auto cursor = first_1; |
| 4416 |
+ while ( cursor != end_1 ) { |
| 4417 |
+ if ( find_sentinel( first_1, cursor, *cursor, cmp ) == |
| 4418 |
+ cursor ) { |
| 4419 |
+ // we haven't checked this element yet |
| 4420 |
+ const auto count_in_range_2 = |
| 4421 |
+ count_sentinel( first_2, end_2, *cursor, cmp ); |
| 4422 |
+ // Not a single instance in 2nd range, so it cannot be a |
| 4423 |
+ // permutation of 1st range |
| 4424 |
+ if ( count_in_range_2 == 0 ) { return false; } |
| 4425 |
+ |
| 4426 |
+ const auto count_in_range_1 = |
| 4427 |
+ count_sentinel( cursor, end_1, *cursor, cmp ); |
| 4428 |
+ if ( count_in_range_1 != count_in_range_2 ) { |
| 4429 |
+ return false; |
| 4430 |
+ } |
| 4431 |
+ } |
| 4432 |
+ |
| 4433 |
+ ++cursor; |
| 4434 |
+ } |
| 4435 |
+ |
| 4436 |
+ return true; |
| 4437 |
+ } |
| 4438 |
+ |
| 4439 |
+ template <typename ForwardIter1, |
| 4440 |
+ typename Sentinel1, |
| 4441 |
+ typename ForwardIter2, |
| 4442 |
+ typename Sentinel2, |
| 4443 |
+ typename Comparator> |
| 4444 |
+ bool is_permutation( ForwardIter1 first_1, |
| 4445 |
+ const Sentinel1 end_1, |
| 4446 |
+ ForwardIter2 first_2, |
| 4447 |
+ const Sentinel2 end_2, |
| 4448 |
+ Comparator cmp ) { |
| 4449 |
+ // TODO: no optimization for stronger iterators, because we would also have to constrain on sentinel vs not sentinel types |
| 4450 |
+ // TODO: Comparator has to be "both sides", e.g. a == b => b == a |
| 4451 |
+ // This skips shared prefix of the two ranges |
| 4452 |
+ while (first_1 != end_1 && first_2 != end_2 && cmp(*first_1, *first_2)) { |
| 4453 |
+ ++first_1; |
| 4454 |
+ ++first_2; |
| 4455 |
+ } |
| 4456 |
+ |
| 4457 |
+ // We need to handle case where at least one of the ranges has no more elements |
| 4458 |
+ if (first_1 == end_1 || first_2 == end_2) { |
| 4459 |
+ return first_1 == end_1 && first_2 == end_2; |
| 4460 |
+ } |
| 4461 |
+ |
| 4462 |
+ // pair counting is n**2, so we pay linear walk to compare the sizes first |
| 4463 |
+ auto dist_1 = sentinel_distance( first_1, end_1 ); |
| 4464 |
+ auto dist_2 = sentinel_distance( first_2, end_2 ); |
| 4465 |
+ |
| 4466 |
+ if (dist_1 != dist_2) { return false; } |
| 4467 |
+ |
| 4468 |
+ // Since we do not try to handle stronger iterators pair (e.g. |
| 4469 |
+ // bidir) optimally, the only thing left to do is to check counts in |
| 4470 |
+ // the remaining ranges. |
| 4471 |
+ return check_element_counts( first_1, end_1, first_2, end_2, cmp ); |
| 4472 |
+ } |
| 4473 |
+ |
| 4474 |
+ } // namespace Detail |
| 4475 |
+} // namespace Catch |
| 4476 |
+ |
| 4477 |
+#endif // CATCH_IS_PERMUTATION_HPP_INCLUDED |
| 4478 |
+ |
| 4479 |
+ |
| 4480 |
#ifndef CATCH_ISTREAM_HPP_INCLUDED |
| 4481 |
#define CATCH_ISTREAM_HPP_INCLUDED |
| 4482 |
|
| 4483 |
@@ -8815,33 +9452,70 @@ namespace Catch { |
| 4484 |
#endif // CATCH_OUTPUT_REDIRECT_HPP_INCLUDED |
| 4485 |
|
| 4486 |
|
| 4487 |
+#ifndef CATCH_PARSE_NUMBERS_HPP_INCLUDED |
| 4488 |
+#define CATCH_PARSE_NUMBERS_HPP_INCLUDED |
| 4489 |
+ |
| 4490 |
+ |
| 4491 |
+#include <string> |
| 4492 |
+ |
| 4493 |
+namespace Catch { |
| 4494 |
+ |
| 4495 |
+ /** |
| 4496 |
+ * Parses unsigned int from the input, using provided base |
| 4497 |
+ * |
| 4498 |
+ * Effectively a wrapper around std::stoul but with better error checking |
| 4499 |
+ * e.g. "-1" is rejected, instead of being parsed as UINT_MAX. |
| 4500 |
+ */ |
| 4501 |
+ Optional<unsigned int> parseUInt(std::string const& input, int base = 10); |
| 4502 |
+} |
| 4503 |
+ |
| 4504 |
+#endif // CATCH_PARSE_NUMBERS_HPP_INCLUDED |
| 4505 |
+ |
| 4506 |
+ |
| 4507 |
#ifndef CATCH_REPORTER_REGISTRY_HPP_INCLUDED |
| 4508 |
#define CATCH_REPORTER_REGISTRY_HPP_INCLUDED |
| 4509 |
|
| 4510 |
|
| 4511 |
#include <map> |
| 4512 |
+#include <string> |
| 4513 |
+#include <vector> |
| 4514 |
|
| 4515 |
namespace Catch { |
| 4516 |
|
| 4517 |
- class ReporterRegistry : public IReporterRegistry { |
| 4518 |
- public: |
| 4519 |
+ class IEventListener; |
| 4520 |
+ using IEventListenerPtr = Detail::unique_ptr<IEventListener>; |
| 4521 |
+ class IReporterFactory; |
| 4522 |
+ using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; |
| 4523 |
+ struct ReporterConfig; |
| 4524 |
+ class EventListenerFactory; |
| 4525 |
|
| 4526 |
+ class ReporterRegistry { |
| 4527 |
+ struct ReporterRegistryImpl; |
| 4528 |
+ Detail::unique_ptr<ReporterRegistryImpl> m_impl; |
| 4529 |
+ |
| 4530 |
+ public: |
| 4531 |
ReporterRegistry(); |
| 4532 |
- ~ReporterRegistry() override; // = default, out of line to allow fwd decl |
| 4533 |
+ ~ReporterRegistry(); // = default; |
| 4534 |
|
| 4535 |
- IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const override; |
| 4536 |
+ IEventListenerPtr create( std::string const& name, |
| 4537 |
+ ReporterConfig&& config ) const; |
| 4538 |
|
| 4539 |
- void registerReporter( std::string const& name, IReporterFactoryPtr factory ); |
| 4540 |
- void registerListener( Detail::unique_ptr<EventListenerFactory> factory ); |
| 4541 |
+ void registerReporter( std::string const& name, |
| 4542 |
+ IReporterFactoryPtr factory ); |
| 4543 |
|
| 4544 |
- FactoryMap const& getFactories() const override; |
| 4545 |
- Listeners const& getListeners() const override; |
| 4546 |
+ void |
| 4547 |
+ registerListener( Detail::unique_ptr<EventListenerFactory> factory ); |
| 4548 |
|
| 4549 |
- private: |
| 4550 |
- FactoryMap m_factories; |
| 4551 |
- Listeners m_listeners; |
| 4552 |
+ std::map<std::string, |
| 4553 |
+ IReporterFactoryPtr, |
| 4554 |
+ Detail::CaseInsensitiveLess> const& |
| 4555 |
+ getFactories() const; |
| 4556 |
+ |
| 4557 |
+ std::vector<Detail::unique_ptr<EventListenerFactory>> const& |
| 4558 |
+ getListeners() const; |
| 4559 |
}; |
| 4560 |
-} |
| 4561 |
+ |
| 4562 |
+} // end namespace Catch |
| 4563 |
|
| 4564 |
#endif // CATCH_REPORTER_REGISTRY_HPP_INCLUDED |
| 4565 |
|
| 4566 |
@@ -8865,10 +9539,49 @@ namespace TestCaseTracking { |
| 4567 |
std::string name; |
| 4568 |
SourceLineInfo location; |
| 4569 |
|
| 4570 |
- NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); |
| 4571 |
+ NameAndLocation( std::string&& _name, SourceLineInfo const& _location ); |
| 4572 |
friend bool operator==(NameAndLocation const& lhs, NameAndLocation const& rhs) { |
| 4573 |
- return lhs.name == rhs.name |
| 4574 |
- && lhs.location == rhs.location; |
| 4575 |
+ // This is a very cheap check that should have a very high hit rate. |
| 4576 |
+ // If we get to SourceLineInfo::operator==, we will redo it, but the |
| 4577 |
+ // cost of repeating is trivial at that point (we will be paying |
| 4578 |
+ // multiple strcmp/memcmps at that point). |
| 4579 |
+ if ( lhs.location.line != rhs.location.line ) { return false; } |
| 4580 |
+ return lhs.name == rhs.name && lhs.location == rhs.location; |
| 4581 |
+ } |
| 4582 |
+ friend bool operator!=(NameAndLocation const& lhs, |
| 4583 |
+ NameAndLocation const& rhs) { |
| 4584 |
+ return !( lhs == rhs ); |
| 4585 |
+ } |
| 4586 |
+ }; |
| 4587 |
+ |
| 4588 |
+ /** |
| 4589 |
+ * This is a variant of `NameAndLocation` that does not own the name string |
| 4590 |
+ * |
| 4591 |
+ * This avoids extra allocations when trying to locate a tracker by its |
| 4592 |
+ * name and location, as long as we make sure that trackers only keep |
| 4593 |
+ * around the owning variant. |
| 4594 |
+ */ |
| 4595 |
+ struct NameAndLocationRef { |
| 4596 |
+ StringRef name; |
| 4597 |
+ SourceLineInfo location; |
| 4598 |
+ |
| 4599 |
+ constexpr NameAndLocationRef( StringRef name_, |
| 4600 |
+ SourceLineInfo location_ ): |
| 4601 |
+ name( name_ ), location( location_ ) {} |
| 4602 |
+ |
| 4603 |
+ friend bool operator==( NameAndLocation const& lhs, |
| 4604 |
+ NameAndLocationRef const& rhs ) { |
| 4605 |
+ // This is a very cheap check that should have a very high hit rate. |
| 4606 |
+ // If we get to SourceLineInfo::operator==, we will redo it, but the |
| 4607 |
+ // cost of repeating is trivial at that point (we will be paying |
| 4608 |
+ // multiple strcmp/memcmps at that point). |
| 4609 |
+ if ( lhs.location.line != rhs.location.line ) { return false; } |
| 4610 |
+ return StringRef( lhs.name ) == rhs.name && |
| 4611 |
+ lhs.location == rhs.location; |
| 4612 |
+ } |
| 4613 |
+ friend bool operator==( NameAndLocationRef const& lhs, |
| 4614 |
+ NameAndLocation const& rhs ) { |
| 4615 |
+ return rhs == lhs; |
| 4616 |
} |
| 4617 |
}; |
| 4618 |
|
| 4619 |
@@ -8896,8 +9609,8 @@ namespace TestCaseTracking { |
| 4620 |
CycleState m_runState = NotStarted; |
| 4621 |
|
| 4622 |
public: |
| 4623 |
- ITracker( NameAndLocation const& nameAndLoc, ITracker* parent ): |
| 4624 |
- m_nameAndLocation( nameAndLoc ), |
| 4625 |
+ ITracker( NameAndLocation&& nameAndLoc, ITracker* parent ): |
| 4626 |
+ m_nameAndLocation( CATCH_MOVE(nameAndLoc) ), |
| 4627 |
m_parent( parent ) |
| 4628 |
{} |
| 4629 |
|
| 4630 |
@@ -8917,8 +9630,10 @@ namespace TestCaseTracking { |
| 4631 |
|
| 4632 |
//! Returns true if tracker run to completion (successfully or not) |
| 4633 |
virtual bool isComplete() const = 0; |
| 4634 |
- //! Returns true if tracker run to completion succesfully |
| 4635 |
- bool isSuccessfullyCompleted() const; |
| 4636 |
+ //! Returns true if tracker run to completion successfully |
| 4637 |
+ bool isSuccessfullyCompleted() const { |
| 4638 |
+ return m_runState == CompletedSuccessfully; |
| 4639 |
+ } |
| 4640 |
//! Returns true if tracker has started but hasn't been completed |
| 4641 |
bool isOpen() const; |
| 4642 |
//! Returns true iff tracker has started |
| 4643 |
@@ -8936,7 +9651,7 @@ namespace TestCaseTracking { |
| 4644 |
* |
| 4645 |
* Returns nullptr if not found. |
| 4646 |
*/ |
| 4647 |
- ITracker* findChild( NameAndLocation const& nameAndLocation ); |
| 4648 |
+ ITracker* findChild( NameAndLocationRef const& nameAndLocation ); |
| 4649 |
//! Have any children been added? |
| 4650 |
bool hasChildren() const { |
| 4651 |
return !m_children.empty(); |
| 4652 |
@@ -8977,13 +9692,15 @@ namespace TestCaseTracking { |
| 4653 |
public: |
| 4654 |
|
| 4655 |
ITracker& startRun(); |
| 4656 |
- void endRun(); |
| 4657 |
|
| 4658 |
- void startCycle(); |
| 4659 |
+ void startCycle() { |
| 4660 |
+ m_currentTracker = m_rootTracker.get(); |
| 4661 |
+ m_runState = Executing; |
| 4662 |
+ } |
| 4663 |
void completeCycle(); |
| 4664 |
|
| 4665 |
bool completedCycle() const; |
| 4666 |
- ITracker& currentTracker(); |
| 4667 |
+ ITracker& currentTracker() { return *m_currentTracker; } |
| 4668 |
void setCurrentTracker( ITracker* tracker ); |
| 4669 |
}; |
| 4670 |
|
| 4671 |
@@ -8993,7 +9710,7 @@ namespace TestCaseTracking { |
| 4672 |
TrackerContext& m_ctx; |
| 4673 |
|
| 4674 |
public: |
| 4675 |
- TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 4676 |
+ TrackerBase( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 4677 |
|
| 4678 |
bool isComplete() const override; |
| 4679 |
|
| 4680 |
@@ -9009,22 +9726,26 @@ namespace TestCaseTracking { |
| 4681 |
|
| 4682 |
class SectionTracker : public TrackerBase { |
| 4683 |
std::vector<StringRef> m_filters; |
| 4684 |
- std::string m_trimmed_name; |
| 4685 |
+ // Note that lifetime-wise we piggy back off the name stored in the `ITracker` parent`. |
| 4686 |
+ // Currently it allocates owns the name, so this is safe. If it is later refactored |
| 4687 |
+ // to not own the name, the name still has to outlive the `ITracker` parent, so |
| 4688 |
+ // this should still be safe. |
| 4689 |
+ StringRef m_trimmed_name; |
| 4690 |
public: |
| 4691 |
- SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 4692 |
+ SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ); |
| 4693 |
|
| 4694 |
bool isSectionTracker() const override; |
| 4695 |
|
| 4696 |
bool isComplete() const override; |
| 4697 |
|
| 4698 |
- static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ); |
| 4699 |
+ static SectionTracker& acquire( TrackerContext& ctx, NameAndLocationRef const& nameAndLocation ); |
| 4700 |
|
| 4701 |
void tryOpen(); |
| 4702 |
|
| 4703 |
void addInitialFilters( std::vector<std::string> const& filters ); |
| 4704 |
void addNextFilters( std::vector<StringRef> const& filters ); |
| 4705 |
//! Returns filters active in this tracker |
| 4706 |
- std::vector<StringRef> const& getFilters() const; |
| 4707 |
+ std::vector<StringRef> const& getFilters() const { return m_filters; } |
| 4708 |
//! Returns whitespace-trimmed name of the tracked section |
| 4709 |
StringRef trimmedName() const; |
| 4710 |
}; |
| 4711 |
@@ -9043,13 +9764,14 @@ using TestCaseTracking::SectionTracker; |
| 4712 |
|
| 4713 |
namespace Catch { |
| 4714 |
|
| 4715 |
- class IMutableContext; |
| 4716 |
class IGeneratorTracker; |
| 4717 |
class IConfig; |
| 4718 |
+ class IEventListener; |
| 4719 |
+ using IEventListenerPtr = Detail::unique_ptr<IEventListener>; |
| 4720 |
|
| 4721 |
/////////////////////////////////////////////////////////////////////////// |
| 4722 |
|
| 4723 |
- class RunContext : public IResultCapture { |
| 4724 |
+ class RunContext final : public IResultCapture { |
| 4725 |
|
| 4726 |
public: |
| 4727 |
RunContext( RunContext const& ) = delete; |
| 4728 |
@@ -9078,7 +9800,7 @@ namespace Catch { |
| 4729 |
AssertionReaction& reaction ) override; |
| 4730 |
void handleUnexpectedInflightException |
| 4731 |
( AssertionInfo const& info, |
| 4732 |
- std::string const& message, |
| 4733 |
+ std::string&& message, |
| 4734 |
AssertionReaction& reaction ) override; |
| 4735 |
void handleIncomplete |
| 4736 |
( AssertionInfo const& info ) override; |
| 4737 |
@@ -9087,12 +9809,22 @@ namespace Catch { |
| 4738 |
ResultWas::OfType resultType, |
| 4739 |
AssertionReaction &reaction ) override; |
| 4740 |
|
| 4741 |
- bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override; |
| 4742 |
+ void notifyAssertionStarted( AssertionInfo const& info ) override; |
| 4743 |
+ bool sectionStarted( StringRef sectionName, |
| 4744 |
+ SourceLineInfo const& sectionLineInfo, |
| 4745 |
+ Counts& assertions ) override; |
| 4746 |
+ |
| 4747 |
+ void sectionEnded( SectionEndInfo&& endInfo ) override; |
| 4748 |
+ void sectionEndedEarly( SectionEndInfo&& endInfo ) override; |
| 4749 |
|
| 4750 |
- void sectionEnded( SectionEndInfo const& endInfo ) override; |
| 4751 |
- void sectionEndedEarly( SectionEndInfo const& endInfo ) override; |
| 4752 |
+ IGeneratorTracker* |
| 4753 |
+ acquireGeneratorTracker( StringRef generatorName, |
| 4754 |
+ SourceLineInfo const& lineInfo ) override; |
| 4755 |
+ IGeneratorTracker* createGeneratorTracker( |
| 4756 |
+ StringRef generatorName, |
| 4757 |
+ SourceLineInfo lineInfo, |
| 4758 |
+ Generators::GeneratorBasePtr&& generator ) override; |
| 4759 |
|
| 4760 |
- auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override; |
| 4761 |
|
| 4762 |
void benchmarkPreparing( StringRef name ) override; |
| 4763 |
void benchmarkStarting( BenchmarkInfo const& info ) override; |
| 4764 |
@@ -9102,7 +9834,7 @@ namespace Catch { |
| 4765 |
void pushScopedMessage( MessageInfo const& message ) override; |
| 4766 |
void popScopedMessage( MessageInfo const& message ) override; |
| 4767 |
|
| 4768 |
- void emplaceUnscopedMessage( MessageBuilder const& builder ) override; |
| 4769 |
+ void emplaceUnscopedMessage( MessageBuilder&& builder ) override; |
| 4770 |
|
| 4771 |
std::string getCurrentTestName() const override; |
| 4772 |
|
| 4773 |
@@ -9128,7 +9860,7 @@ namespace Catch { |
| 4774 |
void resetAssertionInfo(); |
| 4775 |
bool testForMissingAssertions( Counts& assertions ); |
| 4776 |
|
| 4777 |
- void assertionEnded( AssertionResult const& result ); |
| 4778 |
+ void assertionEnded( AssertionResult&& result ); |
| 4779 |
void reportExpr |
| 4780 |
( AssertionInfo const &info, |
| 4781 |
ResultWas::OfType resultType, |
| 4782 |
@@ -9142,7 +9874,6 @@ namespace Catch { |
| 4783 |
void handleUnfinishedSections(); |
| 4784 |
|
| 4785 |
TestRunInfo m_runInfo; |
| 4786 |
- IMutableContext& m_context; |
| 4787 |
TestCaseHandle const* m_activeTestCase = nullptr; |
| 4788 |
ITracker* m_testCaseTracker = nullptr; |
| 4789 |
Optional<AssertionResult> m_lastResult; |
| 4790 |
@@ -9290,6 +10021,7 @@ namespace Catch { |
| 4791 |
#define CATCH_STRING_MANIP_HPP_INCLUDED |
| 4792 |
|
| 4793 |
|
| 4794 |
+#include <cstdint> |
| 4795 |
#include <string> |
| 4796 |
#include <iosfwd> |
| 4797 |
#include <vector> |
| 4798 |
@@ -9398,16 +10130,14 @@ namespace Catch { |
| 4799 |
|
| 4800 |
namespace Catch { |
| 4801 |
|
| 4802 |
- class TestCaseHandle; |
| 4803 |
class IConfig; |
| 4804 |
+ class ITestInvoker; |
| 4805 |
+ class TestCaseHandle; |
| 4806 |
class TestSpec; |
| 4807 |
|
| 4808 |
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ); |
| 4809 |
|
| 4810 |
bool isThrowSafe( TestCaseHandle const& testCase, IConfig const& config ); |
| 4811 |
- bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ); |
| 4812 |
- |
| 4813 |
- void enforceNoDuplicateTestCases( std::vector<TestCaseHandle> const& functions ); |
| 4814 |
|
| 4815 |
std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle> const& testCases, TestSpec const& testSpec, IConfig const& config ); |
| 4816 |
std::vector<TestCaseHandle> const& getAllTestCasesSorted( IConfig const& config ); |
| 4817 |
@@ -9436,18 +10166,6 @@ namespace Catch { |
| 4818 |
|
| 4819 |
/////////////////////////////////////////////////////////////////////////// |
| 4820 |
|
| 4821 |
- class TestInvokerAsFunction final : public ITestInvoker { |
| 4822 |
- using TestType = void(*)(); |
| 4823 |
- TestType m_testAsFunction; |
| 4824 |
- public: |
| 4825 |
- TestInvokerAsFunction(TestType testAsFunction) noexcept: |
| 4826 |
- m_testAsFunction(testAsFunction) {} |
| 4827 |
- |
| 4828 |
- void invoke() const override; |
| 4829 |
- }; |
| 4830 |
- |
| 4831 |
- /////////////////////////////////////////////////////////////////////////// |
| 4832 |
- |
| 4833 |
|
| 4834 |
} // end namespace Catch |
| 4835 |
|
| 4836 |
@@ -9520,7 +10238,6 @@ namespace Catch { |
| 4837 |
} |
| 4838 |
|
| 4839 |
}; |
| 4840 |
- TestSpec parseTestSpec( std::string const& arg ); |
| 4841 |
|
| 4842 |
} // namespace Catch |
| 4843 |
|
| 4844 |
@@ -9584,7 +10301,7 @@ namespace Catch { |
| 4845 |
// Calculates the length of the current line |
| 4846 |
void calcLength(); |
| 4847 |
|
| 4848 |
- // Returns current indention width |
| 4849 |
+ // Returns current indentation width |
| 4850 |
size_t indentSize() const; |
| 4851 |
|
| 4852 |
// Creates an indented and (optionally) suffixed string from |
| 4853 |
@@ -9897,19 +10614,19 @@ namespace Catch { |
| 4854 |
#define CATCH_MATCHERS_IMPL_HPP_INCLUDED |
| 4855 |
|
| 4856 |
|
| 4857 |
+#include <string> |
| 4858 |
+ |
| 4859 |
namespace Catch { |
| 4860 |
|
| 4861 |
template<typename ArgT, typename MatcherT> |
| 4862 |
class MatchExpr : public ITransientExpression { |
| 4863 |
ArgT && m_arg; |
| 4864 |
MatcherT const& m_matcher; |
| 4865 |
- StringRef m_matcherString; |
| 4866 |
public: |
| 4867 |
- MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) |
| 4868 |
+ MatchExpr( ArgT && arg, MatcherT const& matcher ) |
| 4869 |
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose |
| 4870 |
m_arg( CATCH_FORWARD(arg) ), |
| 4871 |
- m_matcher( matcher ), |
| 4872 |
- m_matcherString( matcherString ) |
| 4873 |
+ m_matcher( matcher ) |
| 4874 |
{} |
| 4875 |
|
| 4876 |
void streamReconstructedExpression( std::ostream& os ) const override { |
| 4877 |
@@ -9926,11 +10643,11 @@ namespace Catch { |
| 4878 |
|
| 4879 |
using StringMatcher = Matchers::MatcherBase<std::string>; |
| 4880 |
|
| 4881 |
- void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ); |
| 4882 |
+ void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ); |
| 4883 |
|
| 4884 |
template<typename ArgT, typename MatcherT> |
| 4885 |
- auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> { |
| 4886 |
- return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher, matcherString ); |
| 4887 |
+ auto makeMatchExpr( ArgT && arg, MatcherT const& matcher ) -> MatchExpr<ArgT, MatcherT> { |
| 4888 |
+ return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher ); |
| 4889 |
} |
| 4890 |
|
| 4891 |
} // namespace Catch |
| 4892 |
@@ -9941,7 +10658,7 @@ namespace Catch { |
| 4893 |
do { \ |
| 4894 |
Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ |
| 4895 |
INTERNAL_CATCH_TRY { \ |
| 4896 |
- catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \ |
| 4897 |
+ catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \ |
| 4898 |
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ |
| 4899 |
INTERNAL_CATCH_REACT( catchAssertionHandler ) \ |
| 4900 |
} while( false ) |
| 4901 |
@@ -9957,7 +10674,7 @@ namespace Catch { |
| 4902 |
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ |
| 4903 |
} \ |
| 4904 |
catch( exceptionType const& ex ) { \ |
| 4905 |
- catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \ |
| 4906 |
+ catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher ) ); \ |
| 4907 |
} \ |
| 4908 |
catch( ... ) { \ |
| 4909 |
catchAssertionHandler.handleUnexpectedInflightException(); \ |
| 4910 |
@@ -10217,7 +10934,7 @@ namespace Matchers { |
| 4911 |
MatcherGenericBase() = default; |
| 4912 |
~MatcherGenericBase() override; // = default; |
| 4913 |
|
| 4914 |
- MatcherGenericBase(MatcherGenericBase&) = default; |
| 4915 |
+ MatcherGenericBase(MatcherGenericBase const&) = default; |
| 4916 |
MatcherGenericBase(MatcherGenericBase&&) = default; |
| 4917 |
|
| 4918 |
MatcherGenericBase& operator=(MatcherGenericBase const&) = delete; |
| 4919 |
@@ -10249,20 +10966,6 @@ namespace Matchers { |
| 4920 |
return arr; |
| 4921 |
} |
| 4922 |
|
| 4923 |
-#if defined( __cpp_lib_logical_traits ) && __cpp_lib_logical_traits >= 201510 |
| 4924 |
- |
| 4925 |
- using std::conjunction; |
| 4926 |
- |
| 4927 |
-#else // __cpp_lib_logical_traits |
| 4928 |
- |
| 4929 |
- template<typename... Cond> |
| 4930 |
- struct conjunction : std::true_type {}; |
| 4931 |
- |
| 4932 |
- template<typename Cond, typename... Rest> |
| 4933 |
- struct conjunction<Cond, Rest...> : std::integral_constant<bool, Cond::value && conjunction<Rest...>::value> {}; |
| 4934 |
- |
| 4935 |
-#endif // __cpp_lib_logical_traits |
| 4936 |
- |
| 4937 |
template<typename T> |
| 4938 |
using is_generic_matcher = std::is_base_of< |
| 4939 |
Catch::Matchers::MatcherGenericBase, |
| 4940 |
@@ -10270,7 +10973,7 @@ namespace Matchers { |
| 4941 |
>; |
| 4942 |
|
| 4943 |
template<typename... Ts> |
| 4944 |
- using are_generic_matchers = conjunction<is_generic_matcher<Ts>...>; |
| 4945 |
+ using are_generic_matchers = Catch::Detail::conjunction<is_generic_matcher<Ts>...>; |
| 4946 |
|
| 4947 |
template<typename T> |
| 4948 |
using is_matcher = std::is_base_of< |
| 4949 |
@@ -10605,13 +11308,11 @@ namespace Catch { |
| 4950 |
} |
| 4951 |
|
| 4952 |
template <typename RangeLike> |
| 4953 |
- bool match(RangeLike&& rng) const { |
| 4954 |
- using std::begin; using std::end; |
| 4955 |
- |
| 4956 |
- return end(rng) != std::find_if(begin(rng), end(rng), |
| 4957 |
- [&](auto const& elem) { |
| 4958 |
- return m_eq(elem, m_desired); |
| 4959 |
- }); |
| 4960 |
+ bool match( RangeLike&& rng ) const { |
| 4961 |
+ for ( auto&& elem : rng ) { |
| 4962 |
+ if ( m_eq( elem, m_desired ) ) { return true; } |
| 4963 |
+ } |
| 4964 |
+ return false; |
| 4965 |
} |
| 4966 |
}; |
| 4967 |
|
| 4968 |
@@ -10663,7 +11364,7 @@ namespace Catch { |
| 4969 |
/** |
| 4970 |
* Creates a matcher that checks whether a range contains a specific element. |
| 4971 |
* |
| 4972 |
- * Uses `eq` to do the comparisons |
| 4973 |
+ * Uses `eq` to do the comparisons, the element is provided on the rhs |
| 4974 |
*/ |
| 4975 |
template <typename T, typename Equality> |
| 4976 |
ContainsElementMatcher<T, Equality> Contains(T&& elem, Equality&& eq) { |
| 4977 |
@@ -10699,6 +11400,32 @@ public: |
| 4978 |
//! Creates a matcher that checks whether a std derived exception has the provided message |
| 4979 |
ExceptionMessageMatcher Message(std::string const& message); |
| 4980 |
|
| 4981 |
+template <typename StringMatcherType> |
| 4982 |
+class ExceptionMessageMatchesMatcher final |
| 4983 |
+ : public MatcherBase<std::exception> { |
| 4984 |
+ StringMatcherType m_matcher; |
| 4985 |
+ |
| 4986 |
+public: |
| 4987 |
+ ExceptionMessageMatchesMatcher( StringMatcherType matcher ): |
| 4988 |
+ m_matcher( CATCH_MOVE( matcher ) ) {} |
| 4989 |
+ |
| 4990 |
+ bool match( std::exception const& ex ) const override { |
| 4991 |
+ return m_matcher.match( ex.what() ); |
| 4992 |
+ } |
| 4993 |
+ |
| 4994 |
+ std::string describe() const override { |
| 4995 |
+ return " matches \"" + m_matcher.describe() + '"'; |
| 4996 |
+ } |
| 4997 |
+}; |
| 4998 |
+ |
| 4999 |
+//! Creates a matcher that checks whether a message from an std derived |
| 5000 |
+//! exception matches a provided matcher |
| 5001 |
+template <typename StringMatcherType> |
| 5002 |
+ExceptionMessageMatchesMatcher<StringMatcherType> |
| 5003 |
+MessageMatches( StringMatcherType&& matcher ) { |
| 5004 |
+ return { CATCH_FORWARD( matcher ) }; |
| 5005 |
+} |
| 5006 |
+ |
| 5007 |
} // namespace Matchers |
| 5008 |
} // namespace Catch |
| 5009 |
|
| 5010 |
@@ -10726,6 +11453,11 @@ namespace Matchers { |
| 5011 |
double m_margin; |
| 5012 |
}; |
| 5013 |
|
| 5014 |
+ //! Creates a matcher that accepts numbers within certain range of target |
| 5015 |
+ WithinAbsMatcher WithinAbs( double target, double margin ); |
| 5016 |
+ |
| 5017 |
+ |
| 5018 |
+ |
| 5019 |
class WithinUlpsMatcher final : public MatcherBase<double> { |
| 5020 |
public: |
| 5021 |
WithinUlpsMatcher( double target, |
| 5022 |
@@ -10739,6 +11471,13 @@ namespace Matchers { |
| 5023 |
Detail::FloatingPointKind m_type; |
| 5024 |
}; |
| 5025 |
|
| 5026 |
+ //! Creates a matcher that accepts doubles within certain ULP range of target |
| 5027 |
+ WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff); |
| 5028 |
+ //! Creates a matcher that accepts floats within certain ULP range of target |
| 5029 |
+ WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff); |
| 5030 |
+ |
| 5031 |
+ |
| 5032 |
+ |
| 5033 |
// Given IEEE-754 format for floats and doubles, we can assume |
| 5034 |
// that float -> double promotion is lossless. Given this, we can |
| 5035 |
// assume that if we do the standard relative comparison of |
| 5036 |
@@ -10755,13 +11494,6 @@ namespace Matchers { |
| 5037 |
double m_epsilon; |
| 5038 |
}; |
| 5039 |
|
| 5040 |
- //! Creates a matcher that accepts doubles within certain ULP range of target |
| 5041 |
- WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff); |
| 5042 |
- //! Creates a matcher that accepts floats within certain ULP range of target |
| 5043 |
- WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff); |
| 5044 |
- //! Creates a matcher that accepts numbers within certain range of target |
| 5045 |
- WithinAbsMatcher WithinAbs(double target, double margin); |
| 5046 |
- |
| 5047 |
//! Creates a matcher that accepts doubles within certain relative range of target |
| 5048 |
WithinRelMatcher WithinRel(double target, double eps); |
| 5049 |
//! Creates a matcher that accepts doubles within 100*DBL_EPS relative range of target |
| 5050 |
@@ -10771,6 +11503,17 @@ namespace Matchers { |
| 5051 |
//! Creates a matcher that accepts floats within 100*FLT_EPS relative range of target |
| 5052 |
WithinRelMatcher WithinRel(float target); |
| 5053 |
|
| 5054 |
+ |
| 5055 |
+ |
| 5056 |
+ class IsNaNMatcher final : public MatcherBase<double> { |
| 5057 |
+ public: |
| 5058 |
+ IsNaNMatcher() = default; |
| 5059 |
+ bool match( double const& matchee ) const override; |
| 5060 |
+ std::string describe() const override; |
| 5061 |
+ }; |
| 5062 |
+ |
| 5063 |
+ IsNaNMatcher IsNaN(); |
| 5064 |
+ |
| 5065 |
} // namespace Matchers |
| 5066 |
} // namespace Catch |
| 5067 |
|
| 5068 |
@@ -10986,6 +11729,143 @@ namespace Catch { |
| 5069 |
#endif // CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED |
| 5070 |
|
| 5071 |
|
| 5072 |
+#ifndef CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED |
| 5073 |
+#define CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED |
| 5074 |
+ |
| 5075 |
+ |
| 5076 |
+#include <algorithm> |
| 5077 |
+#include <utility> |
| 5078 |
+ |
| 5079 |
+namespace Catch { |
| 5080 |
+ namespace Matchers { |
| 5081 |
+ |
| 5082 |
+ /** |
| 5083 |
+ * Matcher for checking that an element contains the same |
| 5084 |
+ * elements in the same order |
| 5085 |
+ */ |
| 5086 |
+ template <typename TargetRangeLike, typename Equality> |
| 5087 |
+ class RangeEqualsMatcher final : public MatcherGenericBase { |
| 5088 |
+ TargetRangeLike m_desired; |
| 5089 |
+ Equality m_predicate; |
| 5090 |
+ |
| 5091 |
+ public: |
| 5092 |
+ template <typename TargetRangeLike2, typename Equality2> |
| 5093 |
+ RangeEqualsMatcher( TargetRangeLike2&& range, |
| 5094 |
+ Equality2&& predicate ): |
| 5095 |
+ m_desired( CATCH_FORWARD( range ) ), |
| 5096 |
+ m_predicate( CATCH_FORWARD( predicate ) ) {} |
| 5097 |
+ |
| 5098 |
+ template <typename RangeLike> |
| 5099 |
+ bool match( RangeLike&& rng ) const { |
| 5100 |
+ auto rng_start = begin( rng ); |
| 5101 |
+ const auto rng_end = end( rng ); |
| 5102 |
+ auto target_start = begin( m_desired ); |
| 5103 |
+ const auto target_end = end( m_desired ); |
| 5104 |
+ |
| 5105 |
+ while (rng_start != rng_end && target_start != target_end) { |
| 5106 |
+ if (!m_predicate(*rng_start, *target_start)) { |
| 5107 |
+ return false; |
| 5108 |
+ } |
| 5109 |
+ ++rng_start; |
| 5110 |
+ ++target_start; |
| 5111 |
+ } |
| 5112 |
+ return rng_start == rng_end && target_start == target_end; |
| 5113 |
+ } |
| 5114 |
+ |
| 5115 |
+ std::string describe() const override { |
| 5116 |
+ return "elements are " + Catch::Detail::stringify( m_desired ); |
| 5117 |
+ } |
| 5118 |
+ }; |
| 5119 |
+ |
| 5120 |
+ /** |
| 5121 |
+ * Matcher for checking that an element contains the same |
| 5122 |
+ * elements (but not necessarily in the same order) |
| 5123 |
+ */ |
| 5124 |
+ template <typename TargetRangeLike, typename Equality> |
| 5125 |
+ class UnorderedRangeEqualsMatcher final : public MatcherGenericBase { |
| 5126 |
+ TargetRangeLike m_desired; |
| 5127 |
+ Equality m_predicate; |
| 5128 |
+ |
| 5129 |
+ public: |
| 5130 |
+ template <typename TargetRangeLike2, typename Equality2> |
| 5131 |
+ UnorderedRangeEqualsMatcher( TargetRangeLike2&& range, |
| 5132 |
+ Equality2&& predicate ): |
| 5133 |
+ m_desired( CATCH_FORWARD( range ) ), |
| 5134 |
+ m_predicate( CATCH_FORWARD( predicate ) ) {} |
| 5135 |
+ |
| 5136 |
+ template <typename RangeLike> |
| 5137 |
+ bool match( RangeLike&& rng ) const { |
| 5138 |
+ using std::begin; |
| 5139 |
+ using std::end; |
| 5140 |
+ return Catch::Detail::is_permutation( begin( m_desired ), |
| 5141 |
+ end( m_desired ), |
| 5142 |
+ begin( rng ), |
| 5143 |
+ end( rng ), |
| 5144 |
+ m_predicate ); |
| 5145 |
+ } |
| 5146 |
+ |
| 5147 |
+ std::string describe() const override { |
| 5148 |
+ return "unordered elements are " + |
| 5149 |
+ ::Catch::Detail::stringify( m_desired ); |
| 5150 |
+ } |
| 5151 |
+ }; |
| 5152 |
+ |
| 5153 |
+ /** |
| 5154 |
+ * Creates a matcher that checks if all elements in a range are equal |
| 5155 |
+ * to all elements in another range. |
| 5156 |
+ * |
| 5157 |
+ * Uses `std::equal_to` to do the comparison |
| 5158 |
+ */ |
| 5159 |
+ template <typename RangeLike> |
| 5160 |
+ std::enable_if_t<!Detail::is_matcher<RangeLike>::value, |
| 5161 |
+ RangeEqualsMatcher<RangeLike, std::equal_to<>>> |
| 5162 |
+ RangeEquals( RangeLike&& range ) { |
| 5163 |
+ return { CATCH_FORWARD( range ), std::equal_to<>{} }; |
| 5164 |
+ } |
| 5165 |
+ |
| 5166 |
+ /** |
| 5167 |
+ * Creates a matcher that checks if all elements in a range are equal |
| 5168 |
+ * to all elements in another range. |
| 5169 |
+ * |
| 5170 |
+ * Uses to provided predicate `predicate` to do the comparisons |
| 5171 |
+ */ |
| 5172 |
+ template <typename RangeLike, typename Equality> |
| 5173 |
+ RangeEqualsMatcher<RangeLike, Equality> |
| 5174 |
+ RangeEquals( RangeLike&& range, Equality&& predicate ) { |
| 5175 |
+ return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; |
| 5176 |
+ } |
| 5177 |
+ |
| 5178 |
+ /** |
| 5179 |
+ * Creates a matcher that checks if all elements in a range are equal |
| 5180 |
+ * to all elements in another range, in some permutation |
| 5181 |
+ * |
| 5182 |
+ * Uses `std::equal_to` to do the comparison |
| 5183 |
+ */ |
| 5184 |
+ template <typename RangeLike> |
| 5185 |
+ std::enable_if_t< |
| 5186 |
+ !Detail::is_matcher<RangeLike>::value, |
| 5187 |
+ UnorderedRangeEqualsMatcher<RangeLike, std::equal_to<>>> |
| 5188 |
+ UnorderedRangeEquals( RangeLike&& range ) { |
| 5189 |
+ return { CATCH_FORWARD( range ), std::equal_to<>{} }; |
| 5190 |
+ } |
| 5191 |
+ |
| 5192 |
+ /** |
| 5193 |
+ * Creates a matcher that checks if all elements in a range are equal |
| 5194 |
+ * to all elements in another range, in some permutation. |
| 5195 |
+ * |
| 5196 |
+ * Uses to provided predicate `predicate` to do the comparisons |
| 5197 |
+ */ |
| 5198 |
+ template <typename RangeLike, typename Equality> |
| 5199 |
+ UnorderedRangeEqualsMatcher<RangeLike, Equality> |
| 5200 |
+ UnorderedRangeEquals( RangeLike&& range, Equality&& predicate ) { |
| 5201 |
+ return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; |
| 5202 |
+ } |
| 5203 |
+ } // namespace Matchers |
| 5204 |
+} // namespace Catch |
| 5205 |
+ |
| 5206 |
+#endif // CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED |
| 5207 |
+ |
| 5208 |
+ |
| 5209 |
#ifndef CATCH_MATCHERS_STRING_HPP_INCLUDED |
| 5210 |
#define CATCH_MATCHERS_STRING_HPP_INCLUDED |
| 5211 |
|
| 5212 |
@@ -11141,11 +12021,10 @@ namespace Matchers { |
| 5213 |
// - a more general approach would be via a compare template that defaults |
| 5214 |
// to using !=. but could be specialised for, e.g. std::vector<T> etc |
| 5215 |
// - then just call that directly |
| 5216 |
- if (m_comparator.size() != v.size()) |
| 5217 |
- return false; |
| 5218 |
- for (std::size_t i = 0; i < v.size(); ++i) |
| 5219 |
- if (m_comparator[i] != v[i]) |
| 5220 |
- return false; |
| 5221 |
+ if ( m_comparator.size() != v.size() ) { return false; } |
| 5222 |
+ for ( std::size_t i = 0; i < v.size(); ++i ) { |
| 5223 |
+ if ( !( m_comparator[i] == v[i] ) ) { return false; } |
| 5224 |
+ } |
| 5225 |
return true; |
| 5226 |
} |
| 5227 |
std::string describe() const override { |
| 5228 |
@@ -11480,7 +12359,6 @@ namespace Catch { |
| 5229 |
|
| 5230 |
namespace Catch { |
| 5231 |
// Fwd decls |
| 5232 |
- struct SummaryColumn; |
| 5233 |
class TablePrinter; |
| 5234 |
|
| 5235 |
class ConsoleReporter final : public StreamingReporterBase { |
| 5236 |
@@ -11524,12 +12402,7 @@ namespace Catch { |
| 5237 |
// subsequent lines |
| 5238 |
void printHeaderString(std::string const& _string, std::size_t indent = 0); |
| 5239 |
|
| 5240 |
- |
| 5241 |
- void printTotals(Totals const& totals); |
| 5242 |
- void printSummaryRow(StringRef label, std::vector<SummaryColumn> const& cols, std::size_t row); |
| 5243 |
- |
| 5244 |
void printTotalsDivider(Totals const& totals); |
| 5245 |
- void printSummaryDivider(); |
| 5246 |
|
| 5247 |
bool m_headerPrinted = false; |
| 5248 |
bool m_testRunInfoPrinted = false; |
| 5249 |
@@ -11655,7 +12528,7 @@ namespace Catch { |
| 5250 |
void skipTest(TestCaseInfo const&) override {} |
| 5251 |
|
| 5252 |
protected: |
| 5253 |
- //! Should the cumulative base store the assertion expansion for succesful assertions? |
| 5254 |
+ //! Should the cumulative base store the assertion expansion for successful assertions? |
| 5255 |
bool m_shouldStoreSuccesfulAssertions = true; |
| 5256 |
//! Should the cumulative base store the assertion expansion for failed assertions? |
| 5257 |
bool m_shouldStoreFailedAssertions = true; |
| 5258 |
@@ -11809,6 +12682,15 @@ namespace Catch { |
| 5259 |
bool isFiltered, |
| 5260 |
Verbosity verbosity ); |
| 5261 |
|
| 5262 |
+ /** |
| 5263 |
+ * Prints test run totals to the provided stream in user-friendly format |
| 5264 |
+ * |
| 5265 |
+ * Used by the console and compact reporters. |
| 5266 |
+ */ |
| 5267 |
+ void printTestRunTotals( std::ostream& stream, |
| 5268 |
+ ColourImpl& streamColour, |
| 5269 |
+ Totals const& totals ); |
| 5270 |
+ |
| 5271 |
} // end namespace Catch |
| 5272 |
|
| 5273 |
#endif // CATCH_REPORTER_HELPERS_HPP_INCLUDED |
| 5274 |
@@ -11953,7 +12835,8 @@ namespace Catch { |
| 5275 |
//! independent on the reporter's concrete type |
| 5276 |
void registerReporterImpl( std::string const& name, |
| 5277 |
IReporterFactoryPtr reporterPtr ); |
| 5278 |
- |
| 5279 |
+ //! Actually registers the factory, independent on listener's concrete type |
| 5280 |
+ void registerListenerImpl( Detail::unique_ptr<EventListenerFactory> listenerFactory ); |
| 5281 |
} // namespace Detail |
| 5282 |
|
| 5283 |
class IEventListener; |
| 5284 |
@@ -12014,7 +12897,7 @@ namespace Catch { |
| 5285 |
|
| 5286 |
public: |
| 5287 |
ListenerRegistrar(StringRef listenerName) { |
| 5288 |
- getMutableRegistryHub().registerListener( Detail::make_unique<TypedListenerFactory>(listenerName) ); |
| 5289 |
+ registerListenerImpl( Detail::make_unique<TypedListenerFactory>(listenerName) ); |
| 5290 |
} |
| 5291 |
}; |
| 5292 |
} |
| 5293 |
@@ -12035,7 +12918,7 @@ namespace Catch { |
| 5294 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
| 5295 |
namespace { \ |
| 5296 |
Catch::ListenerRegistrar<listenerType> INTERNAL_CATCH_UNIQUE_NAME( \ |
| 5297 |
- catch_internal_RegistrarFor )( #listenerType ); \ |
| 5298 |
+ catch_internal_RegistrarFor )( #listenerType##_catch_sr ); \ |
| 5299 |
} \ |
| 5300 |
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
| 5301 |
|
| 5302 |
@@ -12082,7 +12965,7 @@ namespace Catch { |
| 5303 |
|
| 5304 |
void writeRun( TestRunNode const& groupNode ); |
| 5305 |
|
| 5306 |
- void writeTestFile(std::string const& filename, std::vector<TestCaseNode const*> const& testCaseNodes); |
| 5307 |
+ void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes); |
| 5308 |
|
| 5309 |
void writeTestCase(TestCaseNode const& testCaseNode); |
| 5310 |
|
| 5311 |
diff --git a/Tests/Contrib/catch2/catch_amalgamated.cpp b/Tests/Contrib/catch2/catch_amalgamated.cpp |
| 5312 |
index ea60686..24baee1 100644 |
| 5313 |
--- a/Tests/Contrib/catch2/catch_amalgamated.cpp |
| 5314 |
+++ b/Tests/Contrib/catch2/catch_amalgamated.cpp |
| 5315 |
@@ -1,12 +1,12 @@ |
| 5316 |
// Copyright Catch2 Authors |
| 5317 |
// Distributed under the Boost Software License, Version 1.0. |
| 5318 |
-// (See accompanying file LICENSE_1_0.txt or copy at |
| 5319 |
+// (See accompanying file LICENSE.txt or copy at |
| 5320 |
// https://www.boost.org/LICENSE_1_0.txt) |
| 5321 |
|
| 5322 |
// SPDX-License-Identifier: BSL-1.0 |
| 5323 |
|
| 5324 |
-// Catch v3.1.1 |
| 5325 |
-// Generated: 2022-10-17 18:47:22.400176 |
| 5326 |
+// Catch v3.4.0 |
| 5327 |
+// Generated: 2023-07-13 13:23:09.554273 |
| 5328 |
// ---------------------------------------------------------- |
| 5329 |
// This file is an amalgamation of multiple different files. |
| 5330 |
// You probably shouldn't edit it directly. |
| 5331 |
@@ -60,6 +60,7 @@ namespace Catch { |
| 5332 |
|
| 5333 |
|
| 5334 |
|
| 5335 |
+ |
| 5336 |
#include <exception> |
| 5337 |
|
| 5338 |
namespace Catch { |
| 5339 |
@@ -88,7 +89,7 @@ namespace Catch { |
| 5340 |
|
| 5341 |
#include <cassert> |
| 5342 |
#include <cstddef> |
| 5343 |
-#include <iterator> |
| 5344 |
+#include <numeric> |
| 5345 |
#include <random> |
| 5346 |
|
| 5347 |
|
| 5348 |
@@ -96,117 +97,172 @@ namespace Catch { |
| 5349 |
#include <future> |
| 5350 |
#endif |
| 5351 |
|
| 5352 |
-namespace { |
| 5353 |
+namespace Catch { |
| 5354 |
+ namespace Benchmark { |
| 5355 |
+ namespace Detail { |
| 5356 |
+ namespace { |
| 5357 |
+ |
| 5358 |
+ template <typename URng, typename Estimator> |
| 5359 |
+ static sample |
| 5360 |
+ resample( URng& rng, |
| 5361 |
+ unsigned int resamples, |
| 5362 |
+ std::vector<double>::const_iterator first, |
| 5363 |
+ std::vector<double>::const_iterator last, |
| 5364 |
+ Estimator& estimator ) { |
| 5365 |
+ auto n = static_cast<size_t>( last - first ); |
| 5366 |
+ std::uniform_int_distribution<decltype( n )> dist( 0, |
| 5367 |
+ n - 1 ); |
| 5368 |
+ |
| 5369 |
+ sample out; |
| 5370 |
+ out.reserve( resamples ); |
| 5371 |
+ // We allocate the vector outside the loop to avoid realloc |
| 5372 |
+ // per resample |
| 5373 |
+ std::vector<double> resampled; |
| 5374 |
+ resampled.reserve( n ); |
| 5375 |
+ for ( size_t i = 0; i < resamples; ++i ) { |
| 5376 |
+ resampled.clear(); |
| 5377 |
+ for ( size_t s = 0; s < n; ++s ) { |
| 5378 |
+ resampled.push_back( |
| 5379 |
+ first[static_cast<std::ptrdiff_t>( |
| 5380 |
+ dist( rng ) )] ); |
| 5381 |
+ } |
| 5382 |
+ const auto estimate = |
| 5383 |
+ estimator( resampled.begin(), resampled.end() ); |
| 5384 |
+ out.push_back( estimate ); |
| 5385 |
+ } |
| 5386 |
+ std::sort( out.begin(), out.end() ); |
| 5387 |
+ return out; |
| 5388 |
+ } |
| 5389 |
|
| 5390 |
-using Catch::Benchmark::Detail::sample; |
| 5391 |
- |
| 5392 |
- template <typename URng, typename Estimator> |
| 5393 |
- sample resample(URng& rng, unsigned int resamples, std::vector<double>::iterator first, std::vector<double>::iterator last, Estimator& estimator) { |
| 5394 |
- auto n = static_cast<size_t>(last - first); |
| 5395 |
- std::uniform_int_distribution<decltype(n)> dist(0, n - 1); |
| 5396 |
- |
| 5397 |
- sample out; |
| 5398 |
- out.reserve(resamples); |
| 5399 |
- std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] { |
| 5400 |
- std::vector<double> resampled; |
| 5401 |
- resampled.reserve(n); |
| 5402 |
- std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[static_cast<std::ptrdiff_t>(dist(rng))]; }); |
| 5403 |
- return estimator(resampled.begin(), resampled.end()); |
| 5404 |
- }); |
| 5405 |
- std::sort(out.begin(), out.end()); |
| 5406 |
- return out; |
| 5407 |
- } |
| 5408 |
- |
| 5409 |
- |
| 5410 |
- double erf_inv(double x) { |
| 5411 |
- // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2 |
| 5412 |
- double w, p; |
| 5413 |
- |
| 5414 |
- w = -log((1.0 - x) * (1.0 + x)); |
| 5415 |
- |
| 5416 |
- if (w < 6.250000) { |
| 5417 |
- w = w - 3.125000; |
| 5418 |
- p = -3.6444120640178196996e-21; |
| 5419 |
- p = -1.685059138182016589e-19 + p * w; |
| 5420 |
- p = 1.2858480715256400167e-18 + p * w; |
| 5421 |
- p = 1.115787767802518096e-17 + p * w; |
| 5422 |
- p = -1.333171662854620906e-16 + p * w; |
| 5423 |
- p = 2.0972767875968561637e-17 + p * w; |
| 5424 |
- p = 6.6376381343583238325e-15 + p * w; |
| 5425 |
- p = -4.0545662729752068639e-14 + p * w; |
| 5426 |
- p = -8.1519341976054721522e-14 + p * w; |
| 5427 |
- p = 2.6335093153082322977e-12 + p * w; |
| 5428 |
- p = -1.2975133253453532498e-11 + p * w; |
| 5429 |
- p = -5.4154120542946279317e-11 + p * w; |
| 5430 |
- p = 1.051212273321532285e-09 + p * w; |
| 5431 |
- p = -4.1126339803469836976e-09 + p * w; |
| 5432 |
- p = -2.9070369957882005086e-08 + p * w; |
| 5433 |
- p = 4.2347877827932403518e-07 + p * w; |
| 5434 |
- p = -1.3654692000834678645e-06 + p * w; |
| 5435 |
- p = -1.3882523362786468719e-05 + p * w; |
| 5436 |
- p = 0.0001867342080340571352 + p * w; |
| 5437 |
- p = -0.00074070253416626697512 + p * w; |
| 5438 |
- p = -0.0060336708714301490533 + p * w; |
| 5439 |
- p = 0.24015818242558961693 + p * w; |
| 5440 |
- p = 1.6536545626831027356 + p * w; |
| 5441 |
- } else if (w < 16.000000) { |
| 5442 |
- w = sqrt(w) - 3.250000; |
| 5443 |
- p = 2.2137376921775787049e-09; |
| 5444 |
- p = 9.0756561938885390979e-08 + p * w; |
| 5445 |
- p = -2.7517406297064545428e-07 + p * w; |
| 5446 |
- p = 1.8239629214389227755e-08 + p * w; |
| 5447 |
- p = 1.5027403968909827627e-06 + p * w; |
| 5448 |
- p = -4.013867526981545969e-06 + p * w; |
| 5449 |
- p = 2.9234449089955446044e-06 + p * w; |
| 5450 |
- p = 1.2475304481671778723e-05 + p * w; |
| 5451 |
- p = -4.7318229009055733981e-05 + p * w; |
| 5452 |
- p = 6.8284851459573175448e-05 + p * w; |
| 5453 |
- p = 2.4031110387097893999e-05 + p * w; |
| 5454 |
- p = -0.0003550375203628474796 + p * w; |
| 5455 |
- p = 0.00095328937973738049703 + p * w; |
| 5456 |
- p = -0.0016882755560235047313 + p * w; |
| 5457 |
- p = 0.0024914420961078508066 + p * w; |
| 5458 |
- p = -0.0037512085075692412107 + p * w; |
| 5459 |
- p = 0.005370914553590063617 + p * w; |
| 5460 |
- p = 1.0052589676941592334 + p * w; |
| 5461 |
- p = 3.0838856104922207635 + p * w; |
| 5462 |
- } else { |
| 5463 |
- w = sqrt(w) - 5.000000; |
| 5464 |
- p = -2.7109920616438573243e-11; |
| 5465 |
- p = -2.5556418169965252055e-10 + p * w; |
| 5466 |
- p = 1.5076572693500548083e-09 + p * w; |
| 5467 |
- p = -3.7894654401267369937e-09 + p * w; |
| 5468 |
- p = 7.6157012080783393804e-09 + p * w; |
| 5469 |
- p = -1.4960026627149240478e-08 + p * w; |
| 5470 |
- p = 2.9147953450901080826e-08 + p * w; |
| 5471 |
- p = -6.7711997758452339498e-08 + p * w; |
| 5472 |
- p = 2.2900482228026654717e-07 + p * w; |
| 5473 |
- p = -9.9298272942317002539e-07 + p * w; |
| 5474 |
- p = 4.5260625972231537039e-06 + p * w; |
| 5475 |
- p = -1.9681778105531670567e-05 + p * w; |
| 5476 |
- p = 7.5995277030017761139e-05 + p * w; |
| 5477 |
- p = -0.00021503011930044477347 + p * w; |
| 5478 |
- p = -0.00013871931833623122026 + p * w; |
| 5479 |
- p = 1.0103004648645343977 + p * w; |
| 5480 |
- p = 4.8499064014085844221 + p * w; |
| 5481 |
- } |
| 5482 |
- return p * x; |
| 5483 |
- } |
| 5484 |
- |
| 5485 |
- double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) { |
| 5486 |
- auto m = Catch::Benchmark::Detail::mean(first, last); |
| 5487 |
- double variance = std::accumulate( first, |
| 5488 |
- last, |
| 5489 |
- 0., |
| 5490 |
- [m]( double a, double b ) { |
| 5491 |
- double diff = b - m; |
| 5492 |
- return a + diff * diff; |
| 5493 |
- } ) / |
| 5494 |
- ( last - first ); |
| 5495 |
- return std::sqrt( variance ); |
| 5496 |
- } |
| 5497 |
+ static double outlier_variance( Estimate<double> mean, |
| 5498 |
+ Estimate<double> stddev, |
| 5499 |
+ int n ) { |
| 5500 |
+ double sb = stddev.point; |
| 5501 |
+ double mn = mean.point / n; |
| 5502 |
+ double mg_min = mn / 2.; |
| 5503 |
+ double sg = (std::min)( mg_min / 4., sb / std::sqrt( n ) ); |
| 5504 |
+ double sg2 = sg * sg; |
| 5505 |
+ double sb2 = sb * sb; |
| 5506 |
+ |
| 5507 |
+ auto c_max = [n, mn, sb2, sg2]( double x ) -> double { |
| 5508 |
+ double k = mn - x; |
| 5509 |
+ double d = k * k; |
| 5510 |
+ double nd = n * d; |
| 5511 |
+ double k0 = -n * nd; |
| 5512 |
+ double k1 = sb2 - n * sg2 + nd; |
| 5513 |
+ double det = k1 * k1 - 4 * sg2 * k0; |
| 5514 |
+ return static_cast<int>( -2. * k0 / |
| 5515 |
+ ( k1 + std::sqrt( det ) ) ); |
| 5516 |
+ }; |
| 5517 |
+ |
| 5518 |
+ auto var_out = [n, sb2, sg2]( double c ) { |
| 5519 |
+ double nc = n - c; |
| 5520 |
+ return ( nc / n ) * ( sb2 - nc * sg2 ); |
| 5521 |
+ }; |
| 5522 |
+ |
| 5523 |
+ return (std::min)( var_out( 1 ), |
| 5524 |
+ var_out( |
| 5525 |
+ (std::min)( c_max( 0. ), |
| 5526 |
+ c_max( mg_min ) ) ) ) / |
| 5527 |
+ sb2; |
| 5528 |
+ } |
| 5529 |
|
| 5530 |
-} |
| 5531 |
+ static double erf_inv( double x ) { |
| 5532 |
+ // Code accompanying the article "Approximating the erfinv |
| 5533 |
+ // function" in GPU Computing Gems, Volume 2 |
| 5534 |
+ double w, p; |
| 5535 |
+ |
| 5536 |
+ w = -log( ( 1.0 - x ) * ( 1.0 + x ) ); |
| 5537 |
+ |
| 5538 |
+ if ( w < 6.250000 ) { |
| 5539 |
+ w = w - 3.125000; |
| 5540 |
+ p = -3.6444120640178196996e-21; |
| 5541 |
+ p = -1.685059138182016589e-19 + p * w; |
| 5542 |
+ p = 1.2858480715256400167e-18 + p * w; |
| 5543 |
+ p = 1.115787767802518096e-17 + p * w; |
| 5544 |
+ p = -1.333171662854620906e-16 + p * w; |
| 5545 |
+ p = 2.0972767875968561637e-17 + p * w; |
| 5546 |
+ p = 6.6376381343583238325e-15 + p * w; |
| 5547 |
+ p = -4.0545662729752068639e-14 + p * w; |
| 5548 |
+ p = -8.1519341976054721522e-14 + p * w; |
| 5549 |
+ p = 2.6335093153082322977e-12 + p * w; |
| 5550 |
+ p = -1.2975133253453532498e-11 + p * w; |
| 5551 |
+ p = -5.4154120542946279317e-11 + p * w; |
| 5552 |
+ p = 1.051212273321532285e-09 + p * w; |
| 5553 |
+ p = -4.1126339803469836976e-09 + p * w; |
| 5554 |
+ p = -2.9070369957882005086e-08 + p * w; |
| 5555 |
+ p = 4.2347877827932403518e-07 + p * w; |
| 5556 |
+ p = -1.3654692000834678645e-06 + p * w; |
| 5557 |
+ p = -1.3882523362786468719e-05 + p * w; |
| 5558 |
+ p = 0.0001867342080340571352 + p * w; |
| 5559 |
+ p = -0.00074070253416626697512 + p * w; |
| 5560 |
+ p = -0.0060336708714301490533 + p * w; |
| 5561 |
+ p = 0.24015818242558961693 + p * w; |
| 5562 |
+ p = 1.6536545626831027356 + p * w; |
| 5563 |
+ } else if ( w < 16.000000 ) { |
| 5564 |
+ w = sqrt( w ) - 3.250000; |
| 5565 |
+ p = 2.2137376921775787049e-09; |
| 5566 |
+ p = 9.0756561938885390979e-08 + p * w; |
| 5567 |
+ p = -2.7517406297064545428e-07 + p * w; |
| 5568 |
+ p = 1.8239629214389227755e-08 + p * w; |
| 5569 |
+ p = 1.5027403968909827627e-06 + p * w; |
| 5570 |
+ p = -4.013867526981545969e-06 + p * w; |
| 5571 |
+ p = 2.9234449089955446044e-06 + p * w; |
| 5572 |
+ p = 1.2475304481671778723e-05 + p * w; |
| 5573 |
+ p = -4.7318229009055733981e-05 + p * w; |
| 5574 |
+ p = 6.8284851459573175448e-05 + p * w; |
| 5575 |
+ p = 2.4031110387097893999e-05 + p * w; |
| 5576 |
+ p = -0.0003550375203628474796 + p * w; |
| 5577 |
+ p = 0.00095328937973738049703 + p * w; |
| 5578 |
+ p = -0.0016882755560235047313 + p * w; |
| 5579 |
+ p = 0.0024914420961078508066 + p * w; |
| 5580 |
+ p = -0.0037512085075692412107 + p * w; |
| 5581 |
+ p = 0.005370914553590063617 + p * w; |
| 5582 |
+ p = 1.0052589676941592334 + p * w; |
| 5583 |
+ p = 3.0838856104922207635 + p * w; |
| 5584 |
+ } else { |
| 5585 |
+ w = sqrt( w ) - 5.000000; |
| 5586 |
+ p = -2.7109920616438573243e-11; |
| 5587 |
+ p = -2.5556418169965252055e-10 + p * w; |
| 5588 |
+ p = 1.5076572693500548083e-09 + p * w; |
| 5589 |
+ p = -3.7894654401267369937e-09 + p * w; |
| 5590 |
+ p = 7.6157012080783393804e-09 + p * w; |
| 5591 |
+ p = -1.4960026627149240478e-08 + p * w; |
| 5592 |
+ p = 2.9147953450901080826e-08 + p * w; |
| 5593 |
+ p = -6.7711997758452339498e-08 + p * w; |
| 5594 |
+ p = 2.2900482228026654717e-07 + p * w; |
| 5595 |
+ p = -9.9298272942317002539e-07 + p * w; |
| 5596 |
+ p = 4.5260625972231537039e-06 + p * w; |
| 5597 |
+ p = -1.9681778105531670567e-05 + p * w; |
| 5598 |
+ p = 7.5995277030017761139e-05 + p * w; |
| 5599 |
+ p = -0.00021503011930044477347 + p * w; |
| 5600 |
+ p = -0.00013871931833623122026 + p * w; |
| 5601 |
+ p = 1.0103004648645343977 + p * w; |
| 5602 |
+ p = 4.8499064014085844221 + p * w; |
| 5603 |
+ } |
| 5604 |
+ return p * x; |
| 5605 |
+ } |
| 5606 |
+ |
| 5607 |
+ static double |
| 5608 |
+ standard_deviation( std::vector<double>::const_iterator first, |
| 5609 |
+ std::vector<double>::const_iterator last ) { |
| 5610 |
+ auto m = Catch::Benchmark::Detail::mean( first, last ); |
| 5611 |
+ double variance = |
| 5612 |
+ std::accumulate( first, |
| 5613 |
+ last, |
| 5614 |
+ 0., |
| 5615 |
+ [m]( double a, double b ) { |
| 5616 |
+ double diff = b - m; |
| 5617 |
+ return a + diff * diff; |
| 5618 |
+ } ) / |
| 5619 |
+ ( last - first ); |
| 5620 |
+ return std::sqrt( variance ); |
| 5621 |
+ } |
| 5622 |
+ |
| 5623 |
+ } // namespace |
| 5624 |
+ } // namespace Detail |
| 5625 |
+ } // namespace Benchmark |
| 5626 |
+} // namespace Catch |
| 5627 |
|
| 5628 |
namespace Catch { |
| 5629 |
namespace Benchmark { |
| 5630 |
@@ -236,6 +292,47 @@ namespace Catch { |
| 5631 |
return xj + g * (xj1 - xj); |
| 5632 |
} |
| 5633 |
|
| 5634 |
+ OutlierClassification |
| 5635 |
+ classify_outliers( std::vector<double>::const_iterator first, |
| 5636 |
+ std::vector<double>::const_iterator last ) { |
| 5637 |
+ std::vector<double> copy( first, last ); |
| 5638 |
+ |
| 5639 |
+ auto q1 = weighted_average_quantile( 1, 4, copy.begin(), copy.end() ); |
| 5640 |
+ auto q3 = weighted_average_quantile( 3, 4, copy.begin(), copy.end() ); |
| 5641 |
+ auto iqr = q3 - q1; |
| 5642 |
+ auto los = q1 - ( iqr * 3. ); |
| 5643 |
+ auto lom = q1 - ( iqr * 1.5 ); |
| 5644 |
+ auto him = q3 + ( iqr * 1.5 ); |
| 5645 |
+ auto his = q3 + ( iqr * 3. ); |
| 5646 |
+ |
| 5647 |
+ OutlierClassification o; |
| 5648 |
+ for ( ; first != last; ++first ) { |
| 5649 |
+ const double t = *first; |
| 5650 |
+ if ( t < los ) { |
| 5651 |
+ ++o.low_severe; |
| 5652 |
+ } else if ( t < lom ) { |
| 5653 |
+ ++o.low_mild; |
| 5654 |
+ } else if ( t > his ) { |
| 5655 |
+ ++o.high_severe; |
| 5656 |
+ } else if ( t > him ) { |
| 5657 |
+ ++o.high_mild; |
| 5658 |
+ } |
| 5659 |
+ ++o.samples_seen; |
| 5660 |
+ } |
| 5661 |
+ return o; |
| 5662 |
+ } |
| 5663 |
+ |
| 5664 |
+ double mean( std::vector<double>::const_iterator first, |
| 5665 |
+ std::vector<double>::const_iterator last ) { |
| 5666 |
+ auto count = last - first; |
| 5667 |
+ double sum = 0.; |
| 5668 |
+ while (first != last) { |
| 5669 |
+ sum += *first; |
| 5670 |
+ ++first; |
| 5671 |
+ } |
| 5672 |
+ return sum / static_cast<double>(count); |
| 5673 |
+ } |
| 5674 |
+ |
| 5675 |
|
| 5676 |
double erfc_inv(double x) { |
| 5677 |
return erf_inv(1.0 - x); |
| 5678 |
@@ -257,35 +354,10 @@ namespace Catch { |
| 5679 |
return result; |
| 5680 |
} |
| 5681 |
|
| 5682 |
- |
| 5683 |
- double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n) { |
| 5684 |
- double sb = stddev.point; |
| 5685 |
- double mn = mean.point / n; |
| 5686 |
- double mg_min = mn / 2.; |
| 5687 |
- double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); |
| 5688 |
- double sg2 = sg * sg; |
| 5689 |
- double sb2 = sb * sb; |
| 5690 |
- |
| 5691 |
- auto c_max = [n, mn, sb2, sg2](double x) -> double { |
| 5692 |
- double k = mn - x; |
| 5693 |
- double d = k * k; |
| 5694 |
- double nd = n * d; |
| 5695 |
- double k0 = -n * nd; |
| 5696 |
- double k1 = sb2 - n * sg2 + nd; |
| 5697 |
- double det = k1 * k1 - 4 * sg2 * k0; |
| 5698 |
- return static_cast<int>(-2. * k0 / (k1 + std::sqrt(det))); |
| 5699 |
- }; |
| 5700 |
- |
| 5701 |
- auto var_out = [n, sb2, sg2](double c) { |
| 5702 |
- double nc = n - c; |
| 5703 |
- return (nc / n) * (sb2 - nc * sg2); |
| 5704 |
- }; |
| 5705 |
- |
| 5706 |
- return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; |
| 5707 |
- } |
| 5708 |
- |
| 5709 |
- |
| 5710 |
- bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) { |
| 5711 |
+ bootstrap_analysis analyse_samples(double confidence_level, |
| 5712 |
+ unsigned int n_resamples, |
| 5713 |
+ std::vector<double>::iterator first, |
| 5714 |
+ std::vector<double>::iterator last) { |
| 5715 |
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION |
| 5716 |
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
| 5717 |
static std::random_device entropy; |
| 5718 |
@@ -293,11 +365,12 @@ namespace Catch { |
| 5719 |
|
| 5720 |
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++ |
| 5721 |
|
| 5722 |
- auto mean = &Detail::mean<std::vector<double>::iterator>; |
| 5723 |
+ auto mean = &Detail::mean; |
| 5724 |
auto stddev = &standard_deviation; |
| 5725 |
|
| 5726 |
#if defined(CATCH_CONFIG_USE_ASYNC) |
| 5727 |
- auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) { |
| 5728 |
+ auto Estimate = [=](double(*f)(std::vector<double>::const_iterator, |
| 5729 |
+ std::vector<double>::const_iterator)) { |
| 5730 |
auto seed = entropy(); |
| 5731 |
return std::async(std::launch::async, [=] { |
| 5732 |
std::mt19937 rng(seed); |
| 5733 |
@@ -312,7 +385,8 @@ namespace Catch { |
| 5734 |
auto mean_estimate = mean_future.get(); |
| 5735 |
auto stddev_estimate = stddev_future.get(); |
| 5736 |
#else |
| 5737 |
- auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) { |
| 5738 |
+ auto Estimate = [=](double(*f)(std::vector<double>::const_iterator, |
| 5739 |
+ std::vector<double>::const_iterator)) { |
| 5740 |
auto seed = entropy(); |
| 5741 |
std::mt19937 rng(seed); |
| 5742 |
auto resampled = resample(rng, n_resamples, first, last, f); |
| 5743 |
@@ -428,9 +502,9 @@ namespace Catch { |
| 5744 |
return reconstructedExpression; |
| 5745 |
} |
| 5746 |
|
| 5747 |
- AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) |
| 5748 |
+ AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData&& data ) |
| 5749 |
: m_info( info ), |
| 5750 |
- m_resultData( data ) |
| 5751 |
+ m_resultData( CATCH_MOVE(data) ) |
| 5752 |
{} |
| 5753 |
|
| 5754 |
// Result was a success |
| 5755 |
@@ -469,16 +543,15 @@ namespace Catch { |
| 5756 |
} |
| 5757 |
|
| 5758 |
std::string AssertionResult::getExpressionInMacro() const { |
| 5759 |
- std::string expr; |
| 5760 |
- if( m_info.macroName.empty() ) |
| 5761 |
- expr = static_cast<std::string>(m_info.capturedExpression); |
| 5762 |
- else { |
| 5763 |
- expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); |
| 5764 |
- expr += m_info.macroName; |
| 5765 |
- expr += "( "; |
| 5766 |
- expr += m_info.capturedExpression; |
| 5767 |
- expr += " )"; |
| 5768 |
+ if ( m_info.macroName.empty() ) { |
| 5769 |
+ return static_cast<std::string>( m_info.capturedExpression ); |
| 5770 |
} |
| 5771 |
+ std::string expr; |
| 5772 |
+ expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); |
| 5773 |
+ expr += m_info.macroName; |
| 5774 |
+ expr += "( "; |
| 5775 |
+ expr += m_info.capturedExpression; |
| 5776 |
+ expr += " )"; |
| 5777 |
return expr; |
| 5778 |
} |
| 5779 |
|
| 5780 |
@@ -508,32 +581,73 @@ namespace Catch { |
| 5781 |
|
| 5782 |
|
| 5783 |
|
| 5784 |
-namespace { |
| 5785 |
- bool provideBazelReporterOutput() { |
| 5786 |
-#if defined(CATCH_CONFIG_BAZEL_SUPPORT) |
| 5787 |
- return true; |
| 5788 |
-#elif defined(CATCH_PLATFORM_WINDOWS_UWP) |
| 5789 |
- // UWP does not support environment variables |
| 5790 |
- return false; |
| 5791 |
+#include <fstream> |
| 5792 |
+ |
| 5793 |
+namespace Catch { |
| 5794 |
+ |
| 5795 |
+ namespace { |
| 5796 |
+ static bool enableBazelEnvSupport() { |
| 5797 |
+#if defined( CATCH_CONFIG_BAZEL_SUPPORT ) |
| 5798 |
+ return true; |
| 5799 |
#else |
| 5800 |
+ return Detail::getEnv( "BAZEL_TEST" ) != nullptr; |
| 5801 |
+#endif |
| 5802 |
+ } |
| 5803 |
|
| 5804 |
-# if defined( _MSC_VER ) |
| 5805 |
- // On Windows getenv throws a warning as there is no input validation, |
| 5806 |
- // since the switch is hardcoded, this should not be an issue. |
| 5807 |
-# pragma warning( push ) |
| 5808 |
-# pragma warning( disable : 4996 ) |
| 5809 |
-# endif |
| 5810 |
+ struct bazelShardingOptions { |
| 5811 |
+ unsigned int shardIndex, shardCount; |
| 5812 |
+ std::string shardFilePath; |
| 5813 |
+ }; |
| 5814 |
|
| 5815 |
- return std::getenv( "BAZEL_TEST" ) != nullptr; |
| 5816 |
+ static Optional<bazelShardingOptions> readBazelShardingOptions() { |
| 5817 |
+ const auto bazelShardIndex = Detail::getEnv( "TEST_SHARD_INDEX" ); |
| 5818 |
+ const auto bazelShardTotal = Detail::getEnv( "TEST_TOTAL_SHARDS" ); |
| 5819 |
+ const auto bazelShardInfoFile = Detail::getEnv( "TEST_SHARD_STATUS_FILE" ); |
| 5820 |
+ |
| 5821 |
+ |
| 5822 |
+ const bool has_all = |
| 5823 |
+ bazelShardIndex && bazelShardTotal && bazelShardInfoFile; |
| 5824 |
+ if ( !has_all ) { |
| 5825 |
+ // We provide nice warning message if the input is |
| 5826 |
+ // misconfigured. |
| 5827 |
+ auto warn = []( const char* env_var ) { |
| 5828 |
+ Catch::cerr() |
| 5829 |
+ << "Warning: Bazel shard configuration is missing '" |
| 5830 |
+ << env_var << "'. Shard configuration is skipped.\n"; |
| 5831 |
+ }; |
| 5832 |
+ if ( !bazelShardIndex ) { |
| 5833 |
+ warn( "TEST_SHARD_INDEX" ); |
| 5834 |
+ } |
| 5835 |
+ if ( !bazelShardTotal ) { |
| 5836 |
+ warn( "TEST_TOTAL_SHARDS" ); |
| 5837 |
+ } |
| 5838 |
+ if ( !bazelShardInfoFile ) { |
| 5839 |
+ warn( "TEST_SHARD_STATUS_FILE" ); |
| 5840 |
+ } |
| 5841 |
+ return {}; |
| 5842 |
+ } |
| 5843 |
|
| 5844 |
-# if defined( _MSC_VER ) |
| 5845 |
-# pragma warning( pop ) |
| 5846 |
-# endif |
| 5847 |
-#endif |
| 5848 |
- } |
| 5849 |
-} |
| 5850 |
+ auto shardIndex = parseUInt( bazelShardIndex ); |
| 5851 |
+ if ( !shardIndex ) { |
| 5852 |
+ Catch::cerr() |
| 5853 |
+ << "Warning: could not parse 'TEST_SHARD_INDEX' ('" << bazelShardIndex |
| 5854 |
+ << "') as unsigned int.\n"; |
| 5855 |
+ return {}; |
| 5856 |
+ } |
| 5857 |
+ auto shardTotal = parseUInt( bazelShardTotal ); |
| 5858 |
+ if ( !shardTotal ) { |
| 5859 |
+ Catch::cerr() |
| 5860 |
+ << "Warning: could not parse 'TEST_TOTAL_SHARD' ('" |
| 5861 |
+ << bazelShardTotal << "') as unsigned int.\n"; |
| 5862 |
+ return {}; |
| 5863 |
+ } |
| 5864 |
+ |
| 5865 |
+ return bazelShardingOptions{ |
| 5866 |
+ *shardIndex, *shardTotal, bazelShardInfoFile }; |
| 5867 |
+ |
| 5868 |
+ } |
| 5869 |
+ } // end namespace |
| 5870 |
|
| 5871 |
-namespace Catch { |
| 5872 |
|
| 5873 |
bool operator==( ProcessedReporterSpec const& lhs, |
| 5874 |
ProcessedReporterSpec const& rhs ) { |
| 5875 |
@@ -556,18 +670,7 @@ namespace Catch { |
| 5876 |
elem = trim(elem); |
| 5877 |
} |
| 5878 |
|
| 5879 |
- |
| 5880 |
- TestSpecParser parser(ITagAliasRegistry::get()); |
| 5881 |
- if (!m_data.testsOrTags.empty()) { |
| 5882 |
- m_hasTestFilters = true; |
| 5883 |
- for (auto const& testOrTags : m_data.testsOrTags) { |
| 5884 |
- parser.parse(testOrTags); |
| 5885 |
- } |
| 5886 |
- } |
| 5887 |
- m_testSpec = parser.testSpec(); |
| 5888 |
- |
| 5889 |
- |
| 5890 |
- // Insert the default reporter if user hasn't asked for a specfic one |
| 5891 |
+ // Insert the default reporter if user hasn't asked for a specific one |
| 5892 |
if ( m_data.reporterSpecifications.empty() ) { |
| 5893 |
m_data.reporterSpecifications.push_back( { |
| 5894 |
#if defined( CATCH_CONFIG_DEFAULT_REPORTER ) |
| 5895 |
@@ -579,29 +682,21 @@ namespace Catch { |
| 5896 |
} ); |
| 5897 |
} |
| 5898 |
|
| 5899 |
-#if !defined(CATCH_PLATFORM_WINDOWS_UWP) |
| 5900 |
- if(provideBazelReporterOutput()){ |
| 5901 |
- // Register a JUnit reporter for Bazel. Bazel sets an environment |
| 5902 |
- // variable with the path to XML output. If this file is written to |
| 5903 |
- // during test, Bazel will not generate a default XML output. |
| 5904 |
- // This allows the XML output file to contain higher level of detail |
| 5905 |
- // than what is possible otherwise. |
| 5906 |
-# if defined( _MSC_VER ) |
| 5907 |
- // On Windows getenv throws a warning as there is no input validation, |
| 5908 |
- // since the key is hardcoded, this should not be an issue. |
| 5909 |
-# pragma warning( push ) |
| 5910 |
-# pragma warning( disable : 4996 ) |
| 5911 |
-# endif |
| 5912 |
- const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" ); |
| 5913 |
-# if defined( _MSC_VER ) |
| 5914 |
-# pragma warning( pop ) |
| 5915 |
-# endif |
| 5916 |
- if ( bazelOutputFilePtr != nullptr ) { |
| 5917 |
- m_data.reporterSpecifications.push_back( |
| 5918 |
- { "junit", std::string( bazelOutputFilePtr ), {}, {} } ); |
| 5919 |
+ if ( enableBazelEnvSupport() ) { |
| 5920 |
+ readBazelEnvVars(); |
| 5921 |
+ } |
| 5922 |
+ |
| 5923 |
+ // Bazel support can modify the test specs, so parsing has to happen |
| 5924 |
+ // after reading Bazel env vars. |
| 5925 |
+ TestSpecParser parser( ITagAliasRegistry::get() ); |
| 5926 |
+ if ( !m_data.testsOrTags.empty() ) { |
| 5927 |
+ m_hasTestFilters = true; |
| 5928 |
+ for ( auto const& testOrTags : m_data.testsOrTags ) { |
| 5929 |
+ parser.parse( testOrTags ); |
| 5930 |
} |
| 5931 |
- } |
| 5932 |
-#endif |
| 5933 |
+ } |
| 5934 |
+ m_testSpec = parser.testSpec(); |
| 5935 |
+ |
| 5936 |
|
| 5937 |
// We now fixup the reporter specs to handle default output spec, |
| 5938 |
// default colour spec, etc |
| 5939 |
@@ -681,6 +776,39 @@ namespace Catch { |
| 5940 |
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; } |
| 5941 |
std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); } |
| 5942 |
|
| 5943 |
+ void Config::readBazelEnvVars() { |
| 5944 |
+ // Register a JUnit reporter for Bazel. Bazel sets an environment |
| 5945 |
+ // variable with the path to XML output. If this file is written to |
| 5946 |
+ // during test, Bazel will not generate a default XML output. |
| 5947 |
+ // This allows the XML output file to contain higher level of detail |
| 5948 |
+ // than what is possible otherwise. |
| 5949 |
+ const auto bazelOutputFile = Detail::getEnv( "XML_OUTPUT_FILE" ); |
| 5950 |
+ |
| 5951 |
+ if ( bazelOutputFile ) { |
| 5952 |
+ m_data.reporterSpecifications.push_back( |
| 5953 |
+ { "junit", std::string( bazelOutputFile ), {}, {} } ); |
| 5954 |
+ } |
| 5955 |
+ |
| 5956 |
+ const auto bazelTestSpec = Detail::getEnv( "TESTBRIDGE_TEST_ONLY" ); |
| 5957 |
+ if ( bazelTestSpec ) { |
| 5958 |
+ // Presumably the test spec from environment should overwrite |
| 5959 |
+ // the one we got from CLI (if we got any) |
| 5960 |
+ m_data.testsOrTags.clear(); |
| 5961 |
+ m_data.testsOrTags.push_back( bazelTestSpec ); |
| 5962 |
+ } |
| 5963 |
+ |
| 5964 |
+ const auto bazelShardOptions = readBazelShardingOptions(); |
| 5965 |
+ if ( bazelShardOptions ) { |
| 5966 |
+ std::ofstream f( bazelShardOptions->shardFilePath, |
| 5967 |
+ std::ios_base::out | std::ios_base::trunc ); |
| 5968 |
+ if ( f.is_open() ) { |
| 5969 |
+ f << ""; |
| 5970 |
+ m_data.shardIndex = bazelShardOptions->shardIndex; |
| 5971 |
+ m_data.shardCount = bazelShardOptions->shardCount; |
| 5972 |
+ } |
| 5973 |
+ } |
| 5974 |
+ } |
| 5975 |
+ |
| 5976 |
} // end namespace Catch |
| 5977 |
|
| 5978 |
|
| 5979 |
@@ -703,8 +831,8 @@ namespace Catch { |
| 5980 |
//////////////////////////////////////////////////////////////////////////// |
| 5981 |
|
| 5982 |
|
| 5983 |
- ScopedMessage::ScopedMessage( MessageBuilder const& builder ): |
| 5984 |
- m_info( builder.m_info ) { |
| 5985 |
+ ScopedMessage::ScopedMessage( MessageBuilder&& builder ): |
| 5986 |
+ m_info( CATCH_MOVE(builder.m_info) ) { |
| 5987 |
m_info.message = builder.m_stream.str(); |
| 5988 |
getResultCapture().pushScopedMessage( m_info ); |
| 5989 |
} |
| 5990 |
@@ -721,7 +849,11 @@ namespace Catch { |
| 5991 |
} |
| 5992 |
|
| 5993 |
|
| 5994 |
- Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { |
| 5995 |
+ Capturer::Capturer( StringRef macroName, |
| 5996 |
+ SourceLineInfo const& lineInfo, |
| 5997 |
+ ResultWas::OfType resultType, |
| 5998 |
+ StringRef names ): |
| 5999 |
+ m_resultCapture( getResultCapture() ) { |
| 6000 |
auto trimmed = [&] (size_t start, size_t end) { |
| 6001 |
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) { |
| 6002 |
++start; |
| 6003 |
@@ -798,6 +930,8 @@ namespace Catch { |
| 6004 |
|
| 6005 |
|
| 6006 |
|
| 6007 |
+#include <exception> |
| 6008 |
+ |
| 6009 |
namespace Catch { |
| 6010 |
|
| 6011 |
namespace { |
| 6012 |
@@ -808,7 +942,7 @@ namespace Catch { |
| 6013 |
|
| 6014 |
public: // IRegistryHub |
| 6015 |
RegistryHub() = default; |
| 6016 |
- IReporterRegistry const& getReporterRegistry() const override { |
| 6017 |
+ ReporterRegistry const& getReporterRegistry() const override { |
| 6018 |
return m_reporterRegistry; |
| 6019 |
} |
| 6020 |
ITestCaseRegistry const& getTestCaseRegistry() const override { |
| 6021 |
@@ -884,6 +1018,7 @@ namespace Catch { |
| 6022 |
|
| 6023 |
#include <algorithm> |
| 6024 |
#include <cassert> |
| 6025 |
+#include <exception> |
| 6026 |
#include <iomanip> |
| 6027 |
#include <set> |
| 6028 |
|
| 6029 |
@@ -1198,6 +1333,12 @@ namespace Catch { |
| 6030 |
return 2; |
| 6031 |
} |
| 6032 |
|
| 6033 |
+ if ( totals.testCases.total() > 0 && |
| 6034 |
+ totals.testCases.total() == totals.testCases.skipped |
| 6035 |
+ && !m_config->zeroTestsCountAsSuccess() ) { |
| 6036 |
+ return 4; |
| 6037 |
+ } |
| 6038 |
+ |
| 6039 |
// Note that on unices only the lower 8 bits are usually used, clamping |
| 6040 |
// the return value to 255 prevents false negative when some multiple |
| 6041 |
// of 256 tests has failed |
| 6042 |
@@ -1360,12 +1501,20 @@ namespace Catch { |
| 6043 |
for (size_t idx = 0; idx < originalTags.size(); ++idx) { |
| 6044 |
auto c = originalTags[idx]; |
| 6045 |
if (c == '[') { |
| 6046 |
- assert(!inTag); |
| 6047 |
+ CATCH_ENFORCE( |
| 6048 |
+ !inTag, |
| 6049 |
+ "Found '[' inside a tag while registering test case '" |
| 6050 |
+ << _nameAndTags.name << "' at " << _lineInfo ); |
| 6051 |
+ |
| 6052 |
inTag = true; |
| 6053 |
tagStart = idx; |
| 6054 |
} |
| 6055 |
if (c == ']') { |
| 6056 |
- assert(inTag); |
| 6057 |
+ CATCH_ENFORCE( |
| 6058 |
+ inTag, |
| 6059 |
+ "Found unmatched ']' while registering test case '" |
| 6060 |
+ << _nameAndTags.name << "' at " << _lineInfo ); |
| 6061 |
+ |
| 6062 |
inTag = false; |
| 6063 |
tagEnd = idx; |
| 6064 |
assert(tagStart < tagEnd); |
| 6065 |
@@ -1374,7 +1523,11 @@ namespace Catch { |
| 6066 |
// it over to backing storage and actually reference the |
| 6067 |
// backing storage in the saved tags |
| 6068 |
StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1); |
| 6069 |
- CATCH_ENFORCE(!tagStr.empty(), "Empty tags are not allowed"); |
| 6070 |
+ CATCH_ENFORCE( !tagStr.empty(), |
| 6071 |
+ "Found an empty tag while registering test case '" |
| 6072 |
+ << _nameAndTags.name << "' at " |
| 6073 |
+ << _lineInfo ); |
| 6074 |
+ |
| 6075 |
enforceNotReservedTag(tagStr, lineInfo); |
| 6076 |
properties |= parseSpecialTag(tagStr); |
| 6077 |
// When copying a tag to the backing storage, we need to |
| 6078 |
@@ -1388,8 +1541,12 @@ namespace Catch { |
| 6079 |
// the tags. |
| 6080 |
internalAppendTag(tagStr); |
| 6081 |
} |
| 6082 |
- (void)inTag; // Silence "set-but-unused" warning in release mode. |
| 6083 |
} |
| 6084 |
+ CATCH_ENFORCE( !inTag, |
| 6085 |
+ "Found an unclosed tag while registering test case '" |
| 6086 |
+ << _nameAndTags.name << "' at " << _lineInfo ); |
| 6087 |
+ |
| 6088 |
+ |
| 6089 |
// Add [.] if relevant |
| 6090 |
if (isHidden()) { |
| 6091 |
internalAppendTag("."_sr); |
| 6092 |
@@ -1472,6 +1629,7 @@ namespace Catch { |
| 6093 |
#include <algorithm> |
| 6094 |
#include <string> |
| 6095 |
#include <vector> |
| 6096 |
+#include <ostream> |
| 6097 |
|
| 6098 |
namespace Catch { |
| 6099 |
|
| 6100 |
@@ -1495,6 +1653,10 @@ namespace Catch { |
| 6101 |
return m_wildcardPattern.matches( testCase.name ); |
| 6102 |
} |
| 6103 |
|
| 6104 |
+ void TestSpec::NamePattern::serializeTo( std::ostream& out ) const { |
| 6105 |
+ out << '"' << name() << '"'; |
| 6106 |
+ } |
| 6107 |
+ |
| 6108 |
|
| 6109 |
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString ) |
| 6110 |
: Pattern( filterString ) |
| 6111 |
@@ -1507,6 +1669,10 @@ namespace Catch { |
| 6112 |
Tag( m_tag ) ) != end( testCase.tags ); |
| 6113 |
} |
| 6114 |
|
| 6115 |
+ void TestSpec::TagPattern::serializeTo( std::ostream& out ) const { |
| 6116 |
+ out << name(); |
| 6117 |
+ } |
| 6118 |
+ |
| 6119 |
bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const { |
| 6120 |
bool should_use = !testCase.isHidden(); |
| 6121 |
for (auto const& pattern : m_required) { |
| 6122 |
@@ -1523,18 +1689,31 @@ namespace Catch { |
| 6123 |
return should_use; |
| 6124 |
} |
| 6125 |
|
| 6126 |
- std::string TestSpec::Filter::name() const { |
| 6127 |
- std::string name; |
| 6128 |
- for (auto const& p : m_required) { |
| 6129 |
- name += p->name(); |
| 6130 |
+ void TestSpec::Filter::serializeTo( std::ostream& out ) const { |
| 6131 |
+ bool first = true; |
| 6132 |
+ for ( auto const& pattern : m_required ) { |
| 6133 |
+ if ( !first ) { |
| 6134 |
+ out << ' '; |
| 6135 |
+ } |
| 6136 |
+ out << *pattern; |
| 6137 |
+ first = false; |
| 6138 |
} |
| 6139 |
- for (auto const& p : m_forbidden) { |
| 6140 |
- name += p->name(); |
| 6141 |
+ for ( auto const& pattern : m_forbidden ) { |
| 6142 |
+ if ( !first ) { |
| 6143 |
+ out << ' '; |
| 6144 |
+ } |
| 6145 |
+ out << *pattern; |
| 6146 |
+ first = false; |
| 6147 |
} |
| 6148 |
- return name; |
| 6149 |
} |
| 6150 |
|
| 6151 |
|
| 6152 |
+ std::string TestSpec::extractFilterName( Filter const& filter ) { |
| 6153 |
+ Catch::ReusableStringStream sstr; |
| 6154 |
+ sstr << filter; |
| 6155 |
+ return sstr.str(); |
| 6156 |
+ } |
| 6157 |
+ |
| 6158 |
bool TestSpec::hasFilters() const { |
| 6159 |
return !m_filters.empty(); |
| 6160 |
} |
| 6161 |
@@ -1543,16 +1722,18 @@ namespace Catch { |
| 6162 |
return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } ); |
| 6163 |
} |
| 6164 |
|
| 6165 |
- TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const |
| 6166 |
- { |
| 6167 |
- Matches matches( m_filters.size() ); |
| 6168 |
- std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){ |
| 6169 |
+ TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const { |
| 6170 |
+ Matches matches; |
| 6171 |
+ matches.reserve( m_filters.size() ); |
| 6172 |
+ for ( auto const& filter : m_filters ) { |
| 6173 |
std::vector<TestCaseHandle const*> currentMatches; |
| 6174 |
- for( auto const& test : testCases ) |
| 6175 |
- if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) ) |
| 6176 |
+ for ( auto const& test : testCases ) |
| 6177 |
+ if ( isThrowSafe( test, config ) && |
| 6178 |
+ filter.matches( test.getTestCaseInfo() ) ) |
| 6179 |
currentMatches.emplace_back( &test ); |
| 6180 |
- return FilterMatch{ filter.name(), currentMatches }; |
| 6181 |
- } ); |
| 6182 |
+ matches.push_back( |
| 6183 |
+ FilterMatch{ extractFilterName( filter ), currentMatches } ); |
| 6184 |
+ } |
| 6185 |
return matches; |
| 6186 |
} |
| 6187 |
|
| 6188 |
@@ -1560,6 +1741,17 @@ namespace Catch { |
| 6189 |
return m_invalidSpecs; |
| 6190 |
} |
| 6191 |
|
| 6192 |
+ void TestSpec::serializeTo( std::ostream& out ) const { |
| 6193 |
+ bool first = true; |
| 6194 |
+ for ( auto const& filter : m_filters ) { |
| 6195 |
+ if ( !first ) { |
| 6196 |
+ out << ','; |
| 6197 |
+ } |
| 6198 |
+ out << filter; |
| 6199 |
+ first = false; |
| 6200 |
+ } |
| 6201 |
+ } |
| 6202 |
+ |
| 6203 |
} |
| 6204 |
|
| 6205 |
|
| 6206 |
@@ -1847,6 +2039,7 @@ namespace Catch { |
| 6207 |
diff.passed = passed - other.passed; |
| 6208 |
diff.failed = failed - other.failed; |
| 6209 |
diff.failedButOk = failedButOk - other.failedButOk; |
| 6210 |
+ diff.skipped = skipped - other.skipped; |
| 6211 |
return diff; |
| 6212 |
} |
| 6213 |
|
| 6214 |
@@ -1854,14 +2047,15 @@ namespace Catch { |
| 6215 |
passed += other.passed; |
| 6216 |
failed += other.failed; |
| 6217 |
failedButOk += other.failedButOk; |
| 6218 |
+ skipped += other.skipped; |
| 6219 |
return *this; |
| 6220 |
} |
| 6221 |
|
| 6222 |
std::uint64_t Counts::total() const { |
| 6223 |
- return passed + failed + failedButOk; |
| 6224 |
+ return passed + failed + failedButOk + skipped; |
| 6225 |
} |
| 6226 |
bool Counts::allPassed() const { |
| 6227 |
- return failed == 0 && failedButOk == 0; |
| 6228 |
+ return failed == 0 && failedButOk == 0 && skipped == 0; |
| 6229 |
} |
| 6230 |
bool Counts::allOk() const { |
| 6231 |
return failed == 0; |
| 6232 |
@@ -1886,6 +2080,8 @@ namespace Catch { |
| 6233 |
++diff.testCases.failed; |
| 6234 |
else if( diff.assertions.failedButOk > 0 ) |
| 6235 |
++diff.testCases.failedButOk; |
| 6236 |
+ else if ( diff.assertions.skipped > 0 ) |
| 6237 |
+ ++ diff.testCases.skipped; |
| 6238 |
else |
| 6239 |
++diff.testCases.passed; |
| 6240 |
return diff; |
| 6241 |
@@ -1894,6 +2090,19 @@ namespace Catch { |
| 6242 |
} |
| 6243 |
|
| 6244 |
|
| 6245 |
+ |
| 6246 |
+ |
| 6247 |
+namespace Catch { |
| 6248 |
+ namespace Detail { |
| 6249 |
+ void registerTranslatorImpl( |
| 6250 |
+ Detail::unique_ptr<IExceptionTranslator>&& translator ) { |
| 6251 |
+ getMutableRegistryHub().registerTranslator( |
| 6252 |
+ CATCH_MOVE( translator ) ); |
| 6253 |
+ } |
| 6254 |
+ } // namespace Detail |
| 6255 |
+} // namespace Catch |
| 6256 |
+ |
| 6257 |
+ |
| 6258 |
#include <ostream> |
| 6259 |
|
| 6260 |
namespace Catch { |
| 6261 |
@@ -1924,7 +2133,7 @@ namespace Catch { |
| 6262 |
} |
| 6263 |
|
| 6264 |
Version const& libraryVersion() { |
| 6265 |
- static Version version( 3, 1, 1, "", 0 ); |
| 6266 |
+ static Version version( 3, 4, 0, "", 0 ); |
| 6267 |
return version; |
| 6268 |
} |
| 6269 |
|
| 6270 |
@@ -1960,10 +2169,17 @@ namespace Detail { |
| 6271 |
|
| 6272 |
GeneratorUntypedBase::~GeneratorUntypedBase() = default; |
| 6273 |
|
| 6274 |
- auto acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 6275 |
+ IGeneratorTracker* acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo ) { |
| 6276 |
return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); |
| 6277 |
} |
| 6278 |
|
| 6279 |
+ IGeneratorTracker* createGeneratorTracker( StringRef generatorName, |
| 6280 |
+ SourceLineInfo lineInfo, |
| 6281 |
+ GeneratorBasePtr&& generator ) { |
| 6282 |
+ return getResultCapture().createGeneratorTracker( |
| 6283 |
+ generatorName, lineInfo, CATCH_MOVE( generator ) ); |
| 6284 |
+ } |
| 6285 |
+ |
| 6286 |
} // namespace Generators |
| 6287 |
} // namespace Catch |
| 6288 |
|
| 6289 |
@@ -2068,24 +2284,21 @@ namespace Catch { |
| 6290 |
infoMessages( _infoMessages ), |
| 6291 |
totals( _totals ) |
| 6292 |
{ |
| 6293 |
- assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; |
| 6294 |
- |
| 6295 |
if( assertionResult.hasMessage() ) { |
| 6296 |
// Copy message into messages list. |
| 6297 |
// !TBD This should have been done earlier, somewhere |
| 6298 |
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); |
| 6299 |
- builder << assertionResult.getMessage(); |
| 6300 |
- builder.m_info.message = builder.m_stream.str(); |
| 6301 |
+ builder.m_info.message = static_cast<std::string>(assertionResult.getMessage()); |
| 6302 |
|
| 6303 |
- infoMessages.push_back( builder.m_info ); |
| 6304 |
+ infoMessages.push_back( CATCH_MOVE(builder.m_info) ); |
| 6305 |
} |
| 6306 |
} |
| 6307 |
|
| 6308 |
- SectionStats::SectionStats( SectionInfo const& _sectionInfo, |
| 6309 |
+ SectionStats::SectionStats( SectionInfo&& _sectionInfo, |
| 6310 |
Counts const& _assertions, |
| 6311 |
double _durationInSeconds, |
| 6312 |
bool _missingAssertions ) |
| 6313 |
- : sectionInfo( _sectionInfo ), |
| 6314 |
+ : sectionInfo( CATCH_MOVE(_sectionInfo) ), |
| 6315 |
assertions( _assertions ), |
| 6316 |
durationInSeconds( _durationInSeconds ), |
| 6317 |
missingAssertions( _missingAssertions ) |
| 6318 |
@@ -2094,13 +2307,13 @@ namespace Catch { |
| 6319 |
|
| 6320 |
TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, |
| 6321 |
Totals const& _totals, |
| 6322 |
- std::string const& _stdOut, |
| 6323 |
- std::string const& _stdErr, |
| 6324 |
+ std::string&& _stdOut, |
| 6325 |
+ std::string&& _stdErr, |
| 6326 |
bool _aborting ) |
| 6327 |
: testInfo( &_testInfo ), |
| 6328 |
totals( _totals ), |
| 6329 |
- stdOut( _stdOut ), |
| 6330 |
- stdErr( _stdErr ), |
| 6331 |
+ stdOut( CATCH_MOVE(_stdOut) ), |
| 6332 |
+ stdErr( CATCH_MOVE(_stdErr) ), |
| 6333 |
aborting( _aborting ) |
| 6334 |
{} |
| 6335 |
|
| 6336 |
@@ -2129,14 +2342,6 @@ namespace Catch { |
| 6337 |
|
| 6338 |
|
| 6339 |
namespace Catch { |
| 6340 |
- IReporterRegistry::~IReporterRegistry() = default; |
| 6341 |
-} |
| 6342 |
- |
| 6343 |
- |
| 6344 |
- |
| 6345 |
- |
| 6346 |
-namespace Catch { |
| 6347 |
- ITestInvoker::~ITestInvoker() = default; |
| 6348 |
ITestCaseRegistry::~ITestCaseRegistry() = default; |
| 6349 |
} |
| 6350 |
|
| 6351 |
@@ -2151,7 +2356,9 @@ namespace Catch { |
| 6352 |
ResultDisposition::Flags resultDisposition ) |
| 6353 |
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, |
| 6354 |
m_resultCapture( getResultCapture() ) |
| 6355 |
- {} |
| 6356 |
+ { |
| 6357 |
+ m_resultCapture.notifyAssertionStarted( m_assertionInfo ); |
| 6358 |
+ } |
| 6359 |
|
| 6360 |
void AssertionHandler::handleExpr( ITransientExpression const& expr ) { |
| 6361 |
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); |
| 6362 |
@@ -2165,7 +2372,7 @@ namespace Catch { |
| 6363 |
} |
| 6364 |
|
| 6365 |
void AssertionHandler::complete() { |
| 6366 |
- setCompleted(); |
| 6367 |
+ m_completed = true; |
| 6368 |
if( m_reaction.shouldDebugBreak ) { |
| 6369 |
|
| 6370 |
// If you find your debugger stopping you here then go one level up on the |
| 6371 |
@@ -2175,15 +2382,11 @@ namespace Catch { |
| 6372 |
CATCH_BREAK_INTO_DEBUGGER(); |
| 6373 |
} |
| 6374 |
if (m_reaction.shouldThrow) { |
| 6375 |
-#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
| 6376 |
- throw Catch::TestFailureException(); |
| 6377 |
-#else |
| 6378 |
- CATCH_ERROR( "Test failure requires aborting test!" ); |
| 6379 |
-#endif |
| 6380 |
+ throw_test_failure_exception(); |
| 6381 |
+ } |
| 6382 |
+ if ( m_reaction.shouldSkip ) { |
| 6383 |
+ throw_test_skip_exception(); |
| 6384 |
} |
| 6385 |
- } |
| 6386 |
- void AssertionHandler::setCompleted() { |
| 6387 |
- m_completed = true; |
| 6388 |
} |
| 6389 |
|
| 6390 |
void AssertionHandler::handleUnexpectedInflightException() { |
| 6391 |
@@ -2207,8 +2410,8 @@ namespace Catch { |
| 6392 |
|
| 6393 |
// This is the overload that takes a string and infers the Equals matcher from it |
| 6394 |
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp |
| 6395 |
- void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) { |
| 6396 |
- handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); |
| 6397 |
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str ) { |
| 6398 |
+ handleExceptionMatchExpr( handler, Matchers::Equals( str ) ); |
| 6399 |
} |
| 6400 |
|
| 6401 |
} // namespace Catch |
| 6402 |
@@ -2744,23 +2947,14 @@ namespace Catch { |
| 6403 |
return ParserResult::ok(ParseResultType::Matched); |
| 6404 |
} |
| 6405 |
|
| 6406 |
- CATCH_TRY { |
| 6407 |
- std::size_t parsedTo = 0; |
| 6408 |
- unsigned long parsedSeed = std::stoul(seed, &parsedTo, 0); |
| 6409 |
- if (parsedTo != seed.size()) { |
| 6410 |
- return ParserResult::runtimeError("Could not parse '" + seed + "' as seed"); |
| 6411 |
- } |
| 6412 |
- |
| 6413 |
- // TODO: Ideally we could parse unsigned int directly, |
| 6414 |
- // but the stdlib doesn't provide helper for that |
| 6415 |
- // type. After this is refactored to use fixed size |
| 6416 |
- // type, we should check the parsed value is in range |
| 6417 |
- // of the underlying type. |
| 6418 |
- config.rngSeed = static_cast<unsigned int>(parsedSeed); |
| 6419 |
- return ParserResult::ok(ParseResultType::Matched); |
| 6420 |
- } CATCH_CATCH_ANON(std::exception const&) { |
| 6421 |
- return ParserResult::runtimeError("Could not parse '" + seed + "' as seed"); |
| 6422 |
+ // TODO: ideally we should be parsing uint32_t directly |
| 6423 |
+ // fix this later when we add new parse overload |
| 6424 |
+ auto parsedSeed = parseUInt( seed, 0 ); |
| 6425 |
+ if ( !parsedSeed ) { |
| 6426 |
+ return ParserResult::runtimeError( "Could not parse '" + seed + "' as seed" ); |
| 6427 |
} |
| 6428 |
+ config.rngSeed = *parsedSeed; |
| 6429 |
+ return ParserResult::ok( ParseResultType::Matched ); |
| 6430 |
}; |
| 6431 |
auto const setDefaultColourMode = [&]( std::string const& colourMode ) { |
| 6432 |
Optional<ColourMode> maybeMode = Catch::Detail::stringToColourMode(toLower( colourMode )); |
| 6433 |
@@ -2820,7 +3014,7 @@ namespace Catch { |
| 6434 |
|
| 6435 |
auto const& reporterSpec = *parsed; |
| 6436 |
|
| 6437 |
- IReporterRegistry::FactoryMap const& factories = |
| 6438 |
+ auto const& factories = |
| 6439 |
getRegistryHub().getReporterRegistry().getFactories(); |
| 6440 |
auto result = factories.find( reporterSpec.name() ); |
| 6441 |
|
| 6442 |
@@ -2852,42 +3046,29 @@ namespace Catch { |
| 6443 |
return ParserResult::ok( ParseResultType::Matched ); |
| 6444 |
}; |
| 6445 |
auto const setShardCount = [&]( std::string const& shardCount ) { |
| 6446 |
- CATCH_TRY{ |
| 6447 |
- std::size_t parsedTo = 0; |
| 6448 |
- int64_t parsedCount = std::stoll(shardCount, &parsedTo, 0); |
| 6449 |
- if (parsedTo != shardCount.size()) { |
| 6450 |
- return ParserResult::runtimeError("Could not parse '" + shardCount + "' as shard count"); |
| 6451 |
- } |
| 6452 |
- if (parsedCount <= 0) { |
| 6453 |
- return ParserResult::runtimeError("Shard count must be a positive number"); |
| 6454 |
- } |
| 6455 |
- |
| 6456 |
- config.shardCount = static_cast<unsigned int>(parsedCount); |
| 6457 |
- return ParserResult::ok(ParseResultType::Matched); |
| 6458 |
- } CATCH_CATCH_ANON(std::exception const&) { |
| 6459 |
- return ParserResult::runtimeError("Could not parse '" + shardCount + "' as shard count"); |
| 6460 |
+ auto parsedCount = parseUInt( shardCount ); |
| 6461 |
+ if ( !parsedCount ) { |
| 6462 |
+ return ParserResult::runtimeError( |
| 6463 |
+ "Could not parse '" + shardCount + "' as shard count" ); |
| 6464 |
} |
| 6465 |
+ if ( *parsedCount == 0 ) { |
| 6466 |
+ return ParserResult::runtimeError( |
| 6467 |
+ "Shard count must be positive" ); |
| 6468 |
+ } |
| 6469 |
+ config.shardCount = *parsedCount; |
| 6470 |
+ return ParserResult::ok( ParseResultType::Matched ); |
| 6471 |
}; |
| 6472 |
|
| 6473 |
auto const setShardIndex = [&](std::string const& shardIndex) { |
| 6474 |
- CATCH_TRY{ |
| 6475 |
- std::size_t parsedTo = 0; |
| 6476 |
- int64_t parsedIndex = std::stoll(shardIndex, &parsedTo, 0); |
| 6477 |
- if (parsedTo != shardIndex.size()) { |
| 6478 |
- return ParserResult::runtimeError("Could not parse '" + shardIndex + "' as shard index"); |
| 6479 |
- } |
| 6480 |
- if (parsedIndex < 0) { |
| 6481 |
- return ParserResult::runtimeError("Shard index must be a non-negative number"); |
| 6482 |
- } |
| 6483 |
- |
| 6484 |
- config.shardIndex = static_cast<unsigned int>(parsedIndex); |
| 6485 |
- return ParserResult::ok(ParseResultType::Matched); |
| 6486 |
- } CATCH_CATCH_ANON(std::exception const&) { |
| 6487 |
- return ParserResult::runtimeError("Could not parse '" + shardIndex + "' as shard index"); |
| 6488 |
+ auto parsedIndex = parseUInt( shardIndex ); |
| 6489 |
+ if ( !parsedIndex ) { |
| 6490 |
+ return ParserResult::runtimeError( |
| 6491 |
+ "Could not parse '" + shardIndex + "' as shard index" ); |
| 6492 |
} |
| 6493 |
+ config.shardIndex = *parsedIndex; |
| 6494 |
+ return ParserResult::ok( ParseResultType::Matched ); |
| 6495 |
}; |
| 6496 |
|
| 6497 |
- |
| 6498 |
auto cli |
| 6499 |
= ExeName( config.processName ) |
| 6500 |
| Help( config.showHelp ) |
| 6501 |
@@ -3071,7 +3252,7 @@ namespace Catch { |
| 6502 |
namespace { |
| 6503 |
//! A do-nothing implementation of colour, used as fallback for unknown |
| 6504 |
//! platforms, and when the user asks to deactivate all colours. |
| 6505 |
- class NoColourImpl : public ColourImpl { |
| 6506 |
+ class NoColourImpl final : public ColourImpl { |
| 6507 |
public: |
| 6508 |
NoColourImpl( IStream* stream ): ColourImpl( stream ) {} |
| 6509 |
|
| 6510 |
@@ -3089,7 +3270,7 @@ namespace Catch { |
| 6511 |
namespace Catch { |
| 6512 |
namespace { |
| 6513 |
|
| 6514 |
- class Win32ColourImpl : public ColourImpl { |
| 6515 |
+ class Win32ColourImpl final : public ColourImpl { |
| 6516 |
public: |
| 6517 |
Win32ColourImpl(IStream* stream): |
| 6518 |
ColourImpl(stream) { |
| 6519 |
@@ -3155,7 +3336,7 @@ namespace { |
| 6520 |
namespace Catch { |
| 6521 |
namespace { |
| 6522 |
|
| 6523 |
- class ANSIColourImpl : public ColourImpl { |
| 6524 |
+ class ANSIColourImpl final : public ColourImpl { |
| 6525 |
public: |
| 6526 |
ANSIColourImpl( IStream* stream ): ColourImpl( stream ) {} |
| 6527 |
|
| 6528 |
@@ -3271,49 +3452,27 @@ namespace Catch { |
| 6529 |
|
| 6530 |
namespace Catch { |
| 6531 |
|
| 6532 |
- class Context : public IMutableContext, private Detail::NonCopyable { |
| 6533 |
- |
| 6534 |
- public: // IContext |
| 6535 |
- IResultCapture* getResultCapture() override { |
| 6536 |
- return m_resultCapture; |
| 6537 |
- } |
| 6538 |
- |
| 6539 |
- IConfig const* getConfig() const override { |
| 6540 |
- return m_config; |
| 6541 |
- } |
| 6542 |
- |
| 6543 |
- ~Context() override; |
| 6544 |
- |
| 6545 |
- public: // IMutableContext |
| 6546 |
- void setResultCapture( IResultCapture* resultCapture ) override { |
| 6547 |
- m_resultCapture = resultCapture; |
| 6548 |
- } |
| 6549 |
- void setConfig( IConfig const* config ) override { |
| 6550 |
- m_config = config; |
| 6551 |
- } |
| 6552 |
+ Context* Context::currentContext = nullptr; |
| 6553 |
|
| 6554 |
- friend IMutableContext& getCurrentMutableContext(); |
| 6555 |
- |
| 6556 |
- private: |
| 6557 |
- IConfig const* m_config = nullptr; |
| 6558 |
- IResultCapture* m_resultCapture = nullptr; |
| 6559 |
- }; |
| 6560 |
- |
| 6561 |
- IMutableContext *IMutableContext::currentContext = nullptr; |
| 6562 |
- |
| 6563 |
- void IMutableContext::createContext() |
| 6564 |
- { |
| 6565 |
+ void cleanUpContext() { |
| 6566 |
+ delete Context::currentContext; |
| 6567 |
+ Context::currentContext = nullptr; |
| 6568 |
+ } |
| 6569 |
+ void Context::createContext() { |
| 6570 |
currentContext = new Context(); |
| 6571 |
} |
| 6572 |
|
| 6573 |
- void cleanUpContext() { |
| 6574 |
- delete IMutableContext::currentContext; |
| 6575 |
- IMutableContext::currentContext = nullptr; |
| 6576 |
+ Context& getCurrentMutableContext() { |
| 6577 |
+ if ( !Context::currentContext ) { Context::createContext(); } |
| 6578 |
+ // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) |
| 6579 |
+ return *Context::currentContext; |
| 6580 |
+ } |
| 6581 |
+ |
| 6582 |
+ void Context::setResultCapture( IResultCapture* resultCapture ) { |
| 6583 |
+ m_resultCapture = resultCapture; |
| 6584 |
} |
| 6585 |
- IContext::~IContext() = default; |
| 6586 |
- IMutableContext::~IMutableContext() = default; |
| 6587 |
- Context::~Context() = default; |
| 6588 |
|
| 6589 |
+ void Context::setConfig( IConfig const* config ) { m_config = config; } |
| 6590 |
|
| 6591 |
SimplePcg32& sharedRng() { |
| 6592 |
static SimplePcg32 s_rng; |
| 6593 |
@@ -3596,8 +3755,24 @@ namespace Catch { |
| 6594 |
|
| 6595 |
|
| 6596 |
|
| 6597 |
+#include <exception> |
| 6598 |
+ |
| 6599 |
namespace Catch { |
| 6600 |
|
| 6601 |
+ namespace { |
| 6602 |
+ static std::string tryTranslators( |
| 6603 |
+ std::vector< |
| 6604 |
+ Detail::unique_ptr<IExceptionTranslator const>> const& translators ) { |
| 6605 |
+ if ( translators.empty() ) { |
| 6606 |
+ std::rethrow_exception( std::current_exception() ); |
| 6607 |
+ } else { |
| 6608 |
+ return translators[0]->translate( translators.begin() + 1, |
| 6609 |
+ translators.end() ); |
| 6610 |
+ } |
| 6611 |
+ } |
| 6612 |
+ |
| 6613 |
+ } |
| 6614 |
+ |
| 6615 |
ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { |
| 6616 |
} |
| 6617 |
|
| 6618 |
@@ -3622,13 +3797,16 @@ namespace Catch { |
| 6619 |
// First we try user-registered translators. If none of them can |
| 6620 |
// handle the exception, it will be rethrown handled by our defaults. |
| 6621 |
try { |
| 6622 |
- return tryTranslators(); |
| 6623 |
+ return tryTranslators(m_translators); |
| 6624 |
} |
| 6625 |
// To avoid having to handle TFE explicitly everywhere, we just |
| 6626 |
// rethrow it so that it goes back up the caller. |
| 6627 |
catch( TestFailureException& ) { |
| 6628 |
std::rethrow_exception(std::current_exception()); |
| 6629 |
} |
| 6630 |
+ catch( TestSkipException& ) { |
| 6631 |
+ std::rethrow_exception(std::current_exception()); |
| 6632 |
+ } |
| 6633 |
catch( std::exception const& ex ) { |
| 6634 |
return ex.what(); |
| 6635 |
} |
| 6636 |
@@ -3643,25 +3821,12 @@ namespace Catch { |
| 6637 |
} |
| 6638 |
} |
| 6639 |
|
| 6640 |
- std::string ExceptionTranslatorRegistry::tryTranslators() const { |
| 6641 |
- if (m_translators.empty()) { |
| 6642 |
- std::rethrow_exception(std::current_exception()); |
| 6643 |
- } else { |
| 6644 |
- return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end()); |
| 6645 |
- } |
| 6646 |
- } |
| 6647 |
- |
| 6648 |
#else // ^^ Exceptions are enabled // Exceptions are disabled vv |
| 6649 |
std::string ExceptionTranslatorRegistry::translateActiveException() const { |
| 6650 |
CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); |
| 6651 |
} |
| 6652 |
- |
| 6653 |
- std::string ExceptionTranslatorRegistry::tryTranslators() const { |
| 6654 |
- CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); |
| 6655 |
- } |
| 6656 |
#endif |
| 6657 |
|
| 6658 |
- |
| 6659 |
} |
| 6660 |
|
| 6661 |
|
| 6662 |
@@ -3925,6 +4090,35 @@ namespace Catch { |
| 6663 |
|
| 6664 |
|
| 6665 |
|
| 6666 |
+ |
| 6667 |
+#include <cstdlib> |
| 6668 |
+ |
| 6669 |
+namespace Catch { |
| 6670 |
+ namespace Detail { |
| 6671 |
+ |
| 6672 |
+#if !defined (CATCH_CONFIG_GETENV) |
| 6673 |
+ char const* getEnv( char const* ) { return nullptr; } |
| 6674 |
+#else |
| 6675 |
+ |
| 6676 |
+ char const* getEnv( char const* varName ) { |
| 6677 |
+# if defined( _MSC_VER ) |
| 6678 |
+# pragma warning( push ) |
| 6679 |
+# pragma warning( disable : 4996 ) // use getenv_s instead of getenv |
| 6680 |
+# endif |
| 6681 |
+ |
| 6682 |
+ return std::getenv( varName ); |
| 6683 |
+ |
| 6684 |
+# if defined( _MSC_VER ) |
| 6685 |
+# pragma warning( pop ) |
| 6686 |
+# endif |
| 6687 |
+ } |
| 6688 |
+#endif |
| 6689 |
+} // namespace Detail |
| 6690 |
+} // namespace Catch |
| 6691 |
+ |
| 6692 |
+ |
| 6693 |
+ |
| 6694 |
+ |
| 6695 |
#include <cstdio> |
| 6696 |
#include <fstream> |
| 6697 |
#include <sstream> |
| 6698 |
@@ -3937,7 +4131,7 @@ namespace Catch { |
| 6699 |
namespace Detail { |
| 6700 |
namespace { |
| 6701 |
template<typename WriterF, std::size_t bufferSize=256> |
| 6702 |
- class StreamBufImpl : public std::streambuf { |
| 6703 |
+ class StreamBufImpl final : public std::streambuf { |
| 6704 |
char data[bufferSize]; |
| 6705 |
WriterF m_writer; |
| 6706 |
|
| 6707 |
@@ -3985,7 +4179,7 @@ namespace Detail { |
| 6708 |
|
| 6709 |
/////////////////////////////////////////////////////////////////////////// |
| 6710 |
|
| 6711 |
- class FileStream : public IStream { |
| 6712 |
+ class FileStream final : public IStream { |
| 6713 |
std::ofstream m_ofs; |
| 6714 |
public: |
| 6715 |
FileStream( std::string const& filename ) { |
| 6716 |
@@ -4002,7 +4196,7 @@ namespace Detail { |
| 6717 |
|
| 6718 |
/////////////////////////////////////////////////////////////////////////// |
| 6719 |
|
| 6720 |
- class CoutStream : public IStream { |
| 6721 |
+ class CoutStream final : public IStream { |
| 6722 |
std::ostream m_os; |
| 6723 |
public: |
| 6724 |
// Store the streambuf from cout up-front because |
| 6725 |
@@ -4031,7 +4225,7 @@ namespace Detail { |
| 6726 |
|
| 6727 |
/////////////////////////////////////////////////////////////////////////// |
| 6728 |
|
| 6729 |
- class DebugOutStream : public IStream { |
| 6730 |
+ class DebugOutStream final : public IStream { |
| 6731 |
Detail::unique_ptr<StreamBufImpl<OutputDebugWriter>> m_streamBuf; |
| 6732 |
std::ostream m_os; |
| 6733 |
public: |
| 6734 |
@@ -4161,7 +4355,7 @@ namespace Catch { |
| 6735 |
void listReporters(IEventListener& reporter) { |
| 6736 |
std::vector<ReporterDescription> descriptions; |
| 6737 |
|
| 6738 |
- IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); |
| 6739 |
+ auto const& factories = getRegistryHub().getReporterRegistry().getFactories(); |
| 6740 |
descriptions.reserve(factories.size()); |
| 6741 |
for (auto const& fac : factories) { |
| 6742 |
descriptions.push_back({ fac.first, fac.second->getDescription() }); |
| 6743 |
@@ -4418,6 +4612,50 @@ namespace Catch { |
| 6744 |
|
| 6745 |
|
| 6746 |
|
| 6747 |
+#include <limits> |
| 6748 |
+#include <stdexcept> |
| 6749 |
+ |
| 6750 |
+namespace Catch { |
| 6751 |
+ |
| 6752 |
+ Optional<unsigned int> parseUInt(std::string const& input, int base) { |
| 6753 |
+ auto trimmed = trim( input ); |
| 6754 |
+ // std::stoull is annoying and accepts numbers starting with '-', |
| 6755 |
+ // it just negates them into unsigned int |
| 6756 |
+ if ( trimmed.empty() || trimmed[0] == '-' ) { |
| 6757 |
+ return {}; |
| 6758 |
+ } |
| 6759 |
+ |
| 6760 |
+ CATCH_TRY { |
| 6761 |
+ size_t pos = 0; |
| 6762 |
+ const auto ret = std::stoull( trimmed, &pos, base ); |
| 6763 |
+ |
| 6764 |
+ // We did not consume the whole input, so there is an issue |
| 6765 |
+ // This can be bunch of different stuff, like multiple numbers |
| 6766 |
+ // in the input, or invalid digits/characters and so on. Either |
| 6767 |
+ // way, we do not want to return the partially parsed result. |
| 6768 |
+ if ( pos != trimmed.size() ) { |
| 6769 |
+ return {}; |
| 6770 |
+ } |
| 6771 |
+ // Too large |
| 6772 |
+ if ( ret > std::numeric_limits<unsigned int>::max() ) { |
| 6773 |
+ return {}; |
| 6774 |
+ } |
| 6775 |
+ return static_cast<unsigned int>(ret); |
| 6776 |
+ } |
| 6777 |
+ CATCH_CATCH_ANON( std::invalid_argument const& ) { |
| 6778 |
+ // no conversion could be performed |
| 6779 |
+ } |
| 6780 |
+ CATCH_CATCH_ANON( std::out_of_range const& ) { |
| 6781 |
+ // the input does not fit into an unsigned long long |
| 6782 |
+ } |
| 6783 |
+ return {}; |
| 6784 |
+ } |
| 6785 |
+ |
| 6786 |
+} // namespace Catch |
| 6787 |
+ |
| 6788 |
+ |
| 6789 |
+ |
| 6790 |
+ |
| 6791 |
#include <cmath> |
| 6792 |
|
| 6793 |
namespace Catch { |
| 6794 |
@@ -4536,49 +4774,71 @@ namespace Catch { |
| 6795 |
|
| 6796 |
|
| 6797 |
namespace Catch { |
| 6798 |
+ struct ReporterRegistry::ReporterRegistryImpl { |
| 6799 |
+ std::vector<Detail::unique_ptr<EventListenerFactory>> listeners; |
| 6800 |
+ std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess> |
| 6801 |
+ factories; |
| 6802 |
+ }; |
| 6803 |
|
| 6804 |
- ReporterRegistry::ReporterRegistry() { |
| 6805 |
+ ReporterRegistry::ReporterRegistry(): |
| 6806 |
+ m_impl( Detail::make_unique<ReporterRegistryImpl>() ) { |
| 6807 |
// Because it is impossible to move out of initializer list, |
| 6808 |
// we have to add the elements manually |
| 6809 |
- m_factories["Automake"] = Detail::make_unique<ReporterFactory<AutomakeReporter>>(); |
| 6810 |
- m_factories["compact"] = Detail::make_unique<ReporterFactory<CompactReporter>>(); |
| 6811 |
- m_factories["console"] = Detail::make_unique<ReporterFactory<ConsoleReporter>>(); |
| 6812 |
- m_factories["JUnit"] = Detail::make_unique<ReporterFactory<JunitReporter>>(); |
| 6813 |
- m_factories["SonarQube"] = Detail::make_unique<ReporterFactory<SonarQubeReporter>>(); |
| 6814 |
- m_factories["TAP"] = Detail::make_unique<ReporterFactory<TAPReporter>>(); |
| 6815 |
- m_factories["TeamCity"] = Detail::make_unique<ReporterFactory<TeamCityReporter>>(); |
| 6816 |
- m_factories["XML"] = Detail::make_unique<ReporterFactory<XmlReporter>>(); |
| 6817 |
+ m_impl->factories["Automake"] = |
| 6818 |
+ Detail::make_unique<ReporterFactory<AutomakeReporter>>(); |
| 6819 |
+ m_impl->factories["compact"] = |
| 6820 |
+ Detail::make_unique<ReporterFactory<CompactReporter>>(); |
| 6821 |
+ m_impl->factories["console"] = |
| 6822 |
+ Detail::make_unique<ReporterFactory<ConsoleReporter>>(); |
| 6823 |
+ m_impl->factories["JUnit"] = |
| 6824 |
+ Detail::make_unique<ReporterFactory<JunitReporter>>(); |
| 6825 |
+ m_impl->factories["SonarQube"] = |
| 6826 |
+ Detail::make_unique<ReporterFactory<SonarQubeReporter>>(); |
| 6827 |
+ m_impl->factories["TAP"] = |
| 6828 |
+ Detail::make_unique<ReporterFactory<TAPReporter>>(); |
| 6829 |
+ m_impl->factories["TeamCity"] = |
| 6830 |
+ Detail::make_unique<ReporterFactory<TeamCityReporter>>(); |
| 6831 |
+ m_impl->factories["XML"] = |
| 6832 |
+ Detail::make_unique<ReporterFactory<XmlReporter>>(); |
| 6833 |
} |
| 6834 |
|
| 6835 |
ReporterRegistry::~ReporterRegistry() = default; |
| 6836 |
|
| 6837 |
- |
| 6838 |
- IEventListenerPtr ReporterRegistry::create( std::string const& name, ReporterConfig&& config ) const { |
| 6839 |
- auto it = m_factories.find( name ); |
| 6840 |
- if( it == m_factories.end() ) |
| 6841 |
- return nullptr; |
| 6842 |
- return it->second->create( CATCH_MOVE(config) ); |
| 6843 |
+ IEventListenerPtr |
| 6844 |
+ ReporterRegistry::create( std::string const& name, |
| 6845 |
+ ReporterConfig&& config ) const { |
| 6846 |
+ auto it = m_impl->factories.find( name ); |
| 6847 |
+ if ( it == m_impl->factories.end() ) return nullptr; |
| 6848 |
+ return it->second->create( CATCH_MOVE( config ) ); |
| 6849 |
} |
| 6850 |
|
| 6851 |
- void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) { |
| 6852 |
+ void ReporterRegistry::registerReporter( std::string const& name, |
| 6853 |
+ IReporterFactoryPtr factory ) { |
| 6854 |
CATCH_ENFORCE( name.find( "::" ) == name.npos, |
| 6855 |
- "'::' is not allowed in reporter name: '" + name + '\'' ); |
| 6856 |
- auto ret = m_factories.emplace(name, CATCH_MOVE(factory)); |
| 6857 |
- CATCH_ENFORCE( ret.second, "reporter using '" + name + "' as name was already registered" ); |
| 6858 |
+ "'::' is not allowed in reporter name: '" + name + |
| 6859 |
+ '\'' ); |
| 6860 |
+ auto ret = m_impl->factories.emplace( name, CATCH_MOVE( factory ) ); |
| 6861 |
+ CATCH_ENFORCE( ret.second, |
| 6862 |
+ "reporter using '" + name + |
| 6863 |
+ "' as name was already registered" ); |
| 6864 |
} |
| 6865 |
void ReporterRegistry::registerListener( |
| 6866 |
Detail::unique_ptr<EventListenerFactory> factory ) { |
| 6867 |
- m_listeners.push_back( CATCH_MOVE(factory) ); |
| 6868 |
+ m_impl->listeners.push_back( CATCH_MOVE( factory ) ); |
| 6869 |
} |
| 6870 |
|
| 6871 |
- IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { |
| 6872 |
- return m_factories; |
| 6873 |
- } |
| 6874 |
- IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { |
| 6875 |
- return m_listeners; |
| 6876 |
+ std::map<std::string, |
| 6877 |
+ IReporterFactoryPtr, |
| 6878 |
+ Detail::CaseInsensitiveLess> const& |
| 6879 |
+ ReporterRegistry::getFactories() const { |
| 6880 |
+ return m_impl->factories; |
| 6881 |
} |
| 6882 |
|
| 6883 |
-} |
| 6884 |
+ std::vector<Detail::unique_ptr<EventListenerFactory>> const& |
| 6885 |
+ ReporterRegistry::getListeners() const { |
| 6886 |
+ return m_impl->listeners; |
| 6887 |
+ } |
| 6888 |
+} // namespace Catch |
| 6889 |
|
| 6890 |
|
| 6891 |
|
| 6892 |
@@ -4594,9 +4854,9 @@ namespace Catch { |
| 6893 |
}; |
| 6894 |
|
| 6895 |
kvPair splitKVPair(StringRef kvString) { |
| 6896 |
- auto splitPos = static_cast<size_t>( std::distance( |
| 6897 |
- kvString.begin(), |
| 6898 |
- std::find( kvString.begin(), kvString.end(), '=' ) ) ); |
| 6899 |
+ auto splitPos = static_cast<size_t>( |
| 6900 |
+ std::find( kvString.begin(), kvString.end(), '=' ) - |
| 6901 |
+ kvString.begin() ); |
| 6902 |
|
| 6903 |
return { kvString.substr( 0, splitPos ), |
| 6904 |
kvString.substr( splitPos + 1, kvString.size() ) }; |
| 6905 |
@@ -4828,149 +5088,152 @@ namespace Catch { |
| 6906 |
namespace Catch { |
| 6907 |
|
| 6908 |
namespace Generators { |
| 6909 |
- struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { |
| 6910 |
- GeneratorBasePtr m_generator; |
| 6911 |
+ namespace { |
| 6912 |
+ struct GeneratorTracker final : TestCaseTracking::TrackerBase, |
| 6913 |
+ IGeneratorTracker { |
| 6914 |
+ GeneratorBasePtr m_generator; |
| 6915 |
+ |
| 6916 |
+ GeneratorTracker( |
| 6917 |
+ TestCaseTracking::NameAndLocation&& nameAndLocation, |
| 6918 |
+ TrackerContext& ctx, |
| 6919 |
+ ITracker* parent ): |
| 6920 |
+ TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {} |
| 6921 |
+ ~GeneratorTracker() override = default; |
| 6922 |
+ |
| 6923 |
+ static GeneratorTracker* |
| 6924 |
+ acquire( TrackerContext& ctx, |
| 6925 |
+ TestCaseTracking::NameAndLocationRef const& |
| 6926 |
+ nameAndLocation ) { |
| 6927 |
+ GeneratorTracker* tracker; |
| 6928 |
+ |
| 6929 |
+ ITracker& currentTracker = ctx.currentTracker(); |
| 6930 |
+ // Under specific circumstances, the generator we want |
| 6931 |
+ // to acquire is also the current tracker. If this is |
| 6932 |
+ // the case, we have to avoid looking through current |
| 6933 |
+ // tracker's children, and instead return the current |
| 6934 |
+ // tracker. |
| 6935 |
+ // A case where this check is important is e.g. |
| 6936 |
+ // for (int i = 0; i < 5; ++i) { |
| 6937 |
+ // int n = GENERATE(1, 2); |
| 6938 |
+ // } |
| 6939 |
+ // |
| 6940 |
+ // without it, the code above creates 5 nested generators. |
| 6941 |
+ if ( currentTracker.nameAndLocation() == nameAndLocation ) { |
| 6942 |
+ auto thisTracker = currentTracker.parent()->findChild( |
| 6943 |
+ nameAndLocation ); |
| 6944 |
+ assert( thisTracker ); |
| 6945 |
+ assert( thisTracker->isGeneratorTracker() ); |
| 6946 |
+ tracker = static_cast<GeneratorTracker*>( thisTracker ); |
| 6947 |
+ } else if ( ITracker* childTracker = |
| 6948 |
+ currentTracker.findChild( |
| 6949 |
+ nameAndLocation ) ) { |
| 6950 |
+ assert( childTracker ); |
| 6951 |
+ assert( childTracker->isGeneratorTracker() ); |
| 6952 |
+ tracker = |
| 6953 |
+ static_cast<GeneratorTracker*>( childTracker ); |
| 6954 |
+ } else { |
| 6955 |
+ return nullptr; |
| 6956 |
+ } |
| 6957 |
|
| 6958 |
- GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) |
| 6959 |
- : TrackerBase( nameAndLocation, ctx, parent ) |
| 6960 |
- {} |
| 6961 |
- ~GeneratorTracker() override; |
| 6962 |
- |
| 6963 |
- static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocation const& nameAndLocation ) { |
| 6964 |
- GeneratorTracker* tracker; |
| 6965 |
- |
| 6966 |
- ITracker& currentTracker = ctx.currentTracker(); |
| 6967 |
- // Under specific circumstances, the generator we want |
| 6968 |
- // to acquire is also the current tracker. If this is |
| 6969 |
- // the case, we have to avoid looking through current |
| 6970 |
- // tracker's children, and instead return the current |
| 6971 |
- // tracker. |
| 6972 |
- // A case where this check is important is e.g. |
| 6973 |
- // for (int i = 0; i < 5; ++i) { |
| 6974 |
- // int n = GENERATE(1, 2); |
| 6975 |
- // } |
| 6976 |
- // |
| 6977 |
- // without it, the code above creates 5 nested generators. |
| 6978 |
- if ( currentTracker.nameAndLocation() == nameAndLocation ) { |
| 6979 |
- auto thisTracker = |
| 6980 |
- currentTracker.parent()->findChild( nameAndLocation ); |
| 6981 |
- assert( thisTracker ); |
| 6982 |
- assert( thisTracker->isGeneratorTracker() ); |
| 6983 |
- tracker = static_cast<GeneratorTracker*>( thisTracker ); |
| 6984 |
- } else if ( ITracker* childTracker = |
| 6985 |
- currentTracker.findChild( nameAndLocation ) ) { |
| 6986 |
- assert( childTracker ); |
| 6987 |
- assert( childTracker->isGeneratorTracker() ); |
| 6988 |
- tracker = static_cast<GeneratorTracker*>( childTracker ); |
| 6989 |
- } else { |
| 6990 |
- auto newTracker = |
| 6991 |
- Catch::Detail::make_unique<GeneratorTracker>( |
| 6992 |
- nameAndLocation, ctx, ¤tTracker ); |
| 6993 |
- tracker = newTracker.get(); |
| 6994 |
- currentTracker.addChild( CATCH_MOVE(newTracker) ); |
| 6995 |
- } |
| 6996 |
+ if ( !tracker->isComplete() ) { tracker->open(); } |
| 6997 |
|
| 6998 |
- if( !tracker->isComplete() ) { |
| 6999 |
- tracker->open(); |
| 7000 |
+ return tracker; |
| 7001 |
} |
| 7002 |
|
| 7003 |
- return *tracker; |
| 7004 |
- } |
| 7005 |
- |
| 7006 |
- // TrackerBase interface |
| 7007 |
- bool isGeneratorTracker() const override { return true; } |
| 7008 |
- auto hasGenerator() const -> bool override { |
| 7009 |
- return !!m_generator; |
| 7010 |
- } |
| 7011 |
- void close() override { |
| 7012 |
- TrackerBase::close(); |
| 7013 |
- // If a generator has a child (it is followed by a section) |
| 7014 |
- // and none of its children have started, then we must wait |
| 7015 |
- // until later to start consuming its values. |
| 7016 |
- // This catches cases where `GENERATE` is placed between two |
| 7017 |
- // `SECTION`s. |
| 7018 |
- // **The check for m_children.empty cannot be removed**. |
| 7019 |
- // doing so would break `GENERATE` _not_ followed by `SECTION`s. |
| 7020 |
- const bool should_wait_for_child = [&]() { |
| 7021 |
- // No children -> nobody to wait for |
| 7022 |
- if ( m_children.empty() ) { |
| 7023 |
- return false; |
| 7024 |
- } |
| 7025 |
- // If at least one child started executing, don't wait |
| 7026 |
- if ( std::find_if( |
| 7027 |
- m_children.begin(), |
| 7028 |
- m_children.end(), |
| 7029 |
- []( TestCaseTracking::ITrackerPtr const& tracker ) { |
| 7030 |
- return tracker->hasStarted(); |
| 7031 |
- } ) != m_children.end() ) { |
| 7032 |
- return false; |
| 7033 |
- } |
| 7034 |
- |
| 7035 |
- // No children have started. We need to check if they _can_ |
| 7036 |
- // start, and thus we should wait for them, or they cannot |
| 7037 |
- // start (due to filters), and we shouldn't wait for them |
| 7038 |
- ITracker* parent = m_parent; |
| 7039 |
- // This is safe: there is always at least one section |
| 7040 |
- // tracker in a test case tracking tree |
| 7041 |
- while ( !parent->isSectionTracker() ) { |
| 7042 |
- parent = parent->parent(); |
| 7043 |
- } |
| 7044 |
- assert( parent && |
| 7045 |
- "Missing root (test case) level section" ); |
| 7046 |
- |
| 7047 |
- auto const& parentSection = |
| 7048 |
- static_cast<SectionTracker const&>( *parent ); |
| 7049 |
- auto const& filters = parentSection.getFilters(); |
| 7050 |
- // No filters -> no restrictions on running sections |
| 7051 |
- if ( filters.empty() ) { |
| 7052 |
- return true; |
| 7053 |
- } |
| 7054 |
+ // TrackerBase interface |
| 7055 |
+ bool isGeneratorTracker() const override { return true; } |
| 7056 |
+ auto hasGenerator() const -> bool override { |
| 7057 |
+ return !!m_generator; |
| 7058 |
+ } |
| 7059 |
+ void close() override { |
| 7060 |
+ TrackerBase::close(); |
| 7061 |
+ // If a generator has a child (it is followed by a section) |
| 7062 |
+ // and none of its children have started, then we must wait |
| 7063 |
+ // until later to start consuming its values. |
| 7064 |
+ // This catches cases where `GENERATE` is placed between two |
| 7065 |
+ // `SECTION`s. |
| 7066 |
+ // **The check for m_children.empty cannot be removed**. |
| 7067 |
+ // doing so would break `GENERATE` _not_ followed by |
| 7068 |
+ // `SECTION`s. |
| 7069 |
+ const bool should_wait_for_child = [&]() { |
| 7070 |
+ // No children -> nobody to wait for |
| 7071 |
+ if ( m_children.empty() ) { return false; } |
| 7072 |
+ // If at least one child started executing, don't wait |
| 7073 |
+ if ( std::find_if( |
| 7074 |
+ m_children.begin(), |
| 7075 |
+ m_children.end(), |
| 7076 |
+ []( TestCaseTracking::ITrackerPtr const& |
| 7077 |
+ tracker ) { |
| 7078 |
+ return tracker->hasStarted(); |
| 7079 |
+ } ) != m_children.end() ) { |
| 7080 |
+ return false; |
| 7081 |
+ } |
| 7082 |
|
| 7083 |
- for ( auto const& child : m_children ) { |
| 7084 |
- if ( child->isSectionTracker() && |
| 7085 |
- std::find( |
| 7086 |
- filters.begin(), |
| 7087 |
- filters.end(), |
| 7088 |
- static_cast<SectionTracker const&>( *child ) |
| 7089 |
- .trimmedName() ) != filters.end() ) { |
| 7090 |
- return true; |
| 7091 |
+ // No children have started. We need to check if they |
| 7092 |
+ // _can_ start, and thus we should wait for them, or |
| 7093 |
+ // they cannot start (due to filters), and we shouldn't |
| 7094 |
+ // wait for them |
| 7095 |
+ ITracker* parent = m_parent; |
| 7096 |
+ // This is safe: there is always at least one section |
| 7097 |
+ // tracker in a test case tracking tree |
| 7098 |
+ while ( !parent->isSectionTracker() ) { |
| 7099 |
+ parent = parent->parent(); |
| 7100 |
} |
| 7101 |
+ assert( parent && |
| 7102 |
+ "Missing root (test case) level section" ); |
| 7103 |
+ |
| 7104 |
+ auto const& parentSection = |
| 7105 |
+ static_cast<SectionTracker const&>( *parent ); |
| 7106 |
+ auto const& filters = parentSection.getFilters(); |
| 7107 |
+ // No filters -> no restrictions on running sections |
| 7108 |
+ if ( filters.empty() ) { return true; } |
| 7109 |
+ |
| 7110 |
+ for ( auto const& child : m_children ) { |
| 7111 |
+ if ( child->isSectionTracker() && |
| 7112 |
+ std::find( filters.begin(), |
| 7113 |
+ filters.end(), |
| 7114 |
+ static_cast<SectionTracker const&>( |
| 7115 |
+ *child ) |
| 7116 |
+ .trimmedName() ) != |
| 7117 |
+ filters.end() ) { |
| 7118 |
+ return true; |
| 7119 |
+ } |
| 7120 |
+ } |
| 7121 |
+ return false; |
| 7122 |
+ }(); |
| 7123 |
+ |
| 7124 |
+ // This check is a bit tricky, because m_generator->next() |
| 7125 |
+ // has a side-effect, where it consumes generator's current |
| 7126 |
+ // value, but we do not want to invoke the side-effect if |
| 7127 |
+ // this generator is still waiting for any child to start. |
| 7128 |
+ assert( m_generator && "Tracker without generator" ); |
| 7129 |
+ if ( should_wait_for_child || |
| 7130 |
+ ( m_runState == CompletedSuccessfully && |
| 7131 |
+ m_generator->countedNext() ) ) { |
| 7132 |
+ m_children.clear(); |
| 7133 |
+ m_runState = Executing; |
| 7134 |
} |
| 7135 |
- return false; |
| 7136 |
- }(); |
| 7137 |
- |
| 7138 |
- // This check is a bit tricky, because m_generator->next() |
| 7139 |
- // has a side-effect, where it consumes generator's current |
| 7140 |
- // value, but we do not want to invoke the side-effect if |
| 7141 |
- // this generator is still waiting for any child to start. |
| 7142 |
- if ( should_wait_for_child || |
| 7143 |
- ( m_runState == CompletedSuccessfully && |
| 7144 |
- m_generator->countedNext() ) ) { |
| 7145 |
- m_children.clear(); |
| 7146 |
- m_runState = Executing; |
| 7147 |
} |
| 7148 |
- } |
| 7149 |
|
| 7150 |
- // IGeneratorTracker interface |
| 7151 |
- auto getGenerator() const -> GeneratorBasePtr const& override { |
| 7152 |
- return m_generator; |
| 7153 |
- } |
| 7154 |
- void setGenerator( GeneratorBasePtr&& generator ) override { |
| 7155 |
- m_generator = CATCH_MOVE( generator ); |
| 7156 |
- } |
| 7157 |
- }; |
| 7158 |
- GeneratorTracker::~GeneratorTracker() = default; |
| 7159 |
+ // IGeneratorTracker interface |
| 7160 |
+ auto getGenerator() const -> GeneratorBasePtr const& override { |
| 7161 |
+ return m_generator; |
| 7162 |
+ } |
| 7163 |
+ void setGenerator( GeneratorBasePtr&& generator ) override { |
| 7164 |
+ m_generator = CATCH_MOVE( generator ); |
| 7165 |
+ } |
| 7166 |
+ }; |
| 7167 |
+ } // namespace |
| 7168 |
} |
| 7169 |
|
| 7170 |
RunContext::RunContext(IConfig const* _config, IEventListenerPtr&& reporter) |
| 7171 |
: m_runInfo(_config->name()), |
| 7172 |
- m_context(getCurrentMutableContext()), |
| 7173 |
m_config(_config), |
| 7174 |
m_reporter(CATCH_MOVE(reporter)), |
| 7175 |
m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, |
| 7176 |
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) |
| 7177 |
{ |
| 7178 |
- m_context.setResultCapture(this); |
| 7179 |
+ getCurrentMutableContext().setResultCapture( this ); |
| 7180 |
m_reporter->testRunStarting(m_runInfo); |
| 7181 |
} |
| 7182 |
|
| 7183 |
@@ -4981,13 +5244,8 @@ namespace Catch { |
| 7184 |
Totals RunContext::runTest(TestCaseHandle const& testCase) { |
| 7185 |
const Totals prevTotals = m_totals; |
| 7186 |
|
| 7187 |
- std::string redirectedCout; |
| 7188 |
- std::string redirectedCerr; |
| 7189 |
- |
| 7190 |
auto const& testInfo = testCase.getTestCaseInfo(); |
| 7191 |
- |
| 7192 |
m_reporter->testCaseStarting(testInfo); |
| 7193 |
- |
| 7194 |
m_activeTestCase = &testCase; |
| 7195 |
|
| 7196 |
|
| 7197 |
@@ -5029,9 +5287,11 @@ namespace Catch { |
| 7198 |
seedRng( *m_config ); |
| 7199 |
|
| 7200 |
uint64_t testRuns = 0; |
| 7201 |
+ std::string redirectedCout; |
| 7202 |
+ std::string redirectedCerr; |
| 7203 |
do { |
| 7204 |
m_trackerContext.startCycle(); |
| 7205 |
- m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); |
| 7206 |
+ m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocationRef(testInfo.name, testInfo.lineInfo)); |
| 7207 |
|
| 7208 |
m_reporter->testCasePartialStarting(testInfo, testRuns); |
| 7209 |
|
| 7210 |
@@ -5042,7 +5302,7 @@ namespace Catch { |
| 7211 |
redirectedCerr += oneRunCerr; |
| 7212 |
|
| 7213 |
const auto singleRunTotals = m_totals.delta(beforeRunTotals); |
| 7214 |
- auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, oneRunCout, oneRunCerr, aborting()); |
| 7215 |
+ auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, CATCH_MOVE(oneRunCout), CATCH_MOVE(oneRunCerr), aborting()); |
| 7216 |
|
| 7217 |
m_reporter->testCasePartialEnded(statsForOneRun, testRuns); |
| 7218 |
++testRuns; |
| 7219 |
@@ -5057,8 +5317,8 @@ namespace Catch { |
| 7220 |
m_totals.testCases += deltaTotals.testCases; |
| 7221 |
m_reporter->testCaseEnded(TestCaseStats(testInfo, |
| 7222 |
deltaTotals, |
| 7223 |
- redirectedCout, |
| 7224 |
- redirectedCerr, |
| 7225 |
+ CATCH_MOVE(redirectedCout), |
| 7226 |
+ CATCH_MOVE(redirectedCerr), |
| 7227 |
aborting())); |
| 7228 |
|
| 7229 |
m_activeTestCase = nullptr; |
| 7230 |
@@ -5068,10 +5328,13 @@ namespace Catch { |
| 7231 |
} |
| 7232 |
|
| 7233 |
|
| 7234 |
- void RunContext::assertionEnded(AssertionResult const & result) { |
| 7235 |
+ void RunContext::assertionEnded(AssertionResult&& result) { |
| 7236 |
if (result.getResultType() == ResultWas::Ok) { |
| 7237 |
m_totals.assertions.passed++; |
| 7238 |
m_lastAssertionPassed = true; |
| 7239 |
+ } else if (result.getResultType() == ResultWas::ExplicitSkip) { |
| 7240 |
+ m_totals.assertions.skipped++; |
| 7241 |
+ m_lastAssertionPassed = true; |
| 7242 |
} else if (!result.succeeded()) { |
| 7243 |
m_lastAssertionPassed = false; |
| 7244 |
if (result.isOk()) { |
| 7245 |
@@ -5087,24 +5350,36 @@ namespace Catch { |
| 7246 |
|
| 7247 |
m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)); |
| 7248 |
|
| 7249 |
- if (result.getResultType() != ResultWas::Warning) |
| 7250 |
+ if ( result.getResultType() != ResultWas::Warning ) { |
| 7251 |
m_messageScopes.clear(); |
| 7252 |
+ } |
| 7253 |
|
| 7254 |
// Reset working state |
| 7255 |
resetAssertionInfo(); |
| 7256 |
- m_lastResult = result; |
| 7257 |
+ m_lastResult = CATCH_MOVE( result ); |
| 7258 |
} |
| 7259 |
void RunContext::resetAssertionInfo() { |
| 7260 |
m_lastAssertionInfo.macroName = StringRef(); |
| 7261 |
m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; |
| 7262 |
} |
| 7263 |
|
| 7264 |
- bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { |
| 7265 |
- ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); |
| 7266 |
+ void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { |
| 7267 |
+ m_reporter->assertionStarting( info ); |
| 7268 |
+ } |
| 7269 |
+ |
| 7270 |
+ bool RunContext::sectionStarted( StringRef sectionName, |
| 7271 |
+ SourceLineInfo const& sectionLineInfo, |
| 7272 |
+ Counts& assertions ) { |
| 7273 |
+ ITracker& sectionTracker = |
| 7274 |
+ SectionTracker::acquire( m_trackerContext, |
| 7275 |
+ TestCaseTracking::NameAndLocationRef( |
| 7276 |
+ sectionName, sectionLineInfo ) ); |
| 7277 |
+ |
| 7278 |
if (!sectionTracker.isOpen()) |
| 7279 |
return false; |
| 7280 |
m_activeSections.push_back(§ionTracker); |
| 7281 |
|
| 7282 |
+ SectionInfo sectionInfo( sectionLineInfo, static_cast<std::string>(sectionName) ); |
| 7283 |
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; |
| 7284 |
|
| 7285 |
m_reporter->sectionStarting(sectionInfo); |
| 7286 |
@@ -5113,14 +5388,39 @@ namespace Catch { |
| 7287 |
|
| 7288 |
return true; |
| 7289 |
} |
| 7290 |
- auto RunContext::acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { |
| 7291 |
+ IGeneratorTracker* |
| 7292 |
+ RunContext::acquireGeneratorTracker( StringRef generatorName, |
| 7293 |
+ SourceLineInfo const& lineInfo ) { |
| 7294 |
using namespace Generators; |
| 7295 |
- GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, |
| 7296 |
- TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) ); |
| 7297 |
+ GeneratorTracker* tracker = GeneratorTracker::acquire( |
| 7298 |
+ m_trackerContext, |
| 7299 |
+ TestCaseTracking::NameAndLocationRef( |
| 7300 |
+ generatorName, lineInfo ) ); |
| 7301 |
m_lastAssertionInfo.lineInfo = lineInfo; |
| 7302 |
return tracker; |
| 7303 |
} |
| 7304 |
|
| 7305 |
+ IGeneratorTracker* RunContext::createGeneratorTracker( |
| 7306 |
+ StringRef generatorName, |
| 7307 |
+ SourceLineInfo lineInfo, |
| 7308 |
+ Generators::GeneratorBasePtr&& generator ) { |
| 7309 |
+ |
| 7310 |
+ auto nameAndLoc = TestCaseTracking::NameAndLocation( static_cast<std::string>( generatorName ), lineInfo ); |
| 7311 |
+ auto& currentTracker = m_trackerContext.currentTracker(); |
| 7312 |
+ assert( |
| 7313 |
+ currentTracker.nameAndLocation() != nameAndLoc && |
| 7314 |
+ "Trying to create tracker for a genreator that already has one" ); |
| 7315 |
+ |
| 7316 |
+ auto newTracker = Catch::Detail::make_unique<Generators::GeneratorTracker>( |
| 7317 |
+ CATCH_MOVE(nameAndLoc), m_trackerContext, ¤tTracker ); |
| 7318 |
+ auto ret = newTracker.get(); |
| 7319 |
+ currentTracker.addChild( CATCH_MOVE( newTracker ) ); |
| 7320 |
+ |
| 7321 |
+ ret->setGenerator( CATCH_MOVE( generator ) ); |
| 7322 |
+ ret->open(); |
| 7323 |
+ return ret; |
| 7324 |
+ } |
| 7325 |
+ |
| 7326 |
bool RunContext::testForMissingAssertions(Counts& assertions) { |
| 7327 |
if (assertions.total() != 0) |
| 7328 |
return false; |
| 7329 |
@@ -5133,7 +5433,7 @@ namespace Catch { |
| 7330 |
return true; |
| 7331 |
} |
| 7332 |
|
| 7333 |
- void RunContext::sectionEnded(SectionEndInfo const & endInfo) { |
| 7334 |
+ void RunContext::sectionEnded(SectionEndInfo&& endInfo) { |
| 7335 |
Counts assertions = m_totals.assertions - endInfo.prevAssertions; |
| 7336 |
bool missingAssertions = testForMissingAssertions(assertions); |
| 7337 |
|
| 7338 |
@@ -5142,19 +5442,20 @@ namespace Catch { |
| 7339 |
m_activeSections.pop_back(); |
| 7340 |
} |
| 7341 |
|
| 7342 |
- m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); |
| 7343 |
+ m_reporter->sectionEnded(SectionStats(CATCH_MOVE(endInfo.sectionInfo), assertions, endInfo.durationInSeconds, missingAssertions)); |
| 7344 |
m_messages.clear(); |
| 7345 |
m_messageScopes.clear(); |
| 7346 |
} |
| 7347 |
|
| 7348 |
- void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { |
| 7349 |
- if (m_unfinishedSections.empty()) |
| 7350 |
+ void RunContext::sectionEndedEarly(SectionEndInfo&& endInfo) { |
| 7351 |
+ if ( m_unfinishedSections.empty() ) { |
| 7352 |
m_activeSections.back()->fail(); |
| 7353 |
- else |
| 7354 |
+ } else { |
| 7355 |
m_activeSections.back()->close(); |
| 7356 |
+ } |
| 7357 |
m_activeSections.pop_back(); |
| 7358 |
|
| 7359 |
- m_unfinishedSections.push_back(endInfo); |
| 7360 |
+ m_unfinishedSections.push_back(CATCH_MOVE(endInfo)); |
| 7361 |
} |
| 7362 |
|
| 7363 |
void RunContext::benchmarkPreparing( StringRef name ) { |
| 7364 |
@@ -5178,8 +5479,8 @@ namespace Catch { |
| 7365 |
m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); |
| 7366 |
} |
| 7367 |
|
| 7368 |
- void RunContext::emplaceUnscopedMessage( MessageBuilder const& builder ) { |
| 7369 |
- m_messageScopes.emplace_back( builder ); |
| 7370 |
+ void RunContext::emplaceUnscopedMessage( MessageBuilder&& builder ) { |
| 7371 |
+ m_messageScopes.emplace_back( CATCH_MOVE(builder) ); |
| 7372 |
} |
| 7373 |
|
| 7374 |
std::string RunContext::getCurrentTestName() const { |
| 7375 |
@@ -5204,9 +5505,9 @@ namespace Catch { |
| 7376 |
// Instead, fake a result data. |
| 7377 |
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); |
| 7378 |
tempResult.message = static_cast<std::string>(message); |
| 7379 |
- AssertionResult result(m_lastAssertionInfo, tempResult); |
| 7380 |
+ AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult)); |
| 7381 |
|
| 7382 |
- assertionEnded(result); |
| 7383 |
+ assertionEnded(CATCH_MOVE(result) ); |
| 7384 |
|
| 7385 |
handleUnfinishedSections(); |
| 7386 |
|
| 7387 |
@@ -5216,7 +5517,7 @@ namespace Catch { |
| 7388 |
|
| 7389 |
Counts assertions; |
| 7390 |
assertions.failed = 1; |
| 7391 |
- SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); |
| 7392 |
+ SectionStats testCaseSectionStats(CATCH_MOVE(testCaseSection), assertions, 0, false); |
| 7393 |
m_reporter->sectionEnded(testCaseSectionStats); |
| 7394 |
|
| 7395 |
auto const& testInfo = m_activeTestCase->getTestCaseInfo(); |
| 7396 |
@@ -5277,6 +5578,8 @@ namespace Catch { |
| 7397 |
duration = timer.getElapsedSeconds(); |
| 7398 |
} CATCH_CATCH_ANON (TestFailureException&) { |
| 7399 |
// This just means the test was aborted due to failure |
| 7400 |
+ } CATCH_CATCH_ANON (TestSkipException&) { |
| 7401 |
+ // This just means the test was explicitly skipped |
| 7402 |
} CATCH_CATCH_ALL { |
| 7403 |
// Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions |
| 7404 |
// are reported without translation at the point of origin. |
| 7405 |
@@ -5293,7 +5596,7 @@ namespace Catch { |
| 7406 |
m_messages.clear(); |
| 7407 |
m_messageScopes.clear(); |
| 7408 |
|
| 7409 |
- SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); |
| 7410 |
+ SectionStats testCaseSectionStats(CATCH_MOVE(testCaseSection), assertions, duration, missingAssertions); |
| 7411 |
m_reporter->sectionEnded(testCaseSectionStats); |
| 7412 |
} |
| 7413 |
|
| 7414 |
@@ -5317,7 +5620,7 @@ namespace Catch { |
| 7415 |
itEnd = m_unfinishedSections.rend(); |
| 7416 |
it != itEnd; |
| 7417 |
++it) |
| 7418 |
- sectionEnded(*it); |
| 7419 |
+ sectionEnded(CATCH_MOVE(*it)); |
| 7420 |
m_unfinishedSections.clear(); |
| 7421 |
} |
| 7422 |
|
| 7423 |
@@ -5326,8 +5629,6 @@ namespace Catch { |
| 7424 |
ITransientExpression const& expr, |
| 7425 |
AssertionReaction& reaction |
| 7426 |
) { |
| 7427 |
- m_reporter->assertionStarting( info ); |
| 7428 |
- |
| 7429 |
bool negated = isFalseTest( info.resultDisposition ); |
| 7430 |
bool result = expr.getResult() != negated; |
| 7431 |
|
| 7432 |
@@ -5353,10 +5654,10 @@ namespace Catch { |
| 7433 |
m_lastAssertionInfo = info; |
| 7434 |
AssertionResultData data( resultType, LazyExpression( negated ) ); |
| 7435 |
|
| 7436 |
- AssertionResult assertionResult{ info, data }; |
| 7437 |
+ AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; |
| 7438 |
assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; |
| 7439 |
|
| 7440 |
- assertionEnded( assertionResult ); |
| 7441 |
+ assertionEnded( CATCH_MOVE(assertionResult) ); |
| 7442 |
} |
| 7443 |
|
| 7444 |
void RunContext::handleMessage( |
| 7445 |
@@ -5365,16 +5666,22 @@ namespace Catch { |
| 7446 |
StringRef message, |
| 7447 |
AssertionReaction& reaction |
| 7448 |
) { |
| 7449 |
- m_reporter->assertionStarting( info ); |
| 7450 |
- |
| 7451 |
m_lastAssertionInfo = info; |
| 7452 |
|
| 7453 |
AssertionResultData data( resultType, LazyExpression( false ) ); |
| 7454 |
data.message = static_cast<std::string>(message); |
| 7455 |
- AssertionResult assertionResult{ m_lastAssertionInfo, data }; |
| 7456 |
- assertionEnded( assertionResult ); |
| 7457 |
- if( !assertionResult.isOk() ) |
| 7458 |
+ AssertionResult assertionResult{ m_lastAssertionInfo, |
| 7459 |
+ CATCH_MOVE( data ) }; |
| 7460 |
+ |
| 7461 |
+ const auto isOk = assertionResult.isOk(); |
| 7462 |
+ assertionEnded( CATCH_MOVE(assertionResult) ); |
| 7463 |
+ if ( !isOk ) { |
| 7464 |
populateReaction( reaction ); |
| 7465 |
+ } else if ( resultType == ResultWas::ExplicitSkip ) { |
| 7466 |
+ // TODO: Need to handle this explicitly, as ExplicitSkip is |
| 7467 |
+ // considered "OK" |
| 7468 |
+ reaction.shouldSkip = true; |
| 7469 |
+ } |
| 7470 |
} |
| 7471 |
void RunContext::handleUnexpectedExceptionNotThrown( |
| 7472 |
AssertionInfo const& info, |
| 7473 |
@@ -5385,15 +5692,15 @@ namespace Catch { |
| 7474 |
|
| 7475 |
void RunContext::handleUnexpectedInflightException( |
| 7476 |
AssertionInfo const& info, |
| 7477 |
- std::string const& message, |
| 7478 |
+ std::string&& message, |
| 7479 |
AssertionReaction& reaction |
| 7480 |
) { |
| 7481 |
m_lastAssertionInfo = info; |
| 7482 |
|
| 7483 |
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); |
| 7484 |
- data.message = message; |
| 7485 |
- AssertionResult assertionResult{ info, data }; |
| 7486 |
- assertionEnded( assertionResult ); |
| 7487 |
+ data.message = CATCH_MOVE(message); |
| 7488 |
+ AssertionResult assertionResult{ info, CATCH_MOVE(data) }; |
| 7489 |
+ assertionEnded( CATCH_MOVE(assertionResult) ); |
| 7490 |
populateReaction( reaction ); |
| 7491 |
} |
| 7492 |
|
| 7493 |
@@ -5405,12 +5712,13 @@ namespace Catch { |
| 7494 |
void RunContext::handleIncomplete( |
| 7495 |
AssertionInfo const& info |
| 7496 |
) { |
| 7497 |
+ using namespace std::string_literals; |
| 7498 |
m_lastAssertionInfo = info; |
| 7499 |
|
| 7500 |
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); |
| 7501 |
- data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; |
| 7502 |
- AssertionResult assertionResult{ info, data }; |
| 7503 |
- assertionEnded( assertionResult ); |
| 7504 |
+ data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"s; |
| 7505 |
+ AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; |
| 7506 |
+ assertionEnded( CATCH_MOVE(assertionResult) ); |
| 7507 |
} |
| 7508 |
void RunContext::handleNonExpr( |
| 7509 |
AssertionInfo const &info, |
| 7510 |
@@ -5420,11 +5728,11 @@ namespace Catch { |
| 7511 |
m_lastAssertionInfo = info; |
| 7512 |
|
| 7513 |
AssertionResultData data( resultType, LazyExpression( false ) ); |
| 7514 |
- AssertionResult assertionResult{ info, data }; |
| 7515 |
- assertionEnded( assertionResult ); |
| 7516 |
+ AssertionResult assertionResult{ info, CATCH_MOVE( data ) }; |
| 7517 |
|
| 7518 |
- if( !assertionResult.isOk() ) |
| 7519 |
- populateReaction( reaction ); |
| 7520 |
+ const auto isOk = assertionResult.isOk(); |
| 7521 |
+ assertionEnded( CATCH_MOVE(assertionResult) ); |
| 7522 |
+ if ( !isOk ) { populateReaction( reaction ); } |
| 7523 |
} |
| 7524 |
|
| 7525 |
|
| 7526 |
@@ -5452,7 +5760,7 @@ namespace Catch { |
| 7527 |
Section::Section( SectionInfo&& info ): |
| 7528 |
m_info( CATCH_MOVE( info ) ), |
| 7529 |
m_sectionIncluded( |
| 7530 |
- getResultCapture().sectionStarted( m_info, m_assertions ) ) { |
| 7531 |
+ getResultCapture().sectionStarted( m_info.name, m_info.lineInfo, m_assertions ) ) { |
| 7532 |
// Non-"included" sections will not use the timing information |
| 7533 |
// anyway, so don't bother with the potential syscall. |
| 7534 |
if (m_sectionIncluded) { |
| 7535 |
@@ -5460,13 +5768,31 @@ namespace Catch { |
| 7536 |
} |
| 7537 |
} |
| 7538 |
|
| 7539 |
+ Section::Section( SourceLineInfo const& _lineInfo, |
| 7540 |
+ StringRef _name, |
| 7541 |
+ const char* const ): |
| 7542 |
+ m_info( { "invalid", static_cast<std::size_t>( -1 ) }, std::string{} ), |
| 7543 |
+ m_sectionIncluded( |
| 7544 |
+ getResultCapture().sectionStarted( _name, _lineInfo, m_assertions ) ) { |
| 7545 |
+ // We delay initialization the SectionInfo member until we know |
| 7546 |
+ // this section needs it, so we avoid allocating std::string for name. |
| 7547 |
+ // We also delay timer start to avoid the potential syscall unless we |
| 7548 |
+ // will actually use the result. |
| 7549 |
+ if ( m_sectionIncluded ) { |
| 7550 |
+ m_info.name = static_cast<std::string>( _name ); |
| 7551 |
+ m_info.lineInfo = _lineInfo; |
| 7552 |
+ m_timer.start(); |
| 7553 |
+ } |
| 7554 |
+ } |
| 7555 |
+ |
| 7556 |
Section::~Section() { |
| 7557 |
if( m_sectionIncluded ) { |
| 7558 |
- SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() }; |
| 7559 |
- if( uncaught_exceptions() ) |
| 7560 |
- getResultCapture().sectionEndedEarly( endInfo ); |
| 7561 |
- else |
| 7562 |
- getResultCapture().sectionEnded( endInfo ); |
| 7563 |
+ SectionEndInfo endInfo{ CATCH_MOVE(m_info), m_assertions, m_timer.getElapsedSeconds() }; |
| 7564 |
+ if ( uncaught_exceptions() ) { |
| 7565 |
+ getResultCapture().sectionEndedEarly( CATCH_MOVE(endInfo) ); |
| 7566 |
+ } else { |
| 7567 |
+ getResultCapture().sectionEnded( CATCH_MOVE( endInfo ) ); |
| 7568 |
+ } |
| 7569 |
} |
| 7570 |
} |
| 7571 |
|
| 7572 |
@@ -5575,7 +5901,6 @@ namespace Catch { |
| 7573 |
|
| 7574 |
|
| 7575 |
|
| 7576 |
-#include <algorithm> |
| 7577 |
#include <ostream> |
| 7578 |
#include <cstring> |
| 7579 |
#include <cctype> |
| 7580 |
@@ -5599,9 +5924,9 @@ namespace Catch { |
| 7581 |
return s.find( infix ) != std::string::npos; |
| 7582 |
} |
| 7583 |
void toLowerInPlace( std::string& s ) { |
| 7584 |
- std::transform( s.begin(), s.end(), s.begin(), []( char c ) { |
| 7585 |
- return toLower( c ); |
| 7586 |
- } ); |
| 7587 |
+ for ( char& c : s ) { |
| 7588 |
+ c = toLower( c ); |
| 7589 |
+ } |
| 7590 |
} |
| 7591 |
std::string toLower( std::string const& s ) { |
| 7592 |
std::string lc = s; |
| 7593 |
@@ -5682,10 +6007,6 @@ namespace Catch { |
| 7594 |
: StringRef( rawChars, std::strlen(rawChars) ) |
| 7595 |
{} |
| 7596 |
|
| 7597 |
- auto StringRef::operator == ( StringRef other ) const noexcept -> bool { |
| 7598 |
- return m_size == other.m_size |
| 7599 |
- && (std::memcmp( m_start, other.m_start, m_size ) == 0); |
| 7600 |
- } |
| 7601 |
|
| 7602 |
bool StringRef::operator<(StringRef rhs) const noexcept { |
| 7603 |
if (m_size < rhs.m_size) { |
| 7604 |
@@ -5819,6 +6140,38 @@ namespace Catch { |
| 7605 |
|
| 7606 |
namespace Catch { |
| 7607 |
|
| 7608 |
+ namespace { |
| 7609 |
+ static void enforceNoDuplicateTestCases( |
| 7610 |
+ std::vector<TestCaseHandle> const& tests ) { |
| 7611 |
+ auto testInfoCmp = []( TestCaseInfo const* lhs, |
| 7612 |
+ TestCaseInfo const* rhs ) { |
| 7613 |
+ return *lhs < *rhs; |
| 7614 |
+ }; |
| 7615 |
+ std::set<TestCaseInfo const*, decltype( testInfoCmp )&> seenTests( |
| 7616 |
+ testInfoCmp ); |
| 7617 |
+ for ( auto const& test : tests ) { |
| 7618 |
+ const auto infoPtr = &test.getTestCaseInfo(); |
| 7619 |
+ const auto prev = seenTests.insert( infoPtr ); |
| 7620 |
+ CATCH_ENFORCE( prev.second, |
| 7621 |
+ "error: test case \"" |
| 7622 |
+ << infoPtr->name << "\", with tags \"" |
| 7623 |
+ << infoPtr->tagsAsString() |
| 7624 |
+ << "\" already defined.\n" |
| 7625 |
+ << "\tFirst seen at " |
| 7626 |
+ << ( *prev.first )->lineInfo << "\n" |
| 7627 |
+ << "\tRedefined at " << infoPtr->lineInfo ); |
| 7628 |
+ } |
| 7629 |
+ } |
| 7630 |
+ |
| 7631 |
+ static bool matchTest( TestCaseHandle const& testCase, |
| 7632 |
+ TestSpec const& testSpec, |
| 7633 |
+ IConfig const& config ) { |
| 7634 |
+ return testSpec.matches( testCase.getTestCaseInfo() ) && |
| 7635 |
+ isThrowSafe( testCase, config ); |
| 7636 |
+ } |
| 7637 |
+ |
| 7638 |
+ } // end unnamed namespace |
| 7639 |
+ |
| 7640 |
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ) { |
| 7641 |
switch (config.runOrder()) { |
| 7642 |
case TestRunOrder::Declared: |
| 7643 |
@@ -5875,29 +6228,6 @@ namespace Catch { |
| 7644 |
return !testCase.getTestCaseInfo().throws() || config.allowThrows(); |
| 7645 |
} |
| 7646 |
|
| 7647 |
- bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ) { |
| 7648 |
- return testSpec.matches( testCase.getTestCaseInfo() ) && isThrowSafe( testCase, config ); |
| 7649 |
- } |
| 7650 |
- |
| 7651 |
- void |
| 7652 |
- enforceNoDuplicateTestCases( std::vector<TestCaseHandle> const& tests ) { |
| 7653 |
- auto testInfoCmp = []( TestCaseInfo const* lhs, |
| 7654 |
- TestCaseInfo const* rhs ) { |
| 7655 |
- return *lhs < *rhs; |
| 7656 |
- }; |
| 7657 |
- std::set<TestCaseInfo const*, decltype(testInfoCmp)> seenTests(testInfoCmp); |
| 7658 |
- for ( auto const& test : tests ) { |
| 7659 |
- const auto infoPtr = &test.getTestCaseInfo(); |
| 7660 |
- const auto prev = seenTests.insert( infoPtr ); |
| 7661 |
- CATCH_ENFORCE( |
| 7662 |
- prev.second, |
| 7663 |
- "error: test case \"" << infoPtr->name << "\", with tags \"" |
| 7664 |
- << infoPtr->tagsAsString() << "\" already defined.\n" |
| 7665 |
- << "\tFirst seen at " << ( *prev.first )->lineInfo << "\n" |
| 7666 |
- << "\tRedefined at " << infoPtr->lineInfo ); |
| 7667 |
- } |
| 7668 |
- } |
| 7669 |
- |
| 7670 |
std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle> const& testCases, TestSpec const& testSpec, IConfig const& config ) { |
| 7671 |
std::vector<TestCaseHandle> filtered; |
| 7672 |
filtered.reserve( testCases.size() ); |
| 7673 |
@@ -5938,13 +6268,6 @@ namespace Catch { |
| 7674 |
return m_sortedFunctions; |
| 7675 |
} |
| 7676 |
|
| 7677 |
- |
| 7678 |
- |
| 7679 |
- /////////////////////////////////////////////////////////////////////////// |
| 7680 |
- void TestInvokerAsFunction::invoke() const { |
| 7681 |
- m_testAsFunction(); |
| 7682 |
- } |
| 7683 |
- |
| 7684 |
} // end namespace Catch |
| 7685 |
|
| 7686 |
|
| 7687 |
@@ -5961,8 +6284,8 @@ namespace Catch { |
| 7688 |
namespace Catch { |
| 7689 |
namespace TestCaseTracking { |
| 7690 |
|
| 7691 |
- NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) |
| 7692 |
- : name( _name ), |
| 7693 |
+ NameAndLocation::NameAndLocation( std::string&& _name, SourceLineInfo const& _location ) |
| 7694 |
+ : name( CATCH_MOVE(_name) ), |
| 7695 |
location( _location ) |
| 7696 |
{} |
| 7697 |
|
| 7698 |
@@ -5977,14 +6300,17 @@ namespace TestCaseTracking { |
| 7699 |
m_children.push_back( CATCH_MOVE(child) ); |
| 7700 |
} |
| 7701 |
|
| 7702 |
- ITracker* ITracker::findChild( NameAndLocation const& nameAndLocation ) { |
| 7703 |
+ ITracker* ITracker::findChild( NameAndLocationRef const& nameAndLocation ) { |
| 7704 |
auto it = std::find_if( |
| 7705 |
m_children.begin(), |
| 7706 |
m_children.end(), |
| 7707 |
[&nameAndLocation]( ITrackerPtr const& tracker ) { |
| 7708 |
- return tracker->nameAndLocation().location == |
| 7709 |
- nameAndLocation.location && |
| 7710 |
- tracker->nameAndLocation().name == nameAndLocation.name; |
| 7711 |
+ auto const& tnameAndLoc = tracker->nameAndLocation(); |
| 7712 |
+ if ( tnameAndLoc.location.line != |
| 7713 |
+ nameAndLocation.location.line ) { |
| 7714 |
+ return false; |
| 7715 |
+ } |
| 7716 |
+ return tnameAndLoc == nameAndLocation; |
| 7717 |
} ); |
| 7718 |
return ( it != m_children.end() ) ? it->get() : nullptr; |
| 7719 |
} |
| 7720 |
@@ -5992,10 +6318,6 @@ namespace TestCaseTracking { |
| 7721 |
bool ITracker::isSectionTracker() const { return false; } |
| 7722 |
bool ITracker::isGeneratorTracker() const { return false; } |
| 7723 |
|
| 7724 |
- bool ITracker::isSuccessfullyCompleted() const { |
| 7725 |
- return m_runState == CompletedSuccessfully; |
| 7726 |
- } |
| 7727 |
- |
| 7728 |
bool ITracker::isOpen() const { |
| 7729 |
return m_runState != NotStarted && !isComplete(); |
| 7730 |
} |
| 7731 |
@@ -6022,16 +6344,6 @@ namespace TestCaseTracking { |
| 7732 |
return *m_rootTracker; |
| 7733 |
} |
| 7734 |
|
| 7735 |
- void TrackerContext::endRun() { |
| 7736 |
- m_rootTracker.reset(); |
| 7737 |
- m_currentTracker = nullptr; |
| 7738 |
- m_runState = NotStarted; |
| 7739 |
- } |
| 7740 |
- |
| 7741 |
- void TrackerContext::startCycle() { |
| 7742 |
- m_currentTracker = m_rootTracker.get(); |
| 7743 |
- m_runState = Executing; |
| 7744 |
- } |
| 7745 |
void TrackerContext::completeCycle() { |
| 7746 |
m_runState = CompletedCycle; |
| 7747 |
} |
| 7748 |
@@ -6039,16 +6351,13 @@ namespace TestCaseTracking { |
| 7749 |
bool TrackerContext::completedCycle() const { |
| 7750 |
return m_runState == CompletedCycle; |
| 7751 |
} |
| 7752 |
- ITracker& TrackerContext::currentTracker() { |
| 7753 |
- return *m_currentTracker; |
| 7754 |
- } |
| 7755 |
void TrackerContext::setCurrentTracker( ITracker* tracker ) { |
| 7756 |
m_currentTracker = tracker; |
| 7757 |
} |
| 7758 |
|
| 7759 |
|
| 7760 |
- TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ): |
| 7761 |
- ITracker(nameAndLocation, parent), |
| 7762 |
+ TrackerBase::TrackerBase( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ): |
| 7763 |
+ ITracker(CATCH_MOVE(nameAndLocation), parent), |
| 7764 |
m_ctx( ctx ) |
| 7765 |
{} |
| 7766 |
|
| 7767 |
@@ -6108,13 +6417,14 @@ namespace TestCaseTracking { |
| 7768 |
m_ctx.setCurrentTracker( this ); |
| 7769 |
} |
| 7770 |
|
| 7771 |
- SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) |
| 7772 |
- : TrackerBase( nameAndLocation, ctx, parent ), |
| 7773 |
- m_trimmed_name(trim(nameAndLocation.name)) |
| 7774 |
+ SectionTracker::SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ) |
| 7775 |
+ : TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ), |
| 7776 |
+ m_trimmed_name(trim(StringRef(ITracker::nameAndLocation().name))) |
| 7777 |
{ |
| 7778 |
if( parent ) { |
| 7779 |
- while( !parent->isSectionTracker() ) |
| 7780 |
+ while ( !parent->isSectionTracker() ) { |
| 7781 |
parent = parent->parent(); |
| 7782 |
+ } |
| 7783 |
|
| 7784 |
SectionTracker& parentSection = static_cast<SectionTracker&>( *parent ); |
| 7785 |
addNextFilters( parentSection.m_filters ); |
| 7786 |
@@ -6134,24 +6444,30 @@ namespace TestCaseTracking { |
| 7787 |
|
| 7788 |
bool SectionTracker::isSectionTracker() const { return true; } |
| 7789 |
|
| 7790 |
- SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { |
| 7791 |
- SectionTracker* section; |
| 7792 |
+ SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocationRef const& nameAndLocation ) { |
| 7793 |
+ SectionTracker* tracker; |
| 7794 |
|
| 7795 |
ITracker& currentTracker = ctx.currentTracker(); |
| 7796 |
if ( ITracker* childTracker = |
| 7797 |
currentTracker.findChild( nameAndLocation ) ) { |
| 7798 |
assert( childTracker ); |
| 7799 |
assert( childTracker->isSectionTracker() ); |
| 7800 |
- section = static_cast<SectionTracker*>( childTracker ); |
| 7801 |
+ tracker = static_cast<SectionTracker*>( childTracker ); |
| 7802 |
} else { |
| 7803 |
- auto newSection = Catch::Detail::make_unique<SectionTracker>( |
| 7804 |
- nameAndLocation, ctx, ¤tTracker ); |
| 7805 |
- section = newSection.get(); |
| 7806 |
- currentTracker.addChild( CATCH_MOVE( newSection ) ); |
| 7807 |
+ auto newTracker = Catch::Detail::make_unique<SectionTracker>( |
| 7808 |
+ NameAndLocation{ static_cast<std::string>(nameAndLocation.name), |
| 7809 |
+ nameAndLocation.location }, |
| 7810 |
+ ctx, |
| 7811 |
+ ¤tTracker ); |
| 7812 |
+ tracker = newTracker.get(); |
| 7813 |
+ currentTracker.addChild( CATCH_MOVE( newTracker ) ); |
| 7814 |
} |
| 7815 |
- if( !ctx.completedCycle() ) |
| 7816 |
- section->tryOpen(); |
| 7817 |
- return *section; |
| 7818 |
+ |
| 7819 |
+ if ( !ctx.completedCycle() ) { |
| 7820 |
+ tracker->tryOpen(); |
| 7821 |
+ } |
| 7822 |
+ |
| 7823 |
+ return *tracker; |
| 7824 |
} |
| 7825 |
|
| 7826 |
void SectionTracker::tryOpen() { |
| 7827 |
@@ -6172,10 +6488,6 @@ namespace TestCaseTracking { |
| 7828 |
m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() ); |
| 7829 |
} |
| 7830 |
|
| 7831 |
- std::vector<StringRef> const& SectionTracker::getFilters() const { |
| 7832 |
- return m_filters; |
| 7833 |
- } |
| 7834 |
- |
| 7835 |
StringRef SectionTracker::trimmedName() const { |
| 7836 |
return m_trimmed_name; |
| 7837 |
} |
| 7838 |
@@ -6190,13 +6502,37 @@ namespace TestCaseTracking { |
| 7839 |
|
| 7840 |
|
| 7841 |
|
| 7842 |
+ |
| 7843 |
+namespace Catch { |
| 7844 |
+ |
| 7845 |
+ void throw_test_failure_exception() { |
| 7846 |
+#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) |
| 7847 |
+ throw TestFailureException{}; |
| 7848 |
+#else |
| 7849 |
+ CATCH_ERROR( "Test failure requires aborting test!" ); |
| 7850 |
+#endif |
| 7851 |
+ } |
| 7852 |
+ |
| 7853 |
+ void throw_test_skip_exception() { |
| 7854 |
+#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) |
| 7855 |
+ throw Catch::TestSkipException(); |
| 7856 |
+#else |
| 7857 |
+ CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); |
| 7858 |
+#endif |
| 7859 |
+ } |
| 7860 |
+ |
| 7861 |
+} // namespace Catch |
| 7862 |
+ |
| 7863 |
+ |
| 7864 |
+ |
| 7865 |
#include <algorithm> |
| 7866 |
#include <iterator> |
| 7867 |
|
| 7868 |
namespace Catch { |
| 7869 |
+ ITestInvoker::~ITestInvoker() = default; |
| 7870 |
|
| 7871 |
namespace { |
| 7872 |
- StringRef extractClassName( StringRef classOrMethodName ) { |
| 7873 |
+ static StringRef extractClassName( StringRef classOrMethodName ) { |
| 7874 |
if ( !startsWith( classOrMethodName, '&' ) ) { |
| 7875 |
return classOrMethodName; |
| 7876 |
} |
| 7877 |
@@ -6223,6 +6559,18 @@ namespace Catch { |
| 7878 |
static_cast<std::size_t>( startIdx ), |
| 7879 |
static_cast<std::size_t>( classNameSize ) ); |
| 7880 |
} |
| 7881 |
+ |
| 7882 |
+ class TestInvokerAsFunction final : public ITestInvoker { |
| 7883 |
+ using TestType = void ( * )(); |
| 7884 |
+ TestType m_testAsFunction; |
| 7885 |
+ |
| 7886 |
+ public: |
| 7887 |
+ TestInvokerAsFunction( TestType testAsFunction ) noexcept: |
| 7888 |
+ m_testAsFunction( testAsFunction ) {} |
| 7889 |
+ |
| 7890 |
+ void invoke() const override { m_testAsFunction(); } |
| 7891 |
+ }; |
| 7892 |
+ |
| 7893 |
} // namespace |
| 7894 |
|
| 7895 |
Detail::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() ) { |
| 7896 |
@@ -6459,10 +6807,8 @@ namespace Catch { |
| 7897 |
token.erase(token.begin()); |
| 7898 |
if (m_exclusion) { |
| 7899 |
m_currentFilter.m_forbidden.emplace_back(Detail::make_unique<TestSpec::TagPattern>(".", m_substring)); |
| 7900 |
- m_currentFilter.m_forbidden.emplace_back(Detail::make_unique<TestSpec::TagPattern>(token, m_substring)); |
| 7901 |
} else { |
| 7902 |
m_currentFilter.m_required.emplace_back(Detail::make_unique<TestSpec::TagPattern>(".", m_substring)); |
| 7903 |
- m_currentFilter.m_required.emplace_back(Detail::make_unique<TestSpec::TagPattern>(token, m_substring)); |
| 7904 |
} |
| 7905 |
} |
| 7906 |
if (m_exclusion) { |
| 7907 |
@@ -6476,10 +6822,6 @@ namespace Catch { |
| 7908 |
m_mode = None; |
| 7909 |
} |
| 7910 |
|
| 7911 |
- TestSpec parseTestSpec( std::string const& arg ) { |
| 7912 |
- return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); |
| 7913 |
- } |
| 7914 |
- |
| 7915 |
} // namespace Catch |
| 7916 |
|
| 7917 |
|
| 7918 |
@@ -6792,6 +7134,7 @@ namespace Catch { |
| 7919 |
// while in /permissive- mode. No, I don't know why. |
| 7920 |
// Tested on VS 2019, 18.{3, 4}.x |
| 7921 |
|
| 7922 |
+#include <cstdint> |
| 7923 |
#include <iomanip> |
| 7924 |
#include <type_traits> |
| 7925 |
|
| 7926 |
@@ -7408,7 +7751,19 @@ WithinRelMatcher WithinRel(float target) { |
| 7927 |
} |
| 7928 |
|
| 7929 |
|
| 7930 |
-} // namespace Matchers |
| 7931 |
+ |
| 7932 |
+bool IsNaNMatcher::match( double const& matchee ) const { |
| 7933 |
+ return std::isnan( matchee ); |
| 7934 |
+} |
| 7935 |
+ |
| 7936 |
+std::string IsNaNMatcher::describe() const { |
| 7937 |
+ using namespace std::string_literals; |
| 7938 |
+ return "is NaN"s; |
| 7939 |
+} |
| 7940 |
+ |
| 7941 |
+IsNaNMatcher IsNaN() { return IsNaNMatcher(); } |
| 7942 |
+ |
| 7943 |
+ } // namespace Matchers |
| 7944 |
} // namespace Catch |
| 7945 |
|
| 7946 |
|
| 7947 |
@@ -7588,9 +7943,9 @@ namespace Catch { |
| 7948 |
// This is the general overload that takes a any string matcher |
| 7949 |
// There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers |
| 7950 |
// the Equals matcher (so the header does not mention matchers) |
| 7951 |
- void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { |
| 7952 |
+ void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ) { |
| 7953 |
std::string exceptionMessage = Catch::translateActiveException(); |
| 7954 |
- MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher, matcherString ); |
| 7955 |
+ MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher ); |
| 7956 |
handler.handleExpr( expr ); |
| 7957 |
} |
| 7958 |
|
| 7959 |
@@ -7607,7 +7962,9 @@ namespace Catch { |
| 7960 |
void AutomakeReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { |
| 7961 |
// Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. |
| 7962 |
m_stream << ":test-result: "; |
| 7963 |
- if (_testCaseStats.totals.assertions.allPassed()) { |
| 7964 |
+ if ( _testCaseStats.totals.testCases.skipped > 0 ) { |
| 7965 |
+ m_stream << "SKIP"; |
| 7966 |
+ } else if (_testCaseStats.totals.assertions.allPassed()) { |
| 7967 |
m_stream << "PASS"; |
| 7968 |
} else if (_testCaseStats.totals.assertions.allOk()) { |
| 7969 |
m_stream << "XFAIL"; |
| 7970 |
@@ -7669,22 +8026,6 @@ namespace Catch { |
| 7971 |
|
| 7972 |
#include <ostream> |
| 7973 |
|
| 7974 |
-namespace { |
| 7975 |
- |
| 7976 |
- constexpr Catch::StringRef bothOrAll( std::uint64_t count ) { |
| 7977 |
- switch (count) { |
| 7978 |
- case 1: |
| 7979 |
- return Catch::StringRef{}; |
| 7980 |
- case 2: |
| 7981 |
- return "both "_catch_sr; |
| 7982 |
- default: |
| 7983 |
- return "all "_catch_sr; |
| 7984 |
- } |
| 7985 |
- } |
| 7986 |
- |
| 7987 |
-} // anon namespace |
| 7988 |
- |
| 7989 |
- |
| 7990 |
namespace Catch { |
| 7991 |
namespace { |
| 7992 |
|
| 7993 |
@@ -7699,42 +8040,6 @@ namespace { |
| 7994 |
static constexpr Catch::StringRef compactPassedString = "passed"_sr; |
| 7995 |
#endif |
| 7996 |
|
| 7997 |
-// Colour, message variants: |
| 7998 |
-// - white: No tests ran. |
| 7999 |
-// - red: Failed [both/all] N test cases, failed [both/all] M assertions. |
| 8000 |
-// - white: Passed [both/all] N test cases (no assertions). |
| 8001 |
-// - red: Failed N tests cases, failed M assertions. |
| 8002 |
-// - green: Passed [both/all] N tests cases with M assertions. |
| 8003 |
-void printTotals(std::ostream& out, const Totals& totals, ColourImpl* colourImpl) { |
| 8004 |
- if (totals.testCases.total() == 0) { |
| 8005 |
- out << "No tests ran."; |
| 8006 |
- } else if (totals.testCases.failed == totals.testCases.total()) { |
| 8007 |
- auto guard = colourImpl->guardColour( Colour::ResultError ).engage( out ); |
| 8008 |
- const StringRef qualify_assertions_failed = |
| 8009 |
- totals.assertions.failed == totals.assertions.total() ? |
| 8010 |
- bothOrAll(totals.assertions.failed) : StringRef{}; |
| 8011 |
- out << |
| 8012 |
- "Failed " << bothOrAll(totals.testCases.failed) |
| 8013 |
- << pluralise(totals.testCases.failed, "test case"_sr) << ", " |
| 8014 |
- "failed " << qualify_assertions_failed << |
| 8015 |
- pluralise(totals.assertions.failed, "assertion"_sr) << '.'; |
| 8016 |
- } else if (totals.assertions.total() == 0) { |
| 8017 |
- out << |
| 8018 |
- "Passed " << bothOrAll(totals.testCases.total()) |
| 8019 |
- << pluralise(totals.testCases.total(), "test case"_sr) |
| 8020 |
- << " (no assertions)."; |
| 8021 |
- } else if (totals.assertions.failed) { |
| 8022 |
- out << colourImpl->guardColour( Colour::ResultError ) << |
| 8023 |
- "Failed " << pluralise(totals.testCases.failed, "test case"_sr) << ", " |
| 8024 |
- "failed " << pluralise(totals.assertions.failed, "assertion"_sr) << '.'; |
| 8025 |
- } else { |
| 8026 |
- out << colourImpl->guardColour( Colour::ResultSuccess ) << |
| 8027 |
- "Passed " << bothOrAll(totals.testCases.passed) |
| 8028 |
- << pluralise(totals.testCases.passed, "test case"_sr) << |
| 8029 |
- " with " << pluralise(totals.assertions.passed, "assertion"_sr) << '.'; |
| 8030 |
- } |
| 8031 |
-} |
| 8032 |
- |
| 8033 |
// Implementation of CompactReporter formatting |
| 8034 |
class AssertionPrinter { |
| 8035 |
public: |
| 8036 |
@@ -7808,6 +8113,11 @@ public: |
| 8037 |
printIssue("explicitly"); |
| 8038 |
printRemainingMessages(Colour::None); |
| 8039 |
break; |
| 8040 |
+ case ResultWas::ExplicitSkip: |
| 8041 |
+ printResultType(Colour::Skip, "skipped"_sr); |
| 8042 |
+ printMessage(); |
| 8043 |
+ printRemainingMessages(); |
| 8044 |
+ break; |
| 8045 |
// These cases are here to prevent compiler warnings |
| 8046 |
case ResultWas::Unknown: |
| 8047 |
case ResultWas::FailureBit: |
| 8048 |
@@ -7869,7 +8179,7 @@ private: |
| 8049 |
return; |
| 8050 |
|
| 8051 |
const auto itEnd = messages.cend(); |
| 8052 |
- const auto N = static_cast<std::size_t>(std::distance(itMessage, itEnd)); |
| 8053 |
+ const auto N = static_cast<std::size_t>(itEnd - itMessage); |
| 8054 |
|
| 8055 |
stream << colourImpl->guardColour( colour ) << " with " |
| 8056 |
<< pluralise( N, "message"_sr ) << ':'; |
| 8057 |
@@ -7890,7 +8200,7 @@ private: |
| 8058 |
private: |
| 8059 |
std::ostream& stream; |
| 8060 |
AssertionResult const& result; |
| 8061 |
- std::vector<MessageInfo> messages; |
| 8062 |
+ std::vector<MessageInfo> const& messages; |
| 8063 |
std::vector<MessageInfo>::const_iterator itMessage; |
| 8064 |
bool printInfoMessages; |
| 8065 |
ColourImpl* colourImpl; |
| 8066 |
@@ -7910,7 +8220,7 @@ private: |
| 8067 |
if ( m_config->testSpec().hasFilters() ) { |
| 8068 |
m_stream << m_colour->guardColour( Colour::BrightYellow ) |
| 8069 |
<< "Filters: " |
| 8070 |
- << serializeFilters( m_config->getTestsOrTags() ) |
| 8071 |
+ << m_config->testSpec() |
| 8072 |
<< '\n'; |
| 8073 |
} |
| 8074 |
m_stream << "RNG seed: " << getSeed() << '\n'; |
| 8075 |
@@ -7923,7 +8233,7 @@ private: |
| 8076 |
|
| 8077 |
// Drop out if result was successful and we're not printing those |
| 8078 |
if( !m_config->includeSuccessfulResults() && result.isOk() ) { |
| 8079 |
- if( result.getResultType() != ResultWas::Warning ) |
| 8080 |
+ if( result.getResultType() != ResultWas::Warning && result.getResultType() != ResultWas::ExplicitSkip ) |
| 8081 |
return; |
| 8082 |
printInfoMessages = false; |
| 8083 |
} |
| 8084 |
@@ -7942,7 +8252,7 @@ private: |
| 8085 |
} |
| 8086 |
|
| 8087 |
void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) { |
| 8088 |
- printTotals( m_stream, _testRunStats.totals, m_colour.get() ); |
| 8089 |
+ printTestRunTotals( m_stream, *m_colour, _testRunStats.totals ); |
| 8090 |
m_stream << "\n\n" << std::flush; |
| 8091 |
StreamingReporterBase::testRunEnded( _testRunStats ); |
| 8092 |
} |
| 8093 |
@@ -7984,7 +8294,6 @@ public: |
| 8094 |
stats(_stats), |
| 8095 |
result(_stats.assertionResult), |
| 8096 |
colour(Colour::None), |
| 8097 |
- message(result.getMessage()), |
| 8098 |
messages(_stats.infoMessages), |
| 8099 |
colourImpl(colourImpl_), |
| 8100 |
printInfoMessages(_printInfoMessages) { |
| 8101 |
@@ -7993,10 +8302,10 @@ public: |
| 8102 |
colour = Colour::Success; |
| 8103 |
passOrFail = "PASSED"_sr; |
| 8104 |
//if( result.hasMessage() ) |
| 8105 |
- if (_stats.infoMessages.size() == 1) |
| 8106 |
- messageLabel = "with message"; |
| 8107 |
- if (_stats.infoMessages.size() > 1) |
| 8108 |
- messageLabel = "with messages"; |
| 8109 |
+ if (messages.size() == 1) |
| 8110 |
+ messageLabel = "with message"_sr; |
| 8111 |
+ if (messages.size() > 1) |
| 8112 |
+ messageLabel = "with messages"_sr; |
| 8113 |
break; |
| 8114 |
case ResultWas::ExpressionFailed: |
| 8115 |
if (result.isOk()) { |
| 8116 |
@@ -8006,43 +8315,57 @@ public: |
| 8117 |
colour = Colour::Error; |
| 8118 |
passOrFail = "FAILED"_sr; |
| 8119 |
} |
| 8120 |
- if (_stats.infoMessages.size() == 1) |
| 8121 |
- messageLabel = "with message"; |
| 8122 |
- if (_stats.infoMessages.size() > 1) |
| 8123 |
- messageLabel = "with messages"; |
| 8124 |
+ if (messages.size() == 1) |
| 8125 |
+ messageLabel = "with message"_sr; |
| 8126 |
+ if (messages.size() > 1) |
| 8127 |
+ messageLabel = "with messages"_sr; |
| 8128 |
break; |
| 8129 |
case ResultWas::ThrewException: |
| 8130 |
colour = Colour::Error; |
| 8131 |
passOrFail = "FAILED"_sr; |
| 8132 |
- messageLabel = "due to unexpected exception with "; |
| 8133 |
- if (_stats.infoMessages.size() == 1) |
| 8134 |
- messageLabel += "message"; |
| 8135 |
- if (_stats.infoMessages.size() > 1) |
| 8136 |
- messageLabel += "messages"; |
| 8137 |
+ // todo switch |
| 8138 |
+ switch (messages.size()) { case 0: |
| 8139 |
+ messageLabel = "due to unexpected exception with "_sr; |
| 8140 |
+ break; |
| 8141 |
+ case 1: |
| 8142 |
+ messageLabel = "due to unexpected exception with message"_sr; |
| 8143 |
+ break; |
| 8144 |
+ default: |
| 8145 |
+ messageLabel = "due to unexpected exception with messages"_sr; |
| 8146 |
+ break; |
| 8147 |
+ } |
| 8148 |
break; |
| 8149 |
case ResultWas::FatalErrorCondition: |
| 8150 |
colour = Colour::Error; |
| 8151 |
passOrFail = "FAILED"_sr; |
| 8152 |
- messageLabel = "due to a fatal error condition"; |
| 8153 |
+ messageLabel = "due to a fatal error condition"_sr; |
| 8154 |
break; |
| 8155 |
case ResultWas::DidntThrowException: |
| 8156 |
colour = Colour::Error; |
| 8157 |
passOrFail = "FAILED"_sr; |
| 8158 |
- messageLabel = "because no exception was thrown where one was expected"; |
| 8159 |
+ messageLabel = "because no exception was thrown where one was expected"_sr; |
| 8160 |
break; |
| 8161 |
case ResultWas::Info: |
| 8162 |
- messageLabel = "info"; |
| 8163 |
+ messageLabel = "info"_sr; |
| 8164 |
break; |
| 8165 |
case ResultWas::Warning: |
| 8166 |
- messageLabel = "warning"; |
| 8167 |
+ messageLabel = "warning"_sr; |
| 8168 |
break; |
| 8169 |
case ResultWas::ExplicitFailure: |
| 8170 |
passOrFail = "FAILED"_sr; |
| 8171 |
colour = Colour::Error; |
| 8172 |
- if (_stats.infoMessages.size() == 1) |
| 8173 |
- messageLabel = "explicitly with message"; |
| 8174 |
- if (_stats.infoMessages.size() > 1) |
| 8175 |
- messageLabel = "explicitly with messages"; |
| 8176 |
+ if (messages.size() == 1) |
| 8177 |
+ messageLabel = "explicitly with message"_sr; |
| 8178 |
+ if (messages.size() > 1) |
| 8179 |
+ messageLabel = "explicitly with messages"_sr; |
| 8180 |
+ break; |
| 8181 |
+ case ResultWas::ExplicitSkip: |
| 8182 |
+ colour = Colour::Skip; |
| 8183 |
+ passOrFail = "SKIPPED"_sr; |
| 8184 |
+ if (messages.size() == 1) |
| 8185 |
+ messageLabel = "explicitly with message"_sr; |
| 8186 |
+ if (messages.size() > 1) |
| 8187 |
+ messageLabel = "explicitly with messages"_sr; |
| 8188 |
break; |
| 8189 |
// These cases are here to prevent compiler warnings |
| 8190 |
case ResultWas::Unknown: |
| 8191 |
@@ -8106,9 +8429,8 @@ private: |
| 8192 |
AssertionResult const& result; |
| 8193 |
Colour::Code colour; |
| 8194 |
StringRef passOrFail; |
| 8195 |
- std::string messageLabel; |
| 8196 |
- std::string message; |
| 8197 |
- std::vector<MessageInfo> messages; |
| 8198 |
+ StringRef messageLabel; |
| 8199 |
+ std::vector<MessageInfo> const& messages; |
| 8200 |
ColourImpl* colourImpl; |
| 8201 |
bool printInfoMessages; |
| 8202 |
}; |
| 8203 |
@@ -8118,13 +8440,16 @@ std::size_t makeRatio( std::uint64_t number, std::uint64_t total ) { |
| 8204 |
return (ratio == 0 && number > 0) ? 1 : static_cast<std::size_t>(ratio); |
| 8205 |
} |
| 8206 |
|
| 8207 |
-std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { |
| 8208 |
- if (i > j && i > k) |
| 8209 |
+std::size_t& |
| 8210 |
+findMax( std::size_t& i, std::size_t& j, std::size_t& k, std::size_t& l ) { |
| 8211 |
+ if (i > j && i > k && i > l) |
| 8212 |
return i; |
| 8213 |
- else if (j > k) |
| 8214 |
+ else if (j > k && j > l) |
| 8215 |
return j; |
| 8216 |
- else |
| 8217 |
+ else if (k > l) |
| 8218 |
return k; |
| 8219 |
+ else |
| 8220 |
+ return l; |
| 8221 |
} |
| 8222 |
|
| 8223 |
enum class Justification { Left, Right }; |
| 8224 |
@@ -8333,7 +8658,8 @@ void ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) { |
| 8225 |
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); |
| 8226 |
|
| 8227 |
// Drop out if result was successful but we're not printing them. |
| 8228 |
- if (!includeResults && result.getResultType() != ResultWas::Warning) |
| 8229 |
+ // TODO: Make configurable whether skips should be printed |
| 8230 |
+ if (!includeResults && result.getResultType() != ResultWas::Warning && result.getResultType() != ResultWas::ExplicitSkip) |
| 8231 |
return; |
| 8232 |
|
| 8233 |
lazyPrint(); |
| 8234 |
@@ -8424,7 +8750,7 @@ void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { |
| 8235 |
} |
| 8236 |
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { |
| 8237 |
printTotalsDivider(_testRunStats.totals); |
| 8238 |
- printTotals(_testRunStats.totals); |
| 8239 |
+ printTestRunTotals( m_stream, *m_colour, _testRunStats.totals ); |
| 8240 |
m_stream << '\n' << std::flush; |
| 8241 |
StreamingReporterBase::testRunEnded(_testRunStats); |
| 8242 |
} |
| 8243 |
@@ -8432,7 +8758,7 @@ void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) { |
| 8244 |
StreamingReporterBase::testRunStarting(_testInfo); |
| 8245 |
if ( m_config->testSpec().hasFilters() ) { |
| 8246 |
m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: " |
| 8247 |
- << serializeFilters( m_config->getTestsOrTags() ) << '\n'; |
| 8248 |
+ << m_config->testSpec() << '\n'; |
| 8249 |
} |
| 8250 |
m_stream << "Randomness seeded to: " << getSeed() << '\n'; |
| 8251 |
} |
| 8252 |
@@ -8531,91 +8857,16 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t |
| 8253 |
<< '\n'; |
| 8254 |
} |
| 8255 |
|
| 8256 |
-struct SummaryColumn { |
| 8257 |
- |
| 8258 |
- SummaryColumn( std::string _label, Colour::Code _colour ) |
| 8259 |
- : label( CATCH_MOVE( _label ) ), |
| 8260 |
- colour( _colour ) {} |
| 8261 |
- SummaryColumn addRow( std::uint64_t count ) { |
| 8262 |
- ReusableStringStream rss; |
| 8263 |
- rss << count; |
| 8264 |
- std::string row = rss.str(); |
| 8265 |
- for (auto& oldRow : rows) { |
| 8266 |
- while (oldRow.size() < row.size()) |
| 8267 |
- oldRow = ' ' + oldRow; |
| 8268 |
- while (oldRow.size() > row.size()) |
| 8269 |
- row = ' ' + row; |
| 8270 |
- } |
| 8271 |
- rows.push_back(row); |
| 8272 |
- return *this; |
| 8273 |
- } |
| 8274 |
- |
| 8275 |
- std::string label; |
| 8276 |
- Colour::Code colour; |
| 8277 |
- std::vector<std::string> rows; |
| 8278 |
- |
| 8279 |
-}; |
| 8280 |
- |
| 8281 |
-void ConsoleReporter::printTotals( Totals const& totals ) { |
| 8282 |
- if (totals.testCases.total() == 0) { |
| 8283 |
- m_stream << m_colour->guardColour( Colour::Warning ) |
| 8284 |
- << "No tests ran\n"; |
| 8285 |
- } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { |
| 8286 |
- m_stream << m_colour->guardColour( Colour::ResultSuccess ) |
| 8287 |
- << "All tests passed"; |
| 8288 |
- m_stream << " (" |
| 8289 |
- << pluralise(totals.assertions.passed, "assertion"_sr) << " in " |
| 8290 |
- << pluralise(totals.testCases.passed, "test case"_sr) << ')' |
| 8291 |
- << '\n'; |
| 8292 |
- } else { |
| 8293 |
- |
| 8294 |
- std::vector<SummaryColumn> columns; |
| 8295 |
- columns.push_back(SummaryColumn("", Colour::None) |
| 8296 |
- .addRow(totals.testCases.total()) |
| 8297 |
- .addRow(totals.assertions.total())); |
| 8298 |
- columns.push_back(SummaryColumn("passed", Colour::Success) |
| 8299 |
- .addRow(totals.testCases.passed) |
| 8300 |
- .addRow(totals.assertions.passed)); |
| 8301 |
- columns.push_back(SummaryColumn("failed", Colour::ResultError) |
| 8302 |
- .addRow(totals.testCases.failed) |
| 8303 |
- .addRow(totals.assertions.failed)); |
| 8304 |
- columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure) |
| 8305 |
- .addRow(totals.testCases.failedButOk) |
| 8306 |
- .addRow(totals.assertions.failedButOk)); |
| 8307 |
- |
| 8308 |
- printSummaryRow("test cases"_sr, columns, 0); |
| 8309 |
- printSummaryRow("assertions"_sr, columns, 1); |
| 8310 |
- } |
| 8311 |
-} |
| 8312 |
-void ConsoleReporter::printSummaryRow(StringRef label, std::vector<SummaryColumn> const& cols, std::size_t row) { |
| 8313 |
- for (auto col : cols) { |
| 8314 |
- std::string const& value = col.rows[row]; |
| 8315 |
- if (col.label.empty()) { |
| 8316 |
- m_stream << label << ": "; |
| 8317 |
- if ( value != "0" ) { |
| 8318 |
- m_stream << value; |
| 8319 |
- } else { |
| 8320 |
- m_stream << m_colour->guardColour( Colour::Warning ) |
| 8321 |
- << "- none -"; |
| 8322 |
- } |
| 8323 |
- } else if (value != "0") { |
| 8324 |
- m_stream << m_colour->guardColour( Colour::LightGrey ) << " | " |
| 8325 |
- << m_colour->guardColour( col.colour ) << value << ' ' |
| 8326 |
- << col.label; |
| 8327 |
- } |
| 8328 |
- } |
| 8329 |
- m_stream << '\n'; |
| 8330 |
-} |
| 8331 |
- |
| 8332 |
void ConsoleReporter::printTotalsDivider(Totals const& totals) { |
| 8333 |
if (totals.testCases.total() > 0) { |
| 8334 |
std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total()); |
| 8335 |
std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total()); |
| 8336 |
std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total()); |
| 8337 |
- while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1) |
| 8338 |
- findMax(failedRatio, failedButOkRatio, passedRatio)++; |
| 8339 |
+ std::size_t skippedRatio = makeRatio(totals.testCases.skipped, totals.testCases.total()); |
| 8340 |
+ while (failedRatio + failedButOkRatio + passedRatio + skippedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1) |
| 8341 |
+ findMax(failedRatio, failedButOkRatio, passedRatio, skippedRatio)++; |
| 8342 |
while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1) |
| 8343 |
- findMax(failedRatio, failedButOkRatio, passedRatio)--; |
| 8344 |
+ findMax(failedRatio, failedButOkRatio, passedRatio, skippedRatio)--; |
| 8345 |
|
| 8346 |
m_stream << m_colour->guardColour( Colour::Error ) |
| 8347 |
<< std::string( failedRatio, '=' ) |
| 8348 |
@@ -8628,15 +8879,14 @@ void ConsoleReporter::printTotalsDivider(Totals const& totals) { |
| 8349 |
m_stream << m_colour->guardColour( Colour::Success ) |
| 8350 |
<< std::string( passedRatio, '=' ); |
| 8351 |
} |
| 8352 |
+ m_stream << m_colour->guardColour( Colour::Skip ) |
| 8353 |
+ << std::string( skippedRatio, '=' ); |
| 8354 |
} else { |
| 8355 |
m_stream << m_colour->guardColour( Colour::Warning ) |
| 8356 |
<< std::string( CATCH_CONFIG_CONSOLE_WIDTH - 1, '=' ); |
| 8357 |
} |
| 8358 |
m_stream << '\n'; |
| 8359 |
} |
| 8360 |
-void ConsoleReporter::printSummaryDivider() { |
| 8361 |
- m_stream << lineOfChars('-') << '\n'; |
| 8362 |
-} |
| 8363 |
|
| 8364 |
} // end namespace Catch |
| 8365 |
|
| 8366 |
@@ -8712,7 +8962,8 @@ namespace Catch { |
| 8367 |
|
| 8368 |
void |
| 8369 |
CumulativeReporterBase::sectionStarting( SectionInfo const& sectionInfo ) { |
| 8370 |
- SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); |
| 8371 |
+ // We need a copy, because SectionStats expect to take ownership |
| 8372 |
+ SectionStats incompleteStats( SectionInfo(sectionInfo), Counts(), 0, false ); |
| 8373 |
SectionNode* node; |
| 8374 |
if ( m_sectionStack.empty() ) { |
| 8375 |
if ( !m_rootSection ) { |
| 8376 |
@@ -9054,6 +9305,111 @@ namespace Catch { |
| 8377 |
out << "\n\n" << std::flush; |
| 8378 |
} |
| 8379 |
|
| 8380 |
+ namespace { |
| 8381 |
+ class SummaryColumn { |
| 8382 |
+ public: |
| 8383 |
+ SummaryColumn( std::string suffix, Colour::Code colour ): |
| 8384 |
+ m_suffix( CATCH_MOVE( suffix ) ), m_colour( colour ) {} |
| 8385 |
+ |
| 8386 |
+ SummaryColumn&& addRow( std::uint64_t count ) && { |
| 8387 |
+ std::string row = std::to_string(count); |
| 8388 |
+ auto const new_width = std::max( m_width, row.size() ); |
| 8389 |
+ if ( new_width > m_width ) { |
| 8390 |
+ for ( auto& oldRow : m_rows ) { |
| 8391 |
+ oldRow.insert( 0, new_width - m_width, ' ' ); |
| 8392 |
+ } |
| 8393 |
+ } else { |
| 8394 |
+ row.insert( 0, m_width - row.size(), ' ' ); |
| 8395 |
+ } |
| 8396 |
+ m_width = new_width; |
| 8397 |
+ m_rows.push_back( row ); |
| 8398 |
+ return std::move( *this ); |
| 8399 |
+ } |
| 8400 |
+ |
| 8401 |
+ std::string const& getSuffix() const { return m_suffix; } |
| 8402 |
+ Colour::Code getColour() const { return m_colour; } |
| 8403 |
+ std::string const& getRow( std::size_t index ) const { |
| 8404 |
+ return m_rows[index]; |
| 8405 |
+ } |
| 8406 |
+ |
| 8407 |
+ private: |
| 8408 |
+ std::string m_suffix; |
| 8409 |
+ Colour::Code m_colour; |
| 8410 |
+ std::size_t m_width = 0; |
| 8411 |
+ std::vector<std::string> m_rows; |
| 8412 |
+ }; |
| 8413 |
+ |
| 8414 |
+ void printSummaryRow( std::ostream& stream, |
| 8415 |
+ ColourImpl& colour, |
| 8416 |
+ StringRef label, |
| 8417 |
+ std::vector<SummaryColumn> const& cols, |
| 8418 |
+ std::size_t row ) { |
| 8419 |
+ for ( auto const& col : cols ) { |
| 8420 |
+ auto const& value = col.getRow( row ); |
| 8421 |
+ auto const& suffix = col.getSuffix(); |
| 8422 |
+ if ( suffix.empty() ) { |
| 8423 |
+ stream << label << ": "; |
| 8424 |
+ if ( value != "0" ) { |
| 8425 |
+ stream << value; |
| 8426 |
+ } else { |
| 8427 |
+ stream << colour.guardColour( Colour::Warning ) |
| 8428 |
+ << "- none -"; |
| 8429 |
+ } |
| 8430 |
+ } else if ( value != "0" ) { |
| 8431 |
+ stream << colour.guardColour( Colour::LightGrey ) << " | " |
| 8432 |
+ << colour.guardColour( col.getColour() ) << value |
| 8433 |
+ << ' ' << suffix; |
| 8434 |
+ } |
| 8435 |
+ } |
| 8436 |
+ stream << '\n'; |
| 8437 |
+ } |
| 8438 |
+ } // namespace |
| 8439 |
+ |
| 8440 |
+ void printTestRunTotals( std::ostream& stream, |
| 8441 |
+ ColourImpl& streamColour, |
| 8442 |
+ Totals const& totals ) { |
| 8443 |
+ if ( totals.testCases.total() == 0 ) { |
| 8444 |
+ stream << streamColour.guardColour( Colour::Warning ) |
| 8445 |
+ << "No tests ran\n"; |
| 8446 |
+ return; |
| 8447 |
+ } |
| 8448 |
+ |
| 8449 |
+ if ( totals.assertions.total() > 0 && totals.testCases.allPassed() ) { |
| 8450 |
+ stream << streamColour.guardColour( Colour::ResultSuccess ) |
| 8451 |
+ << "All tests passed"; |
| 8452 |
+ stream << " (" |
| 8453 |
+ << pluralise( totals.assertions.passed, "assertion"_sr ) |
| 8454 |
+ << " in " |
| 8455 |
+ << pluralise( totals.testCases.passed, "test case"_sr ) |
| 8456 |
+ << ')' << '\n'; |
| 8457 |
+ return; |
| 8458 |
+ } |
| 8459 |
+ |
| 8460 |
+ std::vector<SummaryColumn> columns; |
| 8461 |
+ // Don't include "skipped assertions" in total count |
| 8462 |
+ const auto totalAssertionCount = |
| 8463 |
+ totals.assertions.total() - totals.assertions.skipped; |
| 8464 |
+ columns.push_back( SummaryColumn( "", Colour::None ) |
| 8465 |
+ .addRow( totals.testCases.total() ) |
| 8466 |
+ .addRow( totalAssertionCount ) ); |
| 8467 |
+ columns.push_back( SummaryColumn( "passed", Colour::Success ) |
| 8468 |
+ .addRow( totals.testCases.passed ) |
| 8469 |
+ .addRow( totals.assertions.passed ) ); |
| 8470 |
+ columns.push_back( SummaryColumn( "failed", Colour::ResultError ) |
| 8471 |
+ .addRow( totals.testCases.failed ) |
| 8472 |
+ .addRow( totals.assertions.failed ) ); |
| 8473 |
+ columns.push_back( SummaryColumn( "skipped", Colour::Skip ) |
| 8474 |
+ .addRow( totals.testCases.skipped ) |
| 8475 |
+ // Don't print "skipped assertions" |
| 8476 |
+ .addRow( 0 ) ); |
| 8477 |
+ columns.push_back( |
| 8478 |
+ SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) |
| 8479 |
+ .addRow( totals.testCases.failedButOk ) |
| 8480 |
+ .addRow( totals.assertions.failedButOk ) ); |
| 8481 |
+ printSummaryRow( stream, streamColour, "test cases"_sr, columns, 0 ); |
| 8482 |
+ printSummaryRow( stream, streamColour, "assertions"_sr, columns, 1 ); |
| 8483 |
+ } |
| 8484 |
+ |
| 8485 |
} // namespace Catch |
| 8486 |
|
| 8487 |
|
| 8488 |
@@ -9074,6 +9430,10 @@ namespace Catch { |
| 8489 |
std::tm timeInfo = {}; |
| 8490 |
#if defined (_MSC_VER) || defined (__MINGW32__) |
| 8491 |
gmtime_s(&timeInfo, &rawtime); |
| 8492 |
+#elif defined (CATCH_PLATFORM_PLAYSTATION) |
| 8493 |
+ gmtime_s(&rawtime, &timeInfo); |
| 8494 |
+#elif defined (__IAR_SYSTEMS_ICC__) |
| 8495 |
+ timeInfo = *std::gmtime(&rawtime); |
| 8496 |
#else |
| 8497 |
gmtime_r(&rawtime, &timeInfo); |
| 8498 |
#endif |
| 8499 |
@@ -9173,6 +9533,7 @@ namespace Catch { |
| 8500 |
xml.writeAttribute( "name"_sr, stats.runInfo.name ); |
| 8501 |
xml.writeAttribute( "errors"_sr, unexpectedExceptions ); |
| 8502 |
xml.writeAttribute( "failures"_sr, stats.totals.assertions.failed-unexpectedExceptions ); |
| 8503 |
+ xml.writeAttribute( "skipped"_sr, stats.totals.assertions.skipped ); |
| 8504 |
xml.writeAttribute( "tests"_sr, stats.totals.assertions.total() ); |
| 8505 |
xml.writeAttribute( "hostname"_sr, "tbd"_sr ); // !TBD |
| 8506 |
if( m_config->showDurations() == ShowDurations::Never ) |
| 8507 |
@@ -9187,10 +9548,10 @@ namespace Catch { |
| 8508 |
xml.scopedElement("property") |
| 8509 |
.writeAttribute("name"_sr, "random-seed"_sr) |
| 8510 |
.writeAttribute("value"_sr, m_config->rngSeed()); |
| 8511 |
- if (m_config->hasTestFilters()) { |
| 8512 |
+ if (m_config->testSpec().hasFilters()) { |
| 8513 |
xml.scopedElement("property") |
| 8514 |
.writeAttribute("name"_sr, "filters"_sr) |
| 8515 |
- .writeAttribute("value"_sr, serializeFilters(m_config->getTestsOrTags())); |
| 8516 |
+ .writeAttribute("value"_sr, m_config->testSpec()); |
| 8517 |
} |
| 8518 |
} |
| 8519 |
|
| 8520 |
@@ -9285,7 +9646,8 @@ namespace Catch { |
| 8521 |
|
| 8522 |
void JunitReporter::writeAssertion( AssertionStats const& stats ) { |
| 8523 |
AssertionResult const& result = stats.assertionResult; |
| 8524 |
- if( !result.isOk() ) { |
| 8525 |
+ if ( !result.isOk() || |
| 8526 |
+ result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8527 |
std::string elementName; |
| 8528 |
switch( result.getResultType() ) { |
| 8529 |
case ResultWas::ThrewException: |
| 8530 |
@@ -9297,7 +9659,9 @@ namespace Catch { |
| 8531 |
case ResultWas::DidntThrowException: |
| 8532 |
elementName = "failure"; |
| 8533 |
break; |
| 8534 |
- |
| 8535 |
+ case ResultWas::ExplicitSkip: |
| 8536 |
+ elementName = "skipped"; |
| 8537 |
+ break; |
| 8538 |
// We should never see these here: |
| 8539 |
case ResultWas::Info: |
| 8540 |
case ResultWas::Warning: |
| 8541 |
@@ -9315,7 +9679,9 @@ namespace Catch { |
| 8542 |
xml.writeAttribute( "type"_sr, result.getTestMacroName() ); |
| 8543 |
|
| 8544 |
ReusableStringStream rss; |
| 8545 |
- if (stats.totals.assertions.total() > 0) { |
| 8546 |
+ if ( result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8547 |
+ rss << "SKIPPED\n"; |
| 8548 |
+ } else { |
| 8549 |
rss << "FAILED" << ":\n"; |
| 8550 |
if (result.hasExpression()) { |
| 8551 |
rss << " "; |
| 8552 |
@@ -9326,11 +9692,9 @@ namespace Catch { |
| 8553 |
rss << "with expansion:\n"; |
| 8554 |
rss << TextFlow::Column(result.getExpandedExpression()).indent(2) << '\n'; |
| 8555 |
} |
| 8556 |
- } else { |
| 8557 |
- rss << '\n'; |
| 8558 |
} |
| 8559 |
|
| 8560 |
- if( !result.getMessage().empty() ) |
| 8561 |
+ if( result.hasMessage() ) |
| 8562 |
rss << result.getMessage() << '\n'; |
| 8563 |
for( auto const& msg : stats.infoMessages ) |
| 8564 |
if( msg.type == ResultWas::Info ) |
| 8565 |
@@ -9449,7 +9813,6 @@ namespace Catch { |
| 8566 |
} |
| 8567 |
} |
| 8568 |
|
| 8569 |
- // The return value indicates if the messages buffer should be cleared: |
| 8570 |
void MultiReporter::assertionEnded( AssertionStats const& assertionStats ) { |
| 8571 |
const bool reportByDefault = |
| 8572 |
assertionStats.assertionResult.getResultType() != ResultWas::Ok || |
| 8573 |
@@ -9552,6 +9915,11 @@ namespace Catch { |
| 8574 |
} |
| 8575 |
} |
| 8576 |
|
| 8577 |
+ void registerListenerImpl( Detail::unique_ptr<EventListenerFactory> listenerFactory ) { |
| 8578 |
+ getMutableRegistryHub().registerListener( CATCH_MOVE(listenerFactory) ); |
| 8579 |
+ } |
| 8580 |
+ |
| 8581 |
+ |
| 8582 |
} // namespace Detail |
| 8583 |
} // namespace Catch |
| 8584 |
|
| 8585 |
@@ -9563,9 +9931,14 @@ namespace Catch { |
| 8586 |
namespace Catch { |
| 8587 |
|
| 8588 |
namespace { |
| 8589 |
- std::string createRngSeedString(uint32_t seed) { |
| 8590 |
+ std::string createMetadataString(IConfig const& config) { |
| 8591 |
ReusableStringStream sstr; |
| 8592 |
- sstr << "rng-seed=" << seed; |
| 8593 |
+ if ( config.testSpec().hasFilters() ) { |
| 8594 |
+ sstr << "filters='" |
| 8595 |
+ << config.testSpec() |
| 8596 |
+ << "' "; |
| 8597 |
+ } |
| 8598 |
+ sstr << "rng-seed=" << config.rngSeed(); |
| 8599 |
return sstr.str(); |
| 8600 |
} |
| 8601 |
} |
| 8602 |
@@ -9573,13 +9946,13 @@ namespace Catch { |
| 8603 |
void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) { |
| 8604 |
CumulativeReporterBase::testRunStarting(testRunInfo); |
| 8605 |
|
| 8606 |
- xml.writeComment( createRngSeedString( m_config->rngSeed() ) ); |
| 8607 |
+ xml.writeComment( createMetadataString( *m_config ) ); |
| 8608 |
xml.startElement("testExecutions"); |
| 8609 |
xml.writeAttribute("version"_sr, '1'); |
| 8610 |
} |
| 8611 |
|
| 8612 |
void SonarQubeReporter::writeRun( TestRunNode const& runNode ) { |
| 8613 |
- std::map<std::string, std::vector<TestCaseNode const*>> testsPerFile; |
| 8614 |
+ std::map<StringRef, std::vector<TestCaseNode const*>> testsPerFile; |
| 8615 |
|
| 8616 |
for ( auto const& child : runNode.children ) { |
| 8617 |
testsPerFile[child->value.testInfo->lineInfo.file].push_back( |
| 8618 |
@@ -9591,7 +9964,7 @@ namespace Catch { |
| 8619 |
} |
| 8620 |
} |
| 8621 |
|
| 8622 |
- void SonarQubeReporter::writeTestFile(std::string const& filename, std::vector<TestCaseNode const*> const& testCaseNodes) { |
| 8623 |
+ void SonarQubeReporter::writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes) { |
| 8624 |
XmlWriter::ScopedElement e = xml.scopedElement("file"); |
| 8625 |
xml.writeAttribute("path"_sr, filename); |
| 8626 |
|
| 8627 |
@@ -9636,7 +10009,8 @@ namespace Catch { |
| 8628 |
|
| 8629 |
void SonarQubeReporter::writeAssertion(AssertionStats const& stats, bool okToFail) { |
| 8630 |
AssertionResult const& result = stats.assertionResult; |
| 8631 |
- if (!result.isOk()) { |
| 8632 |
+ if ( !result.isOk() || |
| 8633 |
+ result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8634 |
std::string elementName; |
| 8635 |
if (okToFail) { |
| 8636 |
elementName = "skipped"; |
| 8637 |
@@ -9647,15 +10021,13 @@ namespace Catch { |
| 8638 |
elementName = "error"; |
| 8639 |
break; |
| 8640 |
case ResultWas::ExplicitFailure: |
| 8641 |
- elementName = "failure"; |
| 8642 |
- break; |
| 8643 |
case ResultWas::ExpressionFailed: |
| 8644 |
- elementName = "failure"; |
| 8645 |
- break; |
| 8646 |
case ResultWas::DidntThrowException: |
| 8647 |
elementName = "failure"; |
| 8648 |
break; |
| 8649 |
- |
| 8650 |
+ case ResultWas::ExplicitSkip: |
| 8651 |
+ elementName = "skipped"; |
| 8652 |
+ break; |
| 8653 |
// We should never see these here: |
| 8654 |
case ResultWas::Info: |
| 8655 |
case ResultWas::Warning: |
| 8656 |
@@ -9675,7 +10047,9 @@ namespace Catch { |
| 8657 |
xml.writeAttribute("message"_sr, messageRss.str()); |
| 8658 |
|
| 8659 |
ReusableStringStream textRss; |
| 8660 |
- if (stats.totals.assertions.total() > 0) { |
| 8661 |
+ if ( result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8662 |
+ textRss << "SKIPPED\n"; |
| 8663 |
+ } else { |
| 8664 |
textRss << "FAILED:\n"; |
| 8665 |
if (result.hasExpression()) { |
| 8666 |
textRss << '\t' << result.getExpressionInMacro() << '\n'; |
| 8667 |
@@ -9685,7 +10059,7 @@ namespace Catch { |
| 8668 |
} |
| 8669 |
} |
| 8670 |
|
| 8671 |
- if (!result.getMessage().empty()) |
| 8672 |
+ if (result.hasMessage()) |
| 8673 |
textRss << result.getMessage() << '\n'; |
| 8674 |
|
| 8675 |
for (auto const& msg : stats.infoMessages) |
| 8676 |
@@ -9719,7 +10093,6 @@ namespace Catch { |
| 8677 |
|
| 8678 |
|
| 8679 |
#include <algorithm> |
| 8680 |
-#include <iterator> |
| 8681 |
#include <ostream> |
| 8682 |
|
| 8683 |
namespace Catch { |
| 8684 |
@@ -9805,6 +10178,12 @@ namespace Catch { |
| 8685 |
printIssue("explicitly"_sr); |
| 8686 |
printRemainingMessages(Colour::None); |
| 8687 |
break; |
| 8688 |
+ case ResultWas::ExplicitSkip: |
| 8689 |
+ printResultType(tapPassedString); |
| 8690 |
+ printIssue(" # SKIP"_sr); |
| 8691 |
+ printMessage(); |
| 8692 |
+ printRemainingMessages(); |
| 8693 |
+ break; |
| 8694 |
// These cases are here to prevent compiler warnings |
| 8695 |
case ResultWas::Unknown: |
| 8696 |
case ResultWas::FailureBit: |
| 8697 |
@@ -9864,7 +10243,7 @@ namespace Catch { |
| 8698 |
|
| 8699 |
// using messages.end() directly (or auto) yields compilation error: |
| 8700 |
std::vector<MessageInfo>::const_iterator itEnd = messages.end(); |
| 8701 |
- const std::size_t N = static_cast<std::size_t>(std::distance(itMessage, itEnd)); |
| 8702 |
+ const std::size_t N = static_cast<std::size_t>(itEnd - itMessage); |
| 8703 |
|
| 8704 |
stream << colourImpl->guardColour( colour ) << " with " |
| 8705 |
<< pluralise( N, "message"_sr ) << ':'; |
| 8706 |
@@ -9883,7 +10262,7 @@ namespace Catch { |
| 8707 |
private: |
| 8708 |
std::ostream& stream; |
| 8709 |
AssertionResult const& result; |
| 8710 |
- std::vector<MessageInfo> messages; |
| 8711 |
+ std::vector<MessageInfo> const& messages; |
| 8712 |
std::vector<MessageInfo>::const_iterator itMessage; |
| 8713 |
bool printInfoMessages; |
| 8714 |
std::size_t counter; |
| 8715 |
@@ -9893,6 +10272,9 @@ namespace Catch { |
| 8716 |
} // End anonymous namespace |
| 8717 |
|
| 8718 |
void TAPReporter::testRunStarting( TestRunInfo const& ) { |
| 8719 |
+ if ( m_config->testSpec().hasFilters() ) { |
| 8720 |
+ m_stream << "# filters: " << m_config->testSpec() << '\n'; |
| 8721 |
+ } |
| 8722 |
m_stream << "# rng-seed: " << m_config->rngSeed() << '\n'; |
| 8723 |
} |
| 8724 |
|
| 8725 |
@@ -9973,7 +10355,8 @@ namespace Catch { |
| 8726 |
|
| 8727 |
void TeamCityReporter::assertionEnded(AssertionStats const& assertionStats) { |
| 8728 |
AssertionResult const& result = assertionStats.assertionResult; |
| 8729 |
- if (!result.isOk()) { |
| 8730 |
+ if ( !result.isOk() || |
| 8731 |
+ result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8732 |
|
| 8733 |
ReusableStringStream msg; |
| 8734 |
if (!m_headerPrintedForThisSection) |
| 8735 |
@@ -9998,6 +10381,9 @@ namespace Catch { |
| 8736 |
case ResultWas::ExplicitFailure: |
| 8737 |
msg << "explicit failure"; |
| 8738 |
break; |
| 8739 |
+ case ResultWas::ExplicitSkip: |
| 8740 |
+ msg << "explicit skip"; |
| 8741 |
+ break; |
| 8742 |
|
| 8743 |
// We shouldn't get here because of the isOk() test |
| 8744 |
case ResultWas::Ok: |
| 8745 |
@@ -10025,18 +10411,16 @@ namespace Catch { |
| 8746 |
" " << result.getExpandedExpression() << '\n'; |
| 8747 |
} |
| 8748 |
|
| 8749 |
- if (currentTestCaseInfo->okToFail()) { |
| 8750 |
+ if ( result.getResultType() == ResultWas::ExplicitSkip ) { |
| 8751 |
+ m_stream << "##teamcity[testIgnored"; |
| 8752 |
+ } else if ( currentTestCaseInfo->okToFail() ) { |
| 8753 |
msg << "- failure ignore as test marked as 'ok to fail'\n"; |
| 8754 |
- m_stream << "##teamcity[testIgnored" |
| 8755 |
- << " name='" << escape(currentTestCaseInfo->name) << '\'' |
| 8756 |
- << " message='" << escape(msg.str()) << '\'' |
| 8757 |
- << "]\n"; |
| 8758 |
+ m_stream << "##teamcity[testIgnored"; |
| 8759 |
} else { |
| 8760 |
- m_stream << "##teamcity[testFailed" |
| 8761 |
- << " name='" << escape(currentTestCaseInfo->name) << '\'' |
| 8762 |
- << " message='" << escape(msg.str()) << '\'' |
| 8763 |
- << "]\n"; |
| 8764 |
+ m_stream << "##teamcity[testFailed"; |
| 8765 |
} |
| 8766 |
+ m_stream << " name='" << escape( currentTestCaseInfo->name ) << '\'' |
| 8767 |
+ << " message='" << escape( msg.str() ) << '\'' << "]\n"; |
| 8768 |
} |
| 8769 |
m_stream.flush(); |
| 8770 |
} |
| 8771 |
@@ -10131,15 +10515,17 @@ namespace Catch { |
| 8772 |
m_xml.startElement("Catch2TestRun") |
| 8773 |
.writeAttribute("name"_sr, m_config->name()) |
| 8774 |
.writeAttribute("rng-seed"_sr, m_config->rngSeed()) |
| 8775 |
+ .writeAttribute("xml-format-version"_sr, 3) |
| 8776 |
.writeAttribute("catch2-version"_sr, libraryVersion()); |
| 8777 |
- if (m_config->testSpec().hasFilters()) |
| 8778 |
- m_xml.writeAttribute( "filters"_sr, serializeFilters( m_config->getTestsOrTags() ) ); |
| 8779 |
+ if ( m_config->testSpec().hasFilters() ) { |
| 8780 |
+ m_xml.writeAttribute( "filters"_sr, m_config->testSpec() ); |
| 8781 |
+ } |
| 8782 |
} |
| 8783 |
|
| 8784 |
void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { |
| 8785 |
StreamingReporterBase::testCaseStarting(testInfo); |
| 8786 |
m_xml.startElement( "TestCase" ) |
| 8787 |
- .writeAttribute( "name"_sr, trim( testInfo.name ) ) |
| 8788 |
+ .writeAttribute( "name"_sr, trim( StringRef(testInfo.name) ) ) |
| 8789 |
.writeAttribute( "tags"_sr, testInfo.tagsAsString() ); |
| 8790 |
|
| 8791 |
writeSourceInfo( testInfo.lineInfo ); |
| 8792 |
@@ -10153,7 +10539,7 @@ namespace Catch { |
| 8793 |
StreamingReporterBase::sectionStarting( sectionInfo ); |
| 8794 |
if( m_sectionDepth++ > 0 ) { |
| 8795 |
m_xml.startElement( "Section" ) |
| 8796 |
- .writeAttribute( "name"_sr, trim( sectionInfo.name ) ); |
| 8797 |
+ .writeAttribute( "name"_sr, trim( StringRef(sectionInfo.name) ) ); |
| 8798 |
writeSourceInfo( sectionInfo.lineInfo ); |
| 8799 |
m_xml.ensureTagClosed(); |
| 8800 |
} |
| 8801 |
@@ -10171,19 +10557,22 @@ namespace Catch { |
| 8802 |
// Print any info messages in <Info> tags. |
| 8803 |
for( auto const& msg : assertionStats.infoMessages ) { |
| 8804 |
if( msg.type == ResultWas::Info && includeResults ) { |
| 8805 |
- m_xml.scopedElement( "Info" ) |
| 8806 |
- .writeText( msg.message ); |
| 8807 |
+ auto t = m_xml.scopedElement( "Info" ); |
| 8808 |
+ writeSourceInfo( msg.lineInfo ); |
| 8809 |
+ t.writeText( msg.message ); |
| 8810 |
} else if ( msg.type == ResultWas::Warning ) { |
| 8811 |
- m_xml.scopedElement( "Warning" ) |
| 8812 |
- .writeText( msg.message ); |
| 8813 |
+ auto t = m_xml.scopedElement( "Warning" ); |
| 8814 |
+ writeSourceInfo( msg.lineInfo ); |
| 8815 |
+ t.writeText( msg.message ); |
| 8816 |
} |
| 8817 |
} |
| 8818 |
} |
| 8819 |
|
| 8820 |
// Drop out if result was successful but we're not printing them. |
| 8821 |
- if( !includeResults && result.getResultType() != ResultWas::Warning ) |
| 8822 |
+ if ( !includeResults && result.getResultType() != ResultWas::Warning && |
| 8823 |
+ result.getResultType() != ResultWas::ExplicitSkip ) { |
| 8824 |
return; |
| 8825 |
- |
| 8826 |
+ } |
| 8827 |
|
| 8828 |
// Print the expression if there is one. |
| 8829 |
if( result.hasExpression() ) { |
| 8830 |
@@ -10226,6 +10615,12 @@ namespace Catch { |
| 8831 |
m_xml.writeText( result.getMessage() ); |
| 8832 |
m_xml.endElement(); |
| 8833 |
break; |
| 8834 |
+ case ResultWas::ExplicitSkip: |
| 8835 |
+ m_xml.startElement( "Skip" ); |
| 8836 |
+ writeSourceInfo( result.getSourceInfo() ); |
| 8837 |
+ m_xml.writeText( result.getMessage() ); |
| 8838 |
+ m_xml.endElement(); |
| 8839 |
+ break; |
| 8840 |
default: |
| 8841 |
break; |
| 8842 |
} |
| 8843 |
@@ -10236,15 +10631,18 @@ namespace Catch { |
| 8844 |
|
| 8845 |
void XmlReporter::sectionEnded( SectionStats const& sectionStats ) { |
| 8846 |
StreamingReporterBase::sectionEnded( sectionStats ); |
| 8847 |
- if( --m_sectionDepth > 0 ) { |
| 8848 |
- XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); |
| 8849 |
- e.writeAttribute( "successes"_sr, sectionStats.assertions.passed ); |
| 8850 |
- e.writeAttribute( "failures"_sr, sectionStats.assertions.failed ); |
| 8851 |
- e.writeAttribute( "expectedFailures"_sr, sectionStats.assertions.failedButOk ); |
| 8852 |
- |
| 8853 |
- if ( m_config->showDurations() == ShowDurations::Always ) |
| 8854 |
- e.writeAttribute( "durationInSeconds"_sr, sectionStats.durationInSeconds ); |
| 8855 |
+ if ( --m_sectionDepth > 0 ) { |
| 8856 |
+ { |
| 8857 |
+ XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); |
| 8858 |
+ e.writeAttribute( "successes"_sr, sectionStats.assertions.passed ); |
| 8859 |
+ e.writeAttribute( "failures"_sr, sectionStats.assertions.failed ); |
| 8860 |
+ e.writeAttribute( "expectedFailures"_sr, sectionStats.assertions.failedButOk ); |
| 8861 |
+ e.writeAttribute( "skipped"_sr, sectionStats.assertions.skipped > 0 ); |
| 8862 |
|
| 8863 |
+ if ( m_config->showDurations() == ShowDurations::Always ) |
| 8864 |
+ e.writeAttribute( "durationInSeconds"_sr, sectionStats.durationInSeconds ); |
| 8865 |
+ } |
| 8866 |
+ // Ends assertion tag |
| 8867 |
m_xml.endElement(); |
| 8868 |
} |
| 8869 |
} |
| 8870 |
@@ -10253,14 +10651,14 @@ namespace Catch { |
| 8871 |
StreamingReporterBase::testCaseEnded( testCaseStats ); |
| 8872 |
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); |
| 8873 |
e.writeAttribute( "success"_sr, testCaseStats.totals.assertions.allOk() ); |
| 8874 |
+ e.writeAttribute( "skips"_sr, testCaseStats.totals.assertions.skipped ); |
| 8875 |
|
| 8876 |
if ( m_config->showDurations() == ShowDurations::Always ) |
| 8877 |
e.writeAttribute( "durationInSeconds"_sr, m_testCaseTimer.getElapsedSeconds() ); |
| 8878 |
- |
| 8879 |
if( !testCaseStats.stdOut.empty() ) |
| 8880 |
- m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), XmlFormatting::Newline ); |
| 8881 |
+ m_xml.scopedElement( "StdOut" ).writeText( trim( StringRef(testCaseStats.stdOut) ), XmlFormatting::Newline ); |
| 8882 |
if( !testCaseStats.stdErr.empty() ) |
| 8883 |
- m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), XmlFormatting::Newline ); |
| 8884 |
+ m_xml.scopedElement( "StdErr" ).writeText( trim( StringRef(testCaseStats.stdErr) ), XmlFormatting::Newline ); |
| 8885 |
|
| 8886 |
m_xml.endElement(); |
| 8887 |
} |
| 8888 |
@@ -10270,11 +10668,13 @@ namespace Catch { |
| 8889 |
m_xml.scopedElement( "OverallResults" ) |
| 8890 |
.writeAttribute( "successes"_sr, testRunStats.totals.assertions.passed ) |
| 8891 |
.writeAttribute( "failures"_sr, testRunStats.totals.assertions.failed ) |
| 8892 |
- .writeAttribute( "expectedFailures"_sr, testRunStats.totals.assertions.failedButOk ); |
| 8893 |
+ .writeAttribute( "expectedFailures"_sr, testRunStats.totals.assertions.failedButOk ) |
| 8894 |
+ .writeAttribute( "skips"_sr, testRunStats.totals.assertions.skipped ); |
| 8895 |
m_xml.scopedElement( "OverallResultsCases") |
| 8896 |
.writeAttribute( "successes"_sr, testRunStats.totals.testCases.passed ) |
| 8897 |
.writeAttribute( "failures"_sr, testRunStats.totals.testCases.failed ) |
| 8898 |
- .writeAttribute( "expectedFailures"_sr, testRunStats.totals.testCases.failedButOk ); |
| 8899 |
+ .writeAttribute( "expectedFailures"_sr, testRunStats.totals.testCases.failedButOk ) |
| 8900 |
+ .writeAttribute( "skips"_sr, testRunStats.totals.testCases.skipped ); |
| 8901 |
m_xml.endElement(); |
| 8902 |
} |
| 8903 |
|
| 8904 |
-- |
| 8905 |
2.43.0 |
| 8906 |
|