catch.hpp
Go to the documentation of this file.
1 /*
2  * Catch v2.12.1
3  * Generated: 2020-04-21 19:29:20.964532
4  * ----------------------------------------------------------
5  * This file has been merged from multiple headers. Please don't edit it directly
6  * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
7  *
8  * Distributed under the Boost Software License, Version 1.0. (See accompanying
9  * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10  */
11 #ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
12 #define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
13 // start catch.hpp
14 
15 
16 #define CATCH_VERSION_MAJOR 2
17 #define CATCH_VERSION_MINOR 12
18 #define CATCH_VERSION_PATCH 1
19 
20 #ifdef __clang__
21 # pragma clang system_header
22 #elif defined __GNUC__
23 # pragma GCC system_header
24 #endif
25 
26 // start catch_suppress_warnings.h
27 
28 #ifdef __clang__
29 # ifdef __ICC // icpc defines the __clang__ macro
30 # pragma warning(push)
31 # pragma warning(disable: 161 1682)
32 # else // __ICC
33 # pragma clang diagnostic push
34 # pragma clang diagnostic ignored "-Wpadded"
35 # pragma clang diagnostic ignored "-Wswitch-enum"
36 # pragma clang diagnostic ignored "-Wcovered-switch-default"
37 # endif
38 #elif defined __GNUC__
39  // Because REQUIREs trigger GCC's -Wparentheses, and because still
40  // supported version of g++ have only buggy support for _Pragmas,
41  // Wparentheses have to be suppressed globally.
42 # pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details
43 
44 # pragma GCC diagnostic push
45 # pragma GCC diagnostic ignored "-Wunused-variable"
46 # pragma GCC diagnostic ignored "-Wpadded"
47 #endif
48 // end catch_suppress_warnings.h
49 #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
50 # define CATCH_IMPL
51 # define CATCH_CONFIG_ALL_PARTS
52 #endif
53 
54 // In the impl file, we want to have access to all parts of the headers
55 // Can also be used to sanely support PCHs
56 #if defined(CATCH_CONFIG_ALL_PARTS)
57 # define CATCH_CONFIG_EXTERNAL_INTERFACES
58 # if defined(CATCH_CONFIG_DISABLE_MATCHERS)
59 # undef CATCH_CONFIG_DISABLE_MATCHERS
60 # endif
61 # if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
62 # define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
63 # endif
64 #endif
65 
66 #if !defined(CATCH_CONFIG_IMPL_ONLY)
67 // start catch_platform.h
68 
69 #ifdef __APPLE__
70 # include <TargetConditionals.h>
71 # if TARGET_OS_OSX == 1
72 # define CATCH_PLATFORM_MAC
73 # elif TARGET_OS_IPHONE == 1
74 # define CATCH_PLATFORM_IPHONE
75 # endif
76 
77 #elif defined(linux) || defined(__linux) || defined(__linux__)
78 # define CATCH_PLATFORM_LINUX
79 
80 #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
81 # define CATCH_PLATFORM_WINDOWS
82 #endif
83 
84 // end catch_platform.h
85 
86 #ifdef CATCH_IMPL
87 # ifndef CLARA_CONFIG_MAIN
88 # define CLARA_CONFIG_MAIN_NOT_DEFINED
89 # define CLARA_CONFIG_MAIN
90 # endif
91 #endif
92 
93 // start catch_user_interfaces.h
94 
95 namespace Catch {
96  unsigned int rngSeed();
97 }
98 
99 // end catch_user_interfaces.h
100 // start catch_tag_alias_autoregistrar.h
101 
102 // start catch_common.h
103 
104 // start catch_compiler_capabilities.h
105 
106 // Detect a number of compiler features - by compiler
107 // The following features are defined:
108 //
109 // CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
110 // CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
111 // CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
112 // CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled?
113 // ****************
114 // Note to maintainers: if new toggles are added please document them
115 // in configuration.md, too
116 // ****************
117 
118 // In general each macro has a _NO_<feature name> form
119 // (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature.
120 // Many features, at point of detection, define an _INTERNAL_ macro, so they
121 // can be combined, en-mass, with the _NO_ forms later.
122 
123 #ifdef __cplusplus
124 
125 # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
126 # define CATCH_CPP14_OR_GREATER
127 # endif
128 
129 # if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
130 # define CATCH_CPP17_OR_GREATER
131 # endif
132 
133 #endif
134 
135 #if defined(__cpp_lib_uncaught_exceptions)
136 # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
137 #endif
138 
139 // We have to avoid both ICC and Clang, because they try to mask themselves
140 // as gcc, and we want only GCC in this block
141 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC)
142 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
143 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" )
144 
145 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
146 
147 #endif
148 
149 #if defined(__clang__)
150 
151 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
152 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )
153 
154 // As of this writing, IBM XL's implementation of __builtin_constant_p has a bug
155 // which results in calls to destructors being emitted for each temporary,
156 // without a matching initialization. In practice, this can result in something
157 // like `std::string::~string` being called on an uninitialized value.
158 //
159 // For example, this code will likely segfault under IBM XL:
160 // ```
161 // REQUIRE(std::string("12") + "34" == "1234")
162 // ```
163 //
164 // Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
165 # if !defined(__ibmxl__)
166 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */
167 # endif
168 
169 # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
170  _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
171  _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
172 
173 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
174  _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
175 
176 # define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
177  _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" )
178 
179 # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
180  _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" )
181 
182 # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
183  _Pragma( "clang diagnostic ignored \"-Wunused-template\"" )
184 
185 #endif // __clang__
186 
188 // Assume that non-Windows platforms support posix signals by default
189 #if !defined(CATCH_PLATFORM_WINDOWS)
190  #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
191 #endif
192 
194 // We know some environments not to support full POSIX signals
195 #if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
196  #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
197 #endif
198 
199 #ifdef __OS400__
200 # define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
201 # define CATCH_CONFIG_COLOUR_NONE
202 #endif
203 
205 // Android somehow still does not support std::to_string
206 #if defined(__ANDROID__)
207 # define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
208 # define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
209 #endif
210 
212 // Not all Windows environments support SEH properly
213 #if defined(__MINGW32__)
214 # define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
215 #endif
216 
218 // PS4
219 #if defined(__ORBIS__)
220 # define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
221 #endif
222 
224 // Cygwin
225 #ifdef __CYGWIN__
226 
227 // Required for some versions of Cygwin to declare gettimeofday
228 // see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
229 # define _BSD_SOURCE
230 // some versions of cygwin (most) do not support std::to_string. Use the libstd check.
231 // https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
232 # if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
233  && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
234 
235 # define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
236 
237 # endif
238 #endif // __CYGWIN__
239 
241 // Visual C++
242 #if defined(_MSC_VER)
243 
244 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) )
245 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) )
246 
247 # if _MSC_VER >= 1900 // Visual Studio 2015 or newer
248 # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
249 # endif
250 
251 // Universal Windows platform does not support SEH
252 // Or console colours (or console at all...)
253 # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
254 # define CATCH_CONFIG_COLOUR_NONE
255 # else
256 # define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
257 # endif
258 
259 // MSVC traditional preprocessor needs some workaround for __VA_ARGS__
260 // _MSVC_TRADITIONAL == 0 means new conformant preprocessor
261 // _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor
262 # if !defined(__clang__) // Handle Clang masquerading for msvc
263 # if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
264 # define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
265 # endif // MSVC_TRADITIONAL
266 # endif // __clang__
267 
268 #endif // _MSC_VER
269 
270 #if defined(_REENTRANT) || defined(_MSC_VER)
271 // Enable async processing, as -pthread is specified or no additional linking is required
272 # define CATCH_INTERNAL_CONFIG_USE_ASYNC
273 #endif // _MSC_VER
274 
276 // Check if we are compiled with -fno-exceptions or equivalent
277 #if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)
278 # define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
279 #endif
280 
282 // DJGPP
283 #ifdef __DJGPP__
284 # define CATCH_INTERNAL_CONFIG_NO_WCHAR
285 #endif // __DJGPP__
286 
288 // Embarcadero C++Build
289 #if defined(__BORLANDC__)
290  #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
291 #endif
292 
294 
295 // Use of __COUNTER__ is suppressed during code analysis in
296 // CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
297 // handled by it.
298 // Otherwise all supported compilers support COUNTER macro,
299 // but user still might want to turn it off
300 #if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
301  #define CATCH_INTERNAL_CONFIG_COUNTER
302 #endif
303 
305 
306 // RTX is a special version of Windows that is real time.
307 // This means that it is detected as Windows, but does not provide
308 // the same set of capabilities as real Windows does.
309 #if defined(UNDER_RTSS) || defined(RTX64_BUILD)
310  #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
311  #define CATCH_INTERNAL_CONFIG_NO_ASYNC
312  #define CATCH_CONFIG_COLOUR_NONE
313 #endif
314 
315 #if !defined(_GLIBCXX_USE_C99_MATH_TR1)
316 #define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER
317 #endif
318 
319 // Various stdlib support checks that require __has_include
320 #if defined(__has_include)
321  // Check if string_view is available and usable
322  #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
323  # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
324  #endif
325 
326  // Check if optional is available and usable
327  # if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
328  # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL
329  # endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
330 
331  // Check if byte is available and usable
332  # if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
333  # define CATCH_INTERNAL_CONFIG_CPP17_BYTE
334  # endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
335 
336  // Check if variant is available and usable
337  # if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
338  # if defined(__clang__) && (__clang_major__ < 8)
339  // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
340  // fix should be in clang 8, workaround in libstdc++ 8.2
341  # include <ciso646>
342  # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
343  # define CATCH_CONFIG_NO_CPP17_VARIANT
344  # else
345  # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
346  # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
347  # else
348  # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
349  # endif // defined(__clang__) && (__clang_major__ < 8)
350  # endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
351 #endif // defined(__has_include)
352 
353 #if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
354 # define CATCH_CONFIG_COUNTER
355 #endif
356 #if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
357 # define CATCH_CONFIG_WINDOWS_SEH
358 #endif
359 // This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
360 #if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
361 # define CATCH_CONFIG_POSIX_SIGNALS
362 #endif
363 // This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions.
364 #if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR)
365 # define CATCH_CONFIG_WCHAR
366 #endif
367 
368 #if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
369 # define CATCH_CONFIG_CPP11_TO_STRING
370 #endif
371 
372 #if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL)
373 # define CATCH_CONFIG_CPP17_OPTIONAL
374 #endif
375 
376 #if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
377 # define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
378 #endif
379 
380 #if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
381 # define CATCH_CONFIG_CPP17_STRING_VIEW
382 #endif
383 
384 #if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
385 # define CATCH_CONFIG_CPP17_VARIANT
386 #endif
387 
388 #if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE)
389 # define CATCH_CONFIG_CPP17_BYTE
390 #endif
391 
392 #if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
393 # define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
394 #endif
395 
396 #if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)
397 # define CATCH_CONFIG_NEW_CAPTURE
398 #endif
399 
400 #if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
401 # define CATCH_CONFIG_DISABLE_EXCEPTIONS
402 #endif
403 
404 #if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN)
405 # define CATCH_CONFIG_POLYFILL_ISNAN
406 #endif
407 
408 #if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC)
409 # define CATCH_CONFIG_USE_ASYNC
410 #endif
411 
412 #if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE)
413 # define CATCH_CONFIG_ANDROID_LOGWRITE
414 #endif
415 
416 #if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
417 # define CATCH_CONFIG_GLOBAL_NEXTAFTER
418 #endif
419 
420 // Even if we do not think the compiler has that warning, we still have
421 // to provide a macro that can be used by the code.
422 #if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION)
423 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
424 #endif
425 #if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION)
426 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
427 #endif
428 #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
429 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
430 #endif
431 #if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)
432 # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
433 #endif
434 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS)
435 # define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS
436 #endif
437 #if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS)
438 # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS
439 #endif
440 
441 // The goal of this macro is to avoid evaluation of the arguments, but
442 // still have the compiler warn on problems inside...
443 #if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN)
444 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...)
445 #endif
446 
447 #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10)
448 # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
449 #elif defined(__clang__) && (__clang_major__ < 5)
450 # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
451 #endif
452 
453 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS)
454 # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
455 #endif
456 
457 #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
458 #define CATCH_TRY if ((true))
459 #define CATCH_CATCH_ALL if ((false))
460 #define CATCH_CATCH_ANON(type) if ((false))
461 #else
462 #define CATCH_TRY try
463 #define CATCH_CATCH_ALL catch (...)
464 #define CATCH_CATCH_ANON(type) catch (type)
465 #endif
466 
467 #if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR)
468 #define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
469 #endif
470 
471 // end catch_compiler_capabilities.h
472 #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
473 #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
474 #ifdef CATCH_CONFIG_COUNTER
475 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
476 #else
477 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
478 #endif
479 
480 #include <iosfwd>
481 #include <string>
482 #include <cstdint>
483 
484 // We need a dummy global operator<< so we can bring it into Catch namespace later
486 std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);
487 
488 namespace Catch {
489 
490  struct CaseSensitive { enum Choice {
492  No
493  }; };
494 
495  class NonCopyable {
496  NonCopyable( NonCopyable const& ) = delete;
497  NonCopyable( NonCopyable && ) = delete;
498  NonCopyable& operator = ( NonCopyable const& ) = delete;
499  NonCopyable& operator = ( NonCopyable && ) = delete;
500 
501  protected:
502  NonCopyable();
503  virtual ~NonCopyable();
504  };
505 
506  struct SourceLineInfo {
507 
508  SourceLineInfo() = delete;
509  SourceLineInfo( char const* _file, std::size_t _line ) noexcept
510  : file( _file ),
511  line( _line )
512  {}
513 
514  SourceLineInfo( SourceLineInfo const& other ) = default;
515  SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
516  SourceLineInfo( SourceLineInfo&& ) noexcept = default;
517  SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default;
518 
519  bool empty() const noexcept { return file[0] == '\0'; }
520  bool operator == ( SourceLineInfo const& other ) const noexcept;
521  bool operator < ( SourceLineInfo const& other ) const noexcept;
522 
523  char const* file;
524  std::size_t line;
525  };
526 
527  std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
528 
529  // Bring in operator<< from global namespace into Catch namespace
530  // This is necessary because the overload of operator<< above makes
531  // lookup stop at namespace Catch
532  using ::operator<<;
533 
534  // Use this in variadic streaming macros to allow
535  // >> +StreamEndStop
536  // as well as
537  // >> stuff +StreamEndStop
538  struct StreamEndStop {
539  std::string operator+() const;
540  };
541  template<typename T>
542  T const& operator + ( T const& value, StreamEndStop ) {
543  return value;
544  }
545 }
546 
547 #define CATCH_INTERNAL_LINEINFO \
548  ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
549 
550 // end catch_common.h
551 namespace Catch {
552 
554  RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
555  };
556 
557 } // end namespace Catch
558 
559 #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \
560  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
561  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
562  namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \
563  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
564 
565 // end catch_tag_alias_autoregistrar.h
566 // start catch_test_registry.h
567 
568 // start catch_interfaces_testcase.h
569 
570 #include <vector>
571 
572 namespace Catch {
573 
574  class TestSpec;
575 
576  struct ITestInvoker {
577  virtual void invoke () const = 0;
578  virtual ~ITestInvoker();
579  };
580 
581  class TestCase;
582  struct IConfig;
583 
585  virtual ~ITestCaseRegistry();
586  virtual std::vector<TestCase> const& getAllTests() const = 0;
587  virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
588  };
589 
590  bool isThrowSafe( TestCase const& testCase, IConfig const& config );
591  bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
592  std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
593  std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
594 
595 }
596 
597 // end catch_interfaces_testcase.h
598 // start catch_stringref.h
599 
600 #include <cstddef>
601 #include <string>
602 #include <iosfwd>
603 #include <cassert>
604 
605 namespace Catch {
606 
610  class StringRef {
611  public:
612  using size_type = std::size_t;
613  using const_iterator = const char*;
614 
615  private:
616  static constexpr char const* const s_empty = "";
617 
618  char const* m_start = s_empty;
619  size_type m_size = 0;
620 
621  public: // construction
622  constexpr StringRef() noexcept = default;
623 
624  StringRef( char const* rawChars ) noexcept;
625 
626  constexpr StringRef( char const* rawChars, size_type size ) noexcept
627  : m_start( rawChars ),
628  m_size( size )
629  {}
630 
631  StringRef( std::string const& stdString ) noexcept
632  : m_start( stdString.c_str() ),
633  m_size( stdString.size() )
634  {}
635 
636  explicit operator std::string() const {
637  return std::string(m_start, m_size);
638  }
639 
640  public: // operators
641  auto operator == ( StringRef const& other ) const noexcept -> bool;
642  auto operator != (StringRef const& other) const noexcept -> bool {
643  return !(*this == other);
644  }
645 
646  auto operator[] ( size_type index ) const noexcept -> char {
647  assert(index < m_size);
648  return m_start[index];
649  }
650 
651  public: // named queries
652  constexpr auto empty() const noexcept -> bool {
653  return m_size == 0;
654  }
655  constexpr auto size() const noexcept -> size_type {
656  return m_size;
657  }
658 
659  // Returns the current start pointer. If the StringRef is not
660  // null-terminated, throws std::domain_exception
661  auto c_str() const -> char const*;
662 
663  public: // substrings and searches
664  // Returns a substring of [start, start + length).
665  // If start + length > size(), then the substring is [start, size()).
666  // If start > size(), then the substring is empty.
667  auto substr( size_type start, size_type length ) const noexcept -> StringRef;
668 
669  // Returns the current start pointer. May not be null-terminated.
670  auto data() const noexcept -> char const*;
671 
672  constexpr auto isNullTerminated() const noexcept -> bool {
673  return m_start[m_size] == '\0';
674  }
675 
676  public: // iterators
677  constexpr const_iterator begin() const { return m_start; }
678  constexpr const_iterator end() const { return m_start + m_size; }
679  };
680 
681  auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&;
682  auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
683 
684  constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
685  return StringRef( rawChars, size );
686  }
687 } // namespace Catch
688 
689 constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
690  return Catch::StringRef( rawChars, size );
691 }
692 
693 // end catch_stringref.h
694 // start catch_preprocessor.hpp
695 
696 
697 #define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__
698 #define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__)))
699 #define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__)))
700 #define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__)))
701 #define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__)))
702 #define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__)))
703 
704 #ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
705 #define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__
706 // MSVC needs more evaluations
707 #define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__)))
708 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__))
709 #else
710 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__)
711 #endif
712 
713 #define CATCH_REC_END(...)
714 #define CATCH_REC_OUT
715 
716 #define CATCH_EMPTY()
717 #define CATCH_DEFER(id) id CATCH_EMPTY()
718 
719 #define CATCH_REC_GET_END2() 0, CATCH_REC_END
720 #define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2
721 #define CATCH_REC_GET_END(...) CATCH_REC_GET_END1
722 #define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT
723 #define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0)
724 #define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next)
725 
726 #define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
727 #define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ )
728 #define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
729 
730 #define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )
731 #define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ )
732 #define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )
733 
734 // Applies the function macro `f` to each of the remaining parameters, inserts commas between the results,
735 // and passes userdata as the first parameter to each invocation,
736 // e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c)
737 #define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
738 
739 #define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
740 
741 #define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param)
742 #define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__
743 #define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__
744 #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF
745 #define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__)
746 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
747 #define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__
748 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param))
749 #else
750 // MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF
751 #define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__)
752 #define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__
753 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1)
754 #endif
755 
756 #define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__
757 #define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name)
758 
759 #define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__)
760 
761 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
762 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>())
763 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))
764 #else
765 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>()))
766 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)))
767 #endif
768 
769 #define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\
770  CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__)
771 
772 #define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0)
773 #define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1)
774 #define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2)
775 #define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3)
776 #define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4)
777 #define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5)
778 #define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6)
779 #define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7)
780 #define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8)
781 #define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9)
782 #define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10)
783 
784 #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
785 
786 #define INTERNAL_CATCH_TYPE_GEN\
787  template<typename...> struct TypeList {};\
788  template<typename...Ts>\
789  constexpr auto get_wrapper() noexcept -> TypeList<Ts...> { return {}; }\
790  template<template<typename...> class...> struct TemplateTypeList{};\
791  template<template<typename...> class...Cs>\
792  constexpr auto get_wrapper() noexcept -> TemplateTypeList<Cs...> { return {}; }\
793  template<typename...>\
794  struct append;\
795  template<typename...>\
796  struct rewrap;\
797  template<template<typename...> class, typename...>\
798  struct create;\
799  template<template<typename...> class, typename>\
800  struct convert;\
801  \
802  template<typename T> \
803  struct append<T> { using type = T; };\
804  template< template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2, typename...Rest>\
805  struct append<L1<E1...>, L2<E2...>, Rest...> { using type = typename append<L1<E1...,E2...>, Rest...>::type; };\
806  template< template<typename...> class L1, typename...E1, typename...Rest>\
807  struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { using type = L1<E1...>; };\
808  \
809  template< template<typename...> class Container, template<typename...> class List, typename...elems>\
810  struct rewrap<TemplateTypeList<Container>, List<elems...>> { using type = TypeList<Container<elems...>>; };\
811  template< template<typename...> class Container, template<typename...> class List, class...Elems, typename...Elements>\
812  struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; };\
813  \
814  template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\
815  struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; };\
816  template<template <typename...> class Final, template <typename...> class List, typename...Ts>\
817  struct convert<Final, List<Ts...>> { using type = typename append<Final<>,TypeList<Ts>...>::type; };
818 
819 #define INTERNAL_CATCH_NTTP_1(signature, ...)\
820  template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\
821  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
822  constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \
823  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\
824  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\
825  constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \
826  \
827  template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\
828  struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\
829  template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\
830  struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; };\
831  template<template <typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Containers, typename...Types>\
832  struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; };
833 
834 #define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName)
835 #define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\
836  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
837  static void TestName()
838 #define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...)\
839  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
840  static void TestName()
841 
842 #define INTERNAL_CATCH_DEFINE_SIG_TEST0(TestName)
843 #define INTERNAL_CATCH_DEFINE_SIG_TEST1(TestName, signature)\
844  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
845  static void TestName()
846 #define INTERNAL_CATCH_DEFINE_SIG_TEST_X(TestName, signature,...)\
847  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
848  static void TestName()
849 
850 #define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature)\
851  template<typename Type>\
852  void reg_test(TypeList<Type>, Catch::NameAndTags nameAndTags)\
853  {\
854  Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<Type>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
855  }
856 
857 #define INTERNAL_CATCH_NTTP_REGISTER(TestFunc, signature, ...)\
858  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
859  void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags)\
860  {\
861  Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
862  }
863 
864 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...)\
865  template<typename Type>\
866  void reg_test(TypeList<Type>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
867  {\
868  Catch::AutoReg( Catch::makeTestInvoker(&TestName<Type>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
869  }
870 
871 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...)\
872  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
873  void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
874  {\
875  Catch::AutoReg( Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
876  }
877 
878 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0(TestName, ClassName)
879 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1(TestName, ClassName, signature)\
880  template<typename TestType> \
881  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<TestType> { \
882  void test();\
883  }
884 
885 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X(TestName, ClassName, signature, ...)\
886  template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \
887  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<__VA_ARGS__> { \
888  void test();\
889  }
890 
891 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0(TestName)
892 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1(TestName, signature)\
893  template<typename TestType> \
894  void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<TestType>::test()
895 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X(TestName, signature, ...)\
896  template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \
897  void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<__VA_ARGS__>::test()
898 
899 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
900 #define INTERNAL_CATCH_NTTP_0
901 #define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__),INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_0)
902 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__)
903 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__)
904 #define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__)
905 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__)
906 #define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__)
907 #define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__)
908 #define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__)
909 #else
910 #define INTERNAL_CATCH_NTTP_0(signature)
911 #define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1,INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_0)( __VA_ARGS__))
912 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__))
913 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__))
914 #define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__))
915 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__))
916 #define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__))
917 #define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__))
918 #define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__))
919 #endif
920 
921 // end catch_preprocessor.hpp
922 // start catch_meta.hpp
923 
924 
925 #include <type_traits>
926 
927 namespace Catch {
928  template<typename T>
930 
931  template <typename> struct true_given : std::true_type {};
933  template <typename Fun, typename... Args>
934  true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> static test(int);
935  template <typename...>
936  std::false_type static test(...);
937  };
938 
939  template <typename T>
940  struct is_callable;
941 
942  template <typename Fun, typename... Args>
943  struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {};
944 
945 #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
946  // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is
947  // replaced with std::invoke_result here. Also *_t format is preferred over
948  // typename *::type format.
949  template <typename Func, typename U>
950  using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>;
951 #else
952  template <typename Func, typename U>
954 #endif
955 
956 } // namespace Catch
957 
958 namespace mpl_{
959  struct na;
960 }
961 
962 // end catch_meta.hpp
963 namespace Catch {
964 
965 template<typename C>
967  void (C::*m_testAsMethod)();
968 public:
969  TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}
970 
971  void invoke() const override {
972  C obj;
973  (obj.*m_testAsMethod)();
974  }
975 };
976 
977 auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*;
978 
979 template<typename C>
980 auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {
981  return new(std::nothrow) TestInvokerAsMethod<C>( testAsMethod );
982 }
983 
984 struct NameAndTags {
985  NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept;
988 };
989 
991  AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
992  ~AutoReg();
993 };
994 
995 } // end namespace Catch
996 
997 #if defined(CATCH_CONFIG_DISABLE)
998  #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \
999  static void TestName()
1000  #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
1001  namespace{ \
1002  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
1003  void test(); \
1004  }; \
1005  } \
1006  void TestName::test()
1007  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( TestName, TestFunc, Name, Tags, Signature, ... ) \
1008  INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1009  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
1010  namespace{ \
1011  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
1012  INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1013  } \
1014  } \
1015  INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1016 
1017  #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1018  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
1019  INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ )
1020  #else
1021  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
1022  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) )
1023  #endif
1024 
1025  #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1026  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
1027  INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ )
1028  #else
1029  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
1030  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1031  #endif
1032 
1033  #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1034  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
1035  INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ )
1036  #else
1037  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
1038  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) )
1039  #endif
1040 
1041  #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1042  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
1043  INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ )
1044  #else
1045  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
1046  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) )
1047  #endif
1048 #endif
1049 
1051  #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
1052  static void TestName(); \
1053  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1054  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1055  namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
1056  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1057  static void TestName()
1058  #define INTERNAL_CATCH_TESTCASE( ... ) \
1059  INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
1060 
1062  #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
1063  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1064  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1065  namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
1066  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
1067 
1069  #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
1070  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1071  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1072  namespace{ \
1073  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
1074  void test(); \
1075  }; \
1076  Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
1077  } \
1078  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1079  void TestName::test()
1080  #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
1081  INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
1082 
1084  #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
1085  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1086  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1087  Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
1088  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
1089 
1091  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\
1092  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1093  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1094  CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1095  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1096  INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1097  namespace {\
1098  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
1099  INTERNAL_CATCH_TYPE_GEN\
1100  INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1101  INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1102  template<typename...Types> \
1103  struct TestName{\
1104  TestName(){\
1105  int index = 0; \
1106  constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
1107  using expander = int[];\
1108  (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
1109  }\
1110  };\
1111  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1112  TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
1113  return 0;\
1114  }();\
1115  }\
1116  }\
1117  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1118  INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))
1119 
1120 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1121  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
1122  INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ )
1123 #else
1124  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
1125  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) )
1126 #endif
1127 
1128 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1129  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
1130  INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ )
1131 #else
1132  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
1133  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1134 #endif
1135 
1136  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \
1137  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1138  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1139  CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1140  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1141  template<typename TestType> static void TestFuncName(); \
1142  namespace {\
1143  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
1144  INTERNAL_CATCH_TYPE_GEN \
1145  INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \
1146  template<typename... Types> \
1147  struct TestName { \
1148  void reg_tests() { \
1149  int index = 0; \
1150  using expander = int[]; \
1151  constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
1152  constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
1153  constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
1154  (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */\
1155  } \
1156  }; \
1157  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
1158  using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \
1159  TestInit t; \
1160  t.reg_tests(); \
1161  return 0; \
1162  }(); \
1163  } \
1164  } \
1165  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1166  template<typename TestType> \
1167  static void TestFuncName()
1168 
1169 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1170  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
1171  INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T,__VA_ARGS__)
1172 #else
1173  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
1174  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T, __VA_ARGS__ ) )
1175 #endif
1176 
1177 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1178  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
1179  INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__)
1180 #else
1181  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
1182  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1183 #endif
1184 
1185  #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\
1186  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1187  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1188  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1189  template<typename TestType> static void TestFunc(); \
1190  namespace {\
1191  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
1192  INTERNAL_CATCH_TYPE_GEN\
1193  template<typename... Types> \
1194  struct TestName { \
1195  void reg_tests() { \
1196  int index = 0; \
1197  using expander = int[]; \
1198  (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */\
1199  } \
1200  };\
1201  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
1202  using TestInit = typename convert<TestName, TmplList>::type; \
1203  TestInit t; \
1204  t.reg_tests(); \
1205  return 0; \
1206  }(); \
1207  }}\
1208  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1209  template<typename TestType> \
1210  static void TestFunc()
1211 
1212  #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \
1213  INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, TmplList )
1214 
1215  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
1216  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1217  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1218  CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1219  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1220  namespace {\
1221  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
1222  INTERNAL_CATCH_TYPE_GEN\
1223  INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1224  INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1225  INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1226  template<typename...Types> \
1227  struct TestNameClass{\
1228  TestNameClass(){\
1229  int index = 0; \
1230  constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
1231  using expander = int[];\
1232  (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
1233  }\
1234  };\
1235  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1236  TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
1237  return 0;\
1238  }();\
1239  }\
1240  }\
1241  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1242  INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1243 
1244 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1245  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
1246  INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ )
1247 #else
1248  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
1249  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) )
1250 #endif
1251 
1252 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1253  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
1254  INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ )
1255 #else
1256  #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
1257  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) )
1258 #endif
1259 
1260  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\
1261  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1262  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1263  CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1264  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1265  template<typename TestType> \
1266  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
1267  void test();\
1268  };\
1269  namespace {\
1270  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) {\
1271  INTERNAL_CATCH_TYPE_GEN \
1272  INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1273  template<typename...Types>\
1274  struct TestNameClass{\
1275  void reg_tests(){\
1276  int index = 0;\
1277  using expander = int[];\
1278  constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
1279  constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
1280  constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
1281  (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */ \
1282  }\
1283  };\
1284  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1285  using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\
1286  TestInit t;\
1287  t.reg_tests();\
1288  return 0;\
1289  }(); \
1290  }\
1291  }\
1292  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1293  template<typename TestType> \
1294  void TestName<TestType>::test()
1295 
1296 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1297  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
1298  INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T, __VA_ARGS__ )
1299 #else
1300  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
1301  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T,__VA_ARGS__ ) )
1302 #endif
1303 
1304 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1305  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
1306  INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature, __VA_ARGS__ )
1307 #else
1308  #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
1309  INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature,__VA_ARGS__ ) )
1310 #endif
1311 
1312  #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \
1313  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1314  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1315  CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1316  template<typename TestType> \
1317  struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
1318  void test();\
1319  };\
1320  namespace {\
1321  namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
1322  INTERNAL_CATCH_TYPE_GEN\
1323  template<typename...Types>\
1324  struct TestNameClass{\
1325  void reg_tests(){\
1326  int index = 0;\
1327  using expander = int[];\
1328  (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */ \
1329  }\
1330  };\
1331  static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1332  using TestInit = typename convert<TestNameClass, TmplList>::type;\
1333  TestInit t;\
1334  t.reg_tests();\
1335  return 0;\
1336  }(); \
1337  }}\
1338  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1339  template<typename TestType> \
1340  void TestName<TestType>::test()
1341 
1342 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \
1343  INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, TmplList )
1344 
1345 // end catch_test_registry.h
1346 // start catch_capture.hpp
1347 
1348 // start catch_assertionhandler.h
1349 
1350 // start catch_assertioninfo.h
1351 
1352 // start catch_result_type.h
1353 
1354 namespace Catch {
1355 
1356  // ResultWas::OfType enum
1357  struct ResultWas { enum OfType {
1358  Unknown = -1,
1359  Ok = 0,
1360  Info = 1,
1361  Warning = 2,
1362 
1363  FailureBit = 0x10,
1364 
1365  ExpressionFailed = FailureBit | 1,
1366  ExplicitFailure = FailureBit | 2,
1367 
1368  Exception = 0x100 | FailureBit,
1369 
1370  ThrewException = Exception | 1,
1371  DidntThrowException = Exception | 2,
1372 
1373  FatalErrorCondition = 0x200 | FailureBit
1374 
1375  }; };
1376 
1377  bool isOk( ResultWas::OfType resultType );
1378  bool isJustInfo( int flags );
1379 
1380  // ResultDisposition::Flags enum
1381  struct ResultDisposition { enum Flags {
1382  Normal = 0x01,
1383 
1384  ContinueOnFailure = 0x02, // Failures fail test, but execution continues
1385  FalseTest = 0x04, // Prefix expression with !
1386  SuppressFail = 0x08 // Failures are reported but do not fail the test
1387  }; };
1388 
1390 
1391  bool shouldContinueOnFailure( int flags );
1392  inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
1393  bool shouldSuppressFailure( int flags );
1394 
1395 } // end namespace Catch
1396 
1397 // end catch_result_type.h
1398 namespace Catch {
1399 
1401  {
1406 
1407  // We want to delete this constructor but a compiler bug in 4.8 means
1408  // the struct is then treated as non-aggregate
1409  //AssertionInfo() = delete;
1410  };
1411 
1412 } // end namespace Catch
1413 
1414 // end catch_assertioninfo.h
1415 // start catch_decomposer.h
1416 
1417 // start catch_tostring.h
1418 
1419 #include <vector>
1420 #include <cstddef>
1421 #include <type_traits>
1422 #include <string>
1423 // start catch_stream.h
1424 
1425 #include <iosfwd>
1426 #include <cstddef>
1427 #include <ostream>
1428 
1429 namespace Catch {
1430 
1431  std::ostream& cout();
1432  std::ostream& cerr();
1433  std::ostream& clog();
1434 
1435  class StringRef;
1436 
1437  struct IStream {
1438  virtual ~IStream();
1439  virtual std::ostream& stream() const = 0;
1440  };
1441 
1442  auto makeStream( StringRef const &filename ) -> IStream const*;
1443 
1445  std::size_t m_index;
1446  std::ostream* m_oss;
1447  public:
1450 
1451  auto str() const -> std::string;
1452 
1453  template<typename T>
1454  auto operator << ( T const& value ) -> ReusableStringStream& {
1455  *m_oss << value;
1456  return *this;
1457  }
1458  auto get() -> std::ostream& { return *m_oss; }
1459  };
1460 }
1461 
1462 // end catch_stream.h
1463 // start catch_interfaces_enum_values_registry.h
1464 
1465 #include <vector>
1466 
1467 namespace Catch {
1468 
1469  namespace Detail {
1470  struct EnumInfo {
1472  std::vector<std::pair<int, StringRef>> m_values;
1473 
1474  ~EnumInfo();
1475 
1476  StringRef lookup( int value ) const;
1477  };
1478  } // namespace Detail
1479 
1481  virtual ~IMutableEnumValuesRegistry();
1482 
1483  virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values ) = 0;
1484 
1485  template<typename E>
1486  Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list<E> values ) {
1487  static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int");
1488  std::vector<int> intValues;
1489  intValues.reserve( values.size() );
1490  for( auto enumValue : values )
1491  intValues.push_back( static_cast<int>( enumValue ) );
1492  return registerEnum( enumName, allEnums, intValues );
1493  }
1494  };
1495 
1496 } // Catch
1497 
1498 // end catch_interfaces_enum_values_registry.h
1499 
1500 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1501 #include <string_view>
1502 #endif
1503 
1504 #ifdef __OBJC__
1505 // start catch_objc_arc.hpp
1506 
1507 #import <Foundation/Foundation.h>
1508 
1509 #ifdef __has_feature
1510 #define CATCH_ARC_ENABLED __has_feature(objc_arc)
1511 #else
1512 #define CATCH_ARC_ENABLED 0
1513 #endif
1514 
1515 void arcSafeRelease( NSObject* obj );
1516 id performOptionalSelector( id obj, SEL sel );
1517 
1518 #if !CATCH_ARC_ENABLED
1519 inline void arcSafeRelease( NSObject* obj ) {
1520  [obj release];
1521 }
1522 inline id performOptionalSelector( id obj, SEL sel ) {
1523  if( [obj respondsToSelector: sel] )
1524  return [obj performSelector: sel];
1525  return nil;
1526 }
1527 #define CATCH_UNSAFE_UNRETAINED
1528 #define CATCH_ARC_STRONG
1529 #else
1530 inline void arcSafeRelease( NSObject* ){}
1531 inline id performOptionalSelector( id obj, SEL sel ) {
1532 #ifdef __clang__
1533 #pragma clang diagnostic push
1534 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
1535 #endif
1536  if( [obj respondsToSelector: sel] )
1537  return [obj performSelector: sel];
1538 #ifdef __clang__
1539 #pragma clang diagnostic pop
1540 #endif
1541  return nil;
1542 }
1543 #define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
1544 #define CATCH_ARC_STRONG __strong
1545 #endif
1546 
1547 // end catch_objc_arc.hpp
1548 #endif
1549 
1550 #ifdef _MSC_VER
1551 #pragma warning(push)
1552 #pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless
1553 #endif
1554 
1555 namespace Catch {
1556  namespace Detail {
1557 
1558  extern const std::string unprintableString;
1559 
1560  std::string rawMemoryToString( const void *object, std::size_t size );
1561 
1562  template<typename T>
1563  std::string rawMemoryToString( const T& object ) {
1564  return rawMemoryToString( &object, sizeof(object) );
1565  }
1566 
1567  template<typename T>
1569  template<typename Stream, typename U>
1570  static auto test(int)
1571  -> decltype(std::declval<Stream&>() << std::declval<U>(), std::true_type());
1572 
1573  template<typename, typename>
1574  static auto test(...)->std::false_type;
1575 
1576  public:
1577  static const bool value = decltype(test<std::ostream, const T&>(0))::value;
1578  };
1579 
1580  template<typename E>
1581  std::string convertUnknownEnumToString( E e );
1582 
1583  template<typename T>
1584  typename std::enable_if<
1586  std::string>::type convertUnstreamable( T const& ) {
1588  }
1589  template<typename T>
1590  typename std::enable_if<
1592  std::string>::type convertUnstreamable(T const& ex) {
1593  return ex.what();
1594  }
1595 
1596  template<typename T>
1597  typename std::enable_if<
1599  , std::string>::type convertUnstreamable( T const& value ) {
1600  return convertUnknownEnumToString( value );
1601  }
1602 
1603 #if defined(_MANAGED)
1604  template<typename T>
1606  std::string clrReferenceToString( T^ ref ) {
1607  if (ref == nullptr)
1608  return std::string("null");
1609  auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString());
1610  cli::pin_ptr<System::Byte> p = &bytes[0];
1611  return std::string(reinterpret_cast<char const *>(p), bytes->Length);
1612  }
1613 #endif
1614 
1615  } // namespace Detail
1616 
1617  // If we decide for C++14, change these to enable_if_ts
1618  template <typename T, typename = void>
1619  struct StringMaker {
1620  template <typename Fake = T>
1621  static
1623  convert(const Fake& value) {
1625  // NB: call using the function-like syntax to avoid ambiguity with
1626  // user-defined templated operator<< under clang.
1627  rss.operator<<(value);
1628  return rss.str();
1629  }
1630 
1631  template <typename Fake = T>
1632  static
1634  convert( const Fake& value ) {
1635 #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)
1636  return Detail::convertUnstreamable(value);
1637 #else
1638  return CATCH_CONFIG_FALLBACK_STRINGIFIER(value);
1639 #endif
1640  }
1641  };
1642 
1643  namespace Detail {
1644 
1645  // This function dispatches all stringification requests inside of Catch.
1646  // Should be preferably called fully qualified, like ::Catch::Detail::stringify
1647  template <typename T>
1648  std::string stringify(const T& e) {
1650  }
1651 
1652  template<typename E>
1653  std::string convertUnknownEnumToString( E e ) {
1655  }
1656 
1657 #if defined(_MANAGED)
1658  template <typename T>
1659  std::string stringify( T^ e ) {
1661  }
1662 #endif
1663 
1664  } // namespace Detail
1665 
1666  // Some predefined specializations
1667 
1668  template<>
1670  static std::string convert(const std::string& str);
1671  };
1672 
1673 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1674  template<>
1675  struct StringMaker<std::string_view> {
1676  static std::string convert(std::string_view str);
1677  };
1678 #endif
1679 
1680  template<>
1681  struct StringMaker<char const *> {
1682  static std::string convert(char const * str);
1683  };
1684  template<>
1685  struct StringMaker<char *> {
1686  static std::string convert(char * str);
1687  };
1688 
1689 #ifdef CATCH_CONFIG_WCHAR
1690  template<>
1691  struct StringMaker<std::wstring> {
1692  static std::string convert(const std::wstring& wstr);
1693  };
1694 
1695 # ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1696  template<>
1697  struct StringMaker<std::wstring_view> {
1698  static std::string convert(std::wstring_view str);
1699  };
1700 # endif
1701 
1702  template<>
1703  struct StringMaker<wchar_t const *> {
1704  static std::string convert(wchar_t const * str);
1705  };
1706  template<>
1707  struct StringMaker<wchar_t *> {
1708  static std::string convert(wchar_t * str);
1709  };
1710 #endif
1711 
1712  // TBD: Should we use `strnlen` to ensure that we don't go out of the buffer,
1713  // while keeping string semantics?
1714  template<int SZ>
1715  struct StringMaker<char[SZ]> {
1716  static std::string convert(char const* str) {
1717  return ::Catch::Detail::stringify(std::string{ str });
1718  }
1719  };
1720  template<int SZ>
1721  struct StringMaker<signed char[SZ]> {
1722  static std::string convert(signed char const* str) {
1723  return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) });
1724  }
1725  };
1726  template<int SZ>
1727  struct StringMaker<unsigned char[SZ]> {
1728  static std::string convert(unsigned char const* str) {
1729  return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) });
1730  }
1731  };
1732 
1733 #if defined(CATCH_CONFIG_CPP17_BYTE)
1734  template<>
1735  struct StringMaker<std::byte> {
1736  static std::string convert(std::byte value);
1737  };
1738 #endif // defined(CATCH_CONFIG_CPP17_BYTE)
1739  template<>
1740  struct StringMaker<int> {
1741  static std::string convert(int value);
1742  };
1743  template<>
1744  struct StringMaker<long> {
1745  static std::string convert(long value);
1746  };
1747  template<>
1748  struct StringMaker<long long> {
1749  static std::string convert(long long value);
1750  };
1751  template<>
1752  struct StringMaker<unsigned int> {
1753  static std::string convert(unsigned int value);
1754  };
1755  template<>
1756  struct StringMaker<unsigned long> {
1757  static std::string convert(unsigned long value);
1758  };
1759  template<>
1760  struct StringMaker<unsigned long long> {
1761  static std::string convert(unsigned long long value);
1762  };
1763 
1764  template<>
1765  struct StringMaker<bool> {
1766  static std::string convert(bool b);
1767  };
1768 
1769  template<>
1770  struct StringMaker<char> {
1771  static std::string convert(char c);
1772  };
1773  template<>
1774  struct StringMaker<signed char> {
1775  static std::string convert(signed char c);
1776  };
1777  template<>
1778  struct StringMaker<unsigned char> {
1779  static std::string convert(unsigned char c);
1780  };
1781 
1782  template<>
1783  struct StringMaker<std::nullptr_t> {
1784  static std::string convert(std::nullptr_t);
1785  };
1786 
1787  template<>
1788  struct StringMaker<float> {
1789  static std::string convert(float value);
1790  static int precision;
1791  };
1792 
1793  template<>
1794  struct StringMaker<double> {
1795  static std::string convert(double value);
1796  static int precision;
1797  };
1798 
1799  template <typename T>
1800  struct StringMaker<T*> {
1801  template <typename U>
1802  static std::string convert(U* p) {
1803  if (p) {
1805  } else {
1806  return "nullptr";
1807  }
1808  }
1809  };
1810 
1811  template <typename R, typename C>
1812  struct StringMaker<R C::*> {
1813  static std::string convert(R C::* p) {
1814  if (p) {
1816  } else {
1817  return "nullptr";
1818  }
1819  }
1820  };
1821 
1822 #if defined(_MANAGED)
1823  template <typename T>
1824  struct StringMaker<T^> {
1825  static std::string convert( T^ ref ) {
1826  return ::Catch::Detail::clrReferenceToString(ref);
1827  }
1828  };
1829 #endif
1830 
1831  namespace Detail {
1832  template<typename InputIterator>
1833  std::string rangeToString(InputIterator first, InputIterator last) {
1835  rss << "{ ";
1836  if (first != last) {
1837  rss << ::Catch::Detail::stringify(*first);
1838  for (++first; first != last; ++first)
1839  rss << ", " << ::Catch::Detail::stringify(*first);
1840  }
1841  rss << " }";
1842  return rss.str();
1843  }
1844  }
1845 
1846 #ifdef __OBJC__
1847  template<>
1848  struct StringMaker<NSString*> {
1849  static std::string convert(NSString * nsstring) {
1850  if (!nsstring)
1851  return "nil";
1852  return std::string("@") + [nsstring UTF8String];
1853  }
1854  };
1855  template<>
1856  struct StringMaker<NSObject*> {
1857  static std::string convert(NSObject* nsObject) {
1858  return ::Catch::Detail::stringify([nsObject description]);
1859  }
1860 
1861  };
1862  namespace Detail {
1863  inline std::string stringify( NSString* nsstring ) {
1864  return StringMaker<NSString*>::convert( nsstring );
1865  }
1866 
1867  } // namespace Detail
1868 #endif // __OBJC__
1869 
1870 } // namespace Catch
1871 
1873 // Separate std-lib types stringification, so it can be selectively enabled
1874 // This means that we do not bring in
1875 
1876 #if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
1877 # define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
1878 # define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
1879 # define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
1880 # define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
1881 # define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
1882 #endif
1883 
1884 // Separate std::pair specialization
1885 #if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER)
1886 #include <utility>
1887 namespace Catch {
1888  template<typename T1, typename T2>
1889  struct StringMaker<std::pair<T1, T2> > {
1890  static std::string convert(const std::pair<T1, T2>& pair) {
1892  rss << "{ "
1893  << ::Catch::Detail::stringify(pair.first)
1894  << ", "
1895  << ::Catch::Detail::stringify(pair.second)
1896  << " }";
1897  return rss.str();
1898  }
1899  };
1900 }
1901 #endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
1902 
1903 #if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL)
1904 #include <optional>
1905 namespace Catch {
1906  template<typename T>
1907  struct StringMaker<std::optional<T> > {
1908  static std::string convert(const std::optional<T>& optional) {
1910  if (optional.has_value()) {
1911  rss << ::Catch::Detail::stringify(*optional);
1912  } else {
1913  rss << "{ }";
1914  }
1915  return rss.str();
1916  }
1917  };
1918 }
1919 #endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
1920 
1921 // Separate std::tuple specialization
1922 #if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER)
1923 #include <tuple>
1924 namespace Catch {
1925  namespace Detail {
1926  template<
1927  typename Tuple,
1928  std::size_t N = 0,
1930  >
1931  struct TupleElementPrinter {
1932  static void print(const Tuple& tuple, std::ostream& os) {
1933  os << (N ? ", " : " ")
1934  << ::Catch::Detail::stringify(std::get<N>(tuple));
1936  }
1937  };
1938 
1939  template<
1940  typename Tuple,
1941  std::size_t N
1942  >
1943  struct TupleElementPrinter<Tuple, N, false> {
1944  static void print(const Tuple&, std::ostream&) {}
1945  };
1946 
1947  }
1948 
1949  template<typename ...Types>
1950  struct StringMaker<std::tuple<Types...>> {
1951  static std::string convert(const std::tuple<Types...>& tuple) {
1953  rss << '{';
1954  Detail::TupleElementPrinter<std::tuple<Types...>>::print(tuple, rss.get());
1955  rss << " }";
1956  return rss.str();
1957  }
1958  };
1959 }
1960 #endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
1961 
1962 #if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
1963 #include <variant>
1964 namespace Catch {
1965  template<>
1966  struct StringMaker<std::monostate> {
1967  static std::string convert(const std::monostate&) {
1968  return "{ }";
1969  }
1970  };
1971 
1972  template<typename... Elements>
1973  struct StringMaker<std::variant<Elements...>> {
1974  static std::string convert(const std::variant<Elements...>& variant) {
1975  if (variant.valueless_by_exception()) {
1976  return "{valueless variant}";
1977  } else {
1978  return std::visit(
1979  [](const auto& value) {
1981  },
1982  variant
1983  );
1984  }
1985  }
1986  };
1987 }
1988 #endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
1989 
1990 namespace Catch {
1991  struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
1992 
1993  // Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
1994  using std::begin;
1995  using std::end;
1996 
1997  not_this_one begin( ... );
1998  not_this_one end( ... );
1999 
2000  template <typename T>
2001  struct is_range {
2002  static const bool value =
2003  !std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
2004  !std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;
2005  };
2006 
2007 #if defined(_MANAGED) // Managed types are never ranges
2008  template <typename T>
2009  struct is_range<T^> {
2010  static const bool value = false;
2011  };
2012 #endif
2013 
2014  template<typename Range>
2015  std::string rangeToString( Range const& range ) {
2016  return ::Catch::Detail::rangeToString( begin( range ), end( range ) );
2017  }
2018 
2019  // Handle vector<bool> specially
2020  template<typename Allocator>
2021  std::string rangeToString( std::vector<bool, Allocator> const& v ) {
2023  rss << "{ ";
2024  bool first = true;
2025  for( bool b : v ) {
2026  if( first )
2027  first = false;
2028  else
2029  rss << ", ";
2030  rss << ::Catch::Detail::stringify( b );
2031  }
2032  rss << " }";
2033  return rss.str();
2034  }
2035 
2036  template<typename R>
2037  struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> {
2038  static std::string convert( R const& range ) {
2039  return rangeToString( range );
2040  }
2041  };
2042 
2043  template <typename T, int SZ>
2044  struct StringMaker<T[SZ]> {
2045  static std::string convert(T const(&arr)[SZ]) {
2046  return rangeToString(arr);
2047  }
2048  };
2049 
2050 } // namespace Catch
2051 
2052 // Separate std::chrono::duration specialization
2053 #if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
2054 #include <ctime>
2055 #include <ratio>
2056 #include <chrono>
2057 
2058 namespace Catch {
2059 
2060 template <class Ratio>
2061 struct ratio_string {
2062  static std::string symbol();
2063 };
2064 
2065 template <class Ratio>
2066 std::string ratio_string<Ratio>::symbol() {
2068  rss << '[' << Ratio::num << '/'
2069  << Ratio::den << ']';
2070  return rss.str();
2071 }
2072 template <>
2073 struct ratio_string<std::atto> {
2074  static std::string symbol();
2075 };
2076 template <>
2077 struct ratio_string<std::femto> {
2078  static std::string symbol();
2079 };
2080 template <>
2081 struct ratio_string<std::pico> {
2082  static std::string symbol();
2083 };
2084 template <>
2085 struct ratio_string<std::nano> {
2086  static std::string symbol();
2087 };
2088 template <>
2089 struct ratio_string<std::micro> {
2090  static std::string symbol();
2091 };
2092 template <>
2093 struct ratio_string<std::milli> {
2094  static std::string symbol();
2095 };
2096 
2098  // std::chrono::duration specializations
2099  template<typename Value, typename Ratio>
2100  struct StringMaker<std::chrono::duration<Value, Ratio>> {
2101  static std::string convert(std::chrono::duration<Value, Ratio> const& duration) {
2103  rss << duration.count() << ' ' << ratio_string<Ratio>::symbol() << 's';
2104  return rss.str();
2105  }
2106  };
2107  template<typename Value>
2108  struct StringMaker<std::chrono::duration<Value, std::ratio<1>>> {
2109  static std::string convert(std::chrono::duration<Value, std::ratio<1>> const& duration) {
2111  rss << duration.count() << " s";
2112  return rss.str();
2113  }
2114  };
2115  template<typename Value>
2116  struct StringMaker<std::chrono::duration<Value, std::ratio<60>>> {
2117  static std::string convert(std::chrono::duration<Value, std::ratio<60>> const& duration) {
2119  rss << duration.count() << " m";
2120  return rss.str();
2121  }
2122  };
2123  template<typename Value>
2124  struct StringMaker<std::chrono::duration<Value, std::ratio<3600>>> {
2125  static std::string convert(std::chrono::duration<Value, std::ratio<3600>> const& duration) {
2127  rss << duration.count() << " h";
2128  return rss.str();
2129  }
2130  };
2131 
2133  // std::chrono::time_point specialization
2134  // Generic time_point cannot be specialized, only std::chrono::time_point<system_clock>
2135  template<typename Clock, typename Duration>
2136  struct StringMaker<std::chrono::time_point<Clock, Duration>> {
2137  static std::string convert(std::chrono::time_point<Clock, Duration> const& time_point) {
2138  return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch";
2139  }
2140  };
2141  // std::chrono::time_point<system_clock> specialization
2142  template<typename Duration>
2143  struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> {
2144  static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) {
2145  auto converted = std::chrono::system_clock::to_time_t(time_point);
2146 
2147 #ifdef _MSC_VER
2148  std::tm timeInfo = {};
2149  gmtime_s(&timeInfo, &converted);
2150 #else
2151  std::tm* timeInfo = std::gmtime(&converted);
2152 #endif
2153 
2154  auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
2155  char timeStamp[timeStampSize];
2156  const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
2157 
2158 #ifdef _MSC_VER
2159  std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
2160 #else
2161  std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
2162 #endif
2163  return std::string(timeStamp);
2164  }
2165  };
2166 }
2167 #endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
2168 
2169 #define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
2170 namespace Catch { \
2171  template<> struct StringMaker<enumName> { \
2172  static std::string convert( enumName value ) { \
2173  static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \
2174  return static_cast<std::string>(enumInfo.lookup( static_cast<int>( value ) )); \
2175  } \
2176  }; \
2177 }
2178 
2179 #define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ )
2180 
2181 #ifdef _MSC_VER
2182 #pragma warning(pop)
2183 #endif
2184 
2185 // end catch_tostring.h
2186 #include <iosfwd>
2187 
2188 #ifdef _MSC_VER
2189 #pragma warning(push)
2190 #pragma warning(disable:4389) // '==' : signed/unsigned mismatch
2191 #pragma warning(disable:4018) // more "signed/unsigned mismatch"
2192 #pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
2193 #pragma warning(disable:4180) // qualifier applied to function type has no meaning
2194 #pragma warning(disable:4800) // Forcing result to true or false
2195 #endif
2196 
2197 namespace Catch {
2198 
2200  auto isBinaryExpression() const -> bool { return m_isBinaryExpression; }
2201  auto getResult() const -> bool { return m_result; }
2202  virtual void streamReconstructedExpression( std::ostream &os ) const = 0;
2203 
2204  ITransientExpression( bool isBinaryExpression, bool result )
2205  : m_isBinaryExpression( isBinaryExpression ),
2206  m_result( result )
2207  {}
2208 
2209  // We don't actually need a virtual destructor, but many static analysers
2210  // complain if it's not here :-(
2211  virtual ~ITransientExpression();
2212 
2214  bool m_result;
2215 
2216  };
2217 
2218  void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
2219 
2220  template<typename LhsT, typename RhsT>
2222  LhsT m_lhs;
2224  RhsT m_rhs;
2225 
2226  void streamReconstructedExpression( std::ostream &os ) const override {
2228  ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) );
2229  }
2230 
2231  public:
2232  BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs )
2233  : ITransientExpression{ true, comparisonResult },
2234  m_lhs( lhs ),
2235  m_op( op ),
2236  m_rhs( rhs )
2237  {}
2238 
2239  template<typename T>
2241  static_assert(always_false<T>::value,
2242  "chained comparisons are not supported inside assertions, "
2243  "wrap the expression inside parentheses, or decompose it");
2244  }
2245 
2246  template<typename T>
2247  auto operator || ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
2248  static_assert(always_false<T>::value,
2249  "chained comparisons are not supported inside assertions, "
2250  "wrap the expression inside parentheses, or decompose it");
2251  }
2252 
2253  template<typename T>
2255  static_assert(always_false<T>::value,
2256  "chained comparisons are not supported inside assertions, "
2257  "wrap the expression inside parentheses, or decompose it");
2258  }
2259 
2260  template<typename T>
2262  static_assert(always_false<T>::value,
2263  "chained comparisons are not supported inside assertions, "
2264  "wrap the expression inside parentheses, or decompose it");
2265  }
2266 
2267  template<typename T>
2269  static_assert(always_false<T>::value,
2270  "chained comparisons are not supported inside assertions, "
2271  "wrap the expression inside parentheses, or decompose it");
2272  }
2273 
2274  template<typename T>
2276  static_assert(always_false<T>::value,
2277  "chained comparisons are not supported inside assertions, "
2278  "wrap the expression inside parentheses, or decompose it");
2279  }
2280 
2281  template<typename T>
2283  static_assert(always_false<T>::value,
2284  "chained comparisons are not supported inside assertions, "
2285  "wrap the expression inside parentheses, or decompose it");
2286  }
2287 
2288  template<typename T>
2290  static_assert(always_false<T>::value,
2291  "chained comparisons are not supported inside assertions, "
2292  "wrap the expression inside parentheses, or decompose it");
2293  }
2294  };
2295 
2296  template<typename LhsT>
2298  LhsT m_lhs;
2299 
2300  void streamReconstructedExpression( std::ostream &os ) const override {
2301  os << Catch::Detail::stringify( m_lhs );
2302  }
2303 
2304  public:
2305  explicit UnaryExpr( LhsT lhs )
2306  : ITransientExpression{ false, static_cast<bool>(lhs) },
2307  m_lhs( lhs )
2308  {}
2309  };
2310 
2311  // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
2312  template<typename LhsT, typename RhsT>
2313  auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); }
2314  template<typename T>
2315  auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
2316  template<typename T>
2317  auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
2318  template<typename T>
2319  auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }
2320  template<typename T>
2321  auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }
2322 
2323  template<typename LhsT, typename RhsT>
2324  auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); }
2325  template<typename T>
2326  auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }
2327  template<typename T>
2328  auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }
2329  template<typename T>
2330  auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }
2331  template<typename T>
2332  auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }
2333 
2334  template<typename LhsT>
2335  class ExprLhs {
2336  LhsT m_lhs;
2337  public:
2338  explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}
2339 
2340  template<typename RhsT>
2341  auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2342  return { compareEqual( m_lhs, rhs ), m_lhs, "==", rhs };
2343  }
2344  auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
2345  return { m_lhs == rhs, m_lhs, "==", rhs };
2346  }
2347 
2348  template<typename RhsT>
2349  auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2350  return { compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs };
2351  }
2352  auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
2353  return { m_lhs != rhs, m_lhs, "!=", rhs };
2354  }
2355 
2356  template<typename RhsT>
2357  auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2358  return { static_cast<bool>(m_lhs > rhs), m_lhs, ">", rhs };
2359  }
2360  template<typename RhsT>
2361  auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2362  return { static_cast<bool>(m_lhs < rhs), m_lhs, "<", rhs };
2363  }
2364  template<typename RhsT>
2365  auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2366  return { static_cast<bool>(m_lhs >= rhs), m_lhs, ">=", rhs };
2367  }
2368  template<typename RhsT>
2369  auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
2370  return { static_cast<bool>(m_lhs <= rhs), m_lhs, "<=", rhs };
2371  }
2372  template <typename RhsT>
2373  auto operator | (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
2374  return { static_cast<bool>(m_lhs | rhs), m_lhs, "|", rhs };
2375  }
2376  template <typename RhsT>
2377  auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
2378  return { static_cast<bool>(m_lhs & rhs), m_lhs, "&", rhs };
2379  }
2380  template <typename RhsT>
2381  auto operator ^ (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const {
2382  return { static_cast<bool>(m_lhs ^ rhs), m_lhs, "^", rhs };
2383  }
2384 
2385  template<typename RhsT>
2386  auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const {
2387  static_assert(always_false<RhsT>::value,
2388  "operator&& is not supported inside assertions, "
2389  "wrap the expression inside parentheses, or decompose it");
2390  }
2391 
2392  template<typename RhsT>
2393  auto operator || ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const {
2394  static_assert(always_false<RhsT>::value,
2395  "operator|| is not supported inside assertions, "
2396  "wrap the expression inside parentheses, or decompose it");
2397  }
2398 
2399  auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
2400  return UnaryExpr<LhsT>{ m_lhs };
2401  }
2402  };
2403 
2404  void handleExpression( ITransientExpression const& expr );
2405 
2406  template<typename T>
2407  void handleExpression( ExprLhs<T> const& expr ) {
2408  handleExpression( expr.makeUnaryExpr() );
2409  }
2410 
2411  struct Decomposer {
2412  template<typename T>
2413  auto operator <= ( T const& lhs ) -> ExprLhs<T const&> {
2414  return ExprLhs<T const&>{ lhs };
2415  }
2416 
2417  auto operator <=( bool value ) -> ExprLhs<bool> {
2418  return ExprLhs<bool>{ value };
2419  }
2420  };
2421 
2422 } // end namespace Catch
2423 
2424 #ifdef _MSC_VER
2425 #pragma warning(pop)
2426 #endif
2427 
2428 // end catch_decomposer.h
2429 // start catch_interfaces_capture.h
2430 
2431 #include <string>
2432 #include <chrono>
2433 
2434 namespace Catch {
2435 
2436  class AssertionResult;
2437  struct AssertionInfo;
2438  struct SectionInfo;
2439  struct SectionEndInfo;
2440  struct MessageInfo;
2441  struct MessageBuilder;
2442  struct Counts;
2443  struct AssertionReaction;
2444  struct SourceLineInfo;
2445 
2446  struct ITransientExpression;
2447  struct IGeneratorTracker;
2448 
2449 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
2450  struct BenchmarkInfo;
2451  template <typename Duration = std::chrono::duration<double, std::nano>>
2452  struct BenchmarkStats;
2453 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
2454 
2456 
2457  virtual ~IResultCapture();
2458 
2459  virtual bool sectionStarted( SectionInfo const& sectionInfo,
2460  Counts& assertions ) = 0;
2461  virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
2462  virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
2463 
2464  virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;
2465 
2466 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
2467  virtual void benchmarkPreparing( std::string const& name ) = 0;
2468  virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;
2469  virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0;
2470  virtual void benchmarkFailed( std::string const& error ) = 0;
2471 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
2472 
2473  virtual void pushScopedMessage( MessageInfo const& message ) = 0;
2474  virtual void popScopedMessage( MessageInfo const& message ) = 0;
2475 
2476  virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0;
2477 
2478  virtual void handleFatalErrorCondition( StringRef message ) = 0;
2479 
2480  virtual void handleExpr
2481  ( AssertionInfo const& info,
2482  ITransientExpression const& expr,
2483  AssertionReaction& reaction ) = 0;
2484  virtual void handleMessage
2485  ( AssertionInfo const& info,
2486  ResultWas::OfType resultType,
2487  StringRef const& message,
2488  AssertionReaction& reaction ) = 0;
2489  virtual void handleUnexpectedExceptionNotThrown
2490  ( AssertionInfo const& info,
2491  AssertionReaction& reaction ) = 0;
2492  virtual void handleUnexpectedInflightException
2493  ( AssertionInfo const& info,
2494  std::string const& message,
2495  AssertionReaction& reaction ) = 0;
2496  virtual void handleIncomplete
2497  ( AssertionInfo const& info ) = 0;
2498  virtual void handleNonExpr
2499  ( AssertionInfo const &info,
2500  ResultWas::OfType resultType,
2501  AssertionReaction &reaction ) = 0;
2502 
2503  virtual bool lastAssertionPassed() = 0;
2504  virtual void assertionPassed() = 0;
2505 
2506  // Deprecated, do not use:
2507  virtual std::string getCurrentTestName() const = 0;
2508  virtual const AssertionResult* getLastResult() const = 0;
2509  virtual void exceptionEarlyReported() = 0;
2510  };
2511 
2513 }
2514 
2515 // end catch_interfaces_capture.h
2516 namespace Catch {
2517 
2519  struct AssertionResultData;
2520  struct IResultCapture;
2521  class RunContext;
2522 
2524  friend class AssertionHandler;
2525  friend struct AssertionStats;
2526  friend class RunContext;
2527 
2528  ITransientExpression const* m_transientExpression = nullptr;
2530  public:
2531  LazyExpression( bool isNegated );
2532  LazyExpression( LazyExpression const& other );
2533  LazyExpression& operator = ( LazyExpression const& ) = delete;
2534 
2535  explicit operator bool() const;
2536 
2537  friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;
2538  };
2539 
2541  bool shouldDebugBreak = false;
2542  bool shouldThrow = false;
2543  };
2544 
2548  bool m_completed = false;
2550 
2551  public:
2553  ( StringRef const& macroName,
2554  SourceLineInfo const& lineInfo,
2555  StringRef capturedExpression,
2556  ResultDisposition::Flags resultDisposition );
2558  if ( !m_completed ) {
2559  m_resultCapture.handleIncomplete( m_assertionInfo );
2560  }
2561  }
2562 
2563  template<typename T>
2564  void handleExpr( ExprLhs<T> const& expr ) {
2565  handleExpr( expr.makeUnaryExpr() );
2566  }
2567  void handleExpr( ITransientExpression const& expr );
2568 
2569  void handleMessage(ResultWas::OfType resultType, StringRef const& message);
2570 
2571  void handleExceptionThrownAsExpected();
2572  void handleUnexpectedExceptionNotThrown();
2573  void handleExceptionNotThrownAsExpected();
2574  void handleThrowingCallSkipped();
2575  void handleUnexpectedInflightException();
2576 
2577  void complete();
2578  void setCompleted();
2579 
2580  // query
2581  auto allowThrows() const -> bool;
2582  };
2583 
2584  void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString );
2585 
2586 } // namespace Catch
2587 
2588 // end catch_assertionhandler.h
2589 // start catch_message.h
2590 
2591 #include <string>
2592 #include <vector>
2593 
2594 namespace Catch {
2595 
2596  struct MessageInfo {
2597  MessageInfo( StringRef const& _macroName,
2598  SourceLineInfo const& _lineInfo,
2599  ResultWas::OfType _type );
2600 
2602  std::string message;
2605  unsigned int sequence;
2606 
2607  bool operator == ( MessageInfo const& other ) const;
2608  bool operator < ( MessageInfo const& other ) const;
2609  private:
2610  static unsigned int globalCount;
2611  };
2612 
2613  struct MessageStream {
2614 
2615  template<typename T>
2617  m_stream << value;
2618  return *this;
2619  }
2620 
2622  };
2623 
2625  MessageBuilder( StringRef const& macroName,
2626  SourceLineInfo const& lineInfo,
2628 
2629  template<typename T>
2631  m_stream << value;
2632  return *this;
2633  }
2634 
2636  };
2637 
2639  public:
2640  explicit ScopedMessage( MessageBuilder const& builder );
2641  ScopedMessage( ScopedMessage& duplicate ) = delete;
2642  ScopedMessage( ScopedMessage&& old );
2643  ~ScopedMessage();
2644 
2646  bool m_moved;
2647  };
2648 
2649  class Capturer {
2650  std::vector<MessageInfo> m_messages;
2651  IResultCapture& m_resultCapture = getResultCapture();
2652  size_t m_captured = 0;
2653  public:
2654  Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names );
2655  ~Capturer();
2656 
2657  void captureValue( size_t index, std::string const& value );
2658 
2659  template<typename T>
2660  void captureValues( size_t index, T const& value ) {
2661  captureValue( index, Catch::Detail::stringify( value ) );
2662  }
2663 
2664  template<typename T, typename... Ts>
2665  void captureValues( size_t index, T const& value, Ts const&... values ) {
2666  captureValue( index, Catch::Detail::stringify(value) );
2667  captureValues( index+1, values... );
2668  }
2669  };
2670 
2671 } // end namespace Catch
2672 
2673 // end catch_message.h
2674 #if !defined(CATCH_CONFIG_DISABLE)
2675 
2676 #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)
2677  #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__
2678 #else
2679  #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
2680 #endif
2681 
2682 #if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
2683 
2685 // Another way to speed-up compilation is to omit local try-catch for REQUIRE*
2686 // macros.
2687 #define INTERNAL_CATCH_TRY
2688 #define INTERNAL_CATCH_CATCH( capturer )
2689 
2690 #else // CATCH_CONFIG_FAST_COMPILE
2691 
2692 #define INTERNAL_CATCH_TRY try
2693 #define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); }
2694 
2695 #endif
2696 
2697 #define INTERNAL_CATCH_REACT( handler ) handler.complete();
2698 
2700 #define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \
2701  do { \
2702  CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
2703  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
2704  INTERNAL_CATCH_TRY { \
2705  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
2706  CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
2707  catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
2708  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
2709  } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
2710  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2711  } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) )
2712 
2714 #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \
2715  INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \
2716  if( Catch::getResultCapture().lastAssertionPassed() )
2717 
2719 #define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \
2720  INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \
2721  if( !Catch::getResultCapture().lastAssertionPassed() )
2722 
2724 #define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \
2725  do { \
2726  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
2727  try { \
2728  static_cast<void>(__VA_ARGS__); \
2729  catchAssertionHandler.handleExceptionNotThrownAsExpected(); \
2730  } \
2731  catch( ... ) { \
2732  catchAssertionHandler.handleUnexpectedInflightException(); \
2733  } \
2734  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2735  } while( false )
2736 
2738 #define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \
2739  do { \
2740  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \
2741  if( catchAssertionHandler.allowThrows() ) \
2742  try { \
2743  static_cast<void>(__VA_ARGS__); \
2744  catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
2745  } \
2746  catch( ... ) { \
2747  catchAssertionHandler.handleExceptionThrownAsExpected(); \
2748  } \
2749  else \
2750  catchAssertionHandler.handleThrowingCallSkipped(); \
2751  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2752  } while( false )
2753 
2755 #define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
2756  do { \
2757  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \
2758  if( catchAssertionHandler.allowThrows() ) \
2759  try { \
2760  static_cast<void>(expr); \
2761  catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
2762  } \
2763  catch( exceptionType const& ) { \
2764  catchAssertionHandler.handleExceptionThrownAsExpected(); \
2765  } \
2766  catch( ... ) { \
2767  catchAssertionHandler.handleUnexpectedInflightException(); \
2768  } \
2769  else \
2770  catchAssertionHandler.handleThrowingCallSkipped(); \
2771  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2772  } while( false )
2773 
2775 #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
2776  do { \
2777  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \
2778  catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \
2779  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2780  } while( false )
2781 
2783 #define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \
2784  auto varName = Catch::Capturer( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \
2785  varName.captureValues( 0, __VA_ARGS__ )
2786 
2788 #define INTERNAL_CATCH_INFO( macroName, log ) \
2789  Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log );
2790 
2792 #define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \
2793  Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log )
2794 
2796 // Although this is matcher-based, it can be used with just a string
2797 #define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \
2798  do { \
2799  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
2800  if( catchAssertionHandler.allowThrows() ) \
2801  try { \
2802  static_cast<void>(__VA_ARGS__); \
2803  catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
2804  } \
2805  catch( ... ) { \
2806  Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \
2807  } \
2808  else \
2809  catchAssertionHandler.handleThrowingCallSkipped(); \
2810  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
2811  } while( false )
2812 
2813 #endif // CATCH_CONFIG_DISABLE
2814 
2815 // end catch_capture.hpp
2816 // start catch_section.h
2817 
2818 // start catch_section_info.h
2819 
2820 // start catch_totals.h
2821 
2822 #include <cstddef>
2823 
2824 namespace Catch {
2825 
2826  struct Counts {
2827  Counts operator - ( Counts const& other ) const;
2828  Counts& operator += ( Counts const& other );
2829 
2830  std::size_t total() const;
2831  bool allPassed() const;
2832  bool allOk() const;
2833 
2834  std::size_t passed = 0;
2835  std::size_t failed = 0;
2836  std::size_t failedButOk = 0;
2837  };
2838 
2839  struct Totals {
2840 
2841  Totals operator - ( Totals const& other ) const;
2842  Totals& operator += ( Totals const& other );
2843 
2844  Totals delta( Totals const& prevTotals ) const;
2845 
2846  int error = 0;
2849  };
2850 }
2851 
2852 // end catch_totals.h
2853 #include <string>
2854 
2855 namespace Catch {
2856 
2857  struct SectionInfo {
2858  SectionInfo
2859  ( SourceLineInfo const& _lineInfo,
2860  std::string const& _name );
2861 
2862  // Deprecated
2863  SectionInfo
2864  ( SourceLineInfo const& _lineInfo,
2865  std::string const& _name,
2866  std::string const& ) : SectionInfo( _lineInfo, _name ) {}
2867 
2868  std::string name;
2869  std::string description; // !Deprecated: this will always be empty
2871  };
2872 
2877  };
2878 
2879 } // end namespace Catch
2880 
2881 // end catch_section_info.h
2882 // start catch_timer.h
2883 
2884 #include <cstdint>
2885 
2886 namespace Catch {
2887 
2890 
2891  class Timer {
2892  uint64_t m_nanoseconds = 0;
2893  public:
2894  void start();
2895  auto getElapsedNanoseconds() const -> uint64_t;
2896  auto getElapsedMicroseconds() const -> uint64_t;
2897  auto getElapsedMilliseconds() const -> unsigned int;
2898  auto getElapsedSeconds() const -> double;
2899  };
2900 
2901 } // namespace Catch
2902 
2903 // end catch_timer.h
2904 #include <string>
2905 
2906 namespace Catch {
2907 
2909  public:
2910  Section( SectionInfo const& info );
2911  ~Section();
2912 
2913  // This indicates whether the section should be executed or not
2914  explicit operator bool() const;
2915 
2916  private:
2918 
2919  std::string m_name;
2923  };
2924 
2925 } // end namespace Catch
2926 
2927 #define INTERNAL_CATCH_SECTION( ... ) \
2928  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
2929  CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
2930  if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \
2931  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
2932 
2933 #define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
2934  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
2935  CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
2936  if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \
2937  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
2938 
2939 // end catch_section.h
2940 // start catch_interfaces_exception.h
2941 
2942 // start catch_interfaces_registry_hub.h
2943 
2944 #include <string>
2945 #include <memory>
2946 
2947 namespace Catch {
2948 
2949  class TestCase;
2950  struct ITestCaseRegistry;
2951  struct IExceptionTranslatorRegistry;
2952  struct IExceptionTranslator;
2953  struct IReporterRegistry;
2954  struct IReporterFactory;
2955  struct ITagAliasRegistry;
2956  struct IMutableEnumValuesRegistry;
2957 
2958  class StartupExceptionRegistry;
2959 
2960  using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;
2961 
2962  struct IRegistryHub {
2963  virtual ~IRegistryHub();
2964 
2965  virtual IReporterRegistry const& getReporterRegistry() const = 0;
2966  virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
2967  virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
2968  virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0;
2969 
2970  virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
2971  };
2972 
2974  virtual ~IMutableRegistryHub();
2975  virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0;
2976  virtual void registerListener( IReporterFactoryPtr const& factory ) = 0;
2977  virtual void registerTest( TestCase const& testInfo ) = 0;
2978  virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
2979  virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
2980  virtual void registerStartupException() noexcept = 0;
2981  virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0;
2982  };
2983 
2984  IRegistryHub const& getRegistryHub();
2986  void cleanUp();
2987  std::string translateActiveException();
2988 
2989 }
2990 
2991 // end catch_interfaces_registry_hub.h
2992 #if defined(CATCH_CONFIG_DISABLE)
2993  #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \
2994  static std::string translatorName( signature )
2995 #endif
2996 
2997 #include <exception>
2998 #include <string>
2999 #include <vector>
3000 
3001 namespace Catch {
3002  using exceptionTranslateFunction = std::string(*)();
3003 
3004  struct IExceptionTranslator;
3005  using ExceptionTranslators = std::vector<std::unique_ptr<IExceptionTranslator const>>;
3006 
3008  virtual ~IExceptionTranslator();
3009  virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
3010  };
3011 
3013  virtual ~IExceptionTranslatorRegistry();
3014 
3015  virtual std::string translateActiveException() const = 0;
3016  };
3017 
3019  template<typename T>
3021  public:
3022 
3023  ExceptionTranslator( std::string(*translateFunction)( T& ) )
3024  : m_translateFunction( translateFunction )
3025  {}
3026 
3027  std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override {
3028 #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
3029  return "";
3030 #else
3031  try {
3032  if( it == itEnd )
3033  std::rethrow_exception(std::current_exception());
3034  else
3035  return (*it)->translate( it+1, itEnd );
3036  }
3037  catch( T& ex ) {
3038  return m_translateFunction( ex );
3039  }
3040 #endif
3041  }
3042 
3043  protected:
3044  std::string(*m_translateFunction)( T& );
3045  };
3046 
3047  public:
3048  template<typename T>
3049  ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
3051  ( new ExceptionTranslator<T>( translateFunction ) );
3052  }
3053  };
3054 }
3055 
3057 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
3058  static std::string translatorName( signature ); \
3059  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
3060  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
3061  namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \
3062  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
3063  static std::string translatorName( signature )
3064 
3065 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
3066 
3067 // end catch_interfaces_exception.h
3068 // start catch_approx.h
3069 
3070 #include <type_traits>
3071 
3072 namespace Catch {
3073 namespace Detail {
3074 
3075  class Approx {
3076  private:
3077  bool equalityComparisonImpl(double other) const;
3078  // Validates the new margin (margin >= 0)
3079  // out-of-line to avoid including stdexcept in the header
3080  void setMargin(double margin);
3081  // Validates the new epsilon (0 < epsilon < 1)
3082  // out-of-line to avoid including stdexcept in the header
3083  void setEpsilon(double epsilon);
3084 
3085  public:
3086  explicit Approx ( double value );
3087 
3088  static Approx custom();
3089 
3090  Approx operator-() const;
3091 
3093  Approx operator()( T const& value ) {
3094  Approx approx( static_cast<double>(value) );
3095  approx.m_epsilon = m_epsilon;
3096  approx.m_margin = m_margin;
3097  approx.m_scale = m_scale;
3098  return approx;
3099  }
3100 
3102  explicit Approx( T const& value ): Approx(static_cast<double>(value))
3103  {}
3104 
3106  friend bool operator == ( const T& lhs, Approx const& rhs ) {
3107  auto lhs_v = static_cast<double>(lhs);
3108  return rhs.equalityComparisonImpl(lhs_v);
3109  }
3110 
3112  friend bool operator == ( Approx const& lhs, const T& rhs ) {
3113  return operator==( rhs, lhs );
3114  }
3115 
3117  friend bool operator != ( T const& lhs, Approx const& rhs ) {
3118  return !operator==( lhs, rhs );
3119  }
3120 
3122  friend bool operator != ( Approx const& lhs, T const& rhs ) {
3123  return !operator==( rhs, lhs );
3124  }
3125 
3127  friend bool operator <= ( T const& lhs, Approx const& rhs ) {
3128  return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;
3129  }
3130 
3132  friend bool operator <= ( Approx const& lhs, T const& rhs ) {
3133  return lhs.m_value < static_cast<double>(rhs) || lhs == rhs;
3134  }
3135 
3137  friend bool operator >= ( T const& lhs, Approx const& rhs ) {
3138  return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;
3139  }
3140 
3142  friend bool operator >= ( Approx const& lhs, T const& rhs ) {
3143  return lhs.m_value > static_cast<double>(rhs) || lhs == rhs;
3144  }
3145 
3147  Approx& epsilon( T const& newEpsilon ) {
3148  double epsilonAsDouble = static_cast<double>(newEpsilon);
3149  setEpsilon(epsilonAsDouble);
3150  return *this;
3151  }
3152 
3154  Approx& margin( T const& newMargin ) {
3155  double marginAsDouble = static_cast<double>(newMargin);
3156  setMargin(marginAsDouble);
3157  return *this;
3158  }
3159 
3161  Approx& scale( T const& newScale ) {
3162  m_scale = static_cast<double>(newScale);
3163  return *this;
3164  }
3165 
3166  std::string toString() const;
3167 
3168  private:
3169  double m_epsilon;
3170  double m_margin;
3171  double m_scale;
3172  double m_value;
3173  };
3174 } // end namespace Detail
3175 
3176 namespace literals {
3177  Detail::Approx operator "" _a(long double val);
3178  Detail::Approx operator "" _a(unsigned long long val);
3179 } // end namespace literals
3180 
3181 template<>
3183  static std::string convert(Catch::Detail::Approx const& value);
3184 };
3185 
3186 } // end namespace Catch
3187 
3188 // end catch_approx.h
3189 // start catch_string_manip.h
3190 
3191 #include <string>
3192 #include <iosfwd>
3193 #include <vector>
3194 
3195 namespace Catch {
3196 
3197  bool startsWith( std::string const& s, std::string const& prefix );
3198  bool startsWith( std::string const& s, char prefix );
3199  bool endsWith( std::string const& s, std::string const& suffix );
3200  bool endsWith( std::string const& s, char suffix );
3201  bool contains( std::string const& s, std::string const& infix );
3202  void toLowerInPlace( std::string& s );
3203  std::string toLower( std::string const& s );
3205  std::string trim( std::string const& str );
3208 
3209  // !!! Be aware, returns refs into original string - make sure original string outlives them
3210  std::vector<StringRef> splitStringRef( StringRef str, char delimiter );
3211  bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
3212 
3213  struct pluralise {
3214  pluralise( std::size_t count, std::string const& label );
3215 
3216  friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
3217 
3218  std::size_t m_count;
3219  std::string m_label;
3220  };
3221 }
3222 
3223 // end catch_string_manip.h
3224 #ifndef CATCH_CONFIG_DISABLE_MATCHERS
3225 // start catch_capture_matchers.h
3226 
3227 // start catch_matchers.h
3228 
3229 #include <string>
3230 #include <vector>
3231 
3232 namespace Catch {
3233 namespace Matchers {
3234  namespace Impl {
3235 
3236  template<typename ArgT> struct MatchAllOf;
3237  template<typename ArgT> struct MatchAnyOf;
3238  template<typename ArgT> struct MatchNotOf;
3239 
3241  public:
3242  MatcherUntypedBase() = default;
3243  MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
3244  MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete;
3245  std::string toString() const;
3246 
3247  protected:
3248  virtual ~MatcherUntypedBase();
3249  virtual std::string describe() const = 0;
3250  mutable std::string m_cachedToString;
3251  };
3252 
3253 #ifdef __clang__
3254 # pragma clang diagnostic push
3255 # pragma clang diagnostic ignored "-Wnon-virtual-dtor"
3256 #endif
3257 
3258  template<typename ObjectT>
3259  struct MatcherMethod {
3260  virtual bool match( ObjectT const& arg ) const = 0;
3261  };
3262 
3263 #if defined(__OBJC__)
3264  // Hack to fix Catch GH issue #1661. Could use id for generic Object support.
3265  // use of const for Object pointers is very uncommon and under ARC it causes some kind of signature mismatch that breaks compilation
3266  template<>
3267  struct MatcherMethod<NSString*> {
3268  virtual bool match( NSString* arg ) const = 0;
3269  };
3270 #endif
3271 
3272 #ifdef __clang__
3273 # pragma clang diagnostic pop
3274 #endif
3275 
3276  template<typename T>
3278 
3279  MatchAllOf<T> operator && ( MatcherBase const& other ) const;
3280  MatchAnyOf<T> operator || ( MatcherBase const& other ) const;
3281  MatchNotOf<T> operator ! () const;
3282  };
3283 
3284  template<typename ArgT>
3285  struct MatchAllOf : MatcherBase<ArgT> {
3286  bool match( ArgT const& arg ) const override {
3287  for( auto matcher : m_matchers ) {
3288  if (!matcher->match(arg))
3289  return false;
3290  }
3291  return true;
3292  }
3293  std::string describe() const override {
3294  std::string description;
3295  description.reserve( 4 + m_matchers.size()*32 );
3296  description += "( ";
3297  bool first = true;
3298  for( auto matcher : m_matchers ) {
3299  if( first )
3300  first = false;
3301  else
3302  description += " and ";
3303  description += matcher->toString();
3304  }
3305  description += " )";
3306  return description;
3307  }
3308 
3310  auto copy(*this);
3311  copy.m_matchers.push_back( &other );
3312  return copy;
3313  }
3314 
3315  std::vector<MatcherBase<ArgT> const*> m_matchers;
3316  };
3317  template<typename ArgT>
3318  struct MatchAnyOf : MatcherBase<ArgT> {
3319 
3320  bool match( ArgT const& arg ) const override {
3321  for( auto matcher : m_matchers ) {
3322  if (matcher->match(arg))
3323  return true;
3324  }
3325  return false;
3326  }
3327  std::string describe() const override {
3328  std::string description;
3329  description.reserve( 4 + m_matchers.size()*32 );
3330  description += "( ";
3331  bool first = true;
3332  for( auto matcher : m_matchers ) {
3333  if( first )
3334  first = false;
3335  else
3336  description += " or ";
3337  description += matcher->toString();
3338  }
3339  description += " )";
3340  return description;
3341  }
3342 
3343  MatchAnyOf<ArgT> operator || ( MatcherBase<ArgT> const& other ) {
3344  auto copy(*this);
3345  copy.m_matchers.push_back( &other );
3346  return copy;
3347  }
3348 
3349  std::vector<MatcherBase<ArgT> const*> m_matchers;
3350  };
3351 
3352  template<typename ArgT>
3353  struct MatchNotOf : MatcherBase<ArgT> {
3354 
3355  MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {}
3356 
3357  bool match( ArgT const& arg ) const override {
3358  return !m_underlyingMatcher.match( arg );
3359  }
3360 
3361  std::string describe() const override {
3362  return "not " + m_underlyingMatcher.toString();
3363  }
3365  };
3366 
3367  template<typename T>
3369  return MatchAllOf<T>() && *this && other;
3370  }
3371  template<typename T>
3373  return MatchAnyOf<T>() || *this || other;
3374  }
3375  template<typename T>
3377  return MatchNotOf<T>( *this );
3378  }
3379 
3380  } // namespace Impl
3381 
3382 } // namespace Matchers
3383 
3384 using namespace Matchers;
3386 
3387 } // namespace Catch
3388 
3389 // end catch_matchers.h
3390 // start catch_matchers_exception.hpp
3391 
3392 namespace Catch {
3393 namespace Matchers {
3394 namespace Exception {
3395 
3396 class ExceptionMessageMatcher : public MatcherBase<std::exception> {
3397  std::string m_message;
3398 public:
3399 
3400  ExceptionMessageMatcher(std::string const& message):
3401  m_message(message)
3402  {}
3403 
3404  bool match(std::exception const& ex) const override;
3405 
3406  std::string describe() const override;
3407 };
3408 
3409 } // namespace Exception
3410 
3412 
3413 } // namespace Matchers
3414 } // namespace Catch
3415 
3416 // end catch_matchers_exception.hpp
3417 // start catch_matchers_floating.h
3418 
3419 namespace Catch {
3420 namespace Matchers {
3421 
3422  namespace Floating {
3423 
3424  enum class FloatingPointKind : uint8_t;
3425 
3426  struct WithinAbsMatcher : MatcherBase<double> {
3427  WithinAbsMatcher(double target, double margin);
3428  bool match(double const& matchee) const override;
3429  std::string describe() const override;
3430  private:
3431  double m_target;
3432  double m_margin;
3433  };
3434 
3435  struct WithinUlpsMatcher : MatcherBase<double> {
3436  WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType);
3437  bool match(double const& matchee) const override;
3438  std::string describe() const override;
3439  private:
3440  double m_target;
3441  uint64_t m_ulps;
3442  FloatingPointKind m_type;
3443  };
3444 
3445  // Given IEEE-754 format for floats and doubles, we can assume
3446  // that float -> double promotion is lossless. Given this, we can
3447  // assume that if we do the standard relative comparison of
3448  // |lhs - rhs| <= epsilon * max(fabs(lhs), fabs(rhs)), then we get
3449  // the same result if we do this for floats, as if we do this for
3450  // doubles that were promoted from floats.
3451  struct WithinRelMatcher : MatcherBase<double> {
3452  WithinRelMatcher(double target, double epsilon);
3453  bool match(double const& matchee) const override;
3454  std::string describe() const override;
3455  private:
3456  double m_target;
3457  double m_epsilon;
3458  };
3459 
3460  } // namespace Floating
3461 
3462  // The following functions create the actual matcher objects.
3463  // This allows the types to be inferred
3464  Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff);
3465  Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff);
3466  Floating::WithinAbsMatcher WithinAbs(double target, double margin);
3467  Floating::WithinRelMatcher WithinRel(double target, double eps);
3468  // defaults epsilon to 100*numeric_limits<double>::epsilon()
3469  Floating::WithinRelMatcher WithinRel(double target);
3470  Floating::WithinRelMatcher WithinRel(float target, float eps);
3471  // defaults epsilon to 100*numeric_limits<float>::epsilon()
3472  Floating::WithinRelMatcher WithinRel(float target);
3473 
3474 } // namespace Matchers
3475 } // namespace Catch
3476 
3477 // end catch_matchers_floating.h
3478 // start catch_matchers_generic.hpp
3479 
3480 #include <functional>
3481 #include <string>
3482 
3483 namespace Catch {
3484 namespace Matchers {
3485 namespace Generic {
3486 
3487 namespace Detail {
3488  std::string finalizeDescription(const std::string& desc);
3489 }
3490 
3491 template <typename T>
3492 class PredicateMatcher : public MatcherBase<T> {
3493  std::function<bool(T const&)> m_predicate;
3494  std::string m_description;
3495 public:
3496 
3497  PredicateMatcher(std::function<bool(T const&)> const& elem, std::string const& descr)
3498  :m_predicate(std::move(elem)),
3499  m_description(Detail::finalizeDescription(descr))
3500  {}
3501 
3502  bool match( T const& item ) const override {
3503  return m_predicate(item);
3504  }
3505 
3506  std::string describe() const override {
3507  return m_description;
3508  }
3509 };
3510 
3511 } // namespace Generic
3512 
3513  // The following functions create the actual matcher objects.
3514  // The user has to explicitly specify type to the function, because
3515  // inferring std::function<bool(T const&)> is hard (but possible) and
3516  // requires a lot of TMP.
3517  template<typename T>
3518  Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)> const& predicate, std::string const& description = "") {
3519  return Generic::PredicateMatcher<T>(predicate, description);
3520  }
3521 
3522 } // namespace Matchers
3523 } // namespace Catch
3524 
3525 // end catch_matchers_generic.hpp
3526 // start catch_matchers_string.h
3527 
3528 #include <string>
3529 
3530 namespace Catch {
3531 namespace Matchers {
3532 
3533  namespace StdString {
3534 
3536  {
3537  CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity );
3538  std::string adjustString( std::string const& str ) const;
3539  std::string caseSensitivitySuffix() const;
3540 
3542  std::string m_str;
3543  };
3544 
3545  struct StringMatcherBase : MatcherBase<std::string> {
3546  StringMatcherBase( std::string const& operation, CasedString const& comparator );
3547  std::string describe() const override;
3548 
3550  std::string m_operation;
3551  };
3552 
3554  EqualsMatcher( CasedString const& comparator );
3555  bool match( std::string const& source ) const override;
3556  };
3558  ContainsMatcher( CasedString const& comparator );
3559  bool match( std::string const& source ) const override;
3560  };
3562  StartsWithMatcher( CasedString const& comparator );
3563  bool match( std::string const& source ) const override;
3564  };
3566  EndsWithMatcher( CasedString const& comparator );
3567  bool match( std::string const& source ) const override;
3568  };
3569 
3570  struct RegexMatcher : MatcherBase<std::string> {
3571  RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity );
3572  bool match( std::string const& matchee ) const override;
3573  std::string describe() const override;
3574 
3575  private:
3576  std::string m_regex;
3578  };
3579 
3580  } // namespace StdString
3581 
3582  // The following functions create the actual matcher objects.
3583  // This allows the types to be inferred
3584 
3585  StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
3586  StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
3587  StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
3588  StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
3589  StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );
3590 
3591 } // namespace Matchers
3592 } // namespace Catch
3593 
3594 // end catch_matchers_string.h
3595 // start catch_matchers_vector.h
3596 
3597 #include <algorithm>
3598 
3599 namespace Catch {
3600 namespace Matchers {
3601 
3602  namespace Vector {
3603  template<typename T, typename Alloc>
3604  struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> {
3605 
3606  ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}
3607 
3608  bool match(std::vector<T, Alloc> const &v) const override {
3609  for (auto const& el : v) {
3610  if (el == m_comparator) {
3611  return true;
3612  }
3613  }
3614  return false;
3615  }
3616 
3617  std::string describe() const override {
3618  return "Contains: " + ::Catch::Detail::stringify( m_comparator );
3619  }
3620 
3621  T const& m_comparator;
3622  };
3623 
3624  template<typename T, typename AllocComp, typename AllocMatch>
3625  struct ContainsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
3626 
3627  ContainsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {}
3628 
3629  bool match(std::vector<T, AllocMatch> const &v) const override {
3630  // !TBD: see note in EqualsMatcher
3631  if (m_comparator.size() > v.size())
3632  return false;
3633  for (auto const& comparator : m_comparator) {
3634  auto present = false;
3635  for (const auto& el : v) {
3636  if (el == comparator) {
3637  present = true;
3638  break;
3639  }
3640  }
3641  if (!present) {
3642  return false;
3643  }
3644  }
3645  return true;
3646  }
3647  std::string describe() const override {
3648  return "Contains: " + ::Catch::Detail::stringify( m_comparator );
3649  }
3650 
3651  std::vector<T, AllocComp> const& m_comparator;
3652  };
3653 
3654  template<typename T, typename AllocComp, typename AllocMatch>
3655  struct EqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
3656 
3657  EqualsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {}
3658 
3659  bool match(std::vector<T, AllocMatch> const &v) const override {
3660  // !TBD: This currently works if all elements can be compared using !=
3661  // - a more general approach would be via a compare template that defaults
3662  // to using !=. but could be specialised for, e.g. std::vector<T, Alloc> etc
3663  // - then just call that directly
3664  if (m_comparator.size() != v.size())
3665  return false;
3666  for (std::size_t i = 0; i < v.size(); ++i)
3667  if (m_comparator[i] != v[i])
3668  return false;
3669  return true;
3670  }
3671  std::string describe() const override {
3672  return "Equals: " + ::Catch::Detail::stringify( m_comparator );
3673  }
3674  std::vector<T, AllocComp> const& m_comparator;
3675  };
3676 
3677  template<typename T, typename AllocComp, typename AllocMatch>
3678  struct ApproxMatcher : MatcherBase<std::vector<T, AllocMatch>> {
3679 
3680  ApproxMatcher(std::vector<T, AllocComp> const& comparator) : m_comparator( comparator ) {}
3681 
3682  bool match(std::vector<T, AllocMatch> const &v) const override {
3683  if (m_comparator.size() != v.size())
3684  return false;
3685  for (std::size_t i = 0; i < v.size(); ++i)
3686  if (m_comparator[i] != approx(v[i]))
3687  return false;
3688  return true;
3689  }
3690  std::string describe() const override {
3691  return "is approx: " + ::Catch::Detail::stringify( m_comparator );
3692  }
3694  ApproxMatcher& epsilon( T const& newEpsilon ) {
3695  approx.epsilon(newEpsilon);
3696  return *this;
3697  }
3699  ApproxMatcher& margin( T const& newMargin ) {
3700  approx.margin(newMargin);
3701  return *this;
3702  }
3704  ApproxMatcher& scale( T const& newScale ) {
3705  approx.scale(newScale);
3706  return *this;
3707  }
3708 
3709  std::vector<T, AllocComp> const& m_comparator;
3711  };
3712 
3713  template<typename T, typename AllocComp, typename AllocMatch>
3714  struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
3715  UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {}
3716  bool match(std::vector<T, AllocMatch> const& vec) const override {
3717  // Note: This is a reimplementation of std::is_permutation,
3718  // because I don't want to include <algorithm> inside the common path
3719  if (m_target.size() != vec.size()) {
3720  return false;
3721  }
3722  return std::is_permutation(m_target.begin(), m_target.end(), vec.begin());
3723  }
3724 
3725  std::string describe() const override {
3726  return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target);
3727  }
3728  private:
3729  std::vector<T, AllocComp> const& m_target;
3730  };
3731 
3732  } // namespace Vector
3733 
3734  // The following functions create the actual matcher objects.
3735  // This allows the types to be inferred
3736 
3737  template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
3738  Vector::ContainsMatcher<T, AllocComp, AllocMatch> Contains( std::vector<T, AllocComp> const& comparator ) {
3740  }
3741 
3742  template<typename T, typename Alloc = std::allocator<T>>
3744  return Vector::ContainsElementMatcher<T, Alloc>( comparator );
3745  }
3746 
3747  template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
3748  Vector::EqualsMatcher<T, AllocComp, AllocMatch> Equals( std::vector<T, AllocComp> const& comparator ) {
3750  }
3751 
3752  template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
3753  Vector::ApproxMatcher<T, AllocComp, AllocMatch> Approx( std::vector<T, AllocComp> const& comparator ) {
3755  }
3756 
3757  template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
3760  }
3761 
3762 } // namespace Matchers
3763 } // namespace Catch
3764 
3765 // end catch_matchers_vector.h
3766 namespace Catch {
3767 
3768  template<typename ArgT, typename MatcherT>
3770  ArgT const& m_arg;
3771  MatcherT m_matcher;
3773  public:
3774  MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString )
3775  : ITransientExpression{ true, matcher.match( arg ) },
3776  m_arg( arg ),
3777  m_matcher( matcher ),
3778  m_matcherString( matcherString )
3779  {}
3780 
3781  void streamReconstructedExpression( std::ostream &os ) const override {
3782  auto matcherAsString = m_matcher.toString();
3783  os << Catch::Detail::stringify( m_arg ) << ' ';
3784  if( matcherAsString == Detail::unprintableString )
3785  os << m_matcherString;
3786  else
3787  os << matcherAsString;
3788  }
3789  };
3790 
3792 
3793  void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString );
3794 
3795  template<typename ArgT, typename MatcherT>
3796  auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString ) -> MatchExpr<ArgT, MatcherT> {
3797  return MatchExpr<ArgT, MatcherT>( arg, matcher, matcherString );
3798  }
3799 
3800 } // namespace Catch
3801 
3803 #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
3804  do { \
3805  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
3806  INTERNAL_CATCH_TRY { \
3807  catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
3808  } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
3809  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
3810  } while( false )
3811 
3813 #define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \
3814  do { \
3815  Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
3816  if( catchAssertionHandler.allowThrows() ) \
3817  try { \
3818  static_cast<void>(__VA_ARGS__ ); \
3819  catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
3820  } \
3821  catch( exceptionType const& ex ) { \
3822  catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \
3823  } \
3824  catch( ... ) { \
3825  catchAssertionHandler.handleUnexpectedInflightException(); \
3826  } \
3827  else \
3828  catchAssertionHandler.handleThrowingCallSkipped(); \
3829  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
3830  } while( false )
3831 
3832 // end catch_capture_matchers.h
3833 #endif
3834 // start catch_generators.hpp
3835 
3836 // start catch_interfaces_generatortracker.h
3837 
3838 
3839 #include <memory>
3840 
3841 namespace Catch {
3842 
3843  namespace Generators {
3845  public:
3846  GeneratorUntypedBase() = default;
3847  virtual ~GeneratorUntypedBase();
3848  // Attempts to move the generator to the next element
3849  //
3850  // Returns true iff the move succeeded (and a valid element
3851  // can be retrieved).
3852  virtual bool next() = 0;
3853  };
3854  using GeneratorBasePtr = std::unique_ptr<GeneratorUntypedBase>;
3855 
3856  } // namespace Generators
3857 
3859  virtual ~IGeneratorTracker();
3860  virtual auto hasGenerator() const -> bool = 0;
3861  virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;
3862  virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0;
3863  };
3864 
3865 } // namespace Catch
3866 
3867 // end catch_interfaces_generatortracker.h
3868 // start catch_enforce.h
3869 
3870 #include <exception>
3871 
3872 namespace Catch {
3873 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
3874  template <typename Ex>
3875  [[noreturn]]
3876  void throw_exception(Ex const& e) {
3877  throw e;
3878  }
3879 #else // ^^ Exceptions are enabled // Exceptions are disabled vv
3880  [[noreturn]]
3881  void throw_exception(std::exception const& e);
3882 #endif
3883 
3884  [[noreturn]]
3885  void throw_logic_error(std::string const& msg);
3886  [[noreturn]]
3887  void throw_domain_error(std::string const& msg);
3888  [[noreturn]]
3889  void throw_runtime_error(std::string const& msg);
3890 
3891 } // namespace Catch;
3892 
3893 #define CATCH_MAKE_MSG(...) \
3894  (Catch::ReusableStringStream() << __VA_ARGS__).str()
3895 
3896 #define CATCH_INTERNAL_ERROR(...) \
3897  Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__))
3898 
3899 #define CATCH_ERROR(...) \
3900  Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ ))
3901 
3902 #define CATCH_RUNTIME_ERROR(...) \
3903  Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ ))
3904 
3905 #define CATCH_ENFORCE( condition, ... ) \
3906  do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false)
3907 
3908 // end catch_enforce.h
3909 #include <memory>
3910 #include <vector>
3911 #include <cassert>
3912 
3913 #include <utility>
3914 #include <exception>
3915 
3916 namespace Catch {
3917 
3918 class GeneratorException : public std::exception {
3919  const char* const m_msg = "";
3920 
3921 public:
3922  GeneratorException(const char* msg):
3923  m_msg(msg)
3924  {}
3925 
3926  const char* what() const noexcept override final;
3927 };
3928 
3929 namespace Generators {
3930 
3931  // !TBD move this into its own location?
3932  namespace pf{
3933  template<typename T, typename... Args>
3934  std::unique_ptr<T> make_unique( Args&&... args ) {
3935  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
3936  }
3937  }
3938 
3939  template<typename T>
3941  virtual ~IGenerator() = default;
3942 
3943  // Returns the current element of the generator
3944  //
3945  // \Precondition The generator is either freshly constructed,
3946  // or the last call to `next()` returned true
3947  virtual T const& get() const = 0;
3948  using type = T;
3949  };
3950 
3951  template<typename T>
3952  class SingleValueGenerator final : public IGenerator<T> {
3954  public:
3956 
3957  T const& get() const override {
3958  return m_value;
3959  }
3960  bool next() override {
3961  return false;
3962  }
3963  };
3964 
3965  template<typename T>
3966  class FixedValuesGenerator final : public IGenerator<T> {
3967  static_assert(!std::is_same<T, bool>::value,
3968  "FixedValuesGenerator does not support bools because of std::vector<bool>"
3969  "specialization, use SingleValue Generator instead.");
3970  std::vector<T> m_values;
3971  size_t m_idx = 0;
3972  public:
3973  FixedValuesGenerator( std::initializer_list<T> values ) : m_values( values ) {}
3974 
3975  T const& get() const override {
3976  return m_values[m_idx];
3977  }
3978  bool next() override {
3979  ++m_idx;
3980  return m_idx < m_values.size();
3981  }
3982  };
3983 
3984  template <typename T>
3985  class GeneratorWrapper final {
3986  std::unique_ptr<IGenerator<T>> m_generator;
3987  public:
3988  GeneratorWrapper(std::unique_ptr<IGenerator<T>> generator):
3989  m_generator(std::move(generator))
3990  {}
3991  T const& get() const {
3992  return m_generator->get();
3993  }
3994  bool next() {
3995  return m_generator->next();
3996  }
3997  };
3998 
3999  template <typename T>
4001  return GeneratorWrapper<T>(pf::make_unique<SingleValueGenerator<T>>(std::forward<T>(value)));
4002  }
4003  template <typename T>
4004  GeneratorWrapper<T> values(std::initializer_list<T> values) {
4005  return GeneratorWrapper<T>(pf::make_unique<FixedValuesGenerator<T>>(values));
4006  }
4007 
4008  template<typename T>
4009  class Generators : public IGenerator<T> {
4010  std::vector<GeneratorWrapper<T>> m_generators;
4011  size_t m_current = 0;
4012 
4013  void populate(GeneratorWrapper<T>&& generator) {
4014  m_generators.emplace_back(std::move(generator));
4015  }
4016  void populate(T&& val) {
4017  m_generators.emplace_back(value(std::forward<T>(val)));
4018  }
4019  template<typename U>
4020  void populate(U&& val) {
4021  populate(T(std::forward<U>(val)));
4022  }
4023  template<typename U, typename... Gs>
4024  void populate(U&& valueOrGenerator, Gs &&... moreGenerators) {
4025  populate(std::forward<U>(valueOrGenerator));
4026  populate(std::forward<Gs>(moreGenerators)...);
4027  }
4028 
4029  public:
4030  template <typename... Gs>
4031  Generators(Gs &&... moreGenerators) {
4032  m_generators.reserve(sizeof...(Gs));
4033  populate(std::forward<Gs>(moreGenerators)...);
4034  }
4035 
4036  T const& get() const override {
4037  return m_generators[m_current].get();
4038  }
4039 
4040  bool next() override {
4041  if (m_current >= m_generators.size()) {
4042  return false;
4043  }
4044  const bool current_status = m_generators[m_current].next();
4045  if (!current_status) {
4046  ++m_current;
4047  }
4048  return m_current < m_generators.size();
4049  }
4050  };
4051 
4052  template<typename... Ts>
4053  GeneratorWrapper<std::tuple<Ts...>> table( std::initializer_list<std::tuple<typename std::decay<Ts>::type...>> tuples ) {
4054  return values<std::tuple<Ts...>>( tuples );
4055  }
4056 
4057  // Tag type to signal that a generator sequence should convert arguments to a specific type
4058  template <typename T>
4059  struct as {};
4060 
4061  template<typename T, typename... Gs>
4062  auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> {
4063  return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...);
4064  }
4065  template<typename T>
4067  return Generators<T>(std::move(generator));
4068  }
4069  template<typename T, typename... Gs>
4070  auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<T> {
4071  return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... );
4072  }
4073  template<typename T, typename U, typename... Gs>
4074  auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> {
4075  return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );
4076  }
4077 
4078  auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker&;
4079 
4080  template<typename L>
4081  // Note: The type after -> is weird, because VS2015 cannot parse
4082  // the expression used in the typedef inside, when it is in
4083  // return type. Yeah.
4084  auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
4085  using UnderlyingType = typename decltype(generatorExpression())::type;
4086 
4088  if (!tracker.hasGenerator()) {
4089  tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression()));
4090  }
4091 
4092  auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() );
4093  return generator.get();
4094  }
4095 
4096 } // namespace Generators
4097 } // namespace Catch
4098 
4099 #define GENERATE( ... ) \
4100  Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
4101 #define GENERATE_COPY( ... ) \
4102  Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
4103 #define GENERATE_REF( ... ) \
4104  Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
4105 
4106 // end catch_generators.hpp
4107 // start catch_generators_generic.hpp
4108 
4109 namespace Catch {
4110 namespace Generators {
4111 
4112  template <typename T>
4113  class TakeGenerator : public IGenerator<T> {
4115  size_t m_returned = 0;
4116  size_t m_target;
4117  public:
4118  TakeGenerator(size_t target, GeneratorWrapper<T>&& generator):
4119  m_generator(std::move(generator)),
4120  m_target(target)
4121  {
4122  assert(target != 0 && "Empty generators are not allowed");
4123  }
4124  T const& get() const override {
4125  return m_generator.get();
4126  }
4127  bool next() override {
4128  ++m_returned;
4129  if (m_returned >= m_target) {
4130  return false;
4131  }
4132 
4133  const auto success = m_generator.next();
4134  // If the underlying generator does not contain enough values
4135  // then we cut short as well
4136  if (!success) {
4137  m_returned = m_target;
4138  }
4139  return success;
4140  }
4141  };
4142 
4143  template <typename T>
4144  GeneratorWrapper<T> take(size_t target, GeneratorWrapper<T>&& generator) {
4145  return GeneratorWrapper<T>(pf::make_unique<TakeGenerator<T>>(target, std::move(generator)));
4146  }
4147 
4148  template <typename T, typename Predicate>
4149  class FilterGenerator : public IGenerator<T> {
4152  public:
4153  template <typename P = Predicate>
4154  FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator):
4155  m_generator(std::move(generator)),
4156  m_predicate(std::forward<P>(pred))
4157  {
4158  if (!m_predicate(m_generator.get())) {
4159  // It might happen that there are no values that pass the
4160  // filter. In that case we throw an exception.
4161  auto has_initial_value = next();
4162  if (!has_initial_value) {
4163  Catch::throw_exception(GeneratorException("No valid value found in filtered generator"));
4164  }
4165  }
4166  }
4167 
4168  T const& get() const override {
4169  return m_generator.get();
4170  }
4171 
4172  bool next() override {
4173  bool success = m_generator.next();
4174  if (!success) {
4175  return false;
4176  }
4177  while (!m_predicate(m_generator.get()) && (success = m_generator.next()) == true);
4178  return success;
4179  }
4180  };
4181 
4182  template <typename T, typename Predicate>
4184  return GeneratorWrapper<T>(std::unique_ptr<IGenerator<T>>(pf::make_unique<FilterGenerator<T, Predicate>>(std::forward<Predicate>(pred), std::move(generator))));
4185  }
4186 
4187  template <typename T>
4188  class RepeatGenerator : public IGenerator<T> {
4189  static_assert(!std::is_same<T, bool>::value,
4190  "RepeatGenerator currently does not support bools"
4191  "because of std::vector<bool> specialization");
4193  mutable std::vector<T> m_returned;
4195  size_t m_current_repeat = 0;
4196  size_t m_repeat_index = 0;
4197  public:
4198  RepeatGenerator(size_t repeats, GeneratorWrapper<T>&& generator):
4199  m_generator(std::move(generator)),
4200  m_target_repeats(repeats)
4201  {
4202  assert(m_target_repeats > 0 && "Repeat generator must repeat at least once");
4203  }
4204 
4205  T const& get() const override {
4206  if (m_current_repeat == 0) {
4207  m_returned.push_back(m_generator.get());
4208  return m_returned.back();
4209  }
4210  return m_returned[m_repeat_index];
4211  }
4212 
4213  bool next() override {
4214  // There are 2 basic cases:
4215  // 1) We are still reading the generator
4216  // 2) We are reading our own cache
4217 
4218  // In the first case, we need to poke the underlying generator.
4219  // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache
4220  if (m_current_repeat == 0) {
4221  const auto success = m_generator.next();
4222  if (!success) {
4223  ++m_current_repeat;
4224  }
4225  return m_current_repeat < m_target_repeats;
4226  }
4227 
4228  // In the second case, we need to move indices forward and check that we haven't run up against the end
4229  ++m_repeat_index;
4230  if (m_repeat_index == m_returned.size()) {
4231  m_repeat_index = 0;
4232  ++m_current_repeat;
4233  }
4234  return m_current_repeat < m_target_repeats;
4235  }
4236  };
4237 
4238  template <typename T>
4239  GeneratorWrapper<T> repeat(size_t repeats, GeneratorWrapper<T>&& generator) {
4240  return GeneratorWrapper<T>(pf::make_unique<RepeatGenerator<T>>(repeats, std::move(generator)));
4241  }
4242 
4243  template <typename T, typename U, typename Func>
4244  class MapGenerator : public IGenerator<T> {
4245  // TBD: provide static assert for mapping function, for friendly error message
4248  // To avoid returning dangling reference, we have to save the values
4250  public:
4251  template <typename F2 = Func>
4252  MapGenerator(F2&& function, GeneratorWrapper<U>&& generator) :
4253  m_generator(std::move(generator)),
4254  m_function(std::forward<F2>(function)),
4255  m_cache(m_function(m_generator.get()))
4256  {}
4257 
4258  T const& get() const override {
4259  return m_cache;
4260  }
4261  bool next() override {
4262  const auto success = m_generator.next();
4263  if (success) {
4264  m_cache = m_function(m_generator.get());
4265  }
4266  return success;
4267  }
4268  };
4269 
4270  template <typename Func, typename U, typename T = FunctionReturnType<Func, U>>
4271  GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
4272  return GeneratorWrapper<T>(
4273  pf::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator))
4274  );
4275  }
4276 
4277  template <typename T, typename U, typename Func>
4278  GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
4279  return GeneratorWrapper<T>(
4280  pf::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator))
4281  );
4282  }
4283 
4284  template <typename T>
4285  class ChunkGenerator final : public IGenerator<std::vector<T>> {
4286  std::vector<T> m_chunk;
4289  bool m_used_up = false;
4290  public:
4291  ChunkGenerator(size_t size, GeneratorWrapper<T> generator) :
4292  m_chunk_size(size), m_generator(std::move(generator))
4293  {
4294  m_chunk.reserve(m_chunk_size);
4295  if (m_chunk_size != 0) {
4296  m_chunk.push_back(m_generator.get());
4297  for (size_t i = 1; i < m_chunk_size; ++i) {
4298  if (!m_generator.next()) {
4299  Catch::throw_exception(GeneratorException("Not enough values to initialize the first chunk"));
4300  }
4301  m_chunk.push_back(m_generator.get());
4302  }
4303  }
4304  }
4305  std::vector<T> const& get() const override {
4306  return m_chunk;
4307  }
4308  bool next() override {
4309  m_chunk.clear();
4310  for (size_t idx = 0; idx < m_chunk_size; ++idx) {
4311  if (!m_generator.next()) {
4312  return false;
4313  }
4314  m_chunk.push_back(m_generator.get());
4315  }
4316  return true;
4317  }
4318  };
4319 
4320  template <typename T>
4323  pf::make_unique<ChunkGenerator<T>>(size, std::move(generator))
4324  );
4325  }
4326 
4327 } // namespace Generators
4328 } // namespace Catch
4329 
4330 // end catch_generators_generic.hpp
4331 // start catch_generators_specific.hpp
4332 
4333 // start catch_context.h
4334 
4335 #include <memory>
4336 
4337 namespace Catch {
4338 
4339  struct IResultCapture;
4340  struct IRunner;
4341  struct IConfig;
4342  struct IMutableContext;
4343 
4344  using IConfigPtr = std::shared_ptr<IConfig const>;
4345 
4346  struct IContext
4347  {
4348  virtual ~IContext();
4349 
4350  virtual IResultCapture* getResultCapture() = 0;
4351  virtual IRunner* getRunner() = 0;
4352  virtual IConfigPtr const& getConfig() const = 0;
4353  };
4354 
4356  {
4357  virtual ~IMutableContext();
4358  virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
4359  virtual void setRunner( IRunner* runner ) = 0;
4360  virtual void setConfig( IConfigPtr const& config ) = 0;
4361 
4362  private:
4365  friend void cleanUpContext();
4366  static void createContext();
4367  };
4368 
4370  {
4373  // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
4375  }
4376 
4378  {
4379  return getCurrentMutableContext();
4380  }
4381 
4382  void cleanUpContext();
4383 
4384  class SimplePcg32;
4385  SimplePcg32& rng();
4386 }
4387 
4388 // end catch_context.h
4389 // start catch_interfaces_config.h
4390 
4391 // start catch_option.hpp
4392 
4393 namespace Catch {
4394 
4395  // An optional type
4396  template<typename T>
4397  class Option {
4398  public:
4399  Option() : nullableValue( nullptr ) {}
4400  Option( T const& _value )
4401  : nullableValue( new( storage ) T( _value ) )
4402  {}
4403  Option( Option const& _other )
4404  : nullableValue( _other ? new( storage ) T( *_other ) : nullptr )
4405  {}
4406 
4408  reset();
4409  }
4410 
4411  Option& operator= ( Option const& _other ) {
4412  if( &_other != this ) {
4413  reset();
4414  if( _other )
4415  nullableValue = new( storage ) T( *_other );
4416  }
4417  return *this;
4418  }
4419  Option& operator = ( T const& _value ) {
4420  reset();
4421  nullableValue = new( storage ) T( _value );
4422  return *this;
4423  }
4424 
4425  void reset() {
4426  if( nullableValue )
4427  nullableValue->~T();
4428  nullableValue = nullptr;
4429  }
4430 
4431  T& operator*() { return *nullableValue; }
4432  T const& operator*() const { return *nullableValue; }
4433  T* operator->() { return nullableValue; }
4434  const T* operator->() const { return nullableValue; }
4435 
4436  T valueOr( T const& defaultValue ) const {
4437  return nullableValue ? *nullableValue : defaultValue;
4438  }
4439 
4440  bool some() const { return nullableValue != nullptr; }
4441  bool none() const { return nullableValue == nullptr; }
4442 
4443  bool operator !() const { return nullableValue == nullptr; }
4444  explicit operator bool() const {
4445  return some();
4446  }
4447 
4448  private:
4450  alignas(alignof(T)) char storage[sizeof(T)];
4451  };
4452 
4453 } // end namespace Catch
4454 
4455 // end catch_option.hpp
4456 #include <chrono>
4457 #include <iosfwd>
4458 #include <string>
4459 #include <vector>
4460 #include <memory>
4461 
4462 namespace Catch {
4463 
4464  enum class Verbosity {
4465  Quiet = 0,
4466  Normal,
4467  High
4468  };
4469 
4470  struct WarnAbout { enum What {
4471  Nothing = 0x00,
4472  NoAssertions = 0x01,
4473  NoTests = 0x02
4474  }; };
4475 
4476  struct ShowDurations { enum OrNot {
4479  Never
4480  }; };
4481  struct RunTests { enum InWhatOrder {
4484  InRandomOrder
4485  }; };
4486  struct UseColour { enum YesOrNo {
4489  No
4490  }; };
4491  struct WaitForKeypress { enum When {
4493  BeforeStart = 1,
4494  BeforeExit = 2,
4495  BeforeStartAndExit = BeforeStart | BeforeExit
4496  }; };
4497 
4498  class TestSpec;
4499 
4501 
4502  virtual ~IConfig();
4503 
4504  virtual bool allowThrows() const = 0;
4505  virtual std::ostream& stream() const = 0;
4506  virtual std::string name() const = 0;
4507  virtual bool includeSuccessfulResults() const = 0;
4508  virtual bool shouldDebugBreak() const = 0;
4509  virtual bool warnAboutMissingAssertions() const = 0;
4510  virtual bool warnAboutNoTests() const = 0;
4511  virtual int abortAfter() const = 0;
4512  virtual bool showInvisibles() const = 0;
4513  virtual ShowDurations::OrNot showDurations() const = 0;
4514  virtual TestSpec const& testSpec() const = 0;
4515  virtual bool hasTestFilters() const = 0;
4516  virtual std::vector<std::string> const& getTestsOrTags() const = 0;
4517  virtual RunTests::InWhatOrder runOrder() const = 0;
4518  virtual unsigned int rngSeed() const = 0;
4519  virtual UseColour::YesOrNo useColour() const = 0;
4520  virtual std::vector<std::string> const& getSectionsToRun() const = 0;
4521  virtual Verbosity verbosity() const = 0;
4522 
4523  virtual bool benchmarkNoAnalysis() const = 0;
4524  virtual int benchmarkSamples() const = 0;
4525  virtual double benchmarkConfidenceInterval() const = 0;
4526  virtual unsigned int benchmarkResamples() const = 0;
4527  virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0;
4528  };
4529 
4530  using IConfigPtr = std::shared_ptr<IConfig const>;
4531 }
4532 
4533 // end catch_interfaces_config.h
4534 // start catch_random_number_generator.h
4535 
4536 #include <cstdint>
4537 
4538 namespace Catch {
4539 
4540  // This is a simple implementation of C++11 Uniform Random Number
4541  // Generator. It does not provide all operators, because Catch2
4542  // does not use it, but it should behave as expected inside stdlib's
4543  // distributions.
4544  // The implementation is based on the PCG family (http://pcg-random.org)
4545  class SimplePcg32 {
4547  public:
4549  static constexpr result_type (min)() {
4550  return 0;
4551  }
4552  static constexpr result_type (max)() {
4553  return static_cast<result_type>(-1);
4554  }
4555 
4556  // Provide some default initial state for the default constructor
4557  SimplePcg32():SimplePcg32(0xed743cc4U) {}
4558 
4559  explicit SimplePcg32(result_type seed_);
4560 
4561  void seed(result_type seed_);
4562  void discard(uint64_t skip);
4563 
4564  result_type operator()();
4565 
4566  private:
4567  friend bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs);
4568  friend bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs);
4569 
4570  // In theory we also need operator<< and operator>>
4571  // In practice we do not use them, so we will skip them for now
4572 
4574  // This part of the state determines which "stream" of the numbers
4575  // is chosen -- we take it as a constant for Catch2, so we only
4576  // need to deal with seeding the main state.
4577  // Picked by reading 8 bytes from `/dev/random` :-)
4578  static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL;
4579  };
4580 
4581 } // end namespace Catch
4582 
4583 // end catch_random_number_generator.h
4584 #include <random>
4585 
4586 namespace Catch {
4587 namespace Generators {
4588 
4589 template <typename Float>
4590 class RandomFloatingGenerator final : public IGenerator<Float> {
4592  std::uniform_real_distribution<Float> m_dist;
4594 public:
4595 
4596  RandomFloatingGenerator(Float a, Float b):
4597  m_rng(rng()),
4598  m_dist(a, b) {
4599  static_cast<void>(next());
4600  }
4601 
4602  Float const& get() const override {
4603  return m_current_number;
4604  }
4605  bool next() override {
4606  m_current_number = m_dist(m_rng);
4607  return true;
4608  }
4609 };
4610 
4611 template <typename Integer>
4612 class RandomIntegerGenerator final : public IGenerator<Integer> {
4614  std::uniform_int_distribution<Integer> m_dist;
4616 public:
4617 
4618  RandomIntegerGenerator(Integer a, Integer b):
4619  m_rng(rng()),
4620  m_dist(a, b) {
4621  static_cast<void>(next());
4622  }
4623 
4624  Integer const& get() const override {
4625  return m_current_number;
4626  }
4627  bool next() override {
4628  m_current_number = m_dist(m_rng);
4629  return true;
4630  }
4631 };
4632 
4633 // TODO: Ideally this would be also constrained against the various char types,
4634 // but I don't expect users to run into that in practice.
4635 template <typename T>
4638 random(T a, T b) {
4639  return GeneratorWrapper<T>(
4640  pf::make_unique<RandomIntegerGenerator<T>>(a, b)
4641  );
4642 }
4643 
4644 template <typename T>
4647 random(T a, T b) {
4648  return GeneratorWrapper<T>(
4649  pf::make_unique<RandomFloatingGenerator<T>>(a, b)
4650  );
4651 }
4652 
4653 template <typename T>
4654 class RangeGenerator final : public IGenerator<T> {
4659 
4660 public:
4661  RangeGenerator(T const& start, T const& end, T const& step):
4662  m_current(start),
4663  m_end(end),
4664  m_step(step),
4665  m_positive(m_step > T(0))
4666  {
4667  assert(m_current != m_end && "Range start and end cannot be equal");
4668  assert(m_step != T(0) && "Step size cannot be zero");
4669  assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) && "Step moves away from end");
4670  }
4671 
4672  RangeGenerator(T const& start, T const& end):
4673  RangeGenerator(start, end, (start < end) ? T(1) : T(-1))
4674  {}
4675 
4676  T const& get() const override {
4677  return m_current;
4678  }
4679 
4680  bool next() override {
4681  m_current += m_step;
4682  return (m_positive) ? (m_current < m_end) : (m_current > m_end);
4683  }
4684 };
4685 
4686 template <typename T>
4687 GeneratorWrapper<T> range(T const& start, T const& end, T const& step) {
4688  static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric");
4689  return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end, step));
4690 }
4691 
4692 template <typename T>
4693 GeneratorWrapper<T> range(T const& start, T const& end) {
4694  static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer");
4695  return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end));
4696 }
4697 
4698 template <typename T>
4699 class IteratorGenerator final : public IGenerator<T> {
4700  static_assert(!std::is_same<T, bool>::value,
4701  "IteratorGenerator currently does not support bools"
4702  "because of std::vector<bool> specialization");
4703 
4704  std::vector<T> m_elems;
4705  size_t m_current = 0;
4706 public:
4707  template <typename InputIterator, typename InputSentinel>
4708  IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) {
4709  if (m_elems.empty()) {
4710  Catch::throw_exception(GeneratorException("IteratorGenerator received no valid values"));
4711  }
4712  }
4713 
4714  T const& get() const override {
4715  return m_elems[m_current];
4716  }
4717 
4718  bool next() override {
4719  ++m_current;
4720  return m_current != m_elems.size();
4721  }
4722 };
4723 
4724 template <typename InputIterator,
4725  typename InputSentinel,
4726  typename ResultType = typename std::iterator_traits<InputIterator>::value_type>
4727 GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) {
4728  return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(from, to));
4729 }
4730 
4731 template <typename Container,
4732  typename ResultType = typename Container::value_type>
4734  return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end()));
4735 }
4736 
4737 } // namespace Generators
4738 } // namespace Catch
4739 
4740 // end catch_generators_specific.hpp
4741 
4742 // These files are included here so the single_include script doesn't put them
4743 // in the conditionally compiled sections
4744 // start catch_test_case_info.h
4745 
4746 #include <string>
4747 #include <vector>
4748 #include <memory>
4749 
4750 #ifdef __clang__
4751 #pragma clang diagnostic push
4752 #pragma clang diagnostic ignored "-Wpadded"
4753 #endif
4754 
4755 namespace Catch {
4756 
4757  struct ITestInvoker;
4758 
4759  struct TestCaseInfo {
4761  None = 0,
4762  IsHidden = 1 << 1,
4763  ShouldFail = 1 << 2,
4764  MayFail = 1 << 3,
4765  Throws = 1 << 4,
4766  NonPortable = 1 << 5,
4767  Benchmark = 1 << 6
4768  };
4769 
4770  TestCaseInfo( std::string const& _name,
4771  std::string const& _className,
4772  std::string const& _description,
4773  std::vector<std::string> const& _tags,
4774  SourceLineInfo const& _lineInfo );
4775 
4776  friend void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags );
4777 
4778  bool isHidden() const;
4779  bool throws() const;
4780  bool okToFail() const;
4781  bool expectedToFail() const;
4782 
4783  std::string tagsAsString() const;
4784 
4785  std::string name;
4786  std::string className;
4787  std::string description;
4788  std::vector<std::string> tags;
4789  std::vector<std::string> lcaseTags;
4792  };
4793 
4794  class TestCase : public TestCaseInfo {
4795  public:
4796 
4797  TestCase( ITestInvoker* testCase, TestCaseInfo&& info );
4798 
4799  TestCase withName( std::string const& _newName ) const;
4800 
4801  void invoke() const;
4802 
4803  TestCaseInfo const& getTestCaseInfo() const;
4804 
4805  bool operator == ( TestCase const& other ) const;
4806  bool operator < ( TestCase const& other ) const;
4807 
4808  private:
4809  std::shared_ptr<ITestInvoker> test;
4810  };
4811 
4812  TestCase makeTestCase( ITestInvoker* testCase,
4813  std::string const& className,
4814  NameAndTags const& nameAndTags,
4815  SourceLineInfo const& lineInfo );
4816 }
4817 
4818 #ifdef __clang__
4819 #pragma clang diagnostic pop
4820 #endif
4821 
4822 // end catch_test_case_info.h
4823 // start catch_interfaces_runner.h
4824 
4825 namespace Catch {
4826 
4827  struct IRunner {
4828  virtual ~IRunner();
4829  virtual bool aborting() const = 0;
4830  };
4831 }
4832 
4833 // end catch_interfaces_runner.h
4834 
4835 #ifdef __OBJC__
4836 // start catch_objc.hpp
4837 
4838 #import <objc/runtime.h>
4839 
4840 #include <string>
4841 
4842 // NB. Any general catch headers included here must be included
4843 // in catch.hpp first to make sure they are included by the single
4844 // header for non obj-usage
4845 
4847 // This protocol is really only here for (self) documenting purposes, since
4848 // all its methods are optional.
4849 @protocol OcFixture
4850 
4851 @optional
4852 
4853 -(void) setUp;
4854 -(void) tearDown;
4855 
4856 @end
4857 
4858 namespace Catch {
4859 
4860  class OcMethod : public ITestInvoker {
4861 
4862  public:
4863  OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}
4864 
4865  virtual void invoke() const {
4866  id obj = [[m_cls alloc] init];
4867 
4868  performOptionalSelector( obj, @selector(setUp) );
4869  performOptionalSelector( obj, m_sel );
4870  performOptionalSelector( obj, @selector(tearDown) );
4871 
4872  arcSafeRelease( obj );
4873  }
4874  private:
4875  virtual ~OcMethod() {}
4876 
4877  Class m_cls;
4878  SEL m_sel;
4879  };
4880 
4881  namespace Detail{
4882 
4883  inline std::string getAnnotation( Class cls,
4884  std::string const& annotationName,
4885  std::string const& testCaseName ) {
4886  NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
4887  SEL sel = NSSelectorFromString( selStr );
4888  arcSafeRelease( selStr );
4889  id value = performOptionalSelector( cls, sel );
4890  if( value )
4891  return [(NSString*)value UTF8String];
4892  return "";
4893  }
4894  }
4895 
4896  inline std::size_t registerTestMethods() {
4897  std::size_t noTestMethods = 0;
4898  int noClasses = objc_getClassList( nullptr, 0 );
4899 
4900  Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
4901  objc_getClassList( classes, noClasses );
4902 
4903  for( int c = 0; c < noClasses; c++ ) {
4904  Class cls = classes[c];
4905  {
4906  u_int count;
4907  Method* methods = class_copyMethodList( cls, &count );
4908  for( u_int m = 0; m < count ; m++ ) {
4909  SEL selector = method_getName(methods[m]);
4910  std::string methodName = sel_getName(selector);
4911  if( startsWith( methodName, "Catch_TestCase_" ) ) {
4912  std::string testCaseName = methodName.substr( 15 );
4913  std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
4914  std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
4915  const char* className = class_getName( cls );
4916 
4917  getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo("",0) ) );
4918  noTestMethods++;
4919  }
4920  }
4921  free(methods);
4922  }
4923  }
4924  return noTestMethods;
4925  }
4926 
4927 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
4928 
4929  namespace Matchers {
4930  namespace Impl {
4931  namespace NSStringMatchers {
4932 
4933  struct StringHolder : MatcherBase<NSString*>{
4934  StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
4935  StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
4936  StringHolder() {
4937  arcSafeRelease( m_substr );
4938  }
4939 
4940  bool match( NSString* str ) const override {
4941  return false;
4942  }
4943 
4944  NSString* CATCH_ARC_STRONG m_substr;
4945  };
4946 
4947  struct Equals : StringHolder {
4948  Equals( NSString* substr ) : StringHolder( substr ){}
4949 
4950  bool match( NSString* str ) const override {
4951  return (str != nil || m_substr == nil ) &&
4952  [str isEqualToString:m_substr];
4953  }
4954 
4955  std::string describe() const override {
4956  return "equals string: " + Catch::Detail::stringify( m_substr );
4957  }
4958  };
4959 
4960  struct Contains : StringHolder {
4961  Contains( NSString* substr ) : StringHolder( substr ){}
4962 
4963  bool match( NSString* str ) const override {
4964  return (str != nil || m_substr == nil ) &&
4965  [str rangeOfString:m_substr].location != NSNotFound;
4966  }
4967 
4968  std::string describe() const override {
4969  return "contains string: " + Catch::Detail::stringify( m_substr );
4970  }
4971  };
4972 
4973  struct StartsWith : StringHolder {
4974  StartsWith( NSString* substr ) : StringHolder( substr ){}
4975 
4976  bool match( NSString* str ) const override {
4977  return (str != nil || m_substr == nil ) &&
4978  [str rangeOfString:m_substr].location == 0;
4979  }
4980 
4981  std::string describe() const override {
4982  return "starts with: " + Catch::Detail::stringify( m_substr );
4983  }
4984  };
4985  struct EndsWith : StringHolder {
4986  EndsWith( NSString* substr ) : StringHolder( substr ){}
4987 
4988  bool match( NSString* str ) const override {
4989  return (str != nil || m_substr == nil ) &&
4990  [str rangeOfString:m_substr].location == [str length] - [m_substr length];
4991  }
4992 
4993  std::string describe() const override {
4994  return "ends with: " + Catch::Detail::stringify( m_substr );
4995  }
4996  };
4997 
4998  } // namespace NSStringMatchers
4999  } // namespace Impl
5000 
5002  Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); }
5003 
5005  Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); }
5006 
5008  StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); }
5009 
5011  EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); }
5012 
5013  } // namespace Matchers
5014 
5015  using namespace Matchers;
5016 
5017 #endif // CATCH_CONFIG_DISABLE_MATCHERS
5018 
5019 } // namespace Catch
5020 
5022 #define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix
5023 #define OC_TEST_CASE2( name, desc, uniqueSuffix ) \
5024 +(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \
5025 { \
5026 return @ name; \
5027 } \
5028 +(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \
5029 { \
5030 return @ desc; \
5031 } \
5032 -(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix )
5033 
5034 #define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ )
5035 
5036 // end catch_objc.hpp
5037 #endif
5038 
5039 // Benchmarking needs the externally-facing parts of reporters to work
5040 #if defined(CATCH_CONFIG_EXTERNAL_INTERFACES) || defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
5041 // start catch_external_interfaces.h
5042 
5043 // start catch_reporter_bases.hpp
5044 
5045 // start catch_interfaces_reporter.h
5046 
5047 // start catch_config.hpp
5048 
5049 // start catch_test_spec_parser.h
5050 
5051 #ifdef __clang__
5052 #pragma clang diagnostic push
5053 #pragma clang diagnostic ignored "-Wpadded"
5054 #endif
5055 
5056 // start catch_test_spec.h
5057 
5058 #ifdef __clang__
5059 #pragma clang diagnostic push
5060 #pragma clang diagnostic ignored "-Wpadded"
5061 #endif
5062 
5063 // start catch_wildcard_pattern.h
5064 
5065 namespace Catch
5066 {
5067  class WildcardPattern {
5068  enum WildcardPosition {
5069  NoWildcard = 0,
5070  WildcardAtStart = 1,
5071  WildcardAtEnd = 2,
5072  WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
5073  };
5074 
5075  public:
5076 
5077  WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity );
5078  virtual ~WildcardPattern() = default;
5079  virtual bool matches( std::string const& str ) const;
5080 
5081  private:
5082  std::string normaliseString( std::string const& str ) const;
5083  CaseSensitive::Choice m_caseSensitivity;
5084  WildcardPosition m_wildcard = NoWildcard;
5085  std::string m_pattern;
5086  };
5087 }
5088 
5089 // end catch_wildcard_pattern.h
5090 #include <string>
5091 #include <vector>
5092 #include <memory>
5093 
5094 namespace Catch {
5095 
5096  struct IConfig;
5097 
5098  class TestSpec {
5099  class Pattern {
5100  public:
5101  explicit Pattern( std::string const& name );
5102  virtual ~Pattern();
5103  virtual bool matches( TestCaseInfo const& testCase ) const = 0;
5104  std::string const& name() const;
5105  private:
5106  std::string const m_name;
5107  };
5108  using PatternPtr = std::shared_ptr<Pattern>;
5109 
5110  class NamePattern : public Pattern {
5111  public:
5112  explicit NamePattern( std::string const& name, std::string const& filterString );
5113  bool matches( TestCaseInfo const& testCase ) const override;
5114  private:
5115  WildcardPattern m_wildcardPattern;
5116  };
5117 
5118  class TagPattern : public Pattern {
5119  public:
5120  explicit TagPattern( std::string const& tag, std::string const& filterString );
5121  bool matches( TestCaseInfo const& testCase ) const override;
5122  private:
5123  std::string m_tag;
5124  };
5125 
5126  class ExcludedPattern : public Pattern {
5127  public:
5128  explicit ExcludedPattern( PatternPtr const& underlyingPattern );
5129  bool matches( TestCaseInfo const& testCase ) const override;
5130  private:
5131  PatternPtr m_underlyingPattern;
5132  };
5133 
5134  struct Filter {
5135  std::vector<PatternPtr> m_patterns;
5136 
5137  bool matches( TestCaseInfo const& testCase ) const;
5138  std::string name() const;
5139  };
5140 
5141  public:
5142  struct FilterMatch {
5143  std::string name;
5144  std::vector<TestCase const*> tests;
5145  };
5146  using Matches = std::vector<FilterMatch>;
5147  using vectorStrings = std::vector<std::string>;
5148 
5149  bool hasFilters() const;
5150  bool matches( TestCaseInfo const& testCase ) const;
5151  Matches matchesByFilter( std::vector<TestCase> const& testCases, IConfig const& config ) const;
5152  const vectorStrings & getInvalidArgs() const;
5153 
5154  private:
5155  std::vector<Filter> m_filters;
5156  std::vector<std::string> m_invalidArgs;
5157  friend class TestSpecParser;
5158  };
5159 }
5160 
5161 #ifdef __clang__
5162 #pragma clang diagnostic pop
5163 #endif
5164 
5165 // end catch_test_spec.h
5166 // start catch_interfaces_tag_alias_registry.h
5167 
5168 #include <string>
5169 
5170 namespace Catch {
5171 
5172  struct TagAlias;
5173 
5174  struct ITagAliasRegistry {
5175  virtual ~ITagAliasRegistry();
5176  // Nullptr if not present
5177  virtual TagAlias const* find( std::string const& alias ) const = 0;
5178  virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0;
5179 
5180  static ITagAliasRegistry const& get();
5181  };
5182 
5183 } // end namespace Catch
5184 
5185 // end catch_interfaces_tag_alias_registry.h
5186 namespace Catch {
5187 
5188  class TestSpecParser {
5189  enum Mode{ None, Name, QuotedName, Tag, EscapedName };
5190  Mode m_mode = None;
5191  Mode lastMode = None;
5192  bool m_exclusion = false;
5193  std::size_t m_pos = 0;
5194  std::size_t m_realPatternPos = 0;
5195  std::string m_arg;
5196  std::string m_substring;
5197  std::string m_patternName;
5198  std::vector<std::size_t> m_escapeChars;
5199  TestSpec::Filter m_currentFilter;
5200  TestSpec m_testSpec;
5201  ITagAliasRegistry const* m_tagAliases = nullptr;
5202 
5203  public:
5204  TestSpecParser( ITagAliasRegistry const& tagAliases );
5205 
5206  TestSpecParser& parse( std::string const& arg );
5207  TestSpec testSpec();
5208 
5209  private:
5210  bool visitChar( char c );
5211  void startNewMode( Mode mode );
5212  bool processNoneChar( char c );
5213  void processNameChar( char c );
5214  bool processOtherChar( char c );
5215  void endMode();
5216  void escape();
5217  bool isControlChar( char c ) const;
5218  void saveLastMode();
5219  void revertBackToLastMode();
5220  void addFilter();
5221  bool separate();
5222 
5223  // Handles common preprocessing of the pattern for name/tag patterns
5224  std::string preprocessPattern();
5225  // Adds the current pattern as a test name
5226  void addNamePattern();
5227  // Adds the current pattern as a tag
5228  void addTagPattern();
5229 
5230  inline void addCharToPattern(char c) {
5231  m_substring += c;
5232  m_patternName += c;
5233  m_realPatternPos++;
5234  }
5235 
5236  };
5237  TestSpec parseTestSpec( std::string const& arg );
5238 
5239 } // namespace Catch
5240 
5241 #ifdef __clang__
5242 #pragma clang diagnostic pop
5243 #endif
5244 
5245 // end catch_test_spec_parser.h
5246 // Libstdc++ doesn't like incomplete classes for unique_ptr
5247 
5248 #include <memory>
5249 #include <vector>
5250 #include <string>
5251 
5252 #ifndef CATCH_CONFIG_CONSOLE_WIDTH
5253 #define CATCH_CONFIG_CONSOLE_WIDTH 80
5254 #endif
5255 
5256 namespace Catch {
5257 
5258  struct IStream;
5259 
5260  struct ConfigData {
5261  bool listTests = false;
5262  bool listTags = false;
5263  bool listReporters = false;
5264  bool listTestNamesOnly = false;
5265 
5266  bool showSuccessfulTests = false;
5267  bool shouldDebugBreak = false;
5268  bool noThrow = false;
5269  bool showHelp = false;
5270  bool showInvisibles = false;
5271  bool filenamesAsTags = false;
5272  bool libIdentify = false;
5273 
5274  int abortAfter = -1;
5275  unsigned int rngSeed = 0;
5276 
5277  bool benchmarkNoAnalysis = false;
5278  unsigned int benchmarkSamples = 100;
5279  double benchmarkConfidenceInterval = 0.95;
5280  unsigned int benchmarkResamples = 100000;
5281  std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
5282 
5283  Verbosity verbosity = Verbosity::Normal;
5287  UseColour::YesOrNo useColour = UseColour::Auto;
5289 
5290  std::string outputFilename;
5291  std::string name;
5292  std::string processName;
5293 #ifndef CATCH_CONFIG_DEFAULT_REPORTER
5294 #define CATCH_CONFIG_DEFAULT_REPORTER "console"
5295 #endif
5296  std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER;
5297 #undef CATCH_CONFIG_DEFAULT_REPORTER
5298 
5299  std::vector<std::string> testsOrTags;
5300  std::vector<std::string> sectionsToRun;
5301  };
5302 
5303  class Config : public IConfig {
5304  public:
5305 
5306  Config() = default;
5307  Config( ConfigData const& data );
5308  virtual ~Config() = default;
5309 
5310  std::string const& getFilename() const;
5311 
5312  bool listTests() const;
5313  bool listTestNamesOnly() const;
5314  bool listTags() const;
5315  bool listReporters() const;
5316 
5317  std::string getProcessName() const;
5318  std::string const& getReporterName() const;
5319 
5320  std::vector<std::string> const& getTestsOrTags() const override;
5321  std::vector<std::string> const& getSectionsToRun() const override;
5322 
5323  TestSpec const& testSpec() const override;
5324  bool hasTestFilters() const override;
5325 
5326  bool showHelp() const;
5327 
5328  // IConfig interface
5329  bool allowThrows() const override;
5330  std::ostream& stream() const override;
5331  std::string name() const override;
5332  bool includeSuccessfulResults() const override;
5333  bool warnAboutMissingAssertions() const override;
5334  bool warnAboutNoTests() const override;
5335  ShowDurations::OrNot showDurations() const override;
5336  RunTests::InWhatOrder runOrder() const override;
5337  unsigned int rngSeed() const override;
5338  UseColour::YesOrNo useColour() const override;
5339  bool shouldDebugBreak() const override;
5340  int abortAfter() const override;
5341  bool showInvisibles() const override;
5342  Verbosity verbosity() const override;
5343  bool benchmarkNoAnalysis() const override;
5344  int benchmarkSamples() const override;
5345  double benchmarkConfidenceInterval() const override;
5346  unsigned int benchmarkResamples() const override;
5347  std::chrono::milliseconds benchmarkWarmupTime() const override;
5348 
5349  private:
5350 
5351  IStream const* openStream();
5352  ConfigData m_data;
5353 
5354  std::unique_ptr<IStream const> m_stream;
5355  TestSpec m_testSpec;
5356  bool m_hasTestFilters = false;
5357  };
5358 
5359 } // end namespace Catch
5360 
5361 // end catch_config.hpp
5362 // start catch_assertionresult.h
5363 
5364 #include <string>
5365 
5366 namespace Catch {
5367 
5368  struct AssertionResultData
5369  {
5370  AssertionResultData() = delete;
5371 
5372  AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression );
5373 
5374  std::string message;
5375  mutable std::string reconstructedExpression;
5376  LazyExpression lazyExpression;
5377  ResultWas::OfType resultType;
5378 
5379  std::string reconstructExpression() const;
5380  };
5381 
5382  class AssertionResult {
5383  public:
5384  AssertionResult() = delete;
5385  AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
5386 
5387  bool isOk() const;
5388  bool succeeded() const;
5389  ResultWas::OfType getResultType() const;
5390  bool hasExpression() const;
5391  bool hasMessage() const;
5392  std::string getExpression() const;
5393  std::string getExpressionInMacro() const;
5394  bool hasExpandedExpression() const;
5395  std::string getExpandedExpression() const;
5396  std::string getMessage() const;
5397  SourceLineInfo getSourceInfo() const;
5398  StringRef getTestMacroName() const;
5399 
5400  //protected:
5401  AssertionInfo m_info;
5402  AssertionResultData m_resultData;
5403  };
5404 
5405 } // end namespace Catch
5406 
5407 // end catch_assertionresult.h
5408 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
5409 // start catch_estimate.hpp
5410 
5411  // Statistics estimates
5412 
5413 
5414 namespace Catch {
5415  namespace Benchmark {
5416  template <typename Duration>
5417  struct Estimate {
5418  Duration point;
5419  Duration lower_bound;
5420  Duration upper_bound;
5421  double confidence_interval;
5422 
5423  template <typename Duration2>
5424  operator Estimate<Duration2>() const {
5425  return { point, lower_bound, upper_bound, confidence_interval };
5426  }
5427  };
5428  } // namespace Benchmark
5429 } // namespace Catch
5430 
5431 // end catch_estimate.hpp
5432 // start catch_outlier_classification.hpp
5433 
5434 // Outlier information
5435 
5436 namespace Catch {
5437  namespace Benchmark {
5438  struct OutlierClassification {
5439  int samples_seen = 0;
5440  int low_severe = 0; // more than 3 times IQR below Q1
5441  int low_mild = 0; // 1.5 to 3 times IQR below Q1
5442  int high_mild = 0; // 1.5 to 3 times IQR above Q3
5443  int high_severe = 0; // more than 3 times IQR above Q3
5444 
5445  int total() const {
5446  return low_severe + low_mild + high_mild + high_severe;
5447  }
5448  };
5449  } // namespace Benchmark
5450 } // namespace Catch
5451 
5452 // end catch_outlier_classification.hpp
5453 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
5454 
5455 #include <string>
5456 #include <iosfwd>
5457 #include <map>
5458 #include <set>
5459 #include <memory>
5460 #include <algorithm>
5461 
5462 namespace Catch {
5463 
5464  struct ReporterConfig {
5465  explicit ReporterConfig( IConfigPtr const& _fullConfig );
5466 
5467  ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream );
5468 
5469  std::ostream& stream() const;
5470  IConfigPtr fullConfig() const;
5471 
5472  private:
5473  std::ostream* m_stream;
5474  IConfigPtr m_fullConfig;
5475  };
5476 
5477  struct ReporterPreferences {
5478  bool shouldRedirectStdOut = false;
5479  bool shouldReportAllAssertions = false;
5480  };
5481 
5482  template<typename T>
5483  struct LazyStat : Option<T> {
5484  LazyStat& operator=( T const& _value ) {
5485  Option<T>::operator=( _value );
5486  used = false;
5487  return *this;
5488  }
5489  void reset() {
5490  Option<T>::reset();
5491  used = false;
5492  }
5493  bool used = false;
5494  };
5495 
5496  struct TestRunInfo {
5497  TestRunInfo( std::string const& _name );
5498  std::string name;
5499  };
5500  struct GroupInfo {
5501  GroupInfo( std::string const& _name,
5502  std::size_t _groupIndex,
5503  std::size_t _groupsCount );
5504 
5505  std::string name;
5506  std::size_t groupIndex;
5507  std::size_t groupsCounts;
5508  };
5509 
5510  struct AssertionStats {
5511  AssertionStats( AssertionResult const& _assertionResult,
5512  std::vector<MessageInfo> const& _infoMessages,
5513  Totals const& _totals );
5514 
5515  AssertionStats( AssertionStats const& ) = default;
5516  AssertionStats( AssertionStats && ) = default;
5517  AssertionStats& operator = ( AssertionStats const& ) = delete;
5518  AssertionStats& operator = ( AssertionStats && ) = delete;
5519  virtual ~AssertionStats();
5520 
5521  AssertionResult assertionResult;
5522  std::vector<MessageInfo> infoMessages;
5523  Totals totals;
5524  };
5525 
5526  struct SectionStats {
5527  SectionStats( SectionInfo const& _sectionInfo,
5528  Counts const& _assertions,
5529  double _durationInSeconds,
5530  bool _missingAssertions );
5531  SectionStats( SectionStats const& ) = default;
5532  SectionStats( SectionStats && ) = default;
5533  SectionStats& operator = ( SectionStats const& ) = default;
5534  SectionStats& operator = ( SectionStats && ) = default;
5535  virtual ~SectionStats();
5536 
5537  SectionInfo sectionInfo;
5538  Counts assertions;
5539  double durationInSeconds;
5540  bool missingAssertions;
5541  };
5542 
5543  struct TestCaseStats {
5544  TestCaseStats( TestCaseInfo const& _testInfo,
5545  Totals const& _totals,
5546  std::string const& _stdOut,
5547  std::string const& _stdErr,
5548  bool _aborting );
5549 
5550  TestCaseStats( TestCaseStats const& ) = default;
5551  TestCaseStats( TestCaseStats && ) = default;
5552  TestCaseStats& operator = ( TestCaseStats const& ) = default;
5553  TestCaseStats& operator = ( TestCaseStats && ) = default;
5554  virtual ~TestCaseStats();
5555 
5556  TestCaseInfo testInfo;
5557  Totals totals;
5558  std::string stdOut;
5559  std::string stdErr;
5560  bool aborting;
5561  };
5562 
5563  struct TestGroupStats {
5564  TestGroupStats( GroupInfo const& _groupInfo,
5565  Totals const& _totals,
5566  bool _aborting );
5567  TestGroupStats( GroupInfo const& _groupInfo );
5568 
5569  TestGroupStats( TestGroupStats const& ) = default;
5570  TestGroupStats( TestGroupStats && ) = default;
5571  TestGroupStats& operator = ( TestGroupStats const& ) = default;
5572  TestGroupStats& operator = ( TestGroupStats && ) = default;
5573  virtual ~TestGroupStats();
5574 
5575  GroupInfo groupInfo;
5576  Totals totals;
5577  bool aborting;
5578  };
5579 
5580  struct TestRunStats {
5581  TestRunStats( TestRunInfo const& _runInfo,
5582  Totals const& _totals,
5583  bool _aborting );
5584 
5585  TestRunStats( TestRunStats const& ) = default;
5586  TestRunStats( TestRunStats && ) = default;
5587  TestRunStats& operator = ( TestRunStats const& ) = default;
5588  TestRunStats& operator = ( TestRunStats && ) = default;
5589  virtual ~TestRunStats();
5590 
5591  TestRunInfo runInfo;
5592  Totals totals;
5593  bool aborting;
5594  };
5595 
5596 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
5597  struct BenchmarkInfo {
5598  std::string name;
5599  double estimatedDuration;
5600  int iterations;
5601  int samples;
5602  unsigned int resamples;
5603  double clockResolution;
5604  double clockCost;
5605  };
5606 
5607  template <class Duration>
5608  struct BenchmarkStats {
5609  BenchmarkInfo info;
5610 
5611  std::vector<Duration> samples;
5612  Benchmark::Estimate<Duration> mean;
5613  Benchmark::Estimate<Duration> standardDeviation;
5614  Benchmark::OutlierClassification outliers;
5615  double outlierVariance;
5616 
5617  template <typename Duration2>
5618  operator BenchmarkStats<Duration2>() const {
5619  std::vector<Duration2> samples2;
5620  samples2.reserve(samples.size());
5621  std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
5622  return {
5623  info,
5624  std::move(samples2),
5625  mean,
5626  standardDeviation,
5627  outliers,
5628  outlierVariance,
5629  };
5630  }
5631  };
5632 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
5633 
5634  struct IStreamingReporter {
5635  virtual ~IStreamingReporter() = default;
5636 
5637  // Implementing class must also provide the following static methods:
5638  // static std::string getDescription();
5639  // static std::set<Verbosity> getSupportedVerbosities()
5640 
5641  virtual ReporterPreferences getPreferences() const = 0;
5642 
5643  virtual void noMatchingTestCases( std::string const& spec ) = 0;
5644 
5645  virtual void reportInvalidArguments(std::string const&) {}
5646 
5647  virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
5648  virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;
5649 
5650  virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
5651  virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
5652 
5653 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
5654  virtual void benchmarkPreparing( std::string const& ) {}
5655  virtual void benchmarkStarting( BenchmarkInfo const& ) {}
5656  virtual void benchmarkEnded( BenchmarkStats<> const& ) {}
5657  virtual void benchmarkFailed( std::string const& ) {}
5658 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
5659 
5660  virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
5661 
5662  // The return value indicates if the messages buffer should be cleared:
5663  virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
5664 
5665  virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
5666  virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
5667  virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
5668  virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
5669 
5670  virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
5671 
5672  // Default empty implementation provided
5673  virtual void fatalErrorEncountered( StringRef name );
5674 
5675  virtual bool isMulti() const;
5676  };
5677  using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
5678 
5679  struct IReporterFactory {
5680  virtual ~IReporterFactory();
5681  virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0;
5682  virtual std::string getDescription() const = 0;
5683  };
5684  using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;
5685 
5686  struct IReporterRegistry {
5687  using FactoryMap = std::map<std::string, IReporterFactoryPtr>;
5688  using Listeners = std::vector<IReporterFactoryPtr>;
5689 
5690  virtual ~IReporterRegistry();
5691  virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0;
5692  virtual FactoryMap const& getFactories() const = 0;
5693  virtual Listeners const& getListeners() const = 0;
5694  };
5695 
5696 } // end namespace Catch
5697 
5698 // end catch_interfaces_reporter.h
5699 #include <algorithm>
5700 #include <cstring>
5701 #include <cfloat>
5702 #include <cstdio>
5703 #include <cassert>
5704 #include <memory>
5705 #include <ostream>
5706 
5707 namespace Catch {
5708  void prepareExpandedExpression(AssertionResult& result);
5709 
5710  // Returns double formatted as %.3f (format expected on output)
5711  std::string getFormattedDuration( double duration );
5712 
5713  std::string serializeFilters( std::vector<std::string> const& container );
5714 
5715  template<typename DerivedT>
5716  struct StreamingReporterBase : IStreamingReporter {
5717 
5718  StreamingReporterBase( ReporterConfig const& _config )
5719  : m_config( _config.fullConfig() ),
5720  stream( _config.stream() )
5721  {
5722  m_reporterPrefs.shouldRedirectStdOut = false;
5723  if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) )
5724  CATCH_ERROR( "Verbosity level not supported by this reporter" );
5725  }
5726 
5727  ReporterPreferences getPreferences() const override {
5728  return m_reporterPrefs;
5729  }
5730 
5731  static std::set<Verbosity> getSupportedVerbosities() {
5732  return { Verbosity::Normal };
5733  }
5734 
5735  ~StreamingReporterBase() override = default;
5736 
5737  void noMatchingTestCases(std::string const&) override {}
5738 
5739  void reportInvalidArguments(std::string const&) override {}
5740 
5741  void testRunStarting(TestRunInfo const& _testRunInfo) override {
5742  currentTestRunInfo = _testRunInfo;
5743  }
5744 
5745  void testGroupStarting(GroupInfo const& _groupInfo) override {
5746  currentGroupInfo = _groupInfo;
5747  }
5748 
5749  void testCaseStarting(TestCaseInfo const& _testInfo) override {
5750  currentTestCaseInfo = _testInfo;
5751  }
5752  void sectionStarting(SectionInfo const& _sectionInfo) override {
5753  m_sectionStack.push_back(_sectionInfo);
5754  }
5755 
5756  void sectionEnded(SectionStats const& /* _sectionStats */) override {
5757  m_sectionStack.pop_back();
5758  }
5759  void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override {
5760  currentTestCaseInfo.reset();
5761  }
5762  void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override {
5763  currentGroupInfo.reset();
5764  }
5765  void testRunEnded(TestRunStats const& /* _testRunStats */) override {
5766  currentTestCaseInfo.reset();
5767  currentGroupInfo.reset();
5768  currentTestRunInfo.reset();
5769  }
5770 
5771  void skipTest(TestCaseInfo const&) override {
5772  // Don't do anything with this by default.
5773  // It can optionally be overridden in the derived class.
5774  }
5775 
5776  IConfigPtr m_config;
5777  std::ostream& stream;
5778 
5779  LazyStat<TestRunInfo> currentTestRunInfo;
5780  LazyStat<GroupInfo> currentGroupInfo;
5781  LazyStat<TestCaseInfo> currentTestCaseInfo;
5782 
5783  std::vector<SectionInfo> m_sectionStack;
5784  ReporterPreferences m_reporterPrefs;
5785  };
5786 
5787  template<typename DerivedT>
5788  struct CumulativeReporterBase : IStreamingReporter {
5789  template<typename T, typename ChildNodeT>
5790  struct Node {
5791  explicit Node( T const& _value ) : value( _value ) {}
5792  virtual ~Node() {}
5793 
5794  using ChildNodes = std::vector<std::shared_ptr<ChildNodeT>>;
5795  T value;
5796  ChildNodes children;
5797  };
5798  struct SectionNode {
5799  explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}
5800  virtual ~SectionNode() = default;
5801 
5802  bool operator == (SectionNode const& other) const {
5803  return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
5804  }
5805  bool operator == (std::shared_ptr<SectionNode> const& other) const {
5806  return operator==(*other);
5807  }
5808 
5809  SectionStats stats;
5810  using ChildSections = std::vector<std::shared_ptr<SectionNode>>;
5811  using Assertions = std::vector<AssertionStats>;
5812  ChildSections childSections;
5813  Assertions assertions;
5814  std::string stdOut;
5815  std::string stdErr;
5816  };
5817 
5818  struct BySectionInfo {
5819  BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
5820  BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
5821  bool operator() (std::shared_ptr<SectionNode> const& node) const {
5822  return ((node->stats.sectionInfo.name == m_other.name) &&
5823  (node->stats.sectionInfo.lineInfo == m_other.lineInfo));
5824  }
5825  void operator=(BySectionInfo const&) = delete;
5826 
5827  private:
5828  SectionInfo const& m_other;
5829  };
5830 
5831  using TestCaseNode = Node<TestCaseStats, SectionNode>;
5832  using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
5833  using TestRunNode = Node<TestRunStats, TestGroupNode>;
5834 
5835  CumulativeReporterBase( ReporterConfig const& _config )
5836  : m_config( _config.fullConfig() ),
5837  stream( _config.stream() )
5838  {
5839  m_reporterPrefs.shouldRedirectStdOut = false;
5840  if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) )
5841  CATCH_ERROR( "Verbosity level not supported by this reporter" );
5842  }
5843  ~CumulativeReporterBase() override = default;
5844 
5845  ReporterPreferences getPreferences() const override {
5846  return m_reporterPrefs;
5847  }
5848 
5849  static std::set<Verbosity> getSupportedVerbosities() {
5850  return { Verbosity::Normal };
5851  }
5852 
5853  void testRunStarting( TestRunInfo const& ) override {}
5854  void testGroupStarting( GroupInfo const& ) override {}
5855 
5856  void testCaseStarting( TestCaseInfo const& ) override {}
5857 
5858  void sectionStarting( SectionInfo const& sectionInfo ) override {
5859  SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
5860  std::shared_ptr<SectionNode> node;
5861  if( m_sectionStack.empty() ) {
5862  if( !m_rootSection )
5863  m_rootSection = std::make_shared<SectionNode>( incompleteStats );
5864  node = m_rootSection;
5865  }
5866  else {
5867  SectionNode& parentNode = *m_sectionStack.back();
5868  auto it =
5869  std::find_if( parentNode.childSections.begin(),
5870  parentNode.childSections.end(),
5871  BySectionInfo( sectionInfo ) );
5872  if( it == parentNode.childSections.end() ) {
5873  node = std::make_shared<SectionNode>( incompleteStats );
5874  parentNode.childSections.push_back( node );
5875  }
5876  else
5877  node = *it;
5878  }
5879  m_sectionStack.push_back( node );
5880  m_deepestSection = std::move(node);
5881  }
5882 
5883  void assertionStarting(AssertionInfo const&) override {}
5884 
5885  bool assertionEnded(AssertionStats const& assertionStats) override {
5886  assert(!m_sectionStack.empty());
5887  // AssertionResult holds a pointer to a temporary DecomposedExpression,
5888  // which getExpandedExpression() calls to build the expression string.
5889  // Our section stack copy of the assertionResult will likely outlive the
5890  // temporary, so it must be expanded or discarded now to avoid calling
5891  // a destroyed object later.
5892  prepareExpandedExpression(const_cast<AssertionResult&>( assertionStats.assertionResult ) );
5893  SectionNode& sectionNode = *m_sectionStack.back();
5894  sectionNode.assertions.push_back(assertionStats);
5895  return true;
5896  }
5897  void sectionEnded(SectionStats const& sectionStats) override {
5898  assert(!m_sectionStack.empty());
5899  SectionNode& node = *m_sectionStack.back();
5900  node.stats = sectionStats;
5901  m_sectionStack.pop_back();
5902  }
5903  void testCaseEnded(TestCaseStats const& testCaseStats) override {
5904  auto node = std::make_shared<TestCaseNode>(testCaseStats);
5905  assert(m_sectionStack.size() == 0);
5906  node->children.push_back(m_rootSection);
5907  m_testCases.push_back(node);
5908  m_rootSection.reset();
5909 
5910  assert(m_deepestSection);
5911  m_deepestSection->stdOut = testCaseStats.stdOut;
5912  m_deepestSection->stdErr = testCaseStats.stdErr;
5913  }
5914  void testGroupEnded(TestGroupStats const& testGroupStats) override {
5915  auto node = std::make_shared<TestGroupNode>(testGroupStats);
5916  node->children.swap(m_testCases);
5917  m_testGroups.push_back(node);
5918  }
5919  void testRunEnded(TestRunStats const& testRunStats) override {
5920  auto node = std::make_shared<TestRunNode>(testRunStats);
5921  node->children.swap(m_testGroups);
5922  m_testRuns.push_back(node);
5923  testRunEndedCumulative();
5924  }
5925  virtual void testRunEndedCumulative() = 0;
5926 
5927  void skipTest(TestCaseInfo const&) override {}
5928 
5929  IConfigPtr m_config;
5930  std::ostream& stream;
5931  std::vector<AssertionStats> m_assertions;
5932  std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections;
5933  std::vector<std::shared_ptr<TestCaseNode>> m_testCases;
5934  std::vector<std::shared_ptr<TestGroupNode>> m_testGroups;
5935 
5936  std::vector<std::shared_ptr<TestRunNode>> m_testRuns;
5937 
5938  std::shared_ptr<SectionNode> m_rootSection;
5939  std::shared_ptr<SectionNode> m_deepestSection;
5940  std::vector<std::shared_ptr<SectionNode>> m_sectionStack;
5941  ReporterPreferences m_reporterPrefs;
5942  };
5943 
5944  template<char C>
5945  char const* getLineOfChars() {
5946  static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
5947  if( !*line ) {
5948  std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
5949  line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
5950  }
5951  return line;
5952  }
5953 
5954  struct TestEventListenerBase : StreamingReporterBase<TestEventListenerBase> {
5955  TestEventListenerBase( ReporterConfig const& _config );
5956 
5957  static std::set<Verbosity> getSupportedVerbosities();
5958 
5959  void assertionStarting(AssertionInfo const&) override;
5960  bool assertionEnded(AssertionStats const&) override;
5961  };
5962 
5963 } // end namespace Catch
5964 
5965 // end catch_reporter_bases.hpp
5966 // start catch_console_colour.h
5967 
5968 namespace Catch {
5969 
5970  struct Colour {
5971  enum Code {
5972  None = 0,
5973 
5974  White,
5975  Red,
5976  Green,
5977  Blue,
5978  Cyan,
5979  Yellow,
5980  Grey,
5981 
5982  Bright = 0x10,
5983 
5984  BrightRed = Bright | Red,
5985  BrightGreen = Bright | Green,
5986  LightGrey = Bright | Grey,
5987  BrightWhite = Bright | White,
5988  BrightYellow = Bright | Yellow,
5989 
5990  // By intention
5991  FileName = LightGrey,
5992  Warning = BrightYellow,
5993  ResultError = BrightRed,
5994  ResultSuccess = BrightGreen,
5995  ResultExpectedFailure = Warning,
5996 
5997  Error = BrightRed,
5998  Success = Green,
5999 
6000  OriginalExpression = Cyan,
6001  ReconstructedExpression = BrightYellow,
6002 
6003  SecondaryText = LightGrey,
6004  Headers = White
6005  };
6006 
6007  // Use constructed object for RAII guard
6008  Colour( Code _colourCode );
6009  Colour( Colour&& other ) noexcept;
6010  Colour& operator=( Colour&& other ) noexcept;
6011  ~Colour();
6012 
6013  // Use static method for one-shot changes
6014  static void use( Code _colourCode );
6015 
6016  private:
6017  bool m_moved = false;
6018  };
6019 
6020  std::ostream& operator << ( std::ostream& os, Colour const& );
6021 
6022 } // end namespace Catch
6023 
6024 // end catch_console_colour.h
6025 // start catch_reporter_registrars.hpp
6026 
6027 
6028 namespace Catch {
6029 
6030  template<typename T>
6031  class ReporterRegistrar {
6032 
6033  class ReporterFactory : public IReporterFactory {
6034 
6035  IStreamingReporterPtr create( ReporterConfig const& config ) const override {
6036  return std::unique_ptr<T>( new T( config ) );
6037  }
6038 
6039  std::string getDescription() const override {
6040  return T::getDescription();
6041  }
6042  };
6043 
6044  public:
6045 
6046  explicit ReporterRegistrar( std::string const& name ) {
6047  getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
6048  }
6049  };
6050 
6051  template<typename T>
6052  class ListenerRegistrar {
6053 
6054  class ListenerFactory : public IReporterFactory {
6055 
6056  IStreamingReporterPtr create( ReporterConfig const& config ) const override {
6057  return std::unique_ptr<T>( new T( config ) );
6058  }
6059  std::string getDescription() const override {
6060  return std::string();
6061  }
6062  };
6063 
6064  public:
6065 
6066  ListenerRegistrar() {
6067  getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );
6068  }
6069  };
6070 }
6071 
6072 #if !defined(CATCH_CONFIG_DISABLE)
6073 
6074 #define CATCH_REGISTER_REPORTER( name, reporterType ) \
6075  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6076  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6077  namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } \
6078  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
6079 
6080 #define CATCH_REGISTER_LISTENER( listenerType ) \
6081  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6082  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6083  namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \
6084  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
6085 #else // CATCH_CONFIG_DISABLE
6086 
6087 #define CATCH_REGISTER_REPORTER(name, reporterType)
6088 #define CATCH_REGISTER_LISTENER(listenerType)
6089 
6090 #endif // CATCH_CONFIG_DISABLE
6091 
6092 // end catch_reporter_registrars.hpp
6093 // Allow users to base their work off existing reporters
6094 // start catch_reporter_compact.h
6095 
6096 namespace Catch {
6097 
6098  struct CompactReporter : StreamingReporterBase<CompactReporter> {
6099 
6100  using StreamingReporterBase::StreamingReporterBase;
6101 
6102  ~CompactReporter() override;
6103 
6104  static std::string getDescription();
6105 
6106  ReporterPreferences getPreferences() const override;
6107 
6108  void noMatchingTestCases(std::string const& spec) override;
6109 
6110  void assertionStarting(AssertionInfo const&) override;
6111 
6112  bool assertionEnded(AssertionStats const& _assertionStats) override;
6113 
6114  void sectionEnded(SectionStats const& _sectionStats) override;
6115 
6116  void testRunEnded(TestRunStats const& _testRunStats) override;
6117 
6118  };
6119 
6120 } // end namespace Catch
6121 
6122 // end catch_reporter_compact.h
6123 // start catch_reporter_console.h
6124 
6125 #if defined(_MSC_VER)
6126 #pragma warning(push)
6127 #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
6128  // Note that 4062 (not all labels are handled
6129  // and default is missing) is enabled
6130 #endif
6131 
6132 namespace Catch {
6133  // Fwd decls
6134  struct SummaryColumn;
6135  class TablePrinter;
6136 
6137  struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
6138  std::unique_ptr<TablePrinter> m_tablePrinter;
6139 
6140  ConsoleReporter(ReporterConfig const& config);
6141  ~ConsoleReporter() override;
6142  static std::string getDescription();
6143 
6144  void noMatchingTestCases(std::string const& spec) override;
6145 
6146  void reportInvalidArguments(std::string const&arg) override;
6147 
6148  void assertionStarting(AssertionInfo const&) override;
6149 
6150  bool assertionEnded(AssertionStats const& _assertionStats) override;
6151 
6152  void sectionStarting(SectionInfo const& _sectionInfo) override;
6153  void sectionEnded(SectionStats const& _sectionStats) override;
6154 
6155 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
6156  void benchmarkPreparing(std::string const& name) override;
6157  void benchmarkStarting(BenchmarkInfo const& info) override;
6158  void benchmarkEnded(BenchmarkStats<> const& stats) override;
6159  void benchmarkFailed(std::string const& error) override;
6160 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
6161 
6162  void testCaseEnded(TestCaseStats const& _testCaseStats) override;
6163  void testGroupEnded(TestGroupStats const& _testGroupStats) override;
6164  void testRunEnded(TestRunStats const& _testRunStats) override;
6165  void testRunStarting(TestRunInfo const& _testRunInfo) override;
6166  private:
6167 
6168  void lazyPrint();
6169 
6170  void lazyPrintWithoutClosingBenchmarkTable();
6171  void lazyPrintRunInfo();
6172  void lazyPrintGroupInfo();
6173  void printTestCaseAndSectionHeader();
6174 
6175  void printClosedHeader(std::string const& _name);
6176  void printOpenHeader(std::string const& _name);
6177 
6178  // if string has a : in first line will set indent to follow it on
6179  // subsequent lines
6180  void printHeaderString(std::string const& _string, std::size_t indent = 0);
6181 
6182  void printTotals(Totals const& totals);
6183  void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row);
6184 
6185  void printTotalsDivider(Totals const& totals);
6186  void printSummaryDivider();
6187  void printTestFilters();
6188 
6189  private:
6190  bool m_headerPrinted = false;
6191  };
6192 
6193 } // end namespace Catch
6194 
6195 #if defined(_MSC_VER)
6196 #pragma warning(pop)
6197 #endif
6198 
6199 // end catch_reporter_console.h
6200 // start catch_reporter_junit.h
6201 
6202 // start catch_xmlwriter.h
6203 
6204 #include <vector>
6205 
6206 namespace Catch {
6207  enum class XmlFormatting {
6208  None = 0x00,
6209  Indent = 0x01,
6210  Newline = 0x02,
6211  };
6212 
6213  XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs);
6214  XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs);
6215 
6216  class XmlEncode {
6217  public:
6218  enum ForWhat { ForTextNodes, ForAttributes };
6219 
6220  XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes );
6221 
6222  void encodeTo( std::ostream& os ) const;
6223 
6224  friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode );
6225 
6226  private:
6227  std::string m_str;
6228  ForWhat m_forWhat;
6229  };
6230 
6231  class XmlWriter {
6232  public:
6233 
6234  class ScopedElement {
6235  public:
6236  ScopedElement( XmlWriter* writer, XmlFormatting fmt );
6237 
6238  ScopedElement( ScopedElement&& other ) noexcept;
6239  ScopedElement& operator=( ScopedElement&& other ) noexcept;
6240 
6241  ~ScopedElement();
6242 
6243  ScopedElement& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent );
6244 
6245  template<typename T>
6246  ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
6247  m_writer->writeAttribute( name, attribute );
6248  return *this;
6249  }
6250 
6251  private:
6252  mutable XmlWriter* m_writer = nullptr;
6253  XmlFormatting m_fmt;
6254  };
6255 
6256  XmlWriter( std::ostream& os = Catch::cout() );
6257  ~XmlWriter();
6258 
6259  XmlWriter( XmlWriter const& ) = delete;
6260  XmlWriter& operator=( XmlWriter const& ) = delete;
6261 
6262  XmlWriter& startElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
6263 
6264  ScopedElement scopedElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
6265 
6266  XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
6267 
6268  XmlWriter& writeAttribute( std::string const& name, std::string const& attribute );
6269 
6270  XmlWriter& writeAttribute( std::string const& name, bool attribute );
6271 
6272  template<typename T>
6273  XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
6275  rss << attribute;
6276  return writeAttribute( name, rss.str() );
6277  }
6278 
6279  XmlWriter& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
6280 
6281  XmlWriter& writeComment(std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
6282 
6283  void writeStylesheetRef( std::string const& url );
6284 
6285  XmlWriter& writeBlankLine();
6286 
6287  void ensureTagClosed();
6288 
6289  private:
6290 
6291  void applyFormatting(XmlFormatting fmt);
6292 
6293  void writeDeclaration();
6294 
6295  void newlineIfNecessary();
6296 
6297  bool m_tagIsOpen = false;
6298  bool m_needsNewline = false;
6299  std::vector<std::string> m_tags;
6300  std::string m_indent;
6301  std::ostream& m_os;
6302  };
6303 
6304 }
6305 
6306 // end catch_xmlwriter.h
6307 namespace Catch {
6308 
6309  class JunitReporter : public CumulativeReporterBase<JunitReporter> {
6310  public:
6311  JunitReporter(ReporterConfig const& _config);
6312 
6313  ~JunitReporter() override;
6314 
6315  static std::string getDescription();
6316 
6317  void noMatchingTestCases(std::string const& /*spec*/) override;
6318 
6319  void testRunStarting(TestRunInfo const& runInfo) override;
6320 
6321  void testGroupStarting(GroupInfo const& groupInfo) override;
6322 
6323  void testCaseStarting(TestCaseInfo const& testCaseInfo) override;
6324  bool assertionEnded(AssertionStats const& assertionStats) override;
6325 
6326  void testCaseEnded(TestCaseStats const& testCaseStats) override;
6327 
6328  void testGroupEnded(TestGroupStats const& testGroupStats) override;
6329 
6330  void testRunEndedCumulative() override;
6331 
6332  void writeGroup(TestGroupNode const& groupNode, double suiteTime);
6333 
6334  void writeTestCase(TestCaseNode const& testCaseNode);
6335 
6336  void writeSection(std::string const& className,
6337  std::string const& rootName,
6338  SectionNode const& sectionNode);
6339 
6340  void writeAssertions(SectionNode const& sectionNode);
6341  void writeAssertion(AssertionStats const& stats);
6342 
6343  XmlWriter xml;
6344  Timer suiteTimer;
6345  std::string stdOutForSuite;
6346  std::string stdErrForSuite;
6347  unsigned int unexpectedExceptions = 0;
6348  bool m_okToFail = false;
6349  };
6350 
6351 } // end namespace Catch
6352 
6353 // end catch_reporter_junit.h
6354 // start catch_reporter_xml.h
6355 
6356 namespace Catch {
6357  class XmlReporter : public StreamingReporterBase<XmlReporter> {
6358  public:
6359  XmlReporter(ReporterConfig const& _config);
6360 
6361  ~XmlReporter() override;
6362 
6363  static std::string getDescription();
6364 
6365  virtual std::string getStylesheetRef() const;
6366 
6367  void writeSourceInfo(SourceLineInfo const& sourceInfo);
6368 
6369  public: // StreamingReporterBase
6370 
6371  void noMatchingTestCases(std::string const& s) override;
6372 
6373  void testRunStarting(TestRunInfo const& testInfo) override;
6374 
6375  void testGroupStarting(GroupInfo const& groupInfo) override;
6376 
6377  void testCaseStarting(TestCaseInfo const& testInfo) override;
6378 
6379  void sectionStarting(SectionInfo const& sectionInfo) override;
6380 
6381  void assertionStarting(AssertionInfo const&) override;
6382 
6383  bool assertionEnded(AssertionStats const& assertionStats) override;
6384 
6385  void sectionEnded(SectionStats const& sectionStats) override;
6386 
6387  void testCaseEnded(TestCaseStats const& testCaseStats) override;
6388 
6389  void testGroupEnded(TestGroupStats const& testGroupStats) override;
6390 
6391  void testRunEnded(TestRunStats const& testRunStats) override;
6392 
6393 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
6394  void benchmarkPreparing(std::string const& name) override;
6395  void benchmarkStarting(BenchmarkInfo const&) override;
6396  void benchmarkEnded(BenchmarkStats<> const&) override;
6397  void benchmarkFailed(std::string const&) override;
6398 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
6399 
6400  private:
6401  Timer m_testCaseTimer;
6402  XmlWriter m_xml;
6403  int m_sectionDepth = 0;
6404  };
6405 
6406 } // end namespace Catch
6407 
6408 // end catch_reporter_xml.h
6409 
6410 // end catch_external_interfaces.h
6411 #endif
6412 
6413 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
6414 // start catch_benchmarking_all.hpp
6415 
6416 // A proxy header that includes all of the benchmarking headers to allow
6417 // concise include of the benchmarking features. You should prefer the
6418 // individual includes in standard use.
6419 
6420 // start catch_benchmark.hpp
6421 
6422  // Benchmark
6423 
6424 // start catch_chronometer.hpp
6425 
6426 // User-facing chronometer
6427 
6428 
6429 // start catch_clock.hpp
6430 
6431 // Clocks
6432 
6433 
6434 #include <chrono>
6435 #include <ratio>
6436 
6437 namespace Catch {
6438  namespace Benchmark {
6439  template <typename Clock>
6440  using ClockDuration = typename Clock::duration;
6441  template <typename Clock>
6442  using FloatDuration = std::chrono::duration<double, typename Clock::period>;
6443 
6444  template <typename Clock>
6445  using TimePoint = typename Clock::time_point;
6446 
6447  using default_clock = std::chrono::steady_clock;
6448 
6449  template <typename Clock>
6450  struct now {
6451  TimePoint<Clock> operator()() const {
6452  return Clock::now();
6453  }
6454  };
6455 
6456  using fp_seconds = std::chrono::duration<double, std::ratio<1>>;
6457  } // namespace Benchmark
6458 } // namespace Catch
6459 
6460 // end catch_clock.hpp
6461 // start catch_optimizer.hpp
6462 
6463  // Hinting the optimizer
6464 
6465 
6466 #if defined(_MSC_VER)
6467 # include <atomic> // atomic_thread_fence
6468 #endif
6469 
6470 namespace Catch {
6471  namespace Benchmark {
6472 #if defined(__GNUC__) || defined(__clang__)
6473  template <typename T>
6474  inline void keep_memory(T* p) {
6475  asm volatile("" : : "g"(p) : "memory");
6476  }
6477  inline void keep_memory() {
6478  asm volatile("" : : : "memory");
6479  }
6480 
6481  namespace Detail {
6482  inline void optimizer_barrier() { keep_memory(); }
6483  } // namespace Detail
6484 #elif defined(_MSC_VER)
6485 
6486 #pragma optimize("", off)
6487  template <typename T>
6488  inline void keep_memory(T* p) {
6489  // thanks @milleniumbug
6490  *reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p);
6491  }
6492  // TODO equivalent keep_memory()
6493 #pragma optimize("", on)
6494 
6495  namespace Detail {
6496  inline void optimizer_barrier() {
6497  std::atomic_thread_fence(std::memory_order_seq_cst);
6498  }
6499  } // namespace Detail
6500 
6501 #endif
6502 
6503  template <typename T>
6504  inline void deoptimize_value(T&& x) {
6505  keep_memory(&x);
6506  }
6507 
6508  template <typename Fn, typename... Args>
6509  inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type {
6510  deoptimize_value(std::forward<Fn>(fn) (std::forward<Args...>(args...)));
6511  }
6512 
6513  template <typename Fn, typename... Args>
6514  inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type {
6515  std::forward<Fn>(fn) (std::forward<Args...>(args...));
6516  }
6517  } // namespace Benchmark
6518 } // namespace Catch
6519 
6520 // end catch_optimizer.hpp
6521 // start catch_complete_invoke.hpp
6522 
6523 // Invoke with a special case for void
6524 
6525 
6526 #include <type_traits>
6527 #include <utility>
6528 
6529 namespace Catch {
6530  namespace Benchmark {
6531  namespace Detail {
6532  template <typename T>
6533  struct CompleteType { using type = T; };
6534  template <>
6535  struct CompleteType<void> { struct type {}; };
6536 
6537  template <typename T>
6538  using CompleteType_t = typename CompleteType<T>::type;
6539 
6540  template <typename Result>
6541  struct CompleteInvoker {
6542  template <typename Fun, typename... Args>
6543  static Result invoke(Fun&& fun, Args&&... args) {
6544  return std::forward<Fun>(fun)(std::forward<Args>(args)...);
6545  }
6546  };
6547  template <>
6548  struct CompleteInvoker<void> {
6549  template <typename Fun, typename... Args>
6550  static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) {
6551  std::forward<Fun>(fun)(std::forward<Args>(args)...);
6552  return {};
6553  }
6554  };
6555  template <typename Sig>
6556  using ResultOf_t = typename std::result_of<Sig>::type;
6557 
6558  // invoke and not return void :(
6559  template <typename Fun, typename... Args>
6560  CompleteType_t<ResultOf_t<Fun(Args...)>> complete_invoke(Fun&& fun, Args&&... args) {
6561  return CompleteInvoker<ResultOf_t<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...);
6562  }
6563 
6564  const std::string benchmarkErrorMsg = "a benchmark failed to run successfully";
6565  } // namespace Detail
6566 
6567  template <typename Fun>
6568  Detail::CompleteType_t<Detail::ResultOf_t<Fun()>> user_code(Fun&& fun) {
6569  CATCH_TRY{
6570  return Detail::complete_invoke(std::forward<Fun>(fun));
6571  } CATCH_CATCH_ALL{
6572  getResultCapture().benchmarkFailed(translateActiveException());
6573  CATCH_RUNTIME_ERROR(Detail::benchmarkErrorMsg);
6574  }
6575  }
6576  } // namespace Benchmark
6577 } // namespace Catch
6578 
6579 // end catch_complete_invoke.hpp
6580 namespace Catch {
6581  namespace Benchmark {
6582  namespace Detail {
6583  struct ChronometerConcept {
6584  virtual void start() = 0;
6585  virtual void finish() = 0;
6586  virtual ~ChronometerConcept() = default;
6587  };
6588  template <typename Clock>
6589  struct ChronometerModel final : public ChronometerConcept {
6590  void start() override { started = Clock::now(); }
6591  void finish() override { finished = Clock::now(); }
6592 
6593  ClockDuration<Clock> elapsed() const { return finished - started; }
6594 
6595  TimePoint<Clock> started;
6596  TimePoint<Clock> finished;
6597  };
6598  } // namespace Detail
6599 
6600  struct Chronometer {
6601  public:
6602  template <typename Fun>
6603  void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
6604 
6605  int runs() const { return k; }
6606 
6607  Chronometer(Detail::ChronometerConcept& meter, int k)
6608  : impl(&meter)
6609  , k(k) {}
6610 
6611  private:
6612  template <typename Fun>
6613  void measure(Fun&& fun, std::false_type) {
6614  measure([&fun](int) { return fun(); }, std::true_type());
6615  }
6616 
6617  template <typename Fun>
6618  void measure(Fun&& fun, std::true_type) {
6619  Detail::optimizer_barrier();
6620  impl->start();
6621  for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i);
6622  impl->finish();
6623  Detail::optimizer_barrier();
6624  }
6625 
6626  Detail::ChronometerConcept* impl;
6627  int k;
6628  };
6629  } // namespace Benchmark
6630 } // namespace Catch
6631 
6632 // end catch_chronometer.hpp
6633 // start catch_environment.hpp
6634 
6635 // Environment information
6636 
6637 
6638 namespace Catch {
6639  namespace Benchmark {
6640  template <typename Duration>
6641  struct EnvironmentEstimate {
6642  Duration mean;
6643  OutlierClassification outliers;
6644 
6645  template <typename Duration2>
6646  operator EnvironmentEstimate<Duration2>() const {
6647  return { mean, outliers };
6648  }
6649  };
6650  template <typename Clock>
6651  struct Environment {
6652  using clock_type = Clock;
6653  EnvironmentEstimate<FloatDuration<Clock>> clock_resolution;
6654  EnvironmentEstimate<FloatDuration<Clock>> clock_cost;
6655  };
6656  } // namespace Benchmark
6657 } // namespace Catch
6658 
6659 // end catch_environment.hpp
6660 // start catch_execution_plan.hpp
6661 
6662  // Execution plan
6663 
6664 
6665 // start catch_benchmark_function.hpp
6666 
6667  // Dumb std::function implementation for consistent call overhead
6668 
6669 
6670 #include <cassert>
6671 #include <type_traits>
6672 #include <utility>
6673 #include <memory>
6674 
6675 namespace Catch {
6676  namespace Benchmark {
6677  namespace Detail {
6678  template <typename T>
6679  using Decay = typename std::decay<T>::type;
6680  template <typename T, typename U>
6681  struct is_related
6682  : std::is_same<Decay<T>, Decay<U>> {};
6683 
6691  struct BenchmarkFunction {
6692  private:
6693  struct callable {
6694  virtual void call(Chronometer meter) const = 0;
6695  virtual callable* clone() const = 0;
6696  virtual ~callable() = default;
6697  };
6698  template <typename Fun>
6699  struct model : public callable {
6700  model(Fun&& fun) : fun(std::move(fun)) {}
6701  model(Fun const& fun) : fun(fun) {}
6702 
6703  model<Fun>* clone() const override { return new model<Fun>(*this); }
6704 
6705  void call(Chronometer meter) const override {
6706  call(meter, is_callable<Fun(Chronometer)>());
6707  }
6708  void call(Chronometer meter, std::true_type) const {
6709  fun(meter);
6710  }
6711  void call(Chronometer meter, std::false_type) const {
6712  meter.measure(fun);
6713  }
6714 
6715  Fun fun;
6716  };
6717 
6718  struct do_nothing { void operator()() const {} };
6719 
6720  template <typename T>
6721  BenchmarkFunction(model<T>* c) : f(c) {}
6722 
6723  public:
6724  BenchmarkFunction()
6725  : f(new model<do_nothing>{ {} }) {}
6726 
6727  template <typename Fun,
6729  BenchmarkFunction(Fun&& fun)
6730  : f(new model<typename std::decay<Fun>::type>(std::forward<Fun>(fun))) {}
6731 
6732  BenchmarkFunction(BenchmarkFunction&& that)
6733  : f(std::move(that.f)) {}
6734 
6735  BenchmarkFunction(BenchmarkFunction const& that)
6736  : f(that.f->clone()) {}
6737 
6738  BenchmarkFunction& operator=(BenchmarkFunction&& that) {
6739  f = std::move(that.f);
6740  return *this;
6741  }
6742 
6743  BenchmarkFunction& operator=(BenchmarkFunction const& that) {
6744  f.reset(that.f->clone());
6745  return *this;
6746  }
6747 
6748  void operator()(Chronometer meter) const { f->call(meter); }
6749 
6750  private:
6751  std::unique_ptr<callable> f;
6752  };
6753  } // namespace Detail
6754  } // namespace Benchmark
6755 } // namespace Catch
6756 
6757 // end catch_benchmark_function.hpp
6758 // start catch_repeat.hpp
6759 
6760 // repeat algorithm
6761 
6762 
6763 #include <type_traits>
6764 #include <utility>
6765 
6766 namespace Catch {
6767  namespace Benchmark {
6768  namespace Detail {
6769  template <typename Fun>
6770  struct repeater {
6771  void operator()(int k) const {
6772  for (int i = 0; i < k; ++i) {
6773  fun();
6774  }
6775  }
6776  Fun fun;
6777  };
6778  template <typename Fun>
6780  return { std::forward<Fun>(fun) };
6781  }
6782  } // namespace Detail
6783  } // namespace Benchmark
6784 } // namespace Catch
6785 
6786 // end catch_repeat.hpp
6787 // start catch_run_for_at_least.hpp
6788 
6789 // Run a function for a minimum amount of time
6790 
6791 
6792 // start catch_measure.hpp
6793 
6794 // Measure
6795 
6796 
6797 // start catch_timing.hpp
6798 
6799 // Timing
6800 
6801 
6802 #include <tuple>
6803 #include <type_traits>
6804 
6805 namespace Catch {
6806  namespace Benchmark {
6807  template <typename Duration, typename Result>
6808  struct Timing {
6809  Duration elapsed;
6810  Result result;
6811  int iterations;
6812  };
6813  template <typename Clock, typename Sig>
6814  using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<Detail::ResultOf_t<Sig>>>;
6815  } // namespace Benchmark
6816 } // namespace Catch
6817 
6818 // end catch_timing.hpp
6819 #include <utility>
6820 
6821 namespace Catch {
6822  namespace Benchmark {
6823  namespace Detail {
6824  template <typename Clock, typename Fun, typename... Args>
6825  TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) {
6826  auto start = Clock::now();
6827  auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...);
6828  auto end = Clock::now();
6829  auto delta = end - start;
6830  return { delta, std::forward<decltype(r)>(r), 1 };
6831  }
6832  } // namespace Detail
6833  } // namespace Benchmark
6834 } // namespace Catch
6835 
6836 // end catch_measure.hpp
6837 #include <utility>
6838 #include <type_traits>
6839 
6840 namespace Catch {
6841  namespace Benchmark {
6842  namespace Detail {
6843  template <typename Clock, typename Fun>
6844  TimingOf<Clock, Fun(int)> measure_one(Fun&& fun, int iters, std::false_type) {
6845  return Detail::measure<Clock>(fun, iters);
6846  }
6847  template <typename Clock, typename Fun>
6848  TimingOf<Clock, Fun(Chronometer)> measure_one(Fun&& fun, int iters, std::true_type) {
6849  Detail::ChronometerModel<Clock> meter;
6850  auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
6851 
6852  return { meter.elapsed(), std::move(result), iters };
6853  }
6854 
6855  template <typename Clock, typename Fun>
6856  using run_for_at_least_argument_t = typename std::conditional<is_callable<Fun(Chronometer)>::value, Chronometer, int>::type;
6857 
6858  struct optimized_away_error : std::exception {
6859  const char* what() const noexcept override {
6860  return "could not measure benchmark, maybe it was optimized away";
6861  }
6862  };
6863 
6864  template <typename Clock, typename Fun>
6865  TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) {
6866  auto iters = seed;
6867  while (iters < (1 << 30)) {
6868  auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>());
6869 
6870  if (Timing.elapsed >= how_long) {
6871  return { Timing.elapsed, std::move(Timing.result), iters };
6872  }
6873  iters *= 2;
6874  }
6875  throw optimized_away_error{};
6876  }
6877  } // namespace Detail
6878  } // namespace Benchmark
6879 } // namespace Catch
6880 
6881 // end catch_run_for_at_least.hpp
6882 #include <algorithm>
6883 
6884 namespace Catch {
6885  namespace Benchmark {
6886  template <typename Duration>
6887  struct ExecutionPlan {
6888  int iterations_per_sample;
6889  Duration estimated_duration;
6890  Detail::BenchmarkFunction benchmark;
6891  Duration warmup_time;
6892  int warmup_iterations;
6893 
6894  template <typename Duration2>
6895  operator ExecutionPlan<Duration2>() const {
6896  return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations };
6897  }
6898 
6899  template <typename Clock>
6900  std::vector<FloatDuration<Clock>> run(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {
6901  // warmup a bit
6902  Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{}));
6903 
6904  std::vector<FloatDuration<Clock>> times;
6905  times.reserve(cfg.benchmarkSamples());
6906  std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] {
6907  Detail::ChronometerModel<Clock> model;
6908  this->benchmark(Chronometer(model, iterations_per_sample));
6909  auto sample_time = model.elapsed() - env.clock_cost.mean;
6910  if (sample_time < FloatDuration<Clock>::zero()) sample_time = FloatDuration<Clock>::zero();
6911  return sample_time / iterations_per_sample;
6912  });
6913  return times;
6914  }
6915  };
6916  } // namespace Benchmark
6917 } // namespace Catch
6918 
6919 // end catch_execution_plan.hpp
6920 // start catch_estimate_clock.hpp
6921 
6922  // Environment measurement
6923 
6924 
6925 // start catch_stats.hpp
6926 
6927 // Statistical analysis tools
6928 
6929 
6930 #include <algorithm>
6931 #include <functional>
6932 #include <vector>
6933 #include <iterator>
6934 #include <numeric>
6935 #include <tuple>
6936 #include <cmath>
6937 #include <utility>
6938 #include <cstddef>
6939 #include <random>
6940 
6941 namespace Catch {
6942  namespace Benchmark {
6943  namespace Detail {
6944  using sample = std::vector<double>;
6945 
6946  double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last);
6947 
6948  template <typename Iterator>
6949  OutlierClassification classify_outliers(Iterator first, Iterator last) {
6950  std::vector<double> copy(first, last);
6951 
6952  auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end());
6953  auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end());
6954  auto iqr = q3 - q1;
6955  auto los = q1 - (iqr * 3.);
6956  auto lom = q1 - (iqr * 1.5);
6957  auto him = q3 + (iqr * 1.5);
6958  auto his = q3 + (iqr * 3.);
6959 
6960  OutlierClassification o;
6961  for (; first != last; ++first) {
6962  auto&& t = *first;
6963  if (t < los) ++o.low_severe;
6964  else if (t < lom) ++o.low_mild;
6965  else if (t > his) ++o.high_severe;
6966  else if (t > him) ++o.high_mild;
6967  ++o.samples_seen;
6968  }
6969  return o;
6970  }
6971 
6972  template <typename Iterator>
6973  double mean(Iterator first, Iterator last) {
6974  auto count = last - first;
6975  double sum = std::accumulate(first, last, 0.);
6976  return sum / count;
6977  }
6978 
6979  template <typename URng, typename Iterator, typename Estimator>
6980  sample resample(URng& rng, int resamples, Iterator first, Iterator last, Estimator& estimator) {
6981  auto n = last - first;
6982  std::uniform_int_distribution<decltype(n)> dist(0, n - 1);
6983 
6984  sample out;
6985  out.reserve(resamples);
6986  std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] {
6987  std::vector<double> resampled;
6988  resampled.reserve(n);
6989  std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; });
6990  return estimator(resampled.begin(), resampled.end());
6991  });
6992  std::sort(out.begin(), out.end());
6993  return out;
6994  }
6995 
6996  template <typename Estimator, typename Iterator>
6997  sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {
6998  auto n = last - first;
6999  auto second = std::next(first);
7000  sample results;
7001  results.reserve(n);
7002 
7003  for (auto it = first; it != last; ++it) {
7004  std::iter_swap(it, first);
7005  results.push_back(estimator(second, last));
7006  }
7007 
7008  return results;
7009  }
7010 
7011  inline double normal_cdf(double x) {
7012  return std::erfc(-x / std::sqrt(2.0)) / 2.0;
7013  }
7014 
7015  double erfc_inv(double x);
7016 
7017  double normal_quantile(double p);
7018 
7019  template <typename Iterator, typename Estimator>
7020  Estimate<double> bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) {
7021  auto n_samples = last - first;
7022 
7023  double point = estimator(first, last);
7024  // Degenerate case with a single sample
7025  if (n_samples == 1) return { point, point, point, confidence_level };
7026 
7027  sample jack = jackknife(estimator, first, last);
7028  double jack_mean = mean(jack.begin(), jack.end());
7029  double sum_squares, sum_cubes;
7030  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> {
7031  auto d = jack_mean - x;
7032  auto d2 = d * d;
7033  auto d3 = d2 * d;
7034  return { sqcb.first + d2, sqcb.second + d3 };
7035  });
7036 
7037  double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5));
7038  int n = static_cast<int>(resample.size());
7039  double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / (double)n;
7040  // degenerate case with uniform samples
7041  if (prob_n == 0) return { point, point, point, confidence_level };
7042 
7043  double bias = normal_quantile(prob_n);
7044  double z1 = normal_quantile((1. - confidence_level) / 2.);
7045 
7046  auto cumn = [n](double x) -> int {
7047  return std::lround(normal_cdf(x) * n); };
7048  auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); };
7049  double b1 = bias + z1;
7050  double b2 = bias - z1;
7051  double a1 = a(b1);
7052  double a2 = a(b2);
7053  auto lo = std::max(cumn(a1), 0);
7054  auto hi = std::min(cumn(a2), n - 1);
7055 
7056  return { point, resample[lo], resample[hi], confidence_level };
7057  }
7058 
7059  double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n);
7060 
7061  struct bootstrap_analysis {
7062  Estimate<double> mean;
7063  Estimate<double> standard_deviation;
7064  double outlier_variance;
7065  };
7066 
7067  bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last);
7068  } // namespace Detail
7069  } // namespace Benchmark
7070 } // namespace Catch
7071 
7072 // end catch_stats.hpp
7073 #include <algorithm>
7074 #include <iterator>
7075 #include <tuple>
7076 #include <vector>
7077 #include <cmath>
7078 
7079 namespace Catch {
7080  namespace Benchmark {
7081  namespace Detail {
7082  template <typename Clock>
7083  std::vector<double> resolution(int k) {
7084  std::vector<TimePoint<Clock>> times;
7085  times.reserve(k + 1);
7086  std::generate_n(std::back_inserter(times), k + 1, now<Clock>{});
7087 
7088  std::vector<double> deltas;
7089  deltas.reserve(k);
7090  std::transform(std::next(times.begin()), times.end(), times.begin(),
7091  std::back_inserter(deltas),
7092  [](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); });
7093 
7094  return deltas;
7095  }
7096 
7097  const auto warmup_iterations = 10000;
7098  const auto warmup_time = std::chrono::milliseconds(100);
7099  const auto minimum_ticks = 1000;
7100  const auto warmup_seed = 10000;
7101  const auto clock_resolution_estimation_time = std::chrono::milliseconds(500);
7102  const auto clock_cost_estimation_time_limit = std::chrono::seconds(1);
7103  const auto clock_cost_estimation_tick_limit = 100000;
7104  const auto clock_cost_estimation_time = std::chrono::milliseconds(10);
7105  const auto clock_cost_estimation_iterations = 10000;
7106 
7107  template <typename Clock>
7108  int warmup() {
7109  return run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_seed, &resolution<Clock>)
7110  .iterations;
7111  }
7112  template <typename Clock>
7113  EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_resolution(int iterations) {
7114  auto r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_resolution_estimation_time), iterations, &resolution<Clock>)
7115  .result;
7116  return {
7117  FloatDuration<Clock>(mean(r.begin(), r.end())),
7118  classify_outliers(r.begin(), r.end()),
7119  };
7120  }
7121  template <typename Clock>
7122  EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) {
7123  auto time_limit = std::min(resolution * clock_cost_estimation_tick_limit, FloatDuration<Clock>(clock_cost_estimation_time_limit));
7124  auto time_clock = [](int k) {
7125  return Detail::measure<Clock>([k] {
7126  for (int i = 0; i < k; ++i) {
7127  volatile auto ignored = Clock::now();
7128  (void)ignored;
7129  }
7130  }).elapsed;
7131  };
7132  time_clock(1);
7133  int iters = clock_cost_estimation_iterations;
7134  auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_cost_estimation_time), iters, time_clock);
7135  std::vector<double> times;
7136  int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
7137  times.reserve(nsamples);
7138  std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] {
7139  return static_cast<double>((time_clock(r.iterations) / r.iterations).count());
7140  });
7141  return {
7142  FloatDuration<Clock>(mean(times.begin(), times.end())),
7143  classify_outliers(times.begin(), times.end()),
7144  };
7145  }
7146 
7147  template <typename Clock>
7148  Environment<FloatDuration<Clock>> measure_environment() {
7149  static Environment<FloatDuration<Clock>>* env = nullptr;
7150  if (env) {
7151  return *env;
7152  }
7153 
7154  auto iters = Detail::warmup<Clock>();
7155  auto resolution = Detail::estimate_clock_resolution<Clock>(iters);
7156  auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean);
7157 
7158  env = new Environment<FloatDuration<Clock>>{ resolution, cost };
7159  return *env;
7160  }
7161  } // namespace Detail
7162  } // namespace Benchmark
7163 } // namespace Catch
7164 
7165 // end catch_estimate_clock.hpp
7166 // start catch_analyse.hpp
7167 
7168  // Run and analyse one benchmark
7169 
7170 
7171 // start catch_sample_analysis.hpp
7172 
7173 // Benchmark results
7174 
7175 
7176 #include <algorithm>
7177 #include <vector>
7178 #include <string>
7179 #include <iterator>
7180 
7181 namespace Catch {
7182  namespace Benchmark {
7183  template <typename Duration>
7184  struct SampleAnalysis {
7185  std::vector<Duration> samples;
7186  Estimate<Duration> mean;
7187  Estimate<Duration> standard_deviation;
7188  OutlierClassification outliers;
7189  double outlier_variance;
7190 
7191  template <typename Duration2>
7192  operator SampleAnalysis<Duration2>() const {
7193  std::vector<Duration2> samples2;
7194  samples2.reserve(samples.size());
7195  std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
7196  return {
7197  std::move(samples2),
7198  mean,
7199  standard_deviation,
7200  outliers,
7201  outlier_variance,
7202  };
7203  }
7204  };
7205  } // namespace Benchmark
7206 } // namespace Catch
7207 
7208 // end catch_sample_analysis.hpp
7209 #include <algorithm>
7210 #include <iterator>
7211 #include <vector>
7212 
7213 namespace Catch {
7214  namespace Benchmark {
7215  namespace Detail {
7216  template <typename Duration, typename Iterator>
7217  SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) {
7218  if (!cfg.benchmarkNoAnalysis()) {
7219  std::vector<double> samples;
7220  samples.reserve(last - first);
7221  std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); });
7222 
7223  auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end());
7224  auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end());
7225 
7226  auto wrap_estimate = [](Estimate<double> e) {
7227  return Estimate<Duration> {
7228  Duration(e.point),
7229  Duration(e.lower_bound),
7230  Duration(e.upper_bound),
7231  e.confidence_interval,
7232  };
7233  };
7234  std::vector<Duration> samples2;
7235  samples2.reserve(samples.size());
7236  std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); });
7237  return {
7238  std::move(samples2),
7239  wrap_estimate(analysis.mean),
7240  wrap_estimate(analysis.standard_deviation),
7241  outliers,
7242  analysis.outlier_variance,
7243  };
7244  } else {
7245  std::vector<Duration> samples;
7246  samples.reserve(last - first);
7247 
7248  Duration mean = Duration(0);
7249  int i = 0;
7250  for (auto it = first; it < last; ++it, ++i) {
7251  samples.push_back(Duration(*it));
7252  mean += Duration(*it);
7253  }
7254  mean /= i;
7255 
7256  return {
7257  std::move(samples),
7258  Estimate<Duration>{mean, mean, mean, 0.0},
7259  Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0},
7260  OutlierClassification{},
7261  0.0
7262  };
7263  }
7264  }
7265  } // namespace Detail
7266  } // namespace Benchmark
7267 } // namespace Catch
7268 
7269 // end catch_analyse.hpp
7270 #include <algorithm>
7271 #include <functional>
7272 #include <string>
7273 #include <vector>
7274 #include <cmath>
7275 
7276 namespace Catch {
7277  namespace Benchmark {
7278  struct Benchmark {
7279  Benchmark(std::string &&name)
7280  : name(std::move(name)) {}
7281 
7282  template <class FUN>
7283  Benchmark(std::string &&name, FUN &&func)
7284  : fun(std::move(func)), name(std::move(name)) {}
7285 
7286  template <typename Clock>
7287  ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {
7288  auto min_time = env.clock_resolution.mean * Detail::minimum_ticks;
7289  auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime()));
7290  auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(run_time), 1, fun);
7291  int new_iters = static_cast<int>(std::ceil(min_time * test.iterations / test.elapsed));
7292  return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations };
7293  }
7294 
7295  template <typename Clock = default_clock>
7296  void run() {
7298 
7299  auto env = Detail::measure_environment<Clock>();
7300 
7301  getResultCapture().benchmarkPreparing(name);
7302  CATCH_TRY{
7303  auto plan = user_code([&] {
7304  return prepare<Clock>(*cfg, env);
7305  });
7306 
7307  BenchmarkInfo info {
7308  name,
7309  plan.estimated_duration.count(),
7310  plan.iterations_per_sample,
7311  cfg->benchmarkSamples(),
7312  cfg->benchmarkResamples(),
7313  env.clock_resolution.mean.count(),
7314  env.clock_cost.mean.count()
7315  };
7316 
7317  getResultCapture().benchmarkStarting(info);
7318 
7319  auto samples = user_code([&] {
7320  return plan.template run<Clock>(*cfg, env);
7321  });
7322 
7323  auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
7324  BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
7325  getResultCapture().benchmarkEnded(stats);
7326 
7327  } CATCH_CATCH_ALL{
7328  if (translateActiveException() != Detail::benchmarkErrorMsg) // benchmark errors have been reported, otherwise rethrow.
7329  std::rethrow_exception(std::current_exception());
7330  }
7331  }
7332 
7333  // sets lambda to be used in fun *and* executes benchmark!
7334  template <typename Fun,
7336  Benchmark & operator=(Fun func) {
7337  fun = Detail::BenchmarkFunction(func);
7338  run();
7339  return *this;
7340  }
7341 
7342  explicit operator bool() {
7343  return true;
7344  }
7345 
7346  private:
7347  Detail::BenchmarkFunction fun;
7348  std::string name;
7349  };
7350  }
7351 } // namespace Catch
7352 
7353 #define INTERNAL_CATCH_GET_1_ARG(arg1, arg2, ...) arg1
7354 #define INTERNAL_CATCH_GET_2_ARG(arg1, arg2, ...) arg2
7355 
7356 #define INTERNAL_CATCH_BENCHMARK(BenchmarkName, name, benchmarkIndex)\
7357  if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \
7358  BenchmarkName = [&](int benchmarkIndex)
7359 
7360 #define INTERNAL_CATCH_BENCHMARK_ADVANCED(BenchmarkName, name)\
7361  if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \
7362  BenchmarkName = [&]
7363 
7364 // end catch_benchmark.hpp
7365 // start catch_constructor.hpp
7366 
7367 // Constructor and destructor helpers
7368 
7369 
7370 #include <type_traits>
7371 
7372 namespace Catch {
7373  namespace Benchmark {
7374  namespace Detail {
7375  template <typename T, bool Destruct>
7376  struct ObjectStorage
7377  {
7379 
7380  ObjectStorage() : data() {}
7381 
7382  ObjectStorage(const ObjectStorage& other)
7383  {
7384  new(&data) T(other.stored_object());
7385  }
7386 
7387  ObjectStorage(ObjectStorage&& other)
7388  {
7389  new(&data) T(std::move(other.stored_object()));
7390  }
7391 
7392  ~ObjectStorage() { destruct_on_exit<T>(); }
7393 
7394  template <typename... Args>
7395  void construct(Args&&... args)
7396  {
7397  new (&data) T(std::forward<Args>(args)...);
7398  }
7399 
7400  template <bool AllowManualDestruction = !Destruct>
7402  {
7403  stored_object().~T();
7404  }
7405 
7406  private:
7407  // If this is a constructor benchmark, destruct the underlying object
7408  template <typename U>
7409  void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
7410  // Otherwise, don't
7411  template <typename U>
7412  void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
7413 
7414  T& stored_object() {
7415  return *static_cast<T*>(static_cast<void*>(&data));
7416  }
7417 
7418  T const& stored_object() const {
7419  return *static_cast<T*>(static_cast<void*>(&data));
7420  }
7421 
7422  TStorage data;
7423  };
7424  }
7425 
7426  template <typename T>
7427  using storage_for = Detail::ObjectStorage<T, true>;
7428 
7429  template <typename T>
7430  using destructable_object = Detail::ObjectStorage<T, false>;
7431  }
7432 }
7433 
7434 // end catch_constructor.hpp
7435 // end catch_benchmarking_all.hpp
7436 #endif
7437 
7438 #endif // ! CATCH_CONFIG_IMPL_ONLY
7439 
7440 #ifdef CATCH_IMPL
7441 // start catch_impl.hpp
7442 
7443 #ifdef __clang__
7444 #pragma clang diagnostic push
7445 #pragma clang diagnostic ignored "-Wweak-vtables"
7446 #endif
7447 
7448 // Keep these here for external reporters
7449 // start catch_test_case_tracker.h
7450 
7451 #include <string>
7452 #include <vector>
7453 #include <memory>
7454 
7455 namespace Catch {
7456 namespace TestCaseTracking {
7457 
7458  struct NameAndLocation {
7459  std::string name;
7461 
7462  NameAndLocation( std::string const& _name, SourceLineInfo const& _location );
7463  };
7464 
7465  struct ITracker;
7466 
7467  using ITrackerPtr = std::shared_ptr<ITracker>;
7468 
7469  struct ITracker {
7470  virtual ~ITracker();
7471 
7472  // static queries
7473  virtual NameAndLocation const& nameAndLocation() const = 0;
7474 
7475  // dynamic queries
7476  virtual bool isComplete() const = 0; // Successfully completed or failed
7477  virtual bool isSuccessfullyCompleted() const = 0;
7478  virtual bool isOpen() const = 0; // Started but not complete
7479  virtual bool hasChildren() const = 0;
7480 
7481  virtual ITracker& parent() = 0;
7482 
7483  // actions
7484  virtual void close() = 0; // Successfully complete
7485  virtual void fail() = 0;
7486  virtual void markAsNeedingAnotherRun() = 0;
7487 
7488  virtual void addChild( ITrackerPtr const& child ) = 0;
7489  virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0;
7490  virtual void openChild() = 0;
7491 
7492  // Debug/ checking
7493  virtual bool isSectionTracker() const = 0;
7494  virtual bool isGeneratorTracker() const = 0;
7495  };
7496 
7497  class TrackerContext {
7498 
7499  enum RunState {
7500  NotStarted,
7501  Executing,
7502  CompletedCycle
7503  };
7504 
7505  ITrackerPtr m_rootTracker;
7506  ITracker* m_currentTracker = nullptr;
7507  RunState m_runState = NotStarted;
7508 
7509  public:
7510 
7511  ITracker& startRun();
7512  void endRun();
7513 
7514  void startCycle();
7515  void completeCycle();
7516 
7517  bool completedCycle() const;
7518  ITracker& currentTracker();
7519  void setCurrentTracker( ITracker* tracker );
7520  };
7521 
7522  class TrackerBase : public ITracker {
7523  protected:
7524  enum CycleState {
7525  NotStarted,
7526  Executing,
7527  ExecutingChildren,
7528  NeedsAnotherRun,
7529  CompletedSuccessfully,
7530  Failed
7531  };
7532 
7533  using Children = std::vector<ITrackerPtr>;
7534  NameAndLocation m_nameAndLocation;
7535  TrackerContext& m_ctx;
7536  ITracker* m_parent;
7537  Children m_children;
7538  CycleState m_runState = NotStarted;
7539 
7540  public:
7541  TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
7542 
7543  NameAndLocation const& nameAndLocation() const override;
7544  bool isComplete() const override;
7545  bool isSuccessfullyCompleted() const override;
7546  bool isOpen() const override;
7547  bool hasChildren() const override;
7548 
7549  void addChild( ITrackerPtr const& child ) override;
7550 
7551  ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override;
7552  ITracker& parent() override;
7553 
7554  void openChild() override;
7555 
7556  bool isSectionTracker() const override;
7557  bool isGeneratorTracker() const override;
7558 
7559  void open();
7560 
7561  void close() override;
7562  void fail() override;
7563  void markAsNeedingAnotherRun() override;
7564 
7565  private:
7566  void moveToParent();
7567  void moveToThis();
7568  };
7569 
7570  class SectionTracker : public TrackerBase {
7571  std::vector<std::string> m_filters;
7572  std::string m_trimmed_name;
7573  public:
7574  SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
7575 
7576  bool isSectionTracker() const override;
7577 
7578  bool isComplete() const override;
7579 
7580  static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation );
7581 
7582  void tryOpen();
7583 
7584  void addInitialFilters( std::vector<std::string> const& filters );
7585  void addNextFilters( std::vector<std::string> const& filters );
7586  };
7587 
7588 } // namespace TestCaseTracking
7589 
7590 using TestCaseTracking::ITracker;
7591 using TestCaseTracking::TrackerContext;
7592 using TestCaseTracking::SectionTracker;
7593 
7594 } // namespace Catch
7595 
7596 // end catch_test_case_tracker.h
7597 
7598 // start catch_leak_detector.h
7599 
7600 namespace Catch {
7601 
7602  struct LeakDetector {
7603  LeakDetector();
7604  ~LeakDetector();
7605  };
7606 
7607 }
7608 // end catch_leak_detector.h
7609 // Cpp files will be included in the single-header file here
7610 // start catch_stats.cpp
7611 
7612 // Statistical analysis tools
7613 
7614 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
7615 
7616 #include <cassert>
7617 #include <random>
7618 
7619 #if defined(CATCH_CONFIG_USE_ASYNC)
7620 #include <future>
7621 #endif
7622 
7623 namespace {
7624  double erf_inv(double x) {
7625  // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2
7626  double w, p;
7627 
7628  w = -log((1.0 - x) * (1.0 + x));
7629 
7630  if (w < 6.250000) {
7631  w = w - 3.125000;
7632  p = -3.6444120640178196996e-21;
7633  p = -1.685059138182016589e-19 + p * w;
7634  p = 1.2858480715256400167e-18 + p * w;
7635  p = 1.115787767802518096e-17 + p * w;
7636  p = -1.333171662854620906e-16 + p * w;
7637  p = 2.0972767875968561637e-17 + p * w;
7638  p = 6.6376381343583238325e-15 + p * w;
7639  p = -4.0545662729752068639e-14 + p * w;
7640  p = -8.1519341976054721522e-14 + p * w;
7641  p = 2.6335093153082322977e-12 + p * w;
7642  p = -1.2975133253453532498e-11 + p * w;
7643  p = -5.4154120542946279317e-11 + p * w;
7644  p = 1.051212273321532285e-09 + p * w;
7645  p = -4.1126339803469836976e-09 + p * w;
7646  p = -2.9070369957882005086e-08 + p * w;
7647  p = 4.2347877827932403518e-07 + p * w;
7648  p = -1.3654692000834678645e-06 + p * w;
7649  p = -1.3882523362786468719e-05 + p * w;
7650  p = 0.0001867342080340571352 + p * w;
7651  p = -0.00074070253416626697512 + p * w;
7652  p = -0.0060336708714301490533 + p * w;
7653  p = 0.24015818242558961693 + p * w;
7654  p = 1.6536545626831027356 + p * w;
7655  } else if (w < 16.000000) {
7656  w = sqrt(w) - 3.250000;
7657  p = 2.2137376921775787049e-09;
7658  p = 9.0756561938885390979e-08 + p * w;
7659  p = -2.7517406297064545428e-07 + p * w;
7660  p = 1.8239629214389227755e-08 + p * w;
7661  p = 1.5027403968909827627e-06 + p * w;
7662  p = -4.013867526981545969e-06 + p * w;
7663  p = 2.9234449089955446044e-06 + p * w;
7664  p = 1.2475304481671778723e-05 + p * w;
7665  p = -4.7318229009055733981e-05 + p * w;
7666  p = 6.8284851459573175448e-05 + p * w;
7667  p = 2.4031110387097893999e-05 + p * w;
7668  p = -0.0003550375203628474796 + p * w;
7669  p = 0.00095328937973738049703 + p * w;
7670  p = -0.0016882755560235047313 + p * w;
7671  p = 0.0024914420961078508066 + p * w;
7672  p = -0.0037512085075692412107 + p * w;
7673  p = 0.005370914553590063617 + p * w;
7674  p = 1.0052589676941592334 + p * w;
7675  p = 3.0838856104922207635 + p * w;
7676  } else {
7677  w = sqrt(w) - 5.000000;
7678  p = -2.7109920616438573243e-11;
7679  p = -2.5556418169965252055e-10 + p * w;
7680  p = 1.5076572693500548083e-09 + p * w;
7681  p = -3.7894654401267369937e-09 + p * w;
7682  p = 7.6157012080783393804e-09 + p * w;
7683  p = -1.4960026627149240478e-08 + p * w;
7684  p = 2.9147953450901080826e-08 + p * w;
7685  p = -6.7711997758452339498e-08 + p * w;
7686  p = 2.2900482228026654717e-07 + p * w;
7687  p = -9.9298272942317002539e-07 + p * w;
7688  p = 4.5260625972231537039e-06 + p * w;
7689  p = -1.9681778105531670567e-05 + p * w;
7690  p = 7.5995277030017761139e-05 + p * w;
7691  p = -0.00021503011930044477347 + p * w;
7692  p = -0.00013871931833623122026 + p * w;
7693  p = 1.0103004648645343977 + p * w;
7694  p = 4.8499064014085844221 + p * w;
7695  }
7696  return p * x;
7697  }
7698 
7699  double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) {
7700  auto m = Catch::Benchmark::Detail::mean(first, last);
7701  double variance = std::accumulate(first, last, 0., [m](double a, double b) {
7702  double diff = b - m;
7703  return a + diff * diff;
7704  }) / (last - first);
7705  return std::sqrt(variance);
7706  }
7707 
7708 }
7709 
7710 namespace Catch {
7711  namespace Benchmark {
7712  namespace Detail {
7713 
7714  double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last) {
7715  auto count = last - first;
7716  double idx = (count - 1) * k / static_cast<double>(q);
7717  int j = static_cast<int>(idx);
7718  double g = idx - j;
7719  std::nth_element(first, first + j, last);
7720  auto xj = first[j];
7721  if (g == 0) return xj;
7722 
7723  auto xj1 = *std::min_element(first + (j + 1), last);
7724  return xj + g * (xj1 - xj);
7725  }
7726 
7727  double erfc_inv(double x) {
7728  return erf_inv(1.0 - x);
7729  }
7730 
7731  double normal_quantile(double p) {
7732  static const double ROOT_TWO = std::sqrt(2.0);
7733 
7734  double result = 0.0;
7735  assert(p >= 0 && p <= 1);
7736  if (p < 0 || p > 1) {
7737  return result;
7738  }
7739 
7740  result = -erfc_inv(2.0 * p);
7741  // result *= normal distribution standard deviation (1.0) * sqrt(2)
7742  result *= /*sd * */ ROOT_TWO;
7743  // result += normal disttribution mean (0)
7744  return result;
7745  }
7746 
7747  double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n) {
7748  double sb = stddev.point;
7749  double mn = mean.point / n;
7750  double mg_min = mn / 2.;
7751  double sg = std::min(mg_min / 4., sb / std::sqrt(n));
7752  double sg2 = sg * sg;
7753  double sb2 = sb * sb;
7754 
7755  auto c_max = [n, mn, sb2, sg2](double x) -> double {
7756  double k = mn - x;
7757  double d = k * k;
7758  double nd = n * d;
7759  double k0 = -n * nd;
7760  double k1 = sb2 - n * sg2 + nd;
7761  double det = k1 * k1 - 4 * sg2 * k0;
7762  return (int)(-2. * k0 / (k1 + std::sqrt(det)));
7763  };
7764 
7765  auto var_out = [n, sb2, sg2](double c) {
7766  double nc = n - c;
7767  return (nc / n) * (sb2 - nc * sg2);
7768  };
7769 
7770  return std::min(var_out(1), var_out(std::min(c_max(0.), c_max(mg_min)))) / sb2;
7771  }
7772 
7773  bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
7776  static std::random_device entropy;
7778 
7779  auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
7780 
7781  auto mean = &Detail::mean<std::vector<double>::iterator>;
7782  auto stddev = &standard_deviation;
7783 
7784 #if defined(CATCH_CONFIG_USE_ASYNC)
7785  auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
7786  auto seed = entropy();
7787  return std::async(std::launch::async, [=] {
7788  std::mt19937 rng(seed);
7789  auto resampled = resample(rng, n_resamples, first, last, f);
7790  return bootstrap(confidence_level, first, last, resampled, f);
7791  });
7792  };
7793 
7794  auto mean_future = Estimate(mean);
7795  auto stddev_future = Estimate(stddev);
7796 
7797  auto mean_estimate = mean_future.get();
7798  auto stddev_estimate = stddev_future.get();
7799 #else
7800  auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
7801  auto seed = entropy();
7802  std::mt19937 rng(seed);
7803  auto resampled = resample(rng, n_resamples, first, last, f);
7804  return bootstrap(confidence_level, first, last, resampled, f);
7805  };
7806 
7807  auto mean_estimate = Estimate(mean);
7808  auto stddev_estimate = Estimate(stddev);
7809 #endif // CATCH_USE_ASYNC
7810 
7811  double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n);
7812 
7813  return { mean_estimate, stddev_estimate, outlier_variance };
7814  }
7815  } // namespace Detail
7816  } // namespace Benchmark
7817 } // namespace Catch
7818 
7819 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
7820 // end catch_stats.cpp
7821 // start catch_approx.cpp
7822 
7823 #include <cmath>
7824 #include <limits>
7825 
7826 namespace {
7827 
7828 // Performs equivalent check of std::fabs(lhs - rhs) <= margin
7829 // But without the subtraction to allow for INFINITY in comparison
7830 bool marginComparison(double lhs, double rhs, double margin) {
7831  return (lhs + margin >= rhs) && (rhs + margin >= lhs);
7832 }
7833 
7834 }
7835 
7836 namespace Catch {
7837 namespace Detail {
7838 
7839  Approx::Approx ( double value )
7840  : m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
7841  m_margin( 0.0 ),
7842  m_scale( 0.0 ),
7843  m_value( value )
7844  {}
7845 
7847  return Approx( 0 );
7848  }
7849 
7850  Approx Approx::operator-() const {
7851  auto temp(*this);
7852  temp.m_value = -temp.m_value;
7853  return temp;
7854  }
7855 
7856  std::string Approx::toString() const {
7858  rss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )";
7859  return rss.str();
7860  }
7861 
7862  bool Approx::equalityComparisonImpl(const double other) const {
7863  // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value
7864  // Thanks to Richard Harris for his help refining the scaled margin value
7865  return marginComparison(m_value, other, m_margin)
7866  || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(std::isinf(m_value)? 0 : m_value)));
7867  }
7868 
7869  void Approx::setMargin(double newMargin) {
7870  CATCH_ENFORCE(newMargin >= 0,
7871  "Invalid Approx::margin: " << newMargin << '.'
7872  << " Approx::Margin has to be non-negative.");
7873  m_margin = newMargin;
7874  }
7875 
7876  void Approx::setEpsilon(double newEpsilon) {
7877  CATCH_ENFORCE(newEpsilon >= 0 && newEpsilon <= 1.0,
7878  "Invalid Approx::epsilon: " << newEpsilon << '.'
7879  << " Approx::epsilon has to be in [0, 1]");
7880  m_epsilon = newEpsilon;
7881  }
7882 
7883 } // end namespace Detail
7884 
7885 namespace literals {
7886  Detail::Approx operator "" _a(long double val) {
7887  return Detail::Approx(val);
7888  }
7889  Detail::Approx operator "" _a(unsigned long long val) {
7890  return Detail::Approx(val);
7891  }
7892 } // end namespace literals
7893 
7895  return value.toString();
7896 }
7897 
7898 } // end namespace Catch
7899 // end catch_approx.cpp
7900 // start catch_assertionhandler.cpp
7901 
7902 // start catch_debugger.h
7903 
7904 namespace Catch {
7905  bool isDebuggerActive();
7906 }
7907 
7908 #ifdef CATCH_PLATFORM_MAC
7909 
7910  #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
7911 
7912 #elif defined(CATCH_PLATFORM_IPHONE)
7913 
7914  // use inline assembler
7915  #if defined(__i386__) || defined(__x86_64__)
7916  #define CATCH_TRAP() __asm__("int $3")
7917  #elif defined(__aarch64__)
7918  #define CATCH_TRAP() __asm__(".inst 0xd4200000")
7919  #elif defined(__arm__) && !defined(__thumb__)
7920  #define CATCH_TRAP() __asm__(".inst 0xe7f001f0")
7921  #elif defined(__arm__) && defined(__thumb__)
7922  #define CATCH_TRAP() __asm__(".inst 0xde01")
7923  #endif
7924 
7925 #elif defined(CATCH_PLATFORM_LINUX)
7926  // If we can use inline assembler, do it because this allows us to break
7927  // directly at the location of the failing check instead of breaking inside
7928  // raise() called from it, i.e. one stack frame below.
7929  #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
7930  #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */
7931  #else // Fall back to the generic way.
7932  #include <signal.h>
7933 
7934  #define CATCH_TRAP() raise(SIGTRAP)
7935  #endif
7936 #elif defined(_MSC_VER)
7937  #define CATCH_TRAP() __debugbreak()
7938 #elif defined(__MINGW32__)
7939  extern "C" __declspec(dllimport) void __stdcall DebugBreak();
7940  #define CATCH_TRAP() DebugBreak()
7941 #endif
7942 
7943 #ifndef CATCH_BREAK_INTO_DEBUGGER
7944  #ifdef CATCH_TRAP
7945  #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
7946  #else
7947  #define CATCH_BREAK_INTO_DEBUGGER() []{}()
7948  #endif
7949 #endif
7950 
7951 // end catch_debugger.h
7952 // start catch_run_context.h
7953 
7954 // start catch_fatal_condition.h
7955 
7956 // start catch_windows_h_proxy.h
7957 
7958 
7959 #if defined(CATCH_PLATFORM_WINDOWS)
7960 
7961 #if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)
7962 # define CATCH_DEFINED_NOMINMAX
7963 # define NOMINMAX
7964 #endif
7965 #if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN)
7966 # define CATCH_DEFINED_WIN32_LEAN_AND_MEAN
7967 # define WIN32_LEAN_AND_MEAN
7968 #endif
7969 
7970 #ifdef __AFXDLL
7971 #include <AfxWin.h>
7972 #else
7973 #include <windows.h>
7974 #endif
7975 
7976 #ifdef CATCH_DEFINED_NOMINMAX
7977 # undef NOMINMAX
7978 #endif
7979 #ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN
7980 # undef WIN32_LEAN_AND_MEAN
7981 #endif
7982 
7983 #endif // defined(CATCH_PLATFORM_WINDOWS)
7984 
7985 // end catch_windows_h_proxy.h
7986 #if defined( CATCH_CONFIG_WINDOWS_SEH )
7987 
7988 namespace Catch {
7989 
7990  struct FatalConditionHandler {
7991 
7992  static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
7993  FatalConditionHandler();
7994  static void reset();
7995  ~FatalConditionHandler();
7996 
7997  private:
7998  static bool isSet;
7999  static ULONG guaranteeSize;
8000  static PVOID exceptionHandlerHandle;
8001  };
8002 
8003 } // namespace Catch
8004 
8005 #elif defined ( CATCH_CONFIG_POSIX_SIGNALS )
8006 
8007 #include <signal.h>
8008 
8009 namespace Catch {
8010 
8011  struct FatalConditionHandler {
8012 
8013  static bool isSet;
8014  static struct sigaction oldSigActions[];
8015  static stack_t oldSigStack;
8016  static char altStackMem[];
8017 
8018  static void handleSignal( int sig );
8019 
8020  FatalConditionHandler();
8021  ~FatalConditionHandler();
8022  static void reset();
8023  };
8024 
8025 } // namespace Catch
8026 
8027 #else
8028 
8029 namespace Catch {
8030  struct FatalConditionHandler {
8031  void reset();
8032  };
8033 }
8034 
8035 #endif
8036 
8037 // end catch_fatal_condition.h
8038 #include <string>
8039 
8040 namespace Catch {
8041 
8042  struct IMutableContext;
8043 
8045 
8046  class RunContext : public IResultCapture, public IRunner {
8047 
8048  public:
8049  RunContext( RunContext const& ) = delete;
8050  RunContext& operator =( RunContext const& ) = delete;
8051 
8052  explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter );
8053 
8054  ~RunContext() override;
8055 
8056  void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount );
8057  void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount );
8058 
8059  Totals runTest(TestCase const& testCase);
8060 
8061  IConfigPtr config() const;
8062  IStreamingReporter& reporter() const;
8063 
8064  public: // IResultCapture
8065 
8066  // Assertion handlers
8067  void handleExpr
8068  ( AssertionInfo const& info,
8069  ITransientExpression const& expr,
8070  AssertionReaction& reaction ) override;
8071  void handleMessage
8072  ( AssertionInfo const& info,
8073  ResultWas::OfType resultType,
8074  StringRef const& message,
8075  AssertionReaction& reaction ) override;
8076  void handleUnexpectedExceptionNotThrown
8077  ( AssertionInfo const& info,
8078  AssertionReaction& reaction ) override;
8079  void handleUnexpectedInflightException
8080  ( AssertionInfo const& info,
8081  std::string const& message,
8082  AssertionReaction& reaction ) override;
8083  void handleIncomplete
8084  ( AssertionInfo const& info ) override;
8085  void handleNonExpr
8086  ( AssertionInfo const &info,
8087  ResultWas::OfType resultType,
8088  AssertionReaction &reaction ) override;
8089 
8090  bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override;
8091 
8092  void sectionEnded( SectionEndInfo const& endInfo ) override;
8093  void sectionEndedEarly( SectionEndInfo const& endInfo ) override;
8094 
8095  auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override;
8096 
8097 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
8098  void benchmarkPreparing( std::string const& name ) override;
8099  void benchmarkStarting( BenchmarkInfo const& info ) override;
8100  void benchmarkEnded( BenchmarkStats<> const& stats ) override;
8101  void benchmarkFailed( std::string const& error ) override;
8102 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
8103 
8104  void pushScopedMessage( MessageInfo const& message ) override;
8105  void popScopedMessage( MessageInfo const& message ) override;
8106 
8107  void emplaceUnscopedMessage( MessageBuilder const& builder ) override;
8108 
8109  std::string getCurrentTestName() const override;
8110 
8111  const AssertionResult* getLastResult() const override;
8112 
8113  void exceptionEarlyReported() override;
8114 
8115  void handleFatalErrorCondition( StringRef message ) override;
8116 
8117  bool lastAssertionPassed() override;
8118 
8119  void assertionPassed() override;
8120 
8121  public:
8122  // !TBD We need to do this another way!
8123  bool aborting() const final;
8124 
8125  private:
8126 
8127  void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr );
8128  void invokeActiveTestCase();
8129 
8130  void resetAssertionInfo();
8131  bool testForMissingAssertions( Counts& assertions );
8132 
8133  void assertionEnded( AssertionResult const& result );
8134  void reportExpr
8135  ( AssertionInfo const &info,
8136  ResultWas::OfType resultType,
8137  ITransientExpression const *expr,
8138  bool negated );
8139 
8140  void populateReaction( AssertionReaction& reaction );
8141 
8142  private:
8143 
8144  void handleUnfinishedSections();
8145 
8146  TestRunInfo m_runInfo;
8147  IMutableContext& m_context;
8148  TestCase const* m_activeTestCase = nullptr;
8149  ITracker* m_testCaseTracker = nullptr;
8150  Option<AssertionResult> m_lastResult;
8151 
8152  IConfigPtr m_config;
8153  Totals m_totals;
8154  IStreamingReporterPtr m_reporter;
8155  std::vector<MessageInfo> m_messages;
8156  std::vector<ScopedMessage> m_messageScopes; /* Keeps owners of so-called unscoped messages. */
8157  AssertionInfo m_lastAssertionInfo;
8158  std::vector<SectionEndInfo> m_unfinishedSections;
8159  std::vector<ITracker*> m_activeSections;
8160  TrackerContext m_trackerContext;
8161  bool m_lastAssertionPassed = false;
8162  bool m_shouldReportUnexpected = true;
8163  bool m_includeSuccessfulResults;
8164  };
8165 
8166  void seedRng(IConfig const& config);
8167  unsigned int rngSeed();
8168 } // end namespace Catch
8169 
8170 // end catch_run_context.h
8171 namespace Catch {
8172 
8173  namespace {
8174  auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {
8175  expr.streamReconstructedExpression( os );
8176  return os;
8177  }
8178  }
8179 
8180  LazyExpression::LazyExpression( bool isNegated )
8181  : m_isNegated( isNegated )
8182  {}
8183 
8184  LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {}
8185 
8186  LazyExpression::operator bool() const {
8187  return m_transientExpression != nullptr;
8188  }
8189 
8190  auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& {
8191  if( lazyExpr.m_isNegated )
8192  os << "!";
8193 
8194  if( lazyExpr ) {
8195  if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() )
8196  os << "(" << *lazyExpr.m_transientExpression << ")";
8197  else
8198  os << *lazyExpr.m_transientExpression;
8199  }
8200  else {
8201  os << "{** error - unchecked empty expression requested **}";
8202  }
8203  return os;
8204  }
8205 
8207  ( StringRef const& macroName,
8208  SourceLineInfo const& lineInfo,
8209  StringRef capturedExpression,
8210  ResultDisposition::Flags resultDisposition )
8211  : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
8212  m_resultCapture( getResultCapture() )
8213  {}
8214 
8216  m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
8217  }
8219  m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
8220  }
8221 
8222  auto AssertionHandler::allowThrows() const -> bool {
8223  return getCurrentContext().getConfig()->allowThrows();
8224  }
8225 
8227  setCompleted();
8228  if( m_reaction.shouldDebugBreak ) {
8229 
8230  // If you find your debugger stopping you here then go one level up on the
8231  // call-stack for the code that caused it (typically a failed assertion)
8232 
8233  // (To go back to the test and change execution, jump over the throw, next)
8234  CATCH_BREAK_INTO_DEBUGGER();
8235  }
8236  if (m_reaction.shouldThrow) {
8237 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
8239 #else
8240  CATCH_ERROR( "Test failure requires aborting test!" );
8241 #endif
8242  }
8243  }
8245  m_completed = true;
8246  }
8247 
8249  m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction );
8250  }
8251 
8253  m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
8254  }
8256  m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
8257  }
8258 
8260  m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction );
8261  }
8262 
8264  m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
8265  }
8266 
8267  // This is the overload that takes a string and infers the Equals matcher from it
8268  // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
8269  void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) {
8270  handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
8271  }
8272 
8273 } // namespace Catch
8274 // end catch_assertionhandler.cpp
8275 // start catch_assertionresult.cpp
8276 
8277 namespace Catch {
8278  AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
8279  lazyExpression(_lazyExpression),
8280  resultType(_resultType) {}
8281 
8282  std::string AssertionResultData::reconstructExpression() const {
8283 
8284  if( reconstructedExpression.empty() ) {
8285  if( lazyExpression ) {
8287  rss << lazyExpression;
8288  reconstructedExpression = rss.str();
8289  }
8290  }
8291  return reconstructedExpression;
8292  }
8293 
8294  AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
8295  : m_info( info ),
8296  m_resultData( data )
8297  {}
8298 
8299  // Result was a success
8300  bool AssertionResult::succeeded() const {
8301  return Catch::isOk( m_resultData.resultType );
8302  }
8303 
8304  // Result was a success, or failure is suppressed
8305  bool AssertionResult::isOk() const {
8306  return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition );
8307  }
8308 
8309  ResultWas::OfType AssertionResult::getResultType() const {
8310  return m_resultData.resultType;
8311  }
8312 
8313  bool AssertionResult::hasExpression() const {
8314  return !m_info.capturedExpression.empty();
8315  }
8316 
8317  bool AssertionResult::hasMessage() const {
8318  return !m_resultData.message.empty();
8319  }
8320 
8321  std::string AssertionResult::getExpression() const {
8322  // Possibly overallocating by 3 characters should be basically free
8323  std::string expr; expr.reserve(m_info.capturedExpression.size() + 3);
8324  if (isFalseTest(m_info.resultDisposition)) {
8325  expr += "!(";
8326  }
8327  expr += m_info.capturedExpression;
8328  if (isFalseTest(m_info.resultDisposition)) {
8329  expr += ')';
8330  }
8331  return expr;
8332  }
8333 
8334  std::string AssertionResult::getExpressionInMacro() const {
8335  std::string expr;
8336  if( m_info.macroName.empty() )
8337  expr = static_cast<std::string>(m_info.capturedExpression);
8338  else {
8339  expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
8340  expr += m_info.macroName;
8341  expr += "( ";
8342  expr += m_info.capturedExpression;
8343  expr += " )";
8344  }
8345  return expr;
8346  }
8347 
8348  bool AssertionResult::hasExpandedExpression() const {
8349  return hasExpression() && getExpandedExpression() != getExpression();
8350  }
8351 
8352  std::string AssertionResult::getExpandedExpression() const {
8353  std::string expr = m_resultData.reconstructExpression();
8354  return expr.empty()
8355  ? getExpression()
8356  : expr;
8357  }
8358 
8359  std::string AssertionResult::getMessage() const {
8360  return m_resultData.message;
8361  }
8362  SourceLineInfo AssertionResult::getSourceInfo() const {
8363  return m_info.lineInfo;
8364  }
8365 
8366  StringRef AssertionResult::getTestMacroName() const {
8367  return m_info.macroName;
8368  }
8369 
8370 } // end namespace Catch
8371 // end catch_assertionresult.cpp
8372 // start catch_capture_matchers.cpp
8373 
8374 namespace Catch {
8375 
8377 
8378  // This is the general overload that takes a any string matcher
8379  // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
8380  // the Equals matcher (so the header does not mention matchers)
8381  void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ) {
8382  std::string exceptionMessage = Catch::translateActiveException();
8383  MatchExpr<std::string, StringMatcher const&> expr( exceptionMessage, matcher, matcherString );
8384  handler.handleExpr( expr );
8385  }
8386 
8387 } // namespace Catch
8388 // end catch_capture_matchers.cpp
8389 // start catch_commandline.cpp
8390 
8391 // start catch_commandline.h
8392 
8393 // start catch_clara.h
8394 
8395 // Use Catch's value for console width (store Clara's off to the side, if present)
8396 #ifdef CLARA_CONFIG_CONSOLE_WIDTH
8397 #define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
8398 #undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
8399 #endif
8400 #define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1
8401 
8402 #ifdef __clang__
8403 #pragma clang diagnostic push
8404 #pragma clang diagnostic ignored "-Wweak-vtables"
8405 #pragma clang diagnostic ignored "-Wexit-time-destructors"
8406 #pragma clang diagnostic ignored "-Wshadow"
8407 #endif
8408 
8409 // start clara.hpp
8410 // Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
8411 //
8412 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8413 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8414 //
8415 // See https://github.com/philsquared/Clara for more details
8416 
8417 // Clara v1.1.5
8418 
8419 
8420 #ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH
8421 #define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80
8422 #endif
8423 
8424 #ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
8425 #define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH
8426 #endif
8427 
8428 #ifndef CLARA_CONFIG_OPTIONAL_TYPE
8429 #ifdef __has_include
8430 #if __has_include(<optional>) && __cplusplus >= 201703L
8431 #include <optional>
8432 #define CLARA_CONFIG_OPTIONAL_TYPE std::optional
8433 #endif
8434 #endif
8435 #endif
8436 
8437 // ----------- #included from clara_textflow.hpp -----------
8438 
8439 // TextFlowCpp
8440 //
8441 // A single-header library for wrapping and laying out basic text, by Phil Nash
8442 //
8443 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8444 // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8445 //
8446 // This project is hosted at https://github.com/philsquared/textflowcpp
8447 
8448 
8449 #include <cassert>
8450 #include <ostream>
8451 #include <sstream>
8452 #include <vector>
8453 
8454 #ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
8455 #define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80
8456 #endif
8457 
8458 namespace Catch {
8459 namespace clara {
8460 namespace TextFlow {
8461 
8462 inline auto isWhitespace(char c) -> bool {
8463  static std::string chars = " \t\n\r";
8464  return chars.find(c) != std::string::npos;
8465 }
8466 inline auto isBreakableBefore(char c) -> bool {
8467  static std::string chars = "[({<|";
8468  return chars.find(c) != std::string::npos;
8469 }
8470 inline auto isBreakableAfter(char c) -> bool {
8471  static std::string chars = "])}>.,:;*+-=&/\\";
8472  return chars.find(c) != std::string::npos;
8473 }
8474 
8475 class Columns;
8476 
8477 class Column {
8478  std::vector<std::string> m_strings;
8479  size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH;
8480  size_t m_indent = 0;
8481  size_t m_initialIndent = std::string::npos;
8482 
8483 public:
8484  class iterator {
8485  friend Column;
8486 
8487  Column const& m_column;
8488  size_t m_stringIndex = 0;
8489  size_t m_pos = 0;
8490 
8491  size_t m_len = 0;
8492  size_t m_end = 0;
8493  bool m_suffix = false;
8494 
8495  iterator(Column const& column, size_t stringIndex)
8496  : m_column(column),
8497  m_stringIndex(stringIndex) {}
8498 
8499  auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; }
8500 
8501  auto isBoundary(size_t at) const -> bool {
8502  assert(at > 0);
8503  assert(at <= line().size());
8504 
8505  return at == line().size() ||
8506  (isWhitespace(line()[at]) && !isWhitespace(line()[at - 1])) ||
8507  isBreakableBefore(line()[at]) ||
8508  isBreakableAfter(line()[at - 1]);
8509  }
8510 
8511  void calcLength() {
8512  assert(m_stringIndex < m_column.m_strings.size());
8513 
8514  m_suffix = false;
8515  auto width = m_column.m_width - indent();
8516  m_end = m_pos;
8517  if (line()[m_pos] == '\n') {
8518  ++m_end;
8519  }
8520  while (m_end < line().size() && line()[m_end] != '\n')
8521  ++m_end;
8522 
8523  if (m_end < m_pos + width) {
8524  m_len = m_end - m_pos;
8525  } else {
8526  size_t len = width;
8527  while (len > 0 && !isBoundary(m_pos + len))
8528  --len;
8529  while (len > 0 && isWhitespace(line()[m_pos + len - 1]))
8530  --len;
8531 
8532  if (len > 0) {
8533  m_len = len;
8534  } else {
8535  m_suffix = true;
8536  m_len = width - 1;
8537  }
8538  }
8539  }
8540 
8541  auto indent() const -> size_t {
8542  auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos;
8543  return initial == std::string::npos ? m_column.m_indent : initial;
8544  }
8545 
8546  auto addIndentAndSuffix(std::string const &plain) const -> std::string {
8547  return std::string(indent(), ' ') + (m_suffix ? plain + "-" : plain);
8548  }
8549 
8550  public:
8551  using difference_type = std::ptrdiff_t;
8552  using value_type = std::string;
8553  using pointer = value_type * ;
8554  using reference = value_type & ;
8555  using iterator_category = std::forward_iterator_tag;
8556 
8557  explicit iterator(Column const& column) : m_column(column) {
8558  assert(m_column.m_width > m_column.m_indent);
8559  assert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent);
8560  calcLength();
8561  if (m_len == 0)
8562  m_stringIndex++; // Empty string
8563  }
8564 
8565  auto operator *() const -> std::string {
8566  assert(m_stringIndex < m_column.m_strings.size());
8567  assert(m_pos <= m_end);
8568  return addIndentAndSuffix(line().substr(m_pos, m_len));
8569  }
8570 
8571  auto operator ++() -> iterator& {
8572  m_pos += m_len;
8573  if (m_pos < line().size() && line()[m_pos] == '\n')
8574  m_pos += 1;
8575  else
8576  while (m_pos < line().size() && isWhitespace(line()[m_pos]))
8577  ++m_pos;
8578 
8579  if (m_pos == line().size()) {
8580  m_pos = 0;
8581  ++m_stringIndex;
8582  }
8583  if (m_stringIndex < m_column.m_strings.size())
8584  calcLength();
8585  return *this;
8586  }
8587  auto operator ++(int) -> iterator {
8588  iterator prev(*this);
8589  operator++();
8590  return prev;
8591  }
8592 
8593  auto operator ==(iterator const& other) const -> bool {
8594  return
8595  m_pos == other.m_pos &&
8596  m_stringIndex == other.m_stringIndex &&
8597  &m_column == &other.m_column;
8598  }
8599  auto operator !=(iterator const& other) const -> bool {
8600  return !operator==(other);
8601  }
8602  };
8603  using const_iterator = iterator;
8604 
8605  explicit Column(std::string const& text) { m_strings.push_back(text); }
8606 
8607  auto width(size_t newWidth) -> Column& {
8608  assert(newWidth > 0);
8609  m_width = newWidth;
8610  return *this;
8611  }
8612  auto indent(size_t newIndent) -> Column& {
8613  m_indent = newIndent;
8614  return *this;
8615  }
8616  auto initialIndent(size_t newIndent) -> Column& {
8617  m_initialIndent = newIndent;
8618  return *this;
8619  }
8620 
8621  auto width() const -> size_t { return m_width; }
8622  auto begin() const -> iterator { return iterator(*this); }
8623  auto end() const -> iterator { return { *this, m_strings.size() }; }
8624 
8625  inline friend std::ostream& operator << (std::ostream& os, Column const& col) {
8626  bool first = true;
8627  for (auto line : col) {
8628  if (first)
8629  first = false;
8630  else
8631  os << "\n";
8632  os << line;
8633  }
8634  return os;
8635  }
8636 
8637  auto operator + (Column const& other)->Columns;
8638 
8639  auto toString() const -> std::string {
8640  std::ostringstream oss;
8641  oss << *this;
8642  return oss.str();
8643  }
8644 };
8645 
8646 class Spacer : public Column {
8647 
8648 public:
8649  explicit Spacer(size_t spaceWidth) : Column("") {
8650  width(spaceWidth);
8651  }
8652 };
8653 
8654 class Columns {
8655  std::vector<Column> m_columns;
8656 
8657 public:
8658 
8659  class iterator {
8660  friend Columns;
8661  struct EndTag {};
8662 
8663  std::vector<Column> const& m_columns;
8664  std::vector<Column::iterator> m_iterators;
8665  size_t m_activeIterators;
8666 
8667  iterator(Columns const& columns, EndTag)
8668  : m_columns(columns.m_columns),
8669  m_activeIterators(0) {
8670  m_iterators.reserve(m_columns.size());
8671 
8672  for (auto const& col : m_columns)
8673  m_iterators.push_back(col.end());
8674  }
8675 
8676  public:
8677  using difference_type = std::ptrdiff_t;
8678  using value_type = std::string;
8679  using pointer = value_type * ;
8680  using reference = value_type & ;
8681  using iterator_category = std::forward_iterator_tag;
8682 
8683  explicit iterator(Columns const& columns)
8684  : m_columns(columns.m_columns),
8685  m_activeIterators(m_columns.size()) {
8686  m_iterators.reserve(m_columns.size());
8687 
8688  for (auto const& col : m_columns)
8689  m_iterators.push_back(col.begin());
8690  }
8691 
8692  auto operator ==(iterator const& other) const -> bool {
8693  return m_iterators == other.m_iterators;
8694  }
8695  auto operator !=(iterator const& other) const -> bool {
8696  return m_iterators != other.m_iterators;
8697  }
8698  auto operator *() const -> std::string {
8699  std::string row, padding;
8700 
8701  for (size_t i = 0; i < m_columns.size(); ++i) {
8702  auto width = m_columns[i].width();
8703  if (m_iterators[i] != m_columns[i].end()) {
8704  std::string col = *m_iterators[i];
8705  row += padding + col;
8706  if (col.size() < width)
8707  padding = std::string(width - col.size(), ' ');
8708  else
8709  padding = "";
8710  } else {
8711  padding += std::string(width, ' ');
8712  }
8713  }
8714  return row;
8715  }
8716  auto operator ++() -> iterator& {
8717  for (size_t i = 0; i < m_columns.size(); ++i) {
8718  if (m_iterators[i] != m_columns[i].end())
8719  ++m_iterators[i];
8720  }
8721  return *this;
8722  }
8723  auto operator ++(int) -> iterator {
8724  iterator prev(*this);
8725  operator++();
8726  return prev;
8727  }
8728  };
8729  using const_iterator = iterator;
8730 
8731  auto begin() const -> iterator { return iterator(*this); }
8732  auto end() const -> iterator { return { *this, iterator::EndTag() }; }
8733 
8734  auto operator += (Column const& col) -> Columns& {
8735  m_columns.push_back(col);
8736  return *this;
8737  }
8738  auto operator + (Column const& col) -> Columns {
8739  Columns combined = *this;
8740  combined += col;
8741  return combined;
8742  }
8743 
8744  inline friend std::ostream& operator << (std::ostream& os, Columns const& cols) {
8745 
8746  bool first = true;
8747  for (auto line : cols) {
8748  if (first)
8749  first = false;
8750  else
8751  os << "\n";
8752  os << line;
8753  }
8754  return os;
8755  }
8756 
8757  auto toString() const -> std::string {
8758  std::ostringstream oss;
8759  oss << *this;
8760  return oss.str();
8761  }
8762 };
8763 
8764 inline auto Column::operator + (Column const& other) -> Columns {
8765  Columns cols;
8766  cols += *this;
8767  cols += other;
8768  return cols;
8769 }
8770 }
8771 
8772 }
8773 }
8774 
8775 // ----------- end of #include from clara_textflow.hpp -----------
8776 // ........... back in clara.hpp
8777 
8778 #include <cctype>
8779 #include <string>
8780 #include <memory>
8781 #include <set>
8782 #include <algorithm>
8783 
8784 #if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) )
8785 #define CATCH_PLATFORM_WINDOWS
8786 #endif
8787 
8788 namespace Catch { namespace clara {
8789 namespace detail {
8790 
8791  // Traits for extracting arg and return type of lambdas (for single argument lambdas)
8792  template<typename L>
8793  struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operator() )> {};
8794 
8795  template<typename ClassT, typename ReturnT, typename... Args>
8796  struct UnaryLambdaTraits<ReturnT( ClassT::* )( Args... ) const> {
8797  static const bool isValid = false;
8798  };
8799 
8800  template<typename ClassT, typename ReturnT, typename ArgT>
8801  struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> {
8802  static const bool isValid = true;
8804  using ReturnType = ReturnT;
8805  };
8806 
8807  class TokenStream;
8808 
8809  // Transport for raw args (copied from main args, or supplied via init list for testing)
8810  class Args {
8811  friend TokenStream;
8812  std::string m_exeName;
8813  std::vector<std::string> m_args;
8814 
8815  public:
8816  Args( int argc, char const* const* argv )
8817  : m_exeName(argv[0]),
8818  m_args(argv + 1, argv + argc) {}
8819 
8820  Args( std::initializer_list<std::string> args )
8821  : m_exeName( *args.begin() ),
8822  m_args( args.begin()+1, args.end() )
8823  {}
8824 
8825  auto exeName() const -> std::string {
8826  return m_exeName;
8827  }
8828  };
8829 
8830  // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string
8831  // may encode an option + its argument if the : or = form is used
8832  enum class TokenType {
8833  Option, Argument
8834  };
8835  struct Token {
8836  TokenType type;
8837  std::string token;
8838  };
8839 
8840  inline auto isOptPrefix( char c ) -> bool {
8841  return c == '-'
8842 #ifdef CATCH_PLATFORM_WINDOWS
8843  || c == '/'
8844 #endif
8845  ;
8846  }
8847 
8848  // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled
8849  class TokenStream {
8850  using Iterator = std::vector<std::string>::const_iterator;
8851  Iterator it;
8852  Iterator itEnd;
8853  std::vector<Token> m_tokenBuffer;
8854 
8855  void loadBuffer() {
8856  m_tokenBuffer.resize( 0 );
8857 
8858  // Skip any empty strings
8859  while( it != itEnd && it->empty() )
8860  ++it;
8861 
8862  if( it != itEnd ) {
8863  auto const &next = *it;
8864  if( isOptPrefix( next[0] ) ) {
8865  auto delimiterPos = next.find_first_of( " :=" );
8866  if( delimiterPos != std::string::npos ) {
8867  m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );
8868  m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } );
8869  } else {
8870  if( next[1] != '-' && next.size() > 2 ) {
8871  std::string opt = "- ";
8872  for( size_t i = 1; i < next.size(); ++i ) {
8873  opt[1] = next[i];
8874  m_tokenBuffer.push_back( { TokenType::Option, opt } );
8875  }
8876  } else {
8877  m_tokenBuffer.push_back( { TokenType::Option, next } );
8878  }
8879  }
8880  } else {
8881  m_tokenBuffer.push_back( { TokenType::Argument, next } );
8882  }
8883  }
8884  }
8885 
8886  public:
8887  explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {}
8888 
8889  TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) {
8890  loadBuffer();
8891  }
8892 
8893  explicit operator bool() const {
8894  return !m_tokenBuffer.empty() || it != itEnd;
8895  }
8896 
8897  auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); }
8898 
8899  auto operator*() const -> Token {
8900  assert( !m_tokenBuffer.empty() );
8901  return m_tokenBuffer.front();
8902  }
8903 
8904  auto operator->() const -> Token const * {
8905  assert( !m_tokenBuffer.empty() );
8906  return &m_tokenBuffer.front();
8907  }
8908 
8909  auto operator++() -> TokenStream & {
8910  if( m_tokenBuffer.size() >= 2 ) {
8911  m_tokenBuffer.erase( m_tokenBuffer.begin() );
8912  } else {
8913  if( it != itEnd )
8914  ++it;
8915  loadBuffer();
8916  }
8917  return *this;
8918  }
8919  };
8920 
8921  class ResultBase {
8922  public:
8923  enum Type {
8924  Ok, LogicError, RuntimeError
8925  };
8926 
8927  protected:
8928  ResultBase( Type type ) : m_type( type ) {}
8929  virtual ~ResultBase() = default;
8930 
8931  virtual void enforceOk() const = 0;
8932 
8933  Type m_type;
8934  };
8935 
8936  template<typename T>
8937  class ResultValueBase : public ResultBase {
8938  public:
8939  auto value() const -> T const & {
8940  enforceOk();
8941  return m_value;
8942  }
8943 
8944  protected:
8945  ResultValueBase( Type type ) : ResultBase( type ) {}
8946 
8947  ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) {
8948  if( m_type == ResultBase::Ok )
8949  new( &m_value ) T( other.m_value );
8950  }
8951 
8952  ResultValueBase( Type, T const &value ) : ResultBase( Ok ) {
8953  new( &m_value ) T( value );
8954  }
8955 
8956  auto operator=( ResultValueBase const &other ) -> ResultValueBase & {
8957  if( m_type == ResultBase::Ok )
8958  m_value.~T();
8959  ResultBase::operator=(other);
8960  if( m_type == ResultBase::Ok )
8961  new( &m_value ) T( other.m_value );
8962  return *this;
8963  }
8964 
8965  ~ResultValueBase() override {
8966  if( m_type == Ok )
8967  m_value.~T();
8968  }
8969 
8970  union {
8971  T m_value;
8972  };
8973  };
8974 
8975  template<>
8976  class ResultValueBase<void> : public ResultBase {
8977  protected:
8978  using ResultBase::ResultBase;
8979  };
8980 
8981  template<typename T = void>
8982  class BasicResult : public ResultValueBase<T> {
8983  public:
8984  template<typename U>
8985  explicit BasicResult( BasicResult<U> const &other )
8986  : ResultValueBase<T>( other.type() ),
8987  m_errorMessage( other.errorMessage() )
8988  {
8989  assert( type() != ResultBase::Ok );
8990  }
8991 
8992  template<typename U>
8993  static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; }
8994  static auto ok() -> BasicResult { return { ResultBase::Ok }; }
8995  static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; }
8996  static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; }
8997 
8998  explicit operator bool() const { return m_type == ResultBase::Ok; }
8999  auto type() const -> ResultBase::Type { return m_type; }
9000  auto errorMessage() const -> std::string { return m_errorMessage; }
9001 
9002  protected:
9003  void enforceOk() const override {
9004 
9005  // Errors shouldn't reach this point, but if they do
9006  // the actual error message will be in m_errorMessage
9007  assert( m_type != ResultBase::LogicError );
9008  assert( m_type != ResultBase::RuntimeError );
9009  if( m_type != ResultBase::Ok )
9010  std::abort();
9011  }
9012 
9013  std::string m_errorMessage; // Only populated if resultType is an error
9014 
9015  BasicResult( ResultBase::Type type, std::string const &message )
9016  : ResultValueBase<T>(type),
9017  m_errorMessage(message)
9018  {
9019  assert( m_type != ResultBase::Ok );
9020  }
9021 
9022  using ResultValueBase<T>::ResultValueBase;
9023  using ResultBase::m_type;
9024  };
9025 
9026  enum class ParseResultType {
9027  Matched, NoMatch, ShortCircuitAll, ShortCircuitSame
9028  };
9029 
9030  class ParseState {
9031  public:
9032 
9033  ParseState( ParseResultType type, TokenStream const &remainingTokens )
9034  : m_type(type),
9035  m_remainingTokens( remainingTokens )
9036  {}
9037 
9038  auto type() const -> ParseResultType { return m_type; }
9039  auto remainingTokens() const -> TokenStream { return m_remainingTokens; }
9040 
9041  private:
9042  ParseResultType m_type;
9043  TokenStream m_remainingTokens;
9044  };
9045 
9046  using Result = BasicResult<void>;
9047  using ParserResult = BasicResult<ParseResultType>;
9048  using InternalParseResult = BasicResult<ParseState>;
9049 
9050  struct HelpColumns {
9051  std::string left;
9052  std::string right;
9053  };
9054 
9055  template<typename T>
9056  inline auto convertInto( std::string const &source, T& target ) -> ParserResult {
9057  std::stringstream ss;
9058  ss << source;
9059  ss >> target;
9060  if( ss.fail() )
9061  return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" );
9062  else
9063  return ParserResult::ok( ParseResultType::Matched );
9064  }
9065  inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult {
9066  target = source;
9067  return ParserResult::ok( ParseResultType::Matched );
9068  }
9069  inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
9070  std::string srcLC = source;
9071  std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( std::tolower(c) ); } );
9072  if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
9073  target = true;
9074  else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")
9075  target = false;
9076  else
9077  return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" );
9078  return ParserResult::ok( ParseResultType::Matched );
9079  }
9080 #ifdef CLARA_CONFIG_OPTIONAL_TYPE
9081  template<typename T>
9082  inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE<T>& target ) -> ParserResult {
9083  T temp;
9084  auto result = convertInto( source, temp );
9085  if( result )
9086  target = std::move(temp);
9087  return result;
9088  }
9089 #endif // CLARA_CONFIG_OPTIONAL_TYPE
9090 
9091  struct NonCopyable {
9092  NonCopyable() = default;
9093  NonCopyable( NonCopyable const & ) = delete;
9094  NonCopyable( NonCopyable && ) = delete;
9095  NonCopyable &operator=( NonCopyable const & ) = delete;
9096  NonCopyable &operator=( NonCopyable && ) = delete;
9097  };
9098 
9099  struct BoundRef : NonCopyable {
9100  virtual ~BoundRef() = default;
9101  virtual auto isContainer() const -> bool { return false; }
9102  virtual auto isFlag() const -> bool { return false; }
9103  };
9104  struct BoundValueRefBase : BoundRef {
9105  virtual auto setValue( std::string const &arg ) -> ParserResult = 0;
9106  };
9107  struct BoundFlagRefBase : BoundRef {
9108  virtual auto setFlag( bool flag ) -> ParserResult = 0;
9109  virtual auto isFlag() const -> bool { return true; }
9110  };
9111 
9112  template<typename T>
9113  struct BoundValueRef : BoundValueRefBase {
9114  T &m_ref;
9115 
9116  explicit BoundValueRef( T &ref ) : m_ref( ref ) {}
9117 
9118  auto setValue( std::string const &arg ) -> ParserResult override {
9119  return convertInto( arg, m_ref );
9120  }
9121  };
9122 
9123  template<typename T>
9124  struct BoundValueRef<std::vector<T>> : BoundValueRefBase {
9125  std::vector<T> &m_ref;
9126 
9127  explicit BoundValueRef( std::vector<T> &ref ) : m_ref( ref ) {}
9128 
9129  auto isContainer() const -> bool override { return true; }
9130 
9131  auto setValue( std::string const &arg ) -> ParserResult override {
9132  T temp;
9133  auto result = convertInto( arg, temp );
9134  if( result )
9135  m_ref.push_back( temp );
9136  return result;
9137  }
9138  };
9139 
9140  struct BoundFlagRef : BoundFlagRefBase {
9141  bool &m_ref;
9142 
9143  explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {}
9144 
9145  auto setFlag( bool flag ) -> ParserResult override {
9146  m_ref = flag;
9147  return ParserResult::ok( ParseResultType::Matched );
9148  }
9149  };
9150 
9151  template<typename ReturnType>
9152  struct LambdaInvoker {
9153  static_assert( std::is_same<ReturnType, ParserResult>::value, "Lambda must return void or clara::ParserResult" );
9154 
9155  template<typename L, typename ArgType>
9156  static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult {
9157  return lambda( arg );
9158  }
9159  };
9160 
9161  template<>
9162  struct LambdaInvoker<void> {
9163  template<typename L, typename ArgType>
9164  static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult {
9165  lambda( arg );
9166  return ParserResult::ok( ParseResultType::Matched );
9167  }
9168  };
9169 
9170  template<typename ArgType, typename L>
9171  inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult {
9172  ArgType temp{};
9173  auto result = convertInto( arg, temp );
9174  return !result
9175  ? result
9176  : LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( lambda, temp );
9177  }
9178 
9179  template<typename L>
9180  struct BoundLambda : BoundValueRefBase {
9181  L m_lambda;
9182 
9183  static_assert( UnaryLambdaTraits<L>::isValid, "Supplied lambda must take exactly one argument" );
9184  explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {}
9185 
9186  auto setValue( std::string const &arg ) -> ParserResult override {
9187  return invokeLambda<typename UnaryLambdaTraits<L>::ArgType>( m_lambda, arg );
9188  }
9189  };
9190 
9191  template<typename L>
9192  struct BoundFlagLambda : BoundFlagRefBase {
9193  L m_lambda;
9194 
9195  static_assert( UnaryLambdaTraits<L>::isValid, "Supplied lambda must take exactly one argument" );
9196  static_assert( std::is_same<typename UnaryLambdaTraits<L>::ArgType, bool>::value, "flags must be boolean" );
9197 
9198  explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {}
9199 
9200  auto setFlag( bool flag ) -> ParserResult override {
9201  return LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( m_lambda, flag );
9202  }
9203  };
9204 
9205  enum class Optionality { Optional, Required };
9206 
9207  struct Parser;
9208 
9209  class ParserBase {
9210  public:
9211  virtual ~ParserBase() = default;
9212  virtual auto validate() const -> Result { return Result::ok(); }
9213  virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0;
9214  virtual auto cardinality() const -> size_t { return 1; }
9215 
9216  auto parse( Args const &args ) const -> InternalParseResult {
9217  return parse( args.exeName(), TokenStream( args ) );
9218  }
9219  };
9220 
9221  template<typename DerivedT>
9222  class ComposableParserImpl : public ParserBase {
9223  public:
9224  template<typename T>
9225  auto operator|( T const &other ) const -> Parser;
9226 
9227  template<typename T>
9228  auto operator+( T const &other ) const -> Parser;
9229  };
9230 
9231  // Common code and state for Args and Opts
9232  template<typename DerivedT>
9233  class ParserRefImpl : public ComposableParserImpl<DerivedT> {
9234  protected:
9235  Optionality m_optionality = Optionality::Optional;
9236  std::shared_ptr<BoundRef> m_ref;
9237  std::string m_hint;
9238  std::string m_description;
9239 
9240  explicit ParserRefImpl( std::shared_ptr<BoundRef> const &ref ) : m_ref( ref ) {}
9241 
9242  public:
9243  template<typename T>
9244  ParserRefImpl( T &ref, std::string const &hint )
9245  : m_ref( std::make_shared<BoundValueRef<T>>( ref ) ),
9246  m_hint( hint )
9247  {}
9248 
9249  template<typename LambdaT>
9250  ParserRefImpl( LambdaT const &ref, std::string const &hint )
9251  : m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ),
9252  m_hint(hint)
9253  {}
9254 
9255  auto operator()( std::string const &description ) -> DerivedT & {
9256  m_description = description;
9257  return static_cast<DerivedT &>( *this );
9258  }
9259 
9260  auto optional() -> DerivedT & {
9261  m_optionality = Optionality::Optional;
9262  return static_cast<DerivedT &>( *this );
9263  };
9264 
9265  auto required() -> DerivedT & {
9266  m_optionality = Optionality::Required;
9267  return static_cast<DerivedT &>( *this );
9268  };
9269 
9270  auto isOptional() const -> bool {
9271  return m_optionality == Optionality::Optional;
9272  }
9273 
9274  auto cardinality() const -> size_t override {
9275  if( m_ref->isContainer() )
9276  return 0;
9277  else
9278  return 1;
9279  }
9280 
9281  auto hint() const -> std::string { return m_hint; }
9282  };
9283 
9284  class ExeName : public ComposableParserImpl<ExeName> {
9285  std::shared_ptr<std::string> m_name;
9286  std::shared_ptr<BoundValueRefBase> m_ref;
9287 
9288  template<typename LambdaT>
9289  static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {
9290  return std::make_shared<BoundLambda<LambdaT>>( lambda) ;
9291  }
9292 
9293  public:
9294  ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {}
9295 
9296  explicit ExeName( std::string &ref ) : ExeName() {
9297  m_ref = std::make_shared<BoundValueRef<std::string>>( ref );
9298  }
9299 
9300  template<typename LambdaT>
9301  explicit ExeName( LambdaT const& lambda ) : ExeName() {
9302  m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );
9303  }
9304 
9305  // The exe name is not parsed out of the normal tokens, but is handled specially
9306  auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9307  return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9308  }
9309 
9310  auto name() const -> std::string { return *m_name; }
9311  auto set( std::string const& newName ) -> ParserResult {
9312 
9313  auto lastSlash = newName.find_last_of( "\\/" );
9314  auto filename = ( lastSlash == std::string::npos )
9315  ? newName
9316  : newName.substr( lastSlash+1 );
9317 
9318  *m_name = filename;
9319  if( m_ref )
9320  return m_ref->setValue( filename );
9321  else
9322  return ParserResult::ok( ParseResultType::Matched );
9323  }
9324  };
9325 
9326  class Arg : public ParserRefImpl<Arg> {
9327  public:
9328  using ParserRefImpl::ParserRefImpl;
9329 
9330  auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override {
9331  auto validationResult = validate();
9332  if( !validationResult )
9333  return InternalParseResult( validationResult );
9334 
9335  auto remainingTokens = tokens;
9336  auto const &token = *remainingTokens;
9337  if( token.type != TokenType::Argument )
9338  return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
9339 
9340  assert( !m_ref->isFlag() );
9341  auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
9342 
9343  auto result = valueRef->setValue( remainingTokens->token );
9344  if( !result )
9345  return InternalParseResult( result );
9346  else
9347  return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );
9348  }
9349  };
9350 
9351  inline auto normaliseOpt( std::string const &optName ) -> std::string {
9352 #ifdef CATCH_PLATFORM_WINDOWS
9353  if( optName[0] == '/' )
9354  return "-" + optName.substr( 1 );
9355  else
9356 #endif
9357  return optName;
9358  }
9359 
9360  class Opt : public ParserRefImpl<Opt> {
9361  protected:
9362  std::vector<std::string> m_optNames;
9363 
9364  public:
9365  template<typename LambdaT>
9366  explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared<BoundFlagLambda<LambdaT>>( ref ) ) {}
9367 
9368  explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<BoundFlagRef>( ref ) ) {}
9369 
9370  template<typename LambdaT>
9371  Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}
9372 
9373  template<typename T>
9374  Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}
9375 
9376  auto operator[]( std::string const &optName ) -> Opt & {
9377  m_optNames.push_back( optName );
9378  return *this;
9379  }
9380 
9381  auto getHelpColumns() const -> std::vector<HelpColumns> {
9382  std::ostringstream oss;
9383  bool first = true;
9384  for( auto const &opt : m_optNames ) {
9385  if (first)
9386  first = false;
9387  else
9388  oss << ", ";
9389  oss << opt;
9390  }
9391  if( !m_hint.empty() )
9392  oss << " <" << m_hint << ">";
9393  return { { oss.str(), m_description } };
9394  }
9395 
9396  auto isMatch( std::string const &optToken ) const -> bool {
9397  auto normalisedToken = normaliseOpt( optToken );
9398  for( auto const &name : m_optNames ) {
9399  if( normaliseOpt( name ) == normalisedToken )
9400  return true;
9401  }
9402  return false;
9403  }
9404 
9405  using ParserBase::parse;
9406 
9407  auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9408  auto validationResult = validate();
9409  if( !validationResult )
9410  return InternalParseResult( validationResult );
9411 
9412  auto remainingTokens = tokens;
9413  if( remainingTokens && remainingTokens->type == TokenType::Option ) {
9414  auto const &token = *remainingTokens;
9415  if( isMatch(token.token ) ) {
9416  if( m_ref->isFlag() ) {
9417  auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
9418  auto result = flagRef->setFlag( true );
9419  if( !result )
9420  return InternalParseResult( result );
9421  if( result.value() == ParseResultType::ShortCircuitAll )
9422  return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9423  } else {
9424  auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
9425  ++remainingTokens;
9426  if( !remainingTokens )
9427  return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9428  auto const &argToken = *remainingTokens;
9429  if( argToken.type != TokenType::Argument )
9430  return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9431  auto result = valueRef->setValue( argToken.token );
9432  if( !result )
9433  return InternalParseResult( result );
9434  if( result.value() == ParseResultType::ShortCircuitAll )
9435  return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9436  }
9437  return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );
9438  }
9439  }
9440  return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
9441  }
9442 
9443  auto validate() const -> Result override {
9444  if( m_optNames.empty() )
9445  return Result::logicError( "No options supplied to Opt" );
9446  for( auto const &name : m_optNames ) {
9447  if( name.empty() )
9448  return Result::logicError( "Option name cannot be empty" );
9449 #ifdef CATCH_PLATFORM_WINDOWS
9450  if( name[0] != '-' && name[0] != '/' )
9451  return Result::logicError( "Option name must begin with '-' or '/'" );
9452 #else
9453  if( name[0] != '-' )
9454  return Result::logicError( "Option name must begin with '-'" );
9455 #endif
9456  }
9457  return ParserRefImpl::validate();
9458  }
9459  };
9460 
9461  struct Help : Opt {
9462  Help( bool &showHelpFlag )
9463  : Opt([&]( bool flag ) {
9464  showHelpFlag = flag;
9465  return ParserResult::ok( ParseResultType::ShortCircuitAll );
9466  })
9467  {
9468  static_cast<Opt &>( *this )
9469  ("display usage information")
9470  ["-?"]["-h"]["--help"]
9471  .optional();
9472  }
9473  };
9474 
9475  struct Parser : ParserBase {
9476 
9477  mutable ExeName m_exeName;
9478  std::vector<Opt> m_options;
9479  std::vector<Arg> m_args;
9480 
9481  auto operator|=( ExeName const &exeName ) -> Parser & {
9482  m_exeName = exeName;
9483  return *this;
9484  }
9485 
9486  auto operator|=( Arg const &arg ) -> Parser & {
9487  m_args.push_back(arg);
9488  return *this;
9489  }
9490 
9491  auto operator|=( Opt const &opt ) -> Parser & {
9492  m_options.push_back(opt);
9493  return *this;
9494  }
9495 
9496  auto operator|=( Parser const &other ) -> Parser & {
9497  m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end());
9498  m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end());
9499  return *this;
9500  }
9501 
9502  template<typename T>
9503  auto operator|( T const &other ) const -> Parser {
9504  return Parser( *this ) |= other;
9505  }
9506 
9507  // Forward deprecated interface with '+' instead of '|'
9508  template<typename T>
9509  auto operator+=( T const &other ) -> Parser & { return operator|=( other ); }
9510  template<typename T>
9511  auto operator+( T const &other ) const -> Parser { return operator|( other ); }
9512 
9513  auto getHelpColumns() const -> std::vector<HelpColumns> {
9514  std::vector<HelpColumns> cols;
9515  for (auto const &o : m_options) {
9516  auto childCols = o.getHelpColumns();
9517  cols.insert( cols.end(), childCols.begin(), childCols.end() );
9518  }
9519  return cols;
9520  }
9521 
9522  void writeToStream( std::ostream &os ) const {
9523  if (!m_exeName.name().empty()) {
9524  os << "usage:\n" << " " << m_exeName.name() << " ";
9525  bool required = true, first = true;
9526  for( auto const &arg : m_args ) {
9527  if (first)
9528  first = false;
9529  else
9530  os << " ";
9531  if( arg.isOptional() && required ) {
9532  os << "[";
9533  required = false;
9534  }
9535  os << "<" << arg.hint() << ">";
9536  if( arg.cardinality() == 0 )
9537  os << " ... ";
9538  }
9539  if( !required )
9540  os << "]";
9541  if( !m_options.empty() )
9542  os << " options";
9543  os << "\n\nwhere options are:" << std::endl;
9544  }
9545 
9546  auto rows = getHelpColumns();
9547  size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;
9548  size_t optWidth = 0;
9549  for( auto const &cols : rows )
9550  optWidth = (std::max)(optWidth, cols.left.size() + 2);
9551 
9552  optWidth = (std::min)(optWidth, consoleWidth/2);
9553 
9554  for( auto const &cols : rows ) {
9555  auto row =
9556  TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) +
9557  TextFlow::Spacer(4) +
9558  TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth );
9559  os << row << std::endl;
9560  }
9561  }
9562 
9563  friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& {
9564  parser.writeToStream( os );
9565  return os;
9566  }
9567 
9568  auto validate() const -> Result override {
9569  for( auto const &opt : m_options ) {
9570  auto result = opt.validate();
9571  if( !result )
9572  return result;
9573  }
9574  for( auto const &arg : m_args ) {
9575  auto result = arg.validate();
9576  if( !result )
9577  return result;
9578  }
9579  return Result::ok();
9580  }
9581 
9582  using ParserBase::parse;
9583 
9584  auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override {
9585 
9586  struct ParserInfo {
9587  ParserBase const* parser = nullptr;
9588  size_t count = 0;
9589  };
9590  const size_t totalParsers = m_options.size() + m_args.size();
9591  assert( totalParsers < 512 );
9592  // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
9593  ParserInfo parseInfos[512];
9594 
9595  {
9596  size_t i = 0;
9597  for (auto const &opt : m_options) parseInfos[i++].parser = &opt;
9598  for (auto const &arg : m_args) parseInfos[i++].parser = &arg;
9599  }
9600 
9601  m_exeName.set( exeName );
9602 
9603  auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9604  while( result.value().remainingTokens() ) {
9605  bool tokenParsed = false;
9606 
9607  for( size_t i = 0; i < totalParsers; ++i ) {
9608  auto& parseInfo = parseInfos[i];
9609  if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
9610  result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
9611  if (!result)
9612  return result;
9613  if (result.value().type() != ParseResultType::NoMatch) {
9614  tokenParsed = true;
9615  ++parseInfo.count;
9616  break;
9617  }
9618  }
9619  }
9620 
9621  if( result.value().type() == ParseResultType::ShortCircuitAll )
9622  return result;
9623  if( !tokenParsed )
9624  return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token );
9625  }
9626  // !TBD Check missing required options
9627  return result;
9628  }
9629  };
9630 
9631  template<typename DerivedT>
9632  template<typename T>
9633  auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
9634  return Parser() | static_cast<DerivedT const &>( *this ) | other;
9635  }
9636 } // namespace detail
9637 
9638 // A Combined parser
9639 using detail::Parser;
9640 
9641 // A parser for options
9642 using detail::Opt;
9643 
9644 // A parser for arguments
9645 using detail::Arg;
9646 
9647 // Wrapper for argc, argv from main()
9648 using detail::Args;
9649 
9650 // Specifies the name of the executable
9651 using detail::ExeName;
9652 
9653 // Convenience wrapper for option parser that specifies the help option
9654 using detail::Help;
9655 
9656 // enum of result types from a parse
9657 using detail::ParseResultType;
9658 
9659 // Result type for parser operation
9660 using detail::ParserResult;
9661 
9662 }} // namespace Catch::clara
9663 
9664 // end clara.hpp
9665 #ifdef __clang__
9666 #pragma clang diagnostic pop
9667 #endif
9668 
9669 // Restore Clara's value for console width, if present
9670 #ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
9671 #define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
9672 #undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
9673 #endif
9674 
9675 // end catch_clara.h
9676 namespace Catch {
9677 
9678  clara::Parser makeCommandLineParser( ConfigData& config );
9679 
9680 } // end namespace Catch
9681 
9682 // end catch_commandline.h
9683 #include <fstream>
9684 #include <ctime>
9685 
9686 namespace Catch {
9687 
9688  clara::Parser makeCommandLineParser( ConfigData& config ) {
9689 
9690  using namespace clara;
9691 
9692  auto const setWarning = [&]( std::string const& warning ) {
9693  auto warningSet = [&]() {
9694  if( warning == "NoAssertions" )
9695  return WarnAbout::NoAssertions;
9696 
9697  if ( warning == "NoTests" )
9698  return WarnAbout::NoTests;
9699 
9700  return WarnAbout::Nothing;
9701  }();
9702 
9703  if (warningSet == WarnAbout::Nothing)
9704  return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" );
9705  config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
9706  return ParserResult::ok( ParseResultType::Matched );
9707  };
9708  auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
9709  std::ifstream f( filename.c_str() );
9710  if( !f.is_open() )
9711  return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" );
9712 
9713  std::string line;
9714  while( std::getline( f, line ) ) {
9715  line = trim(line);
9716  if( !line.empty() && !startsWith( line, '#' ) ) {
9717  if( !startsWith( line, '"' ) )
9718  line = '"' + line + '"';
9719  config.testsOrTags.push_back( line );
9720  config.testsOrTags.emplace_back( "," );
9721  }
9722  }
9723  //Remove comma in the end
9724  if(!config.testsOrTags.empty())
9725  config.testsOrTags.erase( config.testsOrTags.end()-1 );
9726 
9727  return ParserResult::ok( ParseResultType::Matched );
9728  };
9729  auto const setTestOrder = [&]( std::string const& order ) {
9730  if( startsWith( "declared", order ) )
9731  config.runOrder = RunTests::InDeclarationOrder;
9732  else if( startsWith( "lexical", order ) )
9733  config.runOrder = RunTests::InLexicographicalOrder;
9734  else if( startsWith( "random", order ) )
9735  config.runOrder = RunTests::InRandomOrder;
9736  else
9737  return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
9738  return ParserResult::ok( ParseResultType::Matched );
9739  };
9740  auto const setRngSeed = [&]( std::string const& seed ) {
9741  if( seed != "time" )
9742  return clara::detail::convertInto( seed, config.rngSeed );
9743  config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
9744  return ParserResult::ok( ParseResultType::Matched );
9745  };
9746  auto const setColourUsage = [&]( std::string const& useColour ) {
9747  auto mode = toLower( useColour );
9748 
9749  if( mode == "yes" )
9750  config.useColour = UseColour::Yes;
9751  else if( mode == "no" )
9752  config.useColour = UseColour::No;
9753  else if( mode == "auto" )
9754  config.useColour = UseColour::Auto;
9755  else
9756  return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" );
9757  return ParserResult::ok( ParseResultType::Matched );
9758  };
9759  auto const setWaitForKeypress = [&]( std::string const& keypress ) {
9760  auto keypressLc = toLower( keypress );
9761  if (keypressLc == "never")
9762  config.waitForKeypress = WaitForKeypress::Never;
9763  else if( keypressLc == "start" )
9764  config.waitForKeypress = WaitForKeypress::BeforeStart;
9765  else if( keypressLc == "exit" )
9766  config.waitForKeypress = WaitForKeypress::BeforeExit;
9767  else if( keypressLc == "both" )
9768  config.waitForKeypress = WaitForKeypress::BeforeStartAndExit;
9769  else
9770  return ParserResult::runtimeError( "keypress argument must be one of: never, start, exit or both. '" + keypress + "' not recognised" );
9771  return ParserResult::ok( ParseResultType::Matched );
9772  };
9773  auto const setVerbosity = [&]( std::string const& verbosity ) {
9774  auto lcVerbosity = toLower( verbosity );
9775  if( lcVerbosity == "quiet" )
9776  config.verbosity = Verbosity::Quiet;
9777  else if( lcVerbosity == "normal" )
9778  config.verbosity = Verbosity::Normal;
9779  else if( lcVerbosity == "high" )
9780  config.verbosity = Verbosity::High;
9781  else
9782  return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" );
9783  return ParserResult::ok( ParseResultType::Matched );
9784  };
9785  auto const setReporter = [&]( std::string const& reporter ) {
9786  IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
9787 
9788  auto lcReporter = toLower( reporter );
9789  auto result = factories.find( lcReporter );
9790 
9791  if( factories.end() != result )
9792  config.reporterName = lcReporter;
9793  else
9794  return ParserResult::runtimeError( "Unrecognized reporter, '" + reporter + "'. Check available with --list-reporters" );
9795  return ParserResult::ok( ParseResultType::Matched );
9796  };
9797 
9798  auto cli
9799  = ExeName( config.processName )
9800  | Help( config.showHelp )
9801  | Opt( config.listTests )
9802  ["-l"]["--list-tests"]
9803  ( "list all/matching test cases" )
9804  | Opt( config.listTags )
9805  ["-t"]["--list-tags"]
9806  ( "list all/matching tags" )
9807  | Opt( config.showSuccessfulTests )
9808  ["-s"]["--success"]
9809  ( "include successful tests in output" )
9810  | Opt( config.shouldDebugBreak )
9811  ["-b"]["--break"]
9812  ( "break into debugger on failure" )
9813  | Opt( config.noThrow )
9814  ["-e"]["--nothrow"]
9815  ( "skip exception tests" )
9816  | Opt( config.showInvisibles )
9817  ["-i"]["--invisibles"]
9818  ( "show invisibles (tabs, newlines)" )
9819  | Opt( config.outputFilename, "filename" )
9820  ["-o"]["--out"]
9821  ( "output filename" )
9822  | Opt( setReporter, "name" )
9823  ["-r"]["--reporter"]
9824  ( "reporter to use (defaults to console)" )
9825  | Opt( config.name, "name" )
9826  ["-n"]["--name"]
9827  ( "suite name" )
9828  | Opt( [&]( bool ){ config.abortAfter = 1; } )
9829  ["-a"]["--abort"]
9830  ( "abort at first failure" )
9831  | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" )
9832  ["-x"]["--abortx"]
9833  ( "abort after x failures" )
9834  | Opt( setWarning, "warning name" )
9835  ["-w"]["--warn"]
9836  ( "enable warnings" )
9837  | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" )
9838  ["-d"]["--durations"]
9839  ( "show test durations" )
9840  | Opt( loadTestNamesFromFile, "filename" )
9841  ["-f"]["--input-file"]
9842  ( "load test names to run from a file" )
9843  | Opt( config.filenamesAsTags )
9844  ["-#"]["--filenames-as-tags"]
9845  ( "adds a tag for the filename" )
9846  | Opt( config.sectionsToRun, "section name" )
9847  ["-c"]["--section"]
9848  ( "specify section to run" )
9849  | Opt( setVerbosity, "quiet|normal|high" )
9850  ["-v"]["--verbosity"]
9851  ( "set output verbosity" )
9852  | Opt( config.listTestNamesOnly )
9853  ["--list-test-names-only"]
9854  ( "list all/matching test cases names only" )
9855  | Opt( config.listReporters )
9856  ["--list-reporters"]
9857  ( "list all reporters" )
9858  | Opt( setTestOrder, "decl|lex|rand" )
9859  ["--order"]
9860  ( "test case order (defaults to decl)" )
9861  | Opt( setRngSeed, "'time'|number" )
9862  ["--rng-seed"]
9863  ( "set a specific seed for random numbers" )
9864  | Opt( setColourUsage, "yes|no" )
9865  ["--use-colour"]
9866  ( "should output be colourised" )
9867  | Opt( config.libIdentify )
9868  ["--libidentify"]
9869  ( "report name and version according to libidentify standard" )
9870  | Opt( setWaitForKeypress, "never|start|exit|both" )
9871  ["--wait-for-keypress"]
9872  ( "waits for a keypress before exiting" )
9873  | Opt( config.benchmarkSamples, "samples" )
9874  ["--benchmark-samples"]
9875  ( "number of samples to collect (default: 100)" )
9876  | Opt( config.benchmarkResamples, "resamples" )
9877  ["--benchmark-resamples"]
9878  ( "number of resamples for the bootstrap (default: 100000)" )
9879  | Opt( config.benchmarkConfidenceInterval, "confidence interval" )
9880  ["--benchmark-confidence-interval"]
9881  ( "confidence interval for the bootstrap (between 0 and 1, default: 0.95)" )
9882  | Opt( config.benchmarkNoAnalysis )
9883  ["--benchmark-no-analysis"]
9884  ( "perform only measurements; do not perform any analysis" )
9885  | Opt( config.benchmarkWarmupTime, "benchmarkWarmupTime" )
9886  ["--benchmark-warmup-time"]
9887  ( "amount of time in milliseconds spent on warming up each test (default: 100)" )
9888  | Arg( config.testsOrTags, "test name|pattern|tags" )
9889  ( "which test or tests to use" );
9890 
9891  return cli;
9892  }
9893 
9894 } // end namespace Catch
9895 // end catch_commandline.cpp
9896 // start catch_common.cpp
9897 
9898 #include <cstring>
9899 #include <ostream>
9900 
9901 namespace Catch {
9902 
9903  bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept {
9904  return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);
9905  }
9906  bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept {
9907  // We can assume that the same file will usually have the same pointer.
9908  // Thus, if the pointers are the same, there is no point in calling the strcmp
9909  return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0));
9910  }
9911 
9912  std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
9913 #ifndef __GNUG__
9914  os << info.file << '(' << info.line << ')';
9915 #else
9916  os << info.file << ':' << info.line;
9917 #endif
9918  return os;
9919  }
9920 
9921  std::string StreamEndStop::operator+() const {
9922  return std::string();
9923  }
9924 
9925  NonCopyable::NonCopyable() = default;
9926  NonCopyable::~NonCopyable() = default;
9927 
9928 }
9929 // end catch_common.cpp
9930 // start catch_config.cpp
9931 
9932 namespace Catch {
9933 
9934  Config::Config( ConfigData const& data )
9935  : m_data( data ),
9936  m_stream( openStream() )
9937  {
9938  // We need to trim filter specs to avoid trouble with superfluous
9939  // whitespace (esp. important for bdd macros, as those are manually
9940  // aligned with whitespace).
9941 
9942  for (auto& elem : m_data.testsOrTags) {
9943  elem = trim(elem);
9944  }
9945  for (auto& elem : m_data.sectionsToRun) {
9946  elem = trim(elem);
9947  }
9948 
9949  TestSpecParser parser(ITagAliasRegistry::get());
9950  if (!m_data.testsOrTags.empty()) {
9951  m_hasTestFilters = true;
9952  for (auto const& testOrTags : m_data.testsOrTags) {
9953  parser.parse(testOrTags);
9954  }
9955  }
9956  m_testSpec = parser.testSpec();
9957  }
9958 
9959  std::string const& Config::getFilename() const {
9960  return m_data.outputFilename ;
9961  }
9962 
9963  bool Config::listTests() const { return m_data.listTests; }
9964  bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; }
9965  bool Config::listTags() const { return m_data.listTags; }
9966  bool Config::listReporters() const { return m_data.listReporters; }
9967 
9968  std::string Config::getProcessName() const { return m_data.processName; }
9969  std::string const& Config::getReporterName() const { return m_data.reporterName; }
9970 
9971  std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
9972  std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }
9973 
9974  TestSpec const& Config::testSpec() const { return m_testSpec; }
9975  bool Config::hasTestFilters() const { return m_hasTestFilters; }
9976 
9977  bool Config::showHelp() const { return m_data.showHelp; }
9978 
9979  // IConfig interface
9980  bool Config::allowThrows() const { return !m_data.noThrow; }
9981  std::ostream& Config::stream() const { return m_stream->stream(); }
9982  std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
9983  bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
9984  bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
9985  bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
9986  ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
9987  RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
9988  unsigned int Config::rngSeed() const { return m_data.rngSeed; }
9989  UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }
9990  bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; }
9991  int Config::abortAfter() const { return m_data.abortAfter; }
9992  bool Config::showInvisibles() const { return m_data.showInvisibles; }
9993  Verbosity Config::verbosity() const { return m_data.verbosity; }
9994 
9995  bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; }
9996  int Config::benchmarkSamples() const { return m_data.benchmarkSamples; }
9997  double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; }
9998  unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
9999  std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); }
10000 
10001  IStream const* Config::openStream() {
10002  return Catch::makeStream(m_data.outputFilename);
10003  }
10004 
10005 } // end namespace Catch
10006 // end catch_config.cpp
10007 // start catch_console_colour.cpp
10008 
10009 #if defined(__clang__)
10010 # pragma clang diagnostic push
10011 # pragma clang diagnostic ignored "-Wexit-time-destructors"
10012 #endif
10013 
10014 // start catch_errno_guard.h
10015 
10016 namespace Catch {
10017 
10018  class ErrnoGuard {
10019  public:
10020  ErrnoGuard();
10021  ~ErrnoGuard();
10022  private:
10023  int m_oldErrno;
10024  };
10025 
10026 }
10027 
10028 // end catch_errno_guard.h
10029 #include <sstream>
10030 
10031 namespace Catch {
10032  namespace {
10033 
10034  struct IColourImpl {
10035  virtual ~IColourImpl() = default;
10036  virtual void use( Colour::Code _colourCode ) = 0;
10037  };
10038 
10039  struct NoColourImpl : IColourImpl {
10040  void use( Colour::Code ) override {}
10041 
10042  static IColourImpl* instance() {
10043  static NoColourImpl s_instance;
10044  return &s_instance;
10045  }
10046  };
10047 
10048  } // anon namespace
10049 } // namespace Catch
10050 
10051 #if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI )
10052 # ifdef CATCH_PLATFORM_WINDOWS
10053 # define CATCH_CONFIG_COLOUR_WINDOWS
10054 # else
10055 # define CATCH_CONFIG_COLOUR_ANSI
10056 # endif
10057 #endif
10058 
10059 #if defined ( CATCH_CONFIG_COLOUR_WINDOWS )
10060 
10061 namespace Catch {
10062 namespace {
10063 
10064  class Win32ColourImpl : public IColourImpl {
10065  public:
10066  Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
10067  {
10068  CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
10069  GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );
10070  originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );
10071  originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
10072  }
10073 
10074  void use( Colour::Code _colourCode ) override {
10075  switch( _colourCode ) {
10076  case Colour::None: return setTextAttribute( originalForegroundAttributes );
10077  case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
10078  case Colour::Red: return setTextAttribute( FOREGROUND_RED );
10079  case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
10080  case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE );
10081  case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN );
10082  case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN );
10083  case Colour::Grey: return setTextAttribute( 0 );
10084 
10085  case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY );
10086  case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );
10087  case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );
10088  case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
10089  case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN );
10090 
10091  case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
10092 
10093  default:
10094  CATCH_ERROR( "Unknown colour requested" );
10095  }
10096  }
10097 
10098  private:
10099  void setTextAttribute( WORD _textAttribute ) {
10100  SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
10101  }
10102  HANDLE stdoutHandle;
10103  WORD originalForegroundAttributes;
10104  WORD originalBackgroundAttributes;
10105  };
10106 
10107  IColourImpl* platformColourInstance() {
10108  static Win32ColourImpl s_instance;
10109 
10111  UseColour::YesOrNo colourMode = config
10112  ? config->useColour()
10113  : UseColour::Auto;
10114  if( colourMode == UseColour::Auto )
10115  colourMode = UseColour::Yes;
10116  return colourMode == UseColour::Yes
10117  ? &s_instance
10118  : NoColourImpl::instance();
10119  }
10120 
10121 } // end anon namespace
10122 } // end namespace Catch
10123 
10124 #elif defined( CATCH_CONFIG_COLOUR_ANSI )
10125 
10126 #include <unistd.h>
10127 
10128 namespace Catch {
10129 namespace {
10130 
10131  // use POSIX/ ANSI console terminal codes
10132  // Thanks to Adam Strzelecki for original contribution
10133  // (http://github.com/nanoant)
10134  // https://github.com/philsquared/Catch/pull/131
10135  class PosixColourImpl : public IColourImpl {
10136  public:
10137  void use( Colour::Code _colourCode ) override {
10138  switch( _colourCode ) {
10139  case Colour::None:
10140  case Colour::White: return setColour( "[0m" );
10141  case Colour::Red: return setColour( "[0;31m" );
10142  case Colour::Green: return setColour( "[0;32m" );
10143  case Colour::Blue: return setColour( "[0;34m" );
10144  case Colour::Cyan: return setColour( "[0;36m" );
10145  case Colour::Yellow: return setColour( "[0;33m" );
10146  case Colour::Grey: return setColour( "[1;30m" );
10147 
10148  case Colour::LightGrey: return setColour( "[0;37m" );
10149  case Colour::BrightRed: return setColour( "[1;31m" );
10150  case Colour::BrightGreen: return setColour( "[1;32m" );
10151  case Colour::BrightWhite: return setColour( "[1;37m" );
10152  case Colour::BrightYellow: return setColour( "[1;33m" );
10153 
10154  case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
10155  default: CATCH_INTERNAL_ERROR( "Unknown colour requested" );
10156  }
10157  }
10158  static IColourImpl* instance() {
10159  static PosixColourImpl s_instance;
10160  return &s_instance;
10161  }
10162 
10163  private:
10164  void setColour( const char* _escapeCode ) {
10165  getCurrentContext().getConfig()->stream()
10166  << '\033' << _escapeCode;
10167  }
10168  };
10169 
10170  bool useColourOnPlatform() {
10171  return
10172 #if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
10173  !isDebuggerActive() &&
10174 #endif
10175 #if !(defined(__DJGPP__) && defined(__STRICT_ANSI__))
10176  isatty(STDOUT_FILENO)
10177 #else
10178  false
10179 #endif
10180  ;
10181  }
10182  IColourImpl* platformColourInstance() {
10183  ErrnoGuard guard;
10185  UseColour::YesOrNo colourMode = config
10186  ? config->useColour()
10187  : UseColour::Auto;
10188  if( colourMode == UseColour::Auto )
10189  colourMode = useColourOnPlatform()
10190  ? UseColour::Yes
10191  : UseColour::No;
10192  return colourMode == UseColour::Yes
10193  ? PosixColourImpl::instance()
10194  : NoColourImpl::instance();
10195  }
10196 
10197 } // end anon namespace
10198 } // end namespace Catch
10199 
10200 #else // not Windows or ANSI
10201 
10202 namespace Catch {
10203 
10204  static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); }
10205 
10206 } // end namespace Catch
10207 
10208 #endif // Windows/ ANSI/ None
10209 
10210 namespace Catch {
10211 
10212  Colour::Colour( Code _colourCode ) { use( _colourCode ); }
10213  Colour::Colour( Colour&& other ) noexcept {
10214  m_moved = other.m_moved;
10215  other.m_moved = true;
10216  }
10217  Colour& Colour::operator=( Colour&& other ) noexcept {
10218  m_moved = other.m_moved;
10219  other.m_moved = true;
10220  return *this;
10221  }
10222 
10223  Colour::~Colour(){ if( !m_moved ) use( None ); }
10224 
10225  void Colour::use( Code _colourCode ) {
10226  static IColourImpl* impl = platformColourInstance();
10227  // Strictly speaking, this cannot possibly happen.
10228  // However, under some conditions it does happen (see #1626),
10229  // and this change is small enough that we can let practicality
10230  // triumph over purity in this case.
10231  if (impl != nullptr) {
10232  impl->use( _colourCode );
10233  }
10234  }
10235 
10236  std::ostream& operator << ( std::ostream& os, Colour const& ) {
10237  return os;
10238  }
10239 
10240 } // end namespace Catch
10241 
10242 #if defined(__clang__)
10243 # pragma clang diagnostic pop
10244 #endif
10245 
10246 // end catch_console_colour.cpp
10247 // start catch_context.cpp
10248 
10249 namespace Catch {
10250 
10251  class Context : public IMutableContext, NonCopyable {
10252 
10253  public: // IContext
10254  IResultCapture* getResultCapture() override {
10255  return m_resultCapture;
10256  }
10257  IRunner* getRunner() override {
10258  return m_runner;
10259  }
10260 
10261  IConfigPtr const& getConfig() const override {
10262  return m_config;
10263  }
10264 
10265  ~Context() override;
10266 
10267  public: // IMutableContext
10268  void setResultCapture( IResultCapture* resultCapture ) override {
10269  m_resultCapture = resultCapture;
10270  }
10271  void setRunner( IRunner* runner ) override {
10272  m_runner = runner;
10273  }
10274  void setConfig( IConfigPtr const& config ) override {
10275  m_config = config;
10276  }
10277 
10279 
10280  private:
10281  IConfigPtr m_config;
10282  IRunner* m_runner = nullptr;
10283  IResultCapture* m_resultCapture = nullptr;
10284  };
10285 
10287 
10289  {
10290  currentContext = new Context();
10291  }
10292 
10293  void cleanUpContext() {
10295  IMutableContext::currentContext = nullptr;
10296  }
10297  IContext::~IContext() = default;
10299  Context::~Context() = default;
10300 
10301  SimplePcg32& rng() {
10302  static SimplePcg32 s_rng;
10303  return s_rng;
10304  }
10305 
10306 }
10307 // end catch_context.cpp
10308 // start catch_debug_console.cpp
10309 
10310 // start catch_debug_console.h
10311 
10312 #include <string>
10313 
10314 namespace Catch {
10315  void writeToDebugConsole( std::string const& text );
10316 }
10317 
10318 // end catch_debug_console.h
10319 #if defined(CATCH_CONFIG_ANDROID_LOGWRITE)
10320 #include <android/log.h>
10321 
10322  namespace Catch {
10323  void writeToDebugConsole( std::string const& text ) {
10324  __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() );
10325  }
10326  }
10327 
10328 #elif defined(CATCH_PLATFORM_WINDOWS)
10329 
10330  namespace Catch {
10331  void writeToDebugConsole( std::string const& text ) {
10332  ::OutputDebugStringA( text.c_str() );
10333  }
10334  }
10335 
10336 #else
10337 
10338  namespace Catch {
10339  void writeToDebugConsole( std::string const& text ) {
10340  // !TBD: Need a version for Mac/ XCode and other IDEs
10341  Catch::cout() << text;
10342  }
10343  }
10344 
10345 #endif // Platform
10346 // end catch_debug_console.cpp
10347 // start catch_debugger.cpp
10348 
10349 #if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
10350 
10351 # include <cassert>
10352 # include <sys/types.h>
10353 # include <unistd.h>
10354 # include <cstddef>
10355 # include <ostream>
10356 
10357 #ifdef __apple_build_version__
10358  // These headers will only compile with AppleClang (XCode)
10359  // For other compilers (Clang, GCC, ... ) we need to exclude them
10360 # include <sys/sysctl.h>
10361 #endif
10362 
10363  namespace Catch {
10364  #ifdef __apple_build_version__
10365  // The following function is taken directly from the following technical note:
10366  // https://developer.apple.com/library/archive/qa/qa1361/_index.html
10367 
10368  // Returns true if the current process is being debugged (either
10369  // running under the debugger or has a debugger attached post facto).
10370  bool isDebuggerActive(){
10371  int mib[4];
10372  struct kinfo_proc info;
10373  std::size_t size;
10374 
10375  // Initialize the flags so that, if sysctl fails for some bizarre
10376  // reason, we get a predictable result.
10377 
10378  info.kp_proc.p_flag = 0;
10379 
10380  // Initialize mib, which tells sysctl the info we want, in this case
10381  // we're looking for information about a specific process ID.
10382 
10383  mib[0] = CTL_KERN;
10384  mib[1] = KERN_PROC;
10385  mib[2] = KERN_PROC_PID;
10386  mib[3] = getpid();
10387 
10388  // Call sysctl.
10389 
10390  size = sizeof(info);
10391  if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {
10392  Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
10393  return false;
10394  }
10395 
10396  // We're being debugged if the P_TRACED flag is set.
10397 
10398  return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
10399  }
10400  #else
10401  bool isDebuggerActive() {
10402  // We need to find another way to determine this for non-appleclang compilers on macOS
10403  return false;
10404  }
10405  #endif
10406  } // namespace Catch
10407 
10408 #elif defined(CATCH_PLATFORM_LINUX)
10409  #include <fstream>
10410  #include <string>
10411 
10412  namespace Catch{
10413  // The standard POSIX way of detecting a debugger is to attempt to
10414  // ptrace() the process, but this needs to be done from a child and not
10415  // this process itself to still allow attaching to this process later
10416  // if wanted, so is rather heavy. Under Linux we have the PID of the
10417  // "debugger" (which doesn't need to be gdb, of course, it could also
10418  // be strace, for example) in /proc/$PID/status, so just get it from
10419  // there instead.
10420  bool isDebuggerActive(){
10421  // Libstdc++ has a bug, where std::ifstream sets errno to 0
10422  // This way our users can properly assert over errno values
10423  ErrnoGuard guard;
10424  std::ifstream in("/proc/self/status");
10425  for( std::string line; std::getline(in, line); ) {
10426  static const int PREFIX_LEN = 11;
10427  if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) {
10428  // We're traced if the PID is not 0 and no other PID starts
10429  // with 0 digit, so it's enough to check for just a single
10430  // character.
10431  return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0';
10432  }
10433  }
10434 
10435  return false;
10436  }
10437  } // namespace Catch
10438 #elif defined(_MSC_VER)
10439  extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
10440  namespace Catch {
10441  bool isDebuggerActive() {
10442  return IsDebuggerPresent() != 0;
10443  }
10444  }
10445 #elif defined(__MINGW32__)
10446  extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
10447  namespace Catch {
10448  bool isDebuggerActive() {
10449  return IsDebuggerPresent() != 0;
10450  }
10451  }
10452 #else
10453  namespace Catch {
10454  bool isDebuggerActive() { return false; }
10455  }
10456 #endif // Platform
10457 // end catch_debugger.cpp
10458 // start catch_decomposer.cpp
10459 
10460 namespace Catch {
10461 
10463 
10464  void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) {
10465  if( lhs.size() + rhs.size() < 40 &&
10466  lhs.find('\n') == std::string::npos &&
10467  rhs.find('\n') == std::string::npos )
10468  os << lhs << " " << op << " " << rhs;
10469  else
10470  os << lhs << "\n" << op << "\n" << rhs;
10471  }
10472 }
10473 // end catch_decomposer.cpp
10474 // start catch_enforce.cpp
10475 
10476 #include <stdexcept>
10477 
10478 namespace Catch {
10479 #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER)
10480  [[noreturn]]
10481  void throw_exception(std::exception const& e) {
10482  Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n"
10483  << "The message was: " << e.what() << '\n';
10484  std::terminate();
10485  }
10486 #endif
10487 
10488  [[noreturn]]
10489  void throw_logic_error(std::string const& msg) {
10490  throw_exception(std::logic_error(msg));
10491  }
10492 
10493  [[noreturn]]
10494  void throw_domain_error(std::string const& msg) {
10495  throw_exception(std::domain_error(msg));
10496  }
10497 
10498  [[noreturn]]
10499  void throw_runtime_error(std::string const& msg) {
10500  throw_exception(std::runtime_error(msg));
10501  }
10502 
10503 } // namespace Catch;
10504 // end catch_enforce.cpp
10505 // start catch_enum_values_registry.cpp
10506 // start catch_enum_values_registry.h
10507 
10508 #include <vector>
10509 #include <memory>
10510 
10511 namespace Catch {
10512 
10513  namespace Detail {
10514 
10515  std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values );
10516 
10517  class EnumValuesRegistry : public IMutableEnumValuesRegistry {
10518 
10519  std::vector<std::unique_ptr<EnumInfo>> m_enumInfos;
10520 
10521  EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override;
10522  };
10523 
10524  std::vector<StringRef> parseEnums( StringRef enums );
10525 
10526  } // Detail
10527 
10528 } // Catch
10529 
10530 // end catch_enum_values_registry.h
10531 
10532 #include <map>
10533 #include <cassert>
10534 
10535 namespace Catch {
10536 
10538 
10539  namespace Detail {
10540 
10541  namespace {
10542  // Extracts the actual name part of an enum instance
10543  // In other words, it returns the Blue part of Bikeshed::Colour::Blue
10544  StringRef extractInstanceName(StringRef enumInstance) {
10545  // Find last occurence of ":"
10546  size_t name_start = enumInstance.size();
10547  while (name_start > 0 && enumInstance[name_start - 1] != ':') {
10548  --name_start;
10549  }
10550  return enumInstance.substr(name_start, enumInstance.size() - name_start);
10551  }
10552  }
10553 
10554  std::vector<StringRef> parseEnums( StringRef enums ) {
10555  auto enumValues = splitStringRef( enums, ',' );
10556  std::vector<StringRef> parsed;
10557  parsed.reserve( enumValues.size() );
10558  for( auto const& enumValue : enumValues ) {
10559  parsed.push_back(trim(extractInstanceName(enumValue)));
10560  }
10561  return parsed;
10562  }
10563 
10564  EnumInfo::~EnumInfo() {}
10565 
10566  StringRef EnumInfo::lookup( int value ) const {
10567  for( auto const& valueToName : m_values ) {
10568  if( valueToName.first == value )
10569  return valueToName.second;
10570  }
10571  return "{** unexpected enum value **}"_sr;
10572  }
10573 
10574  std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) {
10575  std::unique_ptr<EnumInfo> enumInfo( new EnumInfo );
10576  enumInfo->m_name = enumName;
10577  enumInfo->m_values.reserve( values.size() );
10578 
10579  const auto valueNames = Catch::Detail::parseEnums( allValueNames );
10580  assert( valueNames.size() == values.size() );
10581  std::size_t i = 0;
10582  for( auto value : values )
10583  enumInfo->m_values.emplace_back(value, valueNames[i++]);
10584 
10585  return enumInfo;
10586  }
10587 
10588  EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) {
10589  m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values));
10590  return *m_enumInfos.back();
10591  }
10592 
10593  } // Detail
10594 } // Catch
10595 
10596 // end catch_enum_values_registry.cpp
10597 // start catch_errno_guard.cpp
10598 
10599 #include <cerrno>
10600 
10601 namespace Catch {
10602  ErrnoGuard::ErrnoGuard():m_oldErrno(errno){}
10603  ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; }
10604 }
10605 // end catch_errno_guard.cpp
10606 // start catch_exception_translator_registry.cpp
10607 
10608 // start catch_exception_translator_registry.h
10609 
10610 #include <vector>
10611 #include <string>
10612 #include <memory>
10613 
10614 namespace Catch {
10615 
10616  class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
10617  public:
10618  ~ExceptionTranslatorRegistry();
10619  virtual void registerTranslator( const IExceptionTranslator* translator );
10620  std::string translateActiveException() const override;
10621  std::string tryTranslators() const;
10622 
10623  private:
10624  std::vector<std::unique_ptr<IExceptionTranslator const>> m_translators;
10625  };
10626 }
10627 
10628 // end catch_exception_translator_registry.h
10629 #ifdef __OBJC__
10630 #import "Foundation/Foundation.h"
10631 #endif
10632 
10633 namespace Catch {
10634 
10635  ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() {
10636  }
10637 
10638  void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) {
10639  m_translators.push_back( std::unique_ptr<const IExceptionTranslator>( translator ) );
10640  }
10641 
10642 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
10644  try {
10645 #ifdef __OBJC__
10646  // In Objective-C try objective-c exceptions first
10647  @try {
10648  return tryTranslators();
10649  }
10650  @catch (NSException *exception) {
10651  return Catch::Detail::stringify( [exception description] );
10652  }
10653 #else
10654  // Compiling a mixed mode project with MSVC means that CLR
10655  // exceptions will be caught in (...) as well. However, these
10656  // do not fill-in std::current_exception and thus lead to crash
10657  // when attempting rethrow.
10658  // /EHa switch also causes structured exceptions to be caught
10659  // here, but they fill-in current_exception properly, so
10660  // at worst the output should be a little weird, instead of
10661  // causing a crash.
10662  if (std::current_exception() == nullptr) {
10663  return "Non C++ exception. Possibly a CLR exception.";
10664  }
10665  return tryTranslators();
10666 #endif
10667  }
10668  catch( TestFailureException& ) {
10669  std::rethrow_exception(std::current_exception());
10670  }
10671  catch( std::exception& ex ) {
10672  return ex.what();
10673  }
10674  catch( std::string& msg ) {
10675  return msg;
10676  }
10677  catch( const char* msg ) {
10678  return msg;
10679  }
10680  catch(...) {
10681  return "Unknown exception";
10682  }
10683  }
10684 
10685  std::string ExceptionTranslatorRegistry::tryTranslators() const {
10686  if (m_translators.empty()) {
10687  std::rethrow_exception(std::current_exception());
10688  } else {
10689  return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end());
10690  }
10691  }
10692 
10693 #else // ^^ Exceptions are enabled // Exceptions are disabled vv
10695  CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
10696  }
10697 
10698  std::string ExceptionTranslatorRegistry::tryTranslators() const {
10699  CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
10700  }
10701 #endif
10702 
10703 }
10704 // end catch_exception_translator_registry.cpp
10705 // start catch_fatal_condition.cpp
10706 
10707 #if defined(__GNUC__)
10708 # pragma GCC diagnostic push
10709 # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
10710 #endif
10711 
10712 #if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS )
10713 
10714 namespace {
10715  // Report the error condition
10716  void reportFatal( char const * const message ) {
10718  }
10719 }
10720 
10721 #endif // signals/SEH handling
10722 
10723 #if defined( CATCH_CONFIG_WINDOWS_SEH )
10724 
10725 namespace Catch {
10726  struct SignalDefs { DWORD id; const char* name; };
10727 
10728  // There is no 1-1 mapping between signals and windows exceptions.
10729  // Windows can easily distinguish between SO and SigSegV,
10730  // but SigInt, SigTerm, etc are handled differently.
10731  static SignalDefs signalDefs[] = {
10732  { static_cast<DWORD>(EXCEPTION_ILLEGAL_INSTRUCTION), "SIGILL - Illegal instruction signal" },
10733  { static_cast<DWORD>(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow" },
10734  { static_cast<DWORD>(EXCEPTION_ACCESS_VIOLATION), "SIGSEGV - Segmentation violation signal" },
10735  { static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" },
10736  };
10737 
10738  LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
10739  for (auto const& def : signalDefs) {
10740  if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
10741  reportFatal(def.name);
10742  }
10743  }
10744  // If its not an exception we care about, pass it along.
10745  // This stops us from eating debugger breaks etc.
10746  return EXCEPTION_CONTINUE_SEARCH;
10747  }
10748 
10749  FatalConditionHandler::FatalConditionHandler() {
10750  isSet = true;
10751  // 32k seems enough for Catch to handle stack overflow,
10752  // but the value was found experimentally, so there is no strong guarantee
10753  guaranteeSize = 32 * 1024;
10754  exceptionHandlerHandle = nullptr;
10755  // Register as first handler in current chain
10756  exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
10757  // Pass in guarantee size to be filled
10758  SetThreadStackGuarantee(&guaranteeSize);
10759  }
10760 
10762  if (isSet) {
10763  RemoveVectoredExceptionHandler(exceptionHandlerHandle);
10764  SetThreadStackGuarantee(&guaranteeSize);
10765  exceptionHandlerHandle = nullptr;
10766  isSet = false;
10767  }
10768  }
10769 
10770  FatalConditionHandler::~FatalConditionHandler() {
10771  reset();
10772  }
10773 
10774 bool FatalConditionHandler::isSet = false;
10775 ULONG FatalConditionHandler::guaranteeSize = 0;
10776 PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;
10777 
10778 } // namespace Catch
10779 
10780 #elif defined( CATCH_CONFIG_POSIX_SIGNALS )
10781 
10782 namespace Catch {
10783 
10784  struct SignalDefs {
10785  int id;
10786  const char* name;
10787  };
10788 
10789  // 32kb for the alternate stack seems to be sufficient. However, this value
10790  // is experimentally determined, so that's not guaranteed.
10791  static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
10792 
10793  static SignalDefs signalDefs[] = {
10794  { SIGINT, "SIGINT - Terminal interrupt signal" },
10795  { SIGILL, "SIGILL - Illegal instruction signal" },
10796  { SIGFPE, "SIGFPE - Floating point error signal" },
10797  { SIGSEGV, "SIGSEGV - Segmentation violation signal" },
10798  { SIGTERM, "SIGTERM - Termination request signal" },
10799  { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
10800  };
10801 
10802  void FatalConditionHandler::handleSignal( int sig ) {
10803  char const * name = "<unknown signal>";
10804  for (auto const& def : signalDefs) {
10805  if (sig == def.id) {
10806  name = def.name;
10807  break;
10808  }
10809  }
10810  reset();
10811  reportFatal(name);
10812  raise( sig );
10813  }
10814 
10815  FatalConditionHandler::FatalConditionHandler() {
10816  isSet = true;
10817  stack_t sigStack;
10818  sigStack.ss_sp = altStackMem;
10819  sigStack.ss_size = sigStackSize;
10820  sigStack.ss_flags = 0;
10821  sigaltstack(&sigStack, &oldSigStack);
10822  struct sigaction sa = { };
10823 
10824  sa.sa_handler = handleSignal;
10825  sa.sa_flags = SA_ONSTACK;
10826  for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) {
10827  sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
10828  }
10829  }
10830 
10831  FatalConditionHandler::~FatalConditionHandler() {
10832  reset();
10833  }
10834 
10836  if( isSet ) {
10837  // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
10838  for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {
10839  sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
10840  }
10841  // Return the old stack
10842  sigaltstack(&oldSigStack, nullptr);
10843  isSet = false;
10844  }
10845  }
10846 
10847  bool FatalConditionHandler::isSet = false;
10848  struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
10849  stack_t FatalConditionHandler::oldSigStack = {};
10850  char FatalConditionHandler::altStackMem[sigStackSize] = {};
10851 
10852 } // namespace Catch
10853 
10854 #else
10855 
10856 namespace Catch {
10858 }
10859 
10860 #endif // signals/SEH handling
10861 
10862 #if defined(__GNUC__)
10863 # pragma GCC diagnostic pop
10864 #endif
10865 // end catch_fatal_condition.cpp
10866 // start catch_generators.cpp
10867 
10868 #include <limits>
10869 #include <set>
10870 
10871 namespace Catch {
10872 
10874 
10875 const char* GeneratorException::what() const noexcept {
10876  return m_msg;
10877 }
10878 
10879 namespace Generators {
10880 
10881  GeneratorUntypedBase::~GeneratorUntypedBase() {}
10882 
10883  auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {
10884  return getResultCapture().acquireGeneratorTracker( lineInfo );
10885  }
10886 
10887 } // namespace Generators
10888 } // namespace Catch
10889 // end catch_generators.cpp
10890 // start catch_interfaces_capture.cpp
10891 
10892 namespace Catch {
10893  IResultCapture::~IResultCapture() = default;
10894 }
10895 // end catch_interfaces_capture.cpp
10896 // start catch_interfaces_config.cpp
10897 
10898 namespace Catch {
10899  IConfig::~IConfig() = default;
10900 }
10901 // end catch_interfaces_config.cpp
10902 // start catch_interfaces_exception.cpp
10903 
10904 namespace Catch {
10907 }
10908 // end catch_interfaces_exception.cpp
10909 // start catch_interfaces_registry_hub.cpp
10910 
10911 namespace Catch {
10912  IRegistryHub::~IRegistryHub() = default;
10914 }
10915 // end catch_interfaces_registry_hub.cpp
10916 // start catch_interfaces_reporter.cpp
10917 
10918 // start catch_reporter_listening.h
10919 
10920 namespace Catch {
10921 
10922  class ListeningReporter : public IStreamingReporter {
10923  using Reporters = std::vector<IStreamingReporterPtr>;
10924  Reporters m_listeners;
10925  IStreamingReporterPtr m_reporter = nullptr;
10926  ReporterPreferences m_preferences;
10927 
10928  public:
10929  ListeningReporter();
10930 
10931  void addListener( IStreamingReporterPtr&& listener );
10932  void addReporter( IStreamingReporterPtr&& reporter );
10933 
10934  public: // IStreamingReporter
10935 
10936  ReporterPreferences getPreferences() const override;
10937 
10938  void noMatchingTestCases( std::string const& spec ) override;
10939 
10940  void reportInvalidArguments(std::string const&arg) override;
10941 
10942  static std::set<Verbosity> getSupportedVerbosities();
10943 
10944 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
10945  void benchmarkPreparing(std::string const& name) override;
10946  void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;
10947  void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override;
10948  void benchmarkFailed(std::string const&) override;
10949 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
10950 
10951  void testRunStarting( TestRunInfo const& testRunInfo ) override;
10952  void testGroupStarting( GroupInfo const& groupInfo ) override;
10953  void testCaseStarting( TestCaseInfo const& testInfo ) override;
10954  void sectionStarting( SectionInfo const& sectionInfo ) override;
10955  void assertionStarting( AssertionInfo const& assertionInfo ) override;
10956 
10957  // The return value indicates if the messages buffer should be cleared:
10958  bool assertionEnded( AssertionStats const& assertionStats ) override;
10959  void sectionEnded( SectionStats const& sectionStats ) override;
10960  void testCaseEnded( TestCaseStats const& testCaseStats ) override;
10961  void testGroupEnded( TestGroupStats const& testGroupStats ) override;
10962  void testRunEnded( TestRunStats const& testRunStats ) override;
10963 
10964  void skipTest( TestCaseInfo const& testInfo ) override;
10965  bool isMulti() const override;
10966 
10967  };
10968 
10969 } // end namespace Catch
10970 
10971 // end catch_reporter_listening.h
10972 namespace Catch {
10973 
10974  ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig )
10975  : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
10976 
10977  ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream )
10978  : m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
10979 
10980  std::ostream& ReporterConfig::stream() const { return *m_stream; }
10981  IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; }
10982 
10983  TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {}
10984 
10985  GroupInfo::GroupInfo( std::string const& _name,
10986  std::size_t _groupIndex,
10987  std::size_t _groupsCount )
10988  : name( _name ),
10989  groupIndex( _groupIndex ),
10990  groupsCounts( _groupsCount )
10991  {}
10992 
10993  AssertionStats::AssertionStats( AssertionResult const& _assertionResult,
10994  std::vector<MessageInfo> const& _infoMessages,
10995  Totals const& _totals )
10996  : assertionResult( _assertionResult ),
10997  infoMessages( _infoMessages ),
10998  totals( _totals )
10999  {
11000  assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression;
11001 
11002  if( assertionResult.hasMessage() ) {
11003  // Copy message into messages list.
11004  // !TBD This should have been done earlier, somewhere
11005  MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
11006  builder << assertionResult.getMessage();
11007  builder.m_info.message = builder.m_stream.str();
11008 
11009  infoMessages.push_back( builder.m_info );
11010  }
11011  }
11012 
11013  AssertionStats::~AssertionStats() = default;
11014 
11015  SectionStats::SectionStats( SectionInfo const& _sectionInfo,
11016  Counts const& _assertions,
11017  double _durationInSeconds,
11018  bool _missingAssertions )
11019  : sectionInfo( _sectionInfo ),
11020  assertions( _assertions ),
11021  durationInSeconds( _durationInSeconds ),
11022  missingAssertions( _missingAssertions )
11023  {}
11024 
11025  SectionStats::~SectionStats() = default;
11026 
11027  TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo,
11028  Totals const& _totals,
11029  std::string const& _stdOut,
11030  std::string const& _stdErr,
11031  bool _aborting )
11032  : testInfo( _testInfo ),
11033  totals( _totals ),
11034  stdOut( _stdOut ),
11035  stdErr( _stdErr ),
11036  aborting( _aborting )
11037  {}
11038 
11039  TestCaseStats::~TestCaseStats() = default;
11040 
11041  TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo,
11042  Totals const& _totals,
11043  bool _aborting )
11044  : groupInfo( _groupInfo ),
11045  totals( _totals ),
11046  aborting( _aborting )
11047  {}
11048 
11049  TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo )
11050  : groupInfo( _groupInfo ),
11051  aborting( false )
11052  {}
11053 
11054  TestGroupStats::~TestGroupStats() = default;
11055 
11056  TestRunStats::TestRunStats( TestRunInfo const& _runInfo,
11057  Totals const& _totals,
11058  bool _aborting )
11059  : runInfo( _runInfo ),
11060  totals( _totals ),
11061  aborting( _aborting )
11062  {}
11063 
11064  TestRunStats::~TestRunStats() = default;
11065 
11066  void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
11067  bool IStreamingReporter::isMulti() const { return false; }
11068 
11069  IReporterFactory::~IReporterFactory() = default;
11070  IReporterRegistry::~IReporterRegistry() = default;
11071 
11072 } // end namespace Catch
11073 // end catch_interfaces_reporter.cpp
11074 // start catch_interfaces_runner.cpp
11075 
11076 namespace Catch {
11077  IRunner::~IRunner() = default;
11078 }
11079 // end catch_interfaces_runner.cpp
11080 // start catch_interfaces_testcase.cpp
11081 
11082 namespace Catch {
11083  ITestInvoker::~ITestInvoker() = default;
11085 }
11086 // end catch_interfaces_testcase.cpp
11087 // start catch_leak_detector.cpp
11088 
11089 #ifdef CATCH_CONFIG_WINDOWS_CRTDBG
11090 #include <crtdbg.h>
11091 
11092 namespace Catch {
11093 
11094  LeakDetector::LeakDetector() {
11095  int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
11096  flag |= _CRTDBG_LEAK_CHECK_DF;
11097  flag |= _CRTDBG_ALLOC_MEM_DF;
11098  _CrtSetDbgFlag(flag);
11099  _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
11100  _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
11101  // Change this to leaking allocation's number to break there
11102  _CrtSetBreakAlloc(-1);
11103  }
11104 }
11105 
11106 #else
11107 
11108  Catch::LeakDetector::LeakDetector() {}
11109 
11110 #endif
11111 
11112 Catch::LeakDetector::~LeakDetector() {
11113  Catch::cleanUp();
11114 }
11115 // end catch_leak_detector.cpp
11116 // start catch_list.cpp
11117 
11118 // start catch_list.h
11119 
11120 #include <set>
11121 
11122 namespace Catch {
11123 
11124  std::size_t listTests( Config const& config );
11125 
11126  std::size_t listTestsNamesOnly( Config const& config );
11127 
11128  struct TagInfo {
11129  void add( std::string const& spelling );
11130  std::string all() const;
11131 
11132  std::set<std::string> spellings;
11133  std::size_t count = 0;
11134  };
11135 
11136  std::size_t listTags( Config const& config );
11137 
11138  std::size_t listReporters();
11139 
11140  Option<std::size_t> list( std::shared_ptr<Config> const& config );
11141 
11142 } // end namespace Catch
11143 
11144 // end catch_list.h
11145 // start catch_text.h
11146 
11147 namespace Catch {
11148  using namespace clara::TextFlow;
11149 }
11150 
11151 // end catch_text.h
11152 #include <limits>
11153 #include <algorithm>
11154 #include <iomanip>
11155 
11156 namespace Catch {
11157 
11158  std::size_t listTests( Config const& config ) {
11159  TestSpec const& testSpec = config.testSpec();
11160  if( config.hasTestFilters() )
11161  Catch::cout() << "Matching test cases:\n";
11162  else {
11163  Catch::cout() << "All available test cases:\n";
11164  }
11165 
11166  auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
11167  for( auto const& testCaseInfo : matchedTestCases ) {
11168  Colour::Code colour = testCaseInfo.isHidden()
11169  ? Colour::SecondaryText
11170  : Colour::None;
11171  Colour colourGuard( colour );
11172 
11173  Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n";
11174  if( config.verbosity() >= Verbosity::High ) {
11175  Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl;
11176  std::string description = testCaseInfo.description;
11177  if( description.empty() )
11178  description = "(NO DESCRIPTION)";
11179  Catch::cout() << Column( description ).indent(4) << std::endl;
11180  }
11181  if( !testCaseInfo.tags.empty() )
11182  Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n";
11183  }
11184 
11185  if( !config.hasTestFilters() )
11186  Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl;
11187  else
11188  Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl;
11189  return matchedTestCases.size();
11190  }
11191 
11192  std::size_t listTestsNamesOnly( Config const& config ) {
11193  TestSpec const& testSpec = config.testSpec();
11194  std::size_t matchedTests = 0;
11195  std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
11196  for( auto const& testCaseInfo : matchedTestCases ) {
11197  matchedTests++;
11198  if( startsWith( testCaseInfo.name, '#' ) )
11199  Catch::cout() << '"' << testCaseInfo.name << '"';
11200  else
11201  Catch::cout() << testCaseInfo.name;
11202  if ( config.verbosity() >= Verbosity::High )
11203  Catch::cout() << "\t@" << testCaseInfo.lineInfo;
11204  Catch::cout() << std::endl;
11205  }
11206  return matchedTests;
11207  }
11208 
11209  void TagInfo::add( std::string const& spelling ) {
11210  ++count;
11211  spellings.insert( spelling );
11212  }
11213 
11214  std::string TagInfo::all() const {
11215  size_t size = 0;
11216  for (auto const& spelling : spellings) {
11217  // Add 2 for the brackes
11218  size += spelling.size() + 2;
11219  }
11220 
11221  std::string out; out.reserve(size);
11222  for (auto const& spelling : spellings) {
11223  out += '[';
11224  out += spelling;
11225  out += ']';
11226  }
11227  return out;
11228  }
11229 
11230  std::size_t listTags( Config const& config ) {
11231  TestSpec const& testSpec = config.testSpec();
11232  if( config.hasTestFilters() )
11233  Catch::cout() << "Tags for matching test cases:\n";
11234  else {
11235  Catch::cout() << "All available tags:\n";
11236  }
11237 
11238  std::map<std::string, TagInfo> tagCounts;
11239 
11240  std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
11241  for( auto const& testCase : matchedTestCases ) {
11242  for( auto const& tagName : testCase.getTestCaseInfo().tags ) {
11243  std::string lcaseTagName = toLower( tagName );
11244  auto countIt = tagCounts.find( lcaseTagName );
11245  if( countIt == tagCounts.end() )
11246  countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first;
11247  countIt->second.add( tagName );
11248  }
11249  }
11250 
11251  for( auto const& tagCount : tagCounts ) {
11253  rss << " " << std::setw(2) << tagCount.second.count << " ";
11254  auto str = rss.str();
11255  auto wrapper = Column( tagCount.second.all() )
11256  .initialIndent( 0 )
11257  .indent( str.size() )
11258  .width( CATCH_CONFIG_CONSOLE_WIDTH-10 );
11259  Catch::cout() << str << wrapper << '\n';
11260  }
11261  Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl;
11262  return tagCounts.size();
11263  }
11264 
11265  std::size_t listReporters() {
11266  Catch::cout() << "Available reporters:\n";
11267  IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
11268  std::size_t maxNameLen = 0;
11269  for( auto const& factoryKvp : factories )
11270  maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() );
11271 
11272  for( auto const& factoryKvp : factories ) {
11273  Catch::cout()
11274  << Column( factoryKvp.first + ":" )
11275  .indent(2)
11276  .width( 5+maxNameLen )
11277  + Column( factoryKvp.second->getDescription() )
11278  .initialIndent(0)
11279  .indent(2)
11280  .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 )
11281  << "\n";
11282  }
11283  Catch::cout() << std::endl;
11284  return factories.size();
11285  }
11286 
11287  Option<std::size_t> list( std::shared_ptr<Config> const& config ) {
11288  Option<std::size_t> listedCount;
11289  getCurrentMutableContext().setConfig( config );
11290  if( config->listTests() )
11291  listedCount = listedCount.valueOr(0) + listTests( *config );
11292  if( config->listTestNamesOnly() )
11293  listedCount = listedCount.valueOr(0) + listTestsNamesOnly( *config );
11294  if( config->listTags() )
11295  listedCount = listedCount.valueOr(0) + listTags( *config );
11296  if( config->listReporters() )
11297  listedCount = listedCount.valueOr(0) + listReporters();
11298  return listedCount;
11299  }
11300 
11301 } // end namespace Catch
11302 // end catch_list.cpp
11303 // start catch_matchers.cpp
11304 
11305 namespace Catch {
11306 namespace Matchers {
11307  namespace Impl {
11308 
11309  std::string MatcherUntypedBase::toString() const {
11310  if( m_cachedToString.empty() )
11311  m_cachedToString = describe();
11312  return m_cachedToString;
11313  }
11314 
11315  MatcherUntypedBase::~MatcherUntypedBase() = default;
11316 
11317  } // namespace Impl
11318 } // namespace Matchers
11319 
11320 using namespace Matchers;
11322 
11323 } // namespace Catch
11324 // end catch_matchers.cpp
11325 // start catch_matchers_exception.cpp
11326 
11327 namespace Catch {
11328 namespace Matchers {
11329 namespace Exception {
11330 
11331 bool ExceptionMessageMatcher::match(std::exception const& ex) const {
11332  return ex.what() == m_message;
11333 }
11334 
11335 std::string ExceptionMessageMatcher::describe() const {
11336  return "exception message matches \"" + m_message + "\"";
11337 }
11338 
11339 }
11341  return Exception::ExceptionMessageMatcher(message);
11342 }
11343 
11344 // namespace Exception
11345 } // namespace Matchers
11346 } // namespace Catch
11347 // end catch_matchers_exception.cpp
11348 // start catch_matchers_floating.cpp
11349 
11350 // start catch_polyfills.hpp
11351 
11352 namespace Catch {
11353  bool isnan(float f);
11354  bool isnan(double d);
11355 }
11356 
11357 // end catch_polyfills.hpp
11358 // start catch_to_string.hpp
11359 
11360 #include <string>
11361 
11362 namespace Catch {
11363  template <typename T>
11364  std::string to_string(T const& t) {
11365 #if defined(CATCH_CONFIG_CPP11_TO_STRING)
11366  return std::to_string(t);
11367 #else
11369  rss << t;
11370  return rss.str();
11371 #endif
11372  }
11373 } // end namespace Catch
11374 
11375 // end catch_to_string.hpp
11376 #include <algorithm>
11377 #include <cmath>
11378 #include <cstdlib>
11379 #include <cstdint>
11380 #include <cstring>
11381 #include <sstream>
11382 #include <type_traits>
11383 #include <iomanip>
11384 #include <limits>
11385 
11386 namespace Catch {
11387 namespace {
11388 
11389  int32_t convert(float f) {
11390  static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated");
11391  int32_t i;
11392  std::memcpy(&i, &f, sizeof(f));
11393  return i;
11394  }
11395 
11396  int64_t convert(double d) {
11397  static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated");
11398  int64_t i;
11399  std::memcpy(&i, &d, sizeof(d));
11400  return i;
11401  }
11402 
11403  template <typename FP>
11404  bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) {
11405  // Comparison with NaN should always be false.
11406  // This way we can rule it out before getting into the ugly details
11407  if (Catch::isnan(lhs) || Catch::isnan(rhs)) {
11408  return false;
11409  }
11410 
11411  auto lc = convert(lhs);
11412  auto rc = convert(rhs);
11413 
11414  if ((lc < 0) != (rc < 0)) {
11415  // Potentially we can have +0 and -0
11416  return lhs == rhs;
11417  }
11418 
11419  auto ulpDiff = std::abs(lc - rc);
11420  return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
11421  }
11422 
11423 #if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
11424 
11425  float nextafter(float x, float y) {
11426  return ::nextafterf(x, y);
11427  }
11428 
11429  double nextafter(double x, double y) {
11430  return ::nextafter(x, y);
11431  }
11432 
11433 #endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^
11434 
11435 template <typename FP>
11436 FP step(FP start, FP direction, uint64_t steps) {
11437  for (uint64_t i = 0; i < steps; ++i) {
11438 #if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
11439  start = Catch::nextafter(start, direction);
11440 #else
11441  start = std::nextafter(start, direction);
11442 #endif
11443  }
11444  return start;
11445 }
11446 
11447 // Performs equivalent check of std::fabs(lhs - rhs) <= margin
11448 // But without the subtraction to allow for INFINITY in comparison
11449 bool marginComparison(double lhs, double rhs, double margin) {
11450  return (lhs + margin >= rhs) && (rhs + margin >= lhs);
11451 }
11452 
11453 template <typename FloatingPoint>
11454 void write(std::ostream& out, FloatingPoint num) {
11455  out << std::scientific
11456  << std::setprecision(std::numeric_limits<FloatingPoint>::max_digits10 - 1)
11457  << num;
11458 }
11459 
11460 } // end anonymous namespace
11461 
11462 namespace Matchers {
11463 namespace Floating {
11464 
11465  enum class FloatingPointKind : uint8_t {
11466  Float,
11467  Double
11468  };
11469 
11470  WithinAbsMatcher::WithinAbsMatcher(double target, double margin)
11471  :m_target{ target }, m_margin{ margin } {
11472  CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.'
11473  << " Margin has to be non-negative.");
11474  }
11475 
11476  // Performs equivalent check of std::fabs(lhs - rhs) <= margin
11477  // But without the subtraction to allow for INFINITY in comparison
11478  bool WithinAbsMatcher::match(double const& matchee) const {
11479  return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee);
11480  }
11481 
11482  std::string WithinAbsMatcher::describe() const {
11483  return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target);
11484  }
11485 
11486  WithinUlpsMatcher::WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType)
11487  :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } {
11489  || m_ulps < (std::numeric_limits<uint32_t>::max)(),
11490  "Provided ULP is impossibly large for a float comparison.");
11491  }
11492 
11493 #if defined(__clang__)
11494 #pragma clang diagnostic push
11495 // Clang <3.5 reports on the default branch in the switch below
11496 #pragma clang diagnostic ignored "-Wunreachable-code"
11497 #endif
11498 
11499  bool WithinUlpsMatcher::match(double const& matchee) const {
11500  switch (m_type) {
11501  case FloatingPointKind::Float:
11502  return almostEqualUlps<float>(static_cast<float>(matchee), static_cast<float>(m_target), m_ulps);
11504  return almostEqualUlps<double>(matchee, m_target, m_ulps);
11505  default:
11506  CATCH_INTERNAL_ERROR( "Unknown FloatingPointKind value" );
11507  }
11508  }
11509 
11510 #if defined(__clang__)
11511 #pragma clang diagnostic pop
11512 #endif
11513 
11514  std::string WithinUlpsMatcher::describe() const {
11515  std::stringstream ret;
11516 
11517  ret << "is within " << m_ulps << " ULPs of ";
11518 
11519  if (m_type == FloatingPointKind::Float) {
11520  write(ret, static_cast<float>(m_target));
11521  ret << 'f';
11522  } else {
11523  write(ret, m_target);
11524  }
11525 
11526  ret << " ([";
11527  if (m_type == FloatingPointKind::Double) {
11528  write(ret, step(m_target, static_cast<double>(-INFINITY), m_ulps));
11529  ret << ", ";
11530  write(ret, step(m_target, static_cast<double>( INFINITY), m_ulps));
11531  } else {
11532  // We have to cast INFINITY to float because of MinGW, see #1782
11533  write(ret, step(static_cast<float>(m_target), static_cast<float>(-INFINITY), m_ulps));
11534  ret << ", ";
11535  write(ret, step(static_cast<float>(m_target), static_cast<float>( INFINITY), m_ulps));
11536  }
11537  ret << "])";
11538 
11539  return ret.str();
11540  }
11541 
11542  WithinRelMatcher::WithinRelMatcher(double target, double epsilon):
11543  m_target(target),
11544  m_epsilon(epsilon){
11545  CATCH_ENFORCE(m_epsilon >= 0., "Relative comparison with epsilon < 0 does not make sense.");
11546  CATCH_ENFORCE(m_epsilon < 1., "Relative comparison with epsilon >= 1 does not make sense.");
11547  }
11548 
11549  bool WithinRelMatcher::match(double const& matchee) const {
11550  const auto relMargin = m_epsilon * (std::max)(std::fabs(matchee), std::fabs(m_target));
11551  return marginComparison(matchee, m_target,
11552  std::isinf(relMargin)? 0 : relMargin);
11553  }
11554 
11555  std::string WithinRelMatcher::describe() const {
11556  Catch::ReusableStringStream sstr;
11557  sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other";
11558  return sstr.str();
11559  }
11560 
11561 }// namespace Floating
11562 
11563 Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff) {
11564  return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double);
11565 }
11566 
11567 Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff) {
11568  return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float);
11569 }
11570 
11571 Floating::WithinAbsMatcher WithinAbs(double target, double margin) {
11572  return Floating::WithinAbsMatcher(target, margin);
11573 }
11574 
11575 Floating::WithinRelMatcher WithinRel(double target, double eps) {
11576  return Floating::WithinRelMatcher(target, eps);
11577 }
11578 
11579 Floating::WithinRelMatcher WithinRel(double target) {
11580  return Floating::WithinRelMatcher(target, std::numeric_limits<double>::epsilon() * 100);
11581 }
11582 
11583 Floating::WithinRelMatcher WithinRel(float target, float eps) {
11584  return Floating::WithinRelMatcher(target, eps);
11585 }
11586 
11587 Floating::WithinRelMatcher WithinRel(float target) {
11588  return Floating::WithinRelMatcher(target, std::numeric_limits<float>::epsilon() * 100);
11589 }
11590 
11591 } // namespace Matchers
11592 } // namespace Catch
11593 
11594 // end catch_matchers_floating.cpp
11595 // start catch_matchers_generic.cpp
11596 
11597 std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) {
11598  if (desc.empty()) {
11599  return "matches undescribed predicate";
11600  } else {
11601  return "matches predicate: \"" + desc + '"';
11602  }
11603 }
11604 // end catch_matchers_generic.cpp
11605 // start catch_matchers_string.cpp
11606 
11607 #include <regex>
11608 
11609 namespace Catch {
11610 namespace Matchers {
11611 
11612  namespace StdString {
11613 
11614  CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
11615  : m_caseSensitivity( caseSensitivity ),
11616  m_str( adjustString( str ) )
11617  {}
11618  std::string CasedString::adjustString( std::string const& str ) const {
11619  return m_caseSensitivity == CaseSensitive::No
11620  ? toLower( str )
11621  : str;
11622  }
11623  std::string CasedString::caseSensitivitySuffix() const {
11624  return m_caseSensitivity == CaseSensitive::No
11625  ? " (case insensitive)"
11626  : std::string();
11627  }
11628 
11629  StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator )
11630  : m_comparator( comparator ),
11631  m_operation( operation ) {
11632  }
11633 
11634  std::string StringMatcherBase::describe() const {
11635  std::string description;
11636  description.reserve(5 + m_operation.size() + m_comparator.m_str.size() +
11637  m_comparator.caseSensitivitySuffix().size());
11638  description += m_operation;
11639  description += ": \"";
11640  description += m_comparator.m_str;
11641  description += "\"";
11642  description += m_comparator.caseSensitivitySuffix();
11643  return description;
11644  }
11645 
11646  EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {}
11647 
11648  bool EqualsMatcher::match( std::string const& source ) const {
11649  return m_comparator.adjustString( source ) == m_comparator.m_str;
11650  }
11651 
11652  ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {}
11653 
11654  bool ContainsMatcher::match( std::string const& source ) const {
11655  return contains( m_comparator.adjustString( source ), m_comparator.m_str );
11656  }
11657 
11658  StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {}
11659 
11660  bool StartsWithMatcher::match( std::string const& source ) const {
11661  return startsWith( m_comparator.adjustString( source ), m_comparator.m_str );
11662  }
11663 
11664  EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {}
11665 
11666  bool EndsWithMatcher::match( std::string const& source ) const {
11667  return endsWith( m_comparator.adjustString( source ), m_comparator.m_str );
11668  }
11669 
11670  RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {}
11671 
11672  bool RegexMatcher::match(std::string const& matchee) const {
11673  auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway
11674  if (m_caseSensitivity == CaseSensitive::Choice::No) {
11675  flags |= std::regex::icase;
11676  }
11677  auto reg = std::regex(m_regex, flags);
11678  return std::regex_match(matchee, reg);
11679  }
11680 
11681  std::string RegexMatcher::describe() const {
11682  return "matches " + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? " case sensitively" : " case insensitively");
11683  }
11684 
11685  } // namespace StdString
11686 
11687  StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
11688  return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) );
11689  }
11690  StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
11691  return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) );
11692  }
11693  StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
11694  return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) );
11695  }
11696  StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {
11697  return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) );
11698  }
11699 
11700  StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) {
11701  return StdString::RegexMatcher(regex, caseSensitivity);
11702  }
11703 
11704 } // namespace Matchers
11705 } // namespace Catch
11706 // end catch_matchers_string.cpp
11707 // start catch_message.cpp
11708 
11709 // start catch_uncaught_exceptions.h
11710 
11711 namespace Catch {
11712  bool uncaught_exceptions();
11713 } // end namespace Catch
11714 
11715 // end catch_uncaught_exceptions.h
11716 #include <cassert>
11717 #include <stack>
11718 
11719 namespace Catch {
11720 
11721  MessageInfo::MessageInfo( StringRef const& _macroName,
11722  SourceLineInfo const& _lineInfo,
11723  ResultWas::OfType _type )
11724  : macroName( _macroName ),
11725  lineInfo( _lineInfo ),
11726  type( _type ),
11727  sequence( ++globalCount )
11728  {}
11729 
11730  bool MessageInfo::operator==( MessageInfo const& other ) const {
11731  return sequence == other.sequence;
11732  }
11733 
11734  bool MessageInfo::operator<( MessageInfo const& other ) const {
11735  return sequence < other.sequence;
11736  }
11737 
11738  // This may need protecting if threading support is added
11739  unsigned int MessageInfo::globalCount = 0;
11740 
11742 
11744  SourceLineInfo const& lineInfo,
11746  :m_info(macroName, lineInfo, type) {}
11747 
11749 
11751  : m_info( builder.m_info ), m_moved()
11752  {
11753  m_info.message = builder.m_stream.str();
11754  getResultCapture().pushScopedMessage( m_info );
11755  }
11756 
11758  : m_info( old.m_info ), m_moved()
11759  {
11760  old.m_moved = true;
11761  }
11762 
11764  if ( !uncaught_exceptions() && !m_moved ){
11766  }
11767  }
11768 
11769  Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
11770  auto trimmed = [&] (size_t start, size_t end) {
11771  while (names[start] == ',' || isspace(names[start])) {
11772  ++start;
11773  }
11774  while (names[end] == ',' || isspace(names[end])) {
11775  --end;
11776  }
11777  return names.substr(start, end - start + 1);
11778  };
11779  auto skipq = [&] (size_t start, char quote) {
11780  for (auto i = start + 1; i < names.size() ; ++i) {
11781  if (names[i] == quote)
11782  return i;
11783  if (names[i] == '\\')
11784  ++i;
11785  }
11786  CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote");
11787  };
11788 
11789  size_t start = 0;
11790  std::stack<char> openings;
11791  for (size_t pos = 0; pos < names.size(); ++pos) {
11792  char c = names[pos];
11793  switch (c) {
11794  case '[':
11795  case '{':
11796  case '(':
11797  // It is basically impossible to disambiguate between
11798  // comparison and start of template args in this context
11799 // case '<':
11800  openings.push(c);
11801  break;
11802  case ']':
11803  case '}':
11804  case ')':
11805 // case '>':
11806  openings.pop();
11807  break;
11808  case '"':
11809  case '\'':
11810  pos = skipq(pos, c);
11811  break;
11812  case ',':
11813  if (start != pos && openings.empty()) {
11814  m_messages.emplace_back(macroName, lineInfo, resultType);
11815  m_messages.back().message = static_cast<std::string>(trimmed(start, pos));
11816  m_messages.back().message += " := ";
11817  start = pos;
11818  }
11819  }
11820  }
11821  assert(openings.empty() && "Mismatched openings");
11822  m_messages.emplace_back(macroName, lineInfo, resultType);
11823  m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1));
11824  m_messages.back().message += " := ";
11825  }
11827  if ( !uncaught_exceptions() ){
11828  assert( m_captured == m_messages.size() );
11829  for( size_t i = 0; i < m_captured; ++i )
11830  m_resultCapture.popScopedMessage( m_messages[i] );
11831  }
11832  }
11833 
11834  void Capturer::captureValue( size_t index, std::string const& value ) {
11835  assert( index < m_messages.size() );
11836  m_messages[index].message += value;
11837  m_resultCapture.pushScopedMessage( m_messages[index] );
11838  m_captured++;
11839  }
11840 
11841 } // end namespace Catch
11842 // end catch_message.cpp
11843 // start catch_output_redirect.cpp
11844 
11845 // start catch_output_redirect.h
11846 #ifndef TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H
11847 #define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H
11848 
11849 #include <cstdio>
11850 #include <iosfwd>
11851 #include <string>
11852 
11853 namespace Catch {
11854 
11855  class RedirectedStream {
11856  std::ostream& m_originalStream;
11857  std::ostream& m_redirectionStream;
11858  std::streambuf* m_prevBuf;
11859 
11860  public:
11861  RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream );
11862  ~RedirectedStream();
11863  };
11864 
11865  class RedirectedStdOut {
11866  ReusableStringStream m_rss;
11867  RedirectedStream m_cout;
11868  public:
11869  RedirectedStdOut();
11870  auto str() const -> std::string;
11871  };
11872 
11873  // StdErr has two constituent streams in C++, std::cerr and std::clog
11874  // This means that we need to redirect 2 streams into 1 to keep proper
11875  // order of writes
11876  class RedirectedStdErr {
11877  ReusableStringStream m_rss;
11878  RedirectedStream m_cerr;
11879  RedirectedStream m_clog;
11880  public:
11881  RedirectedStdErr();
11882  auto str() const -> std::string;
11883  };
11884 
11885  class RedirectedStreams {
11886  public:
11887  RedirectedStreams(RedirectedStreams const&) = delete;
11888  RedirectedStreams& operator=(RedirectedStreams const&) = delete;
11889  RedirectedStreams(RedirectedStreams&&) = delete;
11890  RedirectedStreams& operator=(RedirectedStreams&&) = delete;
11891 
11892  RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr);
11893  ~RedirectedStreams();
11894  private:
11895  std::string& m_redirectedCout;
11896  std::string& m_redirectedCerr;
11897  RedirectedStdOut m_redirectedStdOut;
11898  RedirectedStdErr m_redirectedStdErr;
11899  };
11900 
11901 #if defined(CATCH_CONFIG_NEW_CAPTURE)
11902 
11903  // Windows's implementation of std::tmpfile is terrible (it tries
11904  // to create a file inside system folder, thus requiring elevated
11905  // privileges for the binary), so we have to use tmpnam(_s) and
11906  // create the file ourselves there.
11907  class TempFile {
11908  public:
11909  TempFile(TempFile const&) = delete;
11910  TempFile& operator=(TempFile const&) = delete;
11911  TempFile(TempFile&&) = delete;
11912  TempFile& operator=(TempFile&&) = delete;
11913 
11914  TempFile();
11915  ~TempFile();
11916 
11917  std::FILE* getFile();
11918  std::string getContents();
11919 
11920  private:
11921  std::FILE* m_file = nullptr;
11922  #if defined(_MSC_VER)
11923  char m_buffer[L_tmpnam] = { 0 };
11924  #endif
11925  };
11926 
11927  class OutputRedirect {
11928  public:
11929  OutputRedirect(OutputRedirect const&) = delete;
11930  OutputRedirect& operator=(OutputRedirect const&) = delete;
11931  OutputRedirect(OutputRedirect&&) = delete;
11932  OutputRedirect& operator=(OutputRedirect&&) = delete;
11933 
11934  OutputRedirect(std::string& stdout_dest, std::string& stderr_dest);
11935  ~OutputRedirect();
11936 
11937  private:
11938  int m_originalStdout = -1;
11939  int m_originalStderr = -1;
11940  TempFile m_stdoutFile;
11941  TempFile m_stderrFile;
11942  std::string& m_stdoutDest;
11943  std::string& m_stderrDest;
11944  };
11945 
11946 #endif
11947 
11948 } // end namespace Catch
11949 
11950 #endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H
11951 // end catch_output_redirect.h
11952 #include <cstdio>
11953 #include <cstring>
11954 #include <fstream>
11955 #include <sstream>
11956 #include <stdexcept>
11957 
11958 #if defined(CATCH_CONFIG_NEW_CAPTURE)
11959  #if defined(_MSC_VER)
11960  #include <io.h> //_dup and _dup2
11961  #define dup _dup
11962  #define dup2 _dup2
11963  #define fileno _fileno
11964  #else
11965  #include <unistd.h> // dup and dup2
11966  #endif
11967 #endif
11968 
11969 namespace Catch {
11970 
11971  RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream )
11972  : m_originalStream( originalStream ),
11973  m_redirectionStream( redirectionStream ),
11974  m_prevBuf( m_originalStream.rdbuf() )
11975  {
11976  m_originalStream.rdbuf( m_redirectionStream.rdbuf() );
11977  }
11978 
11979  RedirectedStream::~RedirectedStream() {
11980  m_originalStream.rdbuf( m_prevBuf );
11981  }
11982 
11983  RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {}
11984  auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); }
11985 
11986  RedirectedStdErr::RedirectedStdErr()
11987  : m_cerr( Catch::cerr(), m_rss.get() ),
11988  m_clog( Catch::clog(), m_rss.get() )
11989  {}
11990  auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
11991 
11992  RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr)
11993  : m_redirectedCout(redirectedCout),
11994  m_redirectedCerr(redirectedCerr)
11995  {}
11996 
11997  RedirectedStreams::~RedirectedStreams() {
11998  m_redirectedCout += m_redirectedStdOut.str();
11999  m_redirectedCerr += m_redirectedStdErr.str();
12000  }
12001 
12002 #if defined(CATCH_CONFIG_NEW_CAPTURE)
12003 
12004 #if defined(_MSC_VER)
12005  TempFile::TempFile() {
12006  if (tmpnam_s(m_buffer)) {
12007  CATCH_RUNTIME_ERROR("Could not get a temp filename");
12008  }
12009  if (fopen_s(&m_file, m_buffer, "w")) {
12010  char buffer[100];
12011  if (strerror_s(buffer, errno)) {
12012  CATCH_RUNTIME_ERROR("Could not translate errno to a string");
12013  }
12014  CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer);
12015  }
12016  }
12017 #else
12018  TempFile::TempFile() {
12019  m_file = std::tmpfile();
12020  if (!m_file) {
12021  CATCH_RUNTIME_ERROR("Could not create a temp file.");
12022  }
12023  }
12024 
12025 #endif
12026 
12027  TempFile::~TempFile() {
12028  // TBD: What to do about errors here?
12029  std::fclose(m_file);
12030  // We manually create the file on Windows only, on Linux
12031  // it will be autodeleted
12032 #if defined(_MSC_VER)
12033  std::remove(m_buffer);
12034 #endif
12035  }
12036 
12037  FILE* TempFile::getFile() {
12038  return m_file;
12039  }
12040 
12041  std::string TempFile::getContents() {
12042  std::stringstream sstr;
12043  char buffer[100] = {};
12044  std::rewind(m_file);
12045  while (std::fgets(buffer, sizeof(buffer), m_file)) {
12046  sstr << buffer;
12047  }
12048  return sstr.str();
12049  }
12050 
12051  OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) :
12052  m_originalStdout(dup(1)),
12053  m_originalStderr(dup(2)),
12054  m_stdoutDest(stdout_dest),
12055  m_stderrDest(stderr_dest) {
12056  dup2(fileno(m_stdoutFile.getFile()), 1);
12057  dup2(fileno(m_stderrFile.getFile()), 2);
12058  }
12059 
12060  OutputRedirect::~OutputRedirect() {
12061  Catch::cout() << std::flush;
12062  fflush(stdout);
12063  // Since we support overriding these streams, we flush cerr
12064  // even though std::cerr is unbuffered
12065  Catch::cerr() << std::flush;
12066  Catch::clog() << std::flush;
12067  fflush(stderr);
12068 
12069  dup2(m_originalStdout, 1);
12070  dup2(m_originalStderr, 2);
12071 
12072  m_stdoutDest += m_stdoutFile.getContents();
12073  m_stderrDest += m_stderrFile.getContents();
12074  }
12075 
12076 #endif // CATCH_CONFIG_NEW_CAPTURE
12077 
12078 } // namespace Catch
12079 
12080 #if defined(CATCH_CONFIG_NEW_CAPTURE)
12081  #if defined(_MSC_VER)
12082  #undef dup
12083  #undef dup2
12084  #undef fileno
12085  #endif
12086 #endif
12087 // end catch_output_redirect.cpp
12088 // start catch_polyfills.cpp
12089 
12090 #include <cmath>
12091 
12092 namespace Catch {
12093 
12094 #if !defined(CATCH_CONFIG_POLYFILL_ISNAN)
12095  bool isnan(float f) {
12096  return std::isnan(f);
12097  }
12098  bool isnan(double d) {
12099  return std::isnan(d);
12100  }
12101 #else
12102  // For now we only use this for embarcadero
12103  bool isnan(float f) {
12104  return std::_isnan(f);
12105  }
12106  bool isnan(double d) {
12107  return std::_isnan(d);
12108  }
12109 #endif
12110 
12111 } // end namespace Catch
12112 // end catch_polyfills.cpp
12113 // start catch_random_number_generator.cpp
12114 
12115 namespace Catch {
12116 
12117 namespace {
12118 
12119 #if defined(_MSC_VER)
12120 #pragma warning(push)
12121 #pragma warning(disable:4146) // we negate uint32 during the rotate
12122 #endif
12123  // Safe rotr implementation thanks to John Regehr
12124  uint32_t rotate_right(uint32_t val, uint32_t count) {
12125  const uint32_t mask = 31;
12126  count &= mask;
12127  return (val >> count) | (val << (-count & mask));
12128  }
12129 
12130 #if defined(_MSC_VER)
12131 #pragma warning(pop)
12132 #endif
12133 
12134 }
12135 
12136  SimplePcg32::SimplePcg32(result_type seed_) {
12137  seed(seed_);
12138  }
12139 
12140  void SimplePcg32::seed(result_type seed_) {
12141  m_state = 0;
12142  (*this)();
12143  m_state += seed_;
12144  (*this)();
12145  }
12146 
12147  void SimplePcg32::discard(uint64_t skip) {
12148  // We could implement this to run in O(log n) steps, but this
12149  // should suffice for our use case.
12150  for (uint64_t s = 0; s < skip; ++s) {
12151  static_cast<void>((*this)());
12152  }
12153  }
12154 
12156  // prepare the output value
12157  const uint32_t xorshifted = static_cast<uint32_t>(((m_state >> 18u) ^ m_state) >> 27u);
12158  const auto output = rotate_right(xorshifted, m_state >> 59u);
12159 
12160  // advance state
12161  m_state = m_state * 6364136223846793005ULL + s_inc;
12162 
12163  return output;
12164  }
12165 
12166  bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs) {
12167  return lhs.m_state == rhs.m_state;
12168  }
12169 
12170  bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs) {
12171  return lhs.m_state != rhs.m_state;
12172  }
12173 }
12174 // end catch_random_number_generator.cpp
12175 // start catch_registry_hub.cpp
12176 
12177 // start catch_test_case_registry_impl.h
12178 
12179 #include <vector>
12180 #include <set>
12181 #include <algorithm>
12182 #include <ios>
12183 
12184 namespace Catch {
12185 
12186  class TestCase;
12187  struct IConfig;
12188 
12189  std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );
12190 
12191  bool isThrowSafe( TestCase const& testCase, IConfig const& config );
12192  bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
12193 
12194  void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions );
12195 
12196  std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
12197  std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
12198 
12199  class TestRegistry : public ITestCaseRegistry {
12200  public:
12201  virtual ~TestRegistry() = default;
12202 
12203  virtual void registerTest( TestCase const& testCase );
12204 
12205  std::vector<TestCase> const& getAllTests() const override;
12206  std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const override;
12207 
12208  private:
12209  std::vector<TestCase> m_functions;
12210  mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
12211  mutable std::vector<TestCase> m_sortedFunctions;
12212  std::size_t m_unnamedCount = 0;
12213  std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
12214  };
12215 
12217 
12218  class TestInvokerAsFunction : public ITestInvoker {
12219  void(*m_testAsFunction)();
12220  public:
12221  TestInvokerAsFunction( void(*testAsFunction)() ) noexcept;
12222 
12223  void invoke() const override;
12224  };
12225 
12226  std::string extractClassName( StringRef const& classOrQualifiedMethodName );
12227 
12229 
12230 } // end namespace Catch
12231 
12232 // end catch_test_case_registry_impl.h
12233 // start catch_reporter_registry.h
12234 
12235 #include <map>
12236 
12237 namespace Catch {
12238 
12239  class ReporterRegistry : public IReporterRegistry {
12240 
12241  public:
12242 
12243  ~ReporterRegistry() override;
12244 
12245  IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override;
12246 
12247  void registerReporter( std::string const& name, IReporterFactoryPtr const& factory );
12248  void registerListener( IReporterFactoryPtr const& factory );
12249 
12250  FactoryMap const& getFactories() const override;
12251  Listeners const& getListeners() const override;
12252 
12253  private:
12254  FactoryMap m_factories;
12255  Listeners m_listeners;
12256  };
12257 }
12258 
12259 // end catch_reporter_registry.h
12260 // start catch_tag_alias_registry.h
12261 
12262 // start catch_tag_alias.h
12263 
12264 #include <string>
12265 
12266 namespace Catch {
12267 
12268  struct TagAlias {
12269  TagAlias(std::string const& _tag, SourceLineInfo _lineInfo);
12270 
12271  std::string tag;
12272  SourceLineInfo lineInfo;
12273  };
12274 
12275 } // end namespace Catch
12276 
12277 // end catch_tag_alias.h
12278 #include <map>
12279 
12280 namespace Catch {
12281 
12282  class TagAliasRegistry : public ITagAliasRegistry {
12283  public:
12284  ~TagAliasRegistry() override;
12285  TagAlias const* find( std::string const& alias ) const override;
12286  std::string expandAliases( std::string const& unexpandedTestSpec ) const override;
12287  void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );
12288 
12289  private:
12290  std::map<std::string, TagAlias> m_registry;
12291  };
12292 
12293 } // end namespace Catch
12294 
12295 // end catch_tag_alias_registry.h
12296 // start catch_startup_exception_registry.h
12297 
12298 #include <vector>
12299 #include <exception>
12300 
12301 namespace Catch {
12302 
12303  class StartupExceptionRegistry {
12304  public:
12305  void add(std::exception_ptr const& exception) noexcept;
12306  std::vector<std::exception_ptr> const& getExceptions() const noexcept;
12307  private:
12308  std::vector<std::exception_ptr> m_exceptions;
12309  };
12310 
12311 } // end namespace Catch
12312 
12313 // end catch_startup_exception_registry.h
12314 // start catch_singletons.hpp
12315 
12316 namespace Catch {
12317 
12318  struct ISingleton {
12319  virtual ~ISingleton();
12320  };
12321 
12322  void addSingleton( ISingleton* singleton );
12323  void cleanupSingletons();
12324 
12325  template<typename SingletonImplT, typename InterfaceT = SingletonImplT, typename MutableInterfaceT = InterfaceT>
12326  class Singleton : SingletonImplT, public ISingleton {
12327 
12328  static auto getInternal() -> Singleton* {
12329  static Singleton* s_instance = nullptr;
12330  if( !s_instance ) {
12331  s_instance = new Singleton;
12332  addSingleton( s_instance );
12333  }
12334  return s_instance;
12335  }
12336 
12337  public:
12338  static auto get() -> InterfaceT const& {
12339  return *getInternal();
12340  }
12341  static auto getMutable() -> MutableInterfaceT& {
12342  return *getInternal();
12343  }
12344  };
12345 
12346 } // namespace Catch
12347 
12348 // end catch_singletons.hpp
12349 namespace Catch {
12350 
12351  namespace {
12352 
12353  class RegistryHub : public IRegistryHub, public IMutableRegistryHub,
12354  private NonCopyable {
12355 
12356  public: // IRegistryHub
12357  RegistryHub() = default;
12358  IReporterRegistry const& getReporterRegistry() const override {
12359  return m_reporterRegistry;
12360  }
12361  ITestCaseRegistry const& getTestCaseRegistry() const override {
12362  return m_testCaseRegistry;
12363  }
12364  IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const override {
12365  return m_exceptionTranslatorRegistry;
12366  }
12367  ITagAliasRegistry const& getTagAliasRegistry() const override {
12368  return m_tagAliasRegistry;
12369  }
12370  StartupExceptionRegistry const& getStartupExceptionRegistry() const override {
12371  return m_exceptionRegistry;
12372  }
12373 
12374  public: // IMutableRegistryHub
12375  void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override {
12376  m_reporterRegistry.registerReporter( name, factory );
12377  }
12378  void registerListener( IReporterFactoryPtr const& factory ) override {
12379  m_reporterRegistry.registerListener( factory );
12380  }
12381  void registerTest( TestCase const& testInfo ) override {
12382  m_testCaseRegistry.registerTest( testInfo );
12383  }
12384  void registerTranslator( const IExceptionTranslator* translator ) override {
12385  m_exceptionTranslatorRegistry.registerTranslator( translator );
12386  }
12387  void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {
12388  m_tagAliasRegistry.add( alias, tag, lineInfo );
12389  }
12390  void registerStartupException() noexcept override {
12391  m_exceptionRegistry.add(std::current_exception());
12392  }
12393  IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override {
12394  return m_enumValuesRegistry;
12395  }
12396 
12397  private:
12398  TestRegistry m_testCaseRegistry;
12399  ReporterRegistry m_reporterRegistry;
12400  ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
12401  TagAliasRegistry m_tagAliasRegistry;
12402  StartupExceptionRegistry m_exceptionRegistry;
12403  Detail::EnumValuesRegistry m_enumValuesRegistry;
12404  };
12405  }
12406 
12407  using RegistryHubSingleton = Singleton<RegistryHub, IRegistryHub, IMutableRegistryHub>;
12408 
12409  IRegistryHub const& getRegistryHub() {
12410  return RegistryHubSingleton::get();
12411  }
12413  return RegistryHubSingleton::getMutable();
12414  }
12415  void cleanUp() {
12416  cleanupSingletons();
12417  cleanUpContext();
12418  }
12419  std::string translateActiveException() {
12421  }
12422 
12423 } // end namespace Catch
12424 // end catch_registry_hub.cpp
12425 // start catch_reporter_registry.cpp
12426 
12427 namespace Catch {
12428 
12429  ReporterRegistry::~ReporterRegistry() = default;
12430 
12431  IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const {
12432  auto it = m_factories.find( name );
12433  if( it == m_factories.end() )
12434  return nullptr;
12435  return it->second->create( ReporterConfig( config ) );
12436  }
12437 
12438  void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) {
12439  m_factories.emplace(name, factory);
12440  }
12441  void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) {
12442  m_listeners.push_back( factory );
12443  }
12444 
12445  IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const {
12446  return m_factories;
12447  }
12448  IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const {
12449  return m_listeners;
12450  }
12451 
12452 }
12453 // end catch_reporter_registry.cpp
12454 // start catch_result_type.cpp
12455 
12456 namespace Catch {
12457 
12458  bool isOk( ResultWas::OfType resultType ) {
12459  return ( resultType & ResultWas::FailureBit ) == 0;
12460  }
12461  bool isJustInfo( int flags ) {
12462  return flags == ResultWas::Info;
12463  }
12464 
12466  return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
12467  }
12468 
12469  bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
12470  bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
12471 
12472 } // end namespace Catch
12473 // end catch_result_type.cpp
12474 // start catch_run_context.cpp
12475 
12476 #include <cassert>
12477 #include <algorithm>
12478 #include <sstream>
12479 
12480 namespace Catch {
12481 
12482  namespace Generators {
12483  struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker {
12484  GeneratorBasePtr m_generator;
12485 
12486  GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
12487  : TrackerBase( nameAndLocation, ctx, parent )
12488  {}
12489  ~GeneratorTracker();
12490 
12491  static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocation const& nameAndLocation ) {
12492  std::shared_ptr<GeneratorTracker> tracker;
12493 
12494  ITracker& currentTracker = ctx.currentTracker();
12495  if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {
12496  assert( childTracker );
12497  assert( childTracker->isGeneratorTracker() );
12498  tracker = std::static_pointer_cast<GeneratorTracker>( childTracker );
12499  }
12500  else {
12501  tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, &currentTracker );
12502  currentTracker.addChild( tracker );
12503  }
12504 
12505  if( !ctx.completedCycle() && !tracker->isComplete() ) {
12506  tracker->open();
12507  }
12508 
12509  return *tracker;
12510  }
12511 
12512  // TrackerBase interface
12513  bool isGeneratorTracker() const override { return true; }
12514  auto hasGenerator() const -> bool override {
12515  return !!m_generator;
12516  }
12517  void close() override {
12518  TrackerBase::close();
12519  // Generator interface only finds out if it has another item on atual move
12520  if (m_runState == CompletedSuccessfully && m_generator->next()) {
12521  m_children.clear();
12522  m_runState = Executing;
12523  }
12524  }
12525 
12526  // IGeneratorTracker interface
12527  auto getGenerator() const -> GeneratorBasePtr const& override {
12528  return m_generator;
12529  }
12530  void setGenerator( GeneratorBasePtr&& generator ) override {
12531  m_generator = std::move( generator );
12532  }
12533  };
12534  GeneratorTracker::~GeneratorTracker() {}
12535  }
12536 
12537  RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter)
12538  : m_runInfo(_config->name()),
12539  m_context(getCurrentMutableContext()),
12540  m_config(_config),
12541  m_reporter(std::move(reporter)),
12542  m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
12543  m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )
12544  {
12545  m_context.setRunner(this);
12546  m_context.setConfig(m_config);
12547  m_context.setResultCapture(this);
12548  m_reporter->testRunStarting(m_runInfo);
12549  }
12550 
12551  RunContext::~RunContext() {
12552  m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting()));
12553  }
12554 
12555  void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) {
12556  m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount));
12557  }
12558 
12559  void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) {
12560  m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting()));
12561  }
12562 
12563  Totals RunContext::runTest(TestCase const& testCase) {
12564  Totals prevTotals = m_totals;
12565 
12566  std::string redirectedCout;
12567  std::string redirectedCerr;
12568 
12569  auto const& testInfo = testCase.getTestCaseInfo();
12570 
12571  m_reporter->testCaseStarting(testInfo);
12572 
12573  m_activeTestCase = &testCase;
12574 
12575  ITracker& rootTracker = m_trackerContext.startRun();
12576  assert(rootTracker.isSectionTracker());
12577  static_cast<SectionTracker&>(rootTracker).addInitialFilters(m_config->getSectionsToRun());
12578  do {
12579  m_trackerContext.startCycle();
12580  m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo));
12581  runCurrentTest(redirectedCout, redirectedCerr);
12582  } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting());
12583 
12584  Totals deltaTotals = m_totals.delta(prevTotals);
12585  if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) {
12586  deltaTotals.assertions.failed++;
12587  deltaTotals.testCases.passed--;
12588  deltaTotals.testCases.failed++;
12589  }
12590  m_totals.testCases += deltaTotals.testCases;
12591  m_reporter->testCaseEnded(TestCaseStats(testInfo,
12592  deltaTotals,
12593  redirectedCout,
12594  redirectedCerr,
12595  aborting()));
12596 
12597  m_activeTestCase = nullptr;
12598  m_testCaseTracker = nullptr;
12599 
12600  return deltaTotals;
12601  }
12602 
12603  IConfigPtr RunContext::config() const {
12604  return m_config;
12605  }
12606 
12607  IStreamingReporter& RunContext::reporter() const {
12608  return *m_reporter;
12609  }
12610 
12611  void RunContext::assertionEnded(AssertionResult const & result) {
12612  if (result.getResultType() == ResultWas::Ok) {
12613  m_totals.assertions.passed++;
12614  m_lastAssertionPassed = true;
12615  } else if (!result.isOk()) {
12616  m_lastAssertionPassed = false;
12617  if( m_activeTestCase->getTestCaseInfo().okToFail() )
12618  m_totals.assertions.failedButOk++;
12619  else
12620  m_totals.assertions.failed++;
12621  }
12622  else {
12623  m_lastAssertionPassed = true;
12624  }
12625 
12626  // We have no use for the return value (whether messages should be cleared), because messages were made scoped
12627  // and should be let to clear themselves out.
12628  static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
12629 
12630  if (result.getResultType() != ResultWas::Warning)
12631  m_messageScopes.clear();
12632 
12633  // Reset working state
12634  resetAssertionInfo();
12635  m_lastResult = result;
12636  }
12637  void RunContext::resetAssertionInfo() {
12638  m_lastAssertionInfo.macroName = StringRef();
12639  m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr;
12640  }
12641 
12642  bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) {
12643  ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));
12644  if (!sectionTracker.isOpen())
12645  return false;
12646  m_activeSections.push_back(&sectionTracker);
12647 
12648  m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
12649 
12650  m_reporter->sectionStarting(sectionInfo);
12651 
12652  assertions = m_totals.assertions;
12653 
12654  return true;
12655  }
12657  using namespace Generators;
12658  GeneratorTracker& tracker = GeneratorTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( "generator", lineInfo ) );
12659  assert( tracker.isOpen() );
12660  m_lastAssertionInfo.lineInfo = lineInfo;
12661  return tracker;
12662  }
12663 
12664  bool RunContext::testForMissingAssertions(Counts& assertions) {
12665  if (assertions.total() != 0)
12666  return false;
12667  if (!m_config->warnAboutMissingAssertions())
12668  return false;
12669  if (m_trackerContext.currentTracker().hasChildren())
12670  return false;
12671  m_totals.assertions.failed++;
12672  assertions.failed++;
12673  return true;
12674  }
12675 
12676  void RunContext::sectionEnded(SectionEndInfo const & endInfo) {
12677  Counts assertions = m_totals.assertions - endInfo.prevAssertions;
12678  bool missingAssertions = testForMissingAssertions(assertions);
12679 
12680  if (!m_activeSections.empty()) {
12681  m_activeSections.back()->close();
12682  m_activeSections.pop_back();
12683  }
12684 
12685  m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions));
12686  m_messages.clear();
12687  m_messageScopes.clear();
12688  }
12689 
12690  void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) {
12691  if (m_unfinishedSections.empty())
12692  m_activeSections.back()->fail();
12693  else
12694  m_activeSections.back()->close();
12695  m_activeSections.pop_back();
12696 
12697  m_unfinishedSections.push_back(endInfo);
12698  }
12699 
12700 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
12701  void RunContext::benchmarkPreparing(std::string const& name) {
12702  m_reporter->benchmarkPreparing(name);
12703  }
12704  void RunContext::benchmarkStarting( BenchmarkInfo const& info ) {
12705  m_reporter->benchmarkStarting( info );
12706  }
12707  void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) {
12708  m_reporter->benchmarkEnded( stats );
12709  }
12710  void RunContext::benchmarkFailed(std::string const & error) {
12711  m_reporter->benchmarkFailed(error);
12712  }
12713 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
12714 
12715  void RunContext::pushScopedMessage(MessageInfo const & message) {
12716  m_messages.push_back(message);
12717  }
12718 
12719  void RunContext::popScopedMessage(MessageInfo const & message) {
12720  m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end());
12721  }
12722 
12723  void RunContext::emplaceUnscopedMessage( MessageBuilder const& builder ) {
12724  m_messageScopes.emplace_back( builder );
12725  }
12726 
12727  std::string RunContext::getCurrentTestName() const {
12728  return m_activeTestCase
12729  ? m_activeTestCase->getTestCaseInfo().name
12730  : std::string();
12731  }
12732 
12733  const AssertionResult * RunContext::getLastResult() const {
12734  return &(*m_lastResult);
12735  }
12736 
12737  void RunContext::exceptionEarlyReported() {
12738  m_shouldReportUnexpected = false;
12739  }
12740 
12741  void RunContext::handleFatalErrorCondition( StringRef message ) {
12742  // First notify reporter that bad things happened
12743  m_reporter->fatalErrorEncountered(message);
12744 
12745  // Don't rebuild the result -- the stringification itself can cause more fatal errors
12746  // Instead, fake a result data.
12747  AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );
12748  tempResult.message = static_cast<std::string>(message);
12749  AssertionResult result(m_lastAssertionInfo, tempResult);
12750 
12751  assertionEnded(result);
12752 
12753  handleUnfinishedSections();
12754 
12755  // Recreate section for test case (as we will lose the one that was in scope)
12756  auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
12757  SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name);
12758 
12759  Counts assertions;
12760  assertions.failed = 1;
12761  SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false);
12762  m_reporter->sectionEnded(testCaseSectionStats);
12763 
12764  auto const& testInfo = m_activeTestCase->getTestCaseInfo();
12765 
12766  Totals deltaTotals;
12767  deltaTotals.testCases.failed = 1;
12768  deltaTotals.assertions.failed = 1;
12769  m_reporter->testCaseEnded(TestCaseStats(testInfo,
12770  deltaTotals,
12771  std::string(),
12772  std::string(),
12773  false));
12774  m_totals.testCases.failed++;
12775  testGroupEnded(std::string(), m_totals, 1, 1);
12776  m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false));
12777  }
12778 
12779  bool RunContext::lastAssertionPassed() {
12780  return m_lastAssertionPassed;
12781  }
12782 
12783  void RunContext::assertionPassed() {
12784  m_lastAssertionPassed = true;
12785  ++m_totals.assertions.passed;
12786  resetAssertionInfo();
12787  m_messageScopes.clear();
12788  }
12789 
12790  bool RunContext::aborting() const {
12791  return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter());
12792  }
12793 
12794  void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) {
12795  auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
12796  SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name);
12797  m_reporter->sectionStarting(testCaseSection);
12798  Counts prevAssertions = m_totals.assertions;
12799  double duration = 0;
12800  m_shouldReportUnexpected = true;
12801  m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal };
12802 
12803  seedRng(*m_config);
12804 
12805  Timer timer;
12806  CATCH_TRY {
12807  if (m_reporter->getPreferences().shouldRedirectStdOut) {
12808 #if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
12809  RedirectedStreams redirectedStreams(redirectedCout, redirectedCerr);
12810 
12811  timer.start();
12812  invokeActiveTestCase();
12813 #else
12814  OutputRedirect r(redirectedCout, redirectedCerr);
12815  timer.start();
12816  invokeActiveTestCase();
12817 #endif
12818  } else {
12819  timer.start();
12820  invokeActiveTestCase();
12821  }
12822  duration = timer.getElapsedSeconds();
12824  // This just means the test was aborted due to failure
12825  } CATCH_CATCH_ALL {
12826  // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions
12827  // are reported without translation at the point of origin.
12828  if( m_shouldReportUnexpected ) {
12829  AssertionReaction dummyReaction;
12830  handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );
12831  }
12832  }
12833  Counts assertions = m_totals.assertions - prevAssertions;
12834  bool missingAssertions = testForMissingAssertions(assertions);
12835 
12836  m_testCaseTracker->close();
12837  handleUnfinishedSections();
12838  m_messages.clear();
12839  m_messageScopes.clear();
12840 
12841  SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);
12842  m_reporter->sectionEnded(testCaseSectionStats);
12843  }
12844 
12845  void RunContext::invokeActiveTestCase() {
12846  FatalConditionHandler fatalConditionHandler; // Handle signals
12847  m_activeTestCase->invoke();
12848  fatalConditionHandler.reset();
12849  }
12850 
12851  void RunContext::handleUnfinishedSections() {
12852  // If sections ended prematurely due to an exception we stored their
12853  // infos here so we can tear them down outside the unwind process.
12854  for (auto it = m_unfinishedSections.rbegin(),
12855  itEnd = m_unfinishedSections.rend();
12856  it != itEnd;
12857  ++it)
12858  sectionEnded(*it);
12859  m_unfinishedSections.clear();
12860  }
12861 
12862  void RunContext::handleExpr(
12863  AssertionInfo const& info,
12864  ITransientExpression const& expr,
12865  AssertionReaction& reaction
12866  ) {
12867  m_reporter->assertionStarting( info );
12868 
12869  bool negated = isFalseTest( info.resultDisposition );
12870  bool result = expr.getResult() != negated;
12871 
12872  if( result ) {
12873  if (!m_includeSuccessfulResults) {
12874  assertionPassed();
12875  }
12876  else {
12877  reportExpr(info, ResultWas::Ok, &expr, negated);
12878  }
12879  }
12880  else {
12881  reportExpr(info, ResultWas::ExpressionFailed, &expr, negated );
12882  populateReaction( reaction );
12883  }
12884  }
12885  void RunContext::reportExpr(
12886  AssertionInfo const &info,
12887  ResultWas::OfType resultType,
12888  ITransientExpression const *expr,
12889  bool negated ) {
12890 
12891  m_lastAssertionInfo = info;
12892  AssertionResultData data( resultType, LazyExpression( negated ) );
12893 
12894  AssertionResult assertionResult{ info, data };
12895  assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;
12896 
12897  assertionEnded( assertionResult );
12898  }
12899 
12900  void RunContext::handleMessage(
12901  AssertionInfo const& info,
12902  ResultWas::OfType resultType,
12903  StringRef const& message,
12904  AssertionReaction& reaction
12905  ) {
12906  m_reporter->assertionStarting( info );
12907 
12908  m_lastAssertionInfo = info;
12909 
12910  AssertionResultData data( resultType, LazyExpression( false ) );
12911  data.message = static_cast<std::string>(message);
12912  AssertionResult assertionResult{ m_lastAssertionInfo, data };
12913  assertionEnded( assertionResult );
12914  if( !assertionResult.isOk() )
12915  populateReaction( reaction );
12916  }
12917  void RunContext::handleUnexpectedExceptionNotThrown(
12918  AssertionInfo const& info,
12919  AssertionReaction& reaction
12920  ) {
12921  handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction);
12922  }
12923 
12924  void RunContext::handleUnexpectedInflightException(
12925  AssertionInfo const& info,
12926  std::string const& message,
12927  AssertionReaction& reaction
12928  ) {
12929  m_lastAssertionInfo = info;
12930 
12931  AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
12932  data.message = message;
12933  AssertionResult assertionResult{ info, data };
12934  assertionEnded( assertionResult );
12935  populateReaction( reaction );
12936  }
12937 
12938  void RunContext::populateReaction( AssertionReaction& reaction ) {
12939  reaction.shouldDebugBreak = m_config->shouldDebugBreak();
12940  reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal);
12941  }
12942 
12943  void RunContext::handleIncomplete(
12944  AssertionInfo const& info
12945  ) {
12946  m_lastAssertionInfo = info;
12947 
12948  AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
12949  data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
12950  AssertionResult assertionResult{ info, data };
12951  assertionEnded( assertionResult );
12952  }
12953  void RunContext::handleNonExpr(
12954  AssertionInfo const &info,
12955  ResultWas::OfType resultType,
12956  AssertionReaction &reaction
12957  ) {
12958  m_lastAssertionInfo = info;
12959 
12960  AssertionResultData data( resultType, LazyExpression( false ) );
12961  AssertionResult assertionResult{ info, data };
12962  assertionEnded( assertionResult );
12963 
12964  if( !assertionResult.isOk() )
12965  populateReaction( reaction );
12966  }
12967 
12969  if (auto* capture = getCurrentContext().getResultCapture())
12970  return *capture;
12971  else
12972  CATCH_INTERNAL_ERROR("No result capture instance");
12973  }
12974 
12975  void seedRng(IConfig const& config) {
12976  if (config.rngSeed() != 0) {
12977  std::srand(config.rngSeed());
12978  rng().seed(config.rngSeed());
12979  }
12980  }
12981 
12982  unsigned int rngSeed() {
12983  return getCurrentContext().getConfig()->rngSeed();
12984  }
12985 
12986 }
12987 // end catch_run_context.cpp
12988 // start catch_section.cpp
12989 
12990 namespace Catch {
12991 
12993  : m_info( info ),
12994  m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
12995  {
12996  m_timer.start();
12997  }
12998 
12999  Section::~Section() {
13000  if( m_sectionIncluded ) {
13001  SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() };
13002  if( uncaught_exceptions() )
13003  getResultCapture().sectionEndedEarly( endInfo );
13004  else
13005  getResultCapture().sectionEnded( endInfo );
13006  }
13007  }
13008 
13009  // This indicates whether the section should be executed or not
13010  Section::operator bool() const {
13011  return m_sectionIncluded;
13012  }
13013 
13014 } // end namespace Catch
13015 // end catch_section.cpp
13016 // start catch_section_info.cpp
13017 
13018 namespace Catch {
13019 
13021  ( SourceLineInfo const& _lineInfo,
13022  std::string const& _name )
13023  : name( _name ),
13024  lineInfo( _lineInfo )
13025  {}
13026 
13027 } // end namespace Catch
13028 // end catch_section_info.cpp
13029 // start catch_session.cpp
13030 
13031 // start catch_session.h
13032 
13033 #include <memory>
13034 
13035 namespace Catch {
13036 
13037  class Session : NonCopyable {
13038  public:
13039 
13040  Session();
13041  ~Session() override;
13042 
13043  void showHelp() const;
13044  void libIdentify();
13045 
13046  int applyCommandLine( int argc, char const * const * argv );
13047  #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE)
13048  int applyCommandLine( int argc, wchar_t const * const * argv );
13049  #endif
13050 
13051  void useConfigData( ConfigData const& configData );
13052 
13053  template<typename CharT>
13054  int run(int argc, CharT const * const argv[]) {
13055  if (m_startupExceptions)
13056  return 1;
13057  int returnCode = applyCommandLine(argc, argv);
13058  if (returnCode == 0)
13059  returnCode = run();
13060  return returnCode;
13061  }
13062 
13063  int run();
13064 
13065  clara::Parser const& cli() const;
13066  void cli( clara::Parser const& newParser );
13067  ConfigData& configData();
13068  Config& config();
13069  private:
13070  int runInternal();
13071 
13072  clara::Parser m_cli;
13073  ConfigData m_configData;
13074  std::shared_ptr<Config> m_config;
13075  bool m_startupExceptions = false;
13076  };
13077 
13078 } // end namespace Catch
13079 
13080 // end catch_session.h
13081 // start catch_version.h
13082 
13083 #include <iosfwd>
13084 
13085 namespace Catch {
13086 
13087  // Versioning information
13088  struct Version {
13089  Version( Version const& ) = delete;
13090  Version& operator=( Version const& ) = delete;
13091  Version( unsigned int _majorVersion,
13092  unsigned int _minorVersion,
13093  unsigned int _patchNumber,
13094  char const * const _branchName,
13095  unsigned int _buildNumber );
13096 
13097  unsigned int const majorVersion;
13098  unsigned int const minorVersion;
13099  unsigned int const patchNumber;
13100 
13101  // buildNumber is only used if branchName is not null
13102  char const * const branchName;
13103  unsigned int const buildNumber;
13104 
13105  friend std::ostream& operator << ( std::ostream& os, Version const& version );
13106  };
13107 
13108  Version const& libraryVersion();
13109 }
13110 
13111 // end catch_version.h
13112 #include <cstdlib>
13113 #include <iomanip>
13114 #include <set>
13115 #include <iterator>
13116 
13117 namespace Catch {
13118 
13119  namespace {
13120  const int MaxExitCode = 255;
13121 
13122  IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) {
13123  auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config);
13124  CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'");
13125 
13126  return reporter;
13127  }
13128 
13129  IStreamingReporterPtr makeReporter(std::shared_ptr<Config> const& config) {
13130  if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) {
13131  return createReporter(config->getReporterName(), config);
13132  }
13133 
13134  // On older platforms, returning std::unique_ptr<ListeningReporter>
13135  // when the return type is std::unique_ptr<IStreamingReporter>
13136  // doesn't compile without a std::move call. However, this causes
13137  // a warning on newer platforms. Thus, we have to work around
13138  // it a bit and downcast the pointer manually.
13139  auto ret = std::unique_ptr<IStreamingReporter>(new ListeningReporter);
13140  auto& multi = static_cast<ListeningReporter&>(*ret);
13141  auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners();
13142  for (auto const& listener : listeners) {
13143  multi.addListener(listener->create(Catch::ReporterConfig(config)));
13144  }
13145  multi.addReporter(createReporter(config->getReporterName(), config));
13146  return ret;
13147  }
13148 
13149  class TestGroup {
13150  public:
13151  explicit TestGroup(std::shared_ptr<Config> const& config)
13152  : m_config{config}
13153  , m_context{config, makeReporter(config)}
13154  {
13155  auto const& allTestCases = getAllTestCasesSorted(*m_config);
13156  m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
13157  auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
13158 
13159  if (m_matches.empty() && invalidArgs.empty()) {
13160  for (auto const& test : allTestCases)
13161  if (!test.isHidden())
13162  m_tests.emplace(&test);
13163  } else {
13164  for (auto const& match : m_matches)
13165  m_tests.insert(match.tests.begin(), match.tests.end());
13166  }
13167  }
13168 
13169  Totals execute() {
13170  auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
13171  Totals totals;
13172  m_context.testGroupStarting(m_config->name(), 1, 1);
13173  for (auto const& testCase : m_tests) {
13174  if (!m_context.aborting())
13175  totals += m_context.runTest(*testCase);
13176  else
13177  m_context.reporter().skipTest(*testCase);
13178  }
13179 
13180  for (auto const& match : m_matches) {
13181  if (match.tests.empty()) {
13182  m_context.reporter().noMatchingTestCases(match.name);
13183  totals.error = -1;
13184  }
13185  }
13186 
13187  if (!invalidArgs.empty()) {
13188  for (auto const& invalidArg: invalidArgs)
13189  m_context.reporter().reportInvalidArguments(invalidArg);
13190  }
13191 
13192  m_context.testGroupEnded(m_config->name(), totals, 1, 1);
13193  return totals;
13194  }
13195 
13196  private:
13197  using Tests = std::set<TestCase const*>;
13198 
13199  std::shared_ptr<Config> m_config;
13200  RunContext m_context;
13201  Tests m_tests;
13202  TestSpec::Matches m_matches;
13203  };
13204 
13205  void applyFilenamesAsTags(Catch::IConfig const& config) {
13206  auto& tests = const_cast<std::vector<TestCase>&>(getAllTestCasesSorted(config));
13207  for (auto& testCase : tests) {
13208  auto tags = testCase.tags;
13209 
13210  std::string filename = testCase.lineInfo.file;
13211  auto lastSlash = filename.find_last_of("\\/");
13212  if (lastSlash != std::string::npos) {
13213  filename.erase(0, lastSlash);
13214  filename[0] = '#';
13215  }
13216 
13217  auto lastDot = filename.find_last_of('.');
13218  if (lastDot != std::string::npos) {
13219  filename.erase(lastDot);
13220  }
13221 
13222  tags.push_back(std::move(filename));
13223  setTags(testCase, tags);
13224  }
13225  }
13226 
13227  } // anon namespace
13228 
13229  Session::Session() {
13230  static bool alreadyInstantiated = false;
13231  if( alreadyInstantiated ) {
13232  CATCH_TRY { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); }
13234  }
13235 
13236  // There cannot be exceptions at startup in no-exception mode.
13237 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
13238  const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions();
13239  if ( !exceptions.empty() ) {
13240  config();
13241  getCurrentMutableContext().setConfig(m_config);
13242 
13243  m_startupExceptions = true;
13244  Colour colourGuard( Colour::Red );
13245  Catch::cerr() << "Errors occurred during startup!" << '\n';
13246  // iterate over all exceptions and notify user
13247  for ( const auto& ex_ptr : exceptions ) {
13248  try {
13249  std::rethrow_exception(ex_ptr);
13250  } catch ( std::exception const& ex ) {
13251  Catch::cerr() << Column( ex.what() ).indent(2) << '\n';
13252  }
13253  }
13254  }
13255 #endif
13256 
13257  alreadyInstantiated = true;
13258  m_cli = makeCommandLineParser( m_configData );
13259  }
13260  Session::~Session() {
13261  Catch::cleanUp();
13262  }
13263 
13264  void Session::showHelp() const {
13265  Catch::cout()
13266  << "\nCatch v" << libraryVersion() << "\n"
13267  << m_cli << std::endl
13268  << "For more detailed usage please see the project docs\n" << std::endl;
13269  }
13270  void Session::libIdentify() {
13271  Catch::cout()
13272  << std::left << std::setw(16) << "description: " << "A Catch2 test executable\n"
13273  << std::left << std::setw(16) << "category: " << "testframework\n"
13274  << std::left << std::setw(16) << "framework: " << "Catch Test\n"
13275  << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl;
13276  }
13277 
13278  int Session::applyCommandLine( int argc, char const * const * argv ) {
13279  if( m_startupExceptions )
13280  return 1;
13281 
13282  auto result = m_cli.parse( clara::Args( argc, argv ) );
13283  if( !result ) {
13284  config();
13285  getCurrentMutableContext().setConfig(m_config);
13286  Catch::cerr()
13287  << Colour( Colour::Red )
13288  << "\nError(s) in input:\n"
13289  << Column( result.errorMessage() ).indent( 2 )
13290  << "\n\n";
13291  Catch::cerr() << "Run with -? for usage\n" << std::endl;
13292  return MaxExitCode;
13293  }
13294 
13295  if( m_configData.showHelp )
13296  showHelp();
13297  if( m_configData.libIdentify )
13298  libIdentify();
13299  m_config.reset();
13300  return 0;
13301  }
13302 
13303 #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE)
13304  int Session::applyCommandLine( int argc, wchar_t const * const * argv ) {
13305 
13306  char **utf8Argv = new char *[ argc ];
13307 
13308  for ( int i = 0; i < argc; ++i ) {
13309  int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, nullptr, 0, nullptr, nullptr );
13310 
13311  utf8Argv[ i ] = new char[ bufSize ];
13312 
13313  WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, nullptr, nullptr );
13314  }
13315 
13316  int returnCode = applyCommandLine( argc, utf8Argv );
13317 
13318  for ( int i = 0; i < argc; ++i )
13319  delete [] utf8Argv[ i ];
13320 
13321  delete [] utf8Argv;
13322 
13323  return returnCode;
13324  }
13325 #endif
13326 
13327  void Session::useConfigData( ConfigData const& configData ) {
13328  m_configData = configData;
13329  m_config.reset();
13330  }
13331 
13332  int Session::run() {
13333  if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {
13334  Catch::cout() << "...waiting for enter/ return before starting" << std::endl;
13335  static_cast<void>(std::getchar());
13336  }
13337  int exitCode = runInternal();
13338  if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {
13339  Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl;
13340  static_cast<void>(std::getchar());
13341  }
13342  return exitCode;
13343  }
13344 
13345  clara::Parser const& Session::cli() const {
13346  return m_cli;
13347  }
13348  void Session::cli( clara::Parser const& newParser ) {
13349  m_cli = newParser;
13350  }
13351  ConfigData& Session::configData() {
13352  return m_configData;
13353  }
13354  Config& Session::config() {
13355  if( !m_config )
13356  m_config = std::make_shared<Config>( m_configData );
13357  return *m_config;
13358  }
13359 
13360  int Session::runInternal() {
13361  if( m_startupExceptions )
13362  return 1;
13363 
13364  if (m_configData.showHelp || m_configData.libIdentify) {
13365  return 0;
13366  }
13367 
13368  CATCH_TRY {
13369  config(); // Force config to be constructed
13370 
13371  seedRng( *m_config );
13372 
13373  if( m_configData.filenamesAsTags )
13374  applyFilenamesAsTags( *m_config );
13375 
13376  // Handle list request
13377  if( Option<std::size_t> listed = list( m_config ) )
13378  return static_cast<int>( *listed );
13379 
13380  TestGroup tests { m_config };
13381  auto const totals = tests.execute();
13382 
13383  if( m_config->warnAboutNoTests() && totals.error == -1 )
13384  return 2;
13385 
13386  // Note that on unices only the lower 8 bits are usually used, clamping
13387  // the return value to 255 prevents false negative when some multiple
13388  // of 256 tests has failed
13389  return (std::min) (MaxExitCode, (std::max) (totals.error, static_cast<int>(totals.assertions.failed)));
13390  }
13391 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
13392  catch( std::exception& ex ) {
13393  Catch::cerr() << ex.what() << std::endl;
13394  return MaxExitCode;
13395  }
13396 #endif
13397  }
13398 
13399 } // end namespace Catch
13400 // end catch_session.cpp
13401 // start catch_singletons.cpp
13402 
13403 #include <vector>
13404 
13405 namespace Catch {
13406 
13407  namespace {
13408  static auto getSingletons() -> std::vector<ISingleton*>*& {
13409  static std::vector<ISingleton*>* g_singletons = nullptr;
13410  if( !g_singletons )
13411  g_singletons = new std::vector<ISingleton*>();
13412  return g_singletons;
13413  }
13414  }
13415 
13416  ISingleton::~ISingleton() {}
13417 
13418  void addSingleton(ISingleton* singleton ) {
13419  getSingletons()->push_back( singleton );
13420  }
13421  void cleanupSingletons() {
13422  auto& singletons = getSingletons();
13423  for( auto singleton : *singletons )
13424  delete singleton;
13425  delete singletons;
13426  singletons = nullptr;
13427  }
13428 
13429 } // namespace Catch
13430 // end catch_singletons.cpp
13431 // start catch_startup_exception_registry.cpp
13432 
13433 namespace Catch {
13434 void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept {
13435  CATCH_TRY {
13436  m_exceptions.push_back(exception);
13437  } CATCH_CATCH_ALL {
13438  // If we run out of memory during start-up there's really not a lot more we can do about it
13439  std::terminate();
13440  }
13441  }
13442 
13443  std::vector<std::exception_ptr> const& StartupExceptionRegistry::getExceptions() const noexcept {
13444  return m_exceptions;
13445  }
13446 
13447 } // end namespace Catch
13448 // end catch_startup_exception_registry.cpp
13449 // start catch_stream.cpp
13450 
13451 #include <cstdio>
13452 #include <iostream>
13453 #include <fstream>
13454 #include <sstream>
13455 #include <vector>
13456 #include <memory>
13457 
13458 namespace Catch {
13459 
13460  Catch::IStream::~IStream() = default;
13461 
13462  namespace Detail { namespace {
13463  template<typename WriterF, std::size_t bufferSize=256>
13464  class StreamBufImpl : public std::streambuf {
13465  char data[bufferSize];
13466  WriterF m_writer;
13467 
13468  public:
13469  StreamBufImpl() {
13470  setp( data, data + sizeof(data) );
13471  }
13472 
13473  ~StreamBufImpl() noexcept {
13475  }
13476 
13477  private:
13478  int overflow( int c ) override {
13479  sync();
13480 
13481  if( c != EOF ) {
13482  if( pbase() == epptr() )
13483  m_writer( std::string( 1, static_cast<char>( c ) ) );
13484  else
13485  sputc( static_cast<char>( c ) );
13486  }
13487  return 0;
13488  }
13489 
13490  int sync() override {
13491  if( pbase() != pptr() ) {
13492  m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
13493  setp( pbase(), epptr() );
13494  }
13495  return 0;
13496  }
13497  };
13498 
13500 
13501  struct OutputDebugWriter {
13502 
13503  void operator()( std::string const&str ) {
13504  writeToDebugConsole( str );
13505  }
13506  };
13507 
13509 
13510  class FileStream : public IStream {
13511  mutable std::ofstream m_ofs;
13512  public:
13513  FileStream( StringRef filename ) {
13514  m_ofs.open( filename.c_str() );
13515  CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" );
13516  }
13517  ~FileStream() override = default;
13518  public: // IStream
13519  std::ostream& stream() const override {
13520  return m_ofs;
13521  }
13522  };
13523 
13525 
13526  class CoutStream : public IStream {
13527  mutable std::ostream m_os;
13528  public:
13529  // Store the streambuf from cout up-front because
13530  // cout may get redirected when running tests
13531  CoutStream() : m_os( Catch::cout().rdbuf() ) {}
13532  ~CoutStream() override = default;
13533 
13534  public: // IStream
13535  std::ostream& stream() const override { return m_os; }
13536  };
13537 
13539 
13540  class DebugOutStream : public IStream {
13541  std::unique_ptr<StreamBufImpl<OutputDebugWriter>> m_streamBuf;
13542  mutable std::ostream m_os;
13543  public:
13544  DebugOutStream()
13545  : m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
13546  m_os( m_streamBuf.get() )
13547  {}
13548 
13549  ~DebugOutStream() override = default;
13550 
13551  public: // IStream
13552  std::ostream& stream() const override { return m_os; }
13553  };
13554 
13555  }} // namespace anon::detail
13556 
13558 
13559  auto makeStream( StringRef const &filename ) -> IStream const* {
13560  if( filename.empty() )
13561  return new Detail::CoutStream();
13562  else if( filename[0] == '%' ) {
13563  if( filename == "%debug" )
13564  return new Detail::DebugOutStream();
13565  else
13566  CATCH_ERROR( "Unrecognised stream: '" << filename << "'" );
13567  }
13568  else
13569  return new Detail::FileStream( filename );
13570  }
13571 
13572  // This class encapsulates the idea of a pool of ostringstreams that can be reused.
13573  struct StringStreams {
13574  std::vector<std::unique_ptr<std::ostringstream>> m_streams;
13575  std::vector<std::size_t> m_unused;
13576  std::ostringstream m_referenceStream; // Used for copy state/ flags from
13577 
13578  auto add() -> std::size_t {
13579  if( m_unused.empty() ) {
13580  m_streams.push_back( std::unique_ptr<std::ostringstream>( new std::ostringstream ) );
13581  return m_streams.size()-1;
13582  }
13583  else {
13584  auto index = m_unused.back();
13585  m_unused.pop_back();
13586  return index;
13587  }
13588  }
13589 
13590  void release( std::size_t index ) {
13591  m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state
13592  m_unused.push_back(index);
13593  }
13594  };
13595 
13597  : m_index( Singleton<StringStreams>::getMutable().add() ),
13598  m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )
13599  {}
13600 
13602  static_cast<std::ostringstream*>( m_oss )->str("");
13603  m_oss->clear();
13604  Singleton<StringStreams>::getMutable().release( m_index );
13605  }
13606 
13607  auto ReusableStringStream::str() const -> std::string {
13608  return static_cast<std::ostringstream*>( m_oss )->str();
13609  }
13610 
13612 
13613 #ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions
13614  std::ostream& cout() { return std::cout; }
13615  std::ostream& cerr() { return std::cerr; }
13616  std::ostream& clog() { return std::clog; }
13617 #endif
13618 }
13619 // end catch_stream.cpp
13620 // start catch_string_manip.cpp
13621 
13622 #include <algorithm>
13623 #include <ostream>
13624 #include <cstring>
13625 #include <cctype>
13626 #include <vector>
13627 
13628 namespace Catch {
13629 
13630  namespace {
13631  char toLowerCh(char c) {
13632  return static_cast<char>( std::tolower( c ) );
13633  }
13634  }
13635 
13636  bool startsWith( std::string const& s, std::string const& prefix ) {
13637  return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
13638  }
13639  bool startsWith( std::string const& s, char prefix ) {
13640  return !s.empty() && s[0] == prefix;
13641  }
13642  bool endsWith( std::string const& s, std::string const& suffix ) {
13643  return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
13644  }
13645  bool endsWith( std::string const& s, char suffix ) {
13646  return !s.empty() && s[s.size()-1] == suffix;
13647  }
13648  bool contains( std::string const& s, std::string const& infix ) {
13649  return s.find( infix ) != std::string::npos;
13650  }
13651  void toLowerInPlace( std::string& s ) {
13652  std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
13653  }
13654  std::string toLower( std::string const& s ) {
13655  std::string lc = s;
13656  toLowerInPlace( lc );
13657  return lc;
13658  }
13659  std::string trim( std::string const& str ) {
13660  static char const* whitespaceChars = "\n\r\t ";
13661  std::string::size_type start = str.find_first_not_of( whitespaceChars );
13662  std::string::size_type end = str.find_last_not_of( whitespaceChars );
13663 
13664  return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string();
13665  }
13666 
13668  const auto is_ws = [](char c) {
13669  return c == ' ' || c == '\t' || c == '\n' || c == '\r';
13670  };
13671  size_t real_begin = 0;
13672  while (real_begin < ref.size() && is_ws(ref[real_begin])) { ++real_begin; }
13673  size_t real_end = ref.size();
13674  while (real_end > real_begin && is_ws(ref[real_end - 1])) { --real_end; }
13675 
13676  return ref.substr(real_begin, real_end - real_begin);
13677  }
13678 
13679  bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
13680  bool replaced = false;
13681  std::size_t i = str.find( replaceThis );
13682  while( i != std::string::npos ) {
13683  replaced = true;
13684  str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() );
13685  if( i < str.size()-withThis.size() )
13686  i = str.find( replaceThis, i+withThis.size() );
13687  else
13688  i = std::string::npos;
13689  }
13690  return replaced;
13691  }
13692 
13693  std::vector<StringRef> splitStringRef( StringRef str, char delimiter ) {
13694  std::vector<StringRef> subStrings;
13695  std::size_t start = 0;
13696  for(std::size_t pos = 0; pos < str.size(); ++pos ) {
13697  if( str[pos] == delimiter ) {
13698  if( pos - start > 1 )
13699  subStrings.push_back( str.substr( start, pos-start ) );
13700  start = pos+1;
13701  }
13702  }
13703  if( start < str.size() )
13704  subStrings.push_back( str.substr( start, str.size()-start ) );
13705  return subStrings;
13706  }
13707 
13708  pluralise::pluralise( std::size_t count, std::string const& label )
13709  : m_count( count ),
13710  m_label( label )
13711  {}
13712 
13713  std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
13714  os << pluraliser.m_count << ' ' << pluraliser.m_label;
13715  if( pluraliser.m_count != 1 )
13716  os << 's';
13717  return os;
13718  }
13719 
13720 }
13721 // end catch_string_manip.cpp
13722 // start catch_stringref.cpp
13723 
13724 #include <algorithm>
13725 #include <ostream>
13726 #include <cstring>
13727 #include <cstdint>
13728 
13729 namespace Catch {
13730  StringRef::StringRef( char const* rawChars ) noexcept
13731  : StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
13732  {}
13733 
13734  auto StringRef::c_str() const -> char const* {
13735  CATCH_ENFORCE(isNullTerminated(), "Called StringRef::c_str() on a non-null-terminated instance");
13736  return m_start;
13737  }
13738  auto StringRef::data() const noexcept -> char const* {
13739  return m_start;
13740  }
13741 
13742  auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {
13743  if (start < m_size) {
13744  return StringRef(m_start + start, (std::min)(m_size - start, size));
13745  } else {
13746  return StringRef();
13747  }
13748  }
13749  auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool {
13750  return m_size == other.m_size
13751  && (std::memcmp( m_start, other.m_start, m_size ) == 0);
13752  }
13753 
13754  auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
13755  return os.write(str.data(), str.size());
13756  }
13757 
13758  auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& {
13759  lhs.append(rhs.data(), rhs.size());
13760  return lhs;
13761  }
13762 
13763 } // namespace Catch
13764 // end catch_stringref.cpp
13765 // start catch_tag_alias.cpp
13766 
13767 namespace Catch {
13768  TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {}
13769 }
13770 // end catch_tag_alias.cpp
13771 // start catch_tag_alias_autoregistrar.cpp
13772 
13773 namespace Catch {
13774 
13775  RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) {
13776  CATCH_TRY {
13777  getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo);
13778  } CATCH_CATCH_ALL {
13779  // Do not throw when constructing global objects, instead register the exception to be processed later
13781  }
13782  }
13783 
13784 }
13785 // end catch_tag_alias_autoregistrar.cpp
13786 // start catch_tag_alias_registry.cpp
13787 
13788 #include <sstream>
13789 
13790 namespace Catch {
13791 
13792  TagAliasRegistry::~TagAliasRegistry() {}
13793 
13794  TagAlias const* TagAliasRegistry::find( std::string const& alias ) const {
13795  auto it = m_registry.find( alias );
13796  if( it != m_registry.end() )
13797  return &(it->second);
13798  else
13799  return nullptr;
13800  }
13801 
13802  std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
13803  std::string expandedTestSpec = unexpandedTestSpec;
13804  for( auto const& registryKvp : m_registry ) {
13805  std::size_t pos = expandedTestSpec.find( registryKvp.first );
13806  if( pos != std::string::npos ) {
13807  expandedTestSpec = expandedTestSpec.substr( 0, pos ) +
13808  registryKvp.second.tag +
13809  expandedTestSpec.substr( pos + registryKvp.first.size() );
13810  }
13811  }
13812  return expandedTestSpec;
13813  }
13814 
13815  void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) {
13816  CATCH_ENFORCE( startsWith(alias, "[@") && endsWith(alias, ']'),
13817  "error: tag alias, '" << alias << "' is not of the form [@alias name].\n" << lineInfo );
13818 
13819  CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second,
13820  "error: tag alias, '" << alias << "' already registered.\n"
13821  << "\tFirst seen at: " << find(alias)->lineInfo << "\n"
13822  << "\tRedefined at: " << lineInfo );
13823  }
13824 
13825  ITagAliasRegistry::~ITagAliasRegistry() {}
13826 
13827  ITagAliasRegistry const& ITagAliasRegistry::get() {
13829  }
13830 
13831 } // end namespace Catch
13832 // end catch_tag_alias_registry.cpp
13833 // start catch_test_case_info.cpp
13834 
13835 #include <cctype>
13836 #include <exception>
13837 #include <algorithm>
13838 #include <sstream>
13839 
13840 namespace Catch {
13841 
13842  namespace {
13843  TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
13844  if( startsWith( tag, '.' ) ||
13845  tag == "!hide" )
13846  return TestCaseInfo::IsHidden;
13847  else if( tag == "!throws" )
13848  return TestCaseInfo::Throws;
13849  else if( tag == "!shouldfail" )
13850  return TestCaseInfo::ShouldFail;
13851  else if( tag == "!mayfail" )
13852  return TestCaseInfo::MayFail;
13853  else if( tag == "!nonportable" )
13855  else if( tag == "!benchmark" )
13857  else
13858  return TestCaseInfo::None;
13859  }
13860  bool isReservedTag( std::string const& tag ) {
13861  return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast<unsigned char>(tag[0]) );
13862  }
13863  void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
13864  CATCH_ENFORCE( !isReservedTag(tag),
13865  "Tag name: [" << tag << "] is not allowed.\n"
13866  << "Tag names starting with non alphanumeric characters are reserved\n"
13867  << _lineInfo );
13868  }
13869  }
13870 
13871  TestCase makeTestCase( ITestInvoker* _testCase,
13872  std::string const& _className,
13873  NameAndTags const& nameAndTags,
13874  SourceLineInfo const& _lineInfo )
13875  {
13876  bool isHidden = false;
13877 
13878  // Parse out tags
13879  std::vector<std::string> tags;
13880  std::string desc, tag;
13881  bool inTag = false;
13882  for (char c : nameAndTags.tags) {
13883  if( !inTag ) {
13884  if( c == '[' )
13885  inTag = true;
13886  else
13887  desc += c;
13888  }
13889  else {
13890  if( c == ']' ) {
13891  TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag );
13892  if( ( prop & TestCaseInfo::IsHidden ) != 0 )
13893  isHidden = true;
13894  else if( prop == TestCaseInfo::None )
13895  enforceNotReservedTag( tag, _lineInfo );
13896 
13897  // Merged hide tags like `[.approvals]` should be added as
13898  // `[.][approvals]`. The `[.]` is added at later point, so
13899  // we only strip the prefix
13900  if (startsWith(tag, '.') && tag.size() > 1) {
13901  tag.erase(0, 1);
13902  }
13903  tags.push_back( tag );
13904  tag.clear();
13905  inTag = false;
13906  }
13907  else
13908  tag += c;
13909  }
13910  }
13911  if( isHidden ) {
13912  // Add all "hidden" tags to make them behave identically
13913  tags.insert( tags.end(), { ".", "!hide" } );
13914  }
13915 
13916  TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, desc, tags, _lineInfo );
13917  return TestCase( _testCase, std::move(info) );
13918  }
13919 
13920  void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ) {
13921  std::sort(begin(tags), end(tags));
13922  tags.erase(std::unique(begin(tags), end(tags)), end(tags));
13923  testCaseInfo.lcaseTags.clear();
13924 
13925  for( auto const& tag : tags ) {
13926  std::string lcaseTag = toLower( tag );
13927  testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
13928  testCaseInfo.lcaseTags.push_back( lcaseTag );
13929  }
13930  testCaseInfo.tags = std::move(tags);
13931  }
13932 
13933  TestCaseInfo::TestCaseInfo( std::string const& _name,
13934  std::string const& _className,
13935  std::string const& _description,
13936  std::vector<std::string> const& _tags,
13937  SourceLineInfo const& _lineInfo )
13938  : name( _name ),
13939  className( _className ),
13940  description( _description ),
13941  lineInfo( _lineInfo ),
13942  properties( None )
13943  {
13944  setTags( *this, _tags );
13945  }
13946 
13947  bool TestCaseInfo::isHidden() const {
13948  return ( properties & IsHidden ) != 0;
13949  }
13950  bool TestCaseInfo::throws() const {
13951  return ( properties & Throws ) != 0;
13952  }
13953  bool TestCaseInfo::okToFail() const {
13954  return ( properties & (ShouldFail | MayFail ) ) != 0;
13955  }
13956  bool TestCaseInfo::expectedToFail() const {
13957  return ( properties & (ShouldFail ) ) != 0;
13958  }
13959 
13960  std::string TestCaseInfo::tagsAsString() const {
13961  std::string ret;
13962  // '[' and ']' per tag
13963  std::size_t full_size = 2 * tags.size();
13964  for (const auto& tag : tags) {
13965  full_size += tag.size();
13966  }
13967  ret.reserve(full_size);
13968  for (const auto& tag : tags) {
13969  ret.push_back('[');
13970  ret.append(tag);
13971  ret.push_back(']');
13972  }
13973 
13974  return ret;
13975  }
13976 
13977  TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {}
13978 
13979  TestCase TestCase::withName( std::string const& _newName ) const {
13980  TestCase other( *this );
13981  other.name = _newName;
13982  return other;
13983  }
13984 
13985  void TestCase::invoke() const {
13986  test->invoke();
13987  }
13988 
13989  bool TestCase::operator == ( TestCase const& other ) const {
13990  return test.get() == other.test.get() &&
13991  name == other.name &&
13992  className == other.className;
13993  }
13994 
13995  bool TestCase::operator < ( TestCase const& other ) const {
13996  return name < other.name;
13997  }
13998 
14000  {
14001  return *this;
14002  }
14003 
14004 } // end namespace Catch
14005 // end catch_test_case_info.cpp
14006 // start catch_test_case_registry_impl.cpp
14007 
14008 #include <algorithm>
14009 #include <sstream>
14010 
14011 namespace Catch {
14012 
14013  namespace {
14014  struct TestHasher {
14015  explicit TestHasher(Catch::SimplePcg32& rng) {
14016  basis = rng();
14017  basis <<= 32;
14018  basis |= rng();
14019  }
14020 
14021  uint64_t basis;
14022 
14023  uint64_t operator()(TestCase const& t) const {
14024  // Modified FNV-1a hash
14025  static constexpr uint64_t prime = 1099511628211;
14026  uint64_t hash = basis;
14027  for (const char c : t.name) {
14028  hash ^= c;
14029  hash *= prime;
14030  }
14031  return hash;
14032  }
14033  };
14034  } // end unnamed namespace
14035 
14036  std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
14037  switch( config.runOrder() ) {
14039  // already in declaration order
14040  break;
14041 
14043  std::vector<TestCase> sorted = unsortedTestCases;
14044  std::sort( sorted.begin(), sorted.end() );
14045  return sorted;
14046  }
14047 
14048  case RunTests::InRandomOrder: {
14049  seedRng( config );
14050  TestHasher h( rng() );
14051 
14052  using hashedTest = std::pair<uint64_t, TestCase const*>;
14053  std::vector<hashedTest> indexed_tests;
14054  indexed_tests.reserve( unsortedTestCases.size() );
14055 
14056  for (auto const& testCase : unsortedTestCases) {
14057  indexed_tests.emplace_back(h(testCase), &testCase);
14058  }
14059 
14060  std::sort(indexed_tests.begin(), indexed_tests.end(),
14061  [](hashedTest const& lhs, hashedTest const& rhs) {
14062  if (lhs.first == rhs.first) {
14063  return lhs.second->name < rhs.second->name;
14064  }
14065  return lhs.first < rhs.first;
14066  });
14067 
14068  std::vector<TestCase> sorted;
14069  sorted.reserve( indexed_tests.size() );
14070 
14071  for (auto const& hashed : indexed_tests) {
14072  sorted.emplace_back(*hashed.second);
14073  }
14074 
14075  return sorted;
14076  }
14077  }
14078  return unsortedTestCases;
14079  }
14080 
14081  bool isThrowSafe( TestCase const& testCase, IConfig const& config ) {
14082  return !testCase.throws() || config.allowThrows();
14083  }
14084 
14085  bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
14086  return testSpec.matches( testCase ) && isThrowSafe( testCase, config );
14087  }
14088 
14089  void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
14090  std::set<TestCase> seenFunctions;
14091  for( auto const& function : functions ) {
14092  auto prev = seenFunctions.insert( function );
14093  CATCH_ENFORCE( prev.second,
14094  "error: TEST_CASE( \"" << function.name << "\" ) already defined.\n"
14095  << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
14096  << "\tRedefined at " << function.getTestCaseInfo().lineInfo );
14097  }
14098  }
14099 
14100  std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
14101  std::vector<TestCase> filtered;
14102  filtered.reserve( testCases.size() );
14103  for (auto const& testCase : testCases) {
14104  if ((!testSpec.hasFilters() && !testCase.isHidden()) ||
14105  (testSpec.hasFilters() && matchTest(testCase, testSpec, config))) {
14106  filtered.push_back(testCase);
14107  }
14108  }
14109  return filtered;
14110  }
14111  std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {
14113  }
14114 
14115  void TestRegistry::registerTest( TestCase const& testCase ) {
14116  std::string name = testCase.getTestCaseInfo().name;
14117  if( name.empty() ) {
14119  rss << "Anonymous test case " << ++m_unnamedCount;
14120  return registerTest( testCase.withName( rss.str() ) );
14121  }
14122  m_functions.push_back( testCase );
14123  }
14124 
14125  std::vector<TestCase> const& TestRegistry::getAllTests() const {
14126  return m_functions;
14127  }
14128  std::vector<TestCase> const& TestRegistry::getAllTestsSorted( IConfig const& config ) const {
14129  if( m_sortedFunctions.empty() )
14130  enforceNoDuplicateTestCases( m_functions );
14131 
14132  if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) {
14133  m_sortedFunctions = sortTests( config, m_functions );
14134  m_currentSortOrder = config.runOrder();
14135  }
14136  return m_sortedFunctions;
14137  }
14138 
14140  TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {}
14141 
14142  void TestInvokerAsFunction::invoke() const {
14143  m_testAsFunction();
14144  }
14145 
14146  std::string extractClassName( StringRef const& classOrQualifiedMethodName ) {
14147  std::string className(classOrQualifiedMethodName);
14148  if( startsWith( className, '&' ) )
14149  {
14150  std::size_t lastColons = className.rfind( "::" );
14151  std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
14152  if( penultimateColons == std::string::npos )
14153  penultimateColons = 1;
14154  className = className.substr( penultimateColons, lastColons-penultimateColons );
14155  }
14156  return className;
14157  }
14158 
14159 } // end namespace Catch
14160 // end catch_test_case_registry_impl.cpp
14161 // start catch_test_case_tracker.cpp
14162 
14163 #include <algorithm>
14164 #include <cassert>
14165 #include <stdexcept>
14166 #include <memory>
14167 #include <sstream>
14168 
14169 #if defined(__clang__)
14170 # pragma clang diagnostic push
14171 # pragma clang diagnostic ignored "-Wexit-time-destructors"
14172 #endif
14173 
14174 namespace Catch {
14175 namespace TestCaseTracking {
14176 
14177  NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location )
14178  : name( _name ),
14179  location( _location )
14180  {}
14181 
14182  ITracker::~ITracker() = default;
14183 
14184  ITracker& TrackerContext::startRun() {
14185  m_rootTracker = std::make_shared<SectionTracker>( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, nullptr );
14186  m_currentTracker = nullptr;
14187  m_runState = Executing;
14188  return *m_rootTracker;
14189  }
14190 
14191  void TrackerContext::endRun() {
14192  m_rootTracker.reset();
14193  m_currentTracker = nullptr;
14194  m_runState = NotStarted;
14195  }
14196 
14197  void TrackerContext::startCycle() {
14198  m_currentTracker = m_rootTracker.get();
14199  m_runState = Executing;
14200  }
14201  void TrackerContext::completeCycle() {
14202  m_runState = CompletedCycle;
14203  }
14204 
14205  bool TrackerContext::completedCycle() const {
14206  return m_runState == CompletedCycle;
14207  }
14208  ITracker& TrackerContext::currentTracker() {
14209  return *m_currentTracker;
14210  }
14211  void TrackerContext::setCurrentTracker( ITracker* tracker ) {
14212  m_currentTracker = tracker;
14213  }
14214 
14215  TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
14216  : m_nameAndLocation( nameAndLocation ),
14217  m_ctx( ctx ),
14218  m_parent( parent )
14219  {}
14220 
14221  NameAndLocation const& TrackerBase::nameAndLocation() const {
14222  return m_nameAndLocation;
14223  }
14224  bool TrackerBase::isComplete() const {
14225  return m_runState == CompletedSuccessfully || m_runState == Failed;
14226  }
14227  bool TrackerBase::isSuccessfullyCompleted() const {
14228  return m_runState == CompletedSuccessfully;
14229  }
14230  bool TrackerBase::isOpen() const {
14231  return m_runState != NotStarted && !isComplete();
14232  }
14233  bool TrackerBase::hasChildren() const {
14234  return !m_children.empty();
14235  }
14236 
14237  void TrackerBase::addChild( ITrackerPtr const& child ) {
14238  m_children.push_back( child );
14239  }
14240 
14241  ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) {
14242  auto it = std::find_if( m_children.begin(), m_children.end(),
14243  [&nameAndLocation]( ITrackerPtr const& tracker ){
14244  return
14245  tracker->nameAndLocation().location == nameAndLocation.location &&
14246  tracker->nameAndLocation().name == nameAndLocation.name;
14247  } );
14248  return( it != m_children.end() )
14249  ? *it
14250  : nullptr;
14251  }
14252  ITracker& TrackerBase::parent() {
14253  assert( m_parent ); // Should always be non-null except for root
14254  return *m_parent;
14255  }
14256 
14257  void TrackerBase::openChild() {
14258  if( m_runState != ExecutingChildren ) {
14259  m_runState = ExecutingChildren;
14260  if( m_parent )
14261  m_parent->openChild();
14262  }
14263  }
14264 
14265  bool TrackerBase::isSectionTracker() const { return false; }
14266  bool TrackerBase::isGeneratorTracker() const { return false; }
14267 
14268  void TrackerBase::open() {
14269  m_runState = Executing;
14270  moveToThis();
14271  if( m_parent )
14272  m_parent->openChild();
14273  }
14274 
14275  void TrackerBase::close() {
14276 
14277  // Close any still open children (e.g. generators)
14278  while( &m_ctx.currentTracker() != this )
14279  m_ctx.currentTracker().close();
14280 
14281  switch( m_runState ) {
14282  case NeedsAnotherRun:
14283  break;
14284 
14285  case Executing:
14286  m_runState = CompletedSuccessfully;
14287  break;
14288  case ExecutingChildren:
14289  if( std::all_of(m_children.begin(), m_children.end(), [](ITrackerPtr const& t){ return t->isComplete(); }) )
14290  m_runState = CompletedSuccessfully;
14291  break;
14292 
14293  case NotStarted:
14294  case CompletedSuccessfully:
14295  case Failed:
14296  CATCH_INTERNAL_ERROR( "Illogical state: " << m_runState );
14297 
14298  default:
14299  CATCH_INTERNAL_ERROR( "Unknown state: " << m_runState );
14300  }
14301  moveToParent();
14302  m_ctx.completeCycle();
14303  }
14304  void TrackerBase::fail() {
14305  m_runState = Failed;
14306  if( m_parent )
14307  m_parent->markAsNeedingAnotherRun();
14308  moveToParent();
14309  m_ctx.completeCycle();
14310  }
14311  void TrackerBase::markAsNeedingAnotherRun() {
14312  m_runState = NeedsAnotherRun;
14313  }
14314 
14315  void TrackerBase::moveToParent() {
14316  assert( m_parent );
14317  m_ctx.setCurrentTracker( m_parent );
14318  }
14319  void TrackerBase::moveToThis() {
14320  m_ctx.setCurrentTracker( this );
14321  }
14322 
14323  SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
14324  : TrackerBase( nameAndLocation, ctx, parent ),
14325  m_trimmed_name(trim(nameAndLocation.name))
14326  {
14327  if( parent ) {
14328  while( !parent->isSectionTracker() )
14329  parent = &parent->parent();
14330 
14331  SectionTracker& parentSection = static_cast<SectionTracker&>( *parent );
14332  addNextFilters( parentSection.m_filters );
14333  }
14334  }
14335 
14336  bool SectionTracker::isComplete() const {
14337  bool complete = true;
14338 
14339  if ((m_filters.empty() || m_filters[0] == "")
14340  || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) {
14341  complete = TrackerBase::isComplete();
14342  }
14343  return complete;
14344  }
14345 
14346  bool SectionTracker::isSectionTracker() const { return true; }
14347 
14348  SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) {
14349  std::shared_ptr<SectionTracker> section;
14350 
14351  ITracker& currentTracker = ctx.currentTracker();
14352  if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {
14353  assert( childTracker );
14354  assert( childTracker->isSectionTracker() );
14355  section = std::static_pointer_cast<SectionTracker>( childTracker );
14356  }
14357  else {
14358  section = std::make_shared<SectionTracker>( nameAndLocation, ctx, &currentTracker );
14359  currentTracker.addChild( section );
14360  }
14361  if( !ctx.completedCycle() )
14362  section->tryOpen();
14363  return *section;
14364  }
14365 
14366  void SectionTracker::tryOpen() {
14367  if( !isComplete() )
14368  open();
14369  }
14370 
14371  void SectionTracker::addInitialFilters( std::vector<std::string> const& filters ) {
14372  if( !filters.empty() ) {
14373  m_filters.reserve( m_filters.size() + filters.size() + 2 );
14374  m_filters.emplace_back(""); // Root - should never be consulted
14375  m_filters.emplace_back(""); // Test Case - not a section filter
14376  m_filters.insert( m_filters.end(), filters.begin(), filters.end() );
14377  }
14378  }
14379  void SectionTracker::addNextFilters( std::vector<std::string> const& filters ) {
14380  if( filters.size() > 1 )
14381  m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() );
14382  }
14383 
14384 } // namespace TestCaseTracking
14385 
14386 using TestCaseTracking::ITracker;
14387 using TestCaseTracking::TrackerContext;
14388 using TestCaseTracking::SectionTracker;
14389 
14390 } // namespace Catch
14391 
14392 #if defined(__clang__)
14393 # pragma clang diagnostic pop
14394 #endif
14395 // end catch_test_case_tracker.cpp
14396 // start catch_test_registry.cpp
14397 
14398 namespace Catch {
14399 
14400  auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* {
14401  return new(std::nothrow) TestInvokerAsFunction( testAsFunction );
14402  }
14403 
14404  NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {}
14405 
14406  AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
14407  CATCH_TRY {
14409  .registerTest(
14410  makeTestCase(
14411  invoker,
14412  extractClassName( classOrMethod ),
14413  nameAndTags,
14414  lineInfo));
14415  } CATCH_CATCH_ALL {
14416  // Do not throw when constructing global objects, instead register the exception to be processed later
14418  }
14419  }
14420 
14421  AutoReg::~AutoReg() = default;
14422 }
14423 // end catch_test_registry.cpp
14424 // start catch_test_spec.cpp
14425 
14426 #include <algorithm>
14427 #include <string>
14428 #include <vector>
14429 #include <memory>
14430 
14431 namespace Catch {
14432 
14433  TestSpec::Pattern::Pattern( std::string const& name )
14434  : m_name( name )
14435  {}
14436 
14437  TestSpec::Pattern::~Pattern() = default;
14438 
14439  std::string const& TestSpec::Pattern::name() const {
14440  return m_name;
14441  }
14442 
14443  TestSpec::NamePattern::NamePattern( std::string const& name, std::string const& filterString )
14444  : Pattern( filterString )
14445  , m_wildcardPattern( toLower( name ), CaseSensitive::No )
14446  {}
14447 
14448  bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const {
14449  return m_wildcardPattern.matches( testCase.name );
14450  }
14451 
14452  TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString )
14453  : Pattern( filterString )
14454  , m_tag( toLower( tag ) )
14455  {}
14456 
14457  bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const {
14458  return std::find(begin(testCase.lcaseTags),
14459  end(testCase.lcaseTags),
14460  m_tag) != end(testCase.lcaseTags);
14461  }
14462 
14463  TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern )
14464  : Pattern( underlyingPattern->name() )
14465  , m_underlyingPattern( underlyingPattern )
14466  {}
14467 
14468  bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const {
14469  return !m_underlyingPattern->matches( testCase );
14470  }
14471 
14472  bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
14473  return std::all_of( m_patterns.begin(), m_patterns.end(), [&]( PatternPtr const& p ){ return p->matches( testCase ); } );
14474  }
14475 
14476  std::string TestSpec::Filter::name() const {
14477  std::string name;
14478  for( auto const& p : m_patterns )
14479  name += p->name();
14480  return name;
14481  }
14482 
14483  bool TestSpec::hasFilters() const {
14484  return !m_filters.empty();
14485  }
14486 
14487  bool TestSpec::matches( TestCaseInfo const& testCase ) const {
14488  return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } );
14489  }
14490 
14491  TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCase> const& testCases, IConfig const& config ) const
14492  {
14493  Matches matches( m_filters.size() );
14494  std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){
14495  std::vector<TestCase const*> currentMatches;
14496  for( auto const& test : testCases )
14497  if( isThrowSafe( test, config ) && filter.matches( test ) )
14498  currentMatches.emplace_back( &test );
14499  return FilterMatch{ filter.name(), currentMatches };
14500  } );
14501  return matches;
14502  }
14503 
14504  const TestSpec::vectorStrings& TestSpec::getInvalidArgs() const{
14505  return (m_invalidArgs);
14506  }
14507 
14508 }
14509 // end catch_test_spec.cpp
14510 // start catch_test_spec_parser.cpp
14511 
14512 namespace Catch {
14513 
14514  TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
14515 
14516  TestSpecParser& TestSpecParser::parse( std::string const& arg ) {
14517  m_mode = None;
14518  m_exclusion = false;
14519  m_arg = m_tagAliases->expandAliases( arg );
14520  m_escapeChars.clear();
14521  m_substring.reserve(m_arg.size());
14522  m_patternName.reserve(m_arg.size());
14523  m_realPatternPos = 0;
14524 
14525  for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
14526  //if visitChar fails
14527  if( !visitChar( m_arg[m_pos] ) ){
14528  m_testSpec.m_invalidArgs.push_back(arg);
14529  break;
14530  }
14531  endMode();
14532  return *this;
14533  }
14534  TestSpec TestSpecParser::testSpec() {
14535  addFilter();
14536  return m_testSpec;
14537  }
14538  bool TestSpecParser::visitChar( char c ) {
14539  if( (m_mode != EscapedName) && (c == '\\') ) {
14540  escape();
14541  addCharToPattern(c);
14542  return true;
14543  }else if((m_mode != EscapedName) && (c == ',') ) {
14544  return separate();
14545  }
14546 
14547  switch( m_mode ) {
14548  case None:
14549  if( processNoneChar( c ) )
14550  return true;
14551  break;
14552  case Name:
14553  processNameChar( c );
14554  break;
14555  case EscapedName:
14556  endMode();
14557  addCharToPattern(c);
14558  return true;
14559  default:
14560  case Tag:
14561  case QuotedName:
14562  if( processOtherChar( c ) )
14563  return true;
14564  break;
14565  }
14566 
14567  m_substring += c;
14568  if( !isControlChar( c ) ) {
14569  m_patternName += c;
14570  m_realPatternPos++;
14571  }
14572  return true;
14573  }
14574  // Two of the processing methods return true to signal the caller to return
14575  // without adding the given character to the current pattern strings
14576  bool TestSpecParser::processNoneChar( char c ) {
14577  switch( c ) {
14578  case ' ':
14579  return true;
14580  case '~':
14581  m_exclusion = true;
14582  return false;
14583  case '[':
14584  startNewMode( Tag );
14585  return false;
14586  case '"':
14587  startNewMode( QuotedName );
14588  return false;
14589  default:
14590  startNewMode( Name );
14591  return false;
14592  }
14593  }
14594  void TestSpecParser::processNameChar( char c ) {
14595  if( c == '[' ) {
14596  if( m_substring == "exclude:" )
14597  m_exclusion = true;
14598  else
14599  endMode();
14600  startNewMode( Tag );
14601  }
14602  }
14603  bool TestSpecParser::processOtherChar( char c ) {
14604  if( !isControlChar( c ) )
14605  return false;
14606  m_substring += c;
14607  endMode();
14608  return true;
14609  }
14610  void TestSpecParser::startNewMode( Mode mode ) {
14611  m_mode = mode;
14612  }
14613  void TestSpecParser::endMode() {
14614  switch( m_mode ) {
14615  case Name:
14616  case QuotedName:
14617  return addNamePattern();
14618  case Tag:
14619  return addTagPattern();
14620  case EscapedName:
14621  revertBackToLastMode();
14622  return;
14623  case None:
14624  default:
14625  return startNewMode( None );
14626  }
14627  }
14628  void TestSpecParser::escape() {
14629  saveLastMode();
14630  m_mode = EscapedName;
14631  m_escapeChars.push_back(m_realPatternPos);
14632  }
14633  bool TestSpecParser::isControlChar( char c ) const {
14634  switch( m_mode ) {
14635  default:
14636  return false;
14637  case None:
14638  return c == '~';
14639  case Name:
14640  return c == '[';
14641  case EscapedName:
14642  return true;
14643  case QuotedName:
14644  return c == '"';
14645  case Tag:
14646  return c == '[' || c == ']';
14647  }
14648  }
14649 
14650  void TestSpecParser::addFilter() {
14651  if( !m_currentFilter.m_patterns.empty() ) {
14652  m_testSpec.m_filters.push_back( m_currentFilter );
14653  m_currentFilter = TestSpec::Filter();
14654  }
14655  }
14656 
14657  void TestSpecParser::saveLastMode() {
14658  lastMode = m_mode;
14659  }
14660 
14661  void TestSpecParser::revertBackToLastMode() {
14662  m_mode = lastMode;
14663  }
14664 
14665  bool TestSpecParser::separate() {
14666  if( (m_mode==QuotedName) || (m_mode==Tag) ){
14667  //invalid argument, signal failure to previous scope.
14668  m_mode = None;
14669  m_pos = m_arg.size();
14670  m_substring.clear();
14671  m_patternName.clear();
14672  m_realPatternPos = 0;
14673  return false;
14674  }
14675  endMode();
14676  addFilter();
14677  return true; //success
14678  }
14679 
14680  std::string TestSpecParser::preprocessPattern() {
14681  std::string token = m_patternName;
14682  for (std::size_t i = 0; i < m_escapeChars.size(); ++i)
14683  token = token.substr(0, m_escapeChars[i] - i) + token.substr(m_escapeChars[i] - i + 1);
14684  m_escapeChars.clear();
14685  if (startsWith(token, "exclude:")) {
14686  m_exclusion = true;
14687  token = token.substr(8);
14688  }
14689 
14690  m_patternName.clear();
14691  m_realPatternPos = 0;
14692 
14693  return token;
14694  }
14695 
14696  void TestSpecParser::addNamePattern() {
14697  auto token = preprocessPattern();
14698 
14699  if (!token.empty()) {
14700  TestSpec::PatternPtr pattern = std::make_shared<TestSpec::NamePattern>(token, m_substring);
14701  if (m_exclusion)
14702  pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern);
14703  m_currentFilter.m_patterns.push_back(pattern);
14704  }
14705  m_substring.clear();
14706  m_exclusion = false;
14707  m_mode = None;
14708  }
14709 
14710  void TestSpecParser::addTagPattern() {
14711  auto token = preprocessPattern();
14712 
14713  if (!token.empty()) {
14714  // If the tag pattern is the "hide and tag" shorthand (e.g. [.foo])
14715  // we have to create a separate hide tag and shorten the real one
14716  if (token.size() > 1 && token[0] == '.') {
14717  token.erase(token.begin());
14718  TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(".", m_substring);
14719  if (m_exclusion) {
14720  pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern);
14721  }
14722  m_currentFilter.m_patterns.push_back(pattern);
14723  }
14724 
14725  TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(token, m_substring);
14726 
14727  if (m_exclusion) {
14728  pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern);
14729  }
14730  m_currentFilter.m_patterns.push_back(pattern);
14731  }
14732  m_substring.clear();
14733  m_exclusion = false;
14734  m_mode = None;
14735  }
14736 
14737  TestSpec parseTestSpec( std::string const& arg ) {
14738  return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
14739  }
14740 
14741 } // namespace Catch
14742 // end catch_test_spec_parser.cpp
14743 // start catch_timer.cpp
14744 
14745 #include <chrono>
14746 
14747 static const uint64_t nanosecondsInSecond = 1000000000;
14748 
14749 namespace Catch {
14750 
14751  auto getCurrentNanosecondsSinceEpoch() -> uint64_t {
14752  return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
14753  }
14754 
14755  namespace {
14756  auto estimateClockResolution() -> uint64_t {
14757  uint64_t sum = 0;
14758  static const uint64_t iterations = 1000000;
14759 
14760  auto startTime = getCurrentNanosecondsSinceEpoch();
14761 
14762  for( std::size_t i = 0; i < iterations; ++i ) {
14763 
14764  uint64_t ticks;
14765  uint64_t baseTicks = getCurrentNanosecondsSinceEpoch();
14766  do {
14768  } while( ticks == baseTicks );
14769 
14770  auto delta = ticks - baseTicks;
14771  sum += delta;
14772 
14773  // If we have been calibrating for over 3 seconds -- the clock
14774  // is terrible and we should move on.
14775  // TBD: How to signal that the measured resolution is probably wrong?
14776  if (ticks > startTime + 3 * nanosecondsInSecond) {
14777  return sum / ( i + 1u );
14778  }
14779  }
14780 
14781  // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers
14782  // - and potentially do more iterations if there's a high variance.
14783  return sum/iterations;
14784  }
14785  }
14786  auto getEstimatedClockResolution() -> uint64_t {
14787  static auto s_resolution = estimateClockResolution();
14788  return s_resolution;
14789  }
14790 
14791  void Timer::start() {
14792  m_nanoseconds = getCurrentNanosecondsSinceEpoch();
14793  }
14794  auto Timer::getElapsedNanoseconds() const -> uint64_t {
14795  return getCurrentNanosecondsSinceEpoch() - m_nanoseconds;
14796  }
14797  auto Timer::getElapsedMicroseconds() const -> uint64_t {
14798  return getElapsedNanoseconds()/1000;
14799  }
14800  auto Timer::getElapsedMilliseconds() const -> unsigned int {
14801  return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
14802  }
14803  auto Timer::getElapsedSeconds() const -> double {
14804  return getElapsedMicroseconds()/1000000.0;
14805  }
14806 
14807 } // namespace Catch
14808 // end catch_timer.cpp
14809 // start catch_tostring.cpp
14810 
14811 #if defined(__clang__)
14812 # pragma clang diagnostic push
14813 # pragma clang diagnostic ignored "-Wexit-time-destructors"
14814 # pragma clang diagnostic ignored "-Wglobal-constructors"
14815 #endif
14816 
14817 // Enable specific decls locally
14818 #if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
14819 #define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
14820 #endif
14821 
14822 #include <cmath>
14823 #include <iomanip>
14824 
14825 namespace Catch {
14826 
14827 namespace Detail {
14828 
14829  const std::string unprintableString = "{?}";
14830 
14831  namespace {
14832  const int hexThreshold = 255;
14833 
14834  struct Endianness {
14835  enum Arch { Big, Little };
14836 
14837  static Arch which() {
14838  int one = 1;
14839  // If the lowest byte we read is non-zero, we can assume
14840  // that little endian format is used.
14841  auto value = *reinterpret_cast<char*>(&one);
14842  return value ? Little : Big;
14843  }
14844  };
14845  }
14846 
14847  std::string rawMemoryToString( const void *object, std::size_t size ) {
14848  // Reverse order for little endian architectures
14849  int i = 0, end = static_cast<int>( size ), inc = 1;
14850  if( Endianness::which() == Endianness::Little ) {
14851  i = end-1;
14852  end = inc = -1;
14853  }
14854 
14855  unsigned char const *bytes = static_cast<unsigned char const *>(object);
14857  rss << "0x" << std::setfill('0') << std::hex;
14858  for( ; i != end; i += inc )
14859  rss << std::setw(2) << static_cast<unsigned>(bytes[i]);
14860  return rss.str();
14861  }
14862 }
14863 
14864 template<typename T>
14865 std::string fpToString( T value, int precision ) {
14866  if (Catch::isnan(value)) {
14867  return "nan";
14868  }
14869 
14871  rss << std::setprecision( precision )
14872  << std::fixed
14873  << value;
14874  std::string d = rss.str();
14875  std::size_t i = d.find_last_not_of( '0' );
14876  if( i != std::string::npos && i != d.size()-1 ) {
14877  if( d[i] == '.' )
14878  i++;
14879  d = d.substr( 0, i+1 );
14880  }
14881  return d;
14882 }
14883 
14885 //
14886 // Out-of-line defs for full specialization of StringMaker
14887 //
14889 
14890 std::string StringMaker<std::string>::convert(const std::string& str) {
14891  if (!getCurrentContext().getConfig()->showInvisibles()) {
14892  return '"' + str + '"';
14893  }
14894 
14895  std::string s("\"");
14896  for (char c : str) {
14897  switch (c) {
14898  case '\n':
14899  s.append("\\n");
14900  break;
14901  case '\t':
14902  s.append("\\t");
14903  break;
14904  default:
14905  s.push_back(c);
14906  break;
14907  }
14908  }
14909  s.append("\"");
14910  return s;
14911 }
14912 
14913 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
14914 std::string StringMaker<std::string_view>::convert(std::string_view str) {
14915  return ::Catch::Detail::stringify(std::string{ str });
14916 }
14917 #endif
14918 
14919 std::string StringMaker<char const*>::convert(char const* str) {
14920  if (str) {
14921  return ::Catch::Detail::stringify(std::string{ str });
14922  } else {
14923  return{ "{null string}" };
14924  }
14925 }
14926 std::string StringMaker<char*>::convert(char* str) {
14927  if (str) {
14928  return ::Catch::Detail::stringify(std::string{ str });
14929  } else {
14930  return{ "{null string}" };
14931  }
14932 }
14933 
14934 #ifdef CATCH_CONFIG_WCHAR
14935 std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
14936  std::string s;
14937  s.reserve(wstr.size());
14938  for (auto c : wstr) {
14939  s += (c <= 0xff) ? static_cast<char>(c) : '?';
14940  }
14942 }
14943 
14944 # ifdef CATCH_CONFIG_CPP17_STRING_VIEW
14945 std::string StringMaker<std::wstring_view>::convert(std::wstring_view str) {
14946  return StringMaker<std::wstring>::convert(std::wstring(str));
14947 }
14948 # endif
14949 
14950 std::string StringMaker<wchar_t const*>::convert(wchar_t const * str) {
14951  if (str) {
14952  return ::Catch::Detail::stringify(std::wstring{ str });
14953  } else {
14954  return{ "{null string}" };
14955  }
14956 }
14957 std::string StringMaker<wchar_t *>::convert(wchar_t * str) {
14958  if (str) {
14959  return ::Catch::Detail::stringify(std::wstring{ str });
14960  } else {
14961  return{ "{null string}" };
14962  }
14963 }
14964 #endif
14965 
14966 #if defined(CATCH_CONFIG_CPP17_BYTE)
14967 #include <cstddef>
14968 std::string StringMaker<std::byte>::convert(std::byte value) {
14969  return ::Catch::Detail::stringify(std::to_integer<unsigned long long>(value));
14970 }
14971 #endif // defined(CATCH_CONFIG_CPP17_BYTE)
14972 
14973 std::string StringMaker<int>::convert(int value) {
14974  return ::Catch::Detail::stringify(static_cast<long long>(value));
14975 }
14976 std::string StringMaker<long>::convert(long value) {
14977  return ::Catch::Detail::stringify(static_cast<long long>(value));
14978 }
14979 std::string StringMaker<long long>::convert(long long value) {
14981  rss << value;
14982  if (value > Detail::hexThreshold) {
14983  rss << " (0x" << std::hex << value << ')';
14984  }
14985  return rss.str();
14986 }
14987 
14988 std::string StringMaker<unsigned int>::convert(unsigned int value) {
14989  return ::Catch::Detail::stringify(static_cast<unsigned long long>(value));
14990 }
14991 std::string StringMaker<unsigned long>::convert(unsigned long value) {
14992  return ::Catch::Detail::stringify(static_cast<unsigned long long>(value));
14993 }
14994 std::string StringMaker<unsigned long long>::convert(unsigned long long value) {
14996  rss << value;
14997  if (value > Detail::hexThreshold) {
14998  rss << " (0x" << std::hex << value << ')';
14999  }
15000  return rss.str();
15001 }
15002 
15003 std::string StringMaker<bool>::convert(bool b) {
15004  return b ? "true" : "false";
15005 }
15006 
15007 std::string StringMaker<signed char>::convert(signed char value) {
15008  if (value == '\r') {
15009  return "'\\r'";
15010  } else if (value == '\f') {
15011  return "'\\f'";
15012  } else if (value == '\n') {
15013  return "'\\n'";
15014  } else if (value == '\t') {
15015  return "'\\t'";
15016  } else if ('\0' <= value && value < ' ') {
15017  return ::Catch::Detail::stringify(static_cast<unsigned int>(value));
15018  } else {
15019  char chstr[] = "' '";
15020  chstr[1] = value;
15021  return chstr;
15022  }
15023 }
15024 std::string StringMaker<char>::convert(char c) {
15025  return ::Catch::Detail::stringify(static_cast<signed char>(c));
15026 }
15027 std::string StringMaker<unsigned char>::convert(unsigned char c) {
15028  return ::Catch::Detail::stringify(static_cast<char>(c));
15029 }
15030 
15031 std::string StringMaker<std::nullptr_t>::convert(std::nullptr_t) {
15032  return "nullptr";
15033 }
15034 
15036 
15037 std::string StringMaker<float>::convert(float value) {
15038  return fpToString(value, precision) + 'f';
15039 }
15040 
15042 
15043 std::string StringMaker<double>::convert(double value) {
15044  return fpToString(value, precision);
15045 }
15046 
15047 std::string ratio_string<std::atto>::symbol() { return "a"; }
15048 std::string ratio_string<std::femto>::symbol() { return "f"; }
15049 std::string ratio_string<std::pico>::symbol() { return "p"; }
15050 std::string ratio_string<std::nano>::symbol() { return "n"; }
15051 std::string ratio_string<std::micro>::symbol() { return "u"; }
15052 std::string ratio_string<std::milli>::symbol() { return "m"; }
15053 
15054 } // end namespace Catch
15055 
15056 #if defined(__clang__)
15057 # pragma clang diagnostic pop
15058 #endif
15059 
15060 // end catch_tostring.cpp
15061 // start catch_totals.cpp
15062 
15063 namespace Catch {
15064 
15065  Counts Counts::operator - ( Counts const& other ) const {
15066  Counts diff;
15067  diff.passed = passed - other.passed;
15068  diff.failed = failed - other.failed;
15069  diff.failedButOk = failedButOk - other.failedButOk;
15070  return diff;
15071  }
15072 
15073  Counts& Counts::operator += ( Counts const& other ) {
15074  passed += other.passed;
15075  failed += other.failed;
15076  failedButOk += other.failedButOk;
15077  return *this;
15078  }
15079 
15080  std::size_t Counts::total() const {
15081  return passed + failed + failedButOk;
15082  }
15083  bool Counts::allPassed() const {
15084  return failed == 0 && failedButOk == 0;
15085  }
15086  bool Counts::allOk() const {
15087  return failed == 0;
15088  }
15089 
15090  Totals Totals::operator - ( Totals const& other ) const {
15091  Totals diff;
15092  diff.assertions = assertions - other.assertions;
15093  diff.testCases = testCases - other.testCases;
15094  return diff;
15095  }
15096 
15097  Totals& Totals::operator += ( Totals const& other ) {
15098  assertions += other.assertions;
15099  testCases += other.testCases;
15100  return *this;
15101  }
15102 
15103  Totals Totals::delta( Totals const& prevTotals ) const {
15104  Totals diff = *this - prevTotals;
15105  if( diff.assertions.failed > 0 )
15106  ++diff.testCases.failed;
15107  else if( diff.assertions.failedButOk > 0 )
15108  ++diff.testCases.failedButOk;
15109  else
15110  ++diff.testCases.passed;
15111  return diff;
15112  }
15113 
15114 }
15115 // end catch_totals.cpp
15116 // start catch_uncaught_exceptions.cpp
15117 
15118 #include <exception>
15119 
15120 namespace Catch {
15121  bool uncaught_exceptions() {
15122 #if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
15123  return std::uncaught_exceptions() > 0;
15124 #else
15125  return std::uncaught_exception();
15126 #endif
15127  }
15128 } // end namespace Catch
15129 // end catch_uncaught_exceptions.cpp
15130 // start catch_version.cpp
15131 
15132 #include <ostream>
15133 
15134 namespace Catch {
15135 
15136  Version::Version
15137  ( unsigned int _majorVersion,
15138  unsigned int _minorVersion,
15139  unsigned int _patchNumber,
15140  char const * const _branchName,
15141  unsigned int _buildNumber )
15142  : majorVersion( _majorVersion ),
15143  minorVersion( _minorVersion ),
15144  patchNumber( _patchNumber ),
15145  branchName( _branchName ),
15146  buildNumber( _buildNumber )
15147  {}
15148 
15149  std::ostream& operator << ( std::ostream& os, Version const& version ) {
15150  os << version.majorVersion << '.'
15151  << version.minorVersion << '.'
15152  << version.patchNumber;
15153  // branchName is never null -> 0th char is \0 if it is empty
15154  if (version.branchName[0]) {
15155  os << '-' << version.branchName
15156  << '.' << version.buildNumber;
15157  }
15158  return os;
15159  }
15160 
15161  Version const& libraryVersion() {
15162  static Version version( 2, 12, 1, "", 0 );
15163  return version;
15164  }
15165 
15166 }
15167 // end catch_version.cpp
15168 // start catch_wildcard_pattern.cpp
15169 
15170 namespace Catch {
15171 
15172  WildcardPattern::WildcardPattern( std::string const& pattern,
15173  CaseSensitive::Choice caseSensitivity )
15174  : m_caseSensitivity( caseSensitivity ),
15175  m_pattern( normaliseString( pattern ) )
15176  {
15177  if( startsWith( m_pattern, '*' ) ) {
15178  m_pattern = m_pattern.substr( 1 );
15179  m_wildcard = WildcardAtStart;
15180  }
15181  if( endsWith( m_pattern, '*' ) ) {
15182  m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
15183  m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
15184  }
15185  }
15186 
15187  bool WildcardPattern::matches( std::string const& str ) const {
15188  switch( m_wildcard ) {
15189  case NoWildcard:
15190  return m_pattern == normaliseString( str );
15191  case WildcardAtStart:
15192  return endsWith( normaliseString( str ), m_pattern );
15193  case WildcardAtEnd:
15194  return startsWith( normaliseString( str ), m_pattern );
15195  case WildcardAtBothEnds:
15196  return contains( normaliseString( str ), m_pattern );
15197  default:
15198  CATCH_INTERNAL_ERROR( "Unknown enum" );
15199  }
15200  }
15201 
15202  std::string WildcardPattern::normaliseString( std::string const& str ) const {
15203  return trim( m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str );
15204  }
15205 }
15206 // end catch_wildcard_pattern.cpp
15207 // start catch_xmlwriter.cpp
15208 
15209 #include <iomanip>
15210 #include <type_traits>
15211 
15212 namespace Catch {
15213 
15214 namespace {
15215 
15216  size_t trailingBytes(unsigned char c) {
15217  if ((c & 0xE0) == 0xC0) {
15218  return 2;
15219  }
15220  if ((c & 0xF0) == 0xE0) {
15221  return 3;
15222  }
15223  if ((c & 0xF8) == 0xF0) {
15224  return 4;
15225  }
15226  CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
15227  }
15228 
15229  uint32_t headerValue(unsigned char c) {
15230  if ((c & 0xE0) == 0xC0) {
15231  return c & 0x1F;
15232  }
15233  if ((c & 0xF0) == 0xE0) {
15234  return c & 0x0F;
15235  }
15236  if ((c & 0xF8) == 0xF0) {
15237  return c & 0x07;
15238  }
15239  CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
15240  }
15241 
15242  void hexEscapeChar(std::ostream& os, unsigned char c) {
15243  std::ios_base::fmtflags f(os.flags());
15244  os << "\\x"
15245  << std::uppercase << std::hex << std::setfill('0') << std::setw(2)
15246  << static_cast<int>(c);
15247  os.flags(f);
15248  }
15249 
15250  bool shouldNewline(XmlFormatting fmt) {
15251  return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Newline));
15252  }
15253 
15254  bool shouldIndent(XmlFormatting fmt) {
15256  }
15257 
15258 } // anonymous namespace
15259 
15260  XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
15261  return static_cast<XmlFormatting>(
15264  );
15265  }
15266 
15267  XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
15268  return static_cast<XmlFormatting>(
15271  );
15272  }
15273 
15274  XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat )
15275  : m_str( str ),
15276  m_forWhat( forWhat )
15277  {}
15278 
15279  void XmlEncode::encodeTo( std::ostream& os ) const {
15280  // Apostrophe escaping not necessary if we always use " to write attributes
15281  // (see: http://www.w3.org/TR/xml/#syntax)
15282 
15283  for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) {
15284  unsigned char c = m_str[idx];
15285  switch (c) {
15286  case '<': os << "&lt;"; break;
15287  case '&': os << "&amp;"; break;
15288 
15289  case '>':
15290  // See: http://www.w3.org/TR/xml/#syntax
15291  if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']')
15292  os << "&gt;";
15293  else
15294  os << c;
15295  break;
15296 
15297  case '\"':
15298  if (m_forWhat == ForAttributes)
15299  os << "&quot;";
15300  else
15301  os << c;
15302  break;
15303 
15304  default:
15305  // Check for control characters and invalid utf-8
15306 
15307  // Escape control characters in standard ascii
15308  // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
15309  if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) {
15310  hexEscapeChar(os, c);
15311  break;
15312  }
15313 
15314  // Plain ASCII: Write it to stream
15315  if (c < 0x7F) {
15316  os << c;
15317  break;
15318  }
15319 
15320  // UTF-8 territory
15321  // Check if the encoding is valid and if it is not, hex escape bytes.
15322  // Important: We do not check the exact decoded values for validity, only the encoding format
15323  // First check that this bytes is a valid lead byte:
15324  // This means that it is not encoded as 1111 1XXX
15325  // Or as 10XX XXXX
15326  if (c < 0xC0 ||
15327  c >= 0xF8) {
15328  hexEscapeChar(os, c);
15329  break;
15330  }
15331 
15332  auto encBytes = trailingBytes(c);
15333  // Are there enough bytes left to avoid accessing out-of-bounds memory?
15334  if (idx + encBytes - 1 >= m_str.size()) {
15335  hexEscapeChar(os, c);
15336  break;
15337  }
15338  // The header is valid, check data
15339  // The next encBytes bytes must together be a valid utf-8
15340  // This means: bitpattern 10XX XXXX and the extracted value is sane (ish)
15341  bool valid = true;
15342  uint32_t value = headerValue(c);
15343  for (std::size_t n = 1; n < encBytes; ++n) {
15344  unsigned char nc = m_str[idx + n];
15345  valid &= ((nc & 0xC0) == 0x80);
15346  value = (value << 6) | (nc & 0x3F);
15347  }
15348 
15349  if (
15350  // Wrong bit pattern of following bytes
15351  (!valid) ||
15352  // Overlong encodings
15353  (value < 0x80) ||
15354  (0x80 <= value && value < 0x800 && encBytes > 2) ||
15355  (0x800 < value && value < 0x10000 && encBytes > 3) ||
15356  // Encoded value out of range
15357  (value >= 0x110000)
15358  ) {
15359  hexEscapeChar(os, c);
15360  break;
15361  }
15362 
15363  // If we got here, this is in fact a valid(ish) utf-8 sequence
15364  for (std::size_t n = 0; n < encBytes; ++n) {
15365  os << m_str[idx + n];
15366  }
15367  idx += encBytes - 1;
15368  break;
15369  }
15370  }
15371  }
15372 
15373  std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
15374  xmlEncode.encodeTo( os );
15375  return os;
15376  }
15377 
15378  XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer, XmlFormatting fmt )
15379  : m_writer( writer ),
15380  m_fmt(fmt)
15381  {}
15382 
15383  XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept
15384  : m_writer( other.m_writer ),
15385  m_fmt(other.m_fmt)
15386  {
15387  other.m_writer = nullptr;
15388  other.m_fmt = XmlFormatting::None;
15389  }
15390  XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept {
15391  if ( m_writer ) {
15392  m_writer->endElement();
15393  }
15394  m_writer = other.m_writer;
15395  other.m_writer = nullptr;
15396  m_fmt = other.m_fmt;
15397  other.m_fmt = XmlFormatting::None;
15398  return *this;
15399  }
15400 
15401  XmlWriter::ScopedElement::~ScopedElement() {
15402  if (m_writer) {
15403  m_writer->endElement(m_fmt);
15404  }
15405  }
15406 
15407  XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, XmlFormatting fmt ) {
15408  m_writer->writeText( text, fmt );
15409  return *this;
15410  }
15411 
15412  XmlWriter::XmlWriter( std::ostream& os ) : m_os( os )
15413  {
15414  writeDeclaration();
15415  }
15416 
15417  XmlWriter::~XmlWriter() {
15418  while (!m_tags.empty()) {
15419  endElement();
15420  }
15421  newlineIfNecessary();
15422  }
15423 
15424  XmlWriter& XmlWriter::startElement( std::string const& name, XmlFormatting fmt ) {
15425  ensureTagClosed();
15426  newlineIfNecessary();
15427  if (shouldIndent(fmt)) {
15428  m_os << m_indent;
15429  m_indent += " ";
15430  }
15431  m_os << '<' << name;
15432  m_tags.push_back( name );
15433  m_tagIsOpen = true;
15434  applyFormatting(fmt);
15435  return *this;
15436  }
15437 
15438  XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name, XmlFormatting fmt ) {
15439  ScopedElement scoped( this, fmt );
15440  startElement( name, fmt );
15441  return scoped;
15442  }
15443 
15444  XmlWriter& XmlWriter::endElement(XmlFormatting fmt) {
15445  m_indent = m_indent.substr(0, m_indent.size() - 2);
15446 
15447  if( m_tagIsOpen ) {
15448  m_os << "/>";
15449  m_tagIsOpen = false;
15450  } else {
15451  newlineIfNecessary();
15452  if (shouldIndent(fmt)) {
15453  m_os << m_indent;
15454  }
15455  m_os << "</" << m_tags.back() << ">";
15456  }
15457  m_os << std::flush;
15458  applyFormatting(fmt);
15459  m_tags.pop_back();
15460  return *this;
15461  }
15462 
15463  XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) {
15464  if( !name.empty() && !attribute.empty() )
15465  m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
15466  return *this;
15467  }
15468 
15469  XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) {
15470  m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
15471  return *this;
15472  }
15473 
15474  XmlWriter& XmlWriter::writeText( std::string const& text, XmlFormatting fmt) {
15475  if( !text.empty() ){
15476  bool tagWasOpen = m_tagIsOpen;
15477  ensureTagClosed();
15478  if (tagWasOpen && shouldIndent(fmt)) {
15479  m_os << m_indent;
15480  }
15481  m_os << XmlEncode( text );
15482  applyFormatting(fmt);
15483  }
15484  return *this;
15485  }
15486 
15487  XmlWriter& XmlWriter::writeComment( std::string const& text, XmlFormatting fmt) {
15488  ensureTagClosed();
15489  if (shouldIndent(fmt)) {
15490  m_os << m_indent;
15491  }
15492  m_os << "<!--" << text << "-->";
15493  applyFormatting(fmt);
15494  return *this;
15495  }
15496 
15497  void XmlWriter::writeStylesheetRef( std::string const& url ) {
15498  m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
15499  }
15500 
15501  XmlWriter& XmlWriter::writeBlankLine() {
15502  ensureTagClosed();
15503  m_os << '\n';
15504  return *this;
15505  }
15506 
15507  void XmlWriter::ensureTagClosed() {
15508  if( m_tagIsOpen ) {
15509  m_os << '>' << std::flush;
15510  newlineIfNecessary();
15511  m_tagIsOpen = false;
15512  }
15513  }
15514 
15515  void XmlWriter::applyFormatting(XmlFormatting fmt) {
15516  m_needsNewline = shouldNewline(fmt);
15517  }
15518 
15519  void XmlWriter::writeDeclaration() {
15520  m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
15521  }
15522 
15523  void XmlWriter::newlineIfNecessary() {
15524  if( m_needsNewline ) {
15525  m_os << std::endl;
15526  m_needsNewline = false;
15527  }
15528  }
15529 }
15530 // end catch_xmlwriter.cpp
15531 // start catch_reporter_bases.cpp
15532 
15533 #include <cstring>
15534 #include <cfloat>
15535 #include <cstdio>
15536 #include <cassert>
15537 #include <memory>
15538 
15539 namespace Catch {
15540  void prepareExpandedExpression(AssertionResult& result) {
15541  result.getExpandedExpression();
15542  }
15543 
15544  // Because formatting using c++ streams is stateful, drop down to C is required
15545  // Alternatively we could use stringstream, but its performance is... not good.
15546  std::string getFormattedDuration( double duration ) {
15547  // Max exponent + 1 is required to represent the whole part
15548  // + 1 for decimal point
15549  // + 3 for the 3 decimal places
15550  // + 1 for null terminator
15551  const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
15552  char buffer[maxDoubleSize];
15553 
15554  // Save previous errno, to prevent sprintf from overwriting it
15555  ErrnoGuard guard;
15556 #ifdef _MSC_VER
15557  sprintf_s(buffer, "%.3f", duration);
15558 #else
15559  std::sprintf(buffer, "%.3f", duration);
15560 #endif
15561  return std::string(buffer);
15562  }
15563 
15564  std::string serializeFilters( std::vector<std::string> const& container ) {
15565  ReusableStringStream oss;
15566  bool first = true;
15567  for (auto&& filter : container)
15568  {
15569  if (!first)
15570  oss << ' ';
15571  else
15572  first = false;
15573 
15574  oss << filter;
15575  }
15576  return oss.str();
15577  }
15578 
15579  TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config)
15580  :StreamingReporterBase(_config) {}
15581 
15582  std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() {
15583  return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High };
15584  }
15585 
15586  void TestEventListenerBase::assertionStarting(AssertionInfo const &) {}
15587 
15588  bool TestEventListenerBase::assertionEnded(AssertionStats const &) {
15589  return false;
15590  }
15591 
15592 } // end namespace Catch
15593 // end catch_reporter_bases.cpp
15594 // start catch_reporter_compact.cpp
15595 
15596 namespace {
15597 
15598 #ifdef CATCH_PLATFORM_MAC
15599  const char* failedString() { return "FAILED"; }
15600  const char* passedString() { return "PASSED"; }
15601 #else
15602  const char* failedString() { return "failed"; }
15603  const char* passedString() { return "passed"; }
15604 #endif
15605 
15606  // Colour::LightGrey
15607  Catch::Colour::Code dimColour() { return Catch::Colour::FileName; }
15608 
15609  std::string bothOrAll( std::size_t count ) {
15610  return count == 1 ? std::string() :
15611  count == 2 ? "both " : "all " ;
15612  }
15613 
15614 } // anon namespace
15615 
15616 namespace Catch {
15617 namespace {
15618 // Colour, message variants:
15619 // - white: No tests ran.
15620 // - red: Failed [both/all] N test cases, failed [both/all] M assertions.
15621 // - white: Passed [both/all] N test cases (no assertions).
15622 // - red: Failed N tests cases, failed M assertions.
15623 // - green: Passed [both/all] N tests cases with M assertions.
15624 void printTotals(std::ostream& out, const Totals& totals) {
15625  if (totals.testCases.total() == 0) {
15626  out << "No tests ran.";
15627  } else if (totals.testCases.failed == totals.testCases.total()) {
15628  Colour colour(Colour::ResultError);
15629  const std::string qualify_assertions_failed =
15630  totals.assertions.failed == totals.assertions.total() ?
15631  bothOrAll(totals.assertions.failed) : std::string();
15632  out <<
15633  "Failed " << bothOrAll(totals.testCases.failed)
15634  << pluralise(totals.testCases.failed, "test case") << ", "
15635  "failed " << qualify_assertions_failed <<
15636  pluralise(totals.assertions.failed, "assertion") << '.';
15637  } else if (totals.assertions.total() == 0) {
15638  out <<
15639  "Passed " << bothOrAll(totals.testCases.total())
15640  << pluralise(totals.testCases.total(), "test case")
15641  << " (no assertions).";
15642  } else if (totals.assertions.failed) {
15643  Colour colour(Colour::ResultError);
15644  out <<
15645  "Failed " << pluralise(totals.testCases.failed, "test case") << ", "
15646  "failed " << pluralise(totals.assertions.failed, "assertion") << '.';
15647  } else {
15648  Colour colour(Colour::ResultSuccess);
15649  out <<
15650  "Passed " << bothOrAll(totals.testCases.passed)
15651  << pluralise(totals.testCases.passed, "test case") <<
15652  " with " << pluralise(totals.assertions.passed, "assertion") << '.';
15653  }
15654 }
15655 
15656 // Implementation of CompactReporter formatting
15657 class AssertionPrinter {
15658 public:
15659  AssertionPrinter& operator= (AssertionPrinter const&) = delete;
15660  AssertionPrinter(AssertionPrinter const&) = delete;
15661  AssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages)
15662  : stream(_stream)
15663  , result(_stats.assertionResult)
15664  , messages(_stats.infoMessages)
15665  , itMessage(_stats.infoMessages.begin())
15666  , printInfoMessages(_printInfoMessages) {}
15667 
15668  void print() {
15669  printSourceInfo();
15670 
15671  itMessage = messages.begin();
15672 
15673  switch (result.getResultType()) {
15674  case ResultWas::Ok:
15675  printResultType(Colour::ResultSuccess, passedString());
15676  printOriginalExpression();
15677  printReconstructedExpression();
15678  if (!result.hasExpression())
15679  printRemainingMessages(Colour::None);
15680  else
15681  printRemainingMessages();
15682  break;
15683  case ResultWas::ExpressionFailed:
15684  if (result.isOk())
15685  printResultType(Colour::ResultSuccess, failedString() + std::string(" - but was ok"));
15686  else
15687  printResultType(Colour::Error, failedString());
15688  printOriginalExpression();
15689  printReconstructedExpression();
15690  printRemainingMessages();
15691  break;
15692  case ResultWas::ThrewException:
15693  printResultType(Colour::Error, failedString());
15694  printIssue("unexpected exception with message:");
15695  printMessage();
15696  printExpressionWas();
15697  printRemainingMessages();
15698  break;
15699  case ResultWas::FatalErrorCondition:
15700  printResultType(Colour::Error, failedString());
15701  printIssue("fatal error condition with message:");
15702  printMessage();
15703  printExpressionWas();
15704  printRemainingMessages();
15705  break;
15706  case ResultWas::DidntThrowException:
15707  printResultType(Colour::Error, failedString());
15708  printIssue("expected exception, got none");
15709  printExpressionWas();
15710  printRemainingMessages();
15711  break;
15712  case ResultWas::Info:
15713  printResultType(Colour::None, "info");
15714  printMessage();
15715  printRemainingMessages();
15716  break;
15717  case ResultWas::Warning:
15718  printResultType(Colour::None, "warning");
15719  printMessage();
15720  printRemainingMessages();
15721  break;
15722  case ResultWas::ExplicitFailure:
15723  printResultType(Colour::Error, failedString());
15724  printIssue("explicitly");
15725  printRemainingMessages(Colour::None);
15726  break;
15727  // These cases are here to prevent compiler warnings
15728  case ResultWas::Unknown:
15729  case ResultWas::FailureBit:
15730  case ResultWas::Exception:
15731  printResultType(Colour::Error, "** internal error **");
15732  break;
15733  }
15734  }
15735 
15736 private:
15737  void printSourceInfo() const {
15738  Colour colourGuard(Colour::FileName);
15739  stream << result.getSourceInfo() << ':';
15740  }
15741 
15742  void printResultType(Colour::Code colour, std::string const& passOrFail) const {
15743  if (!passOrFail.empty()) {
15744  {
15745  Colour colourGuard(colour);
15746  stream << ' ' << passOrFail;
15747  }
15748  stream << ':';
15749  }
15750  }
15751 
15752  void printIssue(std::string const& issue) const {
15753  stream << ' ' << issue;
15754  }
15755 
15756  void printExpressionWas() {
15757  if (result.hasExpression()) {
15758  stream << ';';
15759  {
15760  Colour colour(dimColour());
15761  stream << " expression was:";
15762  }
15763  printOriginalExpression();
15764  }
15765  }
15766 
15767  void printOriginalExpression() const {
15768  if (result.hasExpression()) {
15769  stream << ' ' << result.getExpression();
15770  }
15771  }
15772 
15773  void printReconstructedExpression() const {
15774  if (result.hasExpandedExpression()) {
15775  {
15776  Colour colour(dimColour());
15777  stream << " for: ";
15778  }
15779  stream << result.getExpandedExpression();
15780  }
15781  }
15782 
15783  void printMessage() {
15784  if (itMessage != messages.end()) {
15785  stream << " '" << itMessage->message << '\'';
15786  ++itMessage;
15787  }
15788  }
15789 
15790  void printRemainingMessages(Colour::Code colour = dimColour()) {
15791  if (itMessage == messages.end())
15792  return;
15793 
15794  const auto itEnd = messages.cend();
15795  const auto N = static_cast<std::size_t>(std::distance(itMessage, itEnd));
15796 
15797  {
15798  Colour colourGuard(colour);
15799  stream << " with " << pluralise(N, "message") << ':';
15800  }
15801 
15802  while (itMessage != itEnd) {
15803  // If this assertion is a warning ignore any INFO messages
15804  if (printInfoMessages || itMessage->type != ResultWas::Info) {
15805  printMessage();
15806  if (itMessage != itEnd) {
15807  Colour colourGuard(dimColour());
15808  stream << " and";
15809  }
15810  continue;
15811  }
15812  ++itMessage;
15813  }
15814  }
15815 
15816 private:
15817  std::ostream& stream;
15818  AssertionResult const& result;
15819  std::vector<MessageInfo> messages;
15820  std::vector<MessageInfo>::const_iterator itMessage;
15821  bool printInfoMessages;
15822 };
15823 
15824 } // anon namespace
15825 
15826  std::string CompactReporter::getDescription() {
15827  return "Reports test results on a single line, suitable for IDEs";
15828  }
15829 
15830  ReporterPreferences CompactReporter::getPreferences() const {
15831  return m_reporterPrefs;
15832  }
15833 
15834  void CompactReporter::noMatchingTestCases( std::string const& spec ) {
15835  stream << "No test cases matched '" << spec << '\'' << std::endl;
15836  }
15837 
15838  void CompactReporter::assertionStarting( AssertionInfo const& ) {}
15839 
15840  bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {
15841  AssertionResult const& result = _assertionStats.assertionResult;
15842 
15843  bool printInfoMessages = true;
15844 
15845  // Drop out if result was successful and we're not printing those
15846  if( !m_config->includeSuccessfulResults() && result.isOk() ) {
15847  if( result.getResultType() != ResultWas::Warning )
15848  return false;
15849  printInfoMessages = false;
15850  }
15851 
15852  AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
15853  printer.print();
15854 
15855  stream << std::endl;
15856  return true;
15857  }
15858 
15859  void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
15860  if (m_config->showDurations() == ShowDurations::Always) {
15861  stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
15862  }
15863  }
15864 
15865  void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) {
15866  printTotals( stream, _testRunStats.totals );
15867  stream << '\n' << std::endl;
15868  StreamingReporterBase::testRunEnded( _testRunStats );
15869  }
15870 
15871  CompactReporter::~CompactReporter() {}
15872 
15873  CATCH_REGISTER_REPORTER( "compact", CompactReporter )
15874 
15875 } // end namespace Catch
15876 // end catch_reporter_compact.cpp
15877 // start catch_reporter_console.cpp
15878 
15879 #include <cfloat>
15880 #include <cstdio>
15881 
15882 #if defined(_MSC_VER)
15883 #pragma warning(push)
15884 #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
15885  // Note that 4062 (not all labels are handled and default is missing) is enabled
15886 #endif
15887 
15888 #if defined(__clang__)
15889 # pragma clang diagnostic push
15890 // For simplicity, benchmarking-only helpers are always enabled
15891 # pragma clang diagnostic ignored "-Wunused-function"
15892 #endif
15893 
15894 namespace Catch {
15895 
15896 namespace {
15897 
15898 // Formatter impl for ConsoleReporter
15899 class ConsoleAssertionPrinter {
15900 public:
15901  ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete;
15902  ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete;
15903  ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages)
15904  : stream(_stream),
15905  stats(_stats),
15906  result(_stats.assertionResult),
15907  colour(Colour::None),
15908  message(result.getMessage()),
15909  messages(_stats.infoMessages),
15910  printInfoMessages(_printInfoMessages) {
15911  switch (result.getResultType()) {
15912  case ResultWas::Ok:
15913  colour = Colour::Success;
15914  passOrFail = "PASSED";
15915  //if( result.hasMessage() )
15916  if (_stats.infoMessages.size() == 1)
15917  messageLabel = "with message";
15918  if (_stats.infoMessages.size() > 1)
15919  messageLabel = "with messages";
15920  break;
15922  if (result.isOk()) {
15923  colour = Colour::Success;
15924  passOrFail = "FAILED - but was ok";
15925  } else {
15926  colour = Colour::Error;
15927  passOrFail = "FAILED";
15928  }
15929  if (_stats.infoMessages.size() == 1)
15930  messageLabel = "with message";
15931  if (_stats.infoMessages.size() > 1)
15932  messageLabel = "with messages";
15933  break;
15935  colour = Colour::Error;
15936  passOrFail = "FAILED";
15937  messageLabel = "due to unexpected exception with ";
15938  if (_stats.infoMessages.size() == 1)
15939  messageLabel += "message";
15940  if (_stats.infoMessages.size() > 1)
15941  messageLabel += "messages";
15942  break;
15944  colour = Colour::Error;
15945  passOrFail = "FAILED";
15946  messageLabel = "due to a fatal error condition";
15947  break;
15949  colour = Colour::Error;
15950  passOrFail = "FAILED";
15951  messageLabel = "because no exception was thrown where one was expected";
15952  break;
15953  case ResultWas::Info:
15954  messageLabel = "info";
15955  break;
15956  case ResultWas::Warning:
15957  messageLabel = "warning";
15958  break;
15960  passOrFail = "FAILED";
15961  colour = Colour::Error;
15962  if (_stats.infoMessages.size() == 1)
15963  messageLabel = "explicitly with message";
15964  if (_stats.infoMessages.size() > 1)
15965  messageLabel = "explicitly with messages";
15966  break;
15967  // These cases are here to prevent compiler warnings
15968  case ResultWas::Unknown:
15969  case ResultWas::FailureBit:
15970  case ResultWas::Exception:
15971  passOrFail = "** internal error **";
15972  colour = Colour::Error;
15973  break;
15974  }
15975  }
15976 
15977  void print() const {
15978  printSourceInfo();
15979  if (stats.totals.assertions.total() > 0) {
15980  printResultType();
15981  printOriginalExpression();
15982  printReconstructedExpression();
15983  } else {
15984  stream << '\n';
15985  }
15986  printMessage();
15987  }
15988 
15989 private:
15990  void printResultType() const {
15991  if (!passOrFail.empty()) {
15992  Colour colourGuard(colour);
15993  stream << passOrFail << ":\n";
15994  }
15995  }
15996  void printOriginalExpression() const {
15997  if (result.hasExpression()) {
15998  Colour colourGuard(Colour::OriginalExpression);
15999  stream << " ";
16000  stream << result.getExpressionInMacro();
16001  stream << '\n';
16002  }
16003  }
16004  void printReconstructedExpression() const {
16005  if (result.hasExpandedExpression()) {
16006  stream << "with expansion:\n";
16007  Colour colourGuard(Colour::ReconstructedExpression);
16008  stream << Column(result.getExpandedExpression()).indent(2) << '\n';
16009  }
16010  }
16011  void printMessage() const {
16012  if (!messageLabel.empty())
16013  stream << messageLabel << ':' << '\n';
16014  for (auto const& msg : messages) {
16015  // If this assertion is a warning ignore any INFO messages
16016  if (printInfoMessages || msg.type != ResultWas::Info)
16017  stream << Column(msg.message).indent(2) << '\n';
16018  }
16019  }
16020  void printSourceInfo() const {
16021  Colour colourGuard(Colour::FileName);
16022  stream << result.getSourceInfo() << ": ";
16023  }
16024 
16025  std::ostream& stream;
16026  AssertionStats const& stats;
16027  AssertionResult const& result;
16028  Colour::Code colour;
16029  std::string passOrFail;
16030  std::string messageLabel;
16031  std::string message;
16032  std::vector<MessageInfo> messages;
16033  bool printInfoMessages;
16034 };
16035 
16036 std::size_t makeRatio(std::size_t number, std::size_t total) {
16037  std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0;
16038  return (ratio == 0 && number > 0) ? 1 : ratio;
16039 }
16040 
16041 std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) {
16042  if (i > j && i > k)
16043  return i;
16044  else if (j > k)
16045  return j;
16046  else
16047  return k;
16048 }
16049 
16050 struct ColumnInfo {
16051  enum Justification { Left, Right };
16052  std::string name;
16053  int width;
16054  Justification justification;
16055 };
16056 struct ColumnBreak {};
16057 struct RowBreak {};
16058 
16059 class Duration {
16060  enum class Unit {
16061  Auto,
16062  Nanoseconds,
16063  Microseconds,
16064  Milliseconds,
16065  Seconds,
16066  Minutes
16067  };
16068  static const uint64_t s_nanosecondsInAMicrosecond = 1000;
16069  static const uint64_t s_nanosecondsInAMillisecond = 1000 * s_nanosecondsInAMicrosecond;
16070  static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond;
16071  static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond;
16072 
16073  double m_inNanoseconds;
16074  Unit m_units;
16075 
16076 public:
16077  explicit Duration(double inNanoseconds, Unit units = Unit::Auto)
16078  : m_inNanoseconds(inNanoseconds),
16079  m_units(units) {
16080  if (m_units == Unit::Auto) {
16081  if (m_inNanoseconds < s_nanosecondsInAMicrosecond)
16082  m_units = Unit::Nanoseconds;
16083  else if (m_inNanoseconds < s_nanosecondsInAMillisecond)
16084  m_units = Unit::Microseconds;
16085  else if (m_inNanoseconds < s_nanosecondsInASecond)
16086  m_units = Unit::Milliseconds;
16087  else if (m_inNanoseconds < s_nanosecondsInAMinute)
16088  m_units = Unit::Seconds;
16089  else
16090  m_units = Unit::Minutes;
16091  }
16092 
16093  }
16094 
16095  auto value() const -> double {
16096  switch (m_units) {
16097  case Unit::Microseconds:
16098  return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMicrosecond);
16099  case Unit::Milliseconds:
16100  return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMillisecond);
16101  case Unit::Seconds:
16102  return m_inNanoseconds / static_cast<double>(s_nanosecondsInASecond);
16103  case Unit::Minutes:
16104  return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute);
16105  default:
16106  return m_inNanoseconds;
16107  }
16108  }
16109  auto unitsAsString() const -> std::string {
16110  switch (m_units) {
16111  case Unit::Nanoseconds:
16112  return "ns";
16113  case Unit::Microseconds:
16114  return "us";
16115  case Unit::Milliseconds:
16116  return "ms";
16117  case Unit::Seconds:
16118  return "s";
16119  case Unit::Minutes:
16120  return "m";
16121  default:
16122  return "** internal error **";
16123  }
16124 
16125  }
16126  friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& {
16127  return os << duration.value() << ' ' << duration.unitsAsString();
16128  }
16129 };
16130 } // end anon namespace
16131 
16132 class TablePrinter {
16133  std::ostream& m_os;
16134  std::vector<ColumnInfo> m_columnInfos;
16135  std::ostringstream m_oss;
16136  int m_currentColumn = -1;
16137  bool m_isOpen = false;
16138 
16139 public:
16140  TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
16141  : m_os( os ),
16142  m_columnInfos( std::move( columnInfos ) ) {}
16143 
16144  auto columnInfos() const -> std::vector<ColumnInfo> const& {
16145  return m_columnInfos;
16146  }
16147 
16148  void open() {
16149  if (!m_isOpen) {
16150  m_isOpen = true;
16151  *this << RowBreak();
16152 
16153  Columns headerCols;
16154  Spacer spacer(2);
16155  for (auto const& info : m_columnInfos) {
16156  headerCols += Column(info.name).width(static_cast<std::size_t>(info.width - 2));
16157  headerCols += spacer;
16158  }
16159  m_os << headerCols << '\n';
16160 
16161  m_os << Catch::getLineOfChars<'-'>() << '\n';
16162  }
16163  }
16164  void close() {
16165  if (m_isOpen) {
16166  *this << RowBreak();
16167  m_os << std::endl;
16168  m_isOpen = false;
16169  }
16170  }
16171 
16172  template<typename T>
16173  friend TablePrinter& operator << (TablePrinter& tp, T const& value) {
16174  tp.m_oss << value;
16175  return tp;
16176  }
16177 
16178  friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) {
16179  auto colStr = tp.m_oss.str();
16180  const auto strSize = colStr.size();
16181  tp.m_oss.str("");
16182  tp.open();
16183  if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) {
16184  tp.m_currentColumn = -1;
16185  tp.m_os << '\n';
16186  }
16187  tp.m_currentColumn++;
16188 
16189  auto colInfo = tp.m_columnInfos[tp.m_currentColumn];
16190  auto padding = (strSize + 1 < static_cast<std::size_t>(colInfo.width))
16191  ? std::string(colInfo.width - (strSize + 1), ' ')
16192  : std::string();
16193  if (colInfo.justification == ColumnInfo::Left)
16194  tp.m_os << colStr << padding << ' ';
16195  else
16196  tp.m_os << padding << colStr << ' ';
16197  return tp;
16198  }
16199 
16200  friend TablePrinter& operator << (TablePrinter& tp, RowBreak) {
16201  if (tp.m_currentColumn > 0) {
16202  tp.m_os << '\n';
16203  tp.m_currentColumn = -1;
16204  }
16205  return tp;
16206  }
16207 };
16208 
16209 ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
16210  : StreamingReporterBase(config),
16211  m_tablePrinter(new TablePrinter(config.stream(),
16212  [&config]() -> std::vector<ColumnInfo> {
16213  if (config.fullConfig()->benchmarkNoAnalysis())
16214  {
16215  return{
16216  { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left },
16217  { " samples", 14, ColumnInfo::Right },
16218  { " iterations", 14, ColumnInfo::Right },
16219  { " mean", 14, ColumnInfo::Right }
16220  };
16221  }
16222  else
16223  {
16224  return{
16225  { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left },
16226  { "samples mean std dev", 14, ColumnInfo::Right },
16227  { "iterations low mean low std dev", 14, ColumnInfo::Right },
16228  { "estimated high mean high std dev", 14, ColumnInfo::Right }
16229  };
16230  }
16231  }())) {}
16232 ConsoleReporter::~ConsoleReporter() = default;
16233 
16234 std::string ConsoleReporter::getDescription() {
16235  return "Reports test results as plain lines of text";
16236 }
16237 
16238 void ConsoleReporter::noMatchingTestCases(std::string const& spec) {
16239  stream << "No test cases matched '" << spec << '\'' << std::endl;
16240 }
16241 
16242 void ConsoleReporter::reportInvalidArguments(std::string const&arg){
16243  stream << "Invalid Filter: " << arg << std::endl;
16244 }
16245 
16246 void ConsoleReporter::assertionStarting(AssertionInfo const&) {}
16247 
16248 bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) {
16249  AssertionResult const& result = _assertionStats.assertionResult;
16250 
16251  bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
16252 
16253  // Drop out if result was successful but we're not printing them.
16254  if (!includeResults && result.getResultType() != ResultWas::Warning)
16255  return false;
16256 
16257  lazyPrint();
16258 
16259  ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);
16260  printer.print();
16261  stream << std::endl;
16262  return true;
16263 }
16264 
16265 void ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) {
16266  m_tablePrinter->close();
16267  m_headerPrinted = false;
16268  StreamingReporterBase::sectionStarting(_sectionInfo);
16269 }
16270 void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
16271  m_tablePrinter->close();
16272  if (_sectionStats.missingAssertions) {
16273  lazyPrint();
16274  Colour colour(Colour::ResultError);
16275  if (m_sectionStack.size() > 1)
16276  stream << "\nNo assertions in section";
16277  else
16278  stream << "\nNo assertions in test case";
16279  stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
16280  }
16281  if (m_config->showDurations() == ShowDurations::Always) {
16282  stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
16283  }
16284  if (m_headerPrinted) {
16285  m_headerPrinted = false;
16286  }
16287  StreamingReporterBase::sectionEnded(_sectionStats);
16288 }
16289 
16290 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
16291 void ConsoleReporter::benchmarkPreparing(std::string const& name) {
16292  lazyPrintWithoutClosingBenchmarkTable();
16293 
16294  auto nameCol = Column(name).width(static_cast<std::size_t>(m_tablePrinter->columnInfos()[0].width - 2));
16295 
16296  bool firstLine = true;
16297  for (auto line : nameCol) {
16298  if (!firstLine)
16299  (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak();
16300  else
16301  firstLine = false;
16302 
16303  (*m_tablePrinter) << line << ColumnBreak();
16304  }
16305 }
16306 
16307 void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) {
16308  (*m_tablePrinter) << info.samples << ColumnBreak()
16309  << info.iterations << ColumnBreak();
16310  if (!m_config->benchmarkNoAnalysis())
16311  (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak();
16312 }
16313 void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) {
16314  if (m_config->benchmarkNoAnalysis())
16315  {
16316  (*m_tablePrinter) << Duration(stats.mean.point.count()) << ColumnBreak();
16317  }
16318  else
16319  {
16320  (*m_tablePrinter) << ColumnBreak()
16321  << Duration(stats.mean.point.count()) << ColumnBreak()
16322  << Duration(stats.mean.lower_bound.count()) << ColumnBreak()
16323  << Duration(stats.mean.upper_bound.count()) << ColumnBreak() << ColumnBreak()
16324  << Duration(stats.standardDeviation.point.count()) << ColumnBreak()
16325  << Duration(stats.standardDeviation.lower_bound.count()) << ColumnBreak()
16326  << Duration(stats.standardDeviation.upper_bound.count()) << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak();
16327  }
16328 }
16329 
16330 void ConsoleReporter::benchmarkFailed(std::string const& error) {
16331  Colour colour(Colour::Red);
16332  (*m_tablePrinter)
16333  << "Benchmark failed (" << error << ')'
16334  << ColumnBreak() << RowBreak();
16335 }
16336 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
16337 
16338 void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) {
16339  m_tablePrinter->close();
16340  StreamingReporterBase::testCaseEnded(_testCaseStats);
16341  m_headerPrinted = false;
16342 }
16343 void ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) {
16344  if (currentGroupInfo.used) {
16345  printSummaryDivider();
16346  stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
16347  printTotals(_testGroupStats.totals);
16348  stream << '\n' << std::endl;
16349  }
16350  StreamingReporterBase::testGroupEnded(_testGroupStats);
16351 }
16352 void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
16353  printTotalsDivider(_testRunStats.totals);
16354  printTotals(_testRunStats.totals);
16355  stream << std::endl;
16356  StreamingReporterBase::testRunEnded(_testRunStats);
16357 }
16358 void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
16359  StreamingReporterBase::testRunStarting(_testInfo);
16360  printTestFilters();
16361 }
16362 
16363 void ConsoleReporter::lazyPrint() {
16364 
16365  m_tablePrinter->close();
16366  lazyPrintWithoutClosingBenchmarkTable();
16367 }
16368 
16369 void ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() {
16370 
16371  if (!currentTestRunInfo.used)
16372  lazyPrintRunInfo();
16373  if (!currentGroupInfo.used)
16374  lazyPrintGroupInfo();
16375 
16376  if (!m_headerPrinted) {
16377  printTestCaseAndSectionHeader();
16378  m_headerPrinted = true;
16379  }
16380 }
16381 void ConsoleReporter::lazyPrintRunInfo() {
16382  stream << '\n' << getLineOfChars<'~'>() << '\n';
16383  Colour colour(Colour::SecondaryText);
16384  stream << currentTestRunInfo->name
16385  << " is a Catch v" << libraryVersion() << " host application.\n"
16386  << "Run with -? for options\n\n";
16387 
16388  if (m_config->rngSeed() != 0)
16389  stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n";
16390 
16391  currentTestRunInfo.used = true;
16392 }
16393 void ConsoleReporter::lazyPrintGroupInfo() {
16394  if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) {
16395  printClosedHeader("Group: " + currentGroupInfo->name);
16396  currentGroupInfo.used = true;
16397  }
16398 }
16399 void ConsoleReporter::printTestCaseAndSectionHeader() {
16400  assert(!m_sectionStack.empty());
16401  printOpenHeader(currentTestCaseInfo->name);
16402 
16403  if (m_sectionStack.size() > 1) {
16404  Colour colourGuard(Colour::Headers);
16405 
16406  auto
16407  it = m_sectionStack.begin() + 1, // Skip first section (test case)
16408  itEnd = m_sectionStack.end();
16409  for (; it != itEnd; ++it)
16410  printHeaderString(it->name, 2);
16411  }
16412 
16413  SourceLineInfo lineInfo = m_sectionStack.back().lineInfo;
16414 
16415  stream << getLineOfChars<'-'>() << '\n';
16416  Colour colourGuard(Colour::FileName);
16417  stream << lineInfo << '\n';
16418  stream << getLineOfChars<'.'>() << '\n' << std::endl;
16419 }
16420 
16421 void ConsoleReporter::printClosedHeader(std::string const& _name) {
16422  printOpenHeader(_name);
16423  stream << getLineOfChars<'.'>() << '\n';
16424 }
16425 void ConsoleReporter::printOpenHeader(std::string const& _name) {
16426  stream << getLineOfChars<'-'>() << '\n';
16427  {
16428  Colour colourGuard(Colour::Headers);
16429  printHeaderString(_name);
16430  }
16431 }
16432 
16433 // if string has a : in first line will set indent to follow it on
16434 // subsequent lines
16435 void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t indent) {
16436  std::size_t i = _string.find(": ");
16437  if (i != std::string::npos)
16438  i += 2;
16439  else
16440  i = 0;
16441  stream << Column(_string).indent(indent + i).initialIndent(indent) << '\n';
16442 }
16443 
16444 struct SummaryColumn {
16445 
16446  SummaryColumn( std::string _label, Colour::Code _colour )
16447  : label( std::move( _label ) ),
16448  colour( _colour ) {}
16449  SummaryColumn addRow( std::size_t count ) {
16451  rss << count;
16452  std::string row = rss.str();
16453  for (auto& oldRow : rows) {
16454  while (oldRow.size() < row.size())
16455  oldRow = ' ' + oldRow;
16456  while (oldRow.size() > row.size())
16457  row = ' ' + row;
16458  }
16459  rows.push_back(row);
16460  return *this;
16461  }
16462 
16463  std::string label;
16464  Colour::Code colour;
16465  std::vector<std::string> rows;
16466 
16467 };
16468 
16469 void ConsoleReporter::printTotals( Totals const& totals ) {
16470  if (totals.testCases.total() == 0) {
16471  stream << Colour(Colour::Warning) << "No tests ran\n";
16472  } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) {
16473  stream << Colour(Colour::ResultSuccess) << "All tests passed";
16474  stream << " ("
16475  << pluralise(totals.assertions.passed, "assertion") << " in "
16476  << pluralise(totals.testCases.passed, "test case") << ')'
16477  << '\n';
16478  } else {
16479 
16480  std::vector<SummaryColumn> columns;
16481  columns.push_back(SummaryColumn("", Colour::None)
16482  .addRow(totals.testCases.total())
16483  .addRow(totals.assertions.total()));
16484  columns.push_back(SummaryColumn("passed", Colour::Success)
16485  .addRow(totals.testCases.passed)
16486  .addRow(totals.assertions.passed));
16487  columns.push_back(SummaryColumn("failed", Colour::ResultError)
16488  .addRow(totals.testCases.failed)
16489  .addRow(totals.assertions.failed));
16490  columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure)
16491  .addRow(totals.testCases.failedButOk)
16492  .addRow(totals.assertions.failedButOk));
16493 
16494  printSummaryRow("test cases", columns, 0);
16495  printSummaryRow("assertions", columns, 1);
16496  }
16497 }
16498 void ConsoleReporter::printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row) {
16499  for (auto col : cols) {
16500  std::string value = col.rows[row];
16501  if (col.label.empty()) {
16502  stream << label << ": ";
16503  if (value != "0")
16504  stream << value;
16505  else
16506  stream << Colour(Colour::Warning) << "- none -";
16507  } else if (value != "0") {
16508  stream << Colour(Colour::LightGrey) << " | ";
16509  stream << Colour(col.colour)
16510  << value << ' ' << col.label;
16511  }
16512  }
16513  stream << '\n';
16514 }
16515 
16516 void ConsoleReporter::printTotalsDivider(Totals const& totals) {
16517  if (totals.testCases.total() > 0) {
16518  std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total());
16519  std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total());
16520  std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total());
16521  while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1)
16522  findMax(failedRatio, failedButOkRatio, passedRatio)++;
16523  while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1)
16524  findMax(failedRatio, failedButOkRatio, passedRatio)--;
16525 
16526  stream << Colour(Colour::Error) << std::string(failedRatio, '=');
16527  stream << Colour(Colour::ResultExpectedFailure) << std::string(failedButOkRatio, '=');
16528  if (totals.testCases.allPassed())
16529  stream << Colour(Colour::ResultSuccess) << std::string(passedRatio, '=');
16530  else
16531  stream << Colour(Colour::Success) << std::string(passedRatio, '=');
16532  } else {
16533  stream << Colour(Colour::Warning) << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '=');
16534  }
16535  stream << '\n';
16536 }
16537 void ConsoleReporter::printSummaryDivider() {
16538  stream << getLineOfChars<'-'>() << '\n';
16539 }
16540 
16541 void ConsoleReporter::printTestFilters() {
16542  if (m_config->testSpec().hasFilters()) {
16543  Colour guard(Colour::BrightYellow);
16544  stream << "Filters: " << serializeFilters(m_config->getTestsOrTags()) << '\n';
16545  }
16546 }
16547 
16548 CATCH_REGISTER_REPORTER("console", ConsoleReporter)
16549 
16550 } // end namespace Catch
16551 
16552 #if defined(_MSC_VER)
16553 #pragma warning(pop)
16554 #endif
16555 
16556 #if defined(__clang__)
16557 # pragma clang diagnostic pop
16558 #endif
16559 // end catch_reporter_console.cpp
16560 // start catch_reporter_junit.cpp
16561 
16562 #include <cassert>
16563 #include <sstream>
16564 #include <ctime>
16565 #include <algorithm>
16566 
16567 namespace Catch {
16568 
16569  namespace {
16570  std::string getCurrentTimestamp() {
16571  // Beware, this is not reentrant because of backward compatibility issues
16572  // Also, UTC only, again because of backward compatibility (%z is C++11)
16573  time_t rawtime;
16574  std::time(&rawtime);
16575  auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
16576 
16577 #ifdef _MSC_VER
16578  std::tm timeInfo = {};
16579  gmtime_s(&timeInfo, &rawtime);
16580 #else
16581  std::tm* timeInfo;
16582  timeInfo = std::gmtime(&rawtime);
16583 #endif
16584 
16585  char timeStamp[timeStampSize];
16586  const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
16587 
16588 #ifdef _MSC_VER
16589  std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
16590 #else
16591  std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
16592 #endif
16593  return std::string(timeStamp);
16594  }
16595 
16596  std::string fileNameTag(const std::vector<std::string> &tags) {
16597  auto it = std::find_if(begin(tags),
16598  end(tags),
16599  [] (std::string const& tag) {return tag.front() == '#'; });
16600  if (it != tags.end())
16601  return it->substr(1);
16602  return std::string();
16603  }
16604  } // anonymous namespace
16605 
16606  JunitReporter::JunitReporter( ReporterConfig const& _config )
16607  : CumulativeReporterBase( _config ),
16608  xml( _config.stream() )
16609  {
16610  m_reporterPrefs.shouldRedirectStdOut = true;
16611  m_reporterPrefs.shouldReportAllAssertions = true;
16612  }
16613 
16614  JunitReporter::~JunitReporter() {}
16615 
16616  std::string JunitReporter::getDescription() {
16617  return "Reports test results in an XML format that looks like Ant's junitreport target";
16618  }
16619 
16620  void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {}
16621 
16622  void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) {
16623  CumulativeReporterBase::testRunStarting( runInfo );
16624  xml.startElement( "testsuites" );
16625  }
16626 
16627  void JunitReporter::testGroupStarting( GroupInfo const& groupInfo ) {
16628  suiteTimer.start();
16629  stdOutForSuite.clear();
16630  stdErrForSuite.clear();
16631  unexpectedExceptions = 0;
16632  CumulativeReporterBase::testGroupStarting( groupInfo );
16633  }
16634 
16635  void JunitReporter::testCaseStarting( TestCaseInfo const& testCaseInfo ) {
16636  m_okToFail = testCaseInfo.okToFail();
16637  }
16638 
16639  bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) {
16640  if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
16641  unexpectedExceptions++;
16642  return CumulativeReporterBase::assertionEnded( assertionStats );
16643  }
16644 
16645  void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
16646  stdOutForSuite += testCaseStats.stdOut;
16647  stdErrForSuite += testCaseStats.stdErr;
16648  CumulativeReporterBase::testCaseEnded( testCaseStats );
16649  }
16650 
16651  void JunitReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {
16652  double suiteTime = suiteTimer.getElapsedSeconds();
16653  CumulativeReporterBase::testGroupEnded( testGroupStats );
16654  writeGroup( *m_testGroups.back(), suiteTime );
16655  }
16656 
16657  void JunitReporter::testRunEndedCumulative() {
16658  xml.endElement();
16659  }
16660 
16661  void JunitReporter::writeGroup( TestGroupNode const& groupNode, double suiteTime ) {
16662  XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
16663 
16664  TestGroupStats const& stats = groupNode.value;
16665  xml.writeAttribute( "name", stats.groupInfo.name );
16666  xml.writeAttribute( "errors", unexpectedExceptions );
16667  xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions );
16668  xml.writeAttribute( "tests", stats.totals.assertions.total() );
16669  xml.writeAttribute( "hostname", "tbd" ); // !TBD
16670  if( m_config->showDurations() == ShowDurations::Never )
16671  xml.writeAttribute( "time", "" );
16672  else
16673  xml.writeAttribute( "time", suiteTime );
16674  xml.writeAttribute( "timestamp", getCurrentTimestamp() );
16675 
16676  // Write properties if there are any
16677  if (m_config->hasTestFilters() || m_config->rngSeed() != 0) {
16678  auto properties = xml.scopedElement("properties");
16679  if (m_config->hasTestFilters()) {
16680  xml.scopedElement("property")
16681  .writeAttribute("name", "filters")
16682  .writeAttribute("value", serializeFilters(m_config->getTestsOrTags()));
16683  }
16684  if (m_config->rngSeed() != 0) {
16685  xml.scopedElement("property")
16686  .writeAttribute("name", "random-seed")
16687  .writeAttribute("value", m_config->rngSeed());
16688  }
16689  }
16690 
16691  // Write test cases
16692  for( auto const& child : groupNode.children )
16693  writeTestCase( *child );
16694 
16695  xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), XmlFormatting::Newline );
16696  xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), XmlFormatting::Newline );
16697  }
16698 
16699  void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) {
16700  TestCaseStats const& stats = testCaseNode.value;
16701 
16702  // All test cases have exactly one section - which represents the
16703  // test case itself. That section may have 0-n nested sections
16704  assert( testCaseNode.children.size() == 1 );
16705  SectionNode const& rootSection = *testCaseNode.children.front();
16706 
16707  std::string className = stats.testInfo.className;
16708 
16709  if( className.empty() ) {
16710  className = fileNameTag(stats.testInfo.tags);
16711  if ( className.empty() )
16712  className = "global";
16713  }
16714 
16715  if ( !m_config->name().empty() )
16716  className = m_config->name() + "." + className;
16717 
16718  writeSection( className, "", rootSection );
16719  }
16720 
16721  void JunitReporter::writeSection( std::string const& className,
16722  std::string const& rootName,
16723  SectionNode const& sectionNode ) {
16724  std::string name = trim( sectionNode.stats.sectionInfo.name );
16725  if( !rootName.empty() )
16726  name = rootName + '/' + name;
16727 
16728  if( !sectionNode.assertions.empty() ||
16729  !sectionNode.stdOut.empty() ||
16730  !sectionNode.stdErr.empty() ) {
16731  XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
16732  if( className.empty() ) {
16733  xml.writeAttribute( "classname", name );
16734  xml.writeAttribute( "name", "root" );
16735  }
16736  else {
16737  xml.writeAttribute( "classname", className );
16738  xml.writeAttribute( "name", name );
16739  }
16740  xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );
16741 
16742  writeAssertions( sectionNode );
16743 
16744  if( !sectionNode.stdOut.empty() )
16745  xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), XmlFormatting::Newline );
16746  if( !sectionNode.stdErr.empty() )
16747  xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), XmlFormatting::Newline );
16748  }
16749  for( auto const& childNode : sectionNode.childSections )
16750  if( className.empty() )
16751  writeSection( name, "", *childNode );
16752  else
16753  writeSection( className, name, *childNode );
16754  }
16755 
16756  void JunitReporter::writeAssertions( SectionNode const& sectionNode ) {
16757  for( auto const& assertion : sectionNode.assertions )
16758  writeAssertion( assertion );
16759  }
16760 
16761  void JunitReporter::writeAssertion( AssertionStats const& stats ) {
16762  AssertionResult const& result = stats.assertionResult;
16763  if( !result.isOk() ) {
16764  std::string elementName;
16765  switch( result.getResultType() ) {
16768  elementName = "error";
16769  break;
16773  elementName = "failure";
16774  break;
16775 
16776  // We should never see these here:
16777  case ResultWas::Info:
16778  case ResultWas::Warning:
16779  case ResultWas::Ok:
16780  case ResultWas::Unknown:
16781  case ResultWas::FailureBit:
16782  case ResultWas::Exception:
16783  elementName = "internalError";
16784  break;
16785  }
16786 
16787  XmlWriter::ScopedElement e = xml.scopedElement( elementName );
16788 
16789  xml.writeAttribute( "message", result.getExpression() );
16790  xml.writeAttribute( "type", result.getTestMacroName() );
16791 
16793  if (stats.totals.assertions.total() > 0) {
16794  rss << "FAILED" << ":\n";
16795  if (result.hasExpression()) {
16796  rss << " ";
16797  rss << result.getExpressionInMacro();
16798  rss << '\n';
16799  }
16800  if (result.hasExpandedExpression()) {
16801  rss << "with expansion:\n";
16802  rss << Column(result.getExpandedExpression()).indent(2) << '\n';
16803  }
16804  } else {
16805  rss << '\n';
16806  }
16807 
16808  if( !result.getMessage().empty() )
16809  rss << result.getMessage() << '\n';
16810  for( auto const& msg : stats.infoMessages )
16811  if( msg.type == ResultWas::Info )
16812  rss << msg.message << '\n';
16813 
16814  rss << "at " << result.getSourceInfo();
16815  xml.writeText( rss.str(), XmlFormatting::Newline );
16816  }
16817  }
16818 
16819  CATCH_REGISTER_REPORTER( "junit", JunitReporter )
16820 
16821 } // end namespace Catch
16822 // end catch_reporter_junit.cpp
16823 // start catch_reporter_listening.cpp
16824 
16825 #include <cassert>
16826 
16827 namespace Catch {
16828 
16829  ListeningReporter::ListeningReporter() {
16830  // We will assume that listeners will always want all assertions
16831  m_preferences.shouldReportAllAssertions = true;
16832  }
16833 
16834  void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) {
16835  m_listeners.push_back( std::move( listener ) );
16836  }
16837 
16838  void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) {
16839  assert(!m_reporter && "Listening reporter can wrap only 1 real reporter");
16840  m_reporter = std::move( reporter );
16841  m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;
16842  }
16843 
16844  ReporterPreferences ListeningReporter::getPreferences() const {
16845  return m_preferences;
16846  }
16847 
16848  std::set<Verbosity> ListeningReporter::getSupportedVerbosities() {
16849  return std::set<Verbosity>{ };
16850  }
16851 
16852  void ListeningReporter::noMatchingTestCases( std::string const& spec ) {
16853  for ( auto const& listener : m_listeners ) {
16854  listener->noMatchingTestCases( spec );
16855  }
16856  m_reporter->noMatchingTestCases( spec );
16857  }
16858 
16859  void ListeningReporter::reportInvalidArguments(std::string const&arg){
16860  for ( auto const& listener : m_listeners ) {
16861  listener->reportInvalidArguments( arg );
16862  }
16863  m_reporter->reportInvalidArguments( arg );
16864  }
16865 
16866 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
16867  void ListeningReporter::benchmarkPreparing( std::string const& name ) {
16868  for (auto const& listener : m_listeners) {
16869  listener->benchmarkPreparing(name);
16870  }
16871  m_reporter->benchmarkPreparing(name);
16872  }
16873  void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) {
16874  for ( auto const& listener : m_listeners ) {
16875  listener->benchmarkStarting( benchmarkInfo );
16876  }
16877  m_reporter->benchmarkStarting( benchmarkInfo );
16878  }
16879  void ListeningReporter::benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) {
16880  for ( auto const& listener : m_listeners ) {
16881  listener->benchmarkEnded( benchmarkStats );
16882  }
16883  m_reporter->benchmarkEnded( benchmarkStats );
16884  }
16885 
16886  void ListeningReporter::benchmarkFailed( std::string const& error ) {
16887  for (auto const& listener : m_listeners) {
16888  listener->benchmarkFailed(error);
16889  }
16890  m_reporter->benchmarkFailed(error);
16891  }
16892 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
16893 
16894  void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) {
16895  for ( auto const& listener : m_listeners ) {
16896  listener->testRunStarting( testRunInfo );
16897  }
16898  m_reporter->testRunStarting( testRunInfo );
16899  }
16900 
16901  void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) {
16902  for ( auto const& listener : m_listeners ) {
16903  listener->testGroupStarting( groupInfo );
16904  }
16905  m_reporter->testGroupStarting( groupInfo );
16906  }
16907 
16908  void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
16909  for ( auto const& listener : m_listeners ) {
16910  listener->testCaseStarting( testInfo );
16911  }
16912  m_reporter->testCaseStarting( testInfo );
16913  }
16914 
16915  void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) {
16916  for ( auto const& listener : m_listeners ) {
16917  listener->sectionStarting( sectionInfo );
16918  }
16919  m_reporter->sectionStarting( sectionInfo );
16920  }
16921 
16922  void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) {
16923  for ( auto const& listener : m_listeners ) {
16924  listener->assertionStarting( assertionInfo );
16925  }
16926  m_reporter->assertionStarting( assertionInfo );
16927  }
16928 
16929  // The return value indicates if the messages buffer should be cleared:
16930  bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {
16931  for( auto const& listener : m_listeners ) {
16932  static_cast<void>( listener->assertionEnded( assertionStats ) );
16933  }
16934  return m_reporter->assertionEnded( assertionStats );
16935  }
16936 
16937  void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) {
16938  for ( auto const& listener : m_listeners ) {
16939  listener->sectionEnded( sectionStats );
16940  }
16941  m_reporter->sectionEnded( sectionStats );
16942  }
16943 
16944  void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
16945  for ( auto const& listener : m_listeners ) {
16946  listener->testCaseEnded( testCaseStats );
16947  }
16948  m_reporter->testCaseEnded( testCaseStats );
16949  }
16950 
16951  void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {
16952  for ( auto const& listener : m_listeners ) {
16953  listener->testGroupEnded( testGroupStats );
16954  }
16955  m_reporter->testGroupEnded( testGroupStats );
16956  }
16957 
16958  void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) {
16959  for ( auto const& listener : m_listeners ) {
16960  listener->testRunEnded( testRunStats );
16961  }
16962  m_reporter->testRunEnded( testRunStats );
16963  }
16964 
16965  void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) {
16966  for ( auto const& listener : m_listeners ) {
16967  listener->skipTest( testInfo );
16968  }
16969  m_reporter->skipTest( testInfo );
16970  }
16971 
16972  bool ListeningReporter::isMulti() const {
16973  return true;
16974  }
16975 
16976 } // end namespace Catch
16977 // end catch_reporter_listening.cpp
16978 // start catch_reporter_xml.cpp
16979 
16980 #if defined(_MSC_VER)
16981 #pragma warning(push)
16982 #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
16983  // Note that 4062 (not all labels are handled
16984  // and default is missing) is enabled
16985 #endif
16986 
16987 namespace Catch {
16988  XmlReporter::XmlReporter( ReporterConfig const& _config )
16989  : StreamingReporterBase( _config ),
16990  m_xml(_config.stream())
16991  {
16992  m_reporterPrefs.shouldRedirectStdOut = true;
16993  m_reporterPrefs.shouldReportAllAssertions = true;
16994  }
16995 
16996  XmlReporter::~XmlReporter() = default;
16997 
16998  std::string XmlReporter::getDescription() {
16999  return "Reports test results as an XML document";
17000  }
17001 
17002  std::string XmlReporter::getStylesheetRef() const {
17003  return std::string();
17004  }
17005 
17006  void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) {
17007  m_xml
17008  .writeAttribute( "filename", sourceInfo.file )
17009  .writeAttribute( "line", sourceInfo.line );
17010  }
17011 
17012  void XmlReporter::noMatchingTestCases( std::string const& s ) {
17013  StreamingReporterBase::noMatchingTestCases( s );
17014  }
17015 
17016  void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) {
17017  StreamingReporterBase::testRunStarting( testInfo );
17018  std::string stylesheetRef = getStylesheetRef();
17019  if( !stylesheetRef.empty() )
17020  m_xml.writeStylesheetRef( stylesheetRef );
17021  m_xml.startElement( "Catch" );
17022  if( !m_config->name().empty() )
17023  m_xml.writeAttribute( "name", m_config->name() );
17024  if (m_config->testSpec().hasFilters())
17025  m_xml.writeAttribute( "filters", serializeFilters( m_config->getTestsOrTags() ) );
17026  if( m_config->rngSeed() != 0 )
17027  m_xml.scopedElement( "Randomness" )
17028  .writeAttribute( "seed", m_config->rngSeed() );
17029  }
17030 
17031  void XmlReporter::testGroupStarting( GroupInfo const& groupInfo ) {
17032  StreamingReporterBase::testGroupStarting( groupInfo );
17033  m_xml.startElement( "Group" )
17034  .writeAttribute( "name", groupInfo.name );
17035  }
17036 
17037  void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
17038  StreamingReporterBase::testCaseStarting(testInfo);
17039  m_xml.startElement( "TestCase" )
17040  .writeAttribute( "name", trim( testInfo.name ) )
17041  .writeAttribute( "description", testInfo.description )
17042  .writeAttribute( "tags", testInfo.tagsAsString() );
17043 
17044  writeSourceInfo( testInfo.lineInfo );
17045 
17046  if ( m_config->showDurations() == ShowDurations::Always )
17047  m_testCaseTimer.start();
17048  m_xml.ensureTagClosed();
17049  }
17050 
17051  void XmlReporter::sectionStarting( SectionInfo const& sectionInfo ) {
17052  StreamingReporterBase::sectionStarting( sectionInfo );
17053  if( m_sectionDepth++ > 0 ) {
17054  m_xml.startElement( "Section" )
17055  .writeAttribute( "name", trim( sectionInfo.name ) );
17056  writeSourceInfo( sectionInfo.lineInfo );
17057  m_xml.ensureTagClosed();
17058  }
17059  }
17060 
17061  void XmlReporter::assertionStarting( AssertionInfo const& ) { }
17062 
17063  bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) {
17064 
17065  AssertionResult const& result = assertionStats.assertionResult;
17066 
17067  bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
17068 
17069  if( includeResults || result.getResultType() == ResultWas::Warning ) {
17070  // Print any info messages in <Info> tags.
17071  for( auto const& msg : assertionStats.infoMessages ) {
17072  if( msg.type == ResultWas::Info && includeResults ) {
17073  m_xml.scopedElement( "Info" )
17074  .writeText( msg.message );
17075  } else if ( msg.type == ResultWas::Warning ) {
17076  m_xml.scopedElement( "Warning" )
17077  .writeText( msg.message );
17078  }
17079  }
17080  }
17081 
17082  // Drop out if result was successful but we're not printing them.
17083  if( !includeResults && result.getResultType() != ResultWas::Warning )
17084  return true;
17085 
17086  // Print the expression if there is one.
17087  if( result.hasExpression() ) {
17088  m_xml.startElement( "Expression" )
17089  .writeAttribute( "success", result.succeeded() )
17090  .writeAttribute( "type", result.getTestMacroName() );
17091 
17092  writeSourceInfo( result.getSourceInfo() );
17093 
17094  m_xml.scopedElement( "Original" )
17095  .writeText( result.getExpression() );
17096  m_xml.scopedElement( "Expanded" )
17097  .writeText( result.getExpandedExpression() );
17098  }
17099 
17100  // And... Print a result applicable to each result type.
17101  switch( result.getResultType() ) {
17103  m_xml.startElement( "Exception" );
17104  writeSourceInfo( result.getSourceInfo() );
17105  m_xml.writeText( result.getMessage() );
17106  m_xml.endElement();
17107  break;
17109  m_xml.startElement( "FatalErrorCondition" );
17110  writeSourceInfo( result.getSourceInfo() );
17111  m_xml.writeText( result.getMessage() );
17112  m_xml.endElement();
17113  break;
17114  case ResultWas::Info:
17115  m_xml.scopedElement( "Info" )
17116  .writeText( result.getMessage() );
17117  break;
17118  case ResultWas::Warning:
17119  // Warning will already have been written
17120  break;
17122  m_xml.startElement( "Failure" );
17123  writeSourceInfo( result.getSourceInfo() );
17124  m_xml.writeText( result.getMessage() );
17125  m_xml.endElement();
17126  break;
17127  default:
17128  break;
17129  }
17130 
17131  if( result.hasExpression() )
17132  m_xml.endElement();
17133 
17134  return true;
17135  }
17136 
17137  void XmlReporter::sectionEnded( SectionStats const& sectionStats ) {
17138  StreamingReporterBase::sectionEnded( sectionStats );
17139  if( --m_sectionDepth > 0 ) {
17140  XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
17141  e.writeAttribute( "successes", sectionStats.assertions.passed );
17142  e.writeAttribute( "failures", sectionStats.assertions.failed );
17143  e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
17144 
17145  if ( m_config->showDurations() == ShowDurations::Always )
17146  e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds );
17147 
17148  m_xml.endElement();
17149  }
17150  }
17151 
17152  void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
17153  StreamingReporterBase::testCaseEnded( testCaseStats );
17154  XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
17155  e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
17156 
17157  if ( m_config->showDurations() == ShowDurations::Always )
17158  e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
17159 
17160  if( !testCaseStats.stdOut.empty() )
17161  m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), XmlFormatting::Newline );
17162  if( !testCaseStats.stdErr.empty() )
17163  m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), XmlFormatting::Newline );
17164 
17165  m_xml.endElement();
17166  }
17167 
17168  void XmlReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {
17169  StreamingReporterBase::testGroupEnded( testGroupStats );
17170  // TODO: Check testGroupStats.aborting and act accordingly.
17171  m_xml.scopedElement( "OverallResults" )
17172  .writeAttribute( "successes", testGroupStats.totals.assertions.passed )
17173  .writeAttribute( "failures", testGroupStats.totals.assertions.failed )
17174  .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
17175  m_xml.endElement();
17176  }
17177 
17178  void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) {
17179  StreamingReporterBase::testRunEnded( testRunStats );
17180  m_xml.scopedElement( "OverallResults" )
17181  .writeAttribute( "successes", testRunStats.totals.assertions.passed )
17182  .writeAttribute( "failures", testRunStats.totals.assertions.failed )
17183  .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk );
17184  m_xml.endElement();
17185  }
17186 
17187 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
17188  void XmlReporter::benchmarkPreparing(std::string const& name) {
17189  m_xml.startElement("BenchmarkResults")
17190  .writeAttribute("name", name);
17191  }
17192 
17193  void XmlReporter::benchmarkStarting(BenchmarkInfo const &info) {
17194  m_xml.writeAttribute("samples", info.samples)
17195  .writeAttribute("resamples", info.resamples)
17196  .writeAttribute("iterations", info.iterations)
17197  .writeAttribute("clockResolution", info.clockResolution)
17198  .writeAttribute("estimatedDuration", info.estimatedDuration)
17199  .writeComment("All values in nano seconds");
17200  }
17201 
17202  void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) {
17203  m_xml.startElement("mean")
17204  .writeAttribute("value", benchmarkStats.mean.point.count())
17205  .writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count())
17206  .writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count())
17207  .writeAttribute("ci", benchmarkStats.mean.confidence_interval);
17208  m_xml.endElement();
17209  m_xml.startElement("standardDeviation")
17210  .writeAttribute("value", benchmarkStats.standardDeviation.point.count())
17211  .writeAttribute("lowerBound", benchmarkStats.standardDeviation.lower_bound.count())
17212  .writeAttribute("upperBound", benchmarkStats.standardDeviation.upper_bound.count())
17213  .writeAttribute("ci", benchmarkStats.standardDeviation.confidence_interval);
17214  m_xml.endElement();
17215  m_xml.startElement("outliers")
17216  .writeAttribute("variance", benchmarkStats.outlierVariance)
17217  .writeAttribute("lowMild", benchmarkStats.outliers.low_mild)
17218  .writeAttribute("lowSevere", benchmarkStats.outliers.low_severe)
17219  .writeAttribute("highMild", benchmarkStats.outliers.high_mild)
17220  .writeAttribute("highSevere", benchmarkStats.outliers.high_severe);
17221  m_xml.endElement();
17222  m_xml.endElement();
17223  }
17224 
17225  void XmlReporter::benchmarkFailed(std::string const &error) {
17226  m_xml.scopedElement("failed").
17227  writeAttribute("message", error);
17228  m_xml.endElement();
17229  }
17230 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
17231 
17232  CATCH_REGISTER_REPORTER( "xml", XmlReporter )
17233 
17234 } // end namespace Catch
17235 
17236 #if defined(_MSC_VER)
17237 #pragma warning(pop)
17238 #endif
17239 // end catch_reporter_xml.cpp
17240 
17241 namespace Catch {
17242  LeakDetector leakDetector;
17243 }
17244 
17245 #ifdef __clang__
17246 #pragma clang diagnostic pop
17247 #endif
17248 
17249 // end catch_impl.hpp
17250 #endif
17251 
17252 #ifdef CATCH_CONFIG_MAIN
17253 // start catch_default_main.hpp
17254 
17255 #ifndef __OBJC__
17256 
17257 #if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
17258 // Standard C/C++ Win32 Unicode wmain entry point
17259 extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
17260 #else
17261 // Standard C/C++ main entry point
17262 int main (int argc, char * argv[]) {
17263 #endif
17264 
17265  return Catch::Session().run( argc, argv );
17266 }
17267 
17268 #else // __OBJC__
17269 
17270 // Objective-C entry point
17271 int main (int argc, char * const argv[]) {
17272 #if !CATCH_ARC_ENABLED
17273  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
17274 #endif
17275 
17276  Catch::registerTestMethods();
17277  int result = Catch::Session().run( argc, (char**)argv );
17278 
17279 #if !CATCH_ARC_ENABLED
17280  [pool drain];
17281 #endif
17282 
17283  return result;
17284 }
17285 
17286 #endif // __OBJC__
17287 
17288 // end catch_default_main.hpp
17289 #endif
17290 
17291 #if !defined(CATCH_CONFIG_IMPL_ONLY)
17292 
17293 #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
17294 # undef CLARA_CONFIG_MAIN
17295 #endif
17296 
17297 #if !defined(CATCH_CONFIG_DISABLE)
17298 // If this config identifier is defined then all CATCH macros are prefixed with CATCH_
17300 #ifdef CATCH_CONFIG_PREFIX_ALL
17301 
17302 #define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17303 #define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
17304 
17305 #define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17306 #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
17307 #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
17308 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17309 #define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
17310 #endif// CATCH_CONFIG_DISABLE_MATCHERS
17311 #define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17312 
17313 #define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17314 #define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
17315 #define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17316 #define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17317 #define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
17318 
17319 #define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17320 #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
17321 #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
17322 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17323 #define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
17324 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17325 #define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17326 
17327 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17328 #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
17329 
17330 #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
17331 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17332 
17333 #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
17334 #define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg )
17335 #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
17336 #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE",__VA_ARGS__ )
17337 
17338 #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
17339 #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
17340 #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
17341 #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
17342 #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
17343 #define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )
17344 #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
17345 #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17346 #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17347 
17348 #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()
17349 
17350 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
17351 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17352 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ )
17353 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17354 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
17355 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ )
17356 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ )
17357 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ )
17358 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
17359 #else
17360 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )
17361 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) )
17362 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
17363 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
17364 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) )
17365 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) )
17366 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
17367 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
17368 #endif
17369 
17370 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
17371 #define CATCH_STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__ , #__VA_ARGS__ ); CATCH_SUCCEED( #__VA_ARGS__ )
17372 #define CATCH_STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); CATCH_SUCCEED( #__VA_ARGS__ )
17373 #else
17374 #define CATCH_STATIC_REQUIRE( ... ) CATCH_REQUIRE( __VA_ARGS__ )
17375 #define CATCH_STATIC_REQUIRE_FALSE( ... ) CATCH_REQUIRE_FALSE( __VA_ARGS__ )
17376 #endif
17377 
17378 // "BDD-style" convenience wrappers
17379 #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
17380 #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
17381 #define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc )
17382 #define CATCH_AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc )
17383 #define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc )
17384 #define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc )
17385 #define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc )
17386 #define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc )
17387 
17388 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
17389 #define CATCH_BENCHMARK(...) \
17390  INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,))
17391 #define CATCH_BENCHMARK_ADVANCED(name) \
17392  INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name)
17393 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
17394 
17395 // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
17396 #else
17397 
17398 #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17399 #define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
17400 
17401 #define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17402 #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
17403 #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
17404 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17405 #define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
17406 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17407 #define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
17408 
17409 #define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17410 #define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
17411 #define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17412 #define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17413 #define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
17414 
17415 #define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17416 #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
17417 #define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
17418 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17419 #define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
17420 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17421 #define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17422 
17423 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17424 #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
17425 
17426 #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
17427 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17428 
17429 #define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
17430 #define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg )
17431 #define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
17432 #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE",__VA_ARGS__ )
17433 
17434 #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
17435 #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
17436 #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
17437 #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
17438 #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
17439 #define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )
17440 #define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
17441 #define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17442 #define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
17443 #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()
17444 
17445 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
17446 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17447 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ )
17448 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17449 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
17450 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ )
17451 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ )
17452 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ )
17453 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
17454 #define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__)
17455 #define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ )
17456 #else
17457 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )
17458 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) )
17459 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
17460 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
17461 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) )
17462 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) )
17463 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
17464 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
17465 #define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE( __VA_ARGS__ ) )
17466 #define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
17467 #endif
17468 
17469 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
17470 #define STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__, #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ )
17471 #define STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); SUCCEED( "!(" #__VA_ARGS__ ")" )
17472 #else
17473 #define STATIC_REQUIRE( ... ) REQUIRE( __VA_ARGS__ )
17474 #define STATIC_REQUIRE_FALSE( ... ) REQUIRE_FALSE( __VA_ARGS__ )
17475 #endif
17476 
17477 #endif
17478 
17479 #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
17480 
17481 // "BDD-style" convenience wrappers
17482 #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
17483 #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
17484 
17485 #define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc )
17486 #define AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc )
17487 #define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc )
17488 #define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc )
17489 #define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc )
17490 #define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc )
17491 
17492 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
17493 #define BENCHMARK(...) \
17494  INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,))
17495 #define BENCHMARK_ADVANCED(name) \
17496  INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name)
17497 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
17498 
17499 using Catch::Detail::Approx;
17500 
17501 #else // CATCH_CONFIG_DISABLE
17502 
17504 // If this config identifier is defined then all CATCH macros are prefixed with CATCH_
17505 #ifdef CATCH_CONFIG_PREFIX_ALL
17506 
17507 #define CATCH_REQUIRE( ... ) (void)(0)
17508 #define CATCH_REQUIRE_FALSE( ... ) (void)(0)
17509 
17510 #define CATCH_REQUIRE_THROWS( ... ) (void)(0)
17511 #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
17512 #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
17513 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17514 #define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
17515 #endif// CATCH_CONFIG_DISABLE_MATCHERS
17516 #define CATCH_REQUIRE_NOTHROW( ... ) (void)(0)
17517 
17518 #define CATCH_CHECK( ... ) (void)(0)
17519 #define CATCH_CHECK_FALSE( ... ) (void)(0)
17520 #define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__)
17521 #define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__))
17522 #define CATCH_CHECK_NOFAIL( ... ) (void)(0)
17523 
17524 #define CATCH_CHECK_THROWS( ... ) (void)(0)
17525 #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
17526 #define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0)
17527 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17528 #define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
17529 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17530 #define CATCH_CHECK_NOTHROW( ... ) (void)(0)
17531 
17532 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17533 #define CATCH_CHECK_THAT( arg, matcher ) (void)(0)
17534 
17535 #define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0)
17536 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17537 
17538 #define CATCH_INFO( msg ) (void)(0)
17539 #define CATCH_UNSCOPED_INFO( msg ) (void)(0)
17540 #define CATCH_WARN( msg ) (void)(0)
17541 #define CATCH_CAPTURE( msg ) (void)(0)
17542 
17543 #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17544 #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17545 #define CATCH_METHOD_AS_TEST_CASE( method, ... )
17546 #define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0)
17547 #define CATCH_SECTION( ... )
17548 #define CATCH_DYNAMIC_SECTION( ... )
17549 #define CATCH_FAIL( ... ) (void)(0)
17550 #define CATCH_FAIL_CHECK( ... ) (void)(0)
17551 #define CATCH_SUCCEED( ... ) (void)(0)
17552 
17553 #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17554 
17555 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
17556 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)
17557 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)
17558 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)
17559 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ )
17560 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17561 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17562 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17563 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17564 #else
17565 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) )
17566 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) )
17567 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) )
17568 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) )
17569 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17570 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
17571 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17572 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17573 #endif
17574 
17575 // "BDD-style" convenience wrappers
17576 #define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17577 #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className )
17578 #define CATCH_GIVEN( desc )
17579 #define CATCH_AND_GIVEN( desc )
17580 #define CATCH_WHEN( desc )
17581 #define CATCH_AND_WHEN( desc )
17582 #define CATCH_THEN( desc )
17583 #define CATCH_AND_THEN( desc )
17584 
17585 #define CATCH_STATIC_REQUIRE( ... ) (void)(0)
17586 #define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0)
17587 
17588 // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
17589 #else
17590 
17591 #define REQUIRE( ... ) (void)(0)
17592 #define REQUIRE_FALSE( ... ) (void)(0)
17593 
17594 #define REQUIRE_THROWS( ... ) (void)(0)
17595 #define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
17596 #define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
17597 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17598 #define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
17599 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17600 #define REQUIRE_NOTHROW( ... ) (void)(0)
17601 
17602 #define CHECK( ... ) (void)(0)
17603 #define CHECK_FALSE( ... ) (void)(0)
17604 #define CHECKED_IF( ... ) if (__VA_ARGS__)
17605 #define CHECKED_ELSE( ... ) if (!(__VA_ARGS__))
17606 #define CHECK_NOFAIL( ... ) (void)(0)
17607 
17608 #define CHECK_THROWS( ... ) (void)(0)
17609 #define CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
17610 #define CHECK_THROWS_WITH( expr, matcher ) (void)(0)
17611 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17612 #define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
17613 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17614 #define CHECK_NOTHROW( ... ) (void)(0)
17615 
17616 #if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
17617 #define CHECK_THAT( arg, matcher ) (void)(0)
17618 
17619 #define REQUIRE_THAT( arg, matcher ) (void)(0)
17620 #endif // CATCH_CONFIG_DISABLE_MATCHERS
17621 
17622 #define INFO( msg ) (void)(0)
17623 #define UNSCOPED_INFO( msg ) (void)(0)
17624 #define WARN( msg ) (void)(0)
17625 #define CAPTURE( msg ) (void)(0)
17626 
17627 #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17628 #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17629 #define METHOD_AS_TEST_CASE( method, ... )
17630 #define REGISTER_TEST_CASE( Function, ... ) (void)(0)
17631 #define SECTION( ... )
17632 #define DYNAMIC_SECTION( ... )
17633 #define FAIL( ... ) (void)(0)
17634 #define FAIL_CHECK( ... ) (void)(0)
17635 #define SUCCEED( ... ) (void)(0)
17636 #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))
17637 
17638 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
17639 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)
17640 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)
17641 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)
17642 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ )
17643 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
17644 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
17645 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17646 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17647 #else
17648 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) )
17649 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) )
17650 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) )
17651 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) )
17652 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
17653 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
17654 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17655 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
17656 #endif
17657 
17658 #define STATIC_REQUIRE( ... ) (void)(0)
17659 #define STATIC_REQUIRE_FALSE( ... ) (void)(0)
17660 
17661 #endif
17662 
17663 #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
17664 
17665 // "BDD-style" convenience wrappers
17666 #define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) )
17667 #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className )
17668 
17669 #define GIVEN( desc )
17670 #define AND_GIVEN( desc )
17671 #define WHEN( desc )
17672 #define AND_WHEN( desc )
17673 #define THEN( desc )
17674 #define AND_THEN( desc )
17675 
17676 using Catch::Detail::Approx;
17677 
17678 #endif
17679 
17680 #endif // ! CATCH_CONFIG_IMPL_ONLY
17681 
17682 // start catch_reenable_warnings.h
17683 
17684 
17685 #ifdef __clang__
17686 # ifdef __ICC // icpc defines the __clang__ macro
17687 # pragma warning(pop)
17688 # else
17689 # pragma clang diagnostic pop
17690 # endif
17691 #elif defined __GNUC__
17692 # pragma GCC diagnostic pop
17693 #endif
17694 
17695 // end catch_reenable_warnings.h
17696 // end catch.hpp
17697 #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
17698 
#define CATCH_INTERNAL_ERROR(...)
Definition: catch.hpp:3896
GLboolean GLboolean g
virtual T const & get() const =0
const char * const_iterator
Definition: catch.hpp:613
virtual void setGenerator(Generators::GeneratorBasePtr &&generator)=0
GLsizei GLsizei GLchar * source
GLenum GLuint GLenum GLsizei const GLchar * message
T valueOr(T const &defaultValue) const
Definition: catch.hpp:4436
void handleExpression(ITransientExpression const &expr)
bool matchTest(TestCase const &testCase, TestSpec const &testSpec, IConfig const &config)
SourceLineInfo lineInfo
Definition: catch.hpp:2603
GeneratorWrapper< T > values(std::initializer_list< T > values)
Definition: catch.hpp:4004
auto operator==(StringRef const &other) const noexcept -> bool
std::size_t m_count
Definition: catch.hpp:3218
auto getResult() const -> bool
Definition: catch.hpp:2201
unsigned int sequence
Definition: catch.hpp:2605
Totals & operator+=(Totals const &other)
ChunkGenerator(size_t size, GeneratorWrapper< T > generator)
Definition: catch.hpp:4291
Option(Option const &_other)
Definition: catch.hpp:4403
std::vector< MatcherBase< ArgT > const * > m_matchers
Definition: catch.hpp:3315
std::string rawMemoryToString(const T &object)
Definition: catch.hpp:1563
std::unique_ptr< GeneratorUntypedBase > GeneratorBasePtr
Definition: catch.hpp:3854
Approx approx(F f)
Definition: approx.h:106
GLint y
MessageInfo m_info
Definition: catch.hpp:2635
std::ostream * m_oss
Definition: catch.hpp:1446
virtual ~NonCopyable()
FixedValuesGenerator(std::initializer_list< T > values)
Definition: catch.hpp:3973
const char * what() const noexcept override final
CaseSensitive::Choice m_caseSensitivity
Definition: catch.hpp:3577
bool isFalseTest(int flags)
Definition: catch.hpp:1392
IteratorGenerator(InputIterator first, InputSentinel last)
Definition: catch.hpp:4708
static Approx custom()
ExceptionTranslatorRegistrar(std::string(*translateFunction)(T &))
Definition: catch.hpp:3049
GLenum GLsizei const void * pointer
TestCase(ITestInvoker *testCase, TestCaseInfo &&info)
boost_foreach_argument_dependent_lookup_hack tag
Definition: foreach_fwd.hpp:31
Counts testCases
Definition: catch.hpp:2848
Counts assertions
Definition: catch.hpp:2847
EqualsMatcher(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3657
static std::enable_if<!::Catch::Detail::IsStreamInsertable< Fake >::value, std::string >::type convert(const Fake &value)
Definition: catch.hpp:1634
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
virtual void registerTest(TestCase const &testInfo)=0
GLuint const GLchar * name
Option & operator=(Option const &_other)
Definition: catch.hpp:4411
GLuint GLfloat * val
void toLowerInPlace(std::string &s)
virtual StartupExceptionRegistry const & getStartupExceptionRegistry() const =0
GLdouble GLdouble GLint GLint order
std::vector< std::unique_ptr< IExceptionTranslator const > > ExceptionTranslators
Definition: catch.hpp:3005
static void moveToParent(BtCursor *pCur)
Definition: sqlite3.c:62481
std::shared_ptr< ITestInvoker > test
Definition: catch.hpp:4809
StringRef tags
Definition: catch.hpp:987
void handleMessage(ResultWas::OfType resultType, StringRef const &message)
std::string name
Definition: catch.hpp:4785
void handleExceptionNotThrownAsExpected()
LazyExpression(bool isNegated)
auto c_str() const -> char const *
ResultDisposition::Flags operator|(ResultDisposition::Flags lhs, ResultDisposition::Flags rhs)
TestCase makeTestCase(ITestInvoker *testCase, std::string const &className, NameAndTags const &nameAndTags, SourceLineInfo const &lineInfo)
bool operator&&(d400_caps l, d400_caps r)
Definition: ds5-private.h:323
bool operator==(const plane &lhs, const plane &rhs)
Definition: rendering.h:120
constexpr const_iterator begin() const
Definition: catch.hpp:677
void throw_runtime_error(std::string const &msg)
GLdouble s
std::ostream & operator<<(std::ostream &os, SourceLineInfo const &info)
virtual void registerTagAlias(std::string const &alias, std::string const &tag, SourceLineInfo const &lineInfo)=0
void cleanUpContext()
GeneratorWrapper< std::tuple< Ts... > > table(std::initializer_list< std::tuple< typename std::decay< Ts >::type... >> tuples)
Definition: catch.hpp:4053
virtual auto acquireGeneratorTracker(SourceLineInfo const &lineInfo) -> IGeneratorTracker &=0
bool contains(std::string const &s, std::string const &infix)
Exception::ExceptionMessageMatcher Message(std::string const &message)
bool match(T const &item) const override
Definition: catch.hpp:3502
CaseSensitive::Choice m_caseSensitivity
Definition: catch.hpp:3541
Verbosity
Definition: catch.hpp:4464
std::string m_name
Definition: catch.hpp:2919
struct Column Column
Definition: sqlite3.c:11778
unsigned int rngSeed()
void validate(std::vector< std::vector< rs2::stream_profile >> frames, std::vector< std::vector< double >> timestamps, device_profiles requests, int actual_fps)
PredicateMatcher(std::function< bool(T const &)> const &elem, std::string const &descr)
Definition: catch.hpp:3497
auto makeUnaryExpr() const -> UnaryExpr< LhsT >
Definition: catch.hpp:2399
std::string describe() const override
Definition: catch.hpp:3671
GLsizei const GLchar *const * string
GLboolean reset
SectionInfo m_info
Definition: catch.hpp:2917
std::vector< StringRef > splitStringRef(StringRef str, char delimiter)
Factory * factory
GeneratorWrapper< T > m_generator
Definition: catch.hpp:4114
virtual void registerReporter(std::string const &name, IReporterFactoryPtr const &factory)=0
#define CATCH_TRY
Definition: catch.hpp:458
virtual IConfigPtr const & getConfig() const =0
auto compareNotEqual(LhsT const &lhs, RhsT &&rhs) -> bool
Definition: catch.hpp:2324
std::vector< std::pair< int, StringRef > > m_values
Definition: catch.hpp:1472
auto getCurrentNanosecondsSinceEpoch() -> uint64_t
T const & operator+(T const &value, StreamEndStop)
Definition: catch.hpp:542
auto getEstimatedClockResolution() -> uint64_t
std::string describe() const override
Definition: catch.hpp:3617
integral_constant< bool, false > false_type
#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
Definition: catch.hpp:423
std::mutex m
SpecialProperties properties
Definition: catch.hpp:4791
bool match(ArgT const &arg) const override
Definition: catch.hpp:3286
std::size_t failedButOk
Definition: catch.hpp:2836
GeneratorWrapper(std::unique_ptr< IGenerator< T >> generator)
Definition: catch.hpp:3988
GLint location
GeneratorWrapper< U > m_generator
Definition: catch.hpp:4246
not_this_one end(...)
std::string toString() const
Detail::EnumInfo const & registerEnum(StringRef enumName, StringRef allEnums, std::initializer_list< E > values)
Definition: catch.hpp:1486
::sensor_msgs::Range_< std::allocator< void > > Range
Definition: Range.h:75
auto makeGenerators(as< T >, U &&val, Gs &&... moreGenerators) -> Generators< T >
Definition: catch.hpp:4074
#define isOpen(pFd)
Definition: sqlite3.c:46629
virtual ~ITestInvoker()
GLfloat value
TestInvokerAsMethod(void(C::*testAsMethod)()) noexcept
Definition: catch.hpp:969
GLint GLuint mask
SourceLineInfo(char const *_file, std::size_t _line) noexcept
Definition: catch.hpp:509
virtual void popScopedMessage(MessageInfo const &message)=0
IResultCapture & getResultCapture()
Definition: test.cpp:7
ImVec4 operator*(const ImVec4 &color, float t)
Definition: model-views.h:68
std::string(*)() exceptionTranslateFunction
Definition: catch.hpp:3002
Approx & epsilon(T const &newEpsilon)
Definition: catch.hpp:3147
def indent(str, line_prefix=' ')
Definition: log.py:88
Capturer(StringRef macroName, SourceLineInfo const &lineInfo, ResultWas::OfType resultType, StringRef names)
static std::string convert(T const(&arr)[SZ])
Definition: catch.hpp:2045
std::vector< std::string > lcaseTags
Definition: catch.hpp:4789
def printer
Definition: devices.py:742
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:4000
StdString::RegexMatcher Matches(std::string const &regex, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
std::string describe() const override
Definition: catch.hpp:3725
GeneratorWrapper< std::vector< T > > chunk(size_t size, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4321
double durationInSeconds
Definition: catch.hpp:2876
virtual auto hasGenerator() const -> bool=0
SectionInfo(SourceLineInfo const &_lineInfo, std::string const &_name)
virtual RunTests::InWhatOrder runOrder() const =0
Easylogging++ entry namespace.
bool replaceInPlace(std::string &str, std::string const &replaceThis, std::string const &withThis)
void convert(rs2_format source, std::string &target)
def fail()
Definition: test.py:368
virtual std::vector< TestCase > const & getAllTestsSorted(IConfig const &config) const =0
std::string finalizeDescription(const std::string &desc)
matches
Definition: test-fg.py:19
bool operator==(SourceLineInfo const &other) const noexcept
Definition: catch.hpp:95
Approx operator()(T const &value)
Definition: catch.hpp:3093
SectionInfo sectionInfo
Definition: catch.hpp:2874
Mode
Definition: monitors.c:40
virtual void handleFatalErrorCondition(StringRef message)=0
GLdouble GLdouble GLdouble w
GeneratorWrapper< T > m_generator
Definition: catch.hpp:4191
std::enable_if< std::is_floating_point< T >::value, GeneratorWrapper< T > >::type random(T a, T b)
Definition: catch.hpp:4647
UnaryExpr(LhsT lhs)
Definition: catch.hpp:2305
d
Definition: rmse.py:171
IMGUI_API void Indent(float indent_w=0.0f)
Definition: imgui.cpp:9493
std::uniform_int_distribution< Integer > m_dist
Definition: catch.hpp:4614
T * operator->()
Definition: catch.hpp:4433
virtual auto getGenerator() const -> Generators::GeneratorBasePtr const &=0
Counts m_assertions
Definition: catch.hpp:2920
StringRef(std::string const &stdString) noexcept
Definition: catch.hpp:631
dispatcher invoke([&](dispatcher::cancellable_timer c) { std::this_thread::sleep_for(std::chrono::seconds(3));dispatched_end_verifier=true;})
std::vector< std::string > tags
Definition: catch.hpp:4788
d400_caps operator&(const d400_caps lhs, const d400_caps rhs)
Definition: ds5-private.h:308
auto substr(size_type start, size_type length) const noexcept -> StringRef
std::string operator+() const
ExprLhs(LhsT lhs)
Definition: catch.hpp:2338
static std::string convert(signed char const *str)
Definition: catch.hpp:1722
Definition: arg_fwd.hpp:23
IMutableRegistryHub & getMutableRegistryHub()
Counts & operator+=(Counts const &other)
static const int one
unsigned char uint8_t
Definition: stdint.h:78
bool operator>(failed, failed)
#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
Definition: catch.hpp:426
void formatReconstructedExpression(std::ostream &os, std::string const &lhs, StringRef op, std::string const &rhs)
bool operator<(const stream_identifier &lhs, const stream_identifier &rhs)
bool empty() const noexcept
Definition: catch.hpp:519
e
Definition: rmse.py:177
ITransientExpression(bool isBinaryExpression, bool result)
Definition: catch.hpp:2204
GeneratorWrapper< ResultType > from_range(Container const &cnt)
Definition: catch.hpp:4733
bool none() const
Definition: catch.hpp:4441
ScopedMessage(MessageBuilder const &builder)
point
Definition: rmse.py:166
GLenum GLfloat * buffer
std::string stringify(const T &e)
Definition: catch.hpp:1648
constexpr auto empty() const noexcept -> bool
Definition: catch.hpp:652
StdString::EqualsMatcher Equals(std::string const &str, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
def all()
Definition: devices.py:277
direction
Definition: rs-align.cpp:25
variance
Definition: rmse.py:157
static std::string convert(U *p)
Definition: catch.hpp:1802
virtual void registerStartupException() noexcept=0
std::vector< GeneratorWrapper< T > > m_generators
Definition: catch.hpp:4010
virtual void pushScopedMessage(MessageInfo const &message)=0
GLenum GLuint id
ApproxMatcher(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3680
Vector::EqualsMatcher< T, AllocComp, AllocMatch > Equals(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3748
virtual ~IStream()
Vector::ContainsElementMatcher< T, Alloc > VectorContains(T const &comparator)
Definition: catch.hpp:3743
auto getElapsedSeconds() const -> double
GeneratorWrapper< T > filter(Predicate &&pred, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4183
rs2rosinternal::Time * timeStamp(M &m)
returns TimeStamp<M>::pointer(m);
T && forward(typename ::boost::move_detail::remove_reference< T >::type &t) BOOST_NOEXCEPT
GLuint index
bool some() const
Definition: catch.hpp:4440
ResultDisposition::Flags resultDisposition
Definition: catch.hpp:1405
std::vector< TestCase > const & getAllTestCasesSorted(IConfig const &config)
ExceptionTranslator(std::string(*translateFunction)(T &))
Definition: catch.hpp:3023
GLdouble t
void streamReconstructedExpression(std::ostream &os) const override
Definition: catch.hpp:2300
auto data() const noexcept -> char const *
bool shouldContinueOnFailure(int flags)
::std_msgs::Duration_< std::allocator< void > > Duration
Definition: Duration.h:47
virtual ~IConfig()
bool expectedToFail() const
auto str() const -> std::string
d400_caps & operator|=(d400_caps &lhs, d400_caps rhs)
Definition: ds5-private.h:318
UnorderedEqualsMatcher(std::vector< T, AllocComp > const &target)
Definition: catch.hpp:3715
def info(name, value, persistent=False)
Definition: test.py:327
def tags(self)
Definition: libci.py:121
std::unique_ptr< T > make_unique(Args &&... args)
Definition: catch.hpp:3934
std::function< void(std::function< void()>)> invoker
bool isJustInfo(int flags)
GeneratorWrapper< T > m_generator
Definition: catch.hpp:4150
GeneratorException(const char *msg)
Definition: catch.hpp:3922
AutoReg(ITestInvoker *invoker, SourceLineInfo const &lineInfo, StringRef const &classOrMethod, NameAndTags const &nameAndTags) noexcept
not_this_one begin(...)
static T parse(const mxArray *cell)
GLenum mode
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5294
GeneratorWrapper< T > range(T const &start, T const &end)
Definition: catch.hpp:4693
std::string tagsAsString() const
std::vector< TestCase > filterTests(std::vector< TestCase > const &testCases, TestSpec const &testSpec, IConfig const &config)
bool match(std::vector< T, AllocMatch > const &v) const override
Definition: catch.hpp:3659
AssertionReaction m_reaction
Definition: catch.hpp:2547
TestCase withName(std::string const &_newName) const
GLboolean GLboolean GLboolean GLboolean a
Vector::ContainsMatcher< T, AllocComp, AllocMatch > Contains(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3738
std::uniform_real_distribution< Float > m_dist
Definition: catch.hpp:4592
AssertionInfo m_assertionInfo
Definition: catch.hpp:2546
Approx(T const &value)
Definition: catch.hpp:3102
void populate(U &&valueOrGenerator, Gs &&... moreGenerators)
Definition: catch.hpp:4024
T const & operator*() const
Definition: catch.hpp:4432
std::string description
Definition: catch.hpp:2869
ApproxMatcher & margin(T const &newMargin)
Definition: catch.hpp:3699
void handleUnexpectedInflightException()
Floating::WithinAbsMatcher WithinAbs(double target, double margin)
GLsizeiptr size
Approx & scale(T const &newScale)
Definition: catch.hpp:3161
void populate(GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4013
ArgT const & m_arg
Definition: catch.hpp:3770
static std::string convert(R C::*p)
Definition: catch.hpp:1813
std::size_t failed
Definition: catch.hpp:2835
Option(T const &_value)
Definition: catch.hpp:4400
StringRef m_matcherString
Definition: catch.hpp:3772
BinaryExpr(bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs)
Definition: catch.hpp:2232
void cleanUp()
auto makeTestInvoker(void(*testAsFunction)()) noexcept -> ITestInvoker *
std::ostream & cout()
AssertionHandler(StringRef const &macroName, SourceLineInfo const &lineInfo, StringRef capturedExpression, ResultDisposition::Flags resultDisposition)
static std::string accel
Definition: hid-types.h:24
StringRef capturedExpression
Definition: catch.hpp:1404
GLdouble GLdouble r
double p[GRIDW][GRIDH]
Definition: wave.c:109
bool shouldSuppressFailure(int flags)
Definition: lz4.c:1706
virtual ~IRegistryHub()
std::shared_ptr< IReporterFactory > IReporterFactoryPtr
Definition: catch.hpp:2960
StdString::EndsWithMatcher EndsWith(std::string const &str, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
detail namespace with internal helper functions
Definition: json.hpp:269
std::string describe() const override
Definition: catch.hpp:3506
#define assert(condition)
Definition: lz4.c:245
GLdouble x
ContainsMatcher(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3627
virtual bool allowThrows() const =0
bool isOk(ResultWas::OfType resultType)
ResultWas::OfType type
Definition: catch.hpp:2604
virtual void registerTranslator(const IExceptionTranslator *translator)=0
bool match(std::vector< T, Alloc > const &v) const override
Definition: catch.hpp:3608
ReusableStringStream m_stream
Definition: catch.hpp:2621
unsigned int uint32_t
Definition: stdint.h:80
virtual int benchmarkSamples() const =0
bool operator<(MessageInfo const &other) const
float3 operator-(const float3 &a, const float3 &b)
Definition: float3.h:41
SourceLineInfo lineInfo
Definition: catch.hpp:4790
GeneratorWrapper< T > m_generator
Definition: catch.hpp:4288
StringRef macroName
Definition: catch.hpp:2601
TestCaseInfo const & getTestCaseInfo() const
bool operator<(SourceLineInfo const &other) const noexcept
void handleExceptionThrownAsExpected()
Totals operator-(Totals const &other) const
std::unique_ptr< IGenerator< T > > m_generator
Definition: catch.hpp:3986
bool match(std::vector< T, AllocMatch > const &v) const override
Definition: catch.hpp:3682
virtual std::string translateActiveException() const =0
NameAndTags(StringRef const &name_=StringRef(), StringRef const &tags_=StringRef()) noexcept
std::string className
Definition: catch.hpp:4786
std::string m_label
Definition: catch.hpp:3219
bool allPassed() const
constexpr const_iterator end() const
Definition: catch.hpp:678
void captureValues(size_t index, T const &value)
Definition: catch.hpp:2660
std::string trim(std::string const &str)
Returns a new string without whitespace at the start/end.
bool endsWith(std::string const &s, std::string const &suffix)
#define CATCH_INTERNAL_LINEINFO
Definition: catch.hpp:547
bool allOk() const
static std::string convert(char const *str)
Definition: catch.hpp:1716
GLbitfield flags
def finish()
Definition: test.py:401
std::vector< T, AllocComp > const & m_comparator
Definition: catch.hpp:3651
#define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
Definition: catch.hpp:432
def find(dir, mask)
Definition: file.py:45
static void abort(int status, const std::string &reason)
Aborts application due with user-defined status.
StringRef macroName
Definition: catch.hpp:1402
unsigned __int64 uint64_t
Definition: stdint.h:90
std::string toLower(std::string const &s)
void captureValues(size_t index, T const &value, Ts const &... values)
Definition: catch.hpp:2665
GLuint start
char const * file
Definition: catch.hpp:523
GLint j
GLuint GLsizei bufSize
bool match(std::vector< T, AllocMatch > const &vec) const override
Definition: catch.hpp:3716
bool isThrowSafe(TestCase const &testCase, IConfig const &config)
static std::string custom
Definition: hid-types.h:25
IMGUI_API void Value(const char *prefix, bool b)
Definition: imgui.cpp:9541
std::string translateActiveException()
#define CATCH_CATCH_ALL
Definition: catch.hpp:459
GLint first
virtual void streamReconstructedExpression(std::ostream &os) const =0
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static std::string print(const transformation &tf)
std::vector< T, AllocComp > const & m_comparator
Definition: catch.hpp:3709
#define op
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5974
Counts operator-(Counts const &other) const
std::enable_if< !std::is_enum< T >::value &&!std::is_base_of< std::exception, T >::value, std::string >::type convertUnstreamable(T const &)
Definition: catch.hpp:1586
virtual ITestCaseRegistry const & getTestCaseRegistry() const =0
void handleExpr(ExprLhs< T > const &expr)
Definition: catch.hpp:2564
bool match(ArgT const &arg) const override
Definition: catch.hpp:3357
std::string name
Definition: catch.hpp:2868
bool operator<(TestCase const &other) const
void discard(uint64_t skip)
std::size_t total() const
std::uint64_t m_state
Definition: catch.hpp:4573
IContext & getCurrentContext()
Definition: catch.hpp:4377
typename std::remove_reference< typename std::remove_cv< typename std::result_of< Func(U)>::type >::type >::type FunctionReturnType
Definition: catch.hpp:953
GLenum func
void throw_logic_error(std::string const &msg)
bool match(ArgT const &arg) const override
Definition: catch.hpp:3320
auto operator+=(std::string &lhs, StringRef const &sr) -> std::string &
auto generate(SourceLineInfo const &lineInfo, L const &generatorExpression) -> decltype(std::declval< decltype(generatorExpression())>().get())
Definition: catch.hpp:4084
StringRef m_op
Definition: catch.hpp:2223
GeneratorWrapper< T > repeat(size_t repeats, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4239
GLenum GLenum GLsizei void GLsizei void * column
RegistrarForTagAliases(char const *alias, char const *tag, SourceLineInfo const &lineInfo)
RangeGenerator(T const &start, T const &end, T const &step)
Definition: catch.hpp:4661
def run(cmd, stdout=None, timeout=200, append=False)
Definition: libci.py:33
std::chrono::duration< uint64_t, std::nano > nanoseconds
virtual double benchmarkConfidenceInterval() const =0
static const textual_icon times
Definition: model-views.h:216
MessageBuilder(StringRef const &macroName, SourceLineInfo const &lineInfo, ResultWas::OfType type)
std::ostream & clog()
std::string describe() const override
Definition: catch.hpp:3647
IResultCapture & m_resultCapture
Definition: catch.hpp:2549
void throw_exception(std::exception const &e)
GLboolean GLboolean GLboolean b
GLfloat units
static unsigned int globalCount
Definition: catch.hpp:2610
constexpr auto size() const noexcept -> size_type
Definition: catch.hpp:655
ApproxMatcher & epsilon(T const &newEpsilon)
Definition: catch.hpp:3694
float3 transform(const rs2_extrinsics *extrin, const float3 &point)
Definition: pointcloud.cpp:47
void invoke() const
GLsizei const GLfloat * values
auto getElapsedNanoseconds() const -> uint64_t
virtual void registerListener(IReporterFactoryPtr const &factory)=0
boost::move_detail::add_rvalue_reference< T >::type declval()
void streamReconstructedExpression(std::ostream &os) const override
Definition: catch.hpp:3781
void next(auto_any_t cur, type2type< T, C > *)
Definition: foreach.hpp:757
std::string translate(ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd) const override
Definition: catch.hpp:3027
void seed(result_type seed_)
auto getElapsedMicroseconds() const -> uint64_t
SourceLineInfo lineInfo
Definition: catch.hpp:1403
MapGenerator(F2 &&function, GeneratorWrapper< U > &&generator)
Definition: catch.hpp:4252
bool operator==(TestCase const &other) const
const std::string unprintableString
unsigned char byte
Definition: src/types.h:40
GLdouble GLdouble GLdouble q
const T * operator->() const
Definition: catch.hpp:4434
void construct(Factory const &factory, void *address)
static std::enable_if<::Catch::Detail::IsStreamInsertable< Fake >::value, std::string >::type convert(const Fake &value)
Definition: catch.hpp:1623
#define CATCH_ENFORCE(condition,...)
Definition: catch.hpp:3905
virtual void handleIncomplete(AssertionInfo const &info)=0
MatcherT m_matcher
Definition: catch.hpp:3771
std::string rangeToString(std::vector< bool, Allocator > const &v)
Definition: catch.hpp:2021
auto isBinaryExpression() const -> bool
Definition: catch.hpp:2200
ApproxMatcher & scale(T const &newScale)
Definition: catch.hpp:3704
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14660
GLdouble right
GLenum GLenum GLsizei void * row
virtual std::chrono::milliseconds benchmarkWarmupTime() const =0
static auto it
MessageInfo(StringRef const &_macroName, SourceLineInfo const &_lineInfo, ResultWas::OfType _type)
bool okToFail() const
GLenum type
char const * m_start
Definition: catch.hpp:618
bool match(std::vector< T, AllocMatch > const &v) const override
Definition: catch.hpp:3629
Section(SectionInfo const &info)
void log(std::string message)
int min(int a, int b)
Definition: lz4s.c:73
GLuint GLsizei const GLchar * label
virtual IReporterRegistry const & getReporterRegistry() const =0
GLsizei samples
signed __int64 int64_t
Definition: stdint.h:89
bool operator>=(failed, failed)
std::vector< MatcherBase< ArgT > const * > m_matchers
Definition: catch.hpp:3349
GLdouble f
bool isHidden() const
virtual IResultCapture * getResultCapture()=0
auto acquireGeneratorTracker(SourceLineInfo const &lineInfo) -> IGeneratorTracker &
GLint GLsizei count
std::string describe() const override
Definition: catch.hpp:3690
MatchAllOf< T > operator&&(MatcherBase const &other) const
constexpr auto isNullTerminated() const noexcept -> bool
Definition: catch.hpp:672
size_type m_size
Definition: catch.hpp:619
GLint ref
FilterGenerator(P &&pred, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4154
virtual unsigned int rngSeed() const =0
MessageInfo m_info
Definition: catch.hpp:2645
Totals delta(Totals const &prevTotals) const
virtual ~IRunner()
auto makeMatchExpr(ArgT const &arg, MatcherT const &matcher, StringRef const &matcherString) -> MatchExpr< ArgT, MatcherT >
Definition: catch.hpp:3796
RandomIntegerGenerator(Integer a, Integer b)
Definition: catch.hpp:4618
std::size_t passed
Definition: catch.hpp:2834
typename ::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
StdString::StartsWithMatcher StartsWith(std::string const &str, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
std::vector< T, AllocComp > const & m_target
Definition: catch.hpp:3729
std::enable_if< std::is_enum< T >::value, std::string >::type convertUnstreamable(T const &value)
Definition: catch.hpp:1599
std::size_t line
Definition: catch.hpp:524
result_type operator()()
Approx & margin(T const &newMargin)
Definition: catch.hpp:3154
std::string convertUnknownEnumToString(E e)
Definition: catch.hpp:1653
std::ostream & cerr()
ExceptionMessageMatcher(std::string const &message)
Definition: catch.hpp:3400
std::string describe() const override
Definition: catch.hpp:3327
float rs2_vector::* pos
RepeatGenerator(size_t repeats, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4198
MatchNotOf< T > operator!() const
Definition: catch.hpp:3376
std::function< bool(T const &)> m_predicate
Definition: catch.hpp:3493
virtual void sectionEnded(SectionEndInfo const &endInfo)=0
Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff)
static void terminate(void)
Definition: init.c:62
void throw_domain_error(std::string const &msg)
void handleExceptionMatchExpr(AssertionHandler &handler, std::string const &str, StringRef const &matcherString)
GLsizei range
MatcherBase< ArgT > const & m_underlyingMatcher
Definition: catch.hpp:3364
int main(int argv, const char **argc)
int i
GLenum GLuint GLenum GLsizei length
#define CATCH_RUNTIME_ERROR(...)
Definition: catch.hpp:3902
std::uint64_t state_type
Definition: catch.hpp:4546
static IMutableContext * currentContext
Definition: catch.hpp:4363
virtual IExceptionTranslatorRegistry const & getExceptionTranslatorRegistry() const =0
T * nullableValue
Definition: catch.hpp:4449
StringRef name
Definition: catch.hpp:986
IMutableContext & getCurrentMutableContext()
Definition: catch.hpp:4369
bool m_sectionIncluded
Definition: catch.hpp:2921
void streamReconstructedExpression(std::ostream &os) const override
Definition: catch.hpp:2226
T & operator*()
Definition: catch.hpp:4431
IRegistryHub const & getRegistryHub()
GLushort pattern
std::uint32_t result_type
Definition: catch.hpp:4548
signed int int32_t
Definition: stdint.h:77
std::size_t size_type
Definition: catch.hpp:612
Generic::PredicateMatcher< T > Predicate(std::function< bool(T const &)> const &predicate, std::string const &description="")
Definition: catch.hpp:3518
Timer m_timer
Definition: catch.hpp:2922
dictionary valid
Definition: t265_stereo.py:219
::rosgraph_msgs::Clock_< std::allocator< void > > Clock
Definition: Clock.h:47
void reset()
Definition: catch.hpp:4425
void handleUnexpectedExceptionNotThrown()
static const textual_icon measure
Definition: model-views.h:264
virtual bool benchmarkNoAnalysis() const =0
MatchAnyOf< T > operator||(MatcherBase const &other) const
Definition: catch.hpp:3372
std::string description
Definition: catch.hpp:4787
auto compareEqual(LhsT const &lhs, RhsT const &rhs) -> bool
Definition: catch.hpp:2313
void captureValue(size_t index, std::string const &value)
SourceLineInfo lineInfo
Definition: catch.hpp:2870
std::shared_ptr< IConfig const > IConfigPtr
Definition: catch.hpp:4344
MatchNotOf(MatcherBase< ArgT > const &underlyingMatcher)
Definition: catch.hpp:3355
virtual void sectionEndedEarly(SectionEndInfo const &endInfo)=0
ITransientExpression const * m_transientExpression
Definition: catch.hpp:2528
std::string message
Definition: catch.hpp:2602
std::string describe() const override
Definition: catch.hpp:3361
GLboolean * data
int h
Definition: sw.py:17
virtual ~IContext()
Generators(Gs &&... moreGenerators)
Definition: catch.hpp:4031
std::string describe() const override
Definition: catch.hpp:3293
MatchExpr(ArgT const &arg, MatcherT const &matcher, StringRef const &matcherString)
Definition: catch.hpp:3774
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui.cpp:9401
virtual void setConfig(IConfigPtr const &config)=0
Definition: na_fwd.hpp:22
boost::iterators::detail::postfix_increment_result< I, V, R, TC >::type operator++(iterator_facade< I, V, TC, R, D > &i, int)
static void createContext()
virtual unsigned int benchmarkResamples() const =0
std::string rangeToString(Range const &range)
Definition: catch.hpp:2015
void invoke() const override
Definition: catch.hpp:971
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2997
Vector::ApproxMatcher< T, AllocComp, AllocMatch > Approx(std::vector< T, AllocComp > const &comparator)
Definition: catch.hpp:3753
bool equalityComparisonImpl(double other) const
GLdouble v
auto makeStream(StringRef const &filename) -> IStream const *
static std::string convert(unsigned char const *str)
Definition: catch.hpp:1728
integral_constant< bool, true > true_type
YYCODETYPE lhs
Definition: sqlite3.c:132469
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
Definition: catch.hpp:4271
auto allowThrows() const -> bool
TestCaseInfo(std::string const &_name, std::string const &_className, std::string const &_description, std::vector< std::string > const &_tags, SourceLineInfo const &_lineInfo)
virtual ITagAliasRegistry const & getTagAliasRegistry() const =0
std::vector< T, AllocComp > const & m_comparator
Definition: catch.hpp:3674
Definition: parser.hpp:153
constexpr StringRef() noexcept=default
#define CATCH_CATCH_ANON(type)
Definition: catch.hpp:460
GLint GLsizei width
pluralise(std::size_t count, std::string const &label)
SimplePcg32 & rng()
void copy(void *dst, void const *src, size_t size)
Definition: types.cpp:255
auto get() -> std::ostream &
Definition: catch.hpp:1458
bool operator<=(failed, failed)
std::vector< MessageInfo > m_messages
Definition: catch.hpp:2650
GeneratorWrapper< T > take(size_t target, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4144
#define CATCH_ERROR(...)
Definition: catch.hpp:3899
Vector::UnorderedEqualsMatcher< T, AllocComp, AllocMatch > UnorderedEquals(std::vector< T, AllocComp > const &target)
Definition: catch.hpp:3758
TakeGenerator(size_t target, GeneratorWrapper< T > &&generator)
Definition: catch.hpp:4118
bool startsWith(std::string const &s, std::string const &prefix)
Floating::WithinRelMatcher WithinRel(float target)
bool throws() const
std::string to_string(T value)
RangeGenerator(T const &start, T const &end)
Definition: catch.hpp:4672
bool operator==(MessageInfo const &other) const
auto getElapsedMilliseconds() const -> unsigned int


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:43:16