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>
1582 
1583  template<typename T>
1584  typename std::enable_if<
1588  }
1589  template<typename T>
1590  typename std::enable_if<
1593  return ex.what();
1594  }
1595 
1596  template<typename T>
1597  typename std::enable_if<
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>
1650  }
1651 
1652  template<typename 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) {
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>
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>
2240  auto operator && ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2254  auto operator == ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2261  auto operator != ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2268  auto operator > ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2275  auto operator < ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2282  auto operator >= ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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>
2289  auto operator <= ( T ) const -> BinaryExpr<LhsT, RhsT const&> const {
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 
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 
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 
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();
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 {
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<>
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;
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;
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> {
3398 public:
3399 
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()
3470  Floating::WithinRelMatcher WithinRel(float target, float eps);
3471  // defaults epsilon to 100*numeric_limits<float>::epsilon()
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 {
3489 }
3490 
3491 template <typename T>
3492 class PredicateMatcher : public MatcherBase<T> {
3493  std::function<bool(T const&)> m_predicate;
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 
3543  };
3544 
3545  struct StringMatcherBase : MatcherBase<std::string> {
3546  StringMatcherBase( std::string const& operation, CasedString const& comparator );
3547  std::string describe() const override;
3548 
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> {
3572  bool match( std::string const& matchee ) const override;
3573  std::string describe() const override;
3574 
3575  private:
3578  };
3579 
3580  } // namespace StdString
3581 
3582  // The following functions create the actual matcher objects.
3583  // This allows the types to be inferred
3584 
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:
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>
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 
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;