16 #if defined(min) && defined(max) 21 #ifndef CATCH_AMALGAMATED_HPP_INCLUDED 22 #define CATCH_AMALGAMATED_HPP_INCLUDED 38 #ifndef CATCH_ALL_HPP_INCLUDED 39 #define CATCH_ALL_HPP_INCLUDED 54 #ifndef CATCH_BENCHMARK_ALL_HPP_INCLUDED 55 #define CATCH_BENCHMARK_ALL_HPP_INCLUDED 59 #ifndef CATCH_BENCHMARK_HPP_INCLUDED 60 #define CATCH_BENCHMARK_HPP_INCLUDED 62 #ifndef CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED 63 #define CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED 81 #ifndef CATCH_PLATFORM_HPP_INCLUDED 82 #define CATCH_PLATFORM_HPP_INCLUDED 87 #ifndef __has_extension 88 #define __has_extension(x) 0 90 #include <TargetConditionals.h> 91 #if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) 92 #define CATCH_PLATFORM_MAC 93 #elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) 94 #define CATCH_PLATFORM_IPHONE 97 #elif defined(linux) || defined(__linux) || defined(__linux__) 98 #define CATCH_PLATFORM_LINUX 100 #elif defined(__QNX__) 101 #define CATCH_PLATFORM_QNX 103 #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) 104 #define CATCH_PLATFORM_WINDOWS 106 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) 107 #define CATCH_PLATFORM_WINDOWS_UWP 110 #elif defined(__ORBIS__) || defined(__PROSPERO__) 111 #define CATCH_PLATFORM_PLAYSTATION 115 #endif // CATCH_PLATFORM_HPP_INCLUDED 119 #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) 120 #define CATCH_CPP17_OR_GREATER 123 #if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) 124 #define CATCH_CPP20_OR_GREATER 131 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) && !defined(__NVCOMPILER) 132 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic push") 133 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic pop") 137 #define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ 138 _Pragma("GCC diagnostic ignored \"-Wparentheses\"") 140 #define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ 141 _Pragma("GCC diagnostic ignored \"-Wunused-result\"") 143 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 144 _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") 146 #define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 147 _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") 149 #define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ 150 _Pragma("GCC diagnostic ignored \"-Wshadow\"") 152 #define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P 156 #if defined(__NVCOMPILER) 157 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("diag push") 158 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("diag pop") 159 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma("diag_suppress declared_but_not_referenced") 162 #if defined(__CUDACC__) && !defined(__clang__) 163 #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ 165 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("nv_diagnostic push") 166 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("nv_diagnostic pop") 167 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma("nv_diag_suppress 177") 169 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS _Pragma("diag_suppress 177") 175 #if defined(__clang__) && !defined(_MSC_VER) 176 #define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P 177 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("clang diagnostic push") 178 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("clang diagnostic pop") 179 #endif // __clang__ && !_MSC_VER 181 #if defined(__clang__) 183 #define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 184 _Pragma("clang diagnostic ignored \"-Wexit-time-destructors\"") \ 185 _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") 187 #define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ 188 _Pragma("clang diagnostic ignored \"-Wparentheses\"") 190 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 191 _Pragma("clang diagnostic ignored \"-Wunused-variable\"") 193 #if (__clang_major__ >= 20) 194 #define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 195 _Pragma("clang diagnostic ignored \"-Wvariadic-macro-arguments-omitted\"") 196 #elif (__clang_major__ == 19) 197 #define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 198 _Pragma("clang diagnostic ignored \"-Wc++20-extensions\"") 200 #define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 201 _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") 204 #if (__clang_major__ >= 22) 205 #define CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS \ 206 _Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") 209 #define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 210 _Pragma("clang diagnostic ignored \"-Wunused-template\"") 212 #define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ 213 _Pragma("clang diagnostic ignored \"-Wcomma\"") 215 #define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ 216 _Pragma("clang diagnostic ignored \"-Wshadow\"") 236 #if defined(__ibmxl__) || defined(__CUDACC__) || defined(__NVCOMPILER) 237 #define CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P 242 #if defined(CATCH_PLATFORM_WINDOWS) || defined(CATCH_PLATFORM_PLAYSTATION) || defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) || defined(__OS400__) 243 #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS 245 #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS 250 #if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION) || defined(_GAMING_XBOX) 251 #define CATCH_INTERNAL_CONFIG_NO_GETENV 253 #define CATCH_INTERNAL_CONFIG_GETENV 258 #if defined(__ANDROID__) 259 #define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING 264 #if defined(__MINGW32__) 265 #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH 270 #if defined(__ORBIS__) 271 #define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE 283 #if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ 284 && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) 286 #define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING 293 #if defined(_MSC_VER) && !defined(__clang__) 297 #if !defined(__CUDACC__) 298 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 299 __pragma(warning(push)) 300 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 301 __pragma(warning(pop)) 306 #define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 307 __pragma(warning(disable : 26426)) 310 #if !defined(CATCH_PLATFORM_WINDOWS_UWP) 311 #define CATCH_INTERNAL_CONFIG_WINDOWS_SEH 315 #if defined(WINAPI_FAMILY_PARTITION) 316 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) 317 #define CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32 324 #if !defined(__clang__) // Handle Clang masquerading for msvc 325 #if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) 326 #define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 327 #endif // MSVC_TRADITIONAL 332 #if defined(_REENTRANT) || defined(_MSC_VER) 334 #define CATCH_INTERNAL_CONFIG_USE_ASYNC 339 #if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) 340 #define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED 345 #if defined(__BORLANDC__) 346 #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN 354 #if defined(UNDER_RTSS) || defined(RTX64_BUILD) 355 #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH 356 #define CATCH_INTERNAL_CONFIG_NO_ASYNC 357 #define CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32 360 #if !defined(_GLIBCXX_USE_C99_MATH_TR1) 361 #define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER 365 #if defined(__has_include) 367 #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER) 368 #define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW 372 #if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) 373 #define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL 374 #endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) 377 #if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) 379 #if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) 380 #define CATCH_INTERNAL_CONFIG_CPP17_BYTE 382 #endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) 385 #if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) 386 #if defined(__clang__) && (__clang_major__ < 8) 390 #if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) 391 #define CATCH_CONFIG_NO_CPP17_VARIANT 393 #define CATCH_INTERNAL_CONFIG_CPP17_VARIANT 394 #endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) 396 #define CATCH_INTERNAL_CONFIG_CPP17_VARIANT 397 #endif // defined(__clang__) && (__clang_major__ < 8) 398 #endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) 399 #endif // defined(__has_include) 401 #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) 402 #define CATCH_CONFIG_WINDOWS_SEH 405 #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) 406 #define CATCH_CONFIG_POSIX_SIGNALS 409 #if defined(CATCH_INTERNAL_CONFIG_GETENV) && !defined(CATCH_INTERNAL_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_GETENV) 410 #define CATCH_CONFIG_GETENV 413 #if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) 414 #define CATCH_CONFIG_CPP11_TO_STRING 417 #if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) 418 #define CATCH_CONFIG_CPP17_OPTIONAL 421 #if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) 422 #define CATCH_CONFIG_CPP17_STRING_VIEW 425 #if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) 426 #define CATCH_CONFIG_CPP17_VARIANT 429 #if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) 430 #define CATCH_CONFIG_CPP17_BYTE 433 #if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) 434 #define CATCH_INTERNAL_CONFIG_NEW_CAPTURE 437 #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) 438 #define CATCH_CONFIG_NEW_CAPTURE 441 #if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_DISABLE_EXCEPTIONS) 442 #define CATCH_CONFIG_DISABLE_EXCEPTIONS 445 #if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) 446 #define CATCH_CONFIG_POLYFILL_ISNAN 449 #if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) 450 #define CATCH_CONFIG_USE_ASYNC 453 #if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) 454 #define CATCH_CONFIG_GLOBAL_NEXTAFTER 459 #if defined(CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P) && !defined(CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P) && !defined(CATCH_CONFIG_USE_BUILTIN_CONSTANT_P) 460 #define CATCH_CONFIG_USE_BUILTIN_CONSTANT_P 463 #if defined(CATCH_CONFIG_USE_BUILTIN_CONSTANT_P) && !defined(CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P) 464 #define CATCH_INTERNAL_IGNORE_BUT_WARN(...) \ 465 (void)__builtin_constant_p(__VA_ARGS__) 468 #define CATCH_INTERNAL_IGNORE_BUT_WARN(...) 473 #if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) 474 #define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION 476 #if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) 477 #define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 479 #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) 480 #define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS 482 #if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) 483 #define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS 485 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT) 486 #define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT 488 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS) 489 #define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS 491 #if !defined(CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS) 492 #define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS 494 #if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) 495 #define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS 497 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) 498 #define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS 500 #if !defined(CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS) 501 #define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS 503 #if !defined(CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS) 504 #define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS 506 #if !defined(CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS) 507 #define CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS 510 #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) 511 #undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS 512 #elif defined(__clang__) && (__clang_major__ < 5) 513 #undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS 516 #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 517 #define CATCH_TRY if ((true)) 518 #define CATCH_CATCH_ALL if ((false)) 519 #define CATCH_CATCH_ANON(type) if ((false)) 521 #define CATCH_TRY try 522 #define CATCH_CATCH_ALL catch (...) 523 #define CATCH_CATCH_ANON(type) catch (type) 526 #if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) 527 #define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 530 #if defined(CATCH_PLATFORM_WINDOWS) && !defined(CATCH_CONFIG_COLOUR_WIN32) && !defined(CATCH_CONFIG_NO_COLOUR_WIN32) && !defined(CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32) 531 #define CATCH_CONFIG_COLOUR_WIN32 534 #if defined(CATCH_CONFIG_SHARED_LIBRARY) && defined(_MSC_VER) && !defined(CATCH_CONFIG_STATIC) 535 #ifdef Catch2_EXPORTS 536 #define CATCH_EXPORT //__declspec( dllexport ) // not needed 538 #define CATCH_EXPORT __declspec(dllimport) 544 #endif // CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED 546 #ifndef CATCH_CONTEXT_HPP_INCLUDED 547 #define CATCH_CONTEXT_HPP_INCLUDED 551 class IResultCapture;
555 IConfig const *m_config =
nullptr;
558 CATCH_EXPORT
static Context currentContext;
559 friend Context &getCurrentMutableContext();
560 friend Context const &getCurrentContext();
564 return m_resultCapture;
566 constexpr
IConfig const *getConfig()
const {
return m_config; }
568 m_resultCapture = resultCapture;
570 constexpr
void setConfig(
IConfig const *config) { m_config = config; }
573 Context &getCurrentMutableContext();
575 inline Context const &getCurrentContext() {
576 return Context::currentContext;
583 #endif // CATCH_CONTEXT_HPP_INCLUDED 585 #ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 586 #define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 588 #include <type_traits> 591 #define CATCH_MOVE(...) static_cast<std::remove_reference_t<decltype(__VA_ARGS__)> &&>(__VA_ARGS__) 594 #define CATCH_FORWARD(...) static_cast<decltype(__VA_ARGS__) &&>(__VA_ARGS__) 596 #endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 598 #ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 599 #define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 624 #endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 626 #ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED 627 #define CATCH_UNIQUE_NAME_HPP_INCLUDED 638 #ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED 639 #define CATCH_CONFIG_COUNTER_HPP_INCLUDED 641 #if (!defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L) 642 #define CATCH_INTERNAL_CONFIG_COUNTER 645 #if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) 646 #define CATCH_CONFIG_COUNTER 649 #endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED 657 #if defined(__clang__) && (__clang_major__ >= 22) && !defined(__APPLE__) 658 CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS
661 #define INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) name##line 662 #define INTERNAL_CATCH_UNIQUE_NAME_LINE(name, line) INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) 664 #ifdef CATCH_CONFIG_COUNTER 665 #define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __COUNTER__) 667 #define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __LINE__) 670 #endif // CATCH_UNIQUE_NAME_HPP_INCLUDED 672 #ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED 673 #define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED 677 #ifndef CATCH_STRINGREF_HPP_INCLUDED 678 #define CATCH_STRINGREF_HPP_INCLUDED 680 #ifndef CATCH_LIFETIMEBOUND_HPP_INCLUDED 681 #define CATCH_LIFETIMEBOUND_HPP_INCLUDED 683 #if !defined(__has_cpp_attribute) 684 #define CATCH_ATTR_LIFETIMEBOUND 685 #elif __has_cpp_attribute(msvc::lifetimebound) 686 #define CATCH_ATTR_LIFETIMEBOUND [[msvc::lifetimebound]] 687 #elif __has_cpp_attribute(clang::lifetimebound) 688 #define CATCH_ATTR_LIFETIMEBOUND [[clang::lifetimebound]] 689 #elif __has_cpp_attribute(lifetimebound) 690 #define CATCH_ATTR_LIFETIMEBOUND [[lifetimebound]] 692 #define CATCH_ATTR_LIFETIMEBOUND 695 #endif // CATCH_LIFETIMEBOUND_HPP_INCLUDED 710 using size_type = std::size_t;
711 using const_iterator =
const char *;
713 static constexpr size_type npos{
static_cast<size_type
>(-1)};
716 static constexpr
char const *
const s_empty =
"";
718 char const *m_start = s_empty;
719 size_type m_size = 0;
722 constexpr
StringRef() noexcept =
default;
724 StringRef(
char const *rawChars CATCH_ATTR_LIFETIMEBOUND) noexcept;
726 constexpr
StringRef(
char const *rawChars CATCH_ATTR_LIFETIMEBOUND,
727 size_type size) noexcept
728 : m_start(rawChars), m_size(size) {}
731 std::string
const &stdString CATCH_ATTR_LIFETIMEBOUND) noexcept
732 : m_start(stdString.c_str()), m_size(stdString.size()) {}
734 explicit operator std::string()
const {
735 return std::string(m_start, m_size);
739 auto operator==(
StringRef other)
const noexcept ->
bool {
740 return m_size == other.m_size
741 && (std::memcmp(m_start, other.m_start, m_size) == 0);
743 auto operator!=(
StringRef other)
const noexcept ->
bool {
744 return !(*
this == other);
747 constexpr
auto operator[](size_type index)
const noexcept ->
char {
748 assert(index < m_size);
749 return m_start[index];
752 bool operator<(
StringRef rhs)
const noexcept;
755 constexpr
auto empty()
const noexcept ->
bool {
758 constexpr
auto size()
const noexcept -> size_type {
765 constexpr
StringRef substr(size_type start, size_type length)
const noexcept {
766 if (start < m_size) {
767 const auto shortened_size = m_size - start;
768 return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length);
775 constexpr
char const *data()
const noexcept CATCH_ATTR_LIFETIMEBOUND {
779 constexpr const_iterator begin()
const {
return m_start; }
780 constexpr const_iterator end()
const {
return m_start + m_size; }
782 friend std::string &operator+=(std::string &lhs,
StringRef rhs);
783 friend std::ostream &operator<<(std::ostream &os,
StringRef str);
795 constexpr
auto operator""_sr(
char const *rawChars, std::size_t size) noexcept ->
StringRef {
800 constexpr
auto operator""_catch_sr(
char const *rawChars, std::size_t size) noexcept ->
Catch::StringRef {
804 #endif // CATCH_STRINGREF_HPP_INCLUDED 806 #ifndef CATCH_RESULT_TYPE_HPP_INCLUDED 807 #define CATCH_RESULT_TYPE_HPP_INCLUDED 823 ExpressionFailed = FailureBit | 1,
824 ExplicitFailure = FailureBit | 2,
826 Exception = 0x100 | FailureBit,
828 ThrewException = Exception | 1,
829 DidntThrowException = Exception | 2,
831 FatalErrorCondition = 0x200 | FailureBit
836 constexpr
bool isOk(ResultWas::OfType resultType) {
837 return (resultType & ResultWas::FailureBit) == 0;
839 constexpr
bool isJustInfo(
int flags) {
840 return flags == ResultWas::Info;
848 ContinueOnFailure = 0x02,
854 constexpr ResultDisposition::Flags operator|(ResultDisposition::Flags lhs,
855 ResultDisposition::Flags rhs) {
856 return static_cast<ResultDisposition::Flags
>(
static_cast<int>(lhs) | static_cast<int>(rhs));
859 constexpr
bool isFalseTest(
int flags) {
860 return (flags & ResultDisposition::FalseTest) != 0;
862 constexpr
bool shouldSuppressFailure(
int flags) {
863 return (flags & ResultDisposition::SuppressFail) != 0;
868 #endif // CATCH_RESULT_TYPE_HPP_INCLUDED 870 #ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED 871 #define CATCH_UNIQUE_PTR_HPP_INCLUDED 874 #include <type_traits> 888 constexpr
unique_ptr(std::nullptr_t =
nullptr)
890 explicit constexpr unique_ptr(T *ptr)
893 template<typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
895 : m_ptr(from.release()) {}
897 template<typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
899 reset(from.release());
904 unique_ptr(unique_ptr
const &) =
delete;
905 unique_ptr &operator=(unique_ptr
const &) =
delete;
907 unique_ptr(unique_ptr &&rhs) noexcept
911 unique_ptr &operator=(unique_ptr &&rhs) noexcept {
912 reset(rhs.release());
925 T
const &operator*()
const {
929 T *operator->() noexcept {
933 T
const *operator->()
const noexcept {
938 T *
get() {
return m_ptr; }
939 T
const *
get()
const {
return m_ptr; }
941 void reset(T *ptr =
nullptr) {
952 explicit operator bool()
const {
953 return m_ptr !=
nullptr;
956 friend void swap(unique_ptr &lhs, unique_ptr &rhs) {
957 auto temp = lhs.m_ptr;
958 lhs.m_ptr = rhs.m_ptr;
967 template<
typename T,
typename... Args>
975 #endif // CATCH_UNIQUE_PTR_HPP_INCLUDED 977 #ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 978 #define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 983 struct DummyTemplateArgPlaceholder;
989 template<
typename Duration = Detail::DummyTemplateArgPlaceholder>
994 #endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 1013 namespace Generators {
1014 class GeneratorUntypedBase;
1022 virtual void notifyAssertionStarted(
AssertionInfo const &info) = 0;
1023 virtual bool sectionStarted(
StringRef sectionName,
1031 acquireGeneratorTracker(
StringRef generatorName,
1035 createGeneratorTracker(
StringRef generatorName,
1040 virtual void benchmarkPreparing(
StringRef name) = 0;
1041 virtual void benchmarkStarting(
BenchmarkInfo const &info) = 0;
1043 virtual void benchmarkFailed(
StringRef error) = 0;
1045 static void pushScopedMessage(
MessageInfo &&message);
1046 static void popScopedMessage(
unsigned int messageId);
1047 static void addUnscopedMessage(
MessageInfo &&message);
1050 virtual void handleFatalErrorCondition(
StringRef message) = 0;
1057 ResultWas::OfType resultType,
1058 std::string &&message,
1061 virtual void handleUnexpectedExceptionNotThrown(
AssertionInfo const &info,
1064 virtual void handleUnexpectedInflightException(
AssertionInfo const &info,
1065 std::string &&message,
1068 virtual void handleIncomplete(
AssertionInfo const &info) = 0;
1070 ResultWas::OfType resultType,
1074 virtual bool lastAssertionPassed() = 0;
1077 virtual std::string getCurrentTestName()
const = 0;
1079 virtual void exceptionEarlyReported() = 0;
1084 void missingCaptureInstance();
1087 if (
auto *capture = getCurrentContext().getResultCapture()) {
1090 Detail::missingCaptureInstance();
1096 #endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED 1098 #ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED 1099 #define CATCH_INTERFACES_CONFIG_HPP_INCLUDED 1101 #ifndef CATCH_NONCOPYABLE_HPP_INCLUDED 1102 #define CATCH_NONCOPYABLE_HPP_INCLUDED 1122 #endif // CATCH_NONCOPYABLE_HPP_INCLUDED 1130 enum class Verbosity {
1140 NoAssertions = 0x01,
1142 UnmatchedTestSpec = 0x02,
1144 InfiniteGenerator = 0x04,
1148 enum class ShowDurations {
1153 enum class TestRunOrder {
1155 LexicographicallySorted,
1158 enum class ColourMode : std::uint8_t {
1173 BeforeStartAndExit = BeforeStart | BeforeExit
1185 virtual bool allowThrows()
const = 0;
1187 virtual bool includeSuccessfulResults()
const = 0;
1188 virtual bool shouldDebugBreak()
const = 0;
1189 virtual bool warnAboutMissingAssertions()
const = 0;
1190 virtual bool warnAboutUnmatchedTestSpecs()
const = 0;
1191 virtual bool warnAboutInfiniteGenerators()
const = 0;
1192 virtual bool zeroTestsCountAsSuccess()
const = 0;
1193 virtual int abortAfter()
const = 0;
1194 virtual bool showInvisibles()
const = 0;
1195 virtual ShowDurations showDurations()
const = 0;
1196 virtual double minDuration()
const = 0;
1197 virtual TestSpec const &testSpec()
const = 0;
1198 virtual bool hasTestFilters()
const = 0;
1199 virtual std::vector<std::string>
const &getTestsOrTags()
const = 0;
1200 virtual TestRunOrder runOrder()
const = 0;
1201 virtual uint32_t rngSeed()
const = 0;
1202 virtual unsigned int shardCount()
const = 0;
1203 virtual unsigned int shardIndex()
const = 0;
1204 virtual ColourMode defaultColourMode()
const = 0;
1205 virtual std::vector<PathFilter>
const &getPathFilters()
const = 0;
1206 virtual bool useNewFilterBehaviour()
const = 0;
1208 virtual Verbosity verbosity()
const = 0;
1210 virtual bool skipBenchmarks()
const = 0;
1211 virtual bool benchmarkNoAnalysis()
const = 0;
1212 virtual unsigned int benchmarkSamples()
const = 0;
1213 virtual double benchmarkConfidenceInterval()
const = 0;
1214 virtual unsigned int benchmarkResamples()
const = 0;
1215 virtual std::chrono::milliseconds benchmarkWarmupTime()
const = 0;
1219 #endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED 1221 #ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED 1222 #define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED 1230 class ITestCaseRegistry;
1233 class ReporterRegistry;
1234 class IReporterFactory;
1235 class ITagAliasRegistry;
1240 class StartupExceptionRegistry;
1241 class EventListenerFactory;
1249 virtual ReporterRegistry
const &getReporterRegistry()
const = 0;
1250 virtual ITestCaseRegistry
const &getTestCaseRegistry()
const = 0;
1251 virtual ITagAliasRegistry
const &getTagAliasRegistry()
const = 0;
1254 virtual StartupExceptionRegistry
const &getStartupExceptionRegistry()
const = 0;
1264 virtual void registerTagAlias(std::string
const &alias, std::string
const &tag,
SourceLineInfo const &lineInfo) = 0;
1265 virtual void registerStartupException() noexcept = 0;
1272 std::string translateActiveException();
1276 #endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED 1278 #ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED 1279 #define CATCH_BENCHMARK_STATS_HPP_INCLUDED 1283 #ifndef CATCH_CLOCK_HPP_INCLUDED 1284 #define CATCH_CLOCK_HPP_INCLUDED 1289 namespace Benchmark {
1290 using IDuration = std::chrono::nanoseconds;
1291 using FDuration = std::chrono::duration<double, std::nano>;
1293 template<
typename Clock>
1294 using TimePoint =
typename Clock::time_point;
1296 using default_clock = std::chrono::steady_clock;
1300 #endif // CATCH_CLOCK_HPP_INCLUDED 1304 #ifndef CATCH_ESTIMATE_HPP_INCLUDED 1305 #define CATCH_ESTIMATE_HPP_INCLUDED 1308 namespace Benchmark {
1309 template<
typename Type>
1314 double confidence_interval;
1319 #endif // CATCH_ESTIMATE_HPP_INCLUDED 1323 #ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 1324 #define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 1329 int samples_seen = 0;
1333 int high_severe = 0;
1335 constexpr
int total()
const {
1336 return low_severe + low_mild + high_mild + high_severe;
1342 #endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED 1353 double estimatedDuration;
1355 unsigned int samples;
1356 unsigned int resamples;
1357 double clockResolution;
1363 template<
class Dummy>
1367 std::vector<Benchmark::FDuration> samples;
1371 double outlierVariance;
1376 #endif // CATCH_BENCHMARK_STATS_HPP_INCLUDED 1380 #ifndef CATCH_ENVIRONMENT_HPP_INCLUDED 1381 #define CATCH_ENVIRONMENT_HPP_INCLUDED 1384 namespace Benchmark {
1396 #endif // CATCH_ENVIRONMENT_HPP_INCLUDED 1400 #ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED 1401 #define CATCH_EXECUTION_PLAN_HPP_INCLUDED 1405 #ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED 1406 #define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED 1410 #ifndef CATCH_CHRONOMETER_HPP_INCLUDED 1411 #define CATCH_CHRONOMETER_HPP_INCLUDED 1415 #ifndef CATCH_OPTIMIZER_HPP_INCLUDED 1416 #define CATCH_OPTIMIZER_HPP_INCLUDED 1418 #if defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) 1422 #include <type_traits> 1426 #if defined(__GNUC__) || defined(__clang__) 1427 template<
typename T>
1428 inline void keep_memory(T *p) {
1429 asm volatile(
"" : :
"g"(p) :
"memory");
1431 inline void keep_memory() {
1432 asm volatile(
"" : : :
"memory");
1436 inline void optimizer_barrier() {
1440 #elif defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__) 1442 #if defined(_MSVC_VER) 1443 #pragma optimize("", off) 1444 #elif defined(__IAR_SYSTEMS_ICC__) 1446 #pragma optimize = disable 1448 template<
typename T>
1449 inline void keep_memory(T *p) {
1451 *
reinterpret_cast<char volatile *
>(p) = *reinterpret_cast<char const volatile *>(p);
1454 #if defined(_MSVC_VER) 1455 #pragma optimize("", on) 1459 inline void optimizer_barrier() {
1460 std::atomic_thread_fence(std::memory_order_seq_cst);
1466 template<
typename T>
1467 inline void deoptimize_value(T &&x) {
1471 template<
typename Fn,
typename... Args>
1472 inline auto invoke_deoptimized(Fn &&fn, Args &&...args) -> std::enable_if_t<!std::is_same<void, decltype(fn(args...))>::value> {
1476 template<
typename Fn,
typename... Args>
1477 inline auto invoke_deoptimized(Fn &&fn, Args &&...args) -> std::enable_if_t<std::is_same<void, decltype(fn(args...))>::value> {
1483 #endif // CATCH_OPTIMIZER_HPP_INCLUDED 1485 #ifndef CATCH_META_HPP_INCLUDED 1486 #define CATCH_META_HPP_INCLUDED 1488 #include <type_traits> 1495 template<
typename Fun,
typename... Args>
1497 template<
typename...>
1498 static std::false_type
test(...);
1501 template<
typename T>
1504 template<
typename Fun,
typename... Args>
1505 struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {};
1507 #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 1510 template<
typename Func,
typename... U>
1511 using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>;
1513 template<
typename Func,
typename... U>
1514 using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::result_of_t<Func(U...)>>>;
1523 #endif // CATCH_META_HPP_INCLUDED 1526 namespace Benchmark {
1529 virtual void start() = 0;
1530 virtual void finish() = 0;
1537 template<
typename Clock>
1539 void start()
override { started = Clock::now(); }
1540 void finish()
override { finished = Clock::now(); }
1542 IDuration elapsed()
const {
1543 return std::chrono::duration_cast<std::chrono::nanoseconds>(
1544 finished - started);
1547 TimePoint<Clock> started;
1548 TimePoint<Clock> finished;
1554 template<
typename Fun>
1557 int runs()
const {
return repeats; }
1561 , repeats(repeats_) {}
1564 template<
typename Fun>
1565 void measure(Fun &&fun, std::false_type) {
1566 measure([&fun](
int) {
return fun(); }, std::true_type());
1569 template<
typename Fun>
1570 void measure(Fun &&fun, std::true_type) {
1571 Detail::optimizer_barrier();
1573 for (
int i = 0; i < repeats; ++i) invoke_deoptimized(fun, i);
1575 Detail::optimizer_barrier();
1584 #endif // CATCH_CHRONOMETER_HPP_INCLUDED 1586 #include <type_traits> 1591 template<
typename T,
typename U>
1592 static constexpr
bool is_related_v = std::is_same<std::decay_t<T>, std::decay_t<U>>::value;
1605 virtual ~callable();
1607 callable() =
default;
1608 callable(callable &&) =
default;
1609 callable &operator=(callable &&) =
default;
1611 template<
typename Fun>
1612 struct model :
public callable {
1615 model(Fun
const &fun_)
1621 void call(
Chronometer meter, std::true_type)
const {
1624 void call(
Chronometer meter, std::false_type)
const {
1634 template<
typename Fun,
1635 std::enable_if_t<!is_related_v<Fun, BenchmarkFunction>,
int> = 0>
1648 void operator()(
Chronometer meter)
const { f->call(meter); }
1657 #endif // CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED 1661 #ifndef CATCH_REPEAT_HPP_INCLUDED 1662 #define CATCH_REPEAT_HPP_INCLUDED 1664 #include <type_traits> 1669 template<
typename Fun>
1671 void operator()(
int k)
const {
1672 for (
int i = 0; i < k; ++i) {
1678 template<
typename Fun>
1686 #endif // CATCH_REPEAT_HPP_INCLUDED 1690 #ifndef CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED 1691 #define CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED 1695 #ifndef CATCH_MEASURE_HPP_INCLUDED 1696 #define CATCH_MEASURE_HPP_INCLUDED 1700 #ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED 1701 #define CATCH_COMPLETE_INVOKE_HPP_INCLUDED 1706 template<
typename T>
1715 template<
typename T>
1716 using CompleteType_t =
typename CompleteType<T>::type;
1718 template<
typename Result>
1720 template<
typename Fun,
typename... Args>
1721 static Result invoke(Fun &&fun, Args &&...args) {
1727 template<
typename Fun,
typename... Args>
1728 static CompleteType_t<void> invoke(Fun &&fun, Args &&...args) {
1735 template<
typename Fun,
typename... Args>
1736 CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun &&fun, Args &&...args) {
1742 template<
typename Fun>
1743 Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun &&fun) {
1749 #endif // CATCH_COMPLETE_INVOKE_HPP_INCLUDED 1753 #ifndef CATCH_TIMING_HPP_INCLUDED 1754 #define CATCH_TIMING_HPP_INCLUDED 1758 template<
typename Result>
1764 template<
typename Func,
typename... Args>
1765 using TimingOf =
Timing<Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>;
1769 #endif // CATCH_TIMING_HPP_INCLUDED 1774 template<
typename Clock,
typename Fun,
typename... Args>
1775 TimingOf<Fun, Args...> measure(Fun &&fun, Args &&...args) {
1776 auto start = Clock::now();
1778 auto end = Clock::now();
1779 auto delta = end - start;
1786 #endif // CATCH_MEASURE_HPP_INCLUDED 1788 #include <type_traits> 1793 template<
typename Clock,
typename Fun>
1795 return Detail::measure<Clock>(fun, iters);
1797 template<
typename Clock,
typename Fun>
1800 auto &&result = Detail::complete_invoke(fun,
Chronometer(meter, iters));
1802 return {meter.elapsed(),
CATCH_MOVE(result), iters};
1805 template<
typename Clock,
typename Fun>
1806 using run_for_at_least_argument_t = std::conditional_t<is_callable<Fun(Chronometer)>::value,
Chronometer,
int>;
1809 void throw_optimized_away_error();
1811 template<
typename Clock,
typename Fun>
1813 run_for_at_least(IDuration how_long,
1814 const int initial_iterations,
1816 auto iters = initial_iterations;
1817 while (iters < (1 << 30)) {
1820 if (
Timing.elapsed >= how_long) {
1825 throw_optimized_away_error();
1831 #endif // CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED 1838 int iterations_per_sample;
1839 FDuration estimated_duration;
1841 FDuration warmup_time;
1842 int warmup_iterations;
1844 template<
typename Clock>
1847 Detail::run_for_at_least<Clock>(
1848 std::chrono::duration_cast<IDuration>(warmup_time),
1850 Detail::repeat([]() {
return Clock::now(); }));
1852 std::vector<FDuration> times;
1853 const auto num_samples = cfg.benchmarkSamples();
1854 times.reserve(num_samples);
1855 for (
size_t i = 0; i < num_samples; ++i) {
1857 this->benchmark(
Chronometer(model, iterations_per_sample));
1858 auto sample_time = model.elapsed() - env.clock_cost.mean;
1859 if (sample_time < FDuration::zero()) {
1860 sample_time = FDuration::zero();
1862 times.push_back(sample_time / iterations_per_sample);
1870 #endif // CATCH_EXECUTION_PLAN_HPP_INCLUDED 1874 #ifndef CATCH_ESTIMATE_CLOCK_HPP_INCLUDED 1875 #define CATCH_ESTIMATE_CLOCK_HPP_INCLUDED 1879 #ifndef CATCH_STATS_HPP_INCLUDED 1880 #define CATCH_STATS_HPP_INCLUDED 1887 using sample = std::vector<double>;
1889 double weighted_average_quantile(
int k,
1895 classify_outliers(
double const *first,
double const *last);
1897 double mean(
double const *first,
double const *last);
1899 double normal_cdf(
double x);
1901 double erfc_inv(
double x);
1903 double normal_quantile(
double p);
1906 bootstrap(
double confidence_level,
1909 sample
const &resample,
1910 double (*estimator)(
double const *,
double const *));
1915 double outlier_variance;
1919 unsigned int n_resamples,
1926 #endif // CATCH_STATS_HPP_INCLUDED 1928 #include <algorithm> 1935 template<
typename Clock>
1936 std::vector<double> resolution(
int k) {
1937 const size_t points =
static_cast<size_t>(k + 1);
1940 std::vector<TimePoint<Clock>> times(points);
1941 for (
auto &time : times) {
1942 time = Clock::now();
1945 std::vector<double> deltas;
1946 deltas.reserve(static_cast<size_t>(k));
1947 for (
size_t idx = 1; idx < points; ++idx) {
1948 deltas.push_back(static_cast<double>(
1949 (times[idx] - times[idx - 1]).count()));
1955 constexpr
auto warmup_iterations = 10000;
1956 constexpr
auto warmup_time = std::chrono::milliseconds(100);
1957 constexpr
auto minimum_ticks = 1000;
1958 constexpr
auto warmup_seed = 10000;
1959 constexpr
auto clock_resolution_estimation_time = std::chrono::milliseconds(500);
1960 constexpr
auto clock_cost_estimation_time_limit = std::chrono::seconds(1);
1961 constexpr
auto clock_cost_estimation_tick_limit = 100000;
1962 constexpr
auto clock_cost_estimation_time = std::chrono::milliseconds(10);
1963 constexpr
auto clock_cost_estimation_iterations = 10000;
1965 template<
typename Clock>
1967 return run_for_at_least<Clock>(warmup_time, warmup_seed, &resolution<Clock>)
1970 template<
typename Clock>
1972 auto r = run_for_at_least<Clock>(clock_resolution_estimation_time, iterations, &resolution<Clock>)
1975 FDuration(mean(r.data(), r.data() + r.size())),
1976 classify_outliers(r.data(), r.data() + r.size()),
1979 template<
typename Clock>
1981 auto time_limit = (std::min)(
1982 resolution * clock_cost_estimation_tick_limit,
1983 FDuration(clock_cost_estimation_time_limit));
1984 auto time_clock = [](
int k) {
1985 return Detail::measure<Clock>([k] {
1986 for (
int i = 0; i < k; ++i) {
1987 volatile auto ignored = Clock::now();
1994 int iters = clock_cost_estimation_iterations;
1995 auto &&r = run_for_at_least<Clock>(clock_cost_estimation_time, iters, time_clock);
1996 std::vector<double> times;
1997 int nsamples =
static_cast<int>(std::ceil(time_limit / r.elapsed));
1998 times.reserve(static_cast<size_t>(nsamples));
1999 for (
int s = 0; s < nsamples; ++s) {
2000 times.push_back(static_cast<double>(
2001 (time_clock(r.iterations) / r.iterations)
2005 FDuration(mean(times.data(), times.data() + times.size())),
2006 classify_outliers(times.data(), times.data() + times.size()),
2010 template<
typename Clock>
2012 #if defined(__clang__) 2013 #pragma clang diagnostic push 2014 #pragma clang diagnostic ignored "-Wexit-time-destructors" 2017 #if defined(__clang__) 2018 #pragma clang diagnostic pop 2024 auto iters = Detail::warmup<Clock>();
2025 auto resolution = Detail::estimate_clock_resolution<Clock>(iters);
2026 auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean);
2028 env = Catch::Detail::make_unique<Environment>(
Environment{resolution, cost});
2035 #endif // CATCH_ESTIMATE_CLOCK_HPP_INCLUDED 2039 #ifndef CATCH_ANALYSE_HPP_INCLUDED 2040 #define CATCH_ANALYSE_HPP_INCLUDED 2044 #ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 2045 #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 2052 std::vector<FDuration> samples;
2056 double outlier_variance;
2061 #endif // CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 2073 #endif // CATCH_ANALYSE_HPP_INCLUDED 2075 #include <algorithm> 2078 #include <exception> 2088 Benchmark(std::string &&benchmarkName, FUN &&func)
2091 template<
typename Clock>
2093 auto min_time = env.clock_resolution.mean * Detail::minimum_ticks;
2094 auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime()));
2095 auto &&
test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(run_time), 1, fun);
2096 int new_iters =
static_cast<int>(std::ceil(min_time *
test.iterations /
test.elapsed));
2097 return {new_iters,
test.elapsed /
test.iterations * new_iters * cfg.benchmarkSamples(),
CATCH_MOVE(fun), std::chrono::duration_cast<FDuration>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations};
2100 template<
typename Clock = default_clock>
2102 static_assert(Clock::is_steady,
2103 "Benchmarking clock should be steady");
2104 auto const *cfg = getCurrentContext().getConfig();
2106 auto env = Detail::measure_environment<Clock>();
2108 getResultCapture().benchmarkPreparing(name);
2110 auto plan = user_code([&] {
2111 return prepare<Clock>(*cfg, env);
2116 plan.estimated_duration.count(),
2117 plan.iterations_per_sample,
2118 cfg->benchmarkSamples(),
2119 cfg->benchmarkResamples(),
2120 env.clock_resolution.mean.count(),
2121 env.clock_cost.mean.count()};
2123 getResultCapture().benchmarkStarting(info);
2125 auto samples = user_code([&] {
2126 return plan.template run<Clock>(*cfg, env);
2129 auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size());
2131 getResultCapture().benchmarkEnded(stats);
2134 getResultCapture().benchmarkFailed(translateActiveException());
2137 std::rethrow_exception(std::current_exception());
2142 template<
typename Fun, std::enable_if_t<!Detail::is_related_v<Fun, Benchmark>,
int> = 0>
2144 auto const *cfg = getCurrentContext().getConfig();
2145 if (!cfg->skipBenchmarks()) {
2152 explicit operator bool() {
2163 #define INTERNAL_CATCH_GET_1_ARG(arg1, arg2, ...) arg1 2164 #define INTERNAL_CATCH_GET_2_ARG(arg1, arg2, ...) arg2 2166 #define INTERNAL_CATCH_BENCHMARK(BenchmarkName, name, benchmarkIndex) \ 2167 if (Catch::Benchmark::Benchmark BenchmarkName{name}) \ 2168 BenchmarkName = [&](int benchmarkIndex) 2170 #define INTERNAL_CATCH_BENCHMARK_ADVANCED(BenchmarkName, name) \ 2171 if (Catch::Benchmark::Benchmark BenchmarkName{name}) \ 2174 #if defined(CATCH_CONFIG_PREFIX_ALL) 2176 #define CATCH_BENCHMARK(...) \ 2177 INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__, , ), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__, , )) 2178 #define CATCH_BENCHMARK_ADVANCED(name) \ 2179 INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), name) 2183 #define BENCHMARK(...) \ 2184 INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__, , ), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__, , )) 2185 #define BENCHMARK_ADVANCED(name) \ 2186 INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), name) 2190 #endif // CATCH_BENCHMARK_HPP_INCLUDED 2194 #ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED 2195 #define CATCH_CONSTRUCTOR_HPP_INCLUDED 2197 #include <type_traits> 2202 template<
typename T,
bool Destruct>
2207 new (&data) T(other.stored_object());
2211 new (data) T(
CATCH_MOVE(other.stored_object()));
2216 template<
typename... Args>
2217 void construct(Args &&...args) {
2221 template<
bool AllowManualDestruction = !Destruct>
2222 std::enable_if_t<AllowManualDestruction> destruct() {
2223 stored_object().~T();
2228 template<
typename U>
2229 void destruct_on_exit(std::enable_if_t<Destruct, U> * =
nullptr) { destruct<true>(); }
2231 template<
typename U>
2232 void destruct_on_exit(std::enable_if_t<!Destruct, U> * =
nullptr) {}
2234 #if defined(__GNUC__) && __GNUC__ <= 6 2235 #pragma GCC diagnostic push 2236 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 2238 T &stored_object() {
return *
reinterpret_cast<T *
>(data); }
2240 T
const &stored_object()
const {
2241 return *
reinterpret_cast<T
const *
>(data);
2243 #if defined(__GNUC__) && __GNUC__ <= 6 2244 #pragma GCC diagnostic pop 2247 alignas(T)
unsigned char data[
sizeof(T)]{};
2251 template<
typename T>
2254 template<
typename T>
2259 #endif // CATCH_CONSTRUCTOR_HPP_INCLUDED 2261 #endif // CATCH_BENCHMARK_ALL_HPP_INCLUDED 2263 #ifndef CATCH_APPROX_HPP_INCLUDED 2264 #define CATCH_APPROX_HPP_INCLUDED 2266 #ifndef CATCH_TOSTRING_HPP_INCLUDED 2267 #define CATCH_TOSTRING_HPP_INCLUDED 2272 #include <type_traits> 2283 #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED 2284 #define CATCH_CONFIG_WCHAR_HPP_INCLUDED 2289 #if defined(__DJGPP__) 2290 #define CATCH_INTERNAL_CONFIG_NO_WCHAR 2293 #if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) 2294 #define CATCH_CONFIG_WCHAR 2297 #endif // CATCH_CONFIG_WCHAR_HPP_INCLUDED 2299 #ifndef CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED 2300 #define CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED 2310 std::size_t m_index;
2311 std::ostream *m_oss;
2318 std::string str()
const;
2320 void str(std::string
const &str);
2322 #if defined(__GNUC__) && !defined(__clang__) 2323 #pragma GCC diagnostic push 2325 #pragma GCC diagnostic ignored "-Wpragmas" 2330 #pragma GCC diagnostic ignored "-Waddress" 2331 #pragma GCC diagnostic ignored "-Wnonnull-compare" 2334 template<
typename T>
2340 #if defined(__GNUC__) && !defined(__clang__) 2341 #pragma GCC diagnostic pop 2343 auto get() -> std::ostream & {
return *m_oss; }
2347 #endif // CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED 2349 #ifndef CATCH_VOID_TYPE_HPP_INCLUDED 2350 #define CATCH_VOID_TYPE_HPP_INCLUDED 2355 template<
typename...>
2360 template<
typename... Ts>
2361 using void_t =
typename make_void<Ts...>::type;
2366 #endif // CATCH_VOID_TYPE_HPP_INCLUDED 2368 #ifndef CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED 2369 #define CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED 2378 std::vector<std::pair<int, StringRef>> m_values;
2392 template<
typename E>
2394 static_assert(
sizeof(
int) >=
sizeof(E),
"Cannot serialize enum to int");
2395 std::vector<int> intValues;
2396 intValues.reserve(values.size());
2397 for (
auto enumValue : values)
2398 intValues.push_back(static_cast<int>(enumValue));
2399 return registerEnum(enumName, allEnums, intValues);
2405 #endif // CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED 2407 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW 2408 #include <string_view> 2412 #pragma warning(push) 2413 #pragma warning(disable : 4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless 2427 std::size_t catch_strnlen(
const char *str, std::size_t n);
2429 std::string formatTimeT(std::time_t time);
2431 constexpr StringRef unprintableString =
"{?}"_sr;
2434 std::string convertIntoString(StringRef
string,
bool escapeInvisibles);
2438 std::string convertIntoString(StringRef
string);
2440 std::string rawMemoryToString(
const void *
object, std::size_t size);
2442 template<
typename T>
2443 std::string rawMemoryToString(
const T &
object) {
2444 return rawMemoryToString(&
object,
sizeof(
object));
2447 template<
typename T,
typename =
void>
2448 static constexpr
bool IsStreamInsertable_v =
false;
2450 template<
typename T>
2451 static constexpr
bool IsStreamInsertable_v<
2453 decltype(
void(std::declval<std::ostream &>() << std::declval<T>()))>
2456 template<
typename E>
2457 std::string convertUnknownEnumToString(E e);
2459 template<
typename T>
2461 !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,
2463 convertUnstreamable(T
const &) {
2464 return std::string(Detail::unprintableString);
2466 template<
typename T>
2468 !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value,
2470 convertUnstreamable(T
const &ex) {
2474 template<
typename T>
2476 std::is_enum<T>::value,
2478 convertUnstreamable(T
const &value) {
2479 return convertUnknownEnumToString(value);
2482 #if defined(_MANAGED) 2483 template<
typename T>
2485 std::string clrReferenceToString(T ^ ref) {
2487 return std::string(
"null");
2488 auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString());
2489 cli::pin_ptr<System::Byte> p = &bytes[0];
2490 return std::string(reinterpret_cast<char const *>(p), bytes->Length);
2496 template<
typename T,
typename =
void>
2498 template<
typename Fake = T>
2499 static std::enable_if_t<::Catch::Detail::IsStreamInsertable_v<Fake>, std::string>
2500 convert(
const Fake &value) {
2504 rss.operator<<(value);
2508 template<
typename Fake = T>
2509 static std::enable_if_t<!::Catch::Detail::IsStreamInsertable_v<Fake>, std::string>
2510 convert(
const Fake &value) {
2511 #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) 2512 return Detail::convertUnstreamable(value);
2514 return CATCH_CONFIG_FALLBACK_STRINGIFIER(value);
2521 std::string makeExceptionHappenedString();
2525 template<
typename T>
2526 std::string stringify(
const T &e) {
2528 return ::Catch::StringMaker<
2529 std::remove_cv_t<std::remove_reference_t<T>>>::convert(e);
2532 return makeExceptionHappenedString();
2536 template<
typename E>
2537 std::string convertUnknownEnumToString(E e) {
2538 return ::Catch::Detail::stringify(
static_cast<std::underlying_type_t<E>
>(e));
2541 #if defined(_MANAGED) 2542 template<
typename T>
2543 std::string stringify(T ^ e) {
2544 return ::Catch::StringMaker<T ^>::convert(e);
2554 static std::string convert(
const std::string &str);
2557 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW 2560 static std::string convert(std::string_view str);
2566 static std::string convert(
char const *str);
2570 static std::string convert(
char *str);
2573 #if defined(CATCH_CONFIG_WCHAR) 2576 static std::string convert(
const std::wstring &wstr);
2579 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW 2582 static std::string convert(std::wstring_view str);
2588 static std::string convert(
wchar_t const *str);
2592 static std::string convert(
wchar_t *str);
2594 #endif // CATCH_CONFIG_WCHAR 2598 static std::string convert(
char const *str) {
2599 return Detail::convertIntoString(
2600 StringRef(str, Detail::catch_strnlen(str, SZ)));
2605 static std::string convert(
signed char const *str) {
2606 auto reinterpreted =
reinterpret_cast<char const *
>(str);
2607 return Detail::convertIntoString(
2608 StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ)));
2613 static std::string convert(
unsigned char const *str) {
2614 auto reinterpreted =
reinterpret_cast<char const *
>(str);
2615 return Detail::convertIntoString(
2616 StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ)));
2620 #if defined(CATCH_CONFIG_CPP17_BYTE) 2623 static std::string convert(std::byte value);
2625 #endif // defined(CATCH_CONFIG_CPP17_BYTE) 2628 static std::string convert(
int value);
2632 static std::string convert(
long value);
2636 static std::string convert(
long long value);
2640 static std::string convert(
unsigned int value);
2644 static std::string convert(
unsigned long value);
2648 static std::string convert(
unsigned long long value);
2653 static std::string convert(
bool b) {
2654 using namespace std::string_literals;
2655 return b ?
"true"s :
"false"s;
2661 static std::string convert(
char c);
2665 static std::string convert(
signed char value);
2669 static std::string convert(
unsigned char value);
2674 static std::string convert(std::nullptr_t) {
2675 using namespace std::string_literals;
2682 static std::string convert(
float value);
2683 CATCH_EXPORT
static int precision;
2688 static std::string convert(
double value);
2689 CATCH_EXPORT
static int precision;
2692 template<
typename T>
2694 template<
typename U>
2695 static std::string convert(U *p) {
2697 return ::Catch::Detail::rawMemoryToString(p);
2704 template<
typename R,
typename C>
2706 static std::string convert(R C::*p) {
2708 return ::Catch::Detail::rawMemoryToString(p);
2715 #if defined(_MANAGED) 2716 template<
typename T>
2718 static std::string convert(T ^ ref) {
2719 return ::Catch::Detail::clrReferenceToString(ref);
2725 template<
typename InputIterator,
typename Sentinel = InputIterator>
2726 std::string rangeToString(InputIterator first, Sentinel last) {
2729 if (first != last) {
2730 rss << ::Catch::Detail::stringify(*first);
2731 for (++first; first != last; ++first)
2732 rss <<
", " << ::Catch::Detail::stringify(*first);
2745 #if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS) 2746 #define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER 2747 #define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER 2748 #define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER 2749 #define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER 2753 #if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER) 2756 template<
typename T1,
typename T2>
2758 static std::string convert(
const std::pair<T1, T2> &pair) {
2761 << ::Catch::Detail::stringify(pair.first)
2763 << ::Catch::Detail::stringify(pair.second)
2769 #endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER 2771 #if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL) 2774 template<
typename T>
2776 static std::string convert(
const std::optional<T> &optional) {
2777 if (optional.has_value()) {
2778 return ::Catch::Detail::stringify(*optional);
2786 static std::string convert(
const std::nullopt_t &) {
2791 #endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER 2794 #if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER) 2799 template<
typename Tuple, std::size_t... Is>
2800 void PrintTuple(
const Tuple &tuple,
2802 std::index_sequence<Is...>) {
2804 char a[1 +
sizeof...(Is)] = {
2805 ((os << (Is ?
", " :
" ")
2806 << ::Catch::Detail::stringify(std::get<Is>(tuple))),
2813 template<
typename... Types>
2815 static std::string convert(
const std::tuple<Types...> &tuple) {
2821 std::make_index_sequence<
sizeof...(Types)>{});
2827 #endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER 2829 #if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT) 2834 static std::string convert(
const std::monostate &) {
2839 template<
typename... Elements>
2841 static std::string convert(
const std::variant<Elements...> &variant) {
2842 if (variant.valueless_by_exception()) {
2843 return "{valueless variant}";
2846 [](
const auto &value) {
2847 return ::Catch::Detail::stringify(value);
2854 #endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER 2862 template<
typename T,
typename =
void>
2865 template<
typename T>
2866 struct is_range_impl<T, void_t<decltype(begin(std::declval<T>()))>> : std::true_type {};
2869 template<
typename T>
2872 #if defined(_MANAGED) // Managed types are never ranges 2873 template<
typename T>
2875 static const bool value =
false;
2879 template<
typename Range>
2880 std::string rangeToString(Range
const &range) {
2881 return ::Catch::Detail::rangeToString(begin(range), end(range));
2885 template<
typename Allocator>
2886 std::string rangeToString(std::vector<bool, Allocator>
const &v) {
2895 rss << ::Catch::Detail::stringify(b);
2901 template<
typename R>
2902 struct StringMaker<R, std::enable_if_t<is_range<R>::value && !::Catch::Detail::IsStreamInsertable_v<R>>> {
2903 static std::string convert(R
const &range) {
2904 return rangeToString(range);
2908 template<
typename T,
size_t SZ>
2910 static std::string convert(T
const (&arr)[SZ]) {
2911 return rangeToString(arr);
2924 template<
class Ratio>
2926 static std::string symbol() {
2928 rss <<
'[' << Ratio::num <<
'/' 2929 << Ratio::den <<
']';
2936 static char symbol() {
return 'a'; }
2940 static char symbol() {
return 'f'; }
2944 static char symbol() {
return 'p'; }
2948 static char symbol() {
return 'n'; }
2952 static char symbol() {
return 'u'; }
2956 static char symbol() {
return 'm'; }
2961 template<
typename Value,
typename Ratio>
2963 static std::string convert(std::chrono::duration<Value, Ratio>
const &duration) {
2969 template<
typename Value>
2971 static std::string convert(std::chrono::duration<Value, std::ratio<1>>
const &duration) {
2973 rss << duration.count() <<
" s";
2977 template<
typename Value>
2979 static std::string convert(std::chrono::duration<Value, std::ratio<60>>
const &duration) {
2981 rss << duration.count() <<
" m";
2985 template<
typename Value>
2987 static std::string convert(std::chrono::duration<Value, std::ratio<3600>>
const &duration) {
2989 rss << duration.count() <<
" h";
2997 template<
typename Clock,
typename Duration>
2999 static std::string convert(std::chrono::time_point<Clock, Duration>
const &time_point) {
3000 return ::Catch::Detail::stringify(time_point.time_since_epoch()) +
" since epoch";
3004 template<
typename Duration>
3005 struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> {
3006 static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration>
const &time_point) {
3007 const auto systemish = std::chrono::time_point_cast<
3008 std::chrono::system_clock::duration>(time_point);
3009 const auto as_time_t = std::chrono::system_clock::to_time_t(systemish);
3010 return ::Catch::Detail::formatTimeT(as_time_t);
3015 #define INTERNAL_CATCH_REGISTER_ENUM(enumName, ...) \ 3018 struct StringMaker<enumName> { \ 3019 static std::string convert(enumName value) { \ 3020 static const auto &enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum(#enumName, #__VA_ARGS__, {__VA_ARGS__}); \ 3021 return static_cast<std::string>(enumInfo.lookup(static_cast<int>(value))); \ 3026 #define CATCH_REGISTER_ENUM(enumName, ...) INTERNAL_CATCH_REGISTER_ENUM(enumName, __VA_ARGS__) 3029 #pragma warning(pop) 3032 #endif // CATCH_TOSTRING_HPP_INCLUDED 3034 #include <type_traits> 3040 bool equalityComparisonImpl(
double other)
const;
3042 void setMargin(
double margin);
3044 void setEpsilon(
double epsilon);
3047 explicit Approx(
double value);
3051 Approx operator-()
const;
3053 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3054 Approx operator()(T
const &value)
const {
3055 Approx approx(static_cast<double>(value));
3056 approx.m_epsilon = m_epsilon;
3057 approx.m_margin = m_margin;
3058 approx.m_scale = m_scale;
3062 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3063 explicit Approx(T
const &value)
3064 : Approx(static_cast<double>(value)) {}
3066 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3067 friend bool operator==(
const T &lhs, Approx
const &rhs) {
3068 auto lhs_v =
static_cast<double>(lhs);
3069 return rhs.equalityComparisonImpl(lhs_v);
3072 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3073 friend bool operator==(Approx
const &lhs,
const T &rhs) {
3074 return operator==(rhs, lhs);
3077 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3078 friend bool operator!=(T
const &lhs, Approx
const &rhs) {
3079 return !operator==(lhs, rhs);
3082 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3083 friend bool operator!=(Approx
const &lhs, T
const &rhs) {
3084 return !operator==(rhs, lhs);
3087 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3088 friend bool operator<=(T
const &lhs, Approx
const &rhs) {
3089 return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;
3092 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3093 friend bool operator<=(Approx
const &lhs, T
const &rhs) {
3094 return lhs.m_value <
static_cast<double>(rhs) || lhs == rhs;
3097 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3098 friend bool operator>=(T
const &lhs, Approx
const &rhs) {
3099 return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;
3102 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3103 friend bool operator>=(Approx
const &lhs, T
const &rhs) {
3104 return lhs.m_value >
static_cast<double>(rhs) || lhs == rhs;
3107 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3108 Approx &epsilon(T
const &newEpsilon) {
3109 const auto epsilonAsDouble =
static_cast<double>(newEpsilon);
3110 setEpsilon(epsilonAsDouble);
3114 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3115 Approx &margin(T
const &newMargin) {
3116 const auto marginAsDouble =
static_cast<double>(newMargin);
3117 setMargin(marginAsDouble);
3121 template<typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3122 Approx &scale(T
const &newScale) {
3123 m_scale =
static_cast<double>(newScale);
3127 std::string toString()
const;
3136 namespace literals {
3137 Approx operator""_a(
long double val);
3138 Approx operator""_a(
unsigned long long val);
3148 #endif // CATCH_APPROX_HPP_INCLUDED 3150 #ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED 3151 #define CATCH_ASSERTION_INFO_HPP_INCLUDED 3153 #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 3154 #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 3163 constexpr
SourceLineInfo(
char const *_file, std::size_t _line) noexcept
3164 : file(_file), line(_line) {}
3172 friend std::ostream &operator<<(std::ostream &os,
SourceLineInfo const &info);
3176 #define CATCH_INTERNAL_LINEINFO \ 3177 ::Catch::SourceLineInfo(__FILE__, static_cast<std::size_t>(__LINE__)) 3179 #endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 3189 ResultDisposition::Flags resultDisposition;
3194 #endif // CATCH_ASSERTION_INFO_HPP_INCLUDED 3196 #ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED 3197 #define CATCH_ASSERTION_RESULT_HPP_INCLUDED 3199 #ifndef CATCH_LAZY_EXPR_HPP_INCLUDED 3200 #define CATCH_LAZY_EXPR_HPP_INCLUDED 3210 friend struct AssertionStats;
3211 friend class RunContext;
3218 : m_isNegated(isNegated) {}
3219 constexpr LazyExpression(LazyExpression
const &other) =
default;
3220 LazyExpression &operator=(LazyExpression
const &) =
delete;
3222 constexpr
explicit operator bool()
const {
3223 return m_transientExpression !=
nullptr;
3226 friend auto operator<<(std::ostream &os, LazyExpression
const &lazyExpr) -> std::ostream &;
3231 #endif // CATCH_LAZY_EXPR_HPP_INCLUDED 3242 std::string message;
3243 mutable std::string reconstructedExpression;
3245 ResultWas::OfType resultType;
3247 std::string reconstructExpression()
const;
3256 bool succeeded()
const;
3257 ResultWas::OfType getResultType()
const;
3258 bool hasExpression()
const;
3259 bool hasMessage()
const;
3260 std::string getExpression()
const;
3261 std::string getExpressionInMacro()
const;
3262 bool hasExpandedExpression()
const;
3263 std::string getExpandedExpression()
const;
3275 #endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED 3277 #ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED 3278 #define CATCH_CASE_SENSITIVE_HPP_INCLUDED 3282 enum class CaseSensitive { Yes,
3287 #endif // CATCH_CASE_SENSITIVE_HPP_INCLUDED 3289 #ifndef CATCH_CONFIG_HPP_INCLUDED 3290 #define CATCH_CONFIG_HPP_INCLUDED 3292 #ifndef CATCH_TEST_SPEC_HPP_INCLUDED 3293 #define CATCH_TEST_SPEC_HPP_INCLUDED 3296 #pragma clang diagnostic push 3297 #pragma clang diagnostic ignored "-Wpadded" 3300 #ifndef CATCH_WILDCARD_PATTERN_HPP_INCLUDED 3301 #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED 3307 enum WildcardPosition {
3309 WildcardAtStart = 1,
3311 WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
3315 WildcardPattern(std::string
const &pattern, CaseSensitive caseSensitivity);
3316 bool matches(std::string
const &str)
const;
3319 std::string normaliseString(std::string
const &str)
const;
3320 CaseSensitive m_caseSensitivity;
3321 WildcardPosition m_wildcard = NoWildcard;
3322 std::string m_pattern;
3326 #endif // CATCH_WILDCARD_PATTERN_HPP_INCLUDED 3341 explicit Pattern(std::string
const &name);
3343 virtual bool matches(
TestCaseInfo const &testCase)
const = 0;
3344 std::string
const &name()
const;
3347 virtual void serializeTo(std::ostream &out)
const = 0;
3349 friend std::ostream &operator<<(std::ostream &out,
3350 Pattern
const &pattern) {
3351 pattern.serializeTo(out);
3355 std::string
const m_name;
3358 class NamePattern :
public Pattern {
3360 explicit NamePattern(std::string
const &name, std::string
const &filterString);
3361 bool matches(
TestCaseInfo const &testCase)
const override;
3364 void serializeTo(std::ostream &out)
const override;
3369 class TagPattern :
public Pattern {
3371 explicit TagPattern(std::string
const &tag, std::string
const &filterString);
3372 bool matches(
TestCaseInfo const &testCase)
const override;
3375 void serializeTo(std::ostream &out)
const override;
3381 std::vector<Detail::unique_ptr<Pattern>> m_required;
3382 std::vector<Detail::unique_ptr<Pattern>> m_forbidden;
3386 void serializeTo(std::ostream &out)
const;
3387 friend std::ostream &operator<<(std::ostream &out, Filter
const &f) {
3395 static std::string extractFilterName(Filter
const &filter);
3400 std::vector<TestCaseHandle const *> tests;
3402 using Matches = std::vector<FilterMatch>;
3403 using vectorStrings = std::vector<std::string>;
3405 bool hasFilters()
const;
3407 Matches matchesByFilter(std::vector<TestCaseHandle>
const &testCases,
IConfig const &config)
const;
3408 const vectorStrings &getInvalidSpecs()
const;
3411 std::vector<Filter> m_filters;
3412 std::vector<std::string> m_invalidSpecs;
3414 friend class TestSpecParser;
3417 void serializeTo(std::ostream &out)
const;
3418 friend std::ostream &operator<<(std::ostream &out,
3420 spec.serializeTo(out);
3427 #pragma clang diagnostic pop 3430 #endif // CATCH_TEST_SPEC_HPP_INCLUDED 3432 #ifndef CATCH_OPTIONAL_HPP_INCLUDED 3433 #define CATCH_OPTIONAL_HPP_INCLUDED 3440 template<
typename T>
3444 : nullableValue(
nullptr) {}
3448 : nullableValue(
new (storage) T(_value)) {}
3450 : nullableValue(
new (storage) T(
CATCH_MOVE(_value))) {}
3452 Optional &operator=(T
const &_value) {
3454 nullableValue =
new (storage) T(_value);
3459 nullableValue =
new (storage) T(
CATCH_MOVE(_value));
3464 : nullableValue(_other ?
new (storage) T(*_other) :
nullptr) {}
3466 : nullableValue(_other ?
new (storage) T(
CATCH_MOVE(*_other))
3470 if (&_other !=
this) {
3472 if (_other) { nullableValue =
new (storage) T(*_other); }
3477 if (&_other !=
this) {
3480 nullableValue =
new (storage) T(
CATCH_MOVE(*_other));
3487 if (nullableValue) { nullableValue->~T(); }
3488 nullableValue =
nullptr;
3492 assert(nullableValue);
3493 return *nullableValue;
3495 T
const &operator*()
const {
3496 assert(nullableValue);
3497 return *nullableValue;
3500 assert(nullableValue);
3501 return nullableValue;
3503 const T *operator->()
const {
3504 assert(nullableValue);
3505 return nullableValue;
3508 T valueOr(T
const &defaultValue)
const {
3509 return nullableValue ? *nullableValue : defaultValue;
3512 bool some()
const {
return nullableValue !=
nullptr; }
3513 bool none()
const {
return nullableValue ==
nullptr; }
3515 bool operator!()
const {
return nullableValue ==
nullptr; }
3516 explicit operator bool()
const {
3521 if (a.none() && b.none()) {
3523 }
else if (a.some() && b.some()) {
3535 alignas(
alignof(T))
char storage[
sizeof(T)];
3540 #endif // CATCH_OPTIONAL_HPP_INCLUDED 3542 #ifndef CATCH_PATH_FILTER_HPP_INCLUDED 3543 #define CATCH_PATH_FILTER_HPP_INCLUDED 3555 : type(type_), filter(
CATCH_MOVE(filter_)) {}
3565 #endif // CATCH_PATH_FILTER_HPP_INCLUDED 3567 #ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 3568 #define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 3574 enum class GenerateFrom {
3581 std::uint32_t generateRandomSeed(GenerateFrom from);
3585 #endif // CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 3587 #ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED 3588 #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED 3596 enum class ColourMode : std::uint8_t;
3600 std::vector<std::string> splitReporterSpec(
StringRef reporterSpec);
3617 std::map<std::string, std::string> m_customOptions;
3623 return !(lhs == rhs);
3631 std::map<std::string, std::string> customOptions);
3633 std::string
const &name()
const {
return m_name; }
3636 return m_outputFileName;
3641 std::map<std::string, std::string>
const &customOptions()
const {
3642 return m_customOptions;
3660 #endif // CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED 3678 std::string outputFilename;
3679 ColourMode colourMode;
3680 std::map<std::string, std::string> customOptions;
3685 return !(lhs == rhs);
3690 bool listTests =
false;
3691 bool listTags =
false;
3692 bool listReporters =
false;
3693 bool listListeners =
false;
3695 bool showSuccessfulTests =
false;
3696 bool shouldDebugBreak =
false;
3697 bool noThrow =
false;
3698 bool showHelp =
false;
3699 bool showInvisibles =
false;
3700 bool filenamesAsTags =
false;
3701 bool libIdentify =
false;
3702 bool allowZeroTests =
false;
3704 int abortAfter = -1;
3705 uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
3707 unsigned int shardCount = 1;
3708 unsigned int shardIndex = 0;
3710 bool skipBenchmarks =
false;
3711 bool benchmarkNoAnalysis =
false;
3712 unsigned int benchmarkSamples = 100;
3713 double benchmarkConfidenceInterval = 0.95;
3714 unsigned int benchmarkResamples = 100
'000; 3715 std::chrono::milliseconds::rep benchmarkWarmupTime = 100; 3717 Verbosity verbosity = Verbosity::Normal; 3718 WarnAbout::What warnings = WarnAbout::Nothing; 3719 ShowDurations showDurations = ShowDurations::DefaultForReporter; 3720 double minDuration = -1; 3721 TestRunOrder runOrder = TestRunOrder::Randomized; 3722 ColourMode defaultColourMode = ColourMode::PlatformDefault; 3723 WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; 3725 std::string defaultOutputFilename; 3727 std::string processName; 3728 std::vector<ReporterSpec> reporterSpecifications; 3730 std::vector<std::string> testsOrTags; 3731 std::vector<PathFilter> pathFilters; 3732 bool useNewPathFilteringBehaviour = false; 3734 std::string prematureExitGuardFilePath; 3737 class Config : public IConfig { 3740 Config(ConfigData const &data); 3741 ~Config() override; // = default in the cpp file 3743 bool listTests() const; 3744 bool listTags() const; 3745 bool listReporters() const; 3746 bool listListeners() const; 3748 std::vector<ReporterSpec> const &getReporterSpecs() const; 3749 std::vector<ProcessedReporterSpec> const & 3750 getProcessedReporterSpecs() const; 3752 std::vector<std::string> const &getTestsOrTags() const override; 3753 std::vector<PathFilter> const &getPathFilters() const override; 3754 bool useNewFilterBehaviour() const override; 3756 TestSpec const &testSpec() const override; 3757 bool hasTestFilters() const override; 3759 bool showHelp() const; 3761 std::string const &getExitGuardFilePath() const; 3763 // IConfig interface 3764 bool allowThrows() const override; 3765 StringRef name() const override; 3766 bool includeSuccessfulResults() const override; 3767 bool warnAboutMissingAssertions() const override; 3768 bool warnAboutUnmatchedTestSpecs() const override; 3769 bool warnAboutInfiniteGenerators() const override; 3770 bool zeroTestsCountAsSuccess() const override; 3771 ShowDurations showDurations() const override; 3772 double minDuration() const override; 3773 TestRunOrder runOrder() const override; 3774 uint32_t rngSeed() const override; 3775 unsigned int shardCount() const override; 3776 unsigned int shardIndex() const override; 3777 ColourMode defaultColourMode() const override; 3778 bool shouldDebugBreak() const override; 3779 int abortAfter() const override; 3780 bool showInvisibles() const override; 3781 Verbosity verbosity() const override; 3782 bool skipBenchmarks() const override; 3783 bool benchmarkNoAnalysis() const override; 3784 unsigned int benchmarkSamples() const override; 3785 double benchmarkConfidenceInterval() const override; 3786 unsigned int benchmarkResamples() const override; 3787 std::chrono::milliseconds benchmarkWarmupTime() const override; 3790 // Reads Bazel env vars and applies them to the config 3791 void readBazelEnvVars(); 3794 std::vector<ProcessedReporterSpec> m_processedReporterSpecs; 3795 TestSpec m_testSpec; 3796 bool m_hasTestFilters = false; 3798 } // end namespace Catch 3800 #endif // CATCH_CONFIG_HPP_INCLUDED 3802 #ifndef CATCH_GET_RANDOM_SEED_HPP_INCLUDED 3803 #define CATCH_GET_RANDOM_SEED_HPP_INCLUDED 3809 std::uint32_t getSeed(); 3810 } // namespace Catch 3812 #endif // CATCH_GET_RANDOM_SEED_HPP_INCLUDED 3814 #ifndef CATCH_MESSAGE_HPP_INCLUDED 3815 #define CATCH_MESSAGE_HPP_INCLUDED 3828 #ifndef CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 3829 #define CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 3831 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_PREFIX_MESSAGES) 3832 #define CATCH_CONFIG_PREFIX_MESSAGES 3835 #endif // CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 3837 #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED 3838 #define CATCH_STREAM_END_STOP_HPP_INCLUDED 3842 // Use this in variadic streaming macros to allow 3843 // << +StreamEndStop 3845 // << stuff +StreamEndStop 3846 struct StreamEndStop { 3847 constexpr StringRef operator+() const { return StringRef(); } 3849 template<typename T> 3850 constexpr friend T const &operator+(T const &value, StreamEndStop) { 3855 } // namespace Catch 3857 #endif // CATCH_STREAM_END_STOP_HPP_INCLUDED 3859 #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED 3860 #define CATCH_MESSAGE_INFO_HPP_INCLUDED 3862 #ifndef CATCH_DEPRECATION_MACRO_HPP_INCLUDED 3863 #define CATCH_DEPRECATION_MACRO_HPP_INCLUDED 3865 #if !defined(CATCH_CONFIG_NO_DEPRECATION_ANNOTATIONS) 3866 #define CATCH_DEPRECATED(msg) [[deprecated(msg)]] 3868 #define CATCH_DEPRECATED(msg) 3871 #endif // CATCH_DEPRECATION_MACRO_HPP_INCLUDED 3877 struct MessageInfo { 3878 MessageInfo(StringRef _macroName, 3879 SourceLineInfo const &_lineInfo, 3880 ResultWas::OfType _type); 3882 StringRef macroName; 3883 std::string message; 3884 SourceLineInfo lineInfo; 3885 ResultWas::OfType type; 3886 // The "ID" of the message, used to know when to remove it from reporter context. 3887 unsigned int sequence; 3889 CATCH_DEPRECATED("Explicitly use the 'sequence
' member instead") 3890 bool operator==(MessageInfo const &other) const { 3891 return sequence == other.sequence; 3893 CATCH_DEPRECATED("Explicitly use the 'sequence
' member instead") 3894 bool operator<(MessageInfo const &other) const { 3895 return sequence < other.sequence; 3899 } // end namespace Catch 3901 #endif // CATCH_MESSAGE_INFO_HPP_INCLUDED 3908 struct SourceLineInfo; 3909 class IResultCapture; 3911 struct MessageStream { 3912 template<typename T> 3913 MessageStream &operator<<(T const &value) { 3918 ReusableStringStream m_stream; 3921 struct MessageBuilder : MessageStream { 3922 MessageBuilder(StringRef macroName, 3923 SourceLineInfo const &lineInfo, 3924 ResultWas::OfType type) 3925 : m_info(macroName, lineInfo, type) {} 3927 template<typename T> 3928 MessageBuilder &&operator<<(T const &value) && { 3930 return CATCH_MOVE(*this); 3936 class ScopedMessage { 3938 explicit ScopedMessage(MessageBuilder &&builder); 3939 ScopedMessage(ScopedMessage &duplicate) = delete; 3940 ScopedMessage(ScopedMessage &&old) noexcept; 3943 unsigned int m_messageId; 3944 bool m_moved = false; 3948 std::vector<MessageInfo> m_messages; 3949 size_t m_captured = 0; 3950 bool m_isScoped = false; 3953 Capturer(StringRef macroName, SourceLineInfo const &lineInfo, ResultWas::OfType resultType, StringRef names, bool isScoped); 3955 Capturer(Capturer const &) = delete; 3956 Capturer &operator=(Capturer const &) = delete; 3960 void captureValue(size_t index, std::string const &value); 3962 template<typename T> 3963 void captureValues(size_t index, T const &value) { 3964 captureValue(index, Catch::Detail::stringify(value)); 3967 template<typename T, typename... Ts> 3968 void captureValues(size_t index, T const &value, Ts const &...values) { 3969 captureValue(index, Catch::Detail::stringify(value)); 3970 captureValues(index + 1, values...); 3974 } // end namespace Catch 3977 #define INTERNAL_CATCH_MSG(macroName, messageType, resultDisposition, ...) \ 3979 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition); \ 3980 catchAssertionHandler.handleMessage(messageType, (Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop()).m_stream.str()); \ 3981 catchAssertionHandler.complete(); \ 3985 #define INTERNAL_CATCH_CAPTURE(varName, macroName, scopedCapture, ...) \ 3986 Catch::Capturer varName(macroName##_catch_sr, \ 3987 CATCH_INTERNAL_LINEINFO, \ 3988 Catch::ResultWas::Info, \ 3989 #__VA_ARGS__##_catch_sr, \ 3991 varName.captureValues(0, __VA_ARGS__) 3994 #define INTERNAL_CATCH_INFO(macroName, log) \ 3995 const Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME(scopedMessage)(Catch::MessageBuilder(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info) << log) 3998 #define INTERNAL_CATCH_UNSCOPED_INFO(macroName, log) \ 3999 Catch::IResultCapture::emplaceUnscopedMessage(Catch::MessageBuilder(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info) << log) 4001 #if defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) 4003 #define CATCH_INFO(msg) INTERNAL_CATCH_INFO("CATCH_INFO", msg) 4004 #define CATCH_UNSCOPED_INFO(msg) INTERNAL_CATCH_UNSCOPED_INFO("CATCH_UNSCOPED_INFO", msg) 4005 #define CATCH_WARN(msg) INTERNAL_CATCH_MSG("CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg) 4006 #define CATCH_CAPTURE(...) INTERNAL_CATCH_CAPTURE(INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", true, __VA_ARGS__) 4007 #define CATCH_UNSCOPED_CAPTURE(...) INTERNAL_CATCH_CAPTURE(INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_UNSCOPED_CAPTURE", false, __VA_ARGS__) 4009 #elif defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) 4011 #define CATCH_INFO(msg) (void)(0) 4012 #define CATCH_UNSCOPED_INFO(msg) (void)(0) 4013 #define CATCH_WARN(msg) (void)(0) 4014 #define CATCH_CAPTURE(...) (void)(0) 4015 #define CATCH_UNSCOPED_CAPTURE(...) (void)(0) 4017 #elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) 4019 #define INFO(msg) INTERNAL_CATCH_INFO("INFO", msg) 4020 #define UNSCOPED_INFO(msg) INTERNAL_CATCH_UNSCOPED_INFO("UNSCOPED_INFO", msg) 4021 #define WARN(msg) INTERNAL_CATCH_MSG("WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg) 4022 #define CAPTURE(...) INTERNAL_CATCH_CAPTURE(INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", true, __VA_ARGS__) 4023 #define UNSCOPED_CAPTURE(...) INTERNAL_CATCH_CAPTURE(INTERNAL_CATCH_UNIQUE_NAME(capturer), "UNSCOPED_CAPTURE", false, __VA_ARGS__) 4025 #elif !defined(CATCH_CONFIG_PREFIX_MESSAGES) && defined(CATCH_CONFIG_DISABLE) 4027 #define INFO(msg) (void)(0) 4028 #define UNSCOPED_INFO(msg) (void)(0) 4029 #define WARN(msg) (void)(0) 4030 #define CAPTURE(...) (void)(0) 4031 #define UNSCOPED_CAPTURE(...) (void)(0) 4033 #endif // end of user facing macro declarations 4035 #endif // CATCH_MESSAGE_HPP_INCLUDED 4037 #ifndef CATCH_SECTION_INFO_HPP_INCLUDED 4038 #define CATCH_SECTION_INFO_HPP_INCLUDED 4040 #ifndef CATCH_TOTALS_HPP_INCLUDED 4041 #define CATCH_TOTALS_HPP_INCLUDED 4048 Counts operator-(Counts const &other) const; 4049 Counts &operator+=(Counts const &other); 4051 std::uint64_t total() const; 4052 bool allPassed() const; 4055 std::uint64_t passed = 0; 4056 std::uint64_t failed = 0; 4057 std::uint64_t failedButOk = 0; 4058 std::uint64_t skipped = 0; 4062 Totals operator-(Totals const &other) const; 4063 Totals &operator+=(Totals const &other); 4065 Totals delta(Totals const &prevTotals) const; 4070 } // namespace Catch 4072 #endif // CATCH_TOTALS_HPP_INCLUDED 4078 struct SectionInfo { 4079 // The last argument is ignored, so that people can write 4080 // SECTION("ShortName", "Proper description that is long") and 4081 // still use the `-c` flag comfortably. 4082 SectionInfo(SourceLineInfo const &_lineInfo, std::string _name, 4083 const char *const = nullptr) 4084 : name(CATCH_MOVE(_name)), lineInfo(_lineInfo) {} 4087 SourceLineInfo lineInfo; 4090 struct SectionEndInfo { 4091 SectionInfo sectionInfo; 4092 Counts prevAssertions; 4093 double durationInSeconds; 4096 } // end namespace Catch 4098 #endif // CATCH_SECTION_INFO_HPP_INCLUDED 4100 #ifndef CATCH_SESSION_HPP_INCLUDED 4101 #define CATCH_SESSION_HPP_INCLUDED 4103 #ifndef CATCH_COMMANDLINE_HPP_INCLUDED 4104 #define CATCH_COMMANDLINE_HPP_INCLUDED 4106 #ifndef CATCH_CLARA_HPP_INCLUDED 4107 #define CATCH_CLARA_HPP_INCLUDED 4109 #if defined(__clang__) 4110 #pragma clang diagnostic push 4111 #pragma clang diagnostic ignored "-Wweak-vtables" 4112 #pragma clang diagnostic ignored "-Wshadow" 4113 #pragma clang diagnostic ignored "-Wdeprecated" 4116 #if defined(__GNUC__) 4117 #pragma GCC diagnostic push 4118 #pragma GCC diagnostic ignored "-Wsign-conversion" 4121 #ifndef CLARA_CONFIG_OPTIONAL_TYPE 4122 #ifdef __has_include 4123 #if __has_include(<optional>) && __cplusplus >= 201703L 4125 #define CLARA_CONFIG_OPTIONAL_TYPE std::optional 4135 #include <type_traits> 4144 // enum of result types from a parse 4145 enum class ParseResultType { 4152 struct accept_many_t {}; 4153 constexpr accept_many_t accept_many{}; 4157 template<typename T> 4161 template<typename F, typename = void> 4162 static constexpr bool is_unary_function_v = false; 4164 template<typename F> 4165 static constexpr bool is_unary_function_v< 4167 Catch::Detail::void_t<decltype(std::declval<F>()( 4171 // Traits for extracting arg and return type of lambdas (for single 4172 // argument lambdas) 4173 template<typename L> 4174 struct UnaryLambdaTraits 4175 : UnaryLambdaTraits<decltype(&L::operator())> {}; 4177 template<typename ClassT, typename ReturnT, typename... Args> 4178 struct UnaryLambdaTraits<ReturnT (ClassT::*)(Args...) const> { 4179 static const bool isValid = false; 4182 template<typename ClassT, typename ReturnT, typename ArgT> 4183 struct UnaryLambdaTraits<ReturnT (ClassT::*)(ArgT) const> { 4184 static const bool isValid = true; 4185 using ArgType = std::remove_const_t<std::remove_reference_t<ArgT>>; 4186 using ReturnType = ReturnT; 4191 // Wraps a token coming from a token stream. These may not directly 4192 // correspond to strings as a single string may encode an option + 4193 // its argument if the : or = form is used 4194 enum class TokenType { Option, 4201 // Abstracts iterators into args as a stream of tokens, with option 4202 // arguments uniformly handled 4204 using Iterator = std::vector<StringRef>::const_iterator; 4207 std::vector<Token> m_tokenBuffer; 4211 explicit TokenStream(Args const &args); 4212 TokenStream(Iterator it, Iterator itEnd); 4214 explicit operator bool() const { 4215 return !m_tokenBuffer.empty() || it != itEnd; 4218 size_t count() const { 4219 return m_tokenBuffer.size() + (itEnd - it); 4222 Token operator*() const { 4223 assert(!m_tokenBuffer.empty()); 4224 return m_tokenBuffer.front(); 4227 Token const *operator->() const { 4228 assert(!m_tokenBuffer.empty()); 4229 return &m_tokenBuffer.front(); 4232 TokenStream &operator++(); 4236 enum class ResultType { 4238 LogicError, ///< Error in user-specified arguments for 4240 RuntimeError ///< Error in parsing inputs 4245 ResultBase(ResultType type) 4247 virtual ~ResultBase(); // = default; 4249 ResultBase(ResultBase const &) = default; 4250 ResultBase &operator=(ResultBase const &) = default; 4251 ResultBase(ResultBase &&) = default; 4252 ResultBase &operator=(ResultBase &&) = default; 4254 virtual void enforceOk() const = 0; 4259 template<typename T> 4260 class ResultValueBase : public ResultBase { 4262 T const &value() const & { 4268 return CATCH_MOVE(m_value); 4272 ResultValueBase(ResultType type) 4273 : ResultBase(type) {} 4275 ResultValueBase(ResultValueBase const &other) 4276 : ResultBase(other) { 4277 if (m_type == ResultType::Ok) 4278 new (&m_value) T(other.m_value); 4280 ResultValueBase(ResultValueBase &&other) 4281 : ResultBase(other) { 4282 if (m_type == ResultType::Ok) 4283 new (&m_value) T(CATCH_MOVE(other.m_value)); 4286 ResultValueBase(ResultType, T const &value) 4287 : ResultBase(ResultType::Ok) { 4288 new (&m_value) T(value); 4290 ResultValueBase(ResultType, T &&value) 4291 : ResultBase(ResultType::Ok) { 4292 new (&m_value) T(CATCH_MOVE(value)); 4295 ResultValueBase &operator=(ResultValueBase const &other) { 4296 if (m_type == ResultType::Ok) 4298 ResultBase::operator=(other); 4299 if (m_type == ResultType::Ok) 4300 new (&m_value) T(other.m_value); 4303 ResultValueBase &operator=(ResultValueBase &&other) { 4304 if (m_type == ResultType::Ok) m_value.~T(); 4305 ResultBase::operator=(other); 4306 if (m_type == ResultType::Ok) 4307 new (&m_value) T(CATCH_MOVE(other.m_value)); 4311 ~ResultValueBase() override { 4312 if (m_type == ResultType::Ok) 4322 class ResultValueBase<void> : public ResultBase { 4324 using ResultBase::ResultBase; 4327 template<typename T = void> 4328 class BasicResult : public ResultValueBase<T> { 4330 template<typename U> 4331 explicit BasicResult(BasicResult<U> const &other) 4332 : ResultValueBase<T>(other.type()), m_errorMessage(other.errorMessage()) { 4333 assert(type() != ResultType::Ok); 4336 template<typename U> 4337 static auto ok(U &&value) -> BasicResult { 4338 return {ResultType::Ok, CATCH_FORWARD(value)}; 4340 static auto ok() -> BasicResult { return {ResultType::Ok}; } 4341 static auto logicError(std::string &&message) 4343 return {ResultType::LogicError, CATCH_MOVE(message)}; 4345 static auto runtimeError(std::string &&message) 4347 return {ResultType::RuntimeError, CATCH_MOVE(message)}; 4350 explicit operator bool() const { 4351 return m_type == ResultType::Ok; 4353 auto type() const -> ResultType { return m_type; } 4354 auto errorMessage() const -> std::string const & { 4355 return m_errorMessage; 4359 void enforceOk() const override { 4360 // Errors shouldn't reach
this point, but
if they
do 4362 assert(m_type != ResultType::LogicError);
4363 assert(m_type != ResultType::RuntimeError);
4364 if (m_type != ResultType::Ok)
4372 std::string &&message)
4374 assert(m_type != ResultType::Ok);
4378 using ResultBase::m_type;
4386 ParseResultType type()
const {
return m_type; }
4388 return m_remainingTokens;
4395 ParseResultType m_type;
4408 template<
typename T>
4409 ParserResult convertInto(std::string
const &source, T &target) {
4410 std::stringstream ss(source);
4413 return ParserResult::runtimeError(
4414 "Unable to convert '" + source +
"' to destination type");
4416 return ParserResult::ok(ParseResultType::Matched);
4420 std::string &target);
4421 ParserResult convertInto(std::string
const &source,
bool &target);
4423 #ifdef CLARA_CONFIG_OPTIONAL_TYPE 4424 template<
typename T>
4425 auto convertInto(std::string
const &source,
4426 CLARA_CONFIG_OPTIONAL_TYPE<T> &target)
4429 auto result = convertInto(source, temp);
4434 #endif // CLARA_CONFIG_OPTIONAL_TYPE 4438 virtual bool isContainer()
const;
4439 virtual bool isFlag()
const;
4442 virtual auto setValue(std::string
const &arg)
4448 bool isFlag()
const override;
4451 template<
typename T>
4458 ParserResult setValue(std::string
const &arg)
override {
4459 return convertInto(arg, m_ref);
4463 template<
typename T>
4465 std::vector<T> &m_ref;
4470 auto isContainer()
const ->
bool override {
return true; }
4472 auto setValue(std::string
const &arg)
4475 auto result = convertInto(arg, temp);
4477 m_ref.push_back(temp);
4491 template<
typename ReturnType>
4494 std::is_same<ReturnType, ParserResult>::value,
4495 "Lambda must return void or clara::ParserResult");
4497 template<
typename L,
typename ArgType>
4498 static auto invoke(L
const &lambda, ArgType
const &arg)
4506 template<
typename L,
typename ArgType>
4507 static auto invoke(L
const &lambda, ArgType
const &arg)
4510 return ParserResult::ok(ParseResultType::Matched);
4514 template<
typename ArgType,
typename L>
4515 auto invokeLambda(L
const &lambda, std::string
const &arg)
4518 auto result = convertInto(arg, temp);
4519 return !result ? result
4521 L>::ReturnType>::invoke(lambda, temp);
4524 template<
typename L>
4530 "Supplied lambda must take exactly one argument");
4532 : m_lambda(lambda) {}
4534 auto setValue(std::string
const &arg)
4536 return invokeLambda<typename UnaryLambdaTraits<L>::ArgType>(
4541 template<
typename L>
4545 bool isContainer()
const override {
return true; }
4548 template<
typename L>
4554 "Supplied lambda must take exactly one argument");
4558 "flags must be boolean");
4561 : m_lambda(lambda) {}
4565 L>::ReturnType>::invoke(m_lambda, flag);
4575 virtual auto validate()
const ->
Result {
return Result::ok(); }
4576 virtual auto parse(std::string
const &exeName,
4580 virtual size_t cardinality()
const;
4585 template<
typename DerivedT>
4588 template<
typename T>
4589 auto operator|(T
const &other)
const ->
Parser;
4593 template<
typename DerivedT>
4596 Optionality m_optionality = Optionality::Optional;
4597 std::shared_ptr<BoundRef> m_ref;
4601 explicit ParserRefImpl(std::shared_ptr<BoundRef>
const &ref)
4605 template<
typename LambdaT>
4611 template<
typename T,
4612 typename =
typename std::enable_if_t<
4613 !Detail::is_unary_function_v<T>>>
4617 template<
typename LambdaT,
4618 typename =
typename std::enable_if_t<
4619 Detail::is_unary_function_v<LambdaT>>>
4620 ParserRefImpl(LambdaT
const &ref,
StringRef hint)
4623 DerivedT &operator()(
StringRef description) & {
4624 m_description = description;
4625 return static_cast<DerivedT &
>(*this);
4627 DerivedT &&operator()(
StringRef description) && {
4628 m_description = description;
4629 return static_cast<DerivedT &&
>(*this);
4632 auto optional() -> DerivedT & {
4633 m_optionality = Optionality::Optional;
4634 return static_cast<DerivedT &
>(*this);
4637 auto required() -> DerivedT & {
4638 m_optionality = Optionality::Required;
4639 return static_cast<DerivedT &
>(*this);
4642 auto isOptional()
const ->
bool {
4643 return m_optionality == Optionality::Optional;
4646 auto cardinality()
const ->
size_t override {
4647 if (m_ref->isContainer())
4653 StringRef hint()
const {
return m_hint; }
4661 using ParserBase::parse;
4662 using ParserRefImpl::ParserRefImpl;
4665 parse(std::string
const &,
4672 std::vector<StringRef> m_optNames;
4675 template<
typename LambdaT>
4676 explicit Opt(LambdaT
const &ref)
4680 explicit Opt(
bool &ref);
4682 template<
typename LambdaT,
4683 typename =
typename std::enable_if_t<
4684 Detail::is_unary_function_v<LambdaT>>>
4686 : ParserRefImpl(ref, hint) {}
4688 template<
typename LambdaT>
4690 : ParserRefImpl(accept_many, ref, hint) {}
4692 template<
typename T,
4693 typename =
typename std::enable_if_t<
4694 !Detail::is_unary_function_v<T>>>
4696 : ParserRefImpl(ref, hint) {}
4699 m_optNames.push_back(optName);
4702 Opt &&operator[](
StringRef optName) && {
4703 m_optNames.push_back(optName);
4711 using ParserBase::parse;
4714 parse(std::string
const &,
4722 std::shared_ptr<std::string> m_name;
4723 std::shared_ptr<Detail::BoundValueRefBase> m_ref;
4727 explicit ExeName(std::string &ref);
4729 template<
typename LambdaT>
4730 explicit ExeName(LambdaT
const &lambda)
4732 m_ref = std::make_shared<Detail::BoundLambda<LambdaT>>(lambda);
4738 parse(std::string
const &,
4741 std::string
const &name()
const {
return *m_name; }
4748 std::vector<Opt> m_options;
4749 std::vector<Arg> m_args;
4753 m_exeName = exeName;
4757 auto operator|=(
Arg const &arg) ->
Parser & {
4758 m_args.push_back(arg);
4763 p.m_options.push_back(opt);
4773 template<
typename T>
4780 template<
typename T>
4786 std::vector<Detail::HelpColumns> getHelpColumns()
const;
4788 void writeToStream(std::ostream &os)
const;
4790 friend auto operator<<(std::ostream &os,
Parser const &parser)
4792 parser.writeToStream(os);
4798 using ParserBase::parse;
4800 parse(std::string
const &exeName,
4810 std::vector<StringRef> m_args;
4813 Args(
int argc,
char const *
const *argv);
4815 Args(std::initializer_list<StringRef> args);
4817 StringRef exeName()
const {
return m_exeName; }
4822 Help(
bool &showHelpFlag);
4829 template<
typename DerivedT>
4830 template<
typename T>
4832 ComposableParserImpl<DerivedT>::operator|(T
const &other)
const {
4833 return Parser() |
static_cast<DerivedT
const &
>(*this) | other;
4840 #if defined(__clang__) 4841 #pragma clang diagnostic pop 4844 #if defined(__GNUC__) 4845 #pragma GCC diagnostic pop 4848 #endif // CATCH_CLARA_HPP_INCLUDED 4858 #endif // CATCH_COMMANDLINE_HPP_INCLUDED 4863 constexpr
int UnspecifiedErrorExitCode = 1;
4864 constexpr
int NoTestsRunExitCode = 2;
4865 constexpr
int UnmatchedTestSpecExitCode = 3;
4866 constexpr
int AllTestsSkippedExitCode = 4;
4867 constexpr
int InvalidTestSpecExitCode = 5;
4868 constexpr
int TestFailureExitCode = 42;
4875 void showHelp()
const;
4878 int applyCommandLine(
int argc,
char const *
const *argv);
4879 #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE) 4880 int applyCommandLine(
int argc,
wchar_t const *
const *argv);
4883 void useConfigData(
ConfigData const &configData);
4885 template<
typename CharT>
4886 int run(
int argc, CharT
const *
const argv[]) {
4887 if (m_startupExceptions)
4889 int returnCode = applyCommandLine(argc, argv);
4890 if (returnCode == 0)
4908 bool m_startupExceptions =
false;
4913 #endif // CATCH_SESSION_HPP_INCLUDED 4915 #ifndef CATCH_TAG_ALIAS_HPP_INCLUDED 4916 #define CATCH_TAG_ALIAS_HPP_INCLUDED 4924 : tag(_tag), lineInfo(_lineInfo) {}
4932 #endif // CATCH_TAG_ALIAS_HPP_INCLUDED 4934 #ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 4935 #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 4945 #define CATCH_REGISTER_TAG_ALIAS(alias, spec) \ 4946 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 4947 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 4949 const Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME(AutoRegisterTagAlias)(alias, spec, CATCH_INTERNAL_LINEINFO); \ 4951 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 4953 #endif // CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 4955 #ifndef CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED 4956 #define CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED 4962 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 10 4963 #pragma GCC diagnostic ignored "-Wparentheses" 4966 #ifndef CATCH_TEST_MACROS_HPP_INCLUDED 4967 #define CATCH_TEST_MACROS_HPP_INCLUDED 4969 #ifndef CATCH_TEST_MACRO_IMPL_HPP_INCLUDED 4970 #define CATCH_TEST_MACRO_IMPL_HPP_INCLUDED 4972 #ifndef CATCH_ASSERTION_HANDLER_HPP_INCLUDED 4973 #define CATCH_ASSERTION_HANDLER_HPP_INCLUDED 4975 #ifndef CATCH_DECOMPOSER_HPP_INCLUDED 4976 #define CATCH_DECOMPOSER_HPP_INCLUDED 4978 #ifndef CATCH_COMPARE_TRAITS_HPP_INCLUDED 4979 #define CATCH_COMPARE_TRAITS_HPP_INCLUDED 4981 #include <type_traits> 4986 #if defined(__GNUC__) && !defined(__clang__) 4987 #pragma GCC diagnostic push 4990 #pragma GCC diagnostic ignored "-Wbool-compare" 4993 #pragma GCC diagnostic ignored "-Wextra" 4996 #pragma GCC diagnostic ignored "-Wfloat-equal" 4999 #if defined(__clang__) 5000 #pragma clang diagnostic push 5003 #pragma clang diagnostic ignored "-Wfloat-equal" 5006 #define CATCH_DEFINE_COMPARABLE_TRAIT(id, op) \ 5007 template<typename, typename, typename = void> \ 5008 struct is_##id##_comparable : std::false_type {}; \ 5009 template<typename T, typename U> \ 5010 struct is_##id##_comparable< \ 5013 void_t<decltype(std::declval<T>() op std::declval<U>())>> \ 5014 : std::true_type {}; \ 5015 template<typename, typename = void> \ 5016 struct is_##id##_0_comparable : std::false_type {}; \ 5017 template<typename T> \ 5018 struct is_##id##_0_comparable<T, \ 5019 void_t<decltype(std::declval<T>() op 0)>> \ 5020 : std::true_type {}; 5023 CATCH_DEFINE_COMPARABLE_TRAIT(lt, <)
5024 CATCH_DEFINE_COMPARABLE_TRAIT(le, <=)
5025 CATCH_DEFINE_COMPARABLE_TRAIT(gt, >)
5026 CATCH_DEFINE_COMPARABLE_TRAIT(ge, >=)
5027 CATCH_DEFINE_COMPARABLE_TRAIT(eq, ==)
5028 CATCH_DEFINE_COMPARABLE_TRAIT(ne, !=)
5030 #undef CATCH_DEFINE_COMPARABLE_TRAIT 5032 #if defined(__GNUC__) && !defined(__clang__) 5033 #pragma GCC diagnostic pop 5035 #if defined(__clang__) 5036 #pragma clang diagnostic pop 5042 #endif // CATCH_COMPARE_TRAITS_HPP_INCLUDED 5044 #ifndef CATCH_LOGICAL_TRAITS_HPP_INCLUDED 5045 #define CATCH_LOGICAL_TRAITS_HPP_INCLUDED 5047 #include <type_traits> 5052 #if defined(__cpp_lib_logical_traits) && __cpp_lib_logical_traits >= 201510 5054 using std::conjunction;
5055 using std::disjunction;
5056 using std::negation;
5064 template<
class B1,
class... Bn>
5066 : std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
5072 template<
class B1,
class... Bn>
5074 : std::conditional_t<bool(B1::value), B1, disjunction<Bn...>> {};
5077 struct negation : std::integral_constant<bool, !bool(B::value)> {};
5084 #endif // CATCH_LOGICAL_TRAITS_HPP_INCLUDED 5087 #include <type_traits> 5171 #pragma warning(push) 5172 #pragma warning(disable : 4389) // '==' : signed/unsigned mismatch 5173 #pragma warning(disable : 4018) // more "signed/unsigned mismatch" 5174 #pragma warning(disable : 4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) 5175 #pragma warning(disable : 4180) // qualifier applied to function type has no meaning 5176 #pragma warning(disable : 4800) // Forcing result to true or false 5180 #pragma clang diagnostic push 5181 #pragma clang diagnostic ignored "-Wsign-compare" 5182 #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 5183 #elif defined __GNUC__ 5184 #pragma GCC diagnostic push 5185 #pragma GCC diagnostic ignored "-Wsign-compare" 5186 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 5189 #if defined(CATCH_CPP20_OR_GREATER) && __has_include(<compare>) 5191 #if defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L 5192 #define CATCH_CONFIG_CPP20_COMPARE_OVERLOADS 5200 template<
typename T>
5201 using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>;
5215 template<
typename T>
5217 : std::integral_constant<bool,
5218 std::is_arithmetic<T>::value || std::is_enum<T>::value> {};
5220 #if defined(CATCH_CONFIG_CPP20_COMPARE_OVERLOADS) 5229 template<
typename T>
5233 bool m_isBinaryExpression;
5240 constexpr
auto isBinaryExpression()
const ->
bool {
return m_isBinaryExpression; }
5241 constexpr
auto getResult()
const ->
bool {
return m_result; }
5243 virtual void streamReconstructedExpression(std::ostream &os)
const;
5246 : m_isBinaryExpression(isBinaryExpression), m_result(result) {}
5248 constexpr ITransientExpression(ITransientExpression
const &) =
default;
5249 constexpr ITransientExpression &operator=(ITransientExpression
const &) =
default;
5251 friend std::ostream &operator<<(std::ostream &out, ITransientExpression
const &expr) {
5257 void formatReconstructedExpression(std::ostream &os, std::string
const &lhs,
StringRef op, std::string
const &rhs);
5259 template<
typename LhsT,
typename RhsT>
5265 void streamReconstructedExpression(std::ostream &os)
const override {
5266 formatReconstructedExpression(os, Catch::Detail::stringify(m_lhs), m_op, Catch::Detail::stringify(m_rhs));
5273 template<
typename T>
5276 "chained comparisons are not supported inside assertions, " 5277 "wrap the expression inside parentheses, or decompose it");
5280 template<
typename T>
5283 "chained comparisons are not supported inside assertions, " 5284 "wrap the expression inside parentheses, or decompose it");
5287 template<
typename T>
5290 "chained comparisons are not supported inside assertions, " 5291 "wrap the expression inside parentheses, or decompose it");
5294 template<
typename T>
5297 "chained comparisons are not supported inside assertions, " 5298 "wrap the expression inside parentheses, or decompose it");
5301 template<
typename T>
5304 "chained comparisons are not supported inside assertions, " 5305 "wrap the expression inside parentheses, or decompose it");
5308 template<
typename T>
5311 "chained comparisons are not supported inside assertions, " 5312 "wrap the expression inside parentheses, or decompose it");
5315 template<
typename T>
5318 "chained comparisons are not supported inside assertions, " 5319 "wrap the expression inside parentheses, or decompose it");
5322 template<
typename T>
5325 "chained comparisons are not supported inside assertions, " 5326 "wrap the expression inside parentheses, or decompose it");
5330 template<
typename LhsT>
5334 void streamReconstructedExpression(std::ostream &os)
const override {
5335 os << Catch::Detail::stringify(m_lhs);
5343 template<
typename LhsT>
5348 explicit constexpr
ExprLhs(LhsT lhs)
5351 #define CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR(id, op) \ 5352 template<typename RhsT> \ 5353 constexpr friend auto operator op(ExprLhs &&lhs, RhsT &&rhs) \ 5354 ->std::enable_if_t< \ 5355 Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ 5356 Detail::negation<capture_by_value< \ 5357 Detail::RemoveCVRef_t<RhsT>>>>::value, \ 5358 BinaryExpr<LhsT, RhsT const &>> { \ 5360 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5362 template<typename RhsT> \ 5363 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5364 ->std::enable_if_t< \ 5365 Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ 5366 capture_by_value<RhsT>>::value, \ 5367 BinaryExpr<LhsT, RhsT>> { \ 5369 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5371 template<typename RhsT> \ 5372 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5373 ->std::enable_if_t< \ 5374 Detail::conjunction< \ 5375 Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ 5376 Detail::is_eq_0_comparable<LhsT>, \ 5377 Detail::disjunction<std::is_same<RhsT, int>, \ 5378 std::is_same<RhsT, long>>>::value, \ 5379 BinaryExpr<LhsT, RhsT>> { \ 5380 if (rhs != 0) { throw_test_failure_exception(); } \ 5382 static_cast<bool>(lhs.m_lhs op 0), lhs.m_lhs, #op##_sr, rhs}; \ 5384 template<typename RhsT> \ 5385 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5386 ->std::enable_if_t< \ 5387 Detail::conjunction< \ 5388 Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ 5389 Detail::is_eq_0_comparable<RhsT>, \ 5390 Detail::disjunction<std::is_same<LhsT, int>, \ 5391 std::is_same<LhsT, long>>>::value, \ 5392 BinaryExpr<LhsT, RhsT>> { \ 5393 if (lhs.m_lhs != 0) { throw_test_failure_exception(); } \ 5394 return {static_cast<bool>(0 op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5397 CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR(eq, ==)
5398 CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR(ne, !=)
5400 #undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR 5402 #define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR(id, op) \ 5403 template<typename RhsT> \ 5404 constexpr friend auto operator op(ExprLhs &&lhs, RhsT &&rhs) \ 5405 ->std::enable_if_t< \ 5406 Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ 5407 Detail::negation<capture_by_value< \ 5408 Detail::RemoveCVRef_t<RhsT>>>>::value, \ 5409 BinaryExpr<LhsT, RhsT const &>> { \ 5411 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5413 template<typename RhsT> \ 5414 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5415 ->std::enable_if_t< \ 5416 Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \ 5417 capture_by_value<RhsT>>::value, \ 5418 BinaryExpr<LhsT, RhsT>> { \ 5420 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5422 template<typename RhsT> \ 5423 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5424 ->std::enable_if_t< \ 5425 Detail::conjunction< \ 5426 Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ 5427 Detail::is_##id##_0_comparable<LhsT>, \ 5428 std::is_same<RhsT, int>>::value, \ 5429 BinaryExpr<LhsT, RhsT>> { \ 5430 if (rhs != 0) { throw_test_failure_exception(); } \ 5432 static_cast<bool>(lhs.m_lhs op 0), lhs.m_lhs, #op##_sr, rhs}; \ 5434 template<typename RhsT> \ 5435 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5436 ->std::enable_if_t< \ 5437 Detail::conjunction< \ 5438 Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \ 5439 Detail::is_##id##_0_comparable<RhsT>, \ 5440 std::is_same<LhsT, int>>::value, \ 5441 BinaryExpr<LhsT, RhsT>> { \ 5442 if (lhs.m_lhs != 0) { throw_test_failure_exception(); } \ 5443 return {static_cast<bool>(0 op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5446 CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR(lt, <)
5447 CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR(le, <=)
5448 CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR(gt, >)
5449 CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR(ge, >=)
5451 #undef CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR 5453 #define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(op) \ 5454 template<typename RhsT> \ 5455 constexpr friend auto operator op(ExprLhs &&lhs, RhsT &&rhs) \ 5456 ->std::enable_if_t< \ 5457 !capture_by_value<Detail::RemoveCVRef_t<RhsT>>::value, \ 5458 BinaryExpr<LhsT, RhsT const &>> { \ 5460 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5462 template<typename RhsT> \ 5463 constexpr friend auto operator op(ExprLhs &&lhs, RhsT rhs) \ 5464 ->std::enable_if_t<capture_by_value<RhsT>::value, \ 5465 BinaryExpr<LhsT, RhsT>> { \ 5467 static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs}; \ 5470 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(|)
5471 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(&)
5472 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(^)
5474 #undef CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR 5476 template<
typename RhsT>
5479 "operator&& is not supported inside assertions, " 5480 "wrap the expression inside parentheses, or decompose it");
5483 template<
typename RhsT>
5486 "operator|| is not supported inside assertions, " 5487 "wrap the expression inside parentheses, or decompose it");
5496 template<
typename T,
5497 std::enable_if_t<!capture_by_value<Detail::RemoveCVRef_t<T>>::value,
5504 template<
typename T,
5505 std::enable_if_t<capture_by_value<T>::value,
int> = 0>
5514 #pragma warning(pop) 5517 #pragma clang diagnostic pop 5518 #elif defined __GNUC__ 5519 #pragma GCC diagnostic pop 5522 #endif // CATCH_DECOMPOSER_HPP_INCLUDED 5529 bool shouldDebugBreak =
false;
5530 bool shouldThrow =
false;
5531 bool shouldSkip =
false;
5537 bool m_completed =
false;
5544 ResultDisposition::Flags resultDisposition);
5547 m_resultCapture.handleIncomplete(m_assertionInfo);
5551 template<
typename T>
5552 constexpr
void handleExpr(
ExprLhs<T> const &expr) {
5553 handleExpr(expr.makeUnaryExpr());
5557 void handleMessage(ResultWas::OfType resultType, std::string &&message);
5559 void handleExceptionThrownAsExpected();
5560 void handleUnexpectedExceptionNotThrown();
5561 void handleExceptionNotThrownAsExpected();
5562 void handleThrowingCallSkipped();
5563 void handleUnexpectedInflightException();
5568 auto allowThrows()
const -> bool;
5571 void handleExceptionMatchExpr(
AssertionHandler &handler, std::string
const &str);
5575 #endif // CATCH_ASSERTION_HANDLER_HPP_INCLUDED 5577 #ifndef CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 5578 #define CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 5580 #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) 5581 #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr 5583 #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr 5586 #endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 5590 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ <= 9 5591 #pragma GCC diagnostic ignored "-Wparentheses" 5594 #if !defined(CATCH_CONFIG_DISABLE) 5596 #if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 5601 #define INTERNAL_CATCH_TRY 5602 #define INTERNAL_CATCH_CATCH(capturer) 5604 #else // CATCH_CONFIG_FAST_COMPILE 5606 #define INTERNAL_CATCH_TRY try 5607 #define INTERNAL_CATCH_CATCH(handler) \ 5609 (handler).handleUnexpectedInflightException(); \ 5615 #define INTERNAL_CATCH_TEST(macroName, resultDisposition, ...) \ 5618 CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ 5619 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ 5620 INTERNAL_CATCH_TRY { \ 5621 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5622 CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ 5623 catchAssertionHandler.handleExpr(Catch::Decomposer() <= __VA_ARGS__); \ 5624 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5626 INTERNAL_CATCH_CATCH(catchAssertionHandler) \ 5627 catchAssertionHandler.complete(); \ 5628 } while ((void)0, (false) && static_cast<const bool &>(!!(__VA_ARGS__))) // the expression here is never evaluated at runtime but it forces the compiler to give it a look 5632 #define INTERNAL_CATCH_IF(macroName, resultDisposition, ...) \ 5633 INTERNAL_CATCH_TEST(macroName, resultDisposition, __VA_ARGS__); \ 5634 if (Catch::getResultCapture().lastAssertionPassed()) 5637 #define INTERNAL_CATCH_ELSE(macroName, resultDisposition, ...) \ 5638 INTERNAL_CATCH_TEST(macroName, resultDisposition, __VA_ARGS__); \ 5639 if (!Catch::getResultCapture().lastAssertionPassed()) 5642 #define INTERNAL_CATCH_NO_THROW(macroName, resultDisposition, ...) \ 5644 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ 5646 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5647 CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 5648 static_cast<void>(__VA_ARGS__); \ 5649 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5650 catchAssertionHandler.handleExceptionNotThrownAsExpected(); \ 5652 catchAssertionHandler.handleUnexpectedInflightException(); \ 5654 catchAssertionHandler.complete(); \ 5658 #define INTERNAL_CATCH_THROWS(macroName, resultDisposition, ...) \ 5660 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ 5661 if (catchAssertionHandler.allowThrows()) \ 5663 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5664 CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ 5665 CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 5666 static_cast<void>(__VA_ARGS__); \ 5667 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5668 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ 5670 catchAssertionHandler.handleExceptionThrownAsExpected(); \ 5673 catchAssertionHandler.handleThrowingCallSkipped(); \ 5674 catchAssertionHandler.complete(); \ 5678 #define INTERNAL_CATCH_THROWS_AS(macroName, exceptionType, resultDisposition, expr) \ 5680 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition); \ 5681 if (catchAssertionHandler.allowThrows()) \ 5683 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5684 CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ 5685 CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 5686 static_cast<void>(expr); \ 5687 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5688 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ 5689 } catch (exceptionType const &) { \ 5690 catchAssertionHandler.handleExceptionThrownAsExpected(); \ 5692 catchAssertionHandler.handleUnexpectedInflightException(); \ 5695 catchAssertionHandler.handleThrowingCallSkipped(); \ 5696 catchAssertionHandler.complete(); \ 5701 #define INTERNAL_CATCH_THROWS_STR_MATCHES(macroName, resultDisposition, matcher, ...) \ 5703 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition); \ 5704 if (catchAssertionHandler.allowThrows()) \ 5706 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5707 CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \ 5708 CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 5709 static_cast<void>(__VA_ARGS__); \ 5710 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5711 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ 5713 Catch::handleExceptionMatchExpr(catchAssertionHandler, matcher); \ 5716 catchAssertionHandler.handleThrowingCallSkipped(); \ 5717 catchAssertionHandler.complete(); \ 5720 #endif // CATCH_CONFIG_DISABLE 5722 #endif // CATCH_TEST_MACRO_IMPL_HPP_INCLUDED 5724 #ifndef CATCH_SECTION_HPP_INCLUDED 5725 #define CATCH_SECTION_HPP_INCLUDED 5736 #ifndef CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 5737 #define CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 5739 #if defined(__clang_analyzer__) || defined(__COVERITY__) 5740 #define CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT 5743 #if defined(CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT) && !defined(CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) && !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) 5744 #define CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT 5747 #endif // CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 5749 #ifndef CATCH_TIMER_HPP_INCLUDED 5750 #define CATCH_TIMER_HPP_INCLUDED 5757 uint64_t m_nanoseconds = 0;
5761 auto getElapsedNanoseconds()
const -> uint64_t;
5762 auto getElapsedMicroseconds()
const -> uint64_t;
5763 auto getElapsedMilliseconds()
const ->
unsigned int;
5764 auto getElapsedSeconds()
const -> double;
5769 #endif // CATCH_TIMER_HPP_INCLUDED 5778 const char *
const =
nullptr);
5782 explicit operator bool()
const;
5788 bool m_sectionIncluded;
5794 #if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) 5795 #define INTERNAL_CATCH_SECTION(...) \ 5796 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5797 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 5798 if (Catch::Section const &INTERNAL_CATCH_UNIQUE_NAME( \ 5799 catch_internal_Section) \ 5800 = Catch::Section(CATCH_INTERNAL_LINEINFO, __VA_ARGS__)) \ 5801 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 5803 #define INTERNAL_CATCH_DYNAMIC_SECTION(...) \ 5804 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5805 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 5806 if (Catch::Section const &INTERNAL_CATCH_UNIQUE_NAME( \ 5807 catch_internal_Section) \ 5808 = Catch::SectionInfo( \ 5809 CATCH_INTERNAL_LINEINFO, \ 5810 (Catch::ReusableStringStream() << __VA_ARGS__) \ 5812 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 5826 int GetNewSectionHint(
StringRef,
const char *
const =
nullptr);
5830 #define INTERNAL_CATCH_SECTION(...) \ 5831 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5832 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 5833 CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ 5834 if ([[maybe_unused]] const int catchInternalPreviousSectionHint = catchInternalSectionHint, \ 5835 catchInternalSectionHint = Catch::Detail::GetNewSectionHint(__VA_ARGS__); \ 5836 catchInternalPreviousSectionHint == __LINE__) \ 5837 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 5839 #define INTERNAL_CATCH_DYNAMIC_SECTION(...) \ 5840 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5841 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 5842 CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ 5843 if ([[maybe_unused]] const int catchInternalPreviousSectionHint = catchInternalSectionHint, \ 5844 catchInternalSectionHint = Catch::Detail::GetNewSectionHint( \ 5845 (Catch::ReusableStringStream() << __VA_ARGS__).str()); \ 5846 catchInternalPreviousSectionHint == __LINE__) \ 5847 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 5851 #endif // CATCH_SECTION_HPP_INCLUDED 5853 #ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED 5854 #define CATCH_TEST_REGISTRY_HPP_INCLUDED 5856 #ifndef CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 5857 #define CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 5863 virtual void prepareTestCase();
5864 virtual void tearDownTestCase();
5865 virtual void invoke()
const = 0;
5871 #endif // CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 5873 #ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 5874 #define CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 5876 #define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) 5877 #define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO##__VA_ARGS__ 5878 #define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ 5879 #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF 5881 #define INTERNAL_CATCH_REMOVE_PARENS(...) \ 5882 INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) 5884 #endif // CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 5889 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 5890 #pragma GCC diagnostic ignored "-Wunused-variable" 5895 template<
typename C>
5897 void (C::*m_testAsMethod)();
5901 : m_testAsMethod(testAsMethod) {}
5903 void invoke()
const override {
5905 (obj.*m_testAsMethod)();
5911 template<
typename C>
5913 return Detail::make_unique<TestInvokerAsMethod<C>>(testAsMethod);
5916 template<
typename C>
5918 void (C::*m_testAsMethod)()
const;
5923 : m_testAsMethod(testAsMethod) {}
5925 void prepareTestCase()
override {
5926 m_fixture = Detail::make_unique<C>();
5929 void tearDownTestCase()
override {
5933 void invoke()
const override {
5934 auto *f = m_fixture.get();
5935 (f->*m_testAsMethod)();
5939 template<
typename C>
5941 return Detail::make_unique<TestInvokerFixture<C>>(testAsMethod);
5947 : name(name_), tags(tags_) {}
5958 #if defined(CATCH_CONFIG_DISABLE) 5959 #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(TestName, ...) \ 5960 static inline void TestName() 5961 #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(TestName, ClassName, ...) \ 5963 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ 5967 void TestName::test() 5970 #if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT) 5973 #define INTERNAL_CATCH_TESTCASE2(TestName, ...) \ 5974 static void TestName(); \ 5975 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 5976 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 5977 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 5979 const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(Catch::makeTestInvoker(&TestName), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{__VA_ARGS__}); \ 5981 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 5982 static void TestName() 5983 #define INTERNAL_CATCH_TESTCASE(...) \ 5984 INTERNAL_CATCH_TESTCASE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), __VA_ARGS__) 5986 #else // ^^ !CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT | vv CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT 6002 static int catchInternalSectionHint = 0;
6004 #define INTERNAL_CATCH_TESTCASE2(fname, ...) \ 6005 static void fname(int); \ 6006 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6007 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6008 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6009 static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ 6010 dummyUser)(&(fname), Catch::NameAndTags{__VA_ARGS__}); \ 6011 CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ 6012 static void fname([[maybe_unused]] int catchInternalSectionHint) \ 6013 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 6014 #define INTERNAL_CATCH_TESTCASE(...) \ 6015 INTERNAL_CATCH_TESTCASE2(INTERNAL_CATCH_UNIQUE_NAME(dummyFunction), __VA_ARGS__) 6017 #endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT 6020 #define INTERNAL_CATCH_TEST_CASE_METHOD2(TestName, ClassName, ...) \ 6021 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6022 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6023 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6025 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ 6028 const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ 6029 Catch::makeTestInvoker(&TestName::test), \ 6030 CATCH_INTERNAL_LINEINFO, \ 6031 #ClassName##_catch_sr, \ 6032 Catch::NameAndTags{__VA_ARGS__}); \ 6034 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6035 void TestName::test() 6036 #define INTERNAL_CATCH_TEST_CASE_METHOD(ClassName, ...) \ 6037 INTERNAL_CATCH_TEST_CASE_METHOD2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), ClassName, __VA_ARGS__) 6040 #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2(TestName, ClassName, ...) \ 6041 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6042 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6043 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6045 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ 6046 void test() const; \ 6048 const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ 6049 Catch::makeTestInvokerFixture(&TestName::test), \ 6050 CATCH_INTERNAL_LINEINFO, \ 6051 #ClassName##_catch_sr, \ 6052 Catch::NameAndTags{__VA_ARGS__}); \ 6054 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6055 void TestName::test() const 6056 #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE(ClassName, ...) \ 6057 INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), ClassName, __VA_ARGS__) 6060 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE(QualifiedMethod, ...) \ 6061 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6062 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6063 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6065 const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)( \ 6066 Catch::makeTestInvoker(&QualifiedMethod), \ 6067 CATCH_INTERNAL_LINEINFO, \ 6068 "&" #QualifiedMethod##_catch_sr, \ 6069 Catch::NameAndTags{__VA_ARGS__}); \ 6071 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 6074 #define INTERNAL_CATCH_REGISTER_TESTCASE(Function, ...) \ 6076 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6077 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6078 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6079 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME(autoRegistrar)(Catch::makeTestInvoker(Function), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{__VA_ARGS__}); \ 6080 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6083 #endif // CATCH_TEST_REGISTRY_HPP_INCLUDED 6085 #ifndef CATCH_UNREACHABLE_HPP_INCLUDED 6086 #define CATCH_UNREACHABLE_HPP_INCLUDED 6097 #include <exception> 6099 #if defined(__cpp_lib_unreachable) && __cpp_lib_unreachable > 202202L 6103 using Unreachable = std::unreachable;
6107 #else // vv If we do not have std::unreachable, we implement something similar 6113 inline void Unreachable() noexcept {
6115 #if defined(_MSC_VER) && !defined(__clang__) 6117 #elif defined(__GNUC__) 6118 __builtin_unreachable();
6119 #else // vv platform without known optimization hint 6133 #endif // CATCH_UNREACHABLE_HPP_INCLUDED 6140 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) 6142 #define CATCH_REQUIRE(...) INTERNAL_CATCH_TEST("CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__) 6143 #define CATCH_REQUIRE_FALSE(...) INTERNAL_CATCH_TEST("CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__) 6145 #define CATCH_REQUIRE_THROWS(...) INTERNAL_CATCH_THROWS("CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__) 6146 #define CATCH_REQUIRE_THROWS_AS(expr, exceptionType) INTERNAL_CATCH_THROWS_AS("CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr) 6147 #define CATCH_REQUIRE_NOTHROW(...) INTERNAL_CATCH_NO_THROW("CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__) 6149 #define CATCH_CHECK(...) INTERNAL_CATCH_TEST("CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6150 #define CATCH_CHECK_FALSE(...) INTERNAL_CATCH_TEST("CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__) 6151 #define CATCH_CHECKED_IF(...) INTERNAL_CATCH_IF("CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6152 #define CATCH_CHECKED_ELSE(...) INTERNAL_CATCH_ELSE("CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6153 #define CATCH_CHECK_NOFAIL(...) INTERNAL_CATCH_TEST("CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6155 #define CATCH_CHECK_THROWS(...) INTERNAL_CATCH_THROWS("CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6156 #define CATCH_CHECK_THROWS_AS(expr, exceptionType) INTERNAL_CATCH_THROWS_AS("CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr) 6157 #define CATCH_CHECK_NOTHROW(...) INTERNAL_CATCH_NO_THROW("CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6159 #define CATCH_TEST_CASE(...) INTERNAL_CATCH_TESTCASE(__VA_ARGS__) 6160 #define CATCH_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEST_CASE_METHOD(className, __VA_ARGS__) 6161 #define CATCH_METHOD_AS_TEST_CASE(method, ...) INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, __VA_ARGS__) 6162 #define CATCH_TEST_CASE_PERSISTENT_FIXTURE(className, ...) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE(className, __VA_ARGS__) 6163 #define CATCH_REGISTER_TEST_CASE(Function, ...) INTERNAL_CATCH_REGISTER_TESTCASE(Function, __VA_ARGS__) 6164 #define CATCH_SECTION(...) INTERNAL_CATCH_SECTION(__VA_ARGS__) 6165 #define CATCH_DYNAMIC_SECTION(...) INTERNAL_CATCH_DYNAMIC_SECTION(__VA_ARGS__) 6166 #define CATCH_FAIL(...) \ 6168 INTERNAL_CATCH_MSG("CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__); \ 6169 Catch::Detail::Unreachable(); \ 6171 #define CATCH_FAIL_CHECK(...) INTERNAL_CATCH_MSG("CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6172 #define CATCH_SUCCEED(...) INTERNAL_CATCH_MSG("CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6173 #define CATCH_SKIP(...) \ 6175 INTERNAL_CATCH_MSG("CATCH_SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__); \ 6176 Catch::Detail::Unreachable(); \ 6179 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) 6180 #define CATCH_STATIC_REQUIRE(...) \ 6181 static_assert(__VA_ARGS__, #__VA_ARGS__); \ 6182 CATCH_SUCCEED(#__VA_ARGS__) 6183 #define CATCH_STATIC_REQUIRE_FALSE(...) \ 6184 static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")"); \ 6185 CATCH_SUCCEED(#__VA_ARGS__) 6186 #define CATCH_STATIC_CHECK(...) \ 6187 static_assert(__VA_ARGS__, #__VA_ARGS__); \ 6188 CATCH_SUCCEED(#__VA_ARGS__) 6189 #define CATCH_STATIC_CHECK_FALSE(...) \ 6190 static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")"); \ 6191 CATCH_SUCCEED(#__VA_ARGS__) 6193 #define CATCH_STATIC_REQUIRE(...) CATCH_REQUIRE(__VA_ARGS__) 6194 #define CATCH_STATIC_REQUIRE_FALSE(...) CATCH_REQUIRE_FALSE(__VA_ARGS__) 6195 #define CATCH_STATIC_CHECK(...) CATCH_CHECK(__VA_ARGS__) 6196 #define CATCH_STATIC_CHECK_FALSE(...) CATCH_CHECK_FALSE(__VA_ARGS__) 6200 #define CATCH_SCENARIO(...) CATCH_TEST_CASE("Scenario: " __VA_ARGS__) 6201 #define CATCH_SCENARIO_METHOD(className, ...) INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " __VA_ARGS__) 6202 #define CATCH_GIVEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" Given: " << desc) 6203 #define CATCH_AND_GIVEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION("And given: " << desc) 6204 #define CATCH_WHEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" When: " << desc) 6205 #define CATCH_AND_WHEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" And when: " << desc) 6206 #define CATCH_THEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" Then: " << desc) 6207 #define CATCH_AND_THEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" And: " << desc) 6209 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) // ^^ prefixed, implemented | vv prefixed, disabled 6211 #define CATCH_REQUIRE(...) (void)(0) 6212 #define CATCH_REQUIRE_FALSE(...) (void)(0) 6214 #define CATCH_REQUIRE_THROWS(...) (void)(0) 6215 #define CATCH_REQUIRE_THROWS_AS(expr, exceptionType) (void)(0) 6216 #define CATCH_REQUIRE_NOTHROW(...) (void)(0) 6218 #define CATCH_CHECK(...) (void)(0) 6219 #define CATCH_CHECK_FALSE(...) (void)(0) 6220 #define CATCH_CHECKED_IF(...) if (__VA_ARGS__) 6221 #define CATCH_CHECKED_ELSE(...) if (!(__VA_ARGS__)) 6222 #define CATCH_CHECK_NOFAIL(...) (void)(0) 6224 #define CATCH_CHECK_THROWS(...) (void)(0) 6225 #define CATCH_CHECK_THROWS_AS(expr, exceptionType) (void)(0) 6226 #define CATCH_CHECK_NOTHROW(...) (void)(0) 6228 #define CATCH_TEST_CASE(...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6229 #define CATCH_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6230 #define CATCH_METHOD_AS_TEST_CASE(method, ...) 6231 #define CATCH_TEST_CASE_PERSISTENT_FIXTURE(className, ...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6232 #define CATCH_REGISTER_TEST_CASE(Function, ...) (void)(0) 6233 #define CATCH_SECTION(...) 6234 #define CATCH_DYNAMIC_SECTION(...) 6235 #define CATCH_FAIL(...) (void)(0) 6236 #define CATCH_FAIL_CHECK(...) (void)(0) 6237 #define CATCH_SUCCEED(...) (void)(0) 6238 #define CATCH_SKIP(...) (void)(0) 6240 #define CATCH_STATIC_REQUIRE(...) (void)(0) 6241 #define CATCH_STATIC_REQUIRE_FALSE(...) (void)(0) 6242 #define CATCH_STATIC_CHECK(...) (void)(0) 6243 #define CATCH_STATIC_CHECK_FALSE(...) (void)(0) 6246 #define CATCH_SCENARIO(...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6247 #define CATCH_SCENARIO_METHOD(className, ...) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), className) 6248 #define CATCH_GIVEN(desc) 6249 #define CATCH_AND_GIVEN(desc) 6250 #define CATCH_WHEN(desc) 6251 #define CATCH_AND_WHEN(desc) 6252 #define CATCH_THEN(desc) 6253 #define CATCH_AND_THEN(desc) 6255 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) // ^^ prefixed, disabled | vv unprefixed, implemented 6257 #define REQUIRE(...) INTERNAL_CATCH_TEST("REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__) 6258 #define REQUIRE_FALSE(...) INTERNAL_CATCH_TEST("REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__) 6260 #define REQUIRE_THROWS(...) INTERNAL_CATCH_THROWS("REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__) 6261 #define REQUIRE_THROWS_AS(expr, exceptionType) INTERNAL_CATCH_THROWS_AS("REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr) 6262 #define REQUIRE_NOTHROW(...) INTERNAL_CATCH_NO_THROW("REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__) 6264 #define CHECK(...) INTERNAL_CATCH_TEST("CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6265 #define CHECK_FALSE(...) INTERNAL_CATCH_TEST("CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__) 6266 #define CHECKED_IF(...) INTERNAL_CATCH_IF("CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6267 #define CHECKED_ELSE(...) INTERNAL_CATCH_ELSE("CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6268 #define CHECK_NOFAIL(...) INTERNAL_CATCH_TEST("CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__) 6270 #define CHECK_THROWS(...) INTERNAL_CATCH_THROWS("CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6271 #define CHECK_THROWS_AS(expr, exceptionType) INTERNAL_CATCH_THROWS_AS("CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr) 6272 #define CHECK_NOTHROW(...) INTERNAL_CATCH_NO_THROW("CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6274 #define TEST_CASE(...) INTERNAL_CATCH_TESTCASE(__VA_ARGS__) 6275 #define TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEST_CASE_METHOD(className, __VA_ARGS__) 6276 #define METHOD_AS_TEST_CASE(method, ...) INTERNAL_CATCH_METHOD_AS_TEST_CASE(method, __VA_ARGS__) 6277 #define TEST_CASE_PERSISTENT_FIXTURE(className, ...) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE(className, __VA_ARGS__) 6278 #define REGISTER_TEST_CASE(Function, ...) INTERNAL_CATCH_REGISTER_TESTCASE(Function, __VA_ARGS__) 6279 #define SECTION(...) INTERNAL_CATCH_SECTION(__VA_ARGS__) 6280 #define DYNAMIC_SECTION(...) INTERNAL_CATCH_DYNAMIC_SECTION(__VA_ARGS__) 6283 INTERNAL_CATCH_MSG("FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__); \ 6284 Catch::Detail::Unreachable(); \ 6286 #define FAIL_CHECK(...) INTERNAL_CATCH_MSG("FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6287 #define SUCCEED(...) INTERNAL_CATCH_MSG("SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__) 6290 INTERNAL_CATCH_MSG("SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__); \ 6291 Catch::Detail::Unreachable(); \ 6294 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) 6295 #define STATIC_REQUIRE(...) \ 6296 static_assert(__VA_ARGS__, #__VA_ARGS__); \ 6297 SUCCEED(#__VA_ARGS__) 6298 #define STATIC_REQUIRE_FALSE(...) \ 6299 static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")"); \ 6300 SUCCEED("!(" #__VA_ARGS__ ")") 6301 #define STATIC_CHECK(...) \ 6302 static_assert(__VA_ARGS__, #__VA_ARGS__); \ 6303 SUCCEED(#__VA_ARGS__) 6304 #define STATIC_CHECK_FALSE(...) \ 6305 static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")"); \ 6306 SUCCEED("!(" #__VA_ARGS__ ")") 6308 #define STATIC_REQUIRE(...) REQUIRE(__VA_ARGS__) 6309 #define STATIC_REQUIRE_FALSE(...) REQUIRE_FALSE(__VA_ARGS__) 6310 #define STATIC_CHECK(...) CHECK(__VA_ARGS__) 6311 #define STATIC_CHECK_FALSE(...) CHECK_FALSE(__VA_ARGS__) 6315 #define SCENARIO(...) TEST_CASE("Scenario: " __VA_ARGS__) 6316 #define SCENARIO_METHOD(className, ...) INTERNAL_CATCH_TEST_CASE_METHOD(className, "Scenario: " __VA_ARGS__) 6317 #define GIVEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" Given: " << desc) 6318 #define AND_GIVEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION("And given: " << desc) 6319 #define WHEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" When: " << desc) 6320 #define AND_WHEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" And when: " << desc) 6321 #define THEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" Then: " << desc) 6322 #define AND_THEN(desc) INTERNAL_CATCH_DYNAMIC_SECTION(" And: " << desc) 6324 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) // ^^ unprefixed, implemented | vv unprefixed, disabled 6326 #define REQUIRE(...) (void)(0) 6327 #define REQUIRE_FALSE(...) (void)(0) 6329 #define REQUIRE_THROWS(...) (void)(0) 6330 #define REQUIRE_THROWS_AS(expr, exceptionType) (void)(0) 6331 #define REQUIRE_NOTHROW(...) (void)(0) 6333 #define CHECK(...) (void)(0) 6334 #define CHECK_FALSE(...) (void)(0) 6335 #define CHECKED_IF(...) if (__VA_ARGS__) 6336 #define CHECKED_ELSE(...) if (!(__VA_ARGS__)) 6337 #define CHECK_NOFAIL(...) (void)(0) 6339 #define CHECK_THROWS(...) (void)(0) 6340 #define CHECK_THROWS_AS(expr, exceptionType) (void)(0) 6341 #define CHECK_NOTHROW(...) (void)(0) 6343 #define TEST_CASE(...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), __VA_ARGS__) 6344 #define TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6345 #define METHOD_AS_TEST_CASE(method, ...) 6346 #define TEST_CASE_PERSISTENT_FIXTURE(className, ...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), __VA_ARGS__) 6347 #define REGISTER_TEST_CASE(Function, ...) (void)(0) 6348 #define SECTION(...) 6349 #define DYNAMIC_SECTION(...) 6350 #define FAIL(...) (void)(0) 6351 #define FAIL_CHECK(...) (void)(0) 6352 #define SUCCEED(...) (void)(0) 6353 #define SKIP(...) (void)(0) 6355 #define STATIC_REQUIRE(...) (void)(0) 6356 #define STATIC_REQUIRE_FALSE(...) (void)(0) 6357 #define STATIC_CHECK(...) (void)(0) 6358 #define STATIC_CHECK_FALSE(...) (void)(0) 6361 #define SCENARIO(...) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_)) 6362 #define SCENARIO_METHOD(className, ...) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEST_), className) 6365 #define AND_GIVEN(desc) 6367 #define AND_WHEN(desc) 6369 #define AND_THEN(desc) 6371 #endif // ^^ unprefixed, disabled 6375 #endif // CATCH_TEST_MACROS_HPP_INCLUDED 6377 #ifndef CATCH_TEMPLATE_TEST_REGISTRY_HPP_INCLUDED 6378 #define CATCH_TEMPLATE_TEST_REGISTRY_HPP_INCLUDED 6380 #ifndef CATCH_PREPROCESSOR_HPP_INCLUDED 6381 #define CATCH_PREPROCESSOR_HPP_INCLUDED 6383 #if defined(__GNUC__) 6385 #pragma GCC system_header 6397 #define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ 6398 #define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) 6399 #define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) 6400 #define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) 6401 #define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) 6402 #define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) 6404 #ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6405 #define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ 6407 #define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) 6408 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) 6410 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) 6413 #define CATCH_REC_END(...) 6414 #define CATCH_REC_OUT 6416 #define CATCH_EMPTY() 6417 #define CATCH_DEFER(id) id CATCH_EMPTY() 6419 #define CATCH_REC_GET_END2() 0, CATCH_REC_END 6420 #define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 6421 #define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 6422 #define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT 6423 #define CATCH_REC_NEXT1(test, next) CATCH_DEFER(CATCH_REC_NEXT0)(test, next, 0) 6424 #define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) 6426 #define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__) 6427 #define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST0))(f, peek, __VA_ARGS__) 6428 #define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__) 6430 #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__) 6431 #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__) 6432 #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__) 6437 #define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) 6439 #define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) 6441 #define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) 6442 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6443 #define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ 6444 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) 6447 #define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) 6448 #define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ 6449 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) 6452 #define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ 6453 #define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) 6455 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6456 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>(Catch::Detail::priority_tag<1>{})) 6457 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) 6459 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>(Catch::Detail::priority_tag<1>{}))) 6460 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) 6463 #define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...) \ 6464 CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST, __VA_ARGS__) 6466 #define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) 6467 #define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) 6468 #define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) 6469 #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) 6470 #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) 6471 #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) 6472 #define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) 6473 #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) 6474 #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) 6475 #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) 6476 #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) 6478 #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N 6480 #define INTERNAL_CATCH_TYPE_GEN \ 6481 template<typename...> \ 6482 struct TypeList {}; \ 6483 template<typename... Ts> \ 6484 constexpr auto get_wrapper(Catch::Detail::priority_tag<1>) noexcept -> TypeList<Ts...> { \ 6487 template<template<typename...> class...> \ 6488 struct TemplateTypeList {}; \ 6489 template<template<typename...> class... Cs> \ 6490 constexpr auto get_wrapper(Catch::Detail::priority_tag<1>) noexcept -> TemplateTypeList<Cs...> { \ 6493 template<typename...> \ 6495 template<typename...> \ 6497 template<template<typename...> class, typename...> \ 6499 template<template<typename...> class, typename> \ 6502 template<typename T> \ 6503 struct append<T> { \ 6506 template<template<typename...> class L1, typename... E1, template<typename...> class L2, typename... E2, typename... Rest> \ 6507 struct append<L1<E1...>, L2<E2...>, Rest...> { \ 6508 using type = typename append<L1<E1..., E2...>, Rest...>::type; \ 6510 template<template<typename...> class L1, typename... E1, typename... Rest> \ 6511 struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { \ 6512 using type = L1<E1...>; \ 6515 template<template<typename...> class Container, template<typename...> class List, typename... elems> \ 6516 struct rewrap<TemplateTypeList<Container>, List<elems...>> { \ 6517 using type = TypeList<Container<elems...>>; \ 6519 template<template<typename...> class Container, template<typename...> class List, class... Elems, typename... Elements> \ 6520 struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { \ 6521 using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; \ 6524 template<template<typename...> class Final, template<typename...> class... Containers, typename... Types> \ 6525 struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { \ 6526 using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; \ 6528 template<template<typename...> class Final, template<typename...> class List, typename... Ts> \ 6529 struct convert<Final, List<Ts...>> { \ 6530 using type = typename append<Final<>, TypeList<Ts>...>::type; \ 6533 #define INTERNAL_CATCH_NTTP_1(signature, ...) \ 6534 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6536 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6537 constexpr auto get_wrapper(Catch::Detail::priority_tag<0>) noexcept -> Nttp<__VA_ARGS__> { \ 6540 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> \ 6541 struct NttpTemplateTypeList {}; \ 6542 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class... Cs> \ 6543 constexpr auto get_wrapper(Catch::Detail::priority_tag<0>) noexcept -> NttpTemplateTypeList<Cs...> { \ 6547 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6548 struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { \ 6549 using type = TypeList<Container<__VA_ARGS__>>; \ 6551 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename... Elements> \ 6552 struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { \ 6553 using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; \ 6555 template<template<typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class... Containers, typename... Types> \ 6556 struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { \ 6557 using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; \ 6560 #define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName) 6561 #define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature) \ 6562 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6563 static void TestName() 6564 #define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...) \ 6565 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6566 static void TestName() 6568 #define INTERNAL_CATCH_DEFINE_SIG_TEST0(TestName) 6569 #define INTERNAL_CATCH_DEFINE_SIG_TEST1(TestName, signature) \ 6570 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6571 static void TestName() 6572 #define INTERNAL_CATCH_DEFINE_SIG_TEST_X(TestName, signature, ...) \ 6573 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6574 static void TestName() 6576 #define INTERNAL_CATCH_TYPES_REGISTER(TestFunc) \ 6577 template<typename... Ts> \ 6578 void reg_test(TypeList<Ts...>, Catch::NameAndTags nameAndTags) { \ 6579 Catch::AutoReg(Catch::makeTestInvoker(&TestFunc<Ts...>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags); \ 6582 #define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature, ...) 6583 #define INTERNAL_CATCH_NTTP_REGISTER(TestFunc, signature, ...) \ 6584 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6585 void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags) { \ 6586 Catch::AutoReg(Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags); \ 6589 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...) \ 6590 template<typename Type> \ 6591 void reg_test(TypeList<Type>, Catch::StringRef className, Catch::NameAndTags nameAndTags) { \ 6592 Catch::AutoReg(Catch::makeTestInvoker(&TestName<Type>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags); \ 6595 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...) \ 6596 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6597 void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags) { \ 6598 Catch::AutoReg(Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags); \ 6601 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0(TestName, ClassName) 6602 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1(TestName, ClassName, signature) \ 6603 template<typename TestType> \ 6604 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<TestType> { \ 6608 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X(TestName, ClassName, signature, ...) \ 6609 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6610 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<__VA_ARGS__> { \ 6614 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0(TestName) 6615 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1(TestName, signature) \ 6616 template<typename TestType> \ 6617 void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<TestType>::test() 6618 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X(TestName, signature, ...) \ 6619 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ 6620 void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<__VA_ARGS__>::test() 6622 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6623 #define INTERNAL_CATCH_NTTP_0 6624 #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) 6625 #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__) 6626 #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__) 6627 #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__) 6628 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_TYPES_REGISTER(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__) 6629 #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__) 6630 #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__) 6631 #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__) 6633 #define INTERNAL_CATCH_NTTP_0(signature) 6634 #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__)) 6635 #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__)) 6636 #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__)) 6637 #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__)) 6638 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_TYPES_REGISTER(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__)) 6639 #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__)) 6640 #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__)) 6641 #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__)) 6644 #endif // CATCH_PREPROCESSOR_HPP_INCLUDED 6649 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 6650 #pragma GCC diagnostic ignored "-Wunused-variable" 6653 #if defined(CATCH_CONFIG_DISABLE) 6654 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2(TestName, TestFunc, Name, Tags, Signature, ...) \ 6655 INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) 6656 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ 6658 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6659 INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ 6662 INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) 6664 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6665 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ 6666 INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename TestType, __VA_ARGS__) 6668 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ 6669 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename TestType, __VA_ARGS__)) 6672 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6673 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ 6674 INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__) 6676 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ 6677 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__)) 6680 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6681 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(ClassName, Name, Tags, ...) \ 6682 INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__) 6684 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(ClassName, Name, Tags, ...) \ 6685 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__)) 6688 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6689 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(ClassName, Name, Tags, Signature, ...) \ 6690 INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__) 6692 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(ClassName, Name, Tags, Signature, ...) \ 6693 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__)) 6698 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ...) \ 6699 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6700 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6701 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 6702 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6703 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6704 CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ 6705 INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ 6707 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6708 INTERNAL_CATCH_TYPE_GEN \ 6709 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6710 INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6711 template<typename... Types> \ 6715 constexpr char const *tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ 6716 using expander = size_t[]; \ 6717 (void)expander{(reg_test(Types{}, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), index++)...}; \ 6720 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6721 TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>(); \ 6726 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6727 INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) 6729 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6730 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ 6731 INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename TestType, __VA_ARGS__) 6733 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ 6734 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename TestType, __VA_ARGS__)) 6737 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6738 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ 6739 INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__) 6741 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ 6742 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__)) 6745 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \ 6746 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6747 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6748 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 6749 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6750 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6751 CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ 6752 template<typename TestType> \ 6753 static void TestFuncName(); \ 6755 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6756 INTERNAL_CATCH_TYPE_GEN \ 6757 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6758 template<typename... Types> \ 6760 void reg_tests() { \ 6762 using expander = size_t[]; \ 6763 constexpr char const *tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ 6764 constexpr char const *types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ 6765 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ 6766 (void)expander{(Catch::AutoReg(Catch::makeTestInvoker(&TestFuncName<Types>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags}), index++)...}; \ 6769 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6770 using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ 6777 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6778 template<typename TestType> \ 6779 static void TestFuncName() 6781 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6782 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...) \ 6783 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename T, __VA_ARGS__) 6785 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...) \ 6786 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, typename T, __VA_ARGS__)) 6789 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6790 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...) \ 6791 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__) 6793 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...) \ 6794 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, Signature, __VA_ARGS__)) 6797 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList) \ 6798 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6799 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6800 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6801 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6802 CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ 6803 template<typename TestType> \ 6804 static void TestFunc(); \ 6806 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6807 INTERNAL_CATCH_TYPE_GEN \ 6808 template<typename... Types> \ 6810 void reg_tests() { \ 6812 using expander = size_t[]; \ 6813 (void)expander{(Catch::AutoReg(Catch::makeTestInvoker(&TestFunc<Types>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags}), index++)...}; \ 6816 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6817 using TestInit = typename convert<TestName, TmplList>::type; \ 6824 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6825 template<typename TestType> \ 6826 static void TestFunc() 6828 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \ 6829 INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), Name, Tags, TmplList) 6831 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ 6832 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6833 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6834 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 6835 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6836 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6838 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6839 INTERNAL_CATCH_TYPE_GEN \ 6840 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6841 INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ 6842 INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6843 template<typename... Types> \ 6844 struct TestNameClass { \ 6847 constexpr char const *tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)}; \ 6848 using expander = size_t[]; \ 6849 (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index]), Tags}), index++)...}; \ 6852 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6853 TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>(); \ 6858 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6859 INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) 6861 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6862 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(ClassName, Name, Tags, ...) \ 6863 INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__) 6865 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(ClassName, Name, Tags, ...) \ 6866 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__)) 6869 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6870 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(ClassName, Name, Tags, Signature, ...) \ 6871 INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__) 6873 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(ClassName, Name, Tags, Signature, ...) \ 6874 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_CLASS_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__)) 6877 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList) \ 6878 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6879 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6880 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ 6881 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6882 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6883 template<typename TestType> \ 6884 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName<TestType>) { \ 6888 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) { \ 6889 INTERNAL_CATCH_TYPE_GEN \ 6890 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ 6891 template<typename... Types> \ 6892 struct TestNameClass { \ 6893 void reg_tests() { \ 6894 std::size_t index = 0; \ 6895 using expander = std::size_t[]; \ 6896 constexpr char const *tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ 6897 constexpr char const *types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ 6898 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]); \ 6899 (void)expander{(Catch::AutoReg(Catch::makeTestInvoker(&TestName<Types>::test), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags}), index++)...}; \ 6902 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6903 using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ 6910 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6911 template<typename TestType> \ 6912 void TestName<TestType>::test() 6914 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6915 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(ClassName, Name, Tags, ...) \ 6916 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__) 6918 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(ClassName, Name, Tags, ...) \ 6919 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, typename T, __VA_ARGS__)) 6922 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6923 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(ClassName, Name, Tags, Signature, ...) \ 6924 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__) 6926 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(ClassName, Name, Tags, Signature, ...) \ 6927 INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, Signature, __VA_ARGS__)) 6930 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, TmplList) \ 6931 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 6932 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 6933 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ 6934 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ 6935 CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \ 6936 template<typename TestType> \ 6937 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName<TestType>) { \ 6941 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ 6942 INTERNAL_CATCH_TYPE_GEN \ 6943 template<typename... Types> \ 6944 struct TestNameClass { \ 6945 void reg_tests() { \ 6947 using expander = size_t[]; \ 6948 (void)expander{(Catch::AutoReg(Catch::makeTestInvoker(&TestName<Types>::test), CATCH_INTERNAL_LINEINFO, #ClassName##_catch_sr, Catch::NameAndTags{Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags}), index++)...}; \ 6951 static const int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ 6952 using TestInit = typename convert<TestNameClass, TmplList>::type; \ 6959 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 6960 template<typename TestType> \ 6961 void TestName<TestType>::test() 6963 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \ 6964 INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_TEMPLATE_TEST_), ClassName, Name, Tags, TmplList) 6966 #endif // CATCH_TEMPLATE_TEST_REGISTRY_HPP_INCLUDED 6968 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) 6970 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6971 #define CATCH_TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__) 6972 #define CATCH_TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(__VA_ARGS__) 6973 #define CATCH_TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 6974 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, __VA_ARGS__) 6975 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(__VA_ARGS__) 6976 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(__VA_ARGS__) 6977 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, __VA_ARGS__) 6978 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, __VA_ARGS__) 6979 #define CATCH_TEMPLATE_LIST_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__) 6980 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, __VA_ARGS__) 6982 #define CATCH_TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__)) 6983 #define CATCH_TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(__VA_ARGS__)) 6984 #define CATCH_TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__)) 6985 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, __VA_ARGS__)) 6986 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(__VA_ARGS__)) 6987 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(__VA_ARGS__)) 6988 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, __VA_ARGS__)) 6989 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, __VA_ARGS__)) 6990 #define CATCH_TEMPLATE_LIST_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__)) 6991 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, __VA_ARGS__)) 6994 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) 6996 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 6997 #define CATCH_TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) 6998 #define CATCH_TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) 6999 #define CATCH_TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) 7000 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__) 7002 #define CATCH_TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)) 7003 #define CATCH_TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)) 7004 #define CATCH_TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)) 7005 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__)) 7009 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE(...) CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__) 7010 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(...) CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__) 7011 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7012 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7013 #define CATCH_TEMPLATE_LIST_TEST_CASE(...) CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__) 7014 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7016 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) 7018 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 7019 #define TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__) 7020 #define TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(__VA_ARGS__) 7021 #define TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7022 #define TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, __VA_ARGS__) 7023 #define TEMPLATE_PRODUCT_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(__VA_ARGS__) 7024 #define TEMPLATE_PRODUCT_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(__VA_ARGS__) 7025 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, __VA_ARGS__) 7026 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, __VA_ARGS__) 7027 #define TEMPLATE_LIST_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__) 7028 #define TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, __VA_ARGS__) 7030 #define TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__)) 7031 #define TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(__VA_ARGS__)) 7032 #define TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__)) 7033 #define TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG(className, __VA_ARGS__)) 7034 #define TEMPLATE_PRODUCT_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(__VA_ARGS__)) 7035 #define TEMPLATE_PRODUCT_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(__VA_ARGS__)) 7036 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, __VA_ARGS__)) 7037 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, __VA_ARGS__)) 7038 #define TEMPLATE_LIST_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__)) 7039 #define TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(className, __VA_ARGS__)) 7042 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) 7044 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR 7045 #define TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) 7046 #define TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) 7047 #define TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) 7048 #define TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__) 7050 #define TEMPLATE_TEST_CASE(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)) 7051 #define TEMPLATE_TEST_CASE_SIG(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)) 7052 #define TEMPLATE_TEST_CASE_METHOD(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)) 7053 #define TEMPLATE_TEST_CASE_METHOD_SIG(className, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__)) 7057 #define TEMPLATE_PRODUCT_TEST_CASE(...) TEMPLATE_TEST_CASE(__VA_ARGS__) 7058 #define TEMPLATE_PRODUCT_TEST_CASE_SIG(...) TEMPLATE_TEST_CASE(__VA_ARGS__) 7059 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD(className, ...) TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7060 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(className, ...) TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7061 #define TEMPLATE_LIST_TEST_CASE(...) TEMPLATE_TEST_CASE(__VA_ARGS__) 7062 #define TEMPLATE_LIST_TEST_CASE_METHOD(className, ...) TEMPLATE_TEST_CASE_METHOD(className, __VA_ARGS__) 7064 #endif // end of user facing macro declarations 7066 #endif // CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED 7068 #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED 7069 #define CATCH_TEST_CASE_INFO_HPP_INCLUDED 7076 #pragma clang diagnostic push 7077 #pragma clang diagnostic ignored "-Wpadded" 7091 : original(original_) {}
7094 friend bool operator<(Tag
const &lhs, Tag
const &rhs);
7095 friend bool operator==(Tag
const &lhs, Tag
const &rhs);
7101 enum class TestCaseProperties : uint8_t {
7104 ShouldFail = 1 << 2,
7107 NonPortable = 1 << 5,
7125 bool isHidden()
const;
7126 bool throws()
const;
7127 bool okToFail()
const;
7128 bool expectedToFail()
const;
7131 void addFilenameTag();
7137 std::string tagsAsString()
const;
7143 std::string backingTags;
7146 void internalAppendTag(
StringRef tagString);
7149 std::vector<Tag> tags;
7151 TestCaseProperties properties = TestCaseProperties::None;
7166 : m_info(info), m_invoker(invoker) {}
7168 void prepareTestCase()
const {
7169 m_invoker->prepareTestCase();
7172 void tearDownTestCase()
const {
7173 m_invoker->tearDownTestCase();
7176 void invoke()
const {
7177 m_invoker->invoke();
7180 constexpr
TestCaseInfo const &getTestCaseInfo()
const {
7192 #pragma clang diagnostic pop 7195 #endif // CATCH_TEST_CASE_INFO_HPP_INCLUDED 7197 #ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED 7198 #define CATCH_TEST_RUN_INFO_HPP_INCLUDED 7210 #endif // CATCH_TEST_RUN_INFO_HPP_INCLUDED 7212 #ifndef CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED 7213 #define CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED 7215 #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 7216 #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 7222 using exceptionTranslateFunction = std::string (*)();
7225 using ExceptionTranslators = std::vector<Detail::unique_ptr<IExceptionTranslator const>>;
7230 virtual std::string translate(ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd)
const = 0;
7236 virtual std::string translateActiveException()
const = 0;
7241 #endif // CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 7243 #include <exception> 7247 void registerTranslatorImpl(
7252 template<
typename T>
7255 constexpr ExceptionTranslator(std::string (*translateFunction)(T
const &))
7256 : m_translateFunction(translateFunction) {}
7258 std::string translate(ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd)
const override {
7259 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 7262 std::rethrow_exception(std::current_exception());
7264 return (*it)->translate(it + 1, itEnd);
7265 }
catch (T
const &ex) {
7266 return m_translateFunction(ex);
7269 return "You should never get here!";
7274 std::string (*m_translateFunction)(T
const &);
7278 template<
typename T>
7280 Detail::registerTranslatorImpl(
7281 Detail::make_unique<ExceptionTranslator<T>>(
7282 translateFunction));
7289 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION2(translatorName, signature) \ 7290 static std::string translatorName(signature); \ 7291 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 7292 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 7294 const Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME(catch_internal_ExceptionRegistrar)(&translatorName); \ 7296 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 7297 static std::string translatorName(signature) 7299 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION(signature) INTERNAL_CATCH_TRANSLATE_EXCEPTION2(INTERNAL_CATCH_UNIQUE_NAME(catch_internal_ExceptionTranslator), signature) 7301 #if defined(CATCH_CONFIG_DISABLE) 7302 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG(translatorName, signature) \ 7303 static std::string translatorName(signature) 7307 #if !defined(CATCH_CONFIG_DISABLE) 7308 #define CATCH_TRANSLATE_EXCEPTION(signature) INTERNAL_CATCH_TRANSLATE_EXCEPTION(signature) 7310 #define CATCH_TRANSLATE_EXCEPTION(signature) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG(INTERNAL_CATCH_UNIQUE_NAME(catch_internal_ExceptionTranslator), signature) 7313 #endif // CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED 7315 #ifndef CATCH_VERSION_HPP_INCLUDED 7316 #define CATCH_VERSION_HPP_INCLUDED 7326 Version(
unsigned int _majorVersion,
7327 unsigned int _minorVersion,
7328 unsigned int _patchNumber,
7329 char const *
const _branchName,
7330 unsigned int _buildNumber);
7332 unsigned int const majorVersion;
7333 unsigned int const minorVersion;
7334 unsigned int const patchNumber;
7337 char const *
const branchName;
7338 unsigned int const buildNumber;
7340 friend std::ostream &operator<<(std::ostream &os,
Version const &version);
7343 Version const &libraryVersion();
7346 #endif // CATCH_VERSION_HPP_INCLUDED 7348 #ifndef CATCH_VERSION_MACROS_HPP_INCLUDED 7349 #define CATCH_VERSION_MACROS_HPP_INCLUDED 7351 #define CATCH_VERSION_MAJOR 3 7352 #define CATCH_VERSION_MINOR 14 7353 #define CATCH_VERSION_PATCH 0 7355 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED 7370 #ifndef CATCH_GENERATORS_ALL_HPP_INCLUDED 7371 #define CATCH_GENERATORS_ALL_HPP_INCLUDED 7373 #ifndef CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 7374 #define CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 7376 #include <exception> 7384 const char *
const m_msg =
"";
7390 const char *what()
const noexcept
final;
7395 #endif // CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 7397 #ifndef CATCH_GENERATORS_HPP_INCLUDED 7398 #define CATCH_GENERATORS_HPP_INCLUDED 7400 #ifndef CATCH_GENERATORS_THROW_HPP_INCLUDED 7401 #define CATCH_GENERATORS_THROW_HPP_INCLUDED 7404 namespace Generators {
7409 void throw_generator_exception(
char const *msg);
7415 #endif // CATCH_GENERATORS_THROW_HPP_INCLUDED 7417 #ifndef CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED 7418 #define CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED 7424 namespace Generators {
7428 mutable std::string m_stringReprCache;
7431 std::size_t m_currentElementIndex = 0;
7439 virtual bool next() = 0;
7442 virtual std::string stringifyImpl()
const = 0;
7451 virtual void skipToNthElementImpl(std::size_t n);
7474 std::size_t currentElementIndex()
const {
return m_currentElementIndex; }
7481 void skipToNthElement(std::size_t n);
7496 StringRef currentElementAsString()
const;
7505 virtual bool isFinite()
const;
7519 #endif // CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED 7526 namespace Generators {
7528 template<
typename T>
7530 std::string stringifyImpl()
const override {
7531 return ::Catch::Detail::stringify(
get());
7539 virtual T
const &
get()
const = 0;
7543 template<
typename T>
7546 template<
typename T>
7553 : m_generator(generator) {}
7557 T
const &
get()
const {
7558 return m_generator->get();
7561 return m_generator->countedNext();
7564 bool isFinite()
const {
return m_generator->isFinite(); }
7565 void skipToNthElement(
size_t n) { m_generator->skipToNthElement(n); }
7568 template<
typename T>
7578 T
const &
get()
const override {
7588 template<
typename T>
7590 static_assert(!std::is_same<T, bool>::value,
7591 "FixedValuesGenerator does not support bools because of std::vector<bool>" 7592 "specialization, use SingleValue Generator instead.");
7593 std::vector<T> m_values;
7596 void skipToNthElementImpl(std::size_t n)
override {
7597 if (n >= m_values.size()) {
7598 Detail::throw_generator_exception(
7599 "Coud not jump to Nth element: not enough elements");
7606 : m_values(values) {}
7608 T
const &
get()
const override {
7609 return m_values[m_idx];
7613 return m_idx < m_values.size();
7619 template<
typename T,
typename DecayedT = std::decay_t<T>>
7622 Catch::Detail::make_unique<SingleValueGenerator<DecayedT>>(
7625 template<
typename T>
7630 template<
typename T>
7632 std::vector<GeneratorWrapper<T>> m_generators;
7633 size_t m_current = 0;
7636 m_generators.emplace_back(
CATCH_MOVE(generator));
7638 void add_generator(T
const &val) {
7639 m_generators.emplace_back(value(val));
7641 void add_generator(T &&val) {
7642 m_generators.emplace_back(value(
CATCH_MOVE(val)));
7644 template<
typename U>
7645 std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value>
7646 add_generator(U &&val) {
7650 template<
typename U>
7651 void add_generators(U &&valueOrGenerator) {
7655 template<
typename U,
typename... Gs>
7656 void add_generators(U &&valueOrGenerator, Gs &&...moreGenerators) {
7662 template<
typename... Gs>
7664 m_generators.reserve(
sizeof...(Gs));
7668 T
const &
get()
const override {
7669 return m_generators[m_current].get();
7673 if (m_current >= m_generators.size()) {
7676 const bool current_status = m_generators[m_current].next();
7677 if (!current_status) {
7680 return m_current < m_generators.size();
7684 for (
auto const &gen : m_generators) {
7685 if (!gen.isFinite()) {
7693 template<
typename... Ts>
7695 table(std::initializer_list<std::tuple<std::decay_t<Ts>...>> tuples) {
7696 return values<std::tuple<Ts...>>(tuples);
7700 template<
typename T>
7703 template<
typename T,
typename... Gs>
7707 template<
typename T>
7711 template<
typename T,
typename... Gs>
7715 template<
typename T,
typename U,
typename... Gs>
7726 template<
typename L>
7727 auto generate(
StringRef generatorName,
SourceLineInfo const &lineInfo, L
const &generatorExpression) ->
typename decltype(generatorExpression())::type {
7728 using UnderlyingType =
typename decltype(generatorExpression())::type;
7734 tracker = createGeneratorTracker(
7738 generatorExpression()));
7742 return generator.get();
7748 #define CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL(...) #__VA_ARGS__##_catch_sr 7749 #define CATCH_INTERNAL_GENERATOR_STRINGIZE(...) CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL(__VA_ARGS__) 7751 #define GENERATE(...) \ 7752 Catch::Generators::generate(CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ 7753 CATCH_INTERNAL_LINEINFO, \ 7754 [] { using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); }) // NOLINT(google-build-using-namespace) 7755 #define GENERATE_COPY(...) \ 7756 Catch::Generators::generate(CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ 7757 CATCH_INTERNAL_LINEINFO, \ 7758 [=] { using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); }) // NOLINT(google-build-using-namespace) 7759 #define GENERATE_REF(...) \ 7760 Catch::Generators::generate(CATCH_INTERNAL_GENERATOR_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ 7761 CATCH_INTERNAL_LINEINFO, \ 7762 [&] { using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); }) // NOLINT(google-build-using-namespace) 7764 #endif // CATCH_GENERATORS_HPP_INCLUDED 7766 #ifndef CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED 7767 #define CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED 7774 template<
typename T>
7777 size_t m_returned = 0;
7780 void skipToNthElementImpl(std::size_t n)
override {
7781 if (n >= m_target) {
7782 Detail::throw_generator_exception(
7783 "Coud not jump to Nth element: not enough elements");
7786 m_generator.skipToNthElement(n);
7792 : m_generator(
CATCH_MOVE(generator)), m_target(target) {
7793 assert(target != 0 &&
"Empty generators are not allowed");
7795 T
const &
get()
const override {
7796 return m_generator.get();
7800 if (m_returned >= m_target) {
7804 const auto success = m_generator.next();
7808 m_returned = m_target;
7816 template<
typename T>
7821 template<
typename T,
typename Predicate>
7824 Predicate m_predicate;
7825 static_assert(!std::is_reference<Predicate>::value,
"This would most likely result in a dangling reference");
7828 template<
typename P>
7831 if (!m_predicate(m_generator.get())) {
7834 auto has_initial_value = next();
7835 if (!has_initial_value) {
7836 Detail::throw_generator_exception(
"No valid value found in filtered generator");
7841 T
const &
get()
const override {
7842 return m_generator.get();
7846 bool success = m_generator.next();
7850 while (!m_predicate(m_generator.get()) && (success = m_generator.next()) ==
true);
7854 bool isFinite()
const override {
return m_generator.isFinite(); }
7857 template<
typename T,
typename Predicate>
7862 template<
typename T>
7864 static_assert(!std::is_same<T, bool>::value,
7865 "RepeatGenerator currently does not support bools" 7866 "because of std::vector<bool> specialization");
7868 mutable std::vector<T> m_returned;
7869 size_t m_target_repeats;
7870 size_t m_current_repeat = 0;
7871 size_t m_repeat_index = 0;
7875 : m_generator(
CATCH_MOVE(generator)), m_target_repeats(repeats) {
7876 assert(m_target_repeats > 0 &&
"Repeat generator must repeat at least once");
7877 if (!m_generator.isFinite()) {
7878 Detail::throw_generator_exception(
"Cannot repeat infinite generator");
7882 T
const &
get()
const override {
7883 if (m_current_repeat == 0) {
7884 m_returned.push_back(m_generator.get());
7885 return m_returned.back();
7887 return m_returned[m_repeat_index];
7897 if (m_current_repeat == 0) {
7898 const auto success = m_generator.next();
7902 return m_current_repeat < m_target_repeats;
7907 if (m_repeat_index == m_returned.size()) {
7911 return m_current_repeat < m_target_repeats;
7914 bool isFinite()
const override {
return m_generator.isFinite(); }
7917 template<
typename T>
7922 template<
typename T,
typename U,
typename Func>
7930 void skipToNthElementImpl(std::size_t n)
override {
7931 m_generator.skipToNthElement(n);
7936 template<
typename F2 = Func>
7940 T
const &
get()
const override {
7941 if (!m_cache) { m_cache = m_function(m_generator.get()); }
7946 return m_generator.next();
7949 bool isFinite()
const override {
return m_generator.isFinite(); }
7952 template<
typename Func,
typename U,
typename T = FunctionReturnType<Func, U>>
7958 template<
typename T,
typename U,
typename Func>
7964 template<
typename T>
7966 std::vector<T> m_chunk;
7967 size_t m_chunk_size;
7972 : m_chunk_size(size), m_generator(
CATCH_MOVE(generator)) {
7973 m_chunk.reserve(m_chunk_size);
7974 if (m_chunk_size != 0) {
7975 m_chunk.push_back(m_generator.get());
7976 for (
size_t i = 1; i < m_chunk_size; ++i) {
7977 if (!m_generator.next()) {
7978 Detail::throw_generator_exception(
"Not enough values to initialize the first chunk");
7980 m_chunk.push_back(m_generator.get());
7984 std::vector<T>
const &
get()
const override {
7989 for (
size_t idx = 0; idx < m_chunk_size; ++idx) {
7990 if (!m_generator.next()) {
7993 m_chunk.push_back(m_generator.get());
7998 bool isFinite()
const override {
return m_generator.isFinite(); }
8001 template<
typename T>
8004 Catch::Detail::make_unique<ChunkGenerator<T>>(size,
CATCH_MOVE(generator)));
8007 template<
typename T>
8009 std::vector<GeneratorWrapper<T>> m_generators;
8010 size_t m_current_generator = 0;
8028 T
const &
get()
const override {
8029 return m_generators[m_current_generator].get();
8032 const bool success = m_generators[m_current_generator].next();
8033 if (success) {
return true; }
8036 ++m_current_generator;
8037 return m_current_generator < m_generators.size();
8041 for (
auto const &gen : m_generators) {
8042 if (!gen.isFinite()) {
return false; }
8052 Catch::Detail::make_unique<ConcatGenerator<T>>(
8059 #endif // CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED 8061 #ifndef CATCH_GENERATORS_RANDOM_HPP_INCLUDED 8062 #define CATCH_GENERATORS_RANDOM_HPP_INCLUDED 8064 #ifndef CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED 8065 #define CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED 8077 using state_type = std::uint64_t;
8080 using result_type = std::uint32_t;
8081 static constexpr result_type(min)() {
8084 static constexpr result_type(max)() {
8085 return static_cast<result_type
>(-1);
8094 void seed(result_type seed_);
8095 void discard(uint64_t skip);
8097 result_type operator()();
8106 std::uint64_t m_state;
8111 static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL;
8116 #endif // CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED 8118 #ifndef CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED 8119 #define CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED 8121 #ifndef CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED 8122 #define CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED 8127 #include <type_traits> 8134 #if defined(__SIZEOF_INT128__) 8135 #define CATCH_CONFIG_INTERNAL_UINT128 8139 #elif defined(_MSC_VER) && defined(_M_X64) 8140 #define CATCH_CONFIG_INTERNAL_MSVC_UMUL128 8143 #if defined(CATCH_CONFIG_INTERNAL_UINT128) && !defined(CATCH_CONFIG_NO_UINT128) && !defined(CATCH_CONFIG_UINT128) 8144 #define CATCH_CONFIG_UINT128 8147 #if defined(CATCH_CONFIG_INTERNAL_MSVC_UMUL128) && !defined(CATCH_CONFIG_NO_MSVC_UMUL128) && !defined(CATCH_CONFIG_MSVC_UMUL128) 8148 #define CATCH_CONFIG_MSVC_UMUL128 8155 template<std::
size_t>
8156 struct SizedUnsignedType;
8157 #define SizedUnsignedTypeHelper(TYPE) \ 8159 struct SizedUnsignedType<sizeof(TYPE)> { \ 8160 using type = TYPE; \ 8163 SizedUnsignedTypeHelper(std::uint8_t);
8164 SizedUnsignedTypeHelper(std::uint16_t);
8165 SizedUnsignedTypeHelper(std::uint32_t);
8166 SizedUnsignedTypeHelper(std::uint64_t);
8167 #undef SizedUnsignedTypeHelper 8169 template<std::
size_t sz>
8170 using SizedUnsignedType_t =
typename SizedUnsignedType<sz>::type;
8172 template<
typename T>
8173 using DoubleWidthUnsignedType_t = SizedUnsignedType_t<2 * sizeof(T)>;
8175 template<
typename T>
8176 struct ExtendedMultResult {
8179 constexpr
bool operator==(ExtendedMultResult
const &rhs)
const {
8180 return upper == rhs.upper && lower == rhs.lower;
8190 constexpr ExtendedMultResult<std::uint64_t>
8191 extendedMultPortable(std::uint64_t lhs, std::uint64_t rhs) {
8192 #define CarryBits(x) (x >> 32) 8193 #define Digits(x) (x & 0xFF'FF'FF'FF) 8194 std::uint64_t lhs_low = Digits(lhs);
8195 std::uint64_t rhs_low = Digits(rhs);
8196 std::uint64_t low_low = (lhs_low * rhs_low);
8197 std::uint64_t high_high = CarryBits(lhs) * CarryBits(rhs);
8200 std::uint64_t high_low = (CarryBits(lhs) * rhs_low) + CarryBits(low_low);
8203 std::uint64_t low_high = (lhs_low * CarryBits(rhs)) + Digits(high_low);
8205 return {high_high + CarryBits(high_low) + CarryBits(low_high),
8206 (low_high << 32) | Digits(low_low)};
8212 inline ExtendedMultResult<std::uint64_t>
8213 extendedMult(std::uint64_t lhs, std::uint64_t rhs) {
8214 #if defined(CATCH_CONFIG_UINT128) 8215 auto result = __uint128_t(lhs) * __uint128_t(rhs);
8216 return {
static_cast<std::uint64_t
>(result >> 64),
8217 static_cast<std::uint64_t>(result)};
8218 #elif defined(CATCH_CONFIG_MSVC_UMUL128) 8220 std::uint64_t low = _umul128(lhs, rhs, &high);
8223 return extendedMultPortable(lhs, rhs);
8227 template<
typename UInt>
8228 constexpr ExtendedMultResult<UInt> extendedMult(UInt lhs, UInt rhs) {
8229 static_assert(std::is_unsigned<UInt>::value,
8230 "extendedMult can only handle unsigned integers");
8231 static_assert(
sizeof(UInt) <
sizeof(std::uint64_t),
8232 "Generic extendedMult can only handle types smaller " 8234 using WideType = DoubleWidthUnsignedType_t<UInt>;
8236 auto result = WideType(lhs) * WideType(rhs);
8238 static_cast<UInt
>(result >> (CHAR_BIT *
sizeof(UInt))),
8239 static_cast<UInt>(result & UInt(-1))};
8242 template<
typename TargetType,
8244 std::enable_if_t<sizeof(typename Generator::result_type) >=
sizeof(TargetType),
8246 fillBitsFrom(Generator &gen) {
8247 using gresult_type =
typename Generator::result_type;
8248 static_assert(std::is_unsigned<TargetType>::value,
"Only unsigned integers are supported");
8249 static_assert(Generator::min() == 0 && Generator::max() == static_cast<gresult_type>(-1),
8250 "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)");
8254 constexpr
auto generated_bits =
sizeof(gresult_type) * CHAR_BIT;
8255 constexpr
auto return_bits =
sizeof(TargetType) * CHAR_BIT;
8257 return static_cast<TargetType
>(gen() >> (generated_bits - return_bits));
8260 template<
typename TargetType,
8262 std::enable_if_t<
sizeof(
typename Generator::result_type) <
sizeof(TargetType),
8264 fillBitsFrom(Generator &gen) {
8265 using gresult_type =
typename Generator::result_type;
8266 static_assert(std::is_unsigned<TargetType>::value,
8267 "Only unsigned integers are supported");
8268 static_assert(Generator::min() == 0 && Generator::max() == static_cast<gresult_type>(-1),
8269 "Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)");
8271 constexpr
auto generated_bits =
sizeof(gresult_type) * CHAR_BIT;
8272 constexpr
auto return_bits =
sizeof(TargetType) * CHAR_BIT;
8273 std::size_t filled_bits = 0;
8276 ret <<= generated_bits;
8278 filled_bits += generated_bits;
8279 }
while (filled_bits < return_bits);
8291 template<
typename OriginalType,
typename Un
signedType>
8292 constexpr std::enable_if_t<std::is_signed<OriginalType>::value, UnsignedType>
8293 transposeToNaturalOrder(UnsignedType in) {
8295 sizeof(OriginalType) ==
sizeof(UnsignedType),
8296 "reordering requires the same sized types on both sides");
8297 static_assert(std::is_unsigned<UnsignedType>::value,
8298 "Input type must be unsigned");
8303 constexpr
auto highest_bit = UnsignedType(1) << (
sizeof(UnsignedType) * CHAR_BIT - 1);
8304 return static_cast<UnsignedType
>(in ^ highest_bit);
8307 template<
typename OriginalType,
8308 typename UnsignedType>
8309 constexpr std::enable_if_t<std::is_unsigned<OriginalType>::value, UnsignedType>
8310 transposeToNaturalOrder(UnsignedType in) {
8312 sizeof(OriginalType) ==
sizeof(UnsignedType),
8313 "reordering requires the same sized types on both sides");
8314 static_assert(std::is_unsigned<UnsignedType>::value,
"Input type must be unsigned");
8321 #endif // CATCH_RANDOM_INTEGER_HELPERS_HPP_INCLUDED 8336 template<
typename IntegerType>
8337 class uniform_integer_distribution {
8338 static_assert(std::is_integral<IntegerType>::value,
"...");
8340 using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
8347 UnsignedIntegerType m_a;
8350 UnsignedIntegerType m_ab_distance;
8358 UnsignedIntegerType m_rejection_threshold = 0;
8360 static constexpr UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) {
8363 return transposeTo(b) - transposeTo(a) + 1;
8366 static constexpr UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) {
8369 if (ab_distance == 0) {
return 0; }
8370 return (~ab_distance + 1) % ab_distance;
8373 static constexpr UnsignedIntegerType transposeTo(IntegerType in) {
8374 return Detail::transposeToNaturalOrder<IntegerType>(
8375 static_cast<UnsignedIntegerType
>(in));
8377 static constexpr IntegerType transposeBack(UnsignedIntegerType in) {
8378 return static_cast<IntegerType
>(
8379 Detail::transposeToNaturalOrder<IntegerType>(in));
8383 using result_type = IntegerType;
8385 constexpr uniform_integer_distribution(IntegerType a, IntegerType b)
8386 : m_a(transposeTo(a)), m_ab_distance(computeDistance(a, b)), m_rejection_threshold(computeRejectionThreshold(m_ab_distance)) {
8390 template<
typename Generator>
8391 constexpr result_type operator()(Generator &g) {
8393 if (m_ab_distance == 0) {
8394 return transposeBack(Detail::fillBitsFrom<UnsignedIntegerType>(g));
8397 auto random_number = Detail::fillBitsFrom<UnsignedIntegerType>(g);
8398 auto emul = Detail::extendedMult(random_number, m_ab_distance);
8401 while (emul.lower < m_rejection_threshold) {
8402 random_number = Detail::fillBitsFrom<UnsignedIntegerType>(g);
8403 emul = Detail::extendedMult(random_number, m_ab_distance);
8406 return transposeBack(m_a + emul.upper);
8409 constexpr result_type a()
const {
return transposeBack(m_a); }
8410 constexpr result_type b()
const {
return transposeBack(m_ab_distance + m_a - 1); }
8415 #endif // CATCH_UNIFORM_INTEGER_DISTRIBUTION_HPP_INCLUDED 8417 #ifndef CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED 8418 #define CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED 8420 #ifndef CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED 8421 #define CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED 8423 #ifndef CATCH_POLYFILLS_HPP_INCLUDED 8424 #define CATCH_POLYFILLS_HPP_INCLUDED 8428 bool isnan(
float f);
8429 bool isnan(
double d);
8431 float nextafter(
float x,
float y);
8432 double nextafter(
double x,
double y);
8436 #endif // CATCH_POLYFILLS_HPP_INCLUDED 8442 #include <type_traits> 8452 template<
typename FloatType>
8453 FloatType gamma(FloatType a, FloatType b) {
8454 static_assert(std::is_floating_point<FloatType>::value,
8455 "gamma returns the largest ULP magnitude within " 8456 "floating point range [a, b]. This only makes sense " 8457 "for floating point types");
8460 const auto gamma_up = Catch::nextafter(a, std::numeric_limits<FloatType>::infinity()) - a;
8461 const auto gamma_down = b - Catch::nextafter(b, -std::numeric_limits<FloatType>::infinity());
8463 return gamma_up < gamma_down ? gamma_down : gamma_up;
8466 template<
typename FloatingPo
int>
8467 struct DistanceTypePicker;
8469 struct DistanceTypePicker<float> {
8470 using type = std::uint32_t;
8473 struct DistanceTypePicker<double> {
8474 using type = std::uint64_t;
8477 template<
typename T>
8478 using DistanceType =
typename DistanceTypePicker<T>::type;
8480 #if defined(__GNUC__) || defined(__clang__) 8481 #pragma GCC diagnostic push 8482 #pragma GCC diagnostic ignored "-Wfloat-equal" 8493 template<
typename FloatType>
8494 DistanceType<FloatType>
8495 count_equidistant_floats(FloatType a, FloatType b, FloatType distance) {
8499 const auto ag = a / distance;
8500 const auto bg = b / distance;
8502 const auto s = bg - ag;
8503 const auto err = (std::fabs(a) <= std::fabs(b))
8506 const auto ceil_s =
static_cast<DistanceType<FloatType>
>(std::ceil(s));
8508 return (ceil_s != s) ? ceil_s : ceil_s + (err > 0);
8510 #if defined(__GNUC__) || defined(__clang__) 8511 #pragma GCC diagnostic pop 8518 #endif // CATCH_RANDOM_FLOATING_POINT_HELPERS_HPP_INCLUDED 8521 #include <type_traits> 8526 #if defined(__GNUC__) || defined(__clang__) 8527 #pragma GCC diagnostic push 8528 #pragma GCC diagnostic ignored "-Wfloat-equal" 8534 constexpr std::uint64_t calculate_max_steps_in_one_go(
double gamma) {
8535 if (gamma == 1.99584030953472e+292) {
return 9007199254740991; }
8536 return static_cast<std::uint64_t
>(-1);
8538 constexpr std::uint32_t calculate_max_steps_in_one_go(
float gamma) {
8539 if (gamma == 2.028241e+31f) {
return 16777215; }
8540 return static_cast<std::uint32_t
>(-1);
8542 #if defined(__GNUC__) || defined(__clang__) 8543 #pragma GCC diagnostic pop 8573 template<
typename FloatType>
8574 class uniform_floating_point_distribution {
8575 static_assert(std::is_floating_point<FloatType>::value,
"...");
8576 static_assert(!std::is_same<FloatType, long double>::value,
8577 "We do not support long double due to inconsistent behaviour between platforms");
8579 using WidthType = Detail::DistanceType<FloatType>;
8582 FloatType m_ulp_magnitude;
8583 WidthType m_floats_in_range;
8584 uniform_integer_distribution<WidthType> m_int_dist;
8589 WidthType m_max_steps_in_one_go;
8591 bool m_a_has_leq_magnitude;
8594 using result_type = FloatType;
8596 uniform_floating_point_distribution(FloatType a, FloatType b)
8597 : m_a(a), m_b(b), m_ulp_magnitude(Detail::gamma(m_a, m_b)), m_floats_in_range(Detail::count_equidistant_floats(m_a, m_b, m_ulp_magnitude)), m_int_dist(0, m_floats_in_range), m_max_steps_in_one_go(Detail::calculate_max_steps_in_one_go(m_ulp_magnitude)), m_a_has_leq_magnitude(std::fabs(m_a) <= std::fabs(m_b)) {
8601 template<
typename Generator>
8602 result_type operator()(Generator &g) {
8603 WidthType steps = m_int_dist(g);
8604 if (m_a_has_leq_magnitude) {
8605 if (steps == m_floats_in_range) {
return m_a; }
8607 while (steps > m_max_steps_in_one_go) {
8608 b -= m_max_steps_in_one_go * m_ulp_magnitude;
8609 steps -= m_max_steps_in_one_go;
8611 return b - steps * m_ulp_magnitude;
8613 if (steps == m_floats_in_range) {
return m_b; }
8615 while (steps > m_max_steps_in_one_go) {
8616 a += m_max_steps_in_one_go * m_ulp_magnitude;
8617 steps -= m_max_steps_in_one_go;
8619 return a + steps * m_ulp_magnitude;
8623 result_type a()
const {
return m_a; }
8624 result_type b()
const {
return m_b; }
8629 #endif // CATCH_UNIFORM_FLOATING_POINT_DISTRIBUTION_HPP_INCLUDED 8632 namespace Generators {
8640 template<
typename Float>
8641 class RandomFloatingGenerator final :
public IGenerator<Float> {
8643 Catch::uniform_floating_point_distribution<Float> m_dist;
8644 Float m_current_number;
8647 RandomFloatingGenerator(Float a, Float b, std::uint32_t seed)
8648 : m_rng(seed), m_dist(a, b) {
8649 static_cast<void>(next());
8652 Float
const &
get()
const override {
8653 return m_current_number;
8655 bool next()
override {
8656 m_current_number = m_dist(m_rng);
8659 bool isFinite()
const override {
return false; }
8663 class RandomFloatingGenerator<long double> final :
public IGenerator<long double> {
8668 long double m_current_number;
8671 RandomFloatingGenerator(
long double a,
long double b, std::uint32_t seed);
8673 long double const &
get()
const override {
return m_current_number; }
8674 bool next()
override;
8676 ~RandomFloatingGenerator()
override;
8677 bool isFinite()
const override;
8680 template<
typename Integer>
8681 class RandomIntegerGenerator final :
public IGenerator<Integer> {
8683 Catch::uniform_integer_distribution<Integer> m_dist;
8684 Integer m_current_number;
8687 RandomIntegerGenerator(Integer a, Integer b, std::uint32_t seed)
8688 : m_rng(seed), m_dist(a, b) {
8689 static_cast<void>(next());
8692 Integer
const &
get()
const override {
8693 return m_current_number;
8695 bool next()
override {
8696 m_current_number = m_dist(m_rng);
8699 bool isFinite()
const override {
return false; }
8702 template<
typename T>
8703 std::enable_if_t<std::is_integral<T>::value, GeneratorWrapper<T>>
8705 return GeneratorWrapper<T>(
8706 Catch::Detail::make_unique<RandomIntegerGenerator<T>>(a, b, Detail::getSeed()));
8709 template<
typename T>
8710 std::enable_if_t<std::is_floating_point<T>::value,
8711 GeneratorWrapper<T>>
8713 return GeneratorWrapper<T>(
8714 Catch::Detail::make_unique<RandomFloatingGenerator<T>>(a, b, Detail::getSeed()));
8720 #endif // CATCH_GENERATORS_RANDOM_HPP_INCLUDED 8722 #ifndef CATCH_GENERATORS_RANGE_HPP_INCLUDED 8723 #define CATCH_GENERATORS_RANGE_HPP_INCLUDED 8726 #include <type_traits> 8729 namespace Generators {
8731 template<
typename T>
8732 class RangeGenerator final :
public IGenerator<T> {
8739 RangeGenerator(T
const &start, T
const &end, T
const &step)
8740 : m_current(start), m_end(end), m_step(step), m_positive(m_step > T(0)) {
8741 assert(m_current != m_end &&
"Range start and end cannot be equal");
8742 assert(m_step != T(0) &&
"Step size cannot be zero");
8743 assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) &&
"Step moves away from end");
8746 RangeGenerator(T
const &start, T
const &end)
8747 : RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) {}
8749 T
const &
get()
const override {
8753 bool next()
override {
8754 m_current += m_step;
8755 return (m_positive) ? (m_current < m_end) : (m_current > m_end);
8758 bool isFinite()
const override {
return true; }
8761 template<
typename T>
8762 GeneratorWrapper<T> range(T
const &start, T
const &end, T
const &step) {
8763 static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value,
"Type must be numeric");
8764 return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end, step));
8767 template<
typename T>
8768 GeneratorWrapper<T> range(T
const &start, T
const &end) {
8769 static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value,
"Type must be an integer");
8770 return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end));
8773 template<
typename T>
8774 class IteratorGenerator final :
public IGenerator<T> {
8775 static_assert(!std::is_same<T, bool>::value,
8776 "IteratorGenerator currently does not support bools" 8777 "because of std::vector<bool> specialization");
8779 std::vector<T> m_elems;
8780 size_t m_current = 0;
8783 template<
typename InputIterator,
typename InputSentinel>
8784 IteratorGenerator(InputIterator first, InputSentinel last)
8785 : m_elems(first, last) {
8786 if (m_elems.empty()) {
8787 Detail::throw_generator_exception(
"IteratorGenerator received no valid values");
8791 T
const &
get()
const override {
8792 return m_elems[m_current];
8795 bool next()
override {
8797 return m_current != m_elems.size();
8800 bool isFinite()
const override {
return true; }
8803 template<
typename InputIterator,
8804 typename InputSentinel,
8805 typename ResultType = std::remove_const_t<typename std::iterator_traits<InputIterator>::value_type>>
8806 GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) {
8807 return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(from, to));
8810 template<
typename Container>
8811 auto from_range(Container
const &cnt) {
8814 return from_range(begin(cnt), end(cnt));
8820 #endif // CATCH_GENERATORS_RANGE_HPP_INCLUDED 8822 #endif // CATCH_GENERATORS_ALL_HPP_INCLUDED 8837 #ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED 8838 #define CATCH_INTERFACES_ALL_HPP_INCLUDED 8840 #ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED 8841 #define CATCH_INTERFACES_REPORTER_HPP_INCLUDED 8849 struct ReporterDescription;
8850 struct ListenerDescription;
8856 enum class ColourMode : std::uint8_t;
8858 struct ReporterConfig {
8859 ReporterConfig(
IConfig const *_fullConfig,
8861 ColourMode colourMode,
8862 std::map<std::string, std::string> customOptions);
8864 ReporterConfig(ReporterConfig &&) =
default;
8865 ReporterConfig &operator=(ReporterConfig &&) =
default;
8869 IConfig const *fullConfig()
const;
8870 ColourMode colourMode()
const;
8871 std::map<std::string, std::string>
const &customOptions()
const;
8876 ColourMode m_colourMode;
8877 std::map<std::string, std::string> m_customOptions;
8880 struct AssertionStats {
8882 std::vector<MessageInfo>
const &_infoMessages,
8885 AssertionStats(AssertionStats
const &) =
default;
8886 AssertionStats(AssertionStats &&) =
default;
8887 AssertionStats &operator=(AssertionStats
const &) =
delete;
8888 AssertionStats &operator=(AssertionStats &&) =
delete;
8891 std::vector<MessageInfo> infoMessages;
8895 struct SectionStats {
8897 Counts const &_assertions,
8898 double _durationInSeconds,
8899 bool _missingAssertions);
8903 double durationInSeconds;
8904 bool missingAssertions;
8907 struct TestCaseStats {
8910 std::string &&_stdOut,
8911 std::string &&_stdErr,
8921 struct TestRunStats {
8934 struct ReporterPreferences {
8937 bool shouldRedirectStdOut =
false;
8940 bool shouldReportAllAssertions =
false;
8945 bool shouldReportAllAssertionStarts =
true;
8960 class IEventListener {
8963 ReporterPreferences m_preferences;
8968 IEventListener(
IConfig const *config)
8969 : m_config(config) {}
8971 virtual ~IEventListener();
8976 ReporterPreferences
const &getPreferences()
const {
8977 return m_preferences;
8981 virtual void noMatchingTestCases(
StringRef unmatchedSpec) = 0;
8983 virtual void reportInvalidTestSpec(
StringRef invalidArgument) = 0;
8990 virtual void testRunStarting(
TestRunInfo const &testRunInfo) = 0;
8993 virtual void testCaseStarting(
TestCaseInfo const &testInfo) = 0;
8995 virtual void testCasePartialStarting(
TestCaseInfo const &testInfo, uint64_t partNumber) = 0;
8997 virtual void sectionStarting(
SectionInfo const §ionInfo) = 0;
9000 virtual void benchmarkPreparing(
StringRef benchmarkName) = 0;
9002 virtual void benchmarkStarting(
BenchmarkInfo const &benchmarkInfo) = 0;
9006 virtual void benchmarkFailed(
StringRef benchmarkName) = 0;
9009 virtual void assertionStarting(
AssertionInfo const &assertionInfo) = 0;
9012 virtual void assertionEnded(AssertionStats
const &assertionStats) = 0;
9015 virtual void sectionEnded(SectionStats
const §ionStats) = 0;
9017 virtual void testCasePartialEnded(TestCaseStats
const &testCaseStats, uint64_t partNumber) = 0;
9019 virtual void testCaseEnded(TestCaseStats
const &testCaseStats) = 0;
9025 virtual void testRunEnded(TestRunStats
const &testRunStats) = 0;
9033 virtual void skipTest(
TestCaseInfo const &testInfo) = 0;
9036 virtual void fatalErrorEncountered(
StringRef error) = 0;
9039 virtual void listReporters(std::vector<ReporterDescription>
const &descriptions) = 0;
9041 virtual void listListeners(std::vector<ListenerDescription>
const &descriptions) = 0;
9043 virtual void listTests(std::vector<TestCaseHandle>
const &tests) = 0;
9045 virtual void listTags(std::vector<TagInfo>
const &tags) = 0;
9051 #endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED 9053 #ifndef CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED 9054 #define CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED 9060 struct ReporterConfig;
9062 class IEventListener;
9065 class IReporterFactory {
9067 virtual ~IReporterFactory();
9069 virtual IEventListenerPtr
9070 create(ReporterConfig &&config)
const 9072 virtual std::string getDescription()
const = 0;
9076 class EventListenerFactory {
9078 virtual ~EventListenerFactory();
9079 virtual IEventListenerPtr create(
IConfig const *config)
const = 0;
9083 virtual std::string getDescription()
const = 0;
9087 #endif // CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED 9089 #ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9090 #define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9098 class ITagAliasRegistry {
9100 virtual ~ITagAliasRegistry();
9102 virtual TagAlias const *find(std::string
const &alias)
const = 0;
9103 virtual std::string expandAliases(std::string
const &unexpandedTestSpec)
const = 0;
9105 static ITagAliasRegistry
const &
get();
9110 #endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9112 #ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 9113 #define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 9123 class ITestCaseRegistry {
9125 virtual ~ITestCaseRegistry();
9127 virtual std::vector<TestCaseInfo *>
const &getAllInfos()
const = 0;
9128 virtual std::vector<TestCaseHandle>
const &getAllTests()
const = 0;
9129 virtual std::vector<TestCaseHandle>
const &getAllTestsSorted(
IConfig const &config)
const = 0;
9134 #endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 9136 #endif // CATCH_INTERFACES_ALL_HPP_INCLUDED 9138 #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 9139 #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 9144 struct CaseInsensitiveLess {
9150 struct CaseInsensitiveEqualTo {
9158 #endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 9168 #ifndef CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 9169 #define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 9171 #if defined(__ANDROID__) 9172 #define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE 9175 #if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) 9176 #define CATCH_CONFIG_ANDROID_LOGWRITE 9179 #endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 9189 #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 9190 #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 9192 #if defined(_MSC_VER) 9193 #if _MSC_VER >= 1900 // Visual Studio 2015 or newer 9194 #define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS 9198 #include <exception> 9200 #if defined(__cpp_lib_uncaught_exceptions) \ 9201 && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) 9203 #define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS 9204 #endif // __cpp_lib_uncaught_exceptions 9206 #if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ 9207 && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ 9208 && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) 9210 #define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS 9213 #endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 9215 #ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED 9216 #define CATCH_CONSOLE_COLOUR_HPP_INCLUDED 9223 enum class ColourMode : std::uint8_t;
9240 BrightRed = Bright | Red,
9241 BrightGreen = Bright | Green,
9242 LightGrey = Bright | Grey,
9243 BrightWhite = Bright | White,
9244 BrightYellow = Bright | Yellow,
9247 FileName = LightGrey,
9248 Warning = BrightYellow,
9249 ResultError = BrightRed,
9250 ResultSuccess = BrightGreen,
9251 ResultExpectedFailure = Warning,
9257 OriginalExpression = Cyan,
9258 ReconstructedExpression = BrightYellow,
9260 SecondaryText = LightGrey,
9271 ColourImpl(IStream *stream)
9272 : m_stream(stream) {}
9277 ColourImpl
const *m_colourImpl;
9278 Colour::Code m_code;
9279 bool m_engaged =
false;
9283 ColourGuard(Colour::Code code,
9284 ColourImpl
const *colour);
9286 ColourGuard(ColourGuard
const &rhs) =
delete;
9287 ColourGuard &operator=(ColourGuard
const &rhs) =
delete;
9289 ColourGuard(ColourGuard &&rhs) noexcept;
9290 ColourGuard &operator=(ColourGuard &&rhs) noexcept;
9300 ColourGuard &engage(std::ostream &stream) &;
9306 ColourGuard &&engage(std::ostream &stream) &&;
9310 friend std::ostream &operator<<(std::ostream &lhs,
9311 ColourGuard &guard) {
9312 guard.engageImpl(lhs);
9316 friend std::ostream &operator<<(std::ostream &lhs,
9317 ColourGuard &&guard) {
9318 guard.engageImpl(lhs);
9322 void engageImpl(std::ostream &stream);
9325 virtual ~ColourImpl();
9332 ColourGuard guardColour(Colour::Code colourCode);
9335 virtual void use(Colour::Code colourCode)
const = 0;
9343 bool isColourImplAvailable(ColourMode colourSelection);
9347 #endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED 9349 #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED 9350 #define CATCH_CONSOLE_WIDTH_HPP_INCLUDED 9355 #ifndef CATCH_CONFIG_CONSOLE_WIDTH 9356 #define CATCH_CONFIG_CONSOLE_WIDTH 80 9359 #endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED 9361 #ifndef CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED 9362 #define CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED 9365 #include <initializer_list> 9371 #if defined(CATCH_CPP17_OR_GREATER) || defined(_MSC_VER) 9378 #if !defined(__cpp_lib_nonmember_container_access) 9379 #define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS 9383 #define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS 9389 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) 9390 template<
typename Container>
9391 constexpr
auto empty(Container
const &cont) -> decltype(cont.empty()) {
9392 return cont.empty();
9394 template<
typename T, std::
size_t N>
9395 constexpr
bool empty(
const T (&)[N]) noexcept {
9401 template<
typename T>
9402 constexpr
bool empty(std::initializer_list<T> list) noexcept {
9403 return list.size() > 0;
9406 template<
typename Container>
9407 constexpr
auto size(Container
const &cont) -> decltype(cont.size()) {
9410 template<
typename T, std::
size_t N>
9411 constexpr std::size_t size(
const T (&)[N]) noexcept {
9414 #endif // CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS 9419 #endif // CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED 9421 #ifndef CATCH_DEBUG_CONSOLE_HPP_INCLUDED 9422 #define CATCH_DEBUG_CONSOLE_HPP_INCLUDED 9427 void writeToDebugConsole(std::string
const &text);
9430 #endif // CATCH_DEBUG_CONSOLE_HPP_INCLUDED 9432 #ifndef CATCH_DEBUGGER_HPP_INCLUDED 9433 #define CATCH_DEBUGGER_HPP_INCLUDED 9436 bool isDebuggerActive();
9439 #if !defined(CATCH_TRAP) && defined(__clang__) && defined(__has_builtin) 9440 #if __has_builtin(__builtin_debugtrap) 9441 #define CATCH_TRAP() __builtin_debugtrap() 9445 #if !defined(CATCH_TRAP) && defined(_MSC_VER) 9446 #define CATCH_TRAP() __debugbreak() 9449 #if !defined(CATCH_TRAP) // If we couldn't use compiler-specific impl from above, we get into platform-specific options 9450 #ifdef CATCH_PLATFORM_MAC 9452 #if defined(__i386__) || defined(__x86_64__) 9453 #define CATCH_TRAP() __asm__("int $3\n" : :) 9454 #elif defined(__aarch64__) 9455 #define CATCH_TRAP() __asm__(".inst 0xd43e0000") 9456 #elif defined(__POWERPC__) 9457 #define CATCH_TRAP() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ 9458 : : : "memory", "r0", "r3", "r4") 9461 #elif defined(CATCH_PLATFORM_IPHONE) 9464 #if defined(__i386__) || defined(__x86_64__) 9465 #define CATCH_TRAP() __asm__("int $3") 9466 #elif defined(__aarch64__) 9467 #define CATCH_TRAP() __asm__(".inst 0xd4200000") 9468 #elif defined(__arm__) && !defined(__thumb__) 9469 #define CATCH_TRAP() __asm__(".inst 0xe7f001f0") 9470 #elif defined(__arm__) && defined(__thumb__) 9471 #define CATCH_TRAP() __asm__(".inst 0xde01") 9474 #elif defined(CATCH_PLATFORM_LINUX) || defined(CATCH_PLATFORM_QNX) 9478 #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) 9479 #define CATCH_TRAP() asm volatile("int $3") 9480 #else // Fall back to the generic way. 9483 #define CATCH_TRAP() raise(SIGTRAP) 9485 #elif defined(__MINGW32__) 9486 extern "C" __declspec(dllimport)
void __stdcall DebugBreak();
9487 #define CATCH_TRAP() DebugBreak() 9489 #endif // ^^ CATCH_TRAP is not defined yet, so we define it 9491 #if !defined(CATCH_BREAK_INTO_DEBUGGER) 9492 #if defined(CATCH_TRAP) 9493 #define CATCH_BREAK_INTO_DEBUGGER() [] { if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() 9495 #define CATCH_BREAK_INTO_DEBUGGER() [] {}() 9499 #endif // CATCH_DEBUGGER_HPP_INCLUDED 9501 #ifndef CATCH_ENFORCE_HPP_INCLUDED 9502 #define CATCH_ENFORCE_HPP_INCLUDED 9504 #include <exception> 9507 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 9508 template<
typename Ex>
9510 void throw_exception(Ex
const &e) {
9513 #else // ^^ Exceptions are enabled // Exceptions are disabled vv 9515 void throw_exception(std::exception
const &e);
9519 void throw_logic_error(std::string
const &msg);
9521 void throw_domain_error(std::string
const &msg);
9523 void throw_runtime_error(std::string
const &msg);
9527 #define CATCH_MAKE_MSG(...) \ 9528 (Catch::ReusableStringStream() << __VA_ARGS__).str() 9530 #define CATCH_INTERNAL_ERROR(...) \ 9531 Catch::throw_logic_error(CATCH_MAKE_MSG(CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__)) 9533 #define CATCH_ERROR(...) \ 9534 Catch::throw_domain_error(CATCH_MAKE_MSG(__VA_ARGS__)) 9536 #define CATCH_RUNTIME_ERROR(...) \ 9537 Catch::throw_runtime_error(CATCH_MAKE_MSG(__VA_ARGS__)) 9539 #define CATCH_ENFORCE(condition, ...) \ 9541 if (!(condition)) CATCH_ERROR(__VA_ARGS__); \ 9544 #endif // CATCH_ENFORCE_HPP_INCLUDED 9546 #ifndef CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 9547 #define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 9558 std::vector<Catch::Detail::unique_ptr<EnumInfo>> m_enumInfos;
9560 EnumInfo
const ®isterEnum(
StringRef enumName,
StringRef allValueNames, std::vector<int>
const &values)
override;
9563 std::vector<StringRef> parseEnums(
StringRef enums);
9569 #endif // CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 9571 #ifndef CATCH_ERRNO_GUARD_HPP_INCLUDED 9572 #define CATCH_ERRNO_GUARD_HPP_INCLUDED 9591 #endif // CATCH_ERRNO_GUARD_HPP_INCLUDED 9593 #ifndef CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 9594 #define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 9602 ~ExceptionTranslatorRegistry()
override;
9604 std::string translateActiveException()
const override;
9607 ExceptionTranslators m_translators;
9611 #endif // CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 9613 #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED 9614 #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED 9630 class FatalConditionHandler {
9631 bool m_started =
false;
9636 void engage_platform();
9637 void disengage_platform() noexcept;
9641 FatalConditionHandler();
9642 ~FatalConditionHandler();
9645 assert(!m_started &&
"Handler cannot be installed twice.");
9650 void disengage() noexcept {
9651 assert(m_started &&
"Handler cannot be uninstalled without being installed first");
9653 disengage_platform();
9658 class FatalConditionHandlerGuard {
9659 FatalConditionHandler *m_handler;
9662 FatalConditionHandlerGuard(FatalConditionHandler *handler)
9663 : m_handler(handler) {
9664 m_handler->engage();
9666 ~FatalConditionHandlerGuard() {
9667 m_handler->disengage();
9673 #endif // CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED 9675 #ifndef CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED 9676 #define CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED 9687 uint32_t convertToBits(
float f);
9688 uint64_t convertToBits(
double d);
9692 bool directCompare(
float lhs,
float rhs);
9693 bool directCompare(
double lhs,
double rhs);
9697 #if defined(__GNUC__) || defined(__clang__) 9698 #pragma GCC diagnostic push 9702 #pragma GCC diagnostic ignored "-Wfloat-equal" 9722 template<
typename FP>
9723 uint64_t ulpDistance(FP lhs, FP rhs) {
9724 assert(std::numeric_limits<FP>::is_iec559 &&
"ulpDistance assumes IEEE-754 format for floating point types");
9725 assert(!Catch::isnan(lhs) &&
"Distance between NaN and number is not meaningful");
9726 assert(!Catch::isnan(rhs) &&
"Distance between NaN and number is not meaningful");
9730 if (lhs == rhs) {
return 0; }
9733 static constexpr FP positive_zero{};
9736 if (lhs == positive_zero) { lhs = positive_zero; }
9737 if (rhs == positive_zero) { rhs = positive_zero; }
9741 if (std::signbit(lhs) != std::signbit(rhs)) {
9742 return ulpDistance(std::abs(lhs), positive_zero) + ulpDistance(std::abs(rhs), positive_zero);
9748 uint64_t lc = Detail::convertToBits(lhs);
9749 uint64_t rc = Detail::convertToBits(rhs);
9760 #if defined(__GNUC__) || defined(__clang__) 9761 #pragma GCC diagnostic pop 9766 #endif // CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED 9768 #ifndef CATCH_GETENV_HPP_INCLUDED 9769 #define CATCH_GETENV_HPP_INCLUDED 9775 char const *getEnv(
char const *varName);
9780 #endif // CATCH_GETENV_HPP_INCLUDED 9782 #ifndef CATCH_IS_PERMUTATION_HPP_INCLUDED 9783 #define CATCH_IS_PERMUTATION_HPP_INCLUDED 9786 #include <type_traits> 9791 template<
typename ForwardIter,
9794 typename Comparator>
9795 constexpr ForwardIter find_sentinel(ForwardIter start,
9799 while (start != sentinel) {
9800 if (cmp(*start, value)) {
break; }
9806 template<
typename ForwardIter,
9809 typename Comparator>
9810 constexpr std::ptrdiff_t count_sentinel(ForwardIter start,
9814 std::ptrdiff_t count = 0;
9815 while (start != sentinel) {
9816 if (cmp(*start, value)) { ++count; }
9822 template<
typename ForwardIter,
typename Sentinel>
9823 constexpr std::enable_if_t<!std::is_same<ForwardIter, Sentinel>::value,
9825 sentinel_distance(ForwardIter iter,
const Sentinel sentinel) {
9826 std::ptrdiff_t dist = 0;
9827 while (iter != sentinel) {
9834 template<
typename ForwardIter>
9835 constexpr std::ptrdiff_t sentinel_distance(ForwardIter first,
9837 return std::distance(first, last);
9840 template<
typename ForwardIter1,
9842 typename ForwardIter2,
9844 typename Comparator>
9845 constexpr
bool check_element_counts(ForwardIter1 first_1,
9846 const Sentinel1 end_1,
9847 ForwardIter2 first_2,
9848 const Sentinel2 end_2,
9850 auto cursor = first_1;
9851 while (cursor != end_1) {
9852 if (find_sentinel(first_1, cursor, *cursor, cmp) == cursor) {
9854 const auto count_in_range_2 = count_sentinel(first_2, end_2, *cursor, cmp);
9857 if (count_in_range_2 == 0) {
return false; }
9859 const auto count_in_range_1 = count_sentinel(cursor, end_1, *cursor, cmp);
9860 if (count_in_range_1 != count_in_range_2) {
9871 template<
typename ForwardIter1,
9873 typename ForwardIter2,
9875 typename Comparator>
9876 constexpr
bool is_permutation(ForwardIter1 first_1,
9877 const Sentinel1 end_1,
9878 ForwardIter2 first_2,
9879 const Sentinel2 end_2,
9884 while (first_1 != end_1 && first_2 != end_2 && cmp(*first_1, *first_2)) {
9890 if (first_1 == end_1 || first_2 == end_2) {
9891 return first_1 == end_1 && first_2 == end_2;
9895 auto dist_1 = sentinel_distance(first_1, end_1);
9896 auto dist_2 = sentinel_distance(first_2, end_2);
9898 if (dist_1 != dist_2) {
return false; }
9903 return check_element_counts(first_1, end_1, first_2, end_2, cmp);
9909 #endif // CATCH_IS_PERMUTATION_HPP_INCLUDED 9911 #ifndef CATCH_ISTREAM_HPP_INCLUDED 9912 #define CATCH_ISTREAM_HPP_INCLUDED 9922 virtual std::ostream &stream() = 0;
9934 virtual bool isConsole()
const {
return false; }
9952 #endif // CATCH_STREAM_HPP_INCLUDED 9954 #ifndef CATCH_JSONWRITER_HPP_INCLUDED 9955 #define CATCH_JSONWRITER_HPP_INCLUDED 9961 class JsonObjectWriter;
9962 class JsonArrayWriter;
9965 static void indent(std::ostream &os, std::uint64_t level);
9966 static void appendCommaNewline(std::ostream &os,
9968 std::uint64_t level);
9971 class JsonValueWriter {
9973 JsonValueWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND);
9974 JsonValueWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level);
9976 JsonObjectWriter writeObject() &&;
9977 JsonArrayWriter writeArray() &&;
9979 template<
typename T>
9980 void write(T
const &value) && {
9981 writeImpl(value, !std::is_arithmetic<T>::value);
9984 void write(
bool value) &&;
9987 void writeImpl(
StringRef value,
bool quote);
9993 template<
typename T,
9994 typename =
typename std::enable_if_t<
9995 !std::is_convertible<T, StringRef>::value>>
9996 void writeImpl(T
const &value,
bool quote_value) {
9998 writeImpl(m_sstream.str(), quote_value);
10001 std::ostream &m_os;
10002 std::stringstream m_sstream;
10003 std::uint64_t m_indent_level;
10006 class JsonObjectWriter {
10008 JsonObjectWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND);
10009 JsonObjectWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level);
10011 JsonObjectWriter(JsonObjectWriter &&source) noexcept;
10012 JsonObjectWriter &operator=(JsonObjectWriter &&source) =
delete;
10014 ~JsonObjectWriter();
10019 std::ostream &m_os;
10020 std::uint64_t m_indent_level;
10021 bool m_should_comma =
false;
10022 bool m_active =
true;
10025 class JsonArrayWriter {
10027 JsonArrayWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND);
10028 JsonArrayWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level);
10030 JsonArrayWriter(JsonArrayWriter &&source) noexcept;
10031 JsonArrayWriter &operator=(JsonArrayWriter &&source) =
delete;
10033 ~JsonArrayWriter();
10035 JsonObjectWriter writeObject();
10036 JsonArrayWriter writeArray();
10038 template<
typename T>
10039 JsonArrayWriter &write(T
const &value) {
10040 return writeImpl(value);
10043 JsonArrayWriter &write(
bool value);
10046 template<
typename T>
10047 JsonArrayWriter &writeImpl(T
const &value) {
10048 JsonUtils::appendCommaNewline(
10049 m_os, m_should_comma, m_indent_level + 1);
10050 JsonValueWriter{m_os}.write(value);
10055 std::ostream &m_os;
10056 std::uint64_t m_indent_level;
10057 bool m_should_comma =
false;
10058 bool m_active =
true;
10063 #endif // CATCH_JSONWRITER_HPP_INCLUDED 10065 #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED 10066 #define CATCH_LEAK_DETECTOR_HPP_INCLUDED 10070 struct LeakDetector {
10076 #endif // CATCH_LEAK_DETECTOR_HPP_INCLUDED 10078 #ifndef CATCH_LIST_HPP_INCLUDED 10079 #define CATCH_LIST_HPP_INCLUDED 10086 class IEventListener;
10089 struct ReporterDescription {
10090 std::string name, description;
10092 struct ListenerDescription {
10094 std::string description;
10099 std::string all()
const;
10101 std::set<StringRef> spellings;
10102 std::size_t count = 0;
10105 bool list(IEventListener &reporter,
Config const &config);
10109 #endif // CATCH_LIST_HPP_INCLUDED 10111 #ifndef CATCH_OUTPUT_REDIRECT_HPP_INCLUDED 10112 #define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED 10119 class OutputRedirect {
10120 bool m_redirectActive =
false;
10121 virtual void activateImpl() = 0;
10122 virtual void deactivateImpl() = 0;
10134 virtual ~OutputRedirect();
10137 virtual std::string getStdout() = 0;
10138 virtual std::string getStderr() = 0;
10139 virtual void clearBuffers() = 0;
10140 bool isActive()
const {
return m_redirectActive; }
10142 assert(!m_redirectActive &&
"redirect is already active");
10144 m_redirectActive =
true;
10146 void deactivate() {
10147 assert(m_redirectActive &&
"redirect is not active");
10149 m_redirectActive =
false;
10153 bool isRedirectAvailable(OutputRedirect::Kind kind);
10156 class RedirectGuard {
10157 OutputRedirect *m_redirect;
10159 bool m_previouslyActive;
10160 bool m_moved =
false;
10163 RedirectGuard(
bool activate, OutputRedirect &redirectImpl);
10164 ~RedirectGuard() noexcept(
false);
10166 RedirectGuard(RedirectGuard
const &) =
delete;
10167 RedirectGuard &operator=(RedirectGuard
const &) =
delete;
10170 RedirectGuard(RedirectGuard &&rhs) noexcept;
10171 RedirectGuard &operator=(RedirectGuard &&rhs) noexcept;
10174 RedirectGuard scopedActivate(OutputRedirect &redirectImpl);
10175 RedirectGuard scopedDeactivate(OutputRedirect &redirectImpl);
10179 #endif // CATCH_OUTPUT_REDIRECT_HPP_INCLUDED 10181 #ifndef CATCH_PARSE_NUMBERS_HPP_INCLUDED 10182 #define CATCH_PARSE_NUMBERS_HPP_INCLUDED 10197 #endif // CATCH_PARSE_NUMBERS_HPP_INCLUDED 10199 #ifndef CATCH_REPORTER_REGISTRY_HPP_INCLUDED 10200 #define CATCH_REPORTER_REGISTRY_HPP_INCLUDED 10208 class IEventListener;
10210 class IReporterFactory;
10212 struct ReporterConfig;
10213 class EventListenerFactory;
10215 class ReporterRegistry {
10216 struct ReporterRegistryImpl;
10220 ReporterRegistry();
10221 ~ReporterRegistry();
10223 IEventListenerPtr create(std::string
const &name,
10224 ReporterConfig &&config)
const;
10226 void registerReporter(std::string
const &name,
10232 std::map<std::string,
10234 Detail::CaseInsensitiveLess>
const &
10235 getFactories()
const;
10237 std::vector<Detail::unique_ptr<EventListenerFactory>>
const &
10238 getListeners()
const;
10243 #endif // CATCH_REPORTER_REGISTRY_HPP_INCLUDED 10245 #ifndef CATCH_RUN_CONTEXT_HPP_INCLUDED 10246 #define CATCH_RUN_CONTEXT_HPP_INCLUDED 10248 #ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED 10249 #define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED 10258 namespace TestCaseTracking {
10260 struct NameAndLocation {
10264 NameAndLocation(std::string &&_name,
SourceLineInfo const &_location);
10265 friend bool operator==(NameAndLocation
const &lhs, NameAndLocation
const &rhs) {
10270 if (lhs.location.line != rhs.location.line) {
return false; }
10271 return lhs.name == rhs.name && lhs.location == rhs.location;
10273 friend bool operator!=(NameAndLocation
const &lhs,
10274 NameAndLocation
const &rhs) {
10275 return !(lhs == rhs);
10286 struct NameAndLocationRef {
10290 constexpr NameAndLocationRef(
StringRef name_ CATCH_ATTR_LIFETIMEBOUND,
10292 : name(name_), location(location_) {}
10294 friend bool operator==(NameAndLocation
const &lhs,
10295 NameAndLocationRef
const &rhs) {
10300 if (lhs.location.line != rhs.location.line) {
return false; }
10301 return StringRef(lhs.name) == rhs.name && lhs.location == rhs.location;
10303 friend bool operator==(NameAndLocationRef
const &lhs,
10304 NameAndLocation
const &rhs) {
10314 NameAndLocation m_nameAndLocation;
10316 using Children = std::vector<ITrackerPtr>;
10324 CompletedSuccessfully,
10328 ITracker *m_parent =
nullptr;
10329 Children m_children;
10330 CycleState m_runState = NotStarted;
10333 std::vector<PathFilter>
const *m_filterRef =
nullptr;
10340 size_t m_allTrackerDepth =
static_cast<size_t>(-2);
10343 size_t m_sectionOnlyDepth =
static_cast<size_t>(-2);
10345 bool m_newStyleFilters =
false;
10348 ITracker(NameAndLocation &&nameAndLoc, ITracker *parent);
10351 NameAndLocation
const &nameAndLocation()
const {
10352 return m_nameAndLocation;
10354 ITracker *parent()
const {
10358 virtual ~ITracker();
10363 virtual bool isComplete()
const = 0;
10365 bool isSuccessfullyCompleted()
const {
10366 return m_runState == CompletedSuccessfully;
10369 bool isOpen()
const;
10371 bool hasStarted()
const;
10373 void setFilters(std::vector<PathFilter>
const *filters,
bool newStyleFilters) {
10374 m_filterRef = filters;
10375 m_newStyleFilters = newStyleFilters;
10379 virtual void close() = 0;
10380 virtual void fail() = 0;
10381 void markAsNeedingAnotherRun();
10384 void addChild(ITrackerPtr &&child);
10390 ITracker *findChild(NameAndLocationRef
const &nameAndLocation);
10392 bool hasChildren()
const {
10393 return !m_children.empty();
10405 virtual bool isSectionTracker()
const;
10412 virtual bool isGeneratorTracker()
const;
10415 class TrackerContext {
10422 ITrackerPtr m_rootTracker;
10423 ITracker *m_currentTracker =
nullptr;
10424 RunState m_runState = NotStarted;
10427 ITracker &startRun();
10429 void startCycle() {
10430 m_currentTracker = m_rootTracker.get();
10431 m_runState = Executing;
10433 void completeCycle();
10435 bool completedCycle()
const;
10436 ITracker ¤tTracker() {
return *m_currentTracker; }
10437 void setCurrentTracker(ITracker *tracker);
10440 class TrackerBase :
public ITracker {
10442 TrackerContext &m_ctx;
10445 TrackerBase(NameAndLocation &&nameAndLocation, TrackerContext &ctx, ITracker *parent);
10447 bool isComplete()
const override;
10451 void close()
override;
10452 void fail()
override;
10455 void moveToParent();
10459 class SectionTracker final :
public TrackerBase {
10467 SectionTracker(NameAndLocation &&nameAndLocation, TrackerContext &ctx, ITracker *parent);
10469 bool isSectionTracker()
const override;
10471 bool isComplete()
const override;
10473 static SectionTracker &acquire(TrackerContext &ctx, NameAndLocationRef
const &nameAndLocation);
10483 using TestCaseTracking::ITracker;
10484 using TestCaseTracking::SectionTracker;
10485 using TestCaseTracking::TrackerContext;
10489 #endif // CATCH_TEST_CASE_TRACKER_HPP_INCLUDED 10491 #ifndef CATCH_THREAD_SUPPORT_HPP_INCLUDED 10492 #define CATCH_THREAD_SUPPORT_HPP_INCLUDED 10494 #if defined(CATCH_CONFIG_THREAD_SAFE_ASSERTIONS) 10501 #if defined(CATCH_CONFIG_THREAD_SAFE_ASSERTIONS) 10502 using Mutex = std::mutex;
10503 using LockGuard = std::lock_guard<std::mutex>;
10504 struct AtomicCounts {
10505 std::atomic<std::uint64_t> passed{0};
10506 std::atomic<std::uint64_t> failed{0};
10507 std::atomic<std::uint64_t> failedButOk{0};
10508 std::atomic<std::uint64_t> skipped{0};
10510 #else // ^^ Use actual mutex, lock and atomics 10519 LockGuard(Mutex) {}
10522 using AtomicCounts =
Counts;
10528 #endif // CATCH_THREAD_SUPPORT_HPP_INCLUDED 10536 class IEventListener;
10538 class OutputRedirect;
10544 RunContext(RunContext
const &) =
delete;
10545 RunContext &operator=(RunContext
const &) =
delete;
10547 explicit RunContext(
IConfig const *_config, IEventListenerPtr &&reporter);
10549 ~RunContext()
override;
10559 ResultWas::OfType resultType,
10560 std::string &&message,
10562 void handleUnexpectedExceptionNotThrown(
AssertionInfo const &info,
10564 void handleUnexpectedInflightException(
AssertionInfo const &info,
10565 std::string &&message,
10569 ResultWas::OfType resultType,
10572 void notifyAssertionStarted(
AssertionInfo const &info)
override;
10573 bool sectionStarted(
StringRef sectionName,
10575 Counts &assertions)
override;
10581 acquireGeneratorTracker(
StringRef generatorName,
10588 void benchmarkPreparing(
StringRef name)
override;
10589 void benchmarkStarting(
BenchmarkInfo const &info)
override;
10591 void benchmarkFailed(
StringRef error)
override;
10593 std::string getCurrentTestName()
const override;
10597 void exceptionEarlyReported()
override;
10599 void handleFatalErrorCondition(
StringRef message)
override;
10601 bool lastAssertionPassed()
override;
10605 bool aborting()
const;
10610 void updateTotalsFromAtomics();
10612 void runCurrentTest();
10613 void invokeActiveTestCase();
10615 bool testForMissingAssertions(
Counts &assertions);
10619 ResultWas::OfType resultType,
10623 void populateReaction(
AssertionReaction &reaction,
bool has_normal_disposition);
10631 void handleUnfinishedSections();
10632 mutable Detail::Mutex m_assertionMutex;
10635 ITracker *m_testCaseTracker =
nullptr;
10639 Detail::AtomicCounts m_atomicAssertionCount;
10640 IEventListenerPtr m_reporter;
10641 std::vector<SectionEndInfo> m_unfinishedSections;
10642 std::vector<ITracker *> m_activeSections;
10643 TrackerContext m_trackerContext;
10645 FatalConditionHandler m_fatalConditionhandler;
10647 size_t m_abortAfterXFailedAssertions;
10648 bool m_shouldReportUnexpected =
true;
10650 bool m_reportAssertionStarting;
10652 bool m_includeSuccessfulResults;
10654 bool m_shouldDebugBreak;
10657 void seedRng(
IConfig const &config);
10658 unsigned int rngSeed();
10661 #endif // CATCH_RUN_CONTEXT_HPP_INCLUDED 10663 #ifndef CATCH_SHARDING_HPP_INCLUDED 10664 #define CATCH_SHARDING_HPP_INCLUDED 10666 #include <algorithm> 10671 template<
typename Container>
10672 Container createShard(Container
const &container, std::size_t
const shardCount, std::size_t
const shardIndex) {
10673 assert(shardCount > shardIndex);
10675 if (shardCount == 1) {
10679 const std::size_t totalTestCount = container.size();
10681 const std::size_t shardSize = totalTestCount / shardCount;
10682 const std::size_t leftoverTests = totalTestCount % shardCount;
10684 const std::size_t startIndex = shardIndex * shardSize + (std::min)(shardIndex, leftoverTests);
10685 const std::size_t endIndex = (shardIndex + 1) * shardSize + (std::min)(shardIndex + 1, leftoverTests);
10687 auto startIterator = std::next(container.begin(),
static_cast<std::ptrdiff_t
>(startIndex));
10688 auto endIterator = std::next(container.begin(),
static_cast<std::ptrdiff_t
>(endIndex));
10690 return Container(startIterator, endIterator);
10695 #endif // CATCH_SHARDING_HPP_INCLUDED 10697 #ifndef CATCH_SINGLETONS_HPP_INCLUDED 10698 #define CATCH_SINGLETONS_HPP_INCLUDED 10702 struct ISingleton {
10703 virtual ~ISingleton();
10706 void addSingleton(ISingleton *singleton);
10707 void cleanupSingletons();
10709 template<
typename SingletonImplT,
typename InterfaceT = SingletonImplT,
typename MutableInterfaceT = InterfaceT>
10710 class Singleton : SingletonImplT,
public ISingleton {
10711 static auto getInternal() -> Singleton * {
10712 static Singleton *s_instance =
nullptr;
10714 s_instance =
new Singleton;
10715 addSingleton(s_instance);
10721 static auto get() -> InterfaceT
const & {
10722 return *getInternal();
10724 static auto getMutable() -> MutableInterfaceT & {
10725 return *getInternal();
10731 #endif // CATCH_SINGLETONS_HPP_INCLUDED 10733 #ifndef CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 10734 #define CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 10736 #include <exception> 10741 class StartupExceptionRegistry {
10742 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 10744 void add(std::exception_ptr
const &exception) noexcept;
10745 std::vector<std::exception_ptr>
const &getExceptions()
const noexcept;
10748 std::vector<std::exception_ptr> m_exceptions;
10754 #endif // CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 10756 #ifndef CATCH_STDSTREAMS_HPP_INCLUDED 10757 #define CATCH_STDSTREAMS_HPP_INCLUDED 10763 std::ostream &cout();
10764 std::ostream &cerr();
10765 std::ostream &clog();
10771 #ifndef CATCH_STRING_MANIP_HPP_INCLUDED 10772 #define CATCH_STRING_MANIP_HPP_INCLUDED 10781 bool startsWith(std::string
const &s, std::string
const &prefix);
10782 bool startsWith(
StringRef s,
char prefix);
10783 bool endsWith(std::string
const &s, std::string
const &suffix);
10784 bool endsWith(std::string
const &s,
char suffix);
10785 bool contains(std::string
const &s, std::string
const &infix);
10786 void toLowerInPlace(std::string &s);
10787 std::string toLower(std::string
const &s);
10788 char toLower(
char c);
10790 std::string trim(std::string
const &str);
10795 std::vector<StringRef> splitStringRef(
StringRef str CATCH_ATTR_LIFETIMEBOUND,
char delimiter);
10796 bool replaceInPlace(std::string &str, std::string
const &replaceThis, std::string
const &withThis);
10809 std::uint64_t m_count;
10813 constexpr pluralise(std::uint64_t count,
StringRef label CATCH_ATTR_LIFETIMEBOUND)
10814 : m_count(count), m_label(label) {}
10816 friend std::ostream &operator<<(std::ostream &os, pluralise
const &pluraliser);
10820 #endif // CATCH_STRING_MANIP_HPP_INCLUDED 10822 #ifndef CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10823 #define CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10831 class TagAliasRegistry :
public ITagAliasRegistry {
10833 ~TagAliasRegistry()
override;
10834 TagAlias const *find(std::string
const &alias)
const override;
10835 std::string expandAliases(std::string
const &unexpandedTestSpec)
const override;
10836 void add(std::string
const &alias, std::string
const &tag,
SourceLineInfo const &lineInfo);
10839 std::map<std::string, TagAlias> m_registry;
10844 #endif // CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10846 #ifndef CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 10847 #define CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 10855 class TestCaseInfoHasher {
10857 using hash_t = std::uint64_t;
10858 TestCaseInfoHasher(hash_t seed);
10869 #ifndef CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED 10870 #define CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED 10881 std::vector<TestCaseHandle> sortTests(
IConfig const &config, std::vector<TestCaseHandle>
const &unsortedTestCases);
10885 std::vector<TestCaseHandle> filterTests(std::vector<TestCaseHandle>
const &testCases,
TestSpec const &testSpec,
IConfig const &config);
10886 std::vector<TestCaseHandle>
const &getAllTestCasesSorted(
IConfig const &config);
10888 class TestRegistry :
public ITestCaseRegistry {
10892 std::vector<TestCaseInfo *>
const &getAllInfos()
const override;
10893 std::vector<TestCaseHandle>
const &getAllTests()
const override;
10894 std::vector<TestCaseHandle>
const &getAllTestsSorted(
IConfig const &config)
const override;
10896 ~TestRegistry()
override;
10899 std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
10902 std::vector<TestCaseInfo *> m_viewed_test_infos;
10904 std::vector<Detail::unique_ptr<ITestInvoker>> m_invokers;
10905 std::vector<TestCaseHandle> m_handles;
10906 mutable TestRunOrder m_currentSortOrder = TestRunOrder::Declared;
10907 mutable std::vector<TestCaseHandle> m_sortedFunctions;
10914 #endif // CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED 10916 #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED 10917 #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED 10920 #pragma clang diagnostic push 10921 #pragma clang diagnostic ignored "-Wpadded" 10929 class ITagAliasRegistry;
10931 class TestSpecParser {
10937 Mode m_mode = None;
10938 Mode lastMode = None;
10939 bool m_exclusion =
false;
10940 std::size_t m_pos = 0;
10941 std::size_t m_realPatternPos = 0;
10943 std::string m_substring;
10944 std::string m_patternName;
10945 std::vector<std::size_t> m_escapeChars;
10946 TestSpec::Filter m_currentFilter;
10948 ITagAliasRegistry
const *m_tagAliases =
nullptr;
10951 TestSpecParser(ITagAliasRegistry
const &tagAliases);
10953 TestSpecParser &parse(std::string
const &arg);
10957 bool visitChar(
char c);
10958 void startNewMode(Mode mode);
10959 bool processNoneChar(
char c);
10960 void processNameChar(
char c);
10961 bool processOtherChar(
char c);
10964 bool isControlChar(
char c)
const;
10965 void saveLastMode();
10966 void revertBackToLastMode();
10971 std::string preprocessPattern();
10973 void addNamePattern();
10975 void addTagPattern();
10977 inline void addCharToPattern(
char c) {
10979 m_patternName += c;
10980 m_realPatternPos++;
10987 #pragma clang diagnostic pop 10990 #endif // CATCH_TEST_SPEC_PARSER_HPP_INCLUDED 10992 #ifndef CATCH_TEXTFLOW_HPP_INCLUDED 10993 #define CATCH_TEXTFLOW_HPP_INCLUDED 11000 namespace TextFlow {
11016 class AnsiSkippingString {
11017 std::string m_string;
11018 std::size_t m_size = 0;
11021 void preprocessString();
11024 class const_iterator;
11025 using iterator = const_iterator;
11028 static constexpr
char sentinel =
static_cast<char>(0xffu);
11030 explicit AnsiSkippingString(std::string
const &text);
11031 explicit AnsiSkippingString(std::string &&text);
11033 const_iterator begin()
const;
11034 const_iterator end()
const;
11036 size_t size()
const {
return m_size; }
11038 std::string substring(const_iterator begin,
11039 const_iterator end)
const;
11042 class AnsiSkippingString::const_iterator {
11043 friend AnsiSkippingString;
11046 const std::string *m_string;
11047 std::string::const_iterator m_it;
11049 explicit const_iterator(
const std::string &
string, EndTag)
11050 : m_string(&
string), m_it(
string.end()) {}
11052 void tryParseAnsiEscapes();
11057 using difference_type = std::ptrdiff_t;
11058 using value_type = char;
11059 using pointer = value_type *;
11060 using reference = value_type &;
11061 using iterator_category = std::bidirectional_iterator_tag;
11063 explicit const_iterator(
const std::string &
string)
11064 : m_string(&
string), m_it(
string.begin()) {
11065 tryParseAnsiEscapes();
11068 char operator*()
const {
return *m_it; }
11070 const_iterator &operator++() {
11074 const_iterator operator++(
int) {
11075 iterator prev(*
this);
11079 const_iterator &operator--() {
11083 const_iterator operator--(
int) {
11084 iterator prev(*
this);
11089 bool operator==(const_iterator
const &other)
const {
11090 return m_it == other.m_it;
11092 bool operator!=(const_iterator
const &other)
const {
11093 return !operator==(other);
11095 bool operator<=(const_iterator
const &other)
const {
11096 return m_it <= other.m_it;
11099 const_iterator oneBefore()
const {
11114 AnsiSkippingString m_string;
11116 size_t m_width = CATCH_CONFIG_CONSOLE_WIDTH - 1;
11119 size_t m_indent = 0;
11121 size_t m_initialIndent = std::string::npos;
11127 class const_iterator {
11131 Column
const &m_column;
11133 AnsiSkippingString::const_iterator m_lineStart;
11135 AnsiSkippingString::const_iterator m_lineEnd;
11137 AnsiSkippingString::const_iterator m_parsedTo;
11139 bool m_addHyphen =
false;
11141 const_iterator(Column
const &column, EndTag)
11142 : m_column(column), m_lineStart(m_column.m_string.end()), m_lineEnd(column.m_string.end()), m_parsedTo(column.m_string.end()) {}
11148 size_t indentSize()
const;
11152 std::string addIndentAndSuffix(
11153 AnsiSkippingString::const_iterator start,
11154 AnsiSkippingString::const_iterator end)
const;
11157 using difference_type = std::ptrdiff_t;
11158 using value_type = std::string;
11159 using pointer = value_type *;
11160 using reference = value_type &;
11161 using iterator_category = std::forward_iterator_tag;
11163 explicit const_iterator(Column
const &column);
11165 std::string operator*()
const;
11167 const_iterator &operator++();
11168 const_iterator operator++(
int);
11170 bool operator==(const_iterator
const &other)
const {
11171 return m_lineStart == other.m_lineStart && &m_column == &other.m_column;
11173 bool operator!=(const_iterator
const &other)
const {
11174 return !operator==(other);
11177 using iterator = const_iterator;
11179 explicit Column(std::string
const &text)
11180 : m_string(text) {}
11181 explicit Column(std::string &&text)
11184 Column &width(
size_t newWidth) & {
11185 assert(newWidth > 0);
11186 m_width = newWidth;
11189 Column &&width(
size_t newWidth) && {
11190 assert(newWidth > 0);
11191 m_width = newWidth;
11194 Column &indent(
size_t newIndent) & {
11195 m_indent = newIndent;
11198 Column &&indent(
size_t newIndent) && {
11199 m_indent = newIndent;
11202 Column &initialIndent(
size_t newIndent) & {
11203 m_initialIndent = newIndent;
11206 Column &&initialIndent(
size_t newIndent) && {
11207 m_initialIndent = newIndent;
11211 size_t width()
const {
return m_width; }
11212 const_iterator begin()
const {
return const_iterator(*
this); }
11213 const_iterator end()
const {
11214 return {*
this, const_iterator::EndTag{}};
11217 friend std::ostream &operator<<(std::ostream &os,
11218 Column
const &col);
11220 friend Columns operator+(Column
const &lhs, Column
const &rhs);
11221 friend Columns operator+(Column &&lhs, Column &&rhs);
11225 Column Spacer(
size_t spaceWidth);
11228 std::vector<Column> m_columns;
11235 std::vector<Column>
const &m_columns;
11236 std::vector<Column::const_iterator> m_iterators;
11237 size_t m_activeIterators;
11239 iterator(Columns
const &columns, EndTag);
11242 using difference_type = std::ptrdiff_t;
11243 using value_type = std::string;
11244 using pointer = value_type *;
11245 using reference = value_type &;
11246 using iterator_category = std::forward_iterator_tag;
11248 explicit iterator(Columns
const &columns);
11250 auto operator==(iterator
const &other)
const ->
bool {
11251 return m_iterators == other.m_iterators;
11253 auto operator!=(iterator
const &other)
const ->
bool {
11254 return m_iterators != other.m_iterators;
11256 std::string operator*()
const;
11257 iterator &operator++();
11258 iterator operator++(
int);
11260 using const_iterator = iterator;
11262 iterator begin()
const {
return iterator(*
this); }
11263 iterator end()
const {
return {*
this, iterator::EndTag()}; }
11265 friend Columns &operator+=(Columns &lhs, Column
const &rhs);
11266 friend Columns &operator+=(Columns &lhs, Column &&rhs);
11267 friend Columns operator+(Columns
const &lhs, Column
const &rhs);
11268 friend Columns operator+(Columns &&lhs, Column &&rhs);
11270 friend std::ostream &operator<<(std::ostream &os,
11271 Columns
const &cols);
11276 #endif // CATCH_TEXTFLOW_HPP_INCLUDED 11278 #ifndef CATCH_THREAD_LOCAL_HPP_INCLUDED 11279 #define CATCH_THREAD_LOCAL_HPP_INCLUDED 11281 #if defined(CATCH_CONFIG_THREAD_SAFE_ASSERTIONS) 11282 #define CATCH_INTERNAL_THREAD_LOCAL thread_local 11284 #define CATCH_INTERNAL_THREAD_LOCAL 11287 #endif // CATCH_THREAD_LOCAL_HPP_INCLUDED 11289 #ifndef CATCH_TO_STRING_HPP_INCLUDED 11290 #define CATCH_TO_STRING_HPP_INCLUDED 11295 template<
typename T>
11296 std::string to_string(T
const &t) {
11297 #if defined(CATCH_CONFIG_CPP11_TO_STRING) 11298 return std::to_string(t);
11307 #endif // CATCH_TO_STRING_HPP_INCLUDED 11309 #ifndef CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 11310 #define CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 11313 bool uncaught_exceptions();
11316 #endif // CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 11318 #ifndef CATCH_XMLWRITER_HPP_INCLUDED 11319 #define CATCH_XMLWRITER_HPP_INCLUDED 11326 enum class XmlFormatting : std::uint8_t {
11332 constexpr XmlFormatting operator|(XmlFormatting lhs, XmlFormatting rhs) {
11333 return static_cast<XmlFormatting
>(
static_cast<std::uint8_t
>(lhs) | static_cast<std::uint8_t>(rhs));
11336 constexpr XmlFormatting operator&(XmlFormatting lhs, XmlFormatting rhs) {
11337 return static_cast<XmlFormatting
>(
static_cast<std::uint8_t
>(lhs) & static_cast<std::uint8_t>(rhs));
11348 enum ForWhat { ForTextNodes,
11351 constexpr XmlEncode(
StringRef str CATCH_ATTR_LIFETIMEBOUND, ForWhat forWhat = ForTextNodes)
11352 : m_str(str), m_forWhat(forWhat) {}
11354 void encodeTo(std::ostream &os)
const;
11356 friend std::ostream &operator<<(std::ostream &os, XmlEncode
const &xmlEncode);
11365 class ScopedElement {
11367 ScopedElement(XmlWriter *writer CATCH_ATTR_LIFETIMEBOUND, XmlFormatting fmt);
11369 ScopedElement(ScopedElement &&other) noexcept;
11370 ScopedElement &operator=(ScopedElement &&other) noexcept;
11376 XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11378 ScopedElement &writeAttribute(
StringRef name,
11380 template<
typename T,
11385 typename =
typename std::enable_if_t<
11386 !std::is_convertible<T, StringRef>::value>>
11387 ScopedElement &writeAttribute(
StringRef name,
11388 T
const &attribute) {
11389 m_writer->writeAttribute(name, attribute);
11394 XmlWriter *m_writer =
nullptr;
11395 XmlFormatting m_fmt;
11398 XmlWriter(std::ostream &os CATCH_ATTR_LIFETIMEBOUND);
11401 XmlWriter(XmlWriter
const &) =
delete;
11402 XmlWriter &operator=(XmlWriter
const &) =
delete;
11404 XmlWriter &startElement(std::string
const &name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11406 ScopedElement scopedElement(std::string
const &name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11408 XmlWriter &endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11414 XmlWriter &writeAttribute(
StringRef name,
bool attribute);
11417 XmlWriter &writeAttribute(
StringRef name,
char const *attribute);
11421 template<
typename T,
11426 typename =
typename std::enable_if_t<
11427 !std::is_convertible<T, StringRef>::value>>
11428 XmlWriter &writeAttribute(
StringRef name, T
const &attribute) {
11431 return writeAttribute(name, rss.
str());
11436 XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11439 XmlWriter &writeComment(
StringRef text,
11440 XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
11442 void writeStylesheetRef(
StringRef url);
11444 void ensureTagClosed();
11447 void applyFormatting(XmlFormatting fmt);
11449 void writeDeclaration();
11451 void newlineIfNecessary();
11453 bool m_tagIsOpen =
false;
11454 bool m_needsNewline =
false;
11455 std::vector<std::string> m_tags;
11456 std::string m_indent;
11457 std::ostream &m_os;
11462 #endif // CATCH_XMLWRITER_HPP_INCLUDED 11476 #ifndef CATCH_MATCHERS_ALL_HPP_INCLUDED 11477 #define CATCH_MATCHERS_ALL_HPP_INCLUDED 11479 #ifndef CATCH_MATCHERS_HPP_INCLUDED 11480 #define CATCH_MATCHERS_HPP_INCLUDED 11482 #ifndef CATCH_MATCHERS_IMPL_HPP_INCLUDED 11483 #define CATCH_MATCHERS_IMPL_HPP_INCLUDED 11490 #pragma clang diagnostic push 11491 #pragma clang diagnostic ignored "-Wsign-compare" 11492 #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 11493 #elif defined __GNUC__ 11494 #pragma GCC diagnostic push 11495 #pragma GCC diagnostic ignored "-Wsign-compare" 11496 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 11499 template<
typename ArgT,
typename MatcherT>
11502 MatcherT
const &m_matcher;
11505 constexpr MatchExpr(ArgT &&arg, MatcherT
const &matcher)
11508 , m_matcher(matcher) {}
11510 void streamReconstructedExpression(std::ostream &os)
const override {
11511 os << Catch::Detail::stringify(m_arg)
11513 << m_matcher.toString();
11518 #pragma clang diagnostic pop 11519 #elif defined __GNUC__ 11520 #pragma GCC diagnostic pop 11523 namespace Matchers {
11524 template<
typename ArgT>
11528 using StringMatcher = Matchers::MatcherBase<std::string>;
11530 void handleExceptionMatchExpr(
AssertionHandler &handler, StringMatcher
const &matcher);
11532 template<
typename ArgT,
typename MatcherT>
11533 constexpr MatchExpr<ArgT, MatcherT>
11534 makeMatchExpr(ArgT &&arg, MatcherT
const &matcher) {
11535 return MatchExpr<ArgT, MatcherT>(
CATCH_FORWARD(arg), matcher);
11541 #define INTERNAL_CHECK_THAT(macroName, matcher, resultDisposition, arg) \ 11543 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition); \ 11544 INTERNAL_CATCH_TRY { \ 11545 catchAssertionHandler.handleExpr(Catch::makeMatchExpr(arg, matcher)); \ 11547 INTERNAL_CATCH_CATCH(catchAssertionHandler) \ 11548 catchAssertionHandler.complete(); \ 11552 #define INTERNAL_CATCH_THROWS_MATCHES(macroName, exceptionType, resultDisposition, matcher, ...) \ 11554 Catch::AssertionHandler catchAssertionHandler(macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition); \ 11555 if (catchAssertionHandler.allowThrows()) \ 11557 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 11558 CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ 11559 static_cast<void>(__VA_ARGS__); \ 11560 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ 11561 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ 11562 } catch (exceptionType const &ex) { \ 11563 catchAssertionHandler.handleExpr(Catch::makeMatchExpr(ex, matcher)); \ 11565 catchAssertionHandler.handleUnexpectedInflightException(); \ 11568 catchAssertionHandler.handleThrowingCallSkipped(); \ 11569 catchAssertionHandler.complete(); \ 11572 #endif // CATCH_MATCHERS_IMPL_HPP_INCLUDED 11578 namespace Matchers {
11580 class MatcherUntypedBase {
11582 MatcherUntypedBase() =
default;
11584 MatcherUntypedBase(MatcherUntypedBase
const &) =
default;
11585 MatcherUntypedBase(MatcherUntypedBase &&) =
default;
11587 MatcherUntypedBase &operator=(MatcherUntypedBase
const &) =
delete;
11588 MatcherUntypedBase &operator=(MatcherUntypedBase &&) =
delete;
11590 std::string toString()
const;
11593 virtual ~MatcherUntypedBase();
11594 virtual std::string describe()
const = 0;
11595 mutable std::string m_cachedToString;
11598 template<
typename T>
11599 class MatcherBase :
public MatcherUntypedBase {
11601 virtual bool match(T
const &arg)
const = 0;
11606 template<
typename ArgT>
11607 class MatchAllOf final :
public MatcherBase<ArgT> {
11608 std::vector<MatcherBase<ArgT>
const *> m_matchers;
11611 MatchAllOf() =
default;
11612 MatchAllOf(MatchAllOf
const &) =
delete;
11613 MatchAllOf &operator=(MatchAllOf
const &) =
delete;
11614 MatchAllOf(MatchAllOf &&) =
default;
11615 MatchAllOf &operator=(MatchAllOf &&) =
default;
11617 bool match(ArgT
const &arg)
const override {
11618 for (
auto matcher : m_matchers) {
11619 if (!matcher->match(arg))
11624 std::string describe()
const override {
11625 std::string description;
11626 description.reserve(4 + m_matchers.size() * 32);
11627 description +=
"( ";
11629 for (
auto matcher : m_matchers) {
11633 description +=
" and ";
11634 description += matcher->toString();
11636 description +=
" )";
11637 return description;
11640 friend MatchAllOf operator&&(MatchAllOf &&lhs,
11641 MatcherBase<ArgT>
const &rhs
11642 CATCH_ATTR_LIFETIMEBOUND) {
11643 lhs.m_matchers.push_back(&rhs);
11647 operator&&(MatcherBase<ArgT>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
11648 MatchAllOf &&rhs) {
11649 rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
11656 template<
typename ArgT>
11657 MatchAllOf<ArgT> operator&&(MatchAllOf<ArgT>
const &lhs, MatcherBase<ArgT>
const &rhs) =
delete;
11660 template<
typename ArgT>
11661 MatchAllOf<ArgT> operator&&(MatcherBase<ArgT>
const &lhs, MatchAllOf<ArgT>
const &rhs) =
delete;
11663 template<
typename ArgT>
11664 class MatchAnyOf final :
public MatcherBase<ArgT> {
11665 std::vector<MatcherBase<ArgT>
const *> m_matchers;
11668 MatchAnyOf() =
default;
11669 MatchAnyOf(MatchAnyOf
const &) =
delete;
11670 MatchAnyOf &operator=(MatchAnyOf
const &) =
delete;
11671 MatchAnyOf(MatchAnyOf &&) =
default;
11672 MatchAnyOf &operator=(MatchAnyOf &&) =
default;
11674 bool match(ArgT
const &arg)
const override {
11675 for (
auto matcher : m_matchers) {
11676 if (matcher->match(arg))
11681 std::string describe()
const override {
11682 std::string description;
11683 description.reserve(4 + m_matchers.size() * 32);
11684 description +=
"( ";
11686 for (
auto matcher : m_matchers) {
11690 description +=
" or ";
11691 description += matcher->toString();
11693 description +=
" )";
11694 return description;
11697 friend MatchAnyOf operator||(MatchAnyOf &&lhs,
11698 MatcherBase<ArgT>
const &rhs
11699 CATCH_ATTR_LIFETIMEBOUND) {
11700 lhs.m_matchers.push_back(&rhs);
11704 operator||(MatcherBase<ArgT>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
11705 MatchAnyOf &&rhs) {
11706 rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
11713 template<
typename ArgT>
11714 MatchAnyOf<ArgT> operator||(MatchAnyOf<ArgT>
const &lhs, MatcherBase<ArgT>
const &rhs) =
delete;
11717 template<
typename ArgT>
11718 MatchAnyOf<ArgT> operator||(MatcherBase<ArgT>
const &lhs, MatchAnyOf<ArgT>
const &rhs) =
delete;
11720 template<
typename ArgT>
11721 class MatchNotOf final :
public MatcherBase<ArgT> {
11722 MatcherBase<ArgT>
const &m_underlyingMatcher;
11725 explicit MatchNotOf(MatcherBase<ArgT>
const &underlyingMatcher
11726 CATCH_ATTR_LIFETIMEBOUND)
11727 : m_underlyingMatcher(underlyingMatcher) {}
11729 bool match(ArgT
const &arg)
const override {
11730 return !m_underlyingMatcher.match(arg);
11733 std::string describe()
const override {
11734 return "not " + m_underlyingMatcher.toString();
11740 template<
typename T>
11741 Detail::MatchAllOf<T>
11742 operator&&(MatcherBase<T>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
11743 MatcherBase<T>
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
11744 return Detail::MatchAllOf<T>{} && lhs && rhs;
11747 template<
typename T>
11748 Detail::MatchAnyOf<T>
11749 operator||(MatcherBase<T>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
11750 MatcherBase<T>
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
11751 return Detail::MatchAnyOf<T>{} || lhs || rhs;
11754 template<
typename T>
11755 Detail::MatchNotOf<T>
11756 operator!(MatcherBase<T>
const &matcher CATCH_ATTR_LIFETIMEBOUND) {
11757 return Detail::MatchNotOf<T>{matcher};
11763 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) 11764 #define CATCH_REQUIRE_THROWS_WITH(expr, matcher) INTERNAL_CATCH_THROWS_STR_MATCHES("CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr) 11765 #define CATCH_REQUIRE_THROWS_MATCHES(expr, exceptionType, matcher) INTERNAL_CATCH_THROWS_MATCHES("CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr) 11767 #define CATCH_CHECK_THROWS_WITH(expr, matcher) INTERNAL_CATCH_THROWS_STR_MATCHES("CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr) 11768 #define CATCH_CHECK_THROWS_MATCHES(expr, exceptionType, matcher) INTERNAL_CATCH_THROWS_MATCHES("CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr) 11770 #define CATCH_CHECK_THAT(arg, matcher) INTERNAL_CHECK_THAT("CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg) 11771 #define CATCH_REQUIRE_THAT(arg, matcher) INTERNAL_CHECK_THAT("CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg) 11773 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) 11775 #define CATCH_REQUIRE_THROWS_WITH(expr, matcher) (void)(0) 11776 #define CATCH_REQUIRE_THROWS_MATCHES(expr, exceptionType, matcher) (void)(0) 11778 #define CATCH_CHECK_THROWS_WITH(expr, matcher) (void)(0) 11779 #define CATCH_CHECK_THROWS_MATCHES(expr, exceptionType, matcher) (void)(0) 11781 #define CATCH_CHECK_THAT(arg, matcher) (void)(0) 11782 #define CATCH_REQUIRE_THAT(arg, matcher) (void)(0) 11784 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) 11786 #define REQUIRE_THROWS_WITH(expr, matcher) INTERNAL_CATCH_THROWS_STR_MATCHES("REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr) 11787 #define REQUIRE_THROWS_MATCHES(expr, exceptionType, matcher) INTERNAL_CATCH_THROWS_MATCHES("REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr) 11789 #define CHECK_THROWS_WITH(expr, matcher) INTERNAL_CATCH_THROWS_STR_MATCHES("CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr) 11790 #define CHECK_THROWS_MATCHES(expr, exceptionType, matcher) INTERNAL_CATCH_THROWS_MATCHES("CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr) 11792 #define CHECK_THAT(arg, matcher) INTERNAL_CHECK_THAT("CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg) 11793 #define REQUIRE_THAT(arg, matcher) INTERNAL_CHECK_THAT("REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg) 11795 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) 11797 #define REQUIRE_THROWS_WITH(expr, matcher) (void)(0) 11798 #define REQUIRE_THROWS_MATCHES(expr, exceptionType, matcher) (void)(0) 11800 #define CHECK_THROWS_WITH(expr, matcher) (void)(0) 11801 #define CHECK_THROWS_MATCHES(expr, exceptionType, matcher) (void)(0) 11803 #define CHECK_THAT(arg, matcher) (void)(0) 11804 #define REQUIRE_THAT(arg, matcher) (void)(0) 11806 #endif // end of user facing macro declarations 11808 #endif // CATCH_MATCHERS_HPP_INCLUDED 11810 #ifndef CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED 11811 #define CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED 11813 #ifndef CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED 11814 #define CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED 11816 #include <algorithm> 11819 #include <type_traits> 11822 namespace Matchers {
11823 class MatcherGenericBase :
public MatcherUntypedBase {
11825 MatcherGenericBase() =
default;
11826 ~MatcherGenericBase()
override;
11828 MatcherGenericBase(MatcherGenericBase
const &) =
default;
11829 MatcherGenericBase(MatcherGenericBase &&) =
default;
11831 MatcherGenericBase &operator=(MatcherGenericBase
const &) =
delete;
11832 MatcherGenericBase &operator=(MatcherGenericBase &&) =
delete;
11836 template<std::
size_t N, std::
size_t M>
11837 std::array<void const *, N + M> array_cat(std::array<void const *, N> &&lhs, std::array<void const *, M> &&rhs) {
11838 std::array<void const *, N + M> arr{};
11839 std::copy_n(lhs.begin(), N, arr.begin());
11840 std::copy_n(rhs.begin(), M, arr.begin() + N);
11844 template<std::
size_t N>
11845 std::array<void const *, N + 1> array_cat(std::array<void const *, N> &&lhs,
void const *rhs) {
11846 std::array<void const *, N + 1> arr{};
11847 std::copy_n(lhs.begin(), N, arr.begin());
11852 template<std::
size_t N>
11853 std::array<void const *, N + 1> array_cat(
void const *lhs, std::array<void const *, N> &&rhs) {
11854 std::array<void const *, N + 1> arr{{lhs}};
11855 std::copy_n(rhs.begin(), N, arr.begin() + 1);
11859 template<
typename T>
11860 static constexpr
bool is_generic_matcher_v = std::is_base_of<
11861 Catch::Matchers::MatcherGenericBase,
11862 std::remove_cv_t<std::remove_reference_t<T>>>::value;
11864 template<
typename... Ts>
11867 template<
typename T>
11868 static constexpr
bool is_matcher_v = std::is_base_of<
11869 Catch::Matchers::MatcherUntypedBase,
11870 std::remove_cv_t<std::remove_reference_t<T>>>::value;
11872 template<std::
size_t N,
typename Arg>
11873 bool match_all_of(Arg &&, std::array<void const *, N>
const &, std::index_sequence<>) {
11877 template<
typename T,
typename... MatcherTs, std::size_t N,
typename Arg, std::size_t Idx, std::size_t... Indices>
11878 bool match_all_of(Arg &&arg, std::array<void const *, N>
const &matchers, std::index_sequence<Idx, Indices...>) {
11879 return static_cast<T
const *
>(matchers[Idx])->match(arg) && match_all_of<MatcherTs...>(arg, matchers, std::index_sequence<Indices...>{});
11882 template<std::
size_t N,
typename Arg>
11883 bool match_any_of(Arg &&, std::array<void const *, N>
const &, std::index_sequence<>) {
11887 template<
typename T,
typename... MatcherTs, std::size_t N,
typename Arg, std::size_t Idx, std::size_t... Indices>
11888 bool match_any_of(Arg &&arg, std::array<void const *, N>
const &matchers, std::index_sequence<Idx, Indices...>) {
11889 return static_cast<T
const *
>(matchers[Idx])->match(arg) || match_any_of<MatcherTs...>(arg, matchers, std::index_sequence<Indices...>{});
11892 std::string describe_multi_matcher(
StringRef combine, std::string
const *descriptions_begin, std::string
const *descriptions_end);
11894 template<
typename... MatcherTs, std::size_t... Idx>
11895 std::string describe_multi_matcher(
StringRef combine, std::array<
void const *,
sizeof...(MatcherTs)>
const &matchers, std::index_sequence<Idx...>) {
11896 std::array<std::string,
sizeof...(MatcherTs)> descriptions{{
static_cast<MatcherTs
const *
>(matchers[Idx])->toString()...}};
11898 return describe_multi_matcher(combine, descriptions.data(), descriptions.data() + descriptions.size());
11901 template<
typename... MatcherTs>
11902 class MatchAllOfGeneric final :
public MatcherGenericBase {
11904 MatchAllOfGeneric(MatchAllOfGeneric
const &) =
delete;
11905 MatchAllOfGeneric &operator=(MatchAllOfGeneric
const &) =
delete;
11906 MatchAllOfGeneric(MatchAllOfGeneric &&) =
default;
11907 MatchAllOfGeneric &operator=(MatchAllOfGeneric &&) =
default;
11909 MatchAllOfGeneric(MatcherTs
const &...matchers CATCH_ATTR_LIFETIMEBOUND)
11910 : m_matchers{{std::addressof(matchers)...}} {}
11911 explicit MatchAllOfGeneric(std::array<
void const *,
sizeof...(MatcherTs)> matchers)
11912 : m_matchers{matchers} {}
11914 template<
typename Arg>
11915 bool match(Arg &&arg)
const {
11916 return match_all_of<MatcherTs...>(arg, m_matchers, std::index_sequence_for<MatcherTs...>{});
11919 std::string describe()
const override {
11920 return describe_multi_matcher<MatcherTs...>(
" and "_sr, m_matchers, std::index_sequence_for<MatcherTs...>{});
11926 std::array<
void const *,
sizeof...(MatcherTs)> m_matchers;
11929 template<
typename... MatchersRHS>
11930 friend MatchAllOfGeneric<MatcherTs..., MatchersRHS...> operator&&(
11931 MatchAllOfGeneric<MatcherTs...> &&lhs CATCH_ATTR_LIFETIMEBOUND,
11932 MatchAllOfGeneric<MatchersRHS...> &&rhs CATCH_ATTR_LIFETIMEBOUND) {
11933 return MatchAllOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(
CATCH_MOVE(lhs.m_matchers),
CATCH_MOVE(rhs.m_matchers))};
11937 template<
typename MatcherRHS>
11938 friend std::enable_if_t<is_matcher_v<MatcherRHS>,
11939 MatchAllOfGeneric<MatcherTs..., MatcherRHS>>
11941 MatchAllOfGeneric<MatcherTs...> &&lhs CATCH_ATTR_LIFETIMEBOUND,
11942 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
11943 return MatchAllOfGeneric<MatcherTs..., MatcherRHS>{array_cat(
CATCH_MOVE(lhs.m_matchers), static_cast<void const *>(&rhs))};
11947 template<
typename MatcherLHS>
11948 friend std::enable_if_t<is_matcher_v<MatcherLHS>,
11949 MatchAllOfGeneric<MatcherLHS, MatcherTs...>>
11951 MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
11952 MatchAllOfGeneric<MatcherTs...> &&rhs CATCH_ATTR_LIFETIMEBOUND) {
11953 return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const *>(std::addressof(lhs)),
CATCH_MOVE(rhs.m_matchers))};
11957 template<
typename... MatcherTs>
11958 class MatchAnyOfGeneric final :
public MatcherGenericBase {
11960 MatchAnyOfGeneric(MatchAnyOfGeneric
const &) =
delete;
11961 MatchAnyOfGeneric &operator=(MatchAnyOfGeneric
const &) =
delete;
11962 MatchAnyOfGeneric(MatchAnyOfGeneric &&) =
default;
11963 MatchAnyOfGeneric &operator=(MatchAnyOfGeneric &&) =
default;
11965 MatchAnyOfGeneric(MatcherTs
const &...matchers CATCH_ATTR_LIFETIMEBOUND)
11966 : m_matchers{{std::addressof(matchers)...}} {}
11967 explicit MatchAnyOfGeneric(std::array<
void const *,
sizeof...(MatcherTs)> matchers)
11968 : m_matchers{matchers} {}
11970 template<
typename Arg>
11971 bool match(Arg &&arg)
const {
11972 return match_any_of<MatcherTs...>(arg, m_matchers, std::index_sequence_for<MatcherTs...>{});
11975 std::string describe()
const override {
11976 return describe_multi_matcher<MatcherTs...>(
" or "_sr, m_matchers, std::index_sequence_for<MatcherTs...>{});
11982 std::array<
void const *,
sizeof...(MatcherTs)> m_matchers;
11985 template<
typename... MatchersRHS>
11986 friend MatchAnyOfGeneric<MatcherTs..., MatchersRHS...> operator||(
11987 MatchAnyOfGeneric<MatcherTs...> &&lhs CATCH_ATTR_LIFETIMEBOUND,
11988 MatchAnyOfGeneric<MatchersRHS...> &&rhs CATCH_ATTR_LIFETIMEBOUND) {
11989 return MatchAnyOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(
CATCH_MOVE(lhs.m_matchers),
CATCH_MOVE(rhs.m_matchers))};
11993 template<
typename MatcherRHS>
11994 friend std::enable_if_t<is_matcher_v<MatcherRHS>,
11995 MatchAnyOfGeneric<MatcherTs..., MatcherRHS>>
11997 MatchAnyOfGeneric<MatcherTs...> &&lhs CATCH_ATTR_LIFETIMEBOUND,
11998 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
11999 return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(
CATCH_MOVE(lhs.m_matchers), static_cast<void const *>(std::addressof(rhs)))};
12003 template<
typename MatcherLHS>
12004 friend std::enable_if_t<is_matcher_v<MatcherLHS>,
12005 MatchAnyOfGeneric<MatcherLHS, MatcherTs...>>
12007 MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12008 MatchAnyOfGeneric<MatcherTs...> &&rhs CATCH_ATTR_LIFETIMEBOUND) {
12009 return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const *>(std::addressof(lhs)),
CATCH_MOVE(rhs.m_matchers))};
12013 template<
typename MatcherT>
12014 class MatchNotOfGeneric final :
public MatcherGenericBase {
12015 MatcherT
const &m_matcher;
12018 MatchNotOfGeneric(MatchNotOfGeneric
const &) =
delete;
12019 MatchNotOfGeneric &operator=(MatchNotOfGeneric
const &) =
delete;
12020 MatchNotOfGeneric(MatchNotOfGeneric &&) =
default;
12021 MatchNotOfGeneric &operator=(MatchNotOfGeneric &&) =
default;
12023 explicit MatchNotOfGeneric(MatcherT
const &matcher CATCH_ATTR_LIFETIMEBOUND)
12024 : m_matcher{matcher} {}
12026 template<
typename Arg>
12027 bool match(Arg &&arg)
const {
12028 return !m_matcher.match(arg);
12031 std::string describe()
const override {
12032 return "not " + m_matcher.toString();
12036 friend MatcherT
const &
12037 operator!(MatchNotOfGeneric<MatcherT>
const &matcher
12038 CATCH_ATTR_LIFETIMEBOUND) {
12039 return matcher.m_matcher;
12045 template<
typename MatcherLHS,
typename MatcherRHS>
12046 std::enable_if_t<Detail::are_generic_matchers_v<MatcherLHS, MatcherRHS>, Detail::MatchAllOfGeneric<MatcherLHS, MatcherRHS>>
12047 operator&&(MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12048 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12052 template<
typename MatcherLHS,
typename MatcherRHS>
12053 std::enable_if_t<Detail::are_generic_matchers_v<MatcherLHS, MatcherRHS>, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherRHS>>
12054 operator||(MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12055 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12060 template<
typename MatcherT>
12061 std::enable_if_t<Detail::is_generic_matcher_v<MatcherT>, Detail::MatchNotOfGeneric<MatcherT>>
12062 operator!(MatcherT
const &matcher CATCH_ATTR_LIFETIMEBOUND) {
12063 return Detail::MatchNotOfGeneric<MatcherT>{matcher};
12067 template<
typename MatcherLHS,
typename ArgRHS>
12068 std::enable_if_t<Detail::is_generic_matcher_v<MatcherLHS>, Detail::MatchAllOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>
12069 operator&&(MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12070 MatcherBase<ArgRHS>
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12074 template<
typename ArgLHS,
typename MatcherRHS>
12075 std::enable_if_t<Detail::is_generic_matcher_v<MatcherRHS>, Detail::MatchAllOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>
12076 operator&&(MatcherBase<ArgLHS>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12077 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12081 template<
typename MatcherLHS,
typename ArgRHS>
12082 std::enable_if_t<Detail::is_generic_matcher_v<MatcherLHS>, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>
12083 operator||(MatcherLHS
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12084 MatcherBase<ArgRHS>
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12088 template<
typename ArgLHS,
typename MatcherRHS>
12089 std::enable_if_t<Detail::is_generic_matcher_v<MatcherRHS>, Detail::MatchAnyOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>
12090 operator||(MatcherBase<ArgLHS>
const &lhs CATCH_ATTR_LIFETIMEBOUND,
12091 MatcherRHS
const &rhs CATCH_ATTR_LIFETIMEBOUND) {
12098 #endif // CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED 12101 namespace Matchers {
12103 class IsEmptyMatcher final :
public MatcherGenericBase {
12105 template<
typename RangeLike>
12106 bool match(RangeLike &&rng)
const {
12107 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) 12108 using Catch::Detail::empty;
12115 std::string describe()
const override;
12118 class HasSizeMatcher final :
public MatcherGenericBase {
12119 std::size_t m_target_size;
12122 explicit HasSizeMatcher(std::size_t target_size)
12123 : m_target_size(target_size) {}
12125 template<
typename RangeLike>
12126 bool match(RangeLike &&rng)
const {
12127 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) 12128 using Catch::Detail::size;
12132 return size(rng) == m_target_size;
12135 std::string describe()
const override;
12138 template<
typename Matcher>
12139 class SizeMatchesMatcher final :
public MatcherGenericBase {
12143 explicit SizeMatchesMatcher(Matcher m)
12146 template<
typename RangeLike>
12147 bool match(RangeLike &&rng)
const {
12148 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) 12149 using Catch::Detail::size;
12153 return m_matcher.match(size(rng));
12156 std::string describe()
const override {
12157 return "size matches " + m_matcher.describe();
12162 IsEmptyMatcher IsEmpty();
12164 HasSizeMatcher SizeIs(std::size_t sz);
12165 template<
typename Matcher>
12166 std::enable_if_t<Detail::is_matcher_v<Matcher>,
12167 SizeMatchesMatcher<Matcher>>
12168 SizeIs(Matcher &&m) {
12175 #endif // CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED 12177 #ifndef CATCH_MATCHERS_CONTAINS_HPP_INCLUDED 12178 #define CATCH_MATCHERS_CONTAINS_HPP_INCLUDED 12180 #include <functional> 12181 #include <type_traits> 12184 namespace Matchers {
12186 template<
typename T,
typename Equality>
12187 class ContainsElementMatcher final :
public MatcherGenericBase {
12192 template<
typename T2,
typename Equality2>
12193 ContainsElementMatcher(T2 &&target, Equality2 &&predicate)
12196 std::string describe()
const override {
12197 return "contains element " + Catch::Detail::stringify(m_desired);
12200 template<
typename RangeLike>
12201 bool match(RangeLike &&rng)
const {
12202 for (
auto &&elem : rng) {
12203 if (m_eq(elem, m_desired)) {
return true; }
12210 template<
typename Matcher>
12211 class ContainsMatcherMatcher final :
public MatcherGenericBase {
12218 ContainsMatcherMatcher(Matcher matcher)
12221 template<
typename RangeLike>
12222 bool match(RangeLike &&rng)
const {
12223 for (
auto &&elem : rng) {
12224 if (m_matcher.match(elem)) {
12231 std::string describe()
const override {
12232 return "contains element matching " + m_matcher.describe();
12241 template<
typename T>
12242 std::enable_if_t<!Detail::is_matcher_v<T>,
12243 ContainsElementMatcher<T, std::equal_to<>>>
12244 Contains(T &&elem) {
12249 template<
typename Matcher>
12250 std::enable_if_t<Detail::is_matcher_v<Matcher>,
12251 ContainsMatcherMatcher<Matcher>>
12252 Contains(Matcher &&matcher) {
12261 template<
typename T,
typename Equality>
12262 ContainsElementMatcher<T, Equality> Contains(T &&elem, Equality &&eq) {
12269 #endif // CATCH_MATCHERS_CONTAINS_HPP_INCLUDED 12271 #ifndef CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 12272 #define CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 12275 namespace Matchers {
12277 class ExceptionMessageMatcher final :
public MatcherBase<std::exception> {
12278 std::string m_message;
12281 ExceptionMessageMatcher(std::string
const &message)
12282 : m_message(message) {}
12284 bool match(std::exception
const &ex)
const override;
12286 std::string describe()
const override;
12290 ExceptionMessageMatcher Message(std::string
const &message);
12292 template<
typename StringMatcherType>
12293 class ExceptionMessageMatchesMatcher final
12294 :
public MatcherBase<std::exception> {
12295 StringMatcherType m_matcher;
12298 ExceptionMessageMatchesMatcher(StringMatcherType matcher)
12301 bool match(std::exception
const &ex)
const override {
12302 return m_matcher.match(ex.what());
12305 std::string describe()
const override {
12306 return " matches \"" + m_matcher.describe() +
'"';
12312 template<
typename StringMatcherType>
12313 ExceptionMessageMatchesMatcher<StringMatcherType>
12314 MessageMatches(StringMatcherType &&matcher) {
12321 #endif // CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 12323 #ifndef CATCH_MATCHERS_FLOATING_POINT_HPP_INCLUDED 12324 #define CATCH_MATCHERS_FLOATING_POINT_HPP_INCLUDED 12327 namespace Matchers {
12330 enum class FloatingPointKind : uint8_t;
12333 class WithinAbsMatcher final :
public MatcherBase<double> {
12335 WithinAbsMatcher(
double target,
double margin);
12336 bool match(
double const &matchee)
const override;
12337 std::string describe()
const override;
12345 WithinAbsMatcher WithinAbs(
double target,
double margin);
12347 class WithinUlpsMatcher final :
public MatcherBase<double> {
12349 WithinUlpsMatcher(
double target,
12351 Detail::FloatingPointKind baseType);
12352 bool match(
double const &matchee)
const override;
12353 std::string describe()
const override;
12358 Detail::FloatingPointKind m_type;
12362 WithinUlpsMatcher WithinULP(
double target, uint64_t maxUlpDiff);
12364 WithinUlpsMatcher WithinULP(
float target, uint64_t maxUlpDiff);
12372 class WithinRelMatcher final :
public MatcherBase<double> {
12374 WithinRelMatcher(
double target,
double epsilon);
12375 bool match(
double const &matchee)
const override;
12376 std::string describe()
const override;
12384 WithinRelMatcher WithinRel(
double target,
double eps);
12386 WithinRelMatcher WithinRel(
double target);
12388 WithinRelMatcher WithinRel(
float target,
float eps);
12390 WithinRelMatcher WithinRel(
float target);
12392 class IsNaNMatcher final :
public MatcherBase<double> {
12394 IsNaNMatcher() =
default;
12395 bool match(
double const &matchee)
const override;
12396 std::string describe()
const override;
12399 IsNaNMatcher IsNaN();
12404 #endif // CATCH_MATCHERS_FLOATING_POINT_HPP_INCLUDED 12406 #ifndef CATCH_MATCHERS_PREDICATE_HPP_INCLUDED 12407 #define CATCH_MATCHERS_PREDICATE_HPP_INCLUDED 12412 namespace Matchers {
12415 std::string finalizeDescription(
const std::string &desc);
12418 template<
typename T,
typename Predicate>
12419 class PredicateMatcher final :
public MatcherBase<T> {
12420 Predicate m_predicate;
12421 std::string m_description;
12424 PredicateMatcher(Predicate &&elem, std::string
const &descr)
12425 : m_predicate(
CATCH_FORWARD(elem)), m_description(Detail::finalizeDescription(descr)) {}
12427 bool match(T
const &item)
const override {
12428 return m_predicate(item);
12431 std::string describe()
const override {
12432 return m_description;
12441 template<
typename T,
typename Pred>
12442 PredicateMatcher<T, Pred> Predicate(Pred &&predicate, std::string
const &description =
"") {
12443 static_assert(
is_callable<Pred(T)>::value,
"Predicate not callable with argument T");
12444 static_assert(std::is_same<
bool, FunctionReturnType<Pred, T>>::value,
"Predicate does not return bool");
12445 return PredicateMatcher<T, Pred>(
CATCH_FORWARD(predicate), description);
12451 #endif // CATCH_MATCHERS_PREDICATE_HPP_INCLUDED 12453 #ifndef CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED 12454 #define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED 12457 namespace Matchers {
12459 template<
typename Matcher>
12460 class AllMatchMatcher final :
public MatcherGenericBase {
12464 AllMatchMatcher(Matcher matcher)
12467 std::string describe()
const override {
12468 return "all match " + m_matcher.describe();
12471 template<
typename RangeLike>
12472 bool match(RangeLike &&rng)
const {
12473 for (
auto &&elem : rng) {
12474 if (!m_matcher.match(elem)) {
12483 template<
typename Matcher>
12484 class NoneMatchMatcher final :
public MatcherGenericBase {
12488 NoneMatchMatcher(Matcher matcher)
12491 std::string describe()
const override {
12492 return "none match " + m_matcher.describe();
12495 template<
typename RangeLike>
12496 bool match(RangeLike &&rng)
const {
12497 for (
auto &&elem : rng) {
12498 if (m_matcher.match(elem)) {
12507 template<
typename Matcher>
12508 class AnyMatchMatcher final :
public MatcherGenericBase {
12512 AnyMatchMatcher(Matcher matcher)
12515 std::string describe()
const override {
12516 return "any match " + m_matcher.describe();
12519 template<
typename RangeLike>
12520 bool match(RangeLike &&rng)
const {
12521 for (
auto &&elem : rng) {
12522 if (m_matcher.match(elem)) {
12531 class AllTrueMatcher final :
public MatcherGenericBase {
12533 std::string describe()
const override;
12535 template<
typename RangeLike>
12536 bool match(RangeLike &&rng)
const {
12537 for (
auto &&elem : rng) {
12547 class NoneTrueMatcher final :
public MatcherGenericBase {
12549 std::string describe()
const override;
12551 template<
typename RangeLike>
12552 bool match(RangeLike &&rng)
const {
12553 for (
auto &&elem : rng) {
12563 class AnyTrueMatcher final :
public MatcherGenericBase {
12565 std::string describe()
const override;
12567 template<
typename RangeLike>
12568 bool match(RangeLike &&rng)
const {
12569 for (
auto &&elem : rng) {
12579 template<
typename Matcher>
12580 AllMatchMatcher<Matcher> AllMatch(Matcher &&matcher) {
12585 template<
typename Matcher>
12586 NoneMatchMatcher<Matcher> NoneMatch(Matcher &&matcher) {
12591 template<
typename Matcher>
12592 AnyMatchMatcher<Matcher> AnyMatch(Matcher &&matcher) {
12597 AllTrueMatcher AllTrue();
12600 NoneTrueMatcher NoneTrue();
12603 AnyTrueMatcher AnyTrue();
12607 #endif // CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED 12609 #ifndef CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED 12610 #define CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED 12612 #include <functional> 12615 namespace Matchers {
12621 template<
typename TargetRangeLike,
typename Equality>
12622 class RangeEqualsMatcher final :
public MatcherGenericBase {
12623 TargetRangeLike m_desired;
12624 Equality m_predicate;
12627 template<
typename TargetRangeLike2,
typename Equality2>
12628 constexpr RangeEqualsMatcher(TargetRangeLike2 &&range,
12629 Equality2 &&predicate)
12632 template<
typename RangeLike>
12633 constexpr
bool match(RangeLike &&rng)
const {
12634 auto rng_start = begin(rng);
12635 const auto rng_end = end(rng);
12636 auto target_start = begin(m_desired);
12637 const auto target_end = end(m_desired);
12639 while (rng_start != rng_end && target_start != target_end) {
12640 if (!m_predicate(*rng_start, *target_start)) {
12646 return rng_start == rng_end && target_start == target_end;
12649 std::string describe()
const override {
12650 return "elements are " + Catch::Detail::stringify(m_desired);
12658 template<
typename TargetRangeLike,
typename Equality>
12659 class UnorderedRangeEqualsMatcher final :
public MatcherGenericBase {
12660 TargetRangeLike m_desired;
12661 Equality m_predicate;
12664 template<
typename TargetRangeLike2,
typename Equality2>
12665 constexpr UnorderedRangeEqualsMatcher(TargetRangeLike2 &&range,
12666 Equality2 &&predicate)
12669 template<
typename RangeLike>
12670 constexpr
bool match(RangeLike &&rng)
const {
12673 return Catch::Detail::is_permutation(begin(m_desired),
12680 std::string describe()
const override {
12681 return "unordered elements are " + ::Catch::Detail::stringify(m_desired);
12692 template<
typename RangeLike,
12693 typename Equality = decltype(std::equal_to<>{})>
12694 constexpr RangeEqualsMatcher<RangeLike, Equality>
12695 RangeEquals(RangeLike &&range,
12696 Equality &&predicate = std::equal_to<>{}) {
12707 template<
typename T,
12708 typename Equality = decltype(std::equal_to<>{})>
12709 constexpr RangeEqualsMatcher<std::initializer_list<T>, Equality>
12710 RangeEquals(std::initializer_list<T> range,
12711 Equality &&predicate = std::equal_to<>{}) {
12722 template<
typename RangeLike,
12723 typename Equality = decltype(std::equal_to<>{})>
12724 constexpr UnorderedRangeEqualsMatcher<RangeLike, Equality>
12725 UnorderedRangeEquals(RangeLike &&range,
12726 Equality &&predicate = std::equal_to<>{}) {
12737 template<
typename T,
12738 typename Equality = decltype(std::equal_to<>{})>
12739 constexpr UnorderedRangeEqualsMatcher<std::initializer_list<T>, Equality>
12740 UnorderedRangeEquals(std::initializer_list<T> range,
12741 Equality &&predicate = std::equal_to<>{}) {
12747 #endif // CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED 12749 #ifndef CATCH_MATCHERS_STRING_HPP_INCLUDED 12750 #define CATCH_MATCHERS_STRING_HPP_INCLUDED 12755 namespace Matchers {
12757 struct CasedString {
12758 CasedString(std::string
const &str, CaseSensitive caseSensitivity);
12759 std::string adjustString(std::string
const &str)
const;
12760 StringRef caseSensitivitySuffix()
const;
12762 CaseSensitive m_caseSensitivity;
12766 class StringMatcherBase :
public MatcherBase<std::string> {
12768 CasedString m_comparator;
12773 CasedString
const &comparator);
12774 std::string describe()
const override;
12777 class StringEqualsMatcher final :
public StringMatcherBase {
12779 StringEqualsMatcher(CasedString
const &comparator);
12780 bool match(std::string
const &source)
const override;
12782 class StringContainsMatcher final :
public StringMatcherBase {
12784 StringContainsMatcher(CasedString
const &comparator);
12785 bool match(std::string
const &source)
const override;
12787 class StartsWithMatcher final :
public StringMatcherBase {
12789 StartsWithMatcher(CasedString
const &comparator);
12790 bool match(std::string
const &source)
const override;
12792 class EndsWithMatcher final :
public StringMatcherBase {
12794 EndsWithMatcher(CasedString
const &comparator);
12795 bool match(std::string
const &source)
const override;
12798 class RegexMatcher final :
public MatcherBase<std::string> {
12799 std::string m_regex;
12800 CaseSensitive m_caseSensitivity;
12803 RegexMatcher(std::string regex, CaseSensitive caseSensitivity);
12804 bool match(std::string
const &matchee)
const override;
12805 std::string describe()
const override;
12809 StringEqualsMatcher Equals(std::string
const &str, CaseSensitive caseSensitivity = CaseSensitive::Yes);
12811 StringContainsMatcher ContainsSubstring(std::string
const &str, CaseSensitive caseSensitivity = CaseSensitive::Yes);
12813 EndsWithMatcher EndsWith(std::string
const &str, CaseSensitive caseSensitivity = CaseSensitive::Yes);
12815 StartsWithMatcher StartsWith(std::string
const &str, CaseSensitive caseSensitivity = CaseSensitive::Yes);
12817 RegexMatcher Matches(std::string
const ®ex, CaseSensitive caseSensitivity = CaseSensitive::Yes);
12822 #endif // CATCH_MATCHERS_STRING_HPP_INCLUDED 12824 #ifndef CATCH_MATCHERS_VECTOR_HPP_INCLUDED 12825 #define CATCH_MATCHERS_VECTOR_HPP_INCLUDED 12827 #include <algorithm> 12830 namespace Matchers {
12832 template<
typename T,
typename Alloc>
12833 class VectorContainsElementMatcher final :
public MatcherBase<std::vector<T, Alloc>> {
12834 T
const &m_comparator;
12837 VectorContainsElementMatcher(T
const &comparator)
12838 : m_comparator(comparator) {}
12840 bool match(std::vector<T, Alloc>
const &v)
const override {
12841 for (
auto const &el : v) {
12842 if (el == m_comparator) {
12849 std::string describe()
const override {
12850 return "Contains: " + ::Catch::Detail::stringify(m_comparator);
12854 template<
typename T,
typename AllocComp,
typename AllocMatch>
12855 class ContainsMatcher final :
public MatcherBase<std::vector<T, AllocMatch>> {
12856 std::vector<T, AllocComp>
const &m_comparator;
12859 ContainsMatcher(std::vector<T, AllocComp>
const &comparator)
12860 : m_comparator(comparator) {}
12862 bool match(std::vector<T, AllocMatch>
const &v)
const override {
12864 if (m_comparator.size() > v.size())
12866 for (
auto const &comparator : m_comparator) {
12867 auto present =
false;
12868 for (
const auto &el : v) {
12869 if (el == comparator) {
12880 std::string describe()
const override {
12881 return "Contains: " + ::Catch::Detail::stringify(m_comparator);
12885 template<
typename T,
typename AllocComp,
typename AllocMatch>
12886 class EqualsMatcher final :
public MatcherBase<std::vector<T, AllocMatch>> {
12887 std::vector<T, AllocComp>
const &m_comparator;
12890 EqualsMatcher(std::vector<T, AllocComp>
const &comparator)
12891 : m_comparator(comparator) {}
12893 bool match(std::vector<T, AllocMatch>
const &v)
const override {
12898 if (m_comparator.size() != v.size()) {
return false; }
12899 for (std::size_t i = 0; i < v.size(); ++i) {
12900 if (!(m_comparator[i] == v[i])) {
return false; }
12904 std::string describe()
const override {
12905 return "Equals: " + ::Catch::Detail::stringify(m_comparator);
12909 template<
typename T,
typename AllocComp,
typename AllocMatch>
12910 class ApproxMatcher final :
public MatcherBase<std::vector<T, AllocMatch>> {
12911 std::vector<T, AllocComp>
const &m_comparator;
12915 ApproxMatcher(std::vector<T, AllocComp>
const &comparator)
12916 : m_comparator(comparator) {}
12918 bool match(std::vector<T, AllocMatch>
const &v)
const override {
12919 if (m_comparator.size() != v.size())
12921 for (std::size_t i = 0; i < v.size(); ++i)
12922 if (m_comparator[i] != approx(v[i]))
12926 std::string describe()
const override {
12927 return "is approx: " + ::Catch::Detail::stringify(m_comparator);
12929 template<typename = std::enable_if_t<std::is_constructible<double, T>::value>>
12930 ApproxMatcher &epsilon(T
const &newEpsilon) {
12931 approx.epsilon(static_cast<double>(newEpsilon));
12934 template<typename = std::enable_if_t<std::is_constructible<double, T>::value>>
12935 ApproxMatcher &margin(T
const &newMargin) {
12936 approx.margin(static_cast<double>(newMargin));
12939 template<typename = std::enable_if_t<std::is_constructible<double, T>::value>>
12940 ApproxMatcher &scale(T
const &newScale) {
12941 approx.scale(static_cast<double>(newScale));
12946 template<
typename T,
typename AllocComp,
typename AllocMatch>
12947 class UnorderedEqualsMatcher final :
public MatcherBase<std::vector<T, AllocMatch>> {
12948 std::vector<T, AllocComp>
const &m_target;
12951 UnorderedEqualsMatcher(std::vector<T, AllocComp>
const &target)
12952 : m_target(target) {}
12953 bool match(std::vector<T, AllocMatch>
const &vec)
const override {
12954 if (m_target.size() != vec.size()) {
12957 return std::is_permutation(m_target.begin(), m_target.end(), vec.begin());
12960 std::string describe()
const override {
12961 return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target);
12969 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
12970 ContainsMatcher<T, AllocComp, AllocMatch> Contains(std::vector<T, AllocComp>
const &comparator) {
12971 return ContainsMatcher<T, AllocComp, AllocMatch>(comparator);
12975 template<
typename T,
typename Alloc = std::allocator<T>>
12976 VectorContainsElementMatcher<T, Alloc> VectorContains(T
const &comparator) {
12977 return VectorContainsElementMatcher<T, Alloc>(comparator);
12981 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
12982 EqualsMatcher<T, AllocComp, AllocMatch> Equals(std::vector<T, AllocComp>
const &comparator) {
12983 return EqualsMatcher<T, AllocComp, AllocMatch>(comparator);
12987 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
12988 ApproxMatcher<T, AllocComp, AllocMatch>
Approx(std::vector<T, AllocComp>
const &comparator) {
12989 return ApproxMatcher<T, AllocComp, AllocMatch>(comparator);
12993 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
12994 UnorderedEqualsMatcher<T, AllocComp, AllocMatch> UnorderedEquals(std::vector<T, AllocComp>
const &target) {
12995 return UnorderedEqualsMatcher<T, AllocComp, AllocMatch>(target);
13001 #endif // CATCH_MATCHERS_VECTOR_HPP_INCLUDED 13003 #endif // CATCH_MATCHERS_ALL_HPP_INCLUDED 13018 #ifndef CATCH_REPORTERS_ALL_HPP_INCLUDED 13019 #define CATCH_REPORTERS_ALL_HPP_INCLUDED 13021 #ifndef CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 13022 #define CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 13024 #ifndef CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED 13025 #define CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED 13027 #ifndef CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED 13028 #define CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED 13046 class ReporterBase :
public IEventListener {
13052 std::ostream &m_stream;
13056 std::map<std::string, std::string> m_customOptions;
13059 ReporterBase(ReporterConfig &&config);
13060 ~ReporterBase()
override;
13068 void listReporters(
13069 std::vector<ReporterDescription>
const &descriptions)
override;
13076 void listListeners(
13077 std::vector<ListenerDescription>
const &descriptions)
override;
13085 void listTests(std::vector<TestCaseHandle>
const &tests)
override;
13092 void listTags(std::vector<TagInfo>
const &tags)
override;
13096 #endif // CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED 13102 class StreamingReporterBase :
public ReporterBase {
13106 StreamingReporterBase(ReporterConfig &&_config)
13108 ~StreamingReporterBase()
override;
13110 void benchmarkPreparing(
StringRef)
override {}
13113 void benchmarkFailed(
StringRef)
override {}
13115 void fatalErrorEncountered(
StringRef )
override {}
13116 void noMatchingTestCases(
StringRef )
override {}
13117 void reportInvalidTestSpec(
StringRef )
override {}
13119 void testRunStarting(
TestRunInfo const &_testRunInfo)
override;
13121 void testCaseStarting(
TestCaseInfo const &_testInfo)
override {
13122 currentTestCaseInfo = &_testInfo;
13124 void testCasePartialStarting(
TestCaseInfo const &, uint64_t)
override {}
13125 void sectionStarting(
SectionInfo const &_sectionInfo)
override {
13126 m_sectionStack.push_back(_sectionInfo);
13130 void assertionEnded(AssertionStats
const &)
override {}
13132 void sectionEnded(SectionStats
const & )
override {
13133 m_sectionStack.pop_back();
13135 void testCasePartialEnded(TestCaseStats
const &, uint64_t)
override {}
13136 void testCaseEnded(TestCaseStats
const & )
override {
13137 currentTestCaseInfo =
nullptr;
13139 void testRunEnded(TestRunStats
const & )
override;
13147 TestRunInfo currentTestRunInfo{
"test run has not started yet"_sr};
13151 std::vector<SectionInfo> m_sectionStack;
13156 #endif // CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED 13162 class AutomakeReporter final :
public StreamingReporterBase {
13166 AutomakeReporter(ReporterConfig &&_config)
13167 : StreamingReporterBase(
CATCH_MOVE(_config)) {
13168 m_preferences.shouldReportAllAssertionStarts =
false;
13171 ~AutomakeReporter()
override;
13173 static std::string getDescription() {
13174 using namespace std::string_literals;
13175 return "Reports test results in the format of Automake .trs files"s;
13178 void testCaseEnded(TestCaseStats
const &_testCaseStats)
override;
13184 #endif // CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 13186 #ifndef CATCH_REPORTER_COMPACT_HPP_INCLUDED 13187 #define CATCH_REPORTER_COMPACT_HPP_INCLUDED 13191 class CompactReporter final :
public StreamingReporterBase {
13193 CompactReporter(ReporterConfig &&_config)
13194 : StreamingReporterBase(
CATCH_MOVE(_config)) {
13195 m_preferences.shouldReportAllAssertionStarts =
false;
13198 ~CompactReporter()
override;
13200 static std::string getDescription();
13202 void noMatchingTestCases(
StringRef unmatchedSpec)
override;
13204 void testRunStarting(
TestRunInfo const &_testInfo)
override;
13206 void assertionEnded(AssertionStats
const &_assertionStats)
override;
13208 void sectionEnded(SectionStats
const &_sectionStats)
override;
13210 void testRunEnded(TestRunStats
const &_testRunStats)
override;
13215 #endif // CATCH_REPORTER_COMPACT_HPP_INCLUDED 13217 #ifndef CATCH_REPORTER_CONSOLE_HPP_INCLUDED 13218 #define CATCH_REPORTER_CONSOLE_HPP_INCLUDED 13224 class ConsoleReporter final :
public StreamingReporterBase {
13228 ConsoleReporter(ReporterConfig &&config);
13229 ~ConsoleReporter()
override;
13230 static std::string getDescription();
13232 void noMatchingTestCases(
StringRef unmatchedSpec)
override;
13233 void reportInvalidTestSpec(
StringRef arg)
override;
13235 void assertionEnded(AssertionStats
const &_assertionStats)
override;
13237 void sectionStarting(
SectionInfo const &_sectionInfo)
override;
13238 void sectionEnded(SectionStats
const &_sectionStats)
override;
13240 void benchmarkPreparing(
StringRef name)
override;
13241 void benchmarkStarting(
BenchmarkInfo const &info)
override;
13243 void benchmarkFailed(
StringRef error)
override;
13245 void testCaseEnded(TestCaseStats
const &_testCaseStats)
override;
13246 void testRunEnded(TestRunStats
const &_testRunStats)
override;
13247 void testRunStarting(
TestRunInfo const &_testRunInfo)
override;
13252 void lazyPrintWithoutClosingBenchmarkTable();
13253 void lazyPrintRunInfo();
13254 void printTestCaseAndSectionHeader();
13256 void printClosedHeader(std::string
const &_name);
13257 void printOpenHeader(std::string
const &_name);
13261 void printHeaderString(std::string
const &_string, std::size_t indent = 0);
13263 void printTotalsDivider(
Totals const &totals);
13265 bool m_headerPrinted =
false;
13266 bool m_testRunInfoPrinted =
false;
13271 #endif // CATCH_REPORTER_CONSOLE_HPP_INCLUDED 13273 #ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED 13274 #define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED 13284 class AssertionOrBenchmarkResult {
13292 AssertionOrBenchmarkResult(AssertionStats
const &assertion);
13295 bool isAssertion()
const;
13296 bool isBenchmark()
const;
13298 AssertionStats
const &asAssertion()
const;
13323 class CumulativeReporterBase :
public ReporterBase {
13325 template<
typename T,
typename ChildNodeT>
13327 explicit Node(T
const &_value)
13330 using ChildNodes = std::vector<Detail::unique_ptr<ChildNodeT>>;
13332 ChildNodes children;
13334 struct SectionNode {
13335 explicit SectionNode(SectionStats
const &_stats)
13338 bool operator==(SectionNode
const &other)
const {
13339 return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
13342 bool hasAnyAssertions()
const;
13344 SectionStats stats;
13345 std::vector<Detail::unique_ptr<SectionNode>> childSections;
13346 std::vector<Detail::AssertionOrBenchmarkResult> assertionsAndBenchmarks;
13347 std::string stdOut;
13348 std::string stdErr;
13351 using TestCaseNode = Node<TestCaseStats, SectionNode>;
13352 using TestRunNode = Node<TestRunStats, TestCaseNode>;
13356 CumulativeReporterBase(ReporterConfig &&_config)
13358 ~CumulativeReporterBase()
override;
13360 void benchmarkPreparing(
StringRef)
override {}
13363 void benchmarkFailed(
StringRef)
override {}
13365 void noMatchingTestCases(
StringRef)
override {}
13366 void reportInvalidTestSpec(
StringRef)
override {}
13367 void fatalErrorEncountered(
StringRef )
override {}
13369 void testRunStarting(
TestRunInfo const &)
override {}
13371 void testCaseStarting(
TestCaseInfo const &)
override {}
13372 void testCasePartialStarting(
TestCaseInfo const &, uint64_t)
override {}
13373 void sectionStarting(
SectionInfo const §ionInfo)
override;
13377 void assertionEnded(AssertionStats
const &assertionStats)
override;
13378 void sectionEnded(SectionStats
const §ionStats)
override;
13379 void testCasePartialEnded(TestCaseStats
const &, uint64_t)
override {}
13380 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
13381 void testRunEnded(TestRunStats
const &testRunStats)
override;
13383 virtual void testRunEndedCumulative() = 0;
13389 bool m_shouldStoreSuccesfulAssertions =
true;
13391 bool m_shouldStoreFailedAssertions =
true;
13401 std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases;
13405 SectionNode *m_deepestSection =
nullptr;
13407 std::vector<SectionNode *> m_sectionStack;
13412 #endif // CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED 13414 #ifndef CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED 13415 #define CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED 13426 class EventListenerBase :
public IEventListener {
13428 using IEventListener::IEventListener;
13430 void reportInvalidTestSpec(
StringRef unmatchedSpec)
override;
13431 void fatalErrorEncountered(
StringRef error)
override;
13433 void benchmarkPreparing(
StringRef name)
override;
13434 void benchmarkStarting(
BenchmarkInfo const &benchmarkInfo)
override;
13436 void benchmarkFailed(
StringRef error)
override;
13438 void assertionStarting(
AssertionInfo const &assertionInfo)
override;
13439 void assertionEnded(AssertionStats
const &assertionStats)
override;
13441 void listReporters(
13442 std::vector<ReporterDescription>
const &descriptions)
override;
13443 void listListeners(
13444 std::vector<ListenerDescription>
const &descriptions)
override;
13445 void listTests(std::vector<TestCaseHandle>
const &tests)
override;
13446 void listTags(std::vector<TagInfo>
const &tagInfos)
override;
13448 void noMatchingTestCases(
StringRef unmatchedSpec)
override;
13449 void testRunStarting(
TestRunInfo const &testRunInfo)
override;
13450 void testCaseStarting(
TestCaseInfo const &testInfo)
override;
13451 void testCasePartialStarting(
TestCaseInfo const &testInfo,
13452 uint64_t partNumber)
override;
13453 void sectionStarting(
SectionInfo const §ionInfo)
override;
13454 void sectionEnded(SectionStats
const §ionStats)
override;
13455 void testCasePartialEnded(TestCaseStats
const &testCaseStats,
13456 uint64_t partNumber)
override;
13457 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
13458 void testRunEnded(TestRunStats
const &testRunStats)
override;
13464 #endif // CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED 13466 #ifndef CATCH_REPORTER_HELPERS_HPP_INCLUDED 13467 #define CATCH_REPORTER_HELPERS_HPP_INCLUDED 13480 std::string getFormattedDuration(
double duration);
13483 bool shouldShowDuration(
IConfig const &config,
double duration);
13485 std::string serializeFilters(std::vector<std::string>
const &filters);
13487 struct lineOfChars {
13489 constexpr lineOfChars(
char c_)
13492 friend std::ostream &operator<<(std::ostream &out, lineOfChars value);
13504 defaultListReporters(std::ostream &out,
13505 std::vector<ReporterDescription>
const &descriptions,
13506 Verbosity verbosity);
13512 void defaultListListeners(std::ostream &out,
13513 std::vector<ListenerDescription>
const &descriptions,
13514 Verbosity verbosity);
13523 void defaultListTags(std::ostream &out,
13524 std::vector<TagInfo>
const &tags,
13526 Verbosity verbosity);
13537 void defaultListTests(std::ostream &out,
13538 ColourImpl *streamColour,
13539 std::vector<TestCaseHandle>
const &tests,
13541 Verbosity verbosity);
13548 void printTestRunTotals(std::ostream &stream,
13549 ColourImpl &streamColour,
13554 #endif // CATCH_REPORTER_HELPERS_HPP_INCLUDED 13556 #ifndef CATCH_REPORTER_JSON_HPP_INCLUDED 13557 #define CATCH_REPORTER_JSON_HPP_INCLUDED 13562 class JsonReporter :
public StreamingReporterBase {
13564 JsonReporter(ReporterConfig &&config);
13566 ~JsonReporter()
override;
13568 static std::string getDescription();
13571 void testRunStarting(
TestRunInfo const &runInfo)
override;
13572 void testRunEnded(TestRunStats
const &runStats)
override;
13574 void testCaseStarting(
TestCaseInfo const &tcInfo)
override;
13575 void testCaseEnded(TestCaseStats
const &tcStats)
override;
13577 void testCasePartialStarting(
TestCaseInfo const &tcInfo,
13578 uint64_t index)
override;
13579 void testCasePartialEnded(TestCaseStats
const &tcStats,
13580 uint64_t index)
override;
13582 void sectionStarting(
SectionInfo const §ionInfo)
override;
13583 void sectionEnded(SectionStats
const §ionStats)
override;
13585 void assertionEnded(AssertionStats
const &assertionStats)
override;
13589 void benchmarkPreparing(
StringRef name)
override;
13592 void benchmarkFailed(
StringRef error)
override;
13594 void listReporters(
13595 std::vector<ReporterDescription>
const &descriptions)
override;
13596 void listListeners(
13597 std::vector<ListenerDescription>
const &descriptions)
override;
13598 void listTests(std::vector<TestCaseHandle>
const &tests)
override;
13599 void listTags(std::vector<TagInfo>
const &tags)
override;
13602 Timer m_testCaseTimer;
13603 enum class Writer {
13608 JsonArrayWriter &startArray();
13609 JsonArrayWriter &startArray(
StringRef key);
13611 JsonObjectWriter &startObject();
13612 JsonObjectWriter &startObject(
StringRef key);
13617 bool isInside(Writer writer);
13619 void startListing();
13626 std::stack<JsonObjectWriter> m_objectWriters{};
13627 std::stack<JsonArrayWriter> m_arrayWriters{};
13628 std::stack<Writer> m_writers{};
13630 bool m_startedListing =
false;
13637 #endif // CATCH_REPORTER_JSON_HPP_INCLUDED 13639 #ifndef CATCH_REPORTER_JUNIT_HPP_INCLUDED 13640 #define CATCH_REPORTER_JUNIT_HPP_INCLUDED 13644 class JunitReporter final :
public CumulativeReporterBase {
13646 JunitReporter(ReporterConfig &&_config);
13648 static std::string getDescription();
13650 void testRunStarting(
TestRunInfo const &runInfo)
override;
13652 void testCaseStarting(
TestCaseInfo const &testCaseInfo)
override;
13653 void assertionEnded(AssertionStats
const &assertionStats)
override;
13655 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
13657 void testRunEndedCumulative()
override;
13660 void writeRun(TestRunNode
const &testRunNode,
double suiteTime);
13662 void writeTestCase(TestCaseNode
const &testCaseNode);
13664 void writeSection(std::string
const &className,
13665 std::string
const &rootName,
13666 SectionNode
const §ionNode,
13667 bool testOkToFail);
13669 void writeAssertions(SectionNode
const §ionNode);
13670 bool writeAssertion(AssertionStats
const &stats);
13674 std::string stdOutForSuite;
13675 std::string stdErrForSuite;
13676 unsigned int unexpectedExceptions = 0;
13677 bool m_okToFail =
false;
13682 #endif // CATCH_REPORTER_JUNIT_HPP_INCLUDED 13684 #ifndef CATCH_REPORTER_MULTI_HPP_INCLUDED 13685 #define CATCH_REPORTER_MULTI_HPP_INCLUDED 13689 class MultiReporter final :
public IEventListener {
13696 std::vector<IEventListenerPtr> m_reporterLikes;
13697 bool m_haveNoncapturingReporters =
false;
13701 size_t m_insertedListeners = 0;
13703 void updatePreferences(IEventListener
const &reporterish);
13706 MultiReporter(
IConfig const *config)
13707 : IEventListener(config) {
13708 m_preferences.shouldReportAllAssertionStarts =
false;
13711 using IEventListener::IEventListener;
13713 void addListener(IEventListenerPtr &&listener);
13714 void addReporter(IEventListenerPtr &&reporter);
13717 void noMatchingTestCases(
StringRef unmatchedSpec)
override;
13718 void fatalErrorEncountered(
StringRef error)
override;
13719 void reportInvalidTestSpec(
StringRef arg)
override;
13721 void benchmarkPreparing(
StringRef name)
override;
13722 void benchmarkStarting(
BenchmarkInfo const &benchmarkInfo)
override;
13724 void benchmarkFailed(
StringRef error)
override;
13726 void testRunStarting(
TestRunInfo const &testRunInfo)
override;
13727 void testCaseStarting(
TestCaseInfo const &testInfo)
override;
13728 void testCasePartialStarting(
TestCaseInfo const &testInfo, uint64_t partNumber)
override;
13729 void sectionStarting(
SectionInfo const §ionInfo)
override;
13730 void assertionStarting(
AssertionInfo const &assertionInfo)
override;
13732 void assertionEnded(AssertionStats
const &assertionStats)
override;
13733 void sectionEnded(SectionStats
const §ionStats)
override;
13734 void testCasePartialEnded(TestCaseStats
const &testStats, uint64_t partNumber)
override;
13735 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
13736 void testRunEnded(TestRunStats
const &testRunStats)
override;
13740 void listReporters(std::vector<ReporterDescription>
const &descriptions)
override;
13741 void listListeners(std::vector<ListenerDescription>
const &descriptions)
override;
13742 void listTests(std::vector<TestCaseHandle>
const &tests)
override;
13743 void listTags(std::vector<TagInfo>
const &tags)
override;
13748 #endif // CATCH_REPORTER_MULTI_HPP_INCLUDED 13750 #ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED 13751 #define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED 13753 #include <type_traits> 13759 template<
typename T,
typename =
void>
13760 struct has_description : std::false_type {};
13762 template<
typename T>
13763 struct has_description<
13765 void_t<decltype(T::getDescription())>>
13766 : std::true_type {};
13770 void registerReporterImpl(std::string
const &name,
13776 class IEventListener;
13779 template<
typename T>
13780 class ReporterFactory :
public IReporterFactory {
13781 IEventListenerPtr create(ReporterConfig &&config)
const override {
13782 return Detail::make_unique<T>(
CATCH_MOVE(config));
13785 std::string getDescription()
const override {
13786 return T::getDescription();
13790 template<
typename T>
13791 class ReporterRegistrar {
13793 explicit ReporterRegistrar(std::string
const &name) {
13794 registerReporterImpl(name,
13795 Detail::make_unique<ReporterFactory<T>>());
13799 template<
typename T>
13800 class ListenerRegistrar {
13801 class TypedListenerFactory :
public EventListenerFactory {
13804 std::string getDescriptionImpl(std::true_type)
const {
13805 return T::getDescription();
13808 std::string getDescriptionImpl(std::false_type)
const {
13809 return "(No description provided)";
13813 TypedListenerFactory(
StringRef listenerName)
13814 : m_listenerName(listenerName) {}
13816 IEventListenerPtr create(
IConfig const *config)
const override {
13817 return Detail::make_unique<T>(config);
13821 return m_listenerName;
13824 std::string getDescription()
const override {
13825 return getDescriptionImpl(Detail::has_description<T>{});
13830 ListenerRegistrar(
StringRef listenerName) {
13831 registerListenerImpl(Detail::make_unique<TypedListenerFactory>(listenerName));
13836 #if !defined(CATCH_CONFIG_DISABLE) 13838 #define CATCH_REGISTER_REPORTER(name, reporterType) \ 13839 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 13840 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 13842 const Catch::ReporterRegistrar<reporterType> \ 13843 INTERNAL_CATCH_UNIQUE_NAME(catch_internal_RegistrarFor)( \ 13846 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 13848 #define CATCH_REGISTER_LISTENER(listenerType) \ 13849 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 13850 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 13852 const Catch::ListenerRegistrar<listenerType> \ 13853 INTERNAL_CATCH_UNIQUE_NAME(catch_internal_RegistrarFor)( \ 13854 #listenerType##_catch_sr); \ 13856 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 13858 #else // CATCH_CONFIG_DISABLE 13860 #define CATCH_REGISTER_REPORTER(name, reporterType) 13861 #define CATCH_REGISTER_LISTENER(listenerType) 13863 #endif // CATCH_CONFIG_DISABLE 13865 #endif // CATCH_REPORTER_REGISTRARS_HPP_INCLUDED 13867 #ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED 13868 #define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED 13872 class SonarQubeReporter final :
public CumulativeReporterBase {
13874 SonarQubeReporter(ReporterConfig &&config)
13875 : CumulativeReporterBase(
CATCH_MOVE(config))
13877 m_preferences.shouldRedirectStdOut =
true;
13878 m_preferences.shouldReportAllAssertions =
false;
13879 m_preferences.shouldReportAllAssertionStarts =
false;
13880 m_shouldStoreSuccesfulAssertions =
false;
13883 static std::string getDescription() {
13884 using namespace std::string_literals;
13885 return "Reports test results in the Generic Test Data SonarQube XML format"s;
13888 void testRunStarting(
TestRunInfo const &testRunInfo)
override;
13890 void testRunEndedCumulative()
override {
13891 writeRun(*m_testRun);
13895 void writeRun(TestRunNode
const &runNode);
13897 void writeTestFile(
StringRef filename, std::vector<TestCaseNode const *>
const &testCaseNodes);
13899 void writeTestCase(TestCaseNode
const &testCaseNode);
13901 void writeSection(std::string
const &rootName, SectionNode
const §ionNode,
bool okToFail);
13903 void writeAssertions(SectionNode
const §ionNode,
bool okToFail);
13905 void writeAssertion(AssertionStats
const &stats,
bool okToFail);
13913 #endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED 13915 #ifndef CATCH_REPORTER_TAP_HPP_INCLUDED 13916 #define CATCH_REPORTER_TAP_HPP_INCLUDED 13920 class TAPReporter final :
public StreamingReporterBase {
13922 TAPReporter(ReporterConfig &&config)
13923 : StreamingReporterBase(
CATCH_MOVE(config)) {
13924 m_preferences.shouldReportAllAssertions =
true;
13925 m_preferences.shouldReportAllAssertionStarts =
false;
13928 static std::string getDescription() {
13929 using namespace std::string_literals;
13930 return "Reports test results in TAP format, suitable for test harnesses"s;
13933 void testRunStarting(
TestRunInfo const &testInfo)
override;
13935 void noMatchingTestCases(
StringRef unmatchedSpec)
override;
13937 void assertionEnded(AssertionStats
const &_assertionStats)
override;
13939 void testRunEnded(TestRunStats
const &_testRunStats)
override;
13942 std::size_t counter = 0;
13947 #endif // CATCH_REPORTER_TAP_HPP_INCLUDED 13949 #ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED 13950 #define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED 13955 #pragma clang diagnostic push 13956 #pragma clang diagnostic ignored "-Wpadded" 13961 class TeamCityReporter final :
public StreamingReporterBase {
13963 TeamCityReporter(ReporterConfig &&_config)
13964 : StreamingReporterBase(
CATCH_MOVE(_config)) {
13965 m_preferences.shouldRedirectStdOut =
true;
13966 m_preferences.shouldReportAllAssertionStarts =
false;
13969 ~TeamCityReporter()
override;
13971 static std::string getDescription() {
13972 using namespace std::string_literals;
13973 return "Reports test results as TeamCity service messages"s;
13976 void testRunStarting(
TestRunInfo const &runInfo)
override;
13977 void testRunEnded(TestRunStats
const &runStats)
override;
13979 void assertionEnded(AssertionStats
const &assertionStats)
override;
13981 void sectionStarting(
SectionInfo const §ionInfo)
override {
13982 m_headerPrintedForThisSection =
false;
13983 StreamingReporterBase::sectionStarting(sectionInfo);
13986 void testCaseStarting(
TestCaseInfo const &testInfo)
override;
13988 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
13991 void printSectionHeader(std::ostream &os);
13993 bool m_headerPrintedForThisSection =
false;
14000 #pragma clang diagnostic pop 14003 #endif // CATCH_REPORTER_TEAMCITY_HPP_INCLUDED 14005 #ifndef CATCH_REPORTER_XML_HPP_INCLUDED 14006 #define CATCH_REPORTER_XML_HPP_INCLUDED 14009 class XmlReporter :
public StreamingReporterBase {
14011 XmlReporter(ReporterConfig &&_config);
14013 ~XmlReporter()
override;
14015 static std::string getDescription();
14017 virtual std::string getStylesheetRef()
const;
14022 void testRunStarting(
TestRunInfo const &testInfo)
override;
14024 void testCaseStarting(
TestCaseInfo const &testInfo)
override;
14026 void sectionStarting(
SectionInfo const §ionInfo)
override;
14028 void assertionEnded(AssertionStats
const &assertionStats)
override;
14030 void sectionEnded(SectionStats
const §ionStats)
override;
14032 void testCaseEnded(TestCaseStats
const &testCaseStats)
override;
14034 void testRunEnded(TestRunStats
const &testRunStats)
override;
14036 void benchmarkPreparing(
StringRef name)
override;
14039 void benchmarkFailed(
StringRef error)
override;
14041 void listReporters(std::vector<ReporterDescription>
const &descriptions)
override;
14042 void listListeners(std::vector<ListenerDescription>
const &descriptions)
override;
14043 void listTests(std::vector<TestCaseHandle>
const &tests)
override;
14044 void listTags(std::vector<TagInfo>
const &tags)
override;
14047 Timer m_testCaseTimer;
14049 int m_sectionDepth = 0;
14054 #endif // CATCH_REPORTER_XML_HPP_INCLUDED 14056 #endif // CATCH_REPORTERS_ALL_HPP_INCLUDED 14058 #endif // CATCH_ALL_HPP_INCLUDED 14059 #endif // CATCH_AMALGAMATED_HPP_INCLUDED #define CATCH_FORWARD(...)
Replacement for std::forward with better compile time performance.
Definition: catch_amalgamated.hpp:594
Definition: catch_amalgamated.hpp:1552
Definition: catch_amalgamated.hpp:5331
Definition: catch_amalgamated.hpp:4174
Definition: catch_amalgamated.hpp:8076
Definition: catch_amalgamated.hpp:1707
Definition: catch_amalgamated.hpp:4586
What
Definition: catch_amalgamated.hpp:1137
Definition: catch_amalgamated.hpp:3689
#define CATCH_MOVE(...)
Replacement for std::move with better compile time performance.
Definition: catch_amalgamated.hpp:591
Definition: catch_amalgamated.hpp:4721
Definition: catch_amalgamated.hpp:5232
Definition: catch_amalgamated.hpp:1257
Definition: catch_amalgamated.hpp:3183
Definition: catch_amalgamated.hpp:1245
Definition: catch_amalgamated.hpp:7631
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:8031
Definition: catch_amalgamated.hpp:1328
Definition: catch_amalgamated.hpp:2386
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7611
Definition: catch_amalgamated.hpp:3737
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7585
Definition: catch_amalgamated.hpp:7202
Definition: catch_amalgamated.hpp:3208
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7798
ResultType
Denotes type of a parsing result.
Definition: catch_amalgamated.hpp:4236
Definition: catch_amalgamated.cpp:9260
Used to signal that an assertion macro failed.
Definition: catch_amalgamated.hpp:604
Definition: catch_amalgamated.hpp:5260
Definition: catch_amalgamated.hpp:2356
Definition: catch_amalgamated.hpp:4821
Definition: catch_amalgamated.hpp:4939
Definition: catch_amalgamated.hpp:2863
Definition: catch_amalgamated.hpp:1018
Definition: catch_amalgamated.hpp:5534
Definition: catch_amalgamated.hpp:7547
Definition: catch_amalgamated.hpp:2497
Definition: catch_amalgamated.hpp:7775
Definition: catch_amalgamated.hpp:4746
ReporterSpec but with the defaults filled in.
Definition: catch_amalgamated.hpp:3676
Definition: catch_amalgamated.hpp:4594
Definition: catch_amalgamated.hpp:1538
Definition: catch_amalgamated.hpp:7589
Definition: catch_amalgamated.hpp:1759
Definition: catch_amalgamated.hpp:1168
Definition: catch_amalgamated.cpp:339
A non-owning string class (similar to the forthcoming std::string_view) Note that, because a StringRef may be a substring of another string, it may not be null terminated.
Definition: catch_amalgamated.hpp:708
Definition: catch_amalgamated.hpp:844
Optional< ReporterSpec > parseReporterSpec(StringRef reporterSpec)
Parses provided reporter spec string into.
Definition: catch_amalgamated.cpp:5445
Definition: catch_amalgamated.hpp:5952
Definition: catch_amalgamated.hpp:7529
Definition: catch_amalgamated.hpp:7511
Definition: catch_amalgamated.hpp:4452
We need to reinvent std::function because every piece of code that might add overhead in a measuremen...
Definition: catch_amalgamated.hpp:1601
Definition: catch_amalgamated.hpp:1670
void throw_test_failure_exception()
Outlines throwing of TestFailureException into a single TU.
Definition: catch_amalgamated.cpp:7194
Definition: catch_amalgamated.hpp:5756
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7890
Definition: catch_amalgamated.hpp:4260
Definition: catch_amalgamated.hpp:5528
Definition: catch_amalgamated.hpp:7701
Definition: catch_amalgamated.hpp:5896
Definition: catch_amalgamated.hpp:2051
Structured reporter spec that a reporter can be created from.
Definition: catch_amalgamated.hpp:3613
Definition: catch_amalgamated.hpp:1494
Definition: catch_amalgamated.hpp:554
Deriving classes become noncopyable and nonmovable.
Definition: catch_amalgamated.hpp:1108
Definition: catch_amalgamated.hpp:4090
Wrapper over the test case information and the test case invoker.
Definition: catch_amalgamated.hpp:7160
Definition: catch_amalgamated.hpp:5917
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7949
Definition: catch_amalgamated.hpp:7965
Definition: catch_amalgamated.hpp:1719
Definition: catch_amalgamated.hpp:5230
Definition: catch_amalgamated.hpp:3549
Definition: catch_amalgamated.hpp:4542
Definition: catch_amalgamated.hpp:3237
Definition: memory_leak_test.cpp:28
Definition: catch_amalgamated.hpp:5344
Definition: catch_amalgamated.hpp:4152
Definition: catch_amalgamated.hpp:5071
Definition: catch_amalgamated.hpp:4061
Definition: catch_amalgamated.hpp:4572
Definition: catch_amalgamated.hpp:1310
Definition: catch_amalgamated.hpp:7822
Definition: catch_amalgamated.hpp:7233
Definition: catch_amalgamated.hpp:2083
GeneratorWrapper(IGenerator< T > *generator)
Takes ownership of the passed pointer.
Definition: catch_amalgamated.hpp:7552
Definition: catch_amalgamated.hpp:7569
Definition: catch_amalgamated.hpp:5216
Definition: catch_amalgamated.hpp:8008
std::uint32_t getSeed()
Returns Catch2's current RNG seed.
Definition: catch_amalgamated.cpp:1003
Definition: catch_amalgamated.hpp:3306
Definition: catch_amalgamated.hpp:3398
Definition: catch_amalgamated.hpp:4441
Used to signal that the remainder of a test should be skipped.
Definition: catch_amalgamated.hpp:606
Definition: catch_amalgamated.hpp:1136
Definition: catch_amalgamated.hpp:3161
Definition: catch_amalgamated.hpp:4922
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7998
Definition: catch_amalgamated.hpp:4446
Definition: catch_amalgamated.hpp:1385
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7854
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7672
Definition: catch_amalgamated.hpp:2376
Definition: catch_amalgamated.hpp:7227
Definition: catch_amalgamated.hpp:5861
Definition: catch_amalgamated.hpp:2309
Definition: catch_amalgamated.hpp:4403
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7987
Definition: catch_amalgamated.hpp:4525
A view of a tag string that provides case insensitive comparisons.
Definition: catch_amalgamated.hpp:7089
Definition: catch_amalgamated.hpp:5773
Definition: catch_amalgamated.hpp:4381
Definition: catch_amalgamated.hpp:1181
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:8040
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7581
A reimplementation of std::unique_ptr for improved compilation performance.
Definition: catch_amalgamated.hpp:884
Definition: catch_amalgamated.hpp:4328
Definition: catch_amalgamated.hpp:5061
Definition: catch_amalgamated.hpp:3338
Definition: catch_amalgamated.hpp:4549
Definition: catch_amalgamated.hpp:4482
Definition: catch_amalgamated.hpp:1502
Definition: catch_amalgamated.hpp:1837
Definition: catch_amalgamated.hpp:812
Definition: catch_amalgamated.hpp:2925
Definition: catch_amalgamated.hpp:1912
Definition: catch_amalgamated.hpp:4492
Various metadata about the test case.
Definition: catch_amalgamated.hpp:7120
Definition: catch_amalgamated.hpp:7383
Definition: catch_amalgamated.hpp:1519
Definition: catch_amalgamated.hpp:7323
Definition: catch_amalgamated.hpp:4436
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7813
Wrapper over argc + argv, assumes that the inputs outlive it.
Definition: catch_amalgamated.hpp:4807
std::string str() const
Returns the serialized state.
Definition: catch_amalgamated.cpp:5557
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7845
Definition: catch_amalgamated.hpp:7923
Definition: catch_amalgamated.hpp:4670
Definition: catch_amalgamated.hpp:7863
Definition: catch_amalgamated.hpp:5063
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7616
Definition: catch_amalgamated.hpp:4078
Definition: catch_amalgamated.hpp:7425
Definition: catch_amalgamated.hpp:3877
Definition: catch_amalgamated.hpp:2870
Definition: catch_amalgamated.hpp:4203
Definition: catch_amalgamated.hpp:3441
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7914
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7944
bool isFinite() const override
Returns true if calls to next will eventually return false.
Definition: catch_amalgamated.hpp:7683
Definition: catch_amalgamated.hpp:3250
Definition: catch_amalgamated.hpp:3921
Definition: catch_amalgamated.hpp:1351
Definition: catch_amalgamated.hpp:6391
Definition: catch_amalgamated.hpp:3038
Definition: catch_amalgamated.hpp:4659
Definition: catch_amalgamated.hpp:2417
Definition: catch_amalgamated.hpp:5069
Definition: catch_amalgamated.hpp:5077
Definition: catch_amalgamated.hpp:1528
Definition: catch_amalgamated.hpp:4870
virtual void streamReconstructedExpression(std::ostream &os) const
This function has to be overridden by the derived class.
Definition: catch_amalgamated.cpp:3852
Definition: catch_amalgamated.hpp:5495
Definition: catch_amalgamated.hpp:7251
Definition: catch_amalgamated.hpp:4047
void throw_test_skip_exception()
Outlines throwing of TestSkipException into a single TU.
Definition: catch_amalgamated.cpp:7202
Definition: catch_amalgamated.hpp:990
Definition: catch_amalgamated.hpp:1389
Definition: catch_amalgamated.hpp:2203
Definition: catch_amalgamated.hpp:1492