14 #ifndef CATCH_AMALGAMATED_HPP_INCLUDED
15 #define CATCH_AMALGAMATED_HPP_INCLUDED
32 #ifndef CATCH_ALL_HPP_INCLUDED
33 #define CATCH_ALL_HPP_INCLUDED
50 #ifndef CATCH_BENCHMARK_ALL_HPP_INCLUDED
51 #define CATCH_BENCHMARK_ALL_HPP_INCLUDED
57 #ifndef CATCH_BENCHMARK_HPP_INCLUDED
58 #define CATCH_BENCHMARK_HPP_INCLUDED
62 #ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED
63 #define CATCH_INTERFACES_CONFIG_HPP_INCLUDED
67 #ifndef CATCH_NONCOPYABLE_HPP_INCLUDED
68 #define CATCH_NONCOPYABLE_HPP_INCLUDED
90 #ifndef CATCH_STRINGREF_HPP_INCLUDED
91 #define CATCH_STRINGREF_HPP_INCLUDED
106 using const_iterator =
const char*;
109 static constexpr
char const*
const s_empty =
"";
111 char const* m_start = s_empty;
112 size_type m_size = 0;
115 constexpr
StringRef() noexcept =
default;
117 StringRef(
char const* rawChars ) noexcept;
119 constexpr
StringRef(
char const* rawChars, size_type size ) noexcept
120 : m_start( rawChars ),
124 StringRef( std::string
const& stdString ) noexcept
125 : m_start( stdString.c_str() ),
126 m_size( stdString.size() )
129 explicit operator std::string()
const {
130 return std::string(m_start, m_size);
134 auto operator == (
StringRef other )
const noexcept -> bool;
135 auto operator != (
StringRef other)
const noexcept ->
bool {
136 return !(*
this == other);
139 constexpr
auto operator[] ( size_type index )
const noexcept ->
char {
140 assert(index < m_size);
141 return m_start[index];
144 bool operator<(
StringRef rhs)
const noexcept;
147 constexpr
auto empty()
const noexcept ->
bool {
150 constexpr
auto size()
const noexcept -> size_type {
157 constexpr
StringRef substr(size_type start, size_type length)
const noexcept {
158 if (start < m_size) {
159 const auto shortened_size = m_size - start;
160 return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length);
167 constexpr
char const* data()
const noexcept {
171 constexpr const_iterator begin()
const {
return m_start; }
172 constexpr const_iterator end()
const {
return m_start + m_size; }
175 friend std::string& operator += (std::string& lhs,
StringRef sr);
176 friend std::ostream& operator << (std::ostream& os,
StringRef sr);
207 enum class Verbosity {
221 enum class ShowDurations {
226 enum class TestRunOrder {
228 LexicographicallySorted,
245 BeforeStartAndExit = BeforeStart | BeforeExit
255 virtual bool allowThrows()
const = 0;
257 virtual bool includeSuccessfulResults()
const = 0;
258 virtual bool shouldDebugBreak()
const = 0;
259 virtual bool warnAboutMissingAssertions()
const = 0;
260 virtual bool warnAboutUnmatchedTestSpecs()
const = 0;
261 virtual bool zeroTestsCountAsSuccess()
const = 0;
262 virtual int abortAfter()
const = 0;
263 virtual bool showInvisibles()
const = 0;
264 virtual ShowDurations showDurations()
const = 0;
265 virtual double minDuration()
const = 0;
266 virtual TestSpec const& testSpec()
const = 0;
267 virtual bool hasTestFilters()
const = 0;
268 virtual std::vector<std::string>
const& getTestsOrTags()
const = 0;
269 virtual TestRunOrder runOrder()
const = 0;
270 virtual uint32_t rngSeed()
const = 0;
271 virtual unsigned int shardCount()
const = 0;
272 virtual unsigned int shardIndex()
const = 0;
273 virtual ColourMode defaultColourMode()
const = 0;
274 virtual std::vector<std::string>
const& getSectionsToRun()
const = 0;
275 virtual Verbosity verbosity()
const = 0;
277 virtual bool skipBenchmarks()
const = 0;
278 virtual bool benchmarkNoAnalysis()
const = 0;
279 virtual unsigned int benchmarkSamples()
const = 0;
280 virtual double benchmarkConfidenceInterval()
const = 0;
281 virtual unsigned int benchmarkResamples()
const = 0;
282 virtual std::chrono::milliseconds benchmarkWarmupTime()
const = 0;
289 #ifndef CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
290 #define CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
310 #ifndef CATCH_PLATFORM_HPP_INCLUDED
311 #define CATCH_PLATFORM_HPP_INCLUDED
316 # include <TargetConditionals.h>
317 # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
318 (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
319 # define CATCH_PLATFORM_MAC
320 # elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1)
321 # define CATCH_PLATFORM_IPHONE
324 #elif defined(linux) || defined(__linux) || defined(__linux__)
325 # define CATCH_PLATFORM_LINUX
327 #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
328 # define CATCH_PLATFORM_WINDOWS
335 # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
336 # define CATCH_CPP14_OR_GREATER
339 # if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
340 # define CATCH_CPP17_OR_GREATER
347 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__)
348 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
349 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" )
353 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
354 _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
356 # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
357 _Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" )
359 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
363 #if defined(__clang__) && !defined(_MSC_VER)
365 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
366 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )
384 # if !defined(__ibmxl__) && !defined(__CUDACC__) && !defined( __NVCOMPILER )
385 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
389 # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
390 _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
391 _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
393 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
394 _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
396 # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
397 _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" )
399 # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
400 _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" )
402 # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
403 _Pragma( "clang diagnostic ignored \"-Wunused-template\"" )
410 #if !defined(CATCH_PLATFORM_WINDOWS)
411 #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
416 #if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
417 #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
421 # define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
426 #if defined(__ANDROID__)
427 # define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
432 #if defined(__MINGW32__)
433 # define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
438 #if defined(__ORBIS__)
439 # define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
451 # if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
452 && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
454 # define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
461 #if defined(_MSC_VER)
463 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) )
464 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) )
468 # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
469 # define CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32
471 # define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
477 # if !defined(__clang__)
478 # if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
479 # define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
485 #if defined(_REENTRANT) || defined(_MSC_VER)
487 # define CATCH_INTERNAL_CONFIG_USE_ASYNC
492 #if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)
493 # define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
499 #if defined(__BORLANDC__)
500 #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
508 #if defined(UNDER_RTSS) || defined(RTX64_BUILD)
509 #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
510 #define CATCH_INTERNAL_CONFIG_NO_ASYNC
511 #define CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32
514 #if !defined(_GLIBCXX_USE_C99_MATH_TR1)
515 #define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER
519 #if defined(__has_include)
521 #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
522 # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
526 # if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
527 # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL
531 # if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
533 # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0)
534 # define CATCH_INTERNAL_CONFIG_CPP17_BYTE
539 # if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
540 # if defined(__clang__) && (__clang_major__ < 8)
544 # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
545 # define CATCH_CONFIG_NO_CPP17_VARIANT
547 # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
550 # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
556 #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)
557 # define CATCH_CONFIG_WINDOWS_SEH
560 #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)
561 # define CATCH_CONFIG_POSIX_SIGNALS
564 #if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
565 # define CATCH_CONFIG_CPP11_TO_STRING
568 #if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL)
569 # define CATCH_CONFIG_CPP17_OPTIONAL
572 #if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
573 # define CATCH_CONFIG_CPP17_STRING_VIEW
576 #if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
577 # define CATCH_CONFIG_CPP17_VARIANT
580 #if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE)
581 # define CATCH_CONFIG_CPP17_BYTE
585 #if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
586 # define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
589 #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)
590 # define CATCH_CONFIG_NEW_CAPTURE
593 #if !defined( CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED ) && \
594 !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) && \
595 !defined( CATCH_CONFIG_NO_DISABLE_EXCEPTIONS )
596 # define CATCH_CONFIG_DISABLE_EXCEPTIONS
599 #if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN)
600 # define CATCH_CONFIG_POLYFILL_ISNAN
603 #if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC)
604 # define CATCH_CONFIG_USE_ASYNC
607 #if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
608 # define CATCH_CONFIG_GLOBAL_NEXTAFTER
614 #if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION)
615 # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
617 #if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION)
618 # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
620 #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
621 # define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
623 #if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)
624 # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
626 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS)
627 # define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS
629 #if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS)
630 # define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS
635 #if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN)
636 # define CATCH_INTERNAL_IGNORE_BUT_WARN(...)
639 #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10)
640 # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
641 #elif defined(__clang__) && (__clang_major__ < 5)
642 # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
645 #if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS)
646 # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
649 #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
650 #define CATCH_TRY if ((true))
651 #define CATCH_CATCH_ALL if ((false))
652 #define CATCH_CATCH_ANON(type) if ((false))
654 #define CATCH_TRY try
655 #define CATCH_CATCH_ALL catch (...)
656 #define CATCH_CATCH_ANON(type) catch (type)
659 #if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR)
660 #define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
663 #if defined( CATCH_PLATFORM_WINDOWS ) && \
664 !defined( CATCH_CONFIG_COLOUR_WIN32 ) && \
665 !defined( CATCH_CONFIG_NO_COLOUR_WIN32 ) && \
666 !defined( CATCH_INTERNAL_CONFIG_NO_COLOUR_WIN32 )
667 # define CATCH_CONFIG_COLOUR_WIN32
674 #ifndef CATCH_CONTEXT_HPP_INCLUDED
675 #define CATCH_CONTEXT_HPP_INCLUDED
679 class IResultCapture;
687 virtual IConfig const* getConfig()
const = 0;
693 virtual void setResultCapture(
IResultCapture* resultCapture ) = 0;
694 virtual void setConfig(
IConfig const* config ) = 0;
699 friend void cleanUpContext();
700 static void createContext();
705 if( !IMutableContext::currentContext )
706 IMutableContext::createContext();
708 return *IMutableContext::currentContext;
711 inline IContext& getCurrentContext()
713 return getCurrentMutableContext();
716 void cleanUpContext();
719 SimplePcg32& sharedRng();
725 #ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED
726 #define CATCH_INTERFACES_REPORTER_HPP_INCLUDED
730 #ifndef CATCH_SECTION_INFO_HPP_INCLUDED
731 #define CATCH_SECTION_INFO_HPP_INCLUDED
735 #ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED
736 #define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED
738 #include <type_traits>
741 #define CATCH_MOVE(...) static_cast<std::remove_reference_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)
744 #define CATCH_FORWARD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
749 #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
750 #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
771 friend std::ostream& operator << (std::ostream& os,
SourceLineInfo const& info);
775 #define CATCH_INTERNAL_LINEINFO \
776 ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
781 #ifndef CATCH_TOTALS_HPP_INCLUDED
782 #define CATCH_TOTALS_HPP_INCLUDED
792 std::uint64_t total()
const;
793 bool allPassed()
const;
796 std::uint64_t passed = 0;
797 std::uint64_t failed = 0;
798 std::uint64_t failedButOk = 0;
824 const char*
const =
nullptr ):
836 double durationInSeconds;
844 #ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED
845 #define CATCH_ASSERTION_RESULT_HPP_INCLUDED
849 #ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED
850 #define CATCH_ASSERTION_INFO_HPP_INCLUDED
854 #ifndef CATCH_RESULT_TYPE_HPP_INCLUDED
855 #define CATCH_RESULT_TYPE_HPP_INCLUDED
868 ExpressionFailed = FailureBit | 1,
869 ExplicitFailure = FailureBit | 2,
871 Exception = 0x100 | FailureBit,
873 ThrewException = Exception | 1,
874 DidntThrowException = Exception | 2,
876 FatalErrorCondition = 0x200 | FailureBit
880 bool isOk( ResultWas::OfType resultType );
881 bool isJustInfo(
int flags );
888 ContinueOnFailure = 0x02,
893 ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs );
895 bool shouldContinueOnFailure(
int flags );
896 inline bool isFalseTest(
int flags ) {
return ( flags & ResultDisposition::FalseTest ) != 0; }
897 bool shouldSuppressFailure(
int flags );
911 ResultDisposition::Flags resultDisposition;
919 #ifndef CATCH_LAZY_EXPR_HPP_INCLUDED
920 #define CATCH_LAZY_EXPR_HPP_INCLUDED
926 class ITransientExpression;
937 m_isNegated(isNegated)
942 explicit operator bool()
const {
943 return m_transientExpression !=
nullptr;
946 friend auto operator << ( std::ostream& os,
LazyExpression const& lazyExpr ) -> std::ostream&;
964 mutable std::string reconstructedExpression;
966 ResultWas::OfType resultType;
968 std::string reconstructExpression()
const;
977 bool succeeded()
const;
978 ResultWas::OfType getResultType()
const;
979 bool hasExpression()
const;
980 bool hasMessage()
const;
981 std::string getExpression()
const;
982 std::string getExpressionInMacro()
const;
983 bool hasExpandedExpression()
const;
984 std::string getExpandedExpression()
const;
999 #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
1000 #define CATCH_MESSAGE_INFO_HPP_INCLUDED
1004 #ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
1005 #define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
1013 class AssertionResult;
1014 struct AssertionInfo;
1016 struct SectionEndInfo;
1018 struct MessageBuilder;
1020 struct AssertionReaction;
1021 struct SourceLineInfo;
1023 class ITransientExpression;
1024 class IGeneratorTracker;
1026 struct BenchmarkInfo;
1027 template <
typename Duration = std::chrono::duration<
double, std::nano>>
1028 struct BenchmarkStats;
1034 virtual bool sectionStarted(
SectionInfo const& sectionInfo,
1035 Counts& assertions ) = 0;
1037 virtual void sectionEndedEarly(
SectionEndInfo const& endInfo ) = 0;
1041 virtual void benchmarkPreparing(
StringRef name ) = 0;
1042 virtual void benchmarkStarting(
BenchmarkInfo const& info ) = 0;
1044 virtual void benchmarkFailed(
StringRef error ) = 0;
1046 virtual void pushScopedMessage(
MessageInfo const& message ) = 0;
1047 virtual void popScopedMessage(
MessageInfo const& message ) = 0;
1049 virtual void emplaceUnscopedMessage(
MessageBuilder const& builder ) = 0;
1051 virtual void handleFatalErrorCondition(
StringRef message ) = 0;
1053 virtual void handleExpr
1057 virtual void handleMessage
1059 ResultWas::OfType resultType,
1062 virtual void handleUnexpectedExceptionNotThrown
1065 virtual void handleUnexpectedInflightException
1067 std::string
const& message,
1069 virtual void handleIncomplete
1071 virtual void handleNonExpr
1073 ResultWas::OfType resultType,
1078 virtual bool lastAssertionPassed() = 0;
1079 virtual void assertionPassed() = 0;
1082 virtual std::string getCurrentTestName()
const = 0;
1084 virtual void exceptionEarlyReported() = 0;
1099 ResultWas::OfType _type );
1102 std::string message;
1104 ResultWas::OfType type;
1105 unsigned int sequence;
1107 bool operator == (
MessageInfo const& other)
const {
1108 return sequence == other.sequence;
1110 bool operator < (
MessageInfo const& other)
const {
1111 return sequence < other.sequence;
1114 static unsigned int globalCount;
1122 #ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED
1123 #define CATCH_UNIQUE_PTR_HPP_INCLUDED
1126 #include <type_traits>
1136 template <
typename T>
1140 constexpr
unique_ptr(std::nullptr_t =
nullptr):
1147 template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
1149 m_ptr(from.release())
1152 template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
1154 reset(from.release());
1164 rhs.m_ptr =
nullptr;
1167 reset(rhs.release());
1180 T
const& operator*()
const {
1184 T* operator->() noexcept {
1188 T
const* operator->()
const noexcept {
1193 T* get() {
return m_ptr; }
1194 T
const* get()
const {
return m_ptr; }
1196 void reset(T* ptr =
nullptr) {
1207 explicit operator bool()
const {
1212 auto temp = lhs.m_ptr;
1213 lhs.m_ptr = rhs.m_ptr;
1219 template <
typename T>
1222 template <
typename T,
typename... Args>
1236 #ifndef CATCH_ESTIMATE_HPP_INCLUDED
1237 #define CATCH_ESTIMATE_HPP_INCLUDED
1240 namespace Benchmark {
1241 template <
typename Duration>
1244 Duration lower_bound;
1245 Duration upper_bound;
1246 double confidence_interval;
1248 template <
typename Duration2>
1250 return { point, lower_bound, upper_bound, confidence_interval };
1261 #ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED
1262 #define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED
1265 namespace Benchmark {
1267 int samples_seen = 0;
1271 int high_severe = 0;
1274 return low_severe + low_mild + high_mild + high_severe;
1290 struct ReporterDescription;
1291 struct ListenerDescription;
1293 struct TestCaseInfo;
1294 class TestCaseHandle;
1297 enum class ColourMode : std::uint8_t;
1303 std::map<std::string, std::string> customOptions );
1310 IConfig const* fullConfig()
const;
1312 std::map<std::string, std::string>
const& customOptions()
const;
1318 std::map<std::string, std::string> m_customOptions;
1328 std::vector<MessageInfo>
const& _infoMessages,
1337 std::vector<MessageInfo> infoMessages;
1343 Counts const& _assertions,
1344 double _durationInSeconds,
1345 bool _missingAssertions );
1349 double durationInSeconds;
1350 bool missingAssertions;
1356 std::string
const& _stdOut,
1357 std::string
const& _stdErr,
1380 double estimatedDuration;
1382 unsigned int samples;
1383 unsigned int resamples;
1384 double clockResolution;
1388 template <
class Duration>
1392 std::vector<Duration> samples;
1396 double outlierVariance;
1398 template <
typename Duration2>
1400 std::vector<Duration2> samples2;
1401 samples2.reserve(samples.size());
1402 for (
auto const& sample : samples) {
1403 samples2.push_back(Duration2(sample));
1513 virtual void listReporters(std::vector<ReporterDescription>
const& descriptions) = 0;
1515 virtual void listListeners(std::vector<ListenerDescription>
const& descriptions) = 0;
1517 virtual void listTests(std::vector<TestCaseHandle>
const& tests) = 0;
1519 virtual void listTags(std::vector<TagInfo>
const& tags) = 0;
1528 #ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED
1529 #define CATCH_UNIQUE_NAME_HPP_INCLUDED
1543 #ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED
1544 #define CATCH_CONFIG_COUNTER_HPP_INCLUDED
1546 #if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
1547 #define CATCH_INTERNAL_CONFIG_COUNTER
1550 #if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \
1551 !defined( CATCH_CONFIG_NO_COUNTER ) && \
1552 !defined( CATCH_CONFIG_COUNTER )
1553 # define CATCH_CONFIG_COUNTER
1558 #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
1559 #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
1560 #ifdef CATCH_CONFIG_COUNTER
1561 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
1563 # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
1571 #ifndef CATCH_CHRONOMETER_HPP_INCLUDED
1572 #define CATCH_CHRONOMETER_HPP_INCLUDED
1578 #ifndef CATCH_CLOCK_HPP_INCLUDED
1579 #define CATCH_CLOCK_HPP_INCLUDED
1585 namespace Benchmark {
1586 template <
typename Clock>
1587 using ClockDuration =
typename Clock::duration;
1588 template <
typename Clock>
1589 using FloatDuration = std::chrono::duration<double, typename Clock::period>;
1591 template <
typename Clock>
1592 using TimePoint =
typename Clock::time_point;
1594 using default_clock = std::chrono::steady_clock;
1596 template <
typename Clock>
1598 TimePoint<Clock> operator()()
const {
1599 return Clock::now();
1603 using fp_seconds = std::chrono::duration<double, std::ratio<1>>;
1612 #ifndef CATCH_OPTIMIZER_HPP_INCLUDED
1613 #define CATCH_OPTIMIZER_HPP_INCLUDED
1615 #if defined(_MSC_VER)
1620 #include <type_traits>
1623 namespace Benchmark {
1624 #if defined(__GNUC__) || defined(__clang__)
1625 template <
typename T>
1626 inline void keep_memory(T* p) {
1627 asm volatile(
"" : :
"g"(p) :
"memory");
1629 inline void keep_memory() {
1630 asm volatile(
"" : : :
"memory");
1634 inline void optimizer_barrier() { keep_memory(); }
1636 #elif defined(_MSC_VER)
1638 #pragma optimize("", off)
1639 template <
typename T>
1640 inline void keep_memory(T* p) {
1642 *
reinterpret_cast<char volatile*
>(p) = *
reinterpret_cast<char const volatile*
>(p);
1645 #pragma optimize("", on)
1648 inline void optimizer_barrier() {
1649 std::atomic_thread_fence(std::memory_order_seq_cst);
1655 template <
typename T>
1656 inline void deoptimize_value(T&& x) {
1660 template <
typename Fn,
typename... Args>
1661 inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<!std::is_same<void, decltype(fn(args...))>::value> {
1665 template <
typename Fn,
typename... Args>
1666 inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<std::is_same<void, decltype(fn(args...))>::value> {
1677 #ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED
1678 #define CATCH_COMPLETE_INVOKE_HPP_INCLUDED
1682 #ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
1683 #define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
1695 #ifndef CATCH_META_HPP_INCLUDED
1696 #define CATCH_META_HPP_INCLUDED
1698 #include <type_traits>
1701 template<
typename T>
1706 template <
typename Fun,
typename... Args>
1708 template <
typename...>
1709 std::false_type
static test(...);
1712 template <
typename T>
1715 template <
typename Fun,
typename... Args>
1716 struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {};
1719 #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
1722 template <
typename Func,
typename... U>
1723 using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>;
1725 template <
typename Func,
typename... U>
1726 using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::result_of_t<Func(U...)>>>;
1738 #ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
1739 #define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
1746 class TestCaseHandle;
1747 struct TestCaseInfo;
1748 class ITestCaseRegistry;
1749 class IExceptionTranslatorRegistry;
1750 class IExceptionTranslator;
1751 class IReporterRegistry;
1752 class IReporterFactory;
1753 class ITagAliasRegistry;
1755 class IMutableEnumValuesRegistry;
1756 struct SourceLineInfo;
1758 class StartupExceptionRegistry;
1759 class EventListenerFactory;
1761 using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
1779 virtual void registerReporter( std::string
const& name,
IReporterFactoryPtr factory ) = 0;
1783 virtual void registerTagAlias( std::string
const& alias, std::string
const& tag,
SourceLineInfo const& lineInfo ) = 0;
1784 virtual void registerStartupException() noexcept = 0;
1791 std::string translateActiveException();
1797 #include <type_traits>
1800 namespace Benchmark {
1802 template <
typename T>
1807 template <
typename T>
1808 using CompleteType_t =
typename CompleteType<T>::type;
1810 template <
typename Result>
1812 template <
typename Fun,
typename... Args>
1813 static Result invoke(Fun&& fun, Args&&... args) {
1819 template <
typename Fun,
typename... Args>
1820 static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) {
1827 template <
typename Fun,
typename... Args>
1828 CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
1834 template <
typename Fun>
1835 Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
1844 namespace Benchmark {
1847 virtual void start() = 0;
1848 virtual void finish() = 0;
1855 template <
typename Clock>
1857 void start()
override { started = Clock::now(); }
1858 void finish()
override { finished = Clock::now(); }
1860 ClockDuration<Clock> elapsed()
const {
return finished - started; }
1862 TimePoint<Clock> started;
1863 TimePoint<Clock> finished;
1869 template <
typename Fun>
1872 int runs()
const {
return repeats; }
1876 , repeats(repeats_) {}
1879 template <
typename Fun>
1880 void measure(Fun&& fun, std::false_type) {
1881 measure([&fun](
int) {
return fun(); }, std::true_type());
1884 template <
typename Fun>
1885 void measure(Fun&& fun, std::true_type) {
1886 Detail::optimizer_barrier();
1888 for (
int i = 0; i < repeats; ++i) invoke_deoptimized(fun, i);
1890 Detail::optimizer_barrier();
1904 #ifndef CATCH_ENVIRONMENT_HPP_INCLUDED
1905 #define CATCH_ENVIRONMENT_HPP_INCLUDED
1909 namespace Benchmark {
1910 template <
typename Duration>
1915 template <
typename Duration2>
1917 return { mean, outliers };
1920 template <
typename Clock>
1922 using clock_type = Clock;
1934 #ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED
1935 #define CATCH_EXECUTION_PLAN_HPP_INCLUDED
1941 #ifndef CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED
1942 #define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED
1945 #include <type_traits>
1948 namespace Benchmark {
1950 template <
typename T,
typename U>
1952 : std::is_same<std::decay_t<T>, std::decay_t<U>> {};
1966 virtual ~callable();
1968 callable() =
default;
1969 callable(callable
const&) =
default;
1970 callable& operator=(callable
const&) =
default;
1972 template <
typename Fun>
1973 struct model :
public callable {
1975 model(Fun
const& fun_) : fun(fun_) {}
1978 return Catch::Detail::make_unique<model<Fun>>( *this );
1984 void call(
Chronometer meter, std::true_type)
const {
1987 void call(
Chronometer meter, std::false_type)
const {
1994 struct do_nothing {
void operator()()
const {} };
1996 template <
typename T>
2001 : f(
new model<do_nothing>{ {} }) {}
2003 template <
typename Fun,
2004 std::enable_if_t<!is_related<Fun, BenchmarkFunction>::value,
int> = 0>
2012 : f(that.f->clone()) {}
2021 f = that.f->clone();
2025 void operator()(
Chronometer meter)
const { f->call(meter); }
2039 #ifndef CATCH_REPEAT_HPP_INCLUDED
2040 #define CATCH_REPEAT_HPP_INCLUDED
2042 #include <type_traits>
2045 namespace Benchmark {
2047 template <
typename Fun>
2049 void operator()(
int k)
const {
2050 for (
int i = 0; i < k; ++i) {
2056 template <
typename Fun>
2069 #ifndef CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED
2070 #define CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED
2076 #ifndef CATCH_MEASURE_HPP_INCLUDED
2077 #define CATCH_MEASURE_HPP_INCLUDED
2083 #ifndef CATCH_TIMING_HPP_INCLUDED
2084 #define CATCH_TIMING_HPP_INCLUDED
2087 #include <type_traits>
2090 namespace Benchmark {
2091 template <
typename Duration,
typename Result>
2097 template <
typename Clock,
typename Func,
typename... Args>
2105 namespace Benchmark {
2107 template <
typename Clock,
typename Fun,
typename... Args>
2108 TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
2109 auto start = Clock::now();
2110 auto&& r = Detail::complete_invoke(fun,
CATCH_FORWARD(args)...);
2111 auto end = Clock::now();
2112 auto delta = end - start;
2121 #include <type_traits>
2124 namespace Benchmark {
2126 template <
typename Clock,
typename Fun>
2127 TimingOf<Clock, Fun, int> measure_one(Fun&& fun,
int iters, std::false_type) {
2128 return Detail::measure<Clock>(fun, iters);
2130 template <
typename Clock,
typename Fun>
2131 TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun,
int iters, std::true_type) {
2132 Detail::ChronometerModel<Clock> meter;
2133 auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
2135 return { meter.elapsed(),
CATCH_MOVE(result), iters };
2138 template <
typename Clock,
typename Fun>
2143 void throw_optimized_away_error();
2145 template <
typename Clock,
typename Fun>
2146 TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>>
2147 run_for_at_least(ClockDuration<Clock> how_long,
2148 const int initial_iterations,
2150 auto iters = initial_iterations;
2151 while (iters < (1 << 30)) {
2152 auto&& Timing = measure_one<Clock>(fun, iters,
is_callable<Fun(Chronometer)>());
2154 if (Timing.elapsed >= how_long) {
2155 return { Timing.elapsed,
CATCH_MOVE(Timing.result), iters };
2159 throw_optimized_away_error();
2167 #include <algorithm>
2171 namespace Benchmark {
2172 template <
typename Duration>
2174 int iterations_per_sample;
2175 Duration estimated_duration;
2177 Duration warmup_time;
2178 int warmup_iterations;
2180 template <
typename Duration2>
2182 return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations };
2185 template <
typename Clock>
2186 std::vector<FloatDuration<Clock>> run(
const IConfig &cfg,
Environment<FloatDuration<Clock>> env)
const {
2188 Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(
now<Clock>{}));
2190 std::vector<FloatDuration<Clock>> times;
2191 times.reserve(cfg.benchmarkSamples());
2192 std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [
this, env] {
2193 Detail::ChronometerModel<Clock> model;
2194 this->benchmark(Chronometer(model, iterations_per_sample));
2195 auto sample_time = model.elapsed() - env.clock_cost.mean;
2196 if (sample_time < FloatDuration<Clock>::zero()) sample_time = FloatDuration<Clock>::zero();
2197 return sample_time / iterations_per_sample;
2210 #ifndef CATCH_ESTIMATE_CLOCK_HPP_INCLUDED
2211 #define CATCH_ESTIMATE_CLOCK_HPP_INCLUDED
2217 #ifndef CATCH_STATS_HPP_INCLUDED
2218 #define CATCH_STATS_HPP_INCLUDED
2221 #include <algorithm>
2228 namespace Benchmark {
2230 using sample = std::vector<double>;
2234 bool directCompare(
double lhs,
double rhs );
2236 double weighted_average_quantile(
int k,
int q, std::vector<double>::iterator
first, std::vector<double>::iterator last);
2238 template <
typename Iterator>
2239 OutlierClassification classify_outliers(Iterator
first, Iterator last) {
2240 std::vector<double> copy(
first, last);
2242 auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end());
2243 auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end());
2245 auto los = q1 - (iqr * 3.);
2246 auto lom = q1 - (iqr * 1.5);
2247 auto him = q3 + (iqr * 1.5);
2248 auto his = q3 + (iqr * 3.);
2250 OutlierClassification o;
2253 if (t < los) ++o.low_severe;
2254 else if (t < lom) ++o.low_mild;
2255 else if (t > his) ++o.high_severe;
2256 else if (t > him) ++o.high_mild;
2262 template <
typename Iterator>
2263 double mean(Iterator
first, Iterator last) {
2266 return sum /
static_cast<double>(
count);
2269 template <
typename Estimator,
typename Iterator>
2270 sample jackknife(Estimator&& estimator, Iterator
first, Iterator last) {
2271 auto n =
static_cast<size_t>(last -
first);
2277 for (
auto it =
first; it != last; ++it) {
2278 std::iter_swap(it,
first);
2279 results.push_back(estimator(
second, last));
2285 inline double normal_cdf(
double x) {
2286 return std::erfc(-x / std::sqrt(2.0)) / 2.0;
2289 double erfc_inv(
double x);
2291 double normal_quantile(
double p);
2293 template <
typename Iterator,
typename Estimator>
2294 Estimate<double> bootstrap(
double confidence_level, Iterator
first, Iterator last, sample
const& resample, Estimator&& estimator) {
2295 auto n_samples = last -
first;
2297 double point = estimator(
first, last);
2299 if (n_samples == 1)
return { point, point, point, confidence_level };
2301 sample jack = jackknife(estimator,
first, last);
2302 double jack_mean = mean(jack.begin(), jack.end());
2303 double sum_squares, sum_cubes;
2304 std::tie(sum_squares, sum_cubes) =
std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair<double, double> sqcb,
double x) -> std::pair<double, double> {
2305 auto d = jack_mean - x;
2308 return { sqcb.first + d2, sqcb.second + d3 };
2311 double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5));
2312 long n =
static_cast<long>(resample.size());
2313 double prob_n =
std::count_if(resample.begin(), resample.end(), [point](
double x) { return x < point; }) /
static_cast<double>(n);
2315 if ( directCompare( prob_n, 0. ) ) {
2316 return { point, point, point, confidence_level };
2319 double bias = normal_quantile(prob_n);
2320 double z1 = normal_quantile((1. - confidence_level) / 2.);
2322 auto cumn = [n](
double x ) ->
long {
2323 return std::lround( normal_cdf( x ) * n );
2325 auto a = [bias, accel](
double b) {
return bias + b / (1. - accel * b); };
2326 double b1 = bias + z1;
2327 double b2 = bias - z1;
2330 auto lo =
static_cast<size_t>((std::max)(cumn(a1), 0l));
2331 auto hi =
static_cast<size_t>((std::min)(cumn(a2), n - 1));
2333 return { point, resample[lo], resample[hi], confidence_level };
2336 double outlier_variance(Estimate<double> mean, Estimate<double> stddev,
int n);
2341 double outlier_variance;
2344 bootstrap_analysis analyse_samples(
double confidence_level,
unsigned int n_resamples, std::vector<double>::iterator
first, std::vector<double>::iterator last);
2351 #include <algorithm>
2357 namespace Benchmark {
2359 template <
typename Clock>
2360 std::vector<double> resolution(
int k) {
2361 std::vector<TimePoint<Clock>> times;
2362 times.reserve(
static_cast<size_t>(k + 1));
2363 std::generate_n(std::back_inserter(times), k + 1, now<Clock>{});
2365 std::vector<double> deltas;
2366 deltas.reserve(
static_cast<size_t>(k));
2367 std::transform(std::next(times.begin()), times.end(), times.begin(),
2368 std::back_inserter(deltas),
2369 [](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); });
2374 const auto warmup_iterations = 10000;
2375 const auto warmup_time = std::chrono::milliseconds(100);
2376 const auto minimum_ticks = 1000;
2377 const auto warmup_seed = 10000;
2378 const auto clock_resolution_estimation_time = std::chrono::milliseconds(500);
2379 const auto clock_cost_estimation_time_limit = std::chrono::seconds(1);
2380 const auto clock_cost_estimation_tick_limit = 100000;
2381 const auto clock_cost_estimation_time = std::chrono::milliseconds(10);
2382 const auto clock_cost_estimation_iterations = 10000;
2384 template <
typename Clock>
2386 return run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_seed, &resolution<Clock>)
2389 template <
typename Clock>
2390 EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_resolution(
int iterations) {
2391 auto r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_resolution_estimation_time), iterations, &resolution<Clock>)
2394 FloatDuration<Clock>(mean(r.begin(), r.end())),
2395 classify_outliers(r.begin(), r.end()),
2398 template <
typename Clock>
2399 EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) {
2400 auto time_limit = (std::min)(
2401 resolution * clock_cost_estimation_tick_limit,
2402 FloatDuration<Clock>(clock_cost_estimation_time_limit));
2403 auto time_clock = [](
int k) {
2404 return Detail::measure<Clock>([k] {
2405 for (
int i = 0; i < k; ++i) {
2406 volatile auto ignored = Clock::now();
2412 int iters = clock_cost_estimation_iterations;
2413 auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_cost_estimation_time), iters, time_clock);
2414 std::vector<double> times;
2415 int nsamples =
static_cast<int>(std::ceil(time_limit / r.elapsed));
2416 times.reserve(
static_cast<size_t>(nsamples));
2417 std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] {
2418 return static_cast<double>((time_clock(r.iterations) / r.iterations).
count());
2421 FloatDuration<Clock>(mean(times.begin(), times.end())),
2422 classify_outliers(times.begin(), times.end()),
2426 template <
typename Clock>
2427 Environment<FloatDuration<Clock>> measure_environment() {
2428 #if defined(__clang__)
2429 # pragma clang diagnostic push
2430 # pragma clang diagnostic ignored "-Wexit-time-destructors"
2433 #if defined(__clang__)
2434 # pragma clang diagnostic pop
2440 auto iters = Detail::warmup<Clock>();
2441 auto resolution = Detail::estimate_clock_resolution<Clock>(iters);
2442 auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean);
2444 env = Catch::Detail::make_unique<Environment<FloatDuration<Clock>>>( Environment<FloatDuration<Clock>>{resolution, cost} );
2456 #ifndef CATCH_ANALYSE_HPP_INCLUDED
2457 #define CATCH_ANALYSE_HPP_INCLUDED
2463 #ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
2464 #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
2467 #include <algorithm>
2472 namespace Benchmark {
2473 template <
typename Duration>
2475 std::vector<Duration> samples;
2479 double outlier_variance;
2481 template <
typename Duration2>
2483 std::vector<Duration2> samples2;
2484 samples2.reserve(samples.size());
2485 std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
2500 #include <algorithm>
2505 namespace Benchmark {
2507 template <
typename Duration,
typename Iterator>
2508 SampleAnalysis<Duration> analyse(
const IConfig &cfg, Environment<Duration>, Iterator
first, Iterator last) {
2509 if (!cfg.benchmarkNoAnalysis()) {
2510 std::vector<double> samples;
2511 samples.reserve(
static_cast<size_t>(last -
first));
2512 std::transform(
first, last, std::back_inserter(samples), [](Duration d) {
return d.count(); });
2514 auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end());
2515 auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end());
2517 auto wrap_estimate = [](Estimate<double> e) {
2518 return Estimate<Duration> {
2520 Duration(e.lower_bound),
2521 Duration(e.upper_bound),
2522 e.confidence_interval,
2525 std::vector<Duration> samples2;
2526 samples2.reserve(samples.size());
2527 std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](
double d) { return Duration(d); });
2530 wrap_estimate(analysis.mean),
2531 wrap_estimate(analysis.standard_deviation),
2533 analysis.outlier_variance,
2536 std::vector<Duration> samples;
2537 samples.reserve(
static_cast<size_t>(last -
first));
2539 Duration mean = Duration(0);
2541 for (
auto it =
first; it < last; ++it, ++i) {
2542 samples.push_back(Duration(*it));
2543 mean += Duration(*it);
2549 Estimate<Duration>{mean, mean, mean, 0.0},
2550 Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0},
2551 OutlierClassification{},
2562 #include <algorithm>
2563 #include <functional>
2569 namespace Benchmark {
2574 template <
class FUN>
2575 Benchmark(std::string&& benchmarkName , FUN &&func)
2578 template <
typename Clock>
2580 auto min_time = env.clock_resolution.mean * Detail::minimum_ticks;
2581 auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime()));
2582 auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(run_time), 1, fun);
2583 int new_iters =
static_cast<int>(std::ceil(min_time * test.iterations / test.elapsed));
2584 return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations };
2587 template <
typename Clock = default_clock>
2589 auto const* cfg = getCurrentContext().getConfig();
2591 auto env = Detail::measure_environment<Clock>();
2593 getResultCapture().benchmarkPreparing(name);
2595 auto plan = user_code([&] {
2596 return prepare<Clock>(*cfg, env);
2601 plan.estimated_duration.count(),
2602 plan.iterations_per_sample,
2603 cfg->benchmarkSamples(),
2604 cfg->benchmarkResamples(),
2605 env.clock_resolution.mean.count(),
2606 env.clock_cost.mean.count()
2609 getResultCapture().benchmarkStarting(info);
2611 auto samples = user_code([&] {
2612 return plan.template run<Clock>(*cfg, env);
2615 auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
2617 getResultCapture().benchmarkEnded(stats);
2619 getResultCapture().benchmarkFailed(
"Benchmark failed due to failed assertion"_sr);
2621 getResultCapture().benchmarkFailed(translateActiveException());
2624 std::rethrow_exception(std::current_exception());
2629 template <typename Fun, std::enable_if_t<!Detail::is_related<Fun, Benchmark>::value,
int> = 0>
2631 auto const* cfg = getCurrentContext().getConfig();
2632 if (!cfg->skipBenchmarks()) {
2639 explicit operator bool() {
2650 #define INTERNAL_CATCH_GET_1_ARG(arg1, arg2, ...) arg1
2651 #define INTERNAL_CATCH_GET_2_ARG(arg1, arg2, ...) arg2
2653 #define INTERNAL_CATCH_BENCHMARK(BenchmarkName, name, benchmarkIndex)\
2654 if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \
2655 BenchmarkName = [&](int benchmarkIndex)
2657 #define INTERNAL_CATCH_BENCHMARK_ADVANCED(BenchmarkName, name)\
2658 if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \
2661 #if defined(CATCH_CONFIG_PREFIX_ALL)
2663 #define CATCH_BENCHMARK(...) \
2664 INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,))
2665 #define CATCH_BENCHMARK_ADVANCED(name) \
2666 INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), name)
2670 #define BENCHMARK(...) \
2671 INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,))
2672 #define BENCHMARK_ADVANCED(name) \
2673 INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(CATCH2_INTERNAL_BENCHMARK_), name)
2682 #ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED
2683 #define CATCH_CONSTRUCTOR_HPP_INCLUDED
2686 #include <type_traits>
2689 namespace Benchmark {
2691 template <
typename T,
bool Destruct>
2698 new(&data) T(other.stored_object());
2703 new(data) T(
CATCH_MOVE(other.stored_object()));
2708 template <
typename... Args>
2709 void construct(Args&&... args)
2714 template <
bool AllowManualDestruction = !Destruct>
2715 std::enable_if_t<AllowManualDestruction> destruct()
2717 stored_object().~T();
2722 template <
typename U>
2723 void destruct_on_exit(std::enable_if_t<Destruct, U>* =
nullptr) { destruct<true>(); }
2725 template <
typename U>
2726 void destruct_on_exit(std::enable_if_t<!Destruct, U>* =
nullptr) { }
2728 T& stored_object() {
2729 return *
static_cast<T*
>(
static_cast<void*
>(data));
2732 T
const& stored_object()
const {
2733 return *
static_cast<T*
>(
static_cast<void*
>(data));
2737 alignas( T )
unsigned char data[
sizeof( T )]{};
2741 template <
typename T>
2744 template <
typename T>
2754 #ifndef CATCH_APPROX_HPP_INCLUDED
2755 #define CATCH_APPROX_HPP_INCLUDED
2759 #ifndef CATCH_TOSTRING_HPP_INCLUDED
2760 #define CATCH_TOSTRING_HPP_INCLUDED
2765 #include <type_traits>
2780 #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED
2781 #define CATCH_CONFIG_WCHAR_HPP_INCLUDED
2786 #if defined(__DJGPP__)
2787 # define CATCH_INTERNAL_CONFIG_NO_WCHAR
2790 #if !defined( CATCH_INTERNAL_CONFIG_NO_WCHAR ) && \
2791 !defined( CATCH_CONFIG_NO_WCHAR ) && \
2792 !defined( CATCH_CONFIG_WCHAR )
2793 # define CATCH_CONFIG_WCHAR
2799 #ifndef CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
2800 #define CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
2812 std::ostream* m_oss;
2818 std::string
str()
const;
2820 void str(std::string
const&
str);
2822 #if defined(__GNUC__) && !defined(__clang__)
2823 #pragma GCC diagnostic push
2825 #pragma GCC diagnostic ignored "-Wpragmas"
2830 #pragma GCC diagnostic ignored "-Waddress"
2831 #pragma GCC diagnostic ignored "-Wnonnull-compare"
2834 template<
typename T>
2840 #if defined(__GNUC__) && !defined(__clang__)
2841 #pragma GCC diagnostic pop
2843 auto get() -> std::ostream& {
return *m_oss; }
2850 #ifndef CATCH_VOID_TYPE_HPP_INCLUDED
2851 #define CATCH_VOID_TYPE_HPP_INCLUDED
2857 template <
typename...>
2860 template <
typename... Ts>
2861 using void_t =
typename make_void<Ts...>::type;
2870 #ifndef CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED
2871 #define CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED
2881 std::vector<std::pair<int, StringRef>> m_values;
2895 template<
typename E>
2897 static_assert(
sizeof(
int) >=
sizeof(E),
"Cannot serialize enum to int");
2898 std::vector<int> intValues;
2899 intValues.reserve( values.size() );
2900 for(
auto enumValue : values )
2901 intValues.push_back(
static_cast<int>( enumValue ) );
2902 return registerEnum( enumName, allEnums, intValues );
2910 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
2911 #include <string_view>
2915 #pragma warning(push)
2916 #pragma warning(disable:4180)
2931 constexpr StringRef unprintableString =
"{?}"_sr;
2934 std::string convertIntoString( StringRef
string,
bool escapeInvisibles );
2938 std::string convertIntoString( StringRef
string );
2940 std::string rawMemoryToString(
const void *
object,
std::size_t size );
2942 template<
typename T>
2943 std::string rawMemoryToString(
const T&
object ) {
2944 return rawMemoryToString( &
object,
sizeof(
object) );
2947 template<
typename T>
2949 template<
typename Stream,
typename U>
2950 static auto test(
int)
2951 -> decltype(std::declval<Stream&>() << std::declval<U>(), std::true_type());
2953 template<
typename,
typename>
2954 static auto test(...)->std::false_type;
2957 static const bool value = decltype(test<std::ostream, const T&>(0))::value;
2960 template<
typename E>
2961 std::string convertUnknownEnumToString( E e );
2963 template<
typename T>
2965 !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,
2966 std::string> convertUnstreamable( T
const& ) {
2967 return std::string(Detail::unprintableString);
2969 template<
typename T>
2971 !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value,
2972 std::string> convertUnstreamable(T
const& ex) {
2977 template<
typename T>
2979 std::is_enum<T>::value,
2980 std::string> convertUnstreamable( T
const& value ) {
2981 return convertUnknownEnumToString( value );
2984 #if defined(_MANAGED)
2986 template<
typename T>
2987 std::string clrReferenceToString( T^ ref ) {
2989 return std::string(
"null");
2990 auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString());
2991 cli::pin_ptr<System::Byte> p = &bytes[0];
2992 return std::string(
reinterpret_cast<char const *
>(p), bytes->Length);
3000 template <
typename T,
typename =
void>
3002 template <
typename Fake = T>
3004 std::enable_if_t<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>
3005 convert(
const Fake& value) {
3009 rss.operator<<(value);
3013 template <
typename Fake = T>
3015 std::enable_if_t<!::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>
3016 convert(
const Fake& value ) {
3017 #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)
3018 return Detail::convertUnstreamable(value);
3020 return CATCH_CONFIG_FALLBACK_STRINGIFIER(value);
3029 template <
typename T>
3030 std::string stringify(
const T& e) {
3031 return ::Catch::StringMaker<std::remove_cv_t<std::remove_reference_t<T>>>::convert(e);
3034 template<
typename E>
3035 std::string convertUnknownEnumToString( E e ) {
3036 return ::Catch::Detail::stringify(
static_cast<std::underlying_type_t<E>
>(e));
3039 #if defined(_MANAGED)
3040 template <
typename T>
3041 std::string stringify( T^ e ) {
3042 return ::Catch::StringMaker<T^>::convert(e);
3052 static std::string convert(
const std::string& str);
3055 #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
3058 static std::string convert(std::string_view str);
3064 static std::string convert(
char const * str);
3068 static std::string convert(
char * str);
3071 #if defined(CATCH_CONFIG_WCHAR)
3074 static std::string convert(
const std::wstring& wstr);
3077 # ifdef CATCH_CONFIG_CPP17_STRING_VIEW
3080 static std::string convert(std::wstring_view str);
3086 static std::string convert(
wchar_t const * str);
3090 static std::string convert(
wchar_t * str);
3096 static std::string convert(
char const* str) {
3099 return Detail::convertIntoString(
3105 static std::string convert(
signed char const* str) {
3107 auto reinterpreted =
reinterpret_cast<char const*
>(str);
3108 return Detail::convertIntoString(
3109 StringRef(reinterpreted, strnlen(reinterpreted, SZ)));
3114 static std::string convert(
unsigned char const* str) {
3116 auto reinterpreted =
reinterpret_cast<char const*
>(str);
3117 return Detail::convertIntoString(
3118 StringRef(reinterpreted, strnlen(reinterpreted, SZ)));
3122 #if defined(CATCH_CONFIG_CPP17_BYTE)
3125 static std::string convert(std::byte value);
3130 static std::string convert(
int value);
3134 static std::string convert(
long value);
3138 static std::string convert(
long long value);
3142 static std::string convert(
unsigned int value);
3146 static std::string convert(
unsigned long value);
3150 static std::string convert(
unsigned long long value);
3155 static std::string convert(
bool b) {
3156 using namespace std::string_literals;
3157 return b ?
"true"s :
"false"s;
3163 static std::string convert(
char c);
3167 static std::string convert(
signed char c);
3171 static std::string convert(
unsigned char c);
3176 static std::string convert(std::nullptr_t) {
3177 using namespace std::string_literals;
3184 static std::string convert(
float value);
3185 static int precision;
3190 static std::string convert(
double value);
3191 static int precision;
3194 template <
typename T>
3196 template <
typename U>
3197 static std::string convert(U* p) {
3199 return ::Catch::Detail::rawMemoryToString(p);
3206 template <
typename R,
typename C>
3208 static std::string convert(R C::* p) {
3210 return ::Catch::Detail::rawMemoryToString(p);
3217 #if defined(_MANAGED)
3218 template <
typename T>
3220 static std::string convert( T^ ref ) {
3221 return ::Catch::Detail::clrReferenceToString(ref);
3227 template<
typename InputIterator,
typename Sentinel = InputIterator>
3228 std::string rangeToString(InputIterator
first, Sentinel last) {
3229 ReusableStringStream rss;
3231 if (
first != last) {
3232 rss << ::Catch::Detail::stringify(*
first);
3234 rss <<
", " << ::Catch::Detail::stringify(*
first);
3247 #if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
3248 # define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
3249 # define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
3250 # define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
3251 # define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
3255 #if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER)
3258 template<
typename T1,
typename T2>
3259 struct StringMaker<std::
pair<T1, T2> > {
3260 static std::string convert(
const std::pair<T1, T2>&
pair) {
3261 ReusableStringStream rss;
3263 << ::Catch::Detail::stringify(
pair.first)
3265 << ::Catch::Detail::stringify(
pair.second)
3273 #if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL)
3276 template<
typename T>
3277 struct StringMaker<std::optional<T> > {
3278 static std::string convert(
const std::optional<T>& optional) {
3279 if (optional.has_value()) {
3280 return ::Catch::Detail::stringify(*optional);
3290 #if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER)
3297 bool = (N < std::tuple_size<Tuple>::value)
3299 struct TupleElementPrinter {
3300 static void print(
const Tuple& tuple, std::ostream& os) {
3301 os << (N ?
", " :
" ")
3302 << ::Catch::Detail::stringify(std::get<N>(tuple));
3303 TupleElementPrinter<Tuple, N + 1>::print(tuple, os);
3311 struct TupleElementPrinter<Tuple, N, false> {
3312 static void print(
const Tuple&, std::ostream&) {}
3318 template<
typename ...Types>
3319 struct StringMaker<std::tuple<Types...>> {
3320 static std::string convert(
const std::tuple<Types...>& tuple) {
3321 ReusableStringStream rss;
3323 Detail::TupleElementPrinter<std::tuple<Types...>>::print(tuple, rss.get());
3331 #if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
3335 struct StringMaker<std::monostate> {
3336 static std::string convert(
const std::monostate&) {
3341 template<
typename... Elements>
3342 struct StringMaker<std::variant<Elements...>> {
3343 static std::string convert(
const std::variant<Elements...>& variant) {
3344 if (variant.valueless_by_exception()) {
3345 return "{valueless variant}";
3348 [](
const auto& value) {
3349 return ::Catch::Detail::stringify(value);
3365 template <
typename T,
typename =
void>
3368 template <
typename T>
3369 struct is_range_impl<T, void_t<decltype(begin(std::declval<T>()))>> : std::true_type {};
3372 template <
typename T>
3375 #if defined(_MANAGED)
3376 template <
typename T>
3378 static const bool value =
false;
3382 template<
typename Range>
3383 std::string rangeToString( Range
const& range ) {
3384 return ::Catch::Detail::rangeToString( begin( range ), end( range ) );
3388 template<
typename Allocator>
3389 std::string rangeToString( std::vector<bool, Allocator>
const& v ) {
3390 ReusableStringStream rss;
3398 rss << ::Catch::Detail::stringify( b );
3404 template<
typename R>
3405 struct StringMaker<R, std::enable_if_t<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>> {
3406 static std::string convert( R
const& range ) {
3407 return rangeToString( range );
3411 template <
typename T,
size_t SZ>
3413 static std::string convert(T
const(&arr)[SZ]) {
3414 return rangeToString(arr);
3429 template <
class Ratio>
3431 static std::string symbol() {
3433 rss <<
'[' << Ratio::num <<
'/'
3434 << Ratio::den <<
']';
3441 static char symbol() {
return 'a'; }
3445 static char symbol() {
return 'f'; }
3449 static char symbol() {
return 'p'; }
3453 static char symbol() {
return 'n'; }
3457 static char symbol() {
return 'u'; }
3461 static char symbol() {
return 'm'; }
3466 template<
typename Value,
typename Ratio>
3468 static std::string convert(std::chrono::duration<Value, Ratio>
const& duration) {
3474 template<
typename Value>
3476 static std::string convert(std::chrono::duration<Value, std::ratio<1>>
const& duration) {
3478 rss << duration.count() <<
" s";
3482 template<
typename Value>
3484 static std::string convert(std::chrono::duration<Value, std::ratio<60>>
const& duration) {
3486 rss << duration.count() <<
" m";
3490 template<
typename Value>
3492 static std::string convert(std::chrono::duration<Value, std::ratio<3600>>
const& duration) {
3494 rss << duration.count() <<
" h";
3502 template<
typename Clock,
typename Duration>
3504 static std::string convert(std::chrono::time_point<Clock, Duration>
const& time_point) {
3505 return ::Catch::Detail::stringify(time_point.time_since_epoch()) +
" since epoch";
3509 template<
typename Duration>
3510 struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> {
3511 static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration>
const& time_point) {
3512 auto converted = std::chrono::system_clock::to_time_t(time_point);
3515 std::tm timeInfo = {};
3516 gmtime_s(&timeInfo, &converted);
3518 std::tm* timeInfo = std::gmtime(&converted);
3521 auto const timeStampSize =
sizeof(
"2017-01-16T17:06:45Z");
3522 char timeStamp[timeStampSize];
3523 const char *
const fmt =
"%Y-%m-%dT%H:%M:%SZ";
3526 std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
3528 std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
3530 return std::string(timeStamp, timeStampSize - 1);
3536 #define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
3538 template<> struct StringMaker<enumName> { \
3539 static std::string convert( enumName value ) { \
3540 static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \
3541 return static_cast<std::string>(enumInfo.lookup( static_cast<int>( value ) )); \
3546 #define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ )
3549 #pragma warning(pop)
3554 #include <type_traits>
3560 bool equalityComparisonImpl(
double other)
const;
3562 void setMargin(
double margin);
3564 void setEpsilon(
double epsilon);
3567 explicit Approx (
double value );
3571 Approx operator-()
const;
3573 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3574 Approx operator()( T
const& value )
const {
3575 Approx approx(
static_cast<double>(value) );
3576 approx.m_epsilon = m_epsilon;
3577 approx.m_margin = m_margin;
3578 approx.m_scale = m_scale;
3582 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3583 explicit Approx( T
const& value ):
Approx(
static_cast<double>(value))
3587 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3588 friend bool operator == (
const T& lhs,
Approx const& rhs ) {
3589 auto lhs_v =
static_cast<double>(lhs);
3590 return rhs.equalityComparisonImpl(lhs_v);
3593 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3594 friend bool operator == (
Approx const& lhs,
const T& rhs ) {
3595 return operator==( rhs, lhs );
3598 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3599 friend bool operator != ( T
const& lhs,
Approx const& rhs ) {
3600 return !operator==( lhs, rhs );
3603 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3604 friend bool operator != (
Approx const& lhs, T
const& rhs ) {
3605 return !operator==( rhs, lhs );
3608 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3609 friend bool operator <= ( T
const& lhs,
Approx const& rhs ) {
3610 return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;
3613 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3614 friend bool operator <= (
Approx const& lhs, T
const& rhs ) {
3615 return lhs.m_value <
static_cast<double>(rhs) || lhs == rhs;
3618 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3619 friend bool operator >= ( T
const& lhs,
Approx const& rhs ) {
3620 return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;
3623 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3624 friend bool operator >= (
Approx const& lhs, T
const& rhs ) {
3625 return lhs.m_value >
static_cast<double>(rhs) || lhs == rhs;
3628 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3629 Approx& epsilon( T
const& newEpsilon ) {
3630 const auto epsilonAsDouble =
static_cast<double>(newEpsilon);
3631 setEpsilon(epsilonAsDouble);
3635 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3636 Approx& margin( T
const& newMargin ) {
3637 const auto marginAsDouble =
static_cast<double>(newMargin);
3638 setMargin(marginAsDouble);
3642 template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
3643 Approx& scale( T
const& newScale ) {
3644 m_scale =
static_cast<double>(newScale);
3648 std::string toString()
const;
3657 namespace literals {
3658 Approx operator ""_a(
long double val);
3659 Approx operator ""_a(
unsigned long long val);
3672 #ifndef CATCH_CONFIG_HPP_INCLUDED
3673 #define CATCH_CONFIG_HPP_INCLUDED
3677 #ifndef CATCH_TEST_SPEC_HPP_INCLUDED
3678 #define CATCH_TEST_SPEC_HPP_INCLUDED
3681 #pragma clang diagnostic push
3682 #pragma clang diagnostic ignored "-Wpadded"
3687 #ifndef CATCH_WILDCARD_PATTERN_HPP_INCLUDED
3688 #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED
3692 #ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED
3693 #define CATCH_CASE_SENSITIVE_HPP_INCLUDED
3697 enum class CaseSensitive { Yes, No };
3708 enum WildcardPosition {
3710 WildcardAtStart = 1,
3712 WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
3717 WildcardPattern( std::string
const& pattern, CaseSensitive caseSensitivity );
3718 bool matches( std::string
const& str )
const;
3721 std::string normaliseString( std::string
const& str )
const;
3722 CaseSensitive m_caseSensitivity;
3723 WildcardPosition m_wildcard = NoWildcard;
3724 std::string m_pattern;
3736 struct TestCaseInfo;
3737 class TestCaseHandle;
3743 explicit Pattern( std::string
const& name );
3745 virtual bool matches(
TestCaseInfo const& testCase )
const = 0;
3746 std::string
const& name()
const;
3748 std::string
const m_name;
3751 class NamePattern :
public Pattern {
3753 explicit NamePattern( std::string
const& name, std::string
const& filterString );
3754 bool matches(
TestCaseInfo const& testCase )
const override;
3759 class TagPattern :
public Pattern {
3761 explicit TagPattern( std::string
const& tag, std::string
const& filterString );
3762 bool matches(
TestCaseInfo const& testCase )
const override;
3768 std::vector<Detail::unique_ptr<Pattern>> m_required;
3769 std::vector<Detail::unique_ptr<Pattern>> m_forbidden;
3772 std::string name()
const;
3778 std::vector<TestCaseHandle const*> tests;
3780 using Matches = std::vector<FilterMatch>;
3781 using vectorStrings = std::vector<std::string>;
3783 bool hasFilters()
const;
3785 Matches matchesByFilter( std::vector<TestCaseHandle>
const& testCases,
IConfig const& config )
const;
3786 const vectorStrings & getInvalidSpecs()
const;
3789 std::vector<Filter> m_filters;
3790 std::vector<std::string> m_invalidSpecs;
3796 #pragma clang diagnostic pop
3802 #ifndef CATCH_OPTIONAL_HPP_INCLUDED
3803 #define CATCH_OPTIONAL_HPP_INCLUDED
3810 template<
typename T>
3813 Optional() : nullableValue(
nullptr ) {}
3815 : nullableValue(
new( storage ) T( _value ) )
3818 : nullableValue( _other ?
new( storage ) T( *_other ) :
nullptr )
3826 if( &_other !=
this ) {
3829 nullableValue =
new( storage ) T( *_other );
3833 Optional& operator = ( T
const& _value ) {
3835 nullableValue =
new( storage ) T( _value );
3841 nullableValue->~T();
3842 nullableValue =
nullptr;
3846 assert(nullableValue);
3847 return *nullableValue;
3849 T
const& operator*()
const {
3850 assert(nullableValue);
3851 return *nullableValue;
3854 assert(nullableValue);
3855 return nullableValue;
3857 const T* operator->()
const {
3858 assert(nullableValue);
3859 return nullableValue;
3862 T valueOr( T
const& defaultValue )
const {
3863 return nullableValue ? *nullableValue : defaultValue;
3866 bool some()
const {
return nullableValue !=
nullptr; }
3867 bool none()
const {
return nullableValue ==
nullptr; }
3869 bool operator !()
const {
return nullableValue ==
nullptr; }
3870 explicit operator bool()
const {
3875 if (a.none() && b.none()) {
3877 }
else if (a.some() && b.some()) {
3889 alignas(
alignof(T))
char storage[
sizeof(T)];
3897 #ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED
3898 #define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED
3911 std::uint32_t generateRandomSeed(GenerateFrom from);
3918 #ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED
3919 #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED
3923 #ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED
3924 #define CATCH_CONSOLE_COLOUR_HPP_INCLUDED
3949 BrightRed = Bright | Red,
3950 BrightGreen = Bright | Green,
3951 LightGrey = Bright | Grey,
3952 BrightWhite = Bright | White,
3953 BrightYellow = Bright | Yellow,
3956 FileName = LightGrey,
3957 Warning = BrightYellow,
3958 ResultError = BrightRed,
3959 ResultSuccess = BrightGreen,
3960 ResultExpectedFailure = Warning,
3965 OriginalExpression = Cyan,
3966 ReconstructedExpression = BrightYellow,
3968 SecondaryText = LightGrey,
3984 Colour::Code m_code;
3985 bool m_engaged =
false;
4018 guard.engageImpl( lhs );
4024 guard.engageImpl( lhs );
4028 void engageImpl( std::ostream& stream );
4039 ColourGuard guardColour( Colour::Code colourCode );
4042 virtual void use( Colour::Code colourCode )
const = 0;
4046 Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode colourSelection,
4050 bool isColourImplAvailable( ColourMode colourSelection );
4068 Optional<ColourMode> stringToColourMode( StringRef colourMode );
4083 std::map<std::string, std::string> m_customOptions;
4089 return !( lhs == rhs );
4097 std::map<std::string, std::string> customOptions );
4099 std::string
const& name()
const {
return m_name; }
4102 return m_outputFileName;
4107 std::map<std::string, std::string>
const& customOptions()
const {
4108 return m_customOptions;
4144 std::string outputFilename;
4146 std::map<std::string, std::string> customOptions;
4151 return !( lhs == rhs );
4157 bool listTests =
false;
4158 bool listTags =
false;
4159 bool listReporters =
false;
4160 bool listListeners =
false;
4162 bool showSuccessfulTests =
false;
4163 bool shouldDebugBreak =
false;
4164 bool noThrow =
false;
4165 bool showHelp =
false;
4166 bool showInvisibles =
false;
4167 bool filenamesAsTags =
false;
4168 bool libIdentify =
false;
4169 bool allowZeroTests =
false;
4171 int abortAfter = -1;
4172 uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
4174 unsigned int shardCount = 1;
4175 unsigned int shardIndex = 0;
4177 bool skipBenchmarks =
false;
4178 bool benchmarkNoAnalysis =
false;
4179 unsigned int benchmarkSamples = 100;
4180 double benchmarkConfidenceInterval = 0.95;
4181 unsigned int benchmarkResamples = 100000;
4182 std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
4184 Verbosity verbosity = Verbosity::Normal;
4186 ShowDurations showDurations = ShowDurations::DefaultForReporter;
4187 double minDuration = -1;
4188 TestRunOrder runOrder = TestRunOrder::Declared;
4189 ColourMode defaultColourMode = ColourMode::PlatformDefault;
4190 WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
4192 std::string defaultOutputFilename;
4194 std::string processName;
4195 std::vector<ReporterSpec> reporterSpecifications;
4197 std::vector<std::string> testsOrTags;
4198 std::vector<std::string> sectionsToRun;
4209 bool listTests()
const;
4210 bool listTags()
const;
4211 bool listReporters()
const;
4212 bool listListeners()
const;
4214 std::vector<ReporterSpec>
const& getReporterSpecs()
const;
4215 std::vector<ProcessedReporterSpec>
const&
4216 getProcessedReporterSpecs()
const;
4218 std::vector<std::string>
const& getTestsOrTags()
const override;
4219 std::vector<std::string>
const& getSectionsToRun()
const override;
4221 TestSpec const& testSpec()
const override;
4222 bool hasTestFilters()
const override;
4224 bool showHelp()
const;
4227 bool allowThrows()
const override;
4229 bool includeSuccessfulResults()
const override;
4230 bool warnAboutMissingAssertions()
const override;
4231 bool warnAboutUnmatchedTestSpecs()
const override;
4232 bool zeroTestsCountAsSuccess()
const override;
4233 ShowDurations showDurations()
const override;
4234 double minDuration()
const override;
4235 TestRunOrder runOrder()
const override;
4236 uint32_t rngSeed()
const override;
4237 unsigned int shardCount()
const override;
4238 unsigned int shardIndex()
const override;
4239 ColourMode defaultColourMode()
const override;
4240 bool shouldDebugBreak()
const override;
4241 int abortAfter()
const override;
4242 bool showInvisibles()
const override;
4243 Verbosity verbosity()
const override;
4244 bool skipBenchmarks()
const override;
4245 bool benchmarkNoAnalysis()
const override;
4246 unsigned int benchmarkSamples()
const override;
4247 double benchmarkConfidenceInterval()
const override;
4248 unsigned int benchmarkResamples()
const override;
4249 std::chrono::milliseconds benchmarkWarmupTime()
const override;
4253 std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
4255 bool m_hasTestFilters =
false;
4262 #ifndef CATCH_MESSAGE_HPP_INCLUDED
4263 #define CATCH_MESSAGE_HPP_INCLUDED
4267 #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED
4268 #define CATCH_STREAM_END_STOP_HPP_INCLUDED
4280 template <
typename T>
4281 friend T
const& operator+( T
const& value,
StreamEndStop ) {
4295 struct SourceLineInfo;
4299 template<
typename T>
4311 ResultWas::OfType type ):
4312 m_info(macroName, lineInfo, type) {}
4315 template<
typename T>
4332 bool m_moved =
false;
4336 std::vector<MessageInfo> m_messages;
4338 size_t m_captured = 0;
4347 void captureValue(
size_t index, std::string
const& value );
4349 template<
typename T>
4350 void captureValues(
size_t index, T
const& value ) {
4351 captureValue( index, Catch::Detail::stringify( value ) );
4354 template<
typename T,
typename... Ts>
4355 void captureValues(
size_t index, T
const& value, Ts
const&... values ) {
4356 captureValue( index, Catch::Detail::stringify(value) );
4357 captureValues( index+1, values... );
4364 #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
4366 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \
4367 catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \
4368 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
4372 #define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \
4373 Catch::Capturer varName( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \
4374 varName.captureValues( 0, __VA_ARGS__ )
4377 #define INTERNAL_CATCH_INFO( macroName, log ) \
4378 Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log )
4381 #define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \
4382 Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log )
4385 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
4387 #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
4388 #define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg )
4389 #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
4390 #define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE", __VA_ARGS__ )
4392 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
4394 #define CATCH_INFO( msg ) (void)(0)
4395 #define CATCH_UNSCOPED_INFO( msg ) (void)(0)
4396 #define CATCH_WARN( msg ) (void)(0)
4397 #define CATCH_CAPTURE( ... ) (void)(0)
4399 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
4401 #define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
4402 #define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg )
4403 #define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
4404 #define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE", __VA_ARGS__ )
4406 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
4408 #define INFO( msg ) (void)(0)
4409 #define UNSCOPED_INFO( msg ) (void)(0)
4410 #define WARN( msg ) (void)(0)
4411 #define CAPTURE( ... ) (void)(0)
4421 #ifndef CATCH_SESSION_HPP_INCLUDED
4422 #define CATCH_SESSION_HPP_INCLUDED
4426 #ifndef CATCH_COMMANDLINE_HPP_INCLUDED
4427 #define CATCH_COMMANDLINE_HPP_INCLUDED
4431 #ifndef CATCH_CLARA_HPP_INCLUDED
4432 #define CATCH_CLARA_HPP_INCLUDED
4434 #if defined( __clang__ )
4435 # pragma clang diagnostic push
4436 # pragma clang diagnostic ignored "-Wweak-vtables"
4437 # pragma clang diagnostic ignored "-Wshadow"
4438 # pragma clang diagnostic ignored "-Wdeprecated"
4441 #if defined( __GNUC__ )
4442 # pragma GCC diagnostic push
4443 # pragma GCC diagnostic ignored "-Wsign-conversion"
4446 #ifndef CLARA_CONFIG_OPTIONAL_TYPE
4447 # ifdef __has_include
4448 # if __has_include( <optional>) && __cplusplus >= 201703L
4449 # include <optional>
4450 # define CLARA_CONFIG_OPTIONAL_TYPE std::optional
4461 #include <type_traits>
4471 enum class ParseResultType {
4483 template <
typename T>
4487 template <
typename F,
typename =
void>
4490 template <
typename F>
4493 Catch::Detail::void_t<decltype(
4494 std::declval<F>()( fake_arg() ) )
4496 > : std::true_type {};
4500 template <
typename L>
4504 template <
typename ClassT,
typename ReturnT,
typename...
Args>
4506 static const bool isValid =
false;
4509 template <
typename ClassT,
typename ReturnT,
typename ArgT>
4511 static const bool isValid =
true;
4512 using ArgType = std::remove_const_t<std::remove_reference_t<ArgT>>;
4513 using ReturnType = ReturnT;
4521 enum class TokenType { Option, Argument };
4530 using Iterator = std::vector<std::string>::const_iterator;
4533 std::vector<Token> m_tokenBuffer;
4541 explicit operator bool()
const {
4542 return !m_tokenBuffer.empty() || it != itEnd;
4545 size_t count()
const {
4546 return m_tokenBuffer.size() + ( itEnd - it );
4549 Token operator*()
const {
4550 assert( !m_tokenBuffer.empty() );
4551 return m_tokenBuffer.front();
4554 Token const* operator->()
const {
4555 assert( !m_tokenBuffer.empty() );
4556 return &m_tokenBuffer.front();
4581 virtual void enforceOk()
const = 0;
4588 auto value()
const -> T
const& {
4598 if ( m_type == ResultType::Ok )
4599 new ( &m_value ) T( other.m_value );
4603 new ( &m_value ) T( value );
4608 if ( m_type == ResultType::Ok )
4610 ResultBase::operator=( other );
4611 if ( m_type == ResultType::Ok )
4612 new ( &m_value ) T( other.m_value );
4617 if ( m_type == ResultType::Ok )
4628 using ResultBase::ResultBase;
4631 template <
typename T =
void>
4634 template <
typename U>
4637 m_errorMessage( other.errorMessage() ) {
4638 assert( type() != ResultType::Ok );
4641 template <
typename U>
4643 return { ResultType::Ok, value };
4645 static auto ok() ->
BasicResult {
return { ResultType::Ok }; }
4646 static auto logicError( std::string&& message )
4648 return { ResultType::LogicError,
CATCH_MOVE(message) };
4650 static auto runtimeError( std::string&& message )
4652 return { ResultType::RuntimeError,
CATCH_MOVE(message) };
4655 explicit operator bool()
const {
4656 return m_type == ResultType::Ok;
4658 auto type()
const ->
ResultType {
return m_type; }
4659 auto errorMessage()
const -> std::string
const& {
4660 return m_errorMessage;
4664 void enforceOk()
const override {
4668 assert( m_type != ResultType::LogicError );
4669 assert( m_type != ResultType::RuntimeError );
4670 if ( m_type != ResultType::Ok )
4678 std::string&& message ):
4680 assert( m_type != ResultType::Ok );
4684 using ResultBase::m_type;
4692 ParseResultType type()
const {
return m_type; }
4694 return m_remainingTokens;
4698 ParseResultType m_type;
4711 template <
typename T>
4712 ParserResult convertInto( std::string
const& source, T& target ) {
4713 std::stringstream ss( source );
4716 return ParserResult::runtimeError(
4717 "Unable to convert '" + source +
4718 "' to destination type" );
4720 return ParserResult::ok( ParseResultType::Matched );
4723 ParserResult convertInto( std::string
const& source,
4724 std::string& target );
4725 ParserResult convertInto( std::string
const& source,
bool& target );
4727 #ifdef CLARA_CONFIG_OPTIONAL_TYPE
4728 template <
typename T>
4729 auto convertInto( std::string
const& source,
4730 CLARA_CONFIG_OPTIONAL_TYPE<T>& target )
4733 auto result = convertInto( source, temp );
4742 virtual bool isContainer()
const;
4743 virtual bool isFlag()
const;
4746 virtual auto setValue( std::string
const& arg )
4751 bool isFlag()
const override;
4759 ParserResult setValue( std::string
const& arg )
override {
4760 return convertInto( arg, m_ref );
4764 template <
typename T>
4766 std::vector<T>& m_ref;
4768 explicit BoundValueRef( std::vector<T>& ref ): m_ref( ref ) {}
4770 auto isContainer()
const ->
bool override {
return true; }
4772 auto setValue( std::string
const& arg )
4775 auto result = convertInto( arg, temp );
4777 m_ref.push_back( temp );
4792 std::is_same<ReturnType, ParserResult>::value,
4793 "Lambda must return void or clara::ParserResult" );
4795 template <
typename L,
typename ArgType>
4796 static auto invoke( L
const&
lambda, ArgType
const& arg )
4803 template <
typename L,
typename ArgType>
4804 static auto invoke( L
const&
lambda, ArgType
const& arg )
4807 return ParserResult::ok( ParseResultType::Matched );
4811 template <
typename ArgType,
typename L>
4812 auto invokeLambda( L
const&
lambda, std::string
const& arg )
4815 auto result = convertInto( arg, temp );
4816 return !result ? result
4817 : LambdaInvoker<
typename UnaryLambdaTraits<
4826 "Supplied lambda must take exactly one argument" );
4829 auto setValue( std::string
const& arg )
4831 return invokeLambda<typename UnaryLambdaTraits<L>::ArgType>(
4838 bool isContainer()
const override {
return true; }
4846 "Supplied lambda must take exactly one argument" );
4850 "flags must be boolean" );
4857 L>::ReturnType>
::invoke( m_lambda, flag );
4861 enum class Optionality {
Optional, Required };
4866 virtual auto validate()
const ->
Result {
return Result::ok(); }
4867 virtual auto parse( std::string
const& exeName,
4870 virtual size_t cardinality()
const;
4875 template <
typename DerivedT>
4878 template <
typename T>
4879 auto operator|( T
const& other )
const ->
Parser;
4883 template <
typename DerivedT>
4886 Optionality m_optionality = Optionality::Optional;
4887 std::shared_ptr<BoundRef> m_ref;
4889 std::string m_description;
4891 explicit ParserRefImpl( std::shared_ptr<BoundRef>
const& ref ):
4895 template <
typename LambdaT>
4898 std::string
const& hint ):
4902 template <
typename T,
4903 typename =
typename std::enable_if_t<
4909 template <
typename LambdaT,
4910 typename =
typename std::enable_if_t<
4912 ParserRefImpl( LambdaT
const& ref, std::string
const& hint ):
4916 auto operator()( std::string
const& description ) -> DerivedT& {
4917 m_description = description;
4918 return static_cast<DerivedT&
>( *this );
4921 auto optional() -> DerivedT& {
4922 m_optionality = Optionality::Optional;
4923 return static_cast<DerivedT&
>( *this );
4926 auto required() -> DerivedT& {
4927 m_optionality = Optionality::Required;
4928 return static_cast<DerivedT&
>( *this );
4931 auto isOptional()
const ->
bool {
4932 return m_optionality == Optionality::Optional;
4935 auto cardinality()
const ->
size_t override {
4936 if ( m_ref->isContainer() )
4942 std::string
const& hint()
const {
return m_hint; }
4951 using ParserRefImpl::ParserRefImpl;
4952 using ParserBase::parse;
4955 parse(std::string
const&,
4962 std::vector<std::string> m_optNames;
4965 template <
typename LambdaT>
4966 explicit Opt(LambdaT
const& ref) :
4970 explicit Opt(
bool& ref);
4972 template <
typename LambdaT,
4973 typename =
typename std::enable_if_t<
4975 Opt( LambdaT
const& ref, std::string
const& hint ):
4976 ParserRefImpl( ref, hint ) {}
4978 template <
typename LambdaT>
4980 ParserRefImpl( accept_many, ref, hint ) {}
4982 template <
typename T,
4983 typename =
typename std::enable_if_t<
4985 Opt( T& ref, std::string
const& hint ):
4986 ParserRefImpl( ref, hint ) {}
4988 auto operator[](std::string
const& optName) ->
Opt& {
4989 m_optNames.push_back(optName);
4993 std::vector<Detail::HelpColumns> getHelpColumns()
const;
4995 bool isMatch(std::string
const& optToken)
const;
4997 using ParserBase::parse;
5000 parse(std::string
const&,
5008 std::shared_ptr<std::string> m_name;
5009 std::shared_ptr<Detail::BoundValueRefBase> m_ref;
5013 explicit ExeName(std::string& ref);
5015 template <
typename LambdaT>
5017 m_ref = std::make_shared<Detail::BoundLambda<LambdaT>>(
lambda);
5023 parse(std::string
const&,
5026 std::string
const& name()
const {
return *m_name; }
5034 std::vector<Opt> m_options;
5035 std::vector<Arg> m_args;
5040 m_exeName = exeName;
5044 auto operator|=(
Arg const& arg) ->
Parser& {
5045 m_args.push_back(arg);
5049 auto operator|=(
Opt const& opt) ->
Parser& {
5050 m_options.push_back(opt);
5056 template <
typename T>
5057 auto operator|(T
const& other)
const ->
Parser {
5058 return Parser(*
this) |= other;
5061 std::vector<Detail::HelpColumns> getHelpColumns()
const;
5063 void writeToStream(std::ostream& os)
const;
5065 friend auto operator<<(std::ostream& os,
Parser const& parser)
5067 parser.writeToStream(os);
5073 using ParserBase::parse;
5075 parse(std::string
const& exeName,
5083 std::string m_exeName;
5084 std::vector<std::string> m_args;
5087 Args(
int argc,
char const*
const* argv);
5088 Args(std::initializer_list<std::string> args);
5090 std::string
const& exeName()
const {
return m_exeName; }
5096 Help(
bool& showHelpFlag);
5103 template <
typename DerivedT>
5104 template <
typename T>
5106 ComposableParserImpl<DerivedT>::operator|(T
const& other)
const {
5107 return Parser() |
static_cast<DerivedT const&
>(*this) | other;
5114 #if defined( __clang__ )
5115 # pragma clang diagnostic pop
5118 #if defined( __GNUC__ )
5119 # pragma GCC diagnostic pop
5128 Clara::Parser makeCommandLineParser( ConfigData& config );
5142 void showHelp()
const;
5145 int applyCommandLine(
int argc,
char const *
const * argv );
5146 #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE)
5147 int applyCommandLine(
int argc,
wchar_t const *
const * argv );
5150 void useConfigData(
ConfigData const& configData );
5152 template<
typename CharT>
5153 int run(
int argc, CharT
const *
const argv[]) {
5154 if (m_startupExceptions)
5156 int returnCode = applyCommandLine(argc, argv);
5157 if (returnCode == 0)
5174 bool m_startupExceptions =
false;
5182 #ifndef CATCH_TAG_ALIAS_HPP_INCLUDED
5183 #define CATCH_TAG_ALIAS_HPP_INCLUDED
5205 #ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
5206 #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
5217 #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \
5218 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5219 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
5220 namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \
5221 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
5226 #ifndef CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED
5227 #define CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED
5233 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 10
5234 #pragma GCC diagnostic ignored "-Wparentheses"
5240 #ifndef CATCH_TEST_MACROS_HPP_INCLUDED
5241 #define CATCH_TEST_MACROS_HPP_INCLUDED
5245 #ifndef CATCH_TEST_MACRO_IMPL_HPP_INCLUDED
5246 #define CATCH_TEST_MACRO_IMPL_HPP_INCLUDED
5250 #ifndef CATCH_ASSERTION_HANDLER_HPP_INCLUDED
5251 #define CATCH_ASSERTION_HANDLER_HPP_INCLUDED
5255 #ifndef CATCH_DECOMPOSER_HPP_INCLUDED
5256 #define CATCH_DECOMPOSER_HPP_INCLUDED
5262 #pragma warning(push)
5263 #pragma warning(disable:4389)
5264 #pragma warning(disable:4018)
5265 #pragma warning(disable:4312)
5266 #pragma warning(disable:4180)
5267 #pragma warning(disable:4800)
5271 # pragma clang diagnostic push
5272 # pragma clang diagnostic ignored "-Wsign-compare"
5273 #elif defined __GNUC__
5274 # pragma GCC diagnostic push
5275 # pragma GCC diagnostic ignored "-Wsign-compare"
5281 bool m_isBinaryExpression;
5285 auto isBinaryExpression()
const ->
bool {
return m_isBinaryExpression; }
5286 auto getResult()
const ->
bool {
return m_result; }
5287 virtual void streamReconstructedExpression( std::ostream &os )
const = 0;
5290 : m_isBinaryExpression( isBinaryExpression ),
5303 expr.streamReconstructedExpression(out);
5308 void formatReconstructedExpression( std::ostream &os, std::string
const& lhs,
StringRef op, std::string
const& rhs );
5310 template<
typename LhsT,
typename RhsT>
5316 void streamReconstructedExpression( std::ostream &os )
const override {
5317 formatReconstructedExpression
5318 ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) );
5329 template<
typename T>
5332 "chained comparisons are not supported inside assertions, "
5333 "wrap the expression inside parentheses, or decompose it");
5336 template<
typename T>
5339 "chained comparisons are not supported inside assertions, "
5340 "wrap the expression inside parentheses, or decompose it");
5343 template<
typename T>
5346 "chained comparisons are not supported inside assertions, "
5347 "wrap the expression inside parentheses, or decompose it");
5350 template<
typename T>
5353 "chained comparisons are not supported inside assertions, "
5354 "wrap the expression inside parentheses, or decompose it");
5357 template<
typename T>
5360 "chained comparisons are not supported inside assertions, "
5361 "wrap the expression inside parentheses, or decompose it");
5364 template<
typename T>
5367 "chained comparisons are not supported inside assertions, "
5368 "wrap the expression inside parentheses, or decompose it");
5371 template<
typename T>
5374 "chained comparisons are not supported inside assertions, "
5375 "wrap the expression inside parentheses, or decompose it");
5378 template<
typename T>
5381 "chained comparisons are not supported inside assertions, "
5382 "wrap the expression inside parentheses, or decompose it");
5386 template<
typename LhsT>
5390 void streamReconstructedExpression( std::ostream &os )
const override {
5391 os << Catch::Detail::stringify( m_lhs );
5403 template<
typename LhsT,
typename RhsT>
5404 auto compareEqual( LhsT
const& lhs, RhsT
const& rhs ) ->
bool {
return static_cast<bool>(lhs == rhs); }
5405 template<
typename T>
5406 auto compareEqual( T*
const& lhs,
int rhs ) ->
bool {
return lhs ==
reinterpret_cast<void const*
>( rhs ); }
5407 template<
typename T>
5408 auto compareEqual( T*
const& lhs,
long rhs ) ->
bool {
return lhs ==
reinterpret_cast<void const*
>( rhs ); }
5409 template<
typename T>
5410 auto compareEqual(
int lhs, T*
const& rhs ) ->
bool {
return reinterpret_cast<void const*
>( lhs ) == rhs; }
5411 template<
typename T>
5412 auto compareEqual(
long lhs, T*
const& rhs ) ->
bool {
return reinterpret_cast<void const*
>( lhs ) == rhs; }
5414 template<
typename LhsT,
typename RhsT>
5415 auto compareNotEqual( LhsT
const& lhs, RhsT&& rhs ) ->
bool {
return static_cast<bool>(lhs != rhs); }
5416 template<
typename T>
5417 auto compareNotEqual( T*
const& lhs,
int rhs ) ->
bool {
return lhs !=
reinterpret_cast<void const*
>( rhs ); }
5418 template<
typename T>
5419 auto compareNotEqual( T*
const& lhs,
long rhs ) ->
bool {
return lhs !=
reinterpret_cast<void const*
>( rhs ); }
5420 template<
typename T>
5421 auto compareNotEqual(
int lhs, T*
const& rhs ) ->
bool {
return reinterpret_cast<void const*
>( lhs ) != rhs; }
5422 template<
typename T>
5423 auto compareNotEqual(
long lhs, T*
const& rhs ) ->
bool {
return reinterpret_cast<void const*
>( lhs ) != rhs; }
5426 template<
typename LhsT>
5430 explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}
5432 template<
typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value,
int> = 0>
5434 return { compareEqual( lhs.m_lhs, rhs ), lhs.m_lhs,
"=="_sr, rhs };
5436 template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value,
int> = 0>
5438 return { compareEqual( lhs.m_lhs, rhs ), lhs.m_lhs,
"=="_sr, rhs };
5441 template<
typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value,
int> = 0>
5443 return { compareNotEqual( lhs.m_lhs, rhs ), lhs.m_lhs,
"!="_sr, rhs };
5445 template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value,
int> = 0>
5447 return { compareNotEqual( lhs.m_lhs, rhs ), lhs.m_lhs,
"!="_sr, rhs };
5450 #define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(op) \
5451 template<typename RhsT, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, int> = 0> \
5452 friend auto operator op ( ExprLhs && lhs, RhsT && rhs ) -> BinaryExpr<LhsT, RhsT const&> { \
5453 return { static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs }; \
5455 template<typename RhsT, std::enable_if_t<std::is_arithmetic<RhsT>::value, int> = 0> \
5456 friend auto operator op ( ExprLhs && lhs, RhsT rhs ) -> BinaryExpr<LhsT, RhsT> { \
5457 return { static_cast<bool>(lhs.m_lhs op rhs), lhs.m_lhs, #op##_sr, rhs }; \
5460 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(<)
5461 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(>)
5462 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(<=)
5463 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(>=)
5464 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(|)
5465 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(&)
5466 CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(^)
5468 #undef CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR
5470 template<
typename RhsT>
5473 "operator&& is not supported inside assertions, "
5474 "wrap the expression inside parentheses, or decompose it");
5477 template<
typename RhsT>
5480 "operator|| is not supported inside assertions, "
5481 "wrap the expression inside parentheses, or decompose it");
5490 template<
typename T, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<T>>::value,
int> = 0>
5495 template<typename T, std::enable_if_t<std::is_arithmetic<T>::value,
int> = 0>
5504 #pragma warning(pop)
5507 # pragma clang diagnostic pop
5508 #elif defined __GNUC__
5509 # pragma GCC diagnostic pop
5518 class IResultCapture;
5521 bool shouldDebugBreak =
false;
5522 bool shouldThrow =
false;
5528 bool m_completed =
false;
5536 ResultDisposition::Flags resultDisposition );
5538 if ( !m_completed ) {
5539 m_resultCapture.handleIncomplete( m_assertionInfo );
5544 template<
typename T>
5546 handleExpr( expr.makeUnaryExpr() );
5550 void handleMessage(ResultWas::OfType resultType,
StringRef message);
5552 void handleExceptionThrownAsExpected();
5553 void handleUnexpectedExceptionNotThrown();
5554 void handleExceptionNotThrownAsExpected();
5555 void handleThrowingCallSkipped();
5556 void handleUnexpectedInflightException();
5559 void setCompleted();
5562 auto allowThrows()
const -> bool;
5573 #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 9
5574 #pragma GCC diagnostic ignored "-Wparentheses"
5577 #if !defined(CATCH_CONFIG_DISABLE)
5579 #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)
5580 #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__
5582 #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
5585 #if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
5590 #define INTERNAL_CATCH_TRY
5591 #define INTERNAL_CATCH_CATCH( capturer )
5595 #define INTERNAL_CATCH_TRY try
5596 #define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); }
5600 #define INTERNAL_CATCH_REACT( handler ) handler.complete();
5603 #define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \
5606 CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
5607 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
5608 INTERNAL_CATCH_TRY { \
5609 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5610 CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
5611 catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
5612 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
5613 } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
5614 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
5615 } while( (void)0, (false) && static_cast<const bool&>( !!(__VA_ARGS__) ) )
5619 #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \
5620 INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \
5621 if( Catch::getResultCapture().lastAssertionPassed() )
5624 #define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \
5625 INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \
5626 if( !Catch::getResultCapture().lastAssertionPassed() )
5629 #define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \
5631 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
5633 static_cast<void>(__VA_ARGS__); \
5634 catchAssertionHandler.handleExceptionNotThrownAsExpected(); \
5637 catchAssertionHandler.handleUnexpectedInflightException(); \
5639 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
5643 #define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \
5645 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \
5646 if( catchAssertionHandler.allowThrows() ) \
5648 static_cast<void>(__VA_ARGS__); \
5649 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
5652 catchAssertionHandler.handleExceptionThrownAsExpected(); \
5655 catchAssertionHandler.handleThrowingCallSkipped(); \
5656 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
5660 #define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
5662 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \
5663 if( catchAssertionHandler.allowThrows() ) \
5665 static_cast<void>(expr); \
5666 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
5668 catch( exceptionType const& ) { \
5669 catchAssertionHandler.handleExceptionThrownAsExpected(); \
5672 catchAssertionHandler.handleUnexpectedInflightException(); \
5675 catchAssertionHandler.handleThrowingCallSkipped(); \
5676 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
5683 #define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \
5685 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
5686 if( catchAssertionHandler.allowThrows() ) \
5688 static_cast<void>(__VA_ARGS__); \
5689 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
5692 Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \
5695 catchAssertionHandler.handleThrowingCallSkipped(); \
5696 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
5704 #ifndef CATCH_SECTION_HPP_INCLUDED
5705 #define CATCH_SECTION_HPP_INCLUDED
5709 #ifndef CATCH_TIMER_HPP_INCLUDED
5710 #define CATCH_TIMER_HPP_INCLUDED
5717 uint64_t m_nanoseconds = 0;
5720 auto getElapsedNanoseconds()
const -> uint64_t;
5721 auto getElapsedMicroseconds()
const -> uint64_t;
5722 auto getElapsedMilliseconds()
const ->
unsigned int;
5723 auto getElapsedSeconds()
const -> double;
5738 explicit operator bool()
const;
5744 bool m_sectionIncluded;
5750 #define INTERNAL_CATCH_SECTION( ... ) \
5751 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5752 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
5753 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \
5754 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
5756 #define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
5757 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5758 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
5759 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \
5760 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
5765 #ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED
5766 #define CATCH_TEST_REGISTRY_HPP_INCLUDED
5770 #ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED
5771 #define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED
5778 struct TestCaseInfo;
5782 virtual void invoke ()
const = 0;
5793 virtual std::vector<TestCaseInfo* >
const& getAllInfos()
const = 0;
5794 virtual std::vector<TestCaseHandle>
const& getAllTests()
const = 0;
5795 virtual std::vector<TestCaseHandle>
const& getAllTestsSorted(
IConfig const& config )
const = 0;
5800 std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle>
const& testCases,
TestSpec const& testSpec,
IConfig const& config );
5801 std::vector<TestCaseHandle>
const& getAllTestCasesSorted(
IConfig const& config );
5808 #ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED
5809 #define CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED
5811 #define INTERNAL_CATCH_EXPAND1( param ) INTERNAL_CATCH_EXPAND2( param )
5812 #define INTERNAL_CATCH_EXPAND2( ... ) INTERNAL_CATCH_NO##__VA_ARGS__
5813 #define INTERNAL_CATCH_DEF( ... ) INTERNAL_CATCH_DEF __VA_ARGS__
5814 #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF
5816 #define INTERNAL_CATCH_REMOVE_PARENS( ... ) \
5817 INTERNAL_CATCH_EXPAND1( INTERNAL_CATCH_DEF __VA_ARGS__ )
5824 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5
5825 #pragma GCC diagnostic ignored "-Wunused-variable"
5832 template<
typename C>
5834 void (C::*m_testAsMethod)();
5836 TestInvokerAsMethod(
void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}
5838 void invoke()
const override {
5840 (obj.*m_testAsMethod)();
5846 template<
typename C>
5848 return Detail::make_unique<TestInvokerAsMethod<C>>( testAsMethod );
5854 name( name_ ), tags( tags_ ) {}
5865 #if defined(CATCH_CONFIG_DISABLE)
5866 #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \
5867 static inline void TestName()
5868 #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
5870 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
5874 void TestName::test()
5878 #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
5879 static void TestName(); \
5880 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5881 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
5882 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } \
5883 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
5884 static void TestName()
5885 #define INTERNAL_CATCH_TESTCASE( ... ) \
5886 INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ )
5889 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
5890 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5891 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
5892 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); }
\
5893 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
5896 #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
5897 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5898 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
5900 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
5903 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); \
5905 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
5906 void TestName::test()
5907 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
5908 INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ )
5911 #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
5913 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
5914 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
5915 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); \
5916 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
5928 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
5930 #define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ )
5931 #define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
5933 #define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
5934 #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
5935 #define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
5937 #define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
5938 #define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
5939 #define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
5940 #define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
5941 #define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
5943 #define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
5944 #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
5945 #define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
5947 #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
5948 #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
5949 #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
5950 #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
5951 #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
5952 #define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )
5953 #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
5954 #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
5955 #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
5958 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
5959 #define CATCH_STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__ , #__VA_ARGS__ ); CATCH_SUCCEED( #__VA_ARGS__ )
5960 #define CATCH_STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); CATCH_SUCCEED( #__VA_ARGS__ )
5961 #define CATCH_STATIC_CHECK( ... ) static_assert( __VA_ARGS__ , #__VA_ARGS__ ); CATCH_SUCCEED( #__VA_ARGS__ )
5962 #define CATCH_STATIC_CHECK_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); CATCH_SUCCEED( #__VA_ARGS__ )
5964 #define CATCH_STATIC_REQUIRE( ... ) CATCH_REQUIRE( __VA_ARGS__ )
5965 #define CATCH_STATIC_REQUIRE_FALSE( ... ) CATCH_REQUIRE_FALSE( __VA_ARGS__ )
5966 #define CATCH_STATIC_CHECK( ... ) CATCH_CHECK( __VA_ARGS__ )
5967 #define CATCH_STATIC_CHECK_FALSE( ... ) CATCH_CHECK_FALSE( __VA_ARGS__ )
5972 #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
5973 #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
5974 #define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc )
5975 #define CATCH_AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc )
5976 #define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc )
5977 #define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc )
5978 #define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc )
5979 #define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc )
5981 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
5983 #define CATCH_REQUIRE( ... ) (void)(0)
5984 #define CATCH_REQUIRE_FALSE( ... ) (void)(0)
5986 #define CATCH_REQUIRE_THROWS( ... ) (void)(0)
5987 #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
5988 #define CATCH_REQUIRE_NOTHROW( ... ) (void)(0)
5990 #define CATCH_CHECK( ... ) (void)(0)
5991 #define CATCH_CHECK_FALSE( ... ) (void)(0)
5992 #define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__)
5993 #define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__))
5994 #define CATCH_CHECK_NOFAIL( ... ) (void)(0)
5996 #define CATCH_CHECK_THROWS( ... ) (void)(0)
5997 #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
5998 #define CATCH_CHECK_NOTHROW( ... ) (void)(0)
6000 #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ))
6001 #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ))
6002 #define CATCH_METHOD_AS_TEST_CASE( method, ... )
6003 #define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0)
6004 #define CATCH_SECTION( ... )
6005 #define CATCH_DYNAMIC_SECTION( ... )
6006 #define CATCH_FAIL( ... ) (void)(0)
6007 #define CATCH_FAIL_CHECK( ... ) (void)(0)
6008 #define CATCH_SUCCEED( ... ) (void)(0)
6010 #define CATCH_STATIC_REQUIRE( ... ) (void)(0)
6011 #define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0)
6012 #define CATCH_STATIC_CHECK( ... ) (void)(0)
6013 #define CATCH_STATIC_CHECK_FALSE( ... ) (void)(0)
6016 #define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ))
6017 #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), className )
6018 #define CATCH_GIVEN( desc )
6019 #define CATCH_AND_GIVEN( desc )
6020 #define CATCH_WHEN( desc )
6021 #define CATCH_AND_WHEN( desc )
6022 #define CATCH_THEN( desc )
6023 #define CATCH_AND_THEN( desc )
6025 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
6027 #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ )
6028 #define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
6030 #define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
6031 #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
6032 #define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
6034 #define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
6035 #define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )
6036 #define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
6037 #define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
6038 #define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )
6040 #define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
6041 #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
6042 #define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
6044 #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
6045 #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
6046 #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
6047 #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
6048 #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
6049 #define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )
6050 #define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
6051 #define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
6052 #define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
6055 #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
6056 #define STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__, #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ )
6057 #define STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); SUCCEED( "!(" #__VA_ARGS__ ")" )
6058 #define STATIC_CHECK( ... ) static_assert( __VA_ARGS__, #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ )
6059 #define STATIC_CHECK_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); SUCCEED( "!(" #__VA_ARGS__ ")" )
6061 #define STATIC_REQUIRE( ... ) REQUIRE( __VA_ARGS__ )
6062 #define STATIC_REQUIRE_FALSE( ... ) REQUIRE_FALSE( __VA_ARGS__ )
6063 #define STATIC_CHECK( ... ) CHECK( __VA_ARGS__ )
6064 #define STATIC_CHECK_FALSE( ... ) CHECK_FALSE( __VA_ARGS__ )
6068 #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
6069 #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
6070 #define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc )
6071 #define AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc )
6072 #define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc )
6073 #define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc )
6074 #define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc )
6075 #define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc )
6077 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
6079 #define REQUIRE( ... ) (void)(0)
6080 #define REQUIRE_FALSE( ... ) (void)(0)
6082 #define REQUIRE_THROWS( ... ) (void)(0)
6083 #define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
6084 #define REQUIRE_NOTHROW( ... ) (void)(0)
6086 #define CHECK( ... ) (void)(0)
6087 #define CHECK_FALSE( ... ) (void)(0)
6088 #define CHECKED_IF( ... ) if (__VA_ARGS__)
6089 #define CHECKED_ELSE( ... ) if (!(__VA_ARGS__))
6090 #define CHECK_NOFAIL( ... ) (void)(0)
6092 #define CHECK_THROWS( ... ) (void)(0)
6093 #define CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
6094 #define CHECK_NOTHROW( ... ) (void)(0)
6096 #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__)
6097 #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ))
6098 #define METHOD_AS_TEST_CASE( method, ... )
6099 #define REGISTER_TEST_CASE( Function, ... ) (void)(0)
6100 #define SECTION( ... )
6101 #define DYNAMIC_SECTION( ... )
6102 #define FAIL( ... ) (void)(0)
6103 #define FAIL_CHECK( ... ) (void)(0)
6104 #define SUCCEED( ... ) (void)(0)
6106 #define STATIC_REQUIRE( ... ) (void)(0)
6107 #define STATIC_REQUIRE_FALSE( ... ) (void)(0)
6108 #define STATIC_CHECK( ... ) (void)(0)
6109 #define STATIC_CHECK_FALSE( ... ) (void)(0)
6112 #define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ) )
6113 #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), className )
6115 #define GIVEN( desc )
6116 #define AND_GIVEN( desc )
6117 #define WHEN( desc )
6118 #define AND_WHEN( desc )
6119 #define THEN( desc )
6120 #define AND_THEN( desc )
6129 #ifndef CATCH_TEMPLATE_TEST_REGISTRY_HPP_INCLUDED
6130 #define CATCH_TEMPLATE_TEST_REGISTRY_HPP_INCLUDED
6134 #ifndef CATCH_PREPROCESSOR_HPP_INCLUDED
6135 #define CATCH_PREPROCESSOR_HPP_INCLUDED
6138 #if defined(__GNUC__)
6140 #pragma GCC system_header
6144 #define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__
6145 #define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__)))
6146 #define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__)))
6147 #define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__)))
6148 #define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__)))
6149 #define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__)))
6151 #ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6152 #define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__
6154 #define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__)))
6155 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__))
6157 #define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__)
6160 #define CATCH_REC_END(...)
6161 #define CATCH_REC_OUT
6163 #define CATCH_EMPTY()
6164 #define CATCH_DEFER(id) id CATCH_EMPTY()
6166 #define CATCH_REC_GET_END2() 0, CATCH_REC_END
6167 #define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2
6168 #define CATCH_REC_GET_END(...) CATCH_REC_GET_END1
6169 #define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT
6170 #define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0)
6171 #define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next)
6173 #define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
6174 #define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ )
6175 #define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
6177 #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__ )
6178 #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__ )
6179 #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__ )
6184 #define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
6186 #define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
6188 #define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__)
6189 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6190 #define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__
6191 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param))
6194 #define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__)
6195 #define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__
6196 #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1)
6199 #define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__
6200 #define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name)
6202 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6203 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>())
6204 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))
6206 #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>()))
6207 #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)))
6210 #define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\
6211 CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__)
6213 #define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0)
6214 #define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1)
6215 #define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2)
6216 #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)
6217 #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)
6218 #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)
6219 #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)
6220 #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)
6221 #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)
6222 #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)
6223 #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)
6225 #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
6227 #define INTERNAL_CATCH_TYPE_GEN\
6228 template<typename...> struct TypeList {};\
6229 template<typename...Ts>\
6230 constexpr auto get_wrapper() noexcept -> TypeList<Ts...> { return {}; }\
6231 template<template<typename...> class...> struct TemplateTypeList{};\
6232 template<template<typename...> class...Cs>\
6233 constexpr auto get_wrapper() noexcept -> TemplateTypeList<Cs...> { return {}; }\
6234 template<typename...>\
6236 template<typename...>\
6238 template<template<typename...> class, typename...>\
6240 template<template<typename...> class, typename>\
6243 template<typename T> \
6244 struct append<T> { using type = T; };\
6245 template< template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2, typename...Rest>\
6246 struct append<L1<E1...>, L2<E2...>, Rest...> { using type = typename append<L1<E1...,E2...>, Rest...>::type; };\
6247 template< template<typename...> class L1, typename...E1, typename...Rest>\
6248 struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { using type = L1<E1...>; };\
6250 template< template<typename...> class Container, template<typename...> class List, typename...elems>\
6251 struct rewrap<TemplateTypeList<Container>, List<elems...>> { using type = TypeList<Container<elems...>>; };\
6252 template< template<typename...> class Container, template<typename...> class List, class...Elems, typename...Elements>\
6253 struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; };\
6255 template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\
6256 struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; };\
6257 template<template <typename...> class Final, template <typename...> class List, typename...Ts>\
6258 struct convert<Final, List<Ts...>> { using type = typename append<Final<>,TypeList<Ts>...>::type; };
6260 #define INTERNAL_CATCH_NTTP_1(signature, ...)\
6261 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\
6262 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6263 constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \
6264 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\
6265 template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\
6266 constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \
6268 template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6269 struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\
6270 template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\
6271 struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; };\
6272 template<template <typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Containers, typename...Types>\
6273 struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; };
6275 #define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName)
6276 #define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\
6277 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6278 static void TestName()
6279 #define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...)\
6280 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6281 static void TestName()
6283 #define INTERNAL_CATCH_DEFINE_SIG_TEST0(TestName)
6284 #define INTERNAL_CATCH_DEFINE_SIG_TEST1(TestName, signature)\
6285 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6286 static void TestName()
6287 #define INTERNAL_CATCH_DEFINE_SIG_TEST_X(TestName, signature,...)\
6288 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6289 static void TestName()
6291 #define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature)\
6292 template<typename Type>\
6293 void reg_test(TypeList<Type>, Catch::NameAndTags nameAndTags)\
6295 Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<Type>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
6298 #define INTERNAL_CATCH_NTTP_REGISTER(TestFunc, signature, ...)\
6299 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6300 void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags)\
6302 Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
6305 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...)\
6306 template<typename Type>\
6307 void reg_test(TypeList<Type>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
6309 Catch::AutoReg( Catch::makeTestInvoker(&TestName<Type>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
6312 #define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...)\
6313 template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
6314 void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
6316 Catch::AutoReg( Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
6319 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0(TestName, ClassName)
6320 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1(TestName, ClassName, signature)\
6321 template<typename TestType> \
6322 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<TestType> { \
6326 #define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X(TestName, ClassName, signature, ...)\
6327 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \
6328 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<__VA_ARGS__> { \
6332 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0(TestName)
6333 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1(TestName, signature)\
6334 template<typename TestType> \
6335 void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<TestType>::test()
6336 #define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X(TestName, signature, ...)\
6337 template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \
6338 void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<__VA_ARGS__>::test()
6340 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6341 #define INTERNAL_CATCH_NTTP_0
6342 #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)
6343 #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__)
6344 #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__)
6345 #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__)
6346 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__)
6347 #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__)
6348 #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__)
6349 #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__)
6351 #define INTERNAL_CATCH_NTTP_0(signature)
6352 #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__))
6353 #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__))
6354 #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__))
6355 #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__))
6356 #define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__))
6357 #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__))
6358 #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__))
6359 #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__))
6368 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5
6369 #pragma GCC diagnostic ignored "-Wunused-variable"
6372 #if defined(CATCH_CONFIG_DISABLE)
6373 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( TestName, TestFunc, Name, Tags, Signature, ... ) \
6374 INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature))
6375 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
6377 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
6378 INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
6381 INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
6383 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6384 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
6385 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__ )
6387 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
6388 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__ ) )
6391 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6392 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
6393 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__ )
6395 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
6396 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__ ) )
6399 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6400 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
6401 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__ )
6403 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
6404 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__ ) )
6407 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6408 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
6409 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__ )
6411 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
6412 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__ ) )
6418 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\
6419 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6420 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6421 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
6422 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6423 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6424 INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
6426 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
6427 INTERNAL_CATCH_TYPE_GEN\
6428 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
6429 INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\
6430 template<typename...Types> \
6434 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
6435 using expander = size_t[];\
6436 (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };
\
6439 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
6440 TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
6445 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6446 INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))
6448 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6449 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
6450 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__ )
6452 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
6453 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__ ) )
6456 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6457 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
6458 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__ )
6460 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
6461 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__ ) )
6464 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \
6465 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6466 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6467 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
6468 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6469 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6470 template<typename TestType> static void TestFuncName(); \
6472 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
6473 INTERNAL_CATCH_TYPE_GEN \
6474 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \
6475 template<typename... Types> \
6477 void reg_tests() { \
6479 using expander = size_t[]; \
6480 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
6481 constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
6482 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
6483 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + std::string(types_list[index % num_types]) + '>', Tags } ), index++)... };
\
6486 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
6487 using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \
6494 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6495 template<typename TestType> \
6496 static void TestFuncName()
6498 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6499 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
6500 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__)
6502 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
6503 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__ ) )
6506 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6507 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
6508 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__)
6510 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
6511 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__ ) )
6514 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\
6515 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6516 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6517 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6518 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6519 template<typename TestType> static void TestFunc(); \
6521 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
6522 INTERNAL_CATCH_TYPE_GEN\
6523 template<typename... Types> \
6525 void reg_tests() { \
6527 using expander = size_t[]; \
6528 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };
\
6531 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
6532 using TestInit = typename convert<TestName, TmplList>::type; \
6538 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6539 template<typename TestType> \
6540 static void TestFunc()
6542 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \
6543 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 )
6546 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
6547 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6548 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6549 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
6550 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6551 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6553 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
6554 INTERNAL_CATCH_TYPE_GEN\
6555 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
6556 INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
6557 INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))\
6558 template<typename...Types> \
6559 struct TestNameClass{\
6562 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
6563 using expander = size_t[];\
6564 (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };
\
6567 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
6568 TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
6573 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6574 INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
6576 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6577 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
6578 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__ )
6580 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
6581 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__ ) )
6584 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6585 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
6586 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__ )
6588 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
6589 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__ ) )
6592 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\
6593 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6594 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6595 CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
6596 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6597 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6598 template<typename TestType> \
6599 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
6603 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) {\
6604 INTERNAL_CATCH_TYPE_GEN \
6605 INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
6606 template<typename...Types>\
6607 struct TestNameClass{\
6609 std::size_t index = 0;\
6610 using expander = std::size_t[];\
6611 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
6612 constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
6613 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
6614 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + std::string(types_list[index % num_types]) + '>', Tags } ), index++)... };
\
6617 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
6618 using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\
6625 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6626 template<typename TestType> \
6627 void TestName<TestType>::test()
6629 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6630 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
6631 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__ )
6633 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
6634 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__ ) )
6637 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6638 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
6639 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__ )
6641 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
6642 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__ ) )
6645 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \
6646 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6647 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6648 CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
6649 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
6650 template<typename TestType> \
6651 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
6655 namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
6656 INTERNAL_CATCH_TYPE_GEN\
6657 template<typename...Types>\
6658 struct TestNameClass{\
6661 using expander = size_t[];\
6662 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };
\
6665 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
6666 using TestInit = typename convert<TestNameClass, TmplList>::type;\
6672 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6673 template<typename TestType> \
6674 void TestName<TestType>::test()
6676 #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \
6677 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 )
6683 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
6685 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6686 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
6687 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ )
6688 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6689 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
6690 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ )
6691 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ )
6692 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ )
6693 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
6694 #define CATCH_TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__)
6695 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ )
6697 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )
6698 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) )
6699 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6700 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
6701 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) )
6702 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) )
6703 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6704 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
6705 #define CATCH_TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE( __VA_ARGS__ ) )
6706 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6709 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
6711 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6712 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)
6713 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)
6714 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)
6715 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ )
6717 #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) )
6718 #define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) )
6719 #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) )
6720 #define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) )
6724 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
6725 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
6726 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6727 #define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6728 #define CATCH_TEMPLATE_LIST_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE(__VA_ARGS__)
6729 #define CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6731 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
6733 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6734 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
6735 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ )
6736 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6737 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
6738 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ )
6739 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ )
6740 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ )
6741 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ )
6742 #define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__)
6743 #define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ )
6745 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )
6746 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) )
6747 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6748 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
6749 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) )
6750 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) )
6751 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6752 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) )
6753 #define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE( __VA_ARGS__ ) )
6754 #define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) )
6757 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
6759 #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
6760 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__)
6761 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__)
6762 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__)
6763 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ )
6765 #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) )
6766 #define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) )
6767 #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) )
6768 #define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) )
6772 #define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
6773 #define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ )
6774 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6775 #define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6776 #define TEMPLATE_LIST_TEST_CASE( ... ) TEMPLATE_TEST_CASE(__VA_ARGS__)
6777 #define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )
6785 #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED
6786 #define CATCH_TEST_CASE_INFO_HPP_INCLUDED
6794 #pragma clang diagnostic push
6795 #pragma clang diagnostic ignored "-Wpadded"
6813 friend bool operator< (
Tag const& lhs,
Tag const& rhs );
6814 friend bool operator==(
Tag const& lhs,
Tag const& rhs );
6819 enum class TestCaseProperties : uint8_t {
6822 ShouldFail = 1 << 2,
6825 NonPortable = 1 << 5,
6844 bool isHidden()
const;
6845 bool throws()
const;
6846 bool okToFail()
const;
6847 bool expectedToFail()
const;
6850 void addFilenameTag();
6857 std::string tagsAsString()
const;
6862 std::string backingTags;
6865 void internalAppendTag(
StringRef tagString);
6867 std::vector<Tag> tags;
6869 TestCaseProperties properties = TestCaseProperties::None;
6883 m_info(info), m_invoker(invoker) {}
6886 m_invoker->invoke();
6899 #pragma clang diagnostic pop
6905 #ifndef CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
6906 #define CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
6910 #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
6911 #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
6918 using exceptionTranslateFunction = std::string(*)();
6920 class IExceptionTranslator;
6921 using ExceptionTranslators = std::vector<Detail::unique_ptr<IExceptionTranslator const>>;
6926 virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd )
const = 0;
6932 virtual std::string translateActiveException()
const = 0;
6939 #include <exception>
6944 template<
typename T>
6948 ExceptionTranslator( std::string(*translateFunction)( T
const& ) )
6949 : m_translateFunction( translateFunction )
6952 std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd )
const override {
6953 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
6956 std::rethrow_exception(std::current_exception());
6958 return (*it)->translate( it+1, itEnd );
6960 catch( T
const& ex ) {
6961 return m_translateFunction( ex );
6964 return "You should never get here!";
6969 std::string(*m_translateFunction)( T
const& );
6973 template<
typename T>
6975 getMutableRegistryHub().registerTranslator(
6976 Detail::make_unique<ExceptionTranslator<T>>(translateFunction)
6984 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
6985 static std::string translatorName( signature ); \
6986 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
6987 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
6988 namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \
6989 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
6990 static std::string translatorName( signature )
6992 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
6994 #if defined(CATCH_CONFIG_DISABLE)
6995 #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \
6996 static std::string translatorName( signature )
7001 #if !defined(CATCH_CONFIG_DISABLE)
7002 #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
7004 #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
7011 #ifndef CATCH_VERSION_HPP_INCLUDED
7012 #define CATCH_VERSION_HPP_INCLUDED
7022 Version(
unsigned int _majorVersion,
7023 unsigned int _minorVersion,
7024 unsigned int _patchNumber,
7025 char const *
const _branchName,
7026 unsigned int _buildNumber );
7028 unsigned int const majorVersion;
7029 unsigned int const minorVersion;
7030 unsigned int const patchNumber;
7033 char const *
const branchName;
7034 unsigned int const buildNumber;
7036 friend std::ostream& operator << ( std::ostream& os,
Version const& version );
7039 Version const& libraryVersion();
7045 #ifndef CATCH_VERSION_MACROS_HPP_INCLUDED
7046 #define CATCH_VERSION_MACROS_HPP_INCLUDED
7048 #define CATCH_VERSION_MAJOR 3
7049 #define CATCH_VERSION_MINOR 0
7050 #define CATCH_VERSION_PATCH 1
7068 #ifndef CATCH_GENERATORS_ALL_HPP_INCLUDED
7069 #define CATCH_GENERATORS_ALL_HPP_INCLUDED
7073 #ifndef CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED
7074 #define CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED
7076 #include <exception>
7084 const char*
const m_msg =
"";
7091 const char* what()
const noexcept
override final;
7099 #ifndef CATCH_GENERATORS_HPP_INCLUDED
7100 #define CATCH_GENERATORS_HPP_INCLUDED
7104 #ifndef CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED
7105 #define CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED
7112 namespace Generators {
7116 mutable std::string m_stringReprCache;
7127 virtual bool next() = 0;
7130 virtual std::string stringifyImpl()
const = 0;
7153 std::size_t currentElementIndex()
const {
return m_currentElementIndex; }
7168 StringRef currentElementAsString()
const;
7177 virtual auto hasGenerator()
const ->
bool = 0;
7191 namespace Generators {
7197 void throw_generator_exception(
char const * msg);
7201 template<
typename T>
7203 std::string stringifyImpl()
const override {
7204 return ::Catch::Detail::stringify( get() );
7218 virtual T
const& get()
const = 0;
7222 template <
typename T>
7225 template <
typename T>
7231 m_generator(generator) {}
7235 T
const& get()
const {
7236 return m_generator->get();
7239 return m_generator->countedNext();
7244 template<
typename T>
7255 T
const& get()
const override {
7263 template<
typename T>
7265 static_assert(!std::is_same<T, bool>::value,
7266 "FixedValuesGenerator does not support bools because of std::vector<bool>"
7267 "specialization, use SingleValue Generator instead.");
7268 std::vector<T> m_values;
7273 T
const& get()
const override {
7274 return m_values[m_idx];
7278 return m_idx < m_values.size();
7282 template <
typename T,
typename DecayedT = std::decay_t<T>>
7283 GeneratorWrapper<DecayedT> value( T&& value ) {
7284 return GeneratorWrapper<DecayedT>(
7285 Catch::Detail::make_unique<SingleValueGenerator<DecayedT>>(
7288 template <
typename T>
7289 GeneratorWrapper<T> values(std::initializer_list<T> values) {
7290 return GeneratorWrapper<T>(Catch::Detail::make_unique<FixedValuesGenerator<T>>(values));
7293 template<
typename T>
7295 std::vector<GeneratorWrapper<T>> m_generators;
7296 size_t m_current = 0;
7299 m_generators.emplace_back(
CATCH_MOVE( generator ) );
7301 void add_generator( T
const& val ) {
7302 m_generators.emplace_back( value( val ) );
7304 void add_generator( T&& val ) {
7305 m_generators.emplace_back( value(
CATCH_MOVE( val ) ) );
7307 template <
typename U>
7308 std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value>
7309 add_generator( U&& val ) {
7313 template <
typename U>
void add_generators( U&& valueOrGenerator ) {
7317 template <
typename U,
typename... Gs>
7318 void add_generators( U&& valueOrGenerator, Gs&&... moreGenerators ) {
7324 template <
typename... Gs>
7326 m_generators.reserve(
sizeof...(Gs));
7330 T
const& get()
const override {
7331 return m_generators[m_current].get();
7335 if (m_current >= m_generators.size()) {
7338 const bool current_status = m_generators[m_current].next();
7339 if (!current_status) {
7342 return m_current < m_generators.size();
7347 template <
typename... Ts>
7348 GeneratorWrapper<std::tuple<std::decay_t<Ts>...>>
7349 table( std::initializer_list<std::tuple<std::decay_t<Ts>...>> tuples ) {
7350 return values<std::tuple<Ts...>>( tuples );
7354 template <
typename T>
7357 template<
typename T,
typename... Gs>
7361 template<
typename T>
7362 auto makeGenerators( GeneratorWrapper<T>&& generator ) -> Generators<T> {
7365 template<
typename T,
typename... Gs>
7366 auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<std::decay_t<T>> {
7369 template<
typename T,
typename U,
typename... Gs>
7370 auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> {
7374 auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo
const& lineInfo ) -> IGeneratorTracker&;
7376 template<
typename L>
7380 auto generate( StringRef generatorName, SourceLineInfo
const& lineInfo, L
const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
7381 using UnderlyingType =
typename decltype(generatorExpression())::
type;
7383 IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo );
7384 if (!tracker.hasGenerator()) {
7385 tracker.setGenerator(Catch::Detail::make_unique<Generators<UnderlyingType>>(generatorExpression()));
7388 auto const& generator =
static_cast<IGenerator<UnderlyingType> const&
>( *tracker.getGenerator() );
7389 return generator.get();
7395 #define GENERATE( ... ) \
7396 Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
7397 CATCH_INTERNAL_LINEINFO, \
7398 [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
7399 #define GENERATE_COPY( ... ) \
7400 Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
7401 CATCH_INTERNAL_LINEINFO, \
7402 [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
7403 #define GENERATE_REF( ... ) \
7404 Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
7405 CATCH_INTERNAL_LINEINFO, \
7406 [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
7411 #ifndef CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED
7412 #define CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED
7418 namespace Generators {
7420 template <
typename T>
7423 size_t m_returned = 0;
7430 assert(target != 0 &&
"Empty generators are not allowed");
7432 T
const& get()
const override {
7433 return m_generator.get();
7437 if (m_returned >= m_target) {
7441 const auto success = m_generator.next();
7445 m_returned = m_target;
7451 template <
typename T>
7452 GeneratorWrapper<T> take(
size_t target, GeneratorWrapper<T>&& generator) {
7453 return GeneratorWrapper<T>(Catch::Detail::make_unique<TakeGenerator<T>>(target,
CATCH_MOVE(generator)));
7457 template <
typename T,
typename Predicate>
7460 Predicate m_predicate;
7462 template <
typename P = Predicate>
7467 if (!m_predicate(m_generator.get())) {
7470 auto has_initial_value = next();
7471 if (!has_initial_value) {
7472 Detail::throw_generator_exception(
"No valid value found in filtered generator");
7477 T
const& get()
const override {
7478 return m_generator.get();
7482 bool success = m_generator.next();
7486 while (!m_predicate(m_generator.get()) && (success = m_generator.next()) ==
true);
7492 template <
typename T,
typename Predicate>
7493 GeneratorWrapper<T> filter(Predicate&& pred, GeneratorWrapper<T>&& generator) {
7494 return GeneratorWrapper<T>(Catch::Detail::make_unique<FilterGenerator<T, Predicate>>(
CATCH_FORWARD(pred),
CATCH_MOVE(generator)));
7497 template <
typename T>
7499 static_assert(!std::is_same<T, bool>::value,
7500 "RepeatGenerator currently does not support bools"
7501 "because of std::vector<bool> specialization");
7503 mutable std::vector<T> m_returned;
7504 size_t m_target_repeats;
7505 size_t m_current_repeat = 0;
7506 size_t m_repeat_index = 0;
7510 m_target_repeats(repeats)
7512 assert(m_target_repeats > 0 &&
"Repeat generator must repeat at least once");
7515 T
const& get()
const override {
7516 if (m_current_repeat == 0) {
7517 m_returned.push_back(m_generator.get());
7518 return m_returned.back();
7520 return m_returned[m_repeat_index];
7530 if (m_current_repeat == 0) {
7531 const auto success = m_generator.next();
7535 return m_current_repeat < m_target_repeats;
7540 if (m_repeat_index == m_returned.size()) {
7544 return m_current_repeat < m_target_repeats;
7548 template <
typename T>
7549 GeneratorWrapper<T> repeat(
size_t repeats, GeneratorWrapper<T>&& generator) {
7550 return GeneratorWrapper<T>(Catch::Detail::make_unique<RepeatGenerator<T>>(repeats,
CATCH_MOVE(generator)));
7553 template <
typename T,
typename U,
typename Func>
7561 template <
typename F2 = Func>
7565 m_cache(m_function(m_generator.get()))
7568 T
const& get()
const override {
7572 const auto success = m_generator.next();
7574 m_cache = m_function(m_generator.get());
7580 template <
typename Func,
typename U,
typename T = FunctionReturnType<Func, U>>
7581 GeneratorWrapper<T> map(Func&&
function, GeneratorWrapper<U>&& generator) {
7582 return GeneratorWrapper<T>(
7587 template <
typename T,
typename U,
typename Func>
7588 GeneratorWrapper<T> map(Func&&
function, GeneratorWrapper<U>&& generator) {
7589 return GeneratorWrapper<T>(
7594 template <
typename T>
7596 std::vector<T> m_chunk;
7597 size_t m_chunk_size;
7599 bool m_used_up =
false;
7602 m_chunk_size(size), m_generator(
CATCH_MOVE(generator))
7604 m_chunk.reserve(m_chunk_size);
7605 if (m_chunk_size != 0) {
7606 m_chunk.push_back(m_generator.get());
7607 for (
size_t i = 1; i < m_chunk_size; ++i) {
7608 if (!m_generator.next()) {
7609 Detail::throw_generator_exception(
"Not enough values to initialize the first chunk");
7611 m_chunk.push_back(m_generator.get());
7615 std::vector<T>
const& get()
const override {
7620 for (
size_t idx = 0; idx < m_chunk_size; ++idx) {
7621 if (!m_generator.next()) {
7624 m_chunk.push_back(m_generator.get());
7630 template <
typename T>
7631 GeneratorWrapper<std::vector<T>> chunk(
size_t size, GeneratorWrapper<T>&& generator) {
7632 return GeneratorWrapper<std::vector<T>>(
7633 Catch::Detail::make_unique<ChunkGenerator<T>>(size,
CATCH_MOVE(generator))
7644 #ifndef CATCH_GENERATORS_RANDOM_HPP_INCLUDED
7645 #define CATCH_GENERATORS_RANDOM_HPP_INCLUDED
7649 #ifndef CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED
7650 #define CATCH_RANDOM_NUMBER_GENERATOR_HPP_INCLUDED
7662 using state_type = std::uint64_t;
7664 using result_type = std::uint32_t;
7665 static constexpr result_type (min)() {
7668 static constexpr result_type (max)() {
7669 return static_cast<result_type
>(-1);
7677 void seed(result_type seed_);
7678 void discard(uint64_t skip);
7680 result_type operator()();
7690 std::uint64_t m_state;
7695 static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL;
7705 namespace Generators {
7710 std::uint32_t getSeed();
7713 template <
typename Float>
7716 std::uniform_real_distribution<Float> m_dist;
7717 Float m_current_number;
7722 static_cast<void>(next());
7725 Float
const& get()
const override {
7726 return m_current_number;
7729 m_current_number = m_dist(m_rng);
7734 template <
typename Integer>
7737 std::uniform_int_distribution<Integer> m_dist;
7738 Integer m_current_number;
7743 static_cast<void>(next());
7746 Integer
const& get()
const override {
7747 return m_current_number;
7750 m_current_number = m_dist(m_rng);
7757 template <
typename T>
7758 std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value,
7759 GeneratorWrapper<T>>
7761 return GeneratorWrapper<T>(
7762 Catch::Detail::make_unique<RandomIntegerGenerator<T>>(a, b, Detail::getSeed())
7766 template <
typename T>
7767 std::enable_if_t<std::is_floating_point<T>::value,
7768 GeneratorWrapper<T>>
7770 return GeneratorWrapper<T>(
7771 Catch::Detail::make_unique<RandomFloatingGenerator<T>>(a, b, Detail::getSeed())
7783 #ifndef CATCH_GENERATORS_RANGE_HPP_INCLUDED
7784 #define CATCH_GENERATORS_RANGE_HPP_INCLUDED
7788 #include <type_traits>
7791 namespace Generators {
7794 template <
typename T>
7806 m_positive(m_step > T(0))
7808 assert(m_current != m_end &&
"Range start and end cannot be equal");
7809 assert(m_step != T(0) &&
"Step size cannot be zero");
7810 assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) &&
"Step moves away from end");
7817 T
const& get()
const override {
7822 m_current += m_step;
7823 return (m_positive) ? (m_current < m_end) : (m_current > m_end);
7827 template <
typename T>
7828 GeneratorWrapper<T> range(T
const& start, T
const& end, T
const& step) {
7829 static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value,
"Type must be numeric");
7830 return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end, step));
7833 template <
typename T>
7834 GeneratorWrapper<T> range(T
const& start, T
const& end) {
7835 static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value,
"Type must be an integer");
7836 return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end));
7840 template <
typename T>
7842 static_assert(!std::is_same<T, bool>::value,
7843 "IteratorGenerator currently does not support bools"
7844 "because of std::vector<bool> specialization");
7846 std::vector<T> m_elems;
7847 size_t m_current = 0;
7849 template <
typename InputIterator,
typename InputSentinel>
7851 if (m_elems.empty()) {
7852 Detail::throw_generator_exception(
"IteratorGenerator received no valid values");
7856 T
const& get()
const override {
7857 return m_elems[m_current];
7862 return m_current != m_elems.size();
7866 template <
typename InputIterator,
7867 typename InputSentinel,
7868 typename ResultType =
typename std::iterator_traits<InputIterator>::value_type>
7869 GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) {
7870 return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(from, to));
7873 template <
typename Container,
7874 typename ResultType =
typename Container::value_type>
7875 GeneratorWrapper<ResultType> from_range(Container
const& cnt) {
7876 return GeneratorWrapper<ResultType>(Catch::Detail::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end()));
7903 #ifndef CATCH_INTERFACES_ALL_HPP_INCLUDED
7904 #define CATCH_INTERFACES_ALL_HPP_INCLUDED
7908 #ifndef CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED
7909 #define CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED
7916 struct ReporterConfig;
7918 class IEventListener;
7919 using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
7928 virtual std::string getDescription()
const = 0;
7946 #ifndef CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED
7947 #define CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED
7951 #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED
7952 #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED
7982 class IEventListener;
7983 using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
7984 class IReporterFactory;
7985 using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
7986 struct ReporterConfig;
7987 class EventListenerFactory;
7991 using FactoryMap = std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess>;
7992 using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>;
7996 virtual FactoryMap
const& getFactories()
const = 0;
7997 virtual Listeners
const& getListeners()
const = 0;
8005 #ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED
8006 #define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED
8018 virtual TagAlias const*
find( std::string
const& alias )
const = 0;
8019 virtual std::string expandAliases( std::string
const& unexpandedTestSpec )
const = 0;
8040 #ifndef CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
8041 #define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
8044 #if defined(__ANDROID__)
8045 # define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
8049 #if defined( CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE ) && \
8050 !defined( CATCH_CONFIG_NO_ANDROID_LOGWRITE ) && \
8051 !defined( CATCH_CONFIG_ANDROID_LOGWRITE )
8052 # define CATCH_CONFIG_ANDROID_LOGWRITE
8067 #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
8068 #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
8070 #if defined(_MSC_VER)
8071 # if _MSC_VER >= 1900
8072 # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
8077 #include <exception>
8079 #if defined(__cpp_lib_uncaught_exceptions) \
8080 && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
8082 # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
8086 #if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \
8087 && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \
8088 && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
8090 # define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
8097 #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED
8098 #define CATCH_CONSOLE_WIDTH_HPP_INCLUDED
8100 #ifndef CATCH_CONFIG_CONSOLE_WIDTH
8101 #define CATCH_CONFIG_CONSOLE_WIDTH 80
8107 #ifndef CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
8108 #define CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
8112 #include <initializer_list>
8118 #if defined(CATCH_CPP17_OR_GREATER) || defined(_MSC_VER)
8125 # if !defined(__cpp_lib_nonmember_container_access)
8126 # define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
8130 #define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
8138 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
8139 template <
typename Container>
8140 constexpr
auto empty(Container
const& cont) -> decltype(cont.empty()) {
8141 return cont.empty();
8143 template <
typename T, std::
size_t N>
8144 constexpr
bool empty(
const T (&)[N]) noexcept {
8150 template <
typename T>
8151 constexpr
bool empty(std::initializer_list<T> list) noexcept {
8152 return list.size() > 0;
8156 template <
typename Container>
8157 constexpr
auto size(Container
const& cont) -> decltype(cont.size()) {
8160 template <
typename T, std::
size_t N>
8174 #ifndef CATCH_DEBUG_CONSOLE_HPP_INCLUDED
8175 #define CATCH_DEBUG_CONSOLE_HPP_INCLUDED
8180 void writeToDebugConsole( std::string
const& text );
8186 #ifndef CATCH_DEBUGGER_HPP_INCLUDED
8187 #define CATCH_DEBUGGER_HPP_INCLUDED
8191 bool isDebuggerActive();
8194 #ifdef CATCH_PLATFORM_MAC
8196 #if defined(__i386__) || defined(__x86_64__)
8197 #define CATCH_TRAP() __asm__("int $3\n" : : )
8198 #elif defined(__aarch64__)
8199 #define CATCH_TRAP() __asm__(".inst 0xd43e0000")
8202 #elif defined(CATCH_PLATFORM_IPHONE)
8205 #if defined(__i386__) || defined(__x86_64__)
8206 #define CATCH_TRAP() __asm__("int $3")
8207 #elif defined(__aarch64__)
8208 #define CATCH_TRAP() __asm__(".inst 0xd4200000")
8209 #elif defined(__arm__) && !defined(__thumb__)
8210 #define CATCH_TRAP() __asm__(".inst 0xe7f001f0")
8211 #elif defined(__arm__) && defined(__thumb__)
8212 #define CATCH_TRAP() __asm__(".inst 0xde01")
8215 #elif defined(CATCH_PLATFORM_LINUX)
8219 #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
8220 #define CATCH_TRAP() asm volatile ("int $3")
8224 #define CATCH_TRAP() raise(SIGTRAP)
8226 #elif defined(_MSC_VER)
8227 #define CATCH_TRAP() __debugbreak()
8228 #elif defined(__MINGW32__)
8229 extern "C" __declspec(dllimport)
void __stdcall DebugBreak();
8230 #define CATCH_TRAP() DebugBreak()
8233 #ifndef CATCH_BREAK_INTO_DEBUGGER
8235 #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
8237 #define CATCH_BREAK_INTO_DEBUGGER() []{}()
8244 #ifndef CATCH_ENFORCE_HPP_INCLUDED
8245 #define CATCH_ENFORCE_HPP_INCLUDED
8248 #include <exception>
8251 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
8252 template <
typename Ex>
8254 void throw_exception(Ex
const& e) {
8259 void throw_exception(std::exception
const& e);
8263 void throw_logic_error(std::string
const& msg);
8265 void throw_domain_error(std::string
const& msg);
8267 void throw_runtime_error(std::string
const& msg);
8271 #define CATCH_MAKE_MSG(...) \
8272 (Catch::ReusableStringStream() << __VA_ARGS__).str()
8274 #define CATCH_INTERNAL_ERROR(...) \
8275 Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__))
8277 #define CATCH_ERROR(...) \
8278 Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ ))
8280 #define CATCH_RUNTIME_ERROR(...) \
8281 Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ ))
8283 #define CATCH_ENFORCE( condition, ... ) \
8284 do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false)
8290 #ifndef CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED
8291 #define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED
8304 std::vector<Catch::Detail::unique_ptr<EnumInfo>> m_enumInfos;
8309 std::vector<StringRef> parseEnums(
StringRef enums );
8318 #ifndef CATCH_ERRNO_GUARD_HPP_INCLUDED
8319 #define CATCH_ERRNO_GUARD_HPP_INCLUDED
8340 #ifndef CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
8341 #define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
8353 std::string translateActiveException()
const override;
8354 std::string tryTranslators()
const;
8357 ExceptionTranslators m_translators;
8364 #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED
8365 #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED
8383 bool m_started =
false;
8388 void engage_platform();
8389 void disengage_platform() noexcept;
8396 assert(!m_started &&
"Handler cannot be installed twice.");
8401 void disengage() noexcept {
8402 assert(m_started &&
"Handler cannot be uninstalled without being installed first");
8404 disengage_platform();
8413 m_handler(handler) {
8414 m_handler->engage();
8417 m_handler->disengage();
8426 #ifndef CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED
8427 #define CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED
8431 #ifndef CATCH_POLYFILLS_HPP_INCLUDED
8432 #define CATCH_POLYFILLS_HPP_INCLUDED
8435 bool isnan(
float f);
8436 bool isnan(
double d);
8450 uint32_t convertToBits(
float f);
8451 uint64_t convertToBits(
double d);
8457 #if defined( __GNUC__ ) || defined( __clang__ )
8458 # pragma GCC diagnostic push
8462 # pragma GCC diagnostic ignored "-Wfloat-equal"
8482 template <
typename FP>
8484 assert( std::numeric_limits<FP>::is_iec559 &&
8485 "ulpDistance assumes IEEE-754 format for floating point types" );
8486 assert( !Catch::isnan( lhs ) &&
8487 "Distance between NaN and number is not meaningful" );
8488 assert( !Catch::isnan( rhs ) &&
8489 "Distance between NaN and number is not meaningful" );
8493 if ( lhs == rhs ) {
return 0; }
8496 static constexpr FP positive_zero{};
8499 if ( lhs == positive_zero ) { lhs = positive_zero; }
8500 if ( rhs == positive_zero ) { rhs = positive_zero; }
8504 if ( std::signbit( lhs ) != std::signbit( rhs ) ) {
8505 return ulpDistance( std::abs( lhs ), positive_zero ) +
8512 uint64_t lc = Detail::convertToBits( lhs );
8513 uint64_t rc = Detail::convertToBits( rhs );
8518 std::swap( lc, rc );
8524 #if defined( __GNUC__ ) || defined( __clang__ )
8525 # pragma GCC diagnostic pop
8534 #ifndef CATCH_ISTREAM_HPP_INCLUDED
8535 #define CATCH_ISTREAM_HPP_INCLUDED
8548 virtual std::ostream& stream() = 0;
8574 auto makeStream( std::string
const& filename ) -> Detail::unique_ptr<IStream>;
8581 #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED
8582 #define CATCH_LEAK_DETECTOR_HPP_INCLUDED
8595 #ifndef CATCH_LIST_HPP_INCLUDED
8596 #define CATCH_LIST_HPP_INCLUDED
8605 class IEventListener;
8610 std::string name, description;
8614 std::string description;
8619 std::string all()
const;
8621 std::set<StringRef> spellings;
8632 #ifndef CATCH_OUTPUT_REDIRECT_HPP_INCLUDED
8633 #define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED
8643 std::ostream& m_originalStream;
8644 std::ostream& m_redirectionStream;
8645 std::streambuf* m_prevBuf;
8648 RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream );
8657 auto str()
const -> std::string;
8669 auto str()
const -> std::string;
8682 std::string& m_redirectedCout;
8683 std::string& m_redirectedCerr;
8688 #if defined(CATCH_CONFIG_NEW_CAPTURE)
8696 TempFile(TempFile
const&) =
delete;
8697 TempFile& operator=(TempFile
const&) =
delete;
8698 TempFile(TempFile&&) =
delete;
8699 TempFile& operator=(TempFile&&) =
delete;
8704 std::FILE* getFile();
8705 std::string getContents();
8708 std::FILE* m_file =
nullptr;
8709 #if defined(_MSC_VER)
8710 char m_buffer[L_tmpnam] = { 0 };
8715 class OutputRedirect {
8717 OutputRedirect(OutputRedirect
const&) =
delete;
8718 OutputRedirect& operator=(OutputRedirect
const&) =
delete;
8719 OutputRedirect(OutputRedirect&&) =
delete;
8720 OutputRedirect& operator=(OutputRedirect&&) =
delete;
8723 OutputRedirect(std::string& stdout_dest, std::string& stderr_dest);
8727 int m_originalStdout = -1;
8728 int m_originalStderr = -1;
8729 TempFile m_stdoutFile;
8730 TempFile m_stderrFile;
8731 std::string& m_stdoutDest;
8732 std::string& m_stderrDest;
8742 #ifndef CATCH_REPORTER_REGISTRY_HPP_INCLUDED
8743 #define CATCH_REPORTER_REGISTRY_HPP_INCLUDED
8761 FactoryMap
const& getFactories()
const override;
8762 Listeners
const& getListeners()
const override;
8765 FactoryMap m_factories;
8766 Listeners m_listeners;
8773 #ifndef CATCH_RUN_CONTEXT_HPP_INCLUDED
8774 #define CATCH_RUN_CONTEXT_HPP_INCLUDED
8778 #ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
8779 #define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
8786 namespace TestCaseTracking {
8794 return lhs.name == rhs.name
8795 && lhs.location == rhs.location;
8806 using Children = std::vector<ITrackerPtr>;
8814 CompletedSuccessfully,
8819 Children m_children;
8820 CycleState m_runState = NotStarted;
8824 m_nameAndLocation( nameAndLoc ),
8831 return m_nameAndLocation;
8845 bool isSuccessfullyCompleted()
const;
8847 bool isOpen()
const;
8849 bool hasStarted()
const;
8852 virtual void close() = 0;
8853 virtual void fail() = 0;
8854 void markAsNeedingAnotherRun();
8866 return !m_children.empty();
8879 virtual bool isSectionTracker()
const;
8886 virtual bool isGeneratorTracker()
const;
8898 ITracker* m_currentTracker =
nullptr;
8899 RunState m_runState = NotStarted;
8907 void completeCycle();
8909 bool completedCycle()
const;
8911 void setCurrentTracker(
ITracker* tracker );
8922 bool isComplete()
const override;
8926 void close()
override;
8927 void fail()
override;
8930 void moveToParent();
8935 std::vector<StringRef> m_filters;
8936 std::string m_trimmed_name;
8940 bool isSectionTracker()
const override;
8942 bool isComplete()
const override;
8948 void addInitialFilters( std::vector<std::string>
const& filters );
8949 void addNextFilters( std::vector<StringRef>
const& filters );
8951 std::vector<StringRef>
const& getFilters()
const;
8970 class IMutableContext;
8971 class IGeneratorTracker;
8997 ResultWas::OfType resultType,
9000 void handleUnexpectedExceptionNotThrown
9003 void handleUnexpectedInflightException
9005 std::string
const& message,
9007 void handleIncomplete
9011 ResultWas::OfType resultType,
9014 bool sectionStarted(
SectionInfo const& sectionInfo,
Counts& assertions )
override;
9017 void sectionEndedEarly(
SectionEndInfo const& endInfo )
override;
9021 void benchmarkPreparing(
StringRef name )
override;
9022 void benchmarkStarting(
BenchmarkInfo const& info )
override;
9024 void benchmarkFailed(
StringRef error )
override;
9026 void pushScopedMessage(
MessageInfo const& message )
override;
9027 void popScopedMessage(
MessageInfo const& message )
override;
9029 void emplaceUnscopedMessage(
MessageBuilder const& builder )
override;
9031 std::string getCurrentTestName()
const override;
9035 void exceptionEarlyReported()
override;
9037 void handleFatalErrorCondition(
StringRef message )
override;
9039 bool lastAssertionPassed()
override;
9041 void assertionPassed()
override;
9045 bool aborting()
const;
9049 void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr );
9050 void invokeActiveTestCase();
9052 void resetAssertionInfo();
9053 bool testForMissingAssertions(
Counts& assertions );
9058 ResultWas::OfType resultType,
9066 void handleUnfinishedSections();
9071 ITracker* m_testCaseTracker =
nullptr;
9077 std::vector<MessageInfo> m_messages;
9078 std::vector<ScopedMessage> m_messageScopes;
9080 std::vector<SectionEndInfo> m_unfinishedSections;
9081 std::vector<ITracker*> m_activeSections;
9084 bool m_lastAssertionPassed =
false;
9085 bool m_shouldReportUnexpected =
true;
9086 bool m_includeSuccessfulResults;
9089 void seedRng(
IConfig const& config);
9090 unsigned int rngSeed();
9096 #ifndef CATCH_SHARDING_HPP_INCLUDED
9097 #define CATCH_SHARDING_HPP_INCLUDED
9104 template<
typename Container>
9106 assert(shardCount > shardIndex);
9108 if (shardCount == 1) {
9114 const std::size_t shardSize = totalTestCount / shardCount;
9115 const std::size_t leftoverTests = totalTestCount % shardCount;
9117 const std::size_t startIndex = shardIndex * shardSize + (std::min)(shardIndex, leftoverTests);
9118 const std::size_t endIndex = (shardIndex + 1) * shardSize + (std::min)(shardIndex + 1, leftoverTests);
9120 auto startIterator = std::next(
container.begin(),
static_cast<std::ptrdiff_t
>(startIndex));
9121 auto endIterator = std::next(
container.begin(),
static_cast<std::ptrdiff_t
>(endIndex));
9123 return Container(startIterator, endIterator);
9131 #ifndef CATCH_SINGLETONS_HPP_INCLUDED
9132 #define CATCH_SINGLETONS_HPP_INCLUDED
9142 void cleanupSingletons();
9145 template<
typename SingletonImplT,
typename InterfaceT = SingletonImplT,
typename MutableInterfaceT = InterfaceT>
9148 static auto getInternal() ->
Singleton* {
9152 addSingleton( s_instance );
9158 static auto get() -> InterfaceT
const& {
9159 return *getInternal();
9161 static auto getMutable() -> MutableInterfaceT& {
9162 return *getInternal();
9171 #ifndef CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED
9172 #define CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED
9176 #include <exception>
9181 #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
9183 void add(std::exception_ptr
const& exception) noexcept;
9184 std::vector<std::exception_ptr>
const& getExceptions()
const noexcept;
9186 std::vector<std::exception_ptr> m_exceptions;
9196 #ifndef CATCH_STDSTREAMS_HPP_INCLUDED
9197 #define CATCH_STDSTREAMS_HPP_INCLUDED
9203 std::ostream& cout();
9204 std::ostream& cerr();
9205 std::ostream& clog();
9212 #ifndef CATCH_STRING_MANIP_HPP_INCLUDED
9213 #define CATCH_STRING_MANIP_HPP_INCLUDED
9222 bool startsWith( std::string
const& s, std::string
const& prefix );
9223 bool startsWith( StringRef s,
char prefix );
9224 bool endsWith( std::string
const& s, std::string
const& suffix );
9225 bool endsWith( std::string
const& s,
char suffix );
9226 bool contains( std::string
const& s, std::string
const& infix );
9227 void toLowerInPlace( std::string& s );
9228 std::string toLower( std::string
const& s );
9229 char toLower(
char c );
9231 std::string
trim( std::string
const& str );
9233 StringRef
trim(StringRef ref);
9236 std::vector<StringRef> splitStringRef( StringRef str,
char delimiter );
9237 bool replaceInPlace( std::string& str, std::string
const& replaceThis, std::string
const& withThis );
9250 std::uint64_t m_count;
9259 friend std::ostream& operator << ( std::ostream& os,
pluralise const& pluraliser );
9266 #ifndef CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED
9267 #define CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED
9274 struct SourceLineInfo;
9279 TagAlias const*
find( std::string
const& alias )
const override;
9280 std::string expandAliases( std::string
const& unexpandedTestSpec )
const override;
9281 void add( std::string
const& alias, std::string
const& tag,
SourceLineInfo const& lineInfo );
9284 std::map<std::string, TagAlias> m_registry;
9292 #ifndef CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED
9293 #define CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED
9299 struct TestCaseInfo;
9303 using hash_t = std::uint64_t;
9316 #ifndef CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
9317 #define CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
9324 class TestCaseHandle;
9328 std::vector<TestCaseHandle> sortTests( IConfig
const& config, std::vector<TestCaseHandle>
const& unsortedTestCases );
9330 bool isThrowSafe( TestCaseHandle
const& testCase, IConfig
const& config );
9331 bool matchTest( TestCaseHandle
const& testCase, TestSpec
const& testSpec, IConfig
const& config );
9333 void enforceNoDuplicateTestCases( std::vector<TestCaseHandle>
const& functions );
9335 std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle>
const& testCases, TestSpec
const& testSpec, IConfig
const& config );
9336 std::vector<TestCaseHandle>
const& getAllTestCasesSorted( IConfig
const& config );
9344 std::vector<TestCaseInfo*>
const& getAllInfos()
const override;
9345 std::vector<TestCaseHandle>
const& getAllTests()
const override;
9346 std::vector<TestCaseHandle>
const& getAllTestsSorted(
IConfig const& config )
const override;
9349 std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
9352 std::vector<TestCaseInfo*> m_viewed_test_infos;
9354 std::vector<Detail::unique_ptr<ITestInvoker>> m_invokers;
9355 std::vector<TestCaseHandle> m_handles;
9356 mutable TestRunOrder m_currentSortOrder = TestRunOrder::Declared;
9357 mutable std::vector<TestCaseHandle> m_sortedFunctions;
9363 using TestType = void(*)();
9364 TestType m_testAsFunction;
9367 m_testAsFunction(testAsFunction) {}
9369 void invoke()
const override;
9381 #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
9382 #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
9385 #pragma clang diagnostic push
9386 #pragma clang diagnostic ignored "-Wpadded"
9395 class ITagAliasRegistry;
9398 enum Mode{
None, Name, QuotedName,
Tag, EscapedName };
9400 Mode lastMode =
None;
9401 bool m_exclusion =
false;
9405 std::string m_substring;
9406 std::string m_patternName;
9407 std::vector<std::size_t> m_escapeChars;
9408 TestSpec::Filter m_currentFilter;
9419 bool visitChar(
char c );
9420 void startNewMode( Mode mode );
9421 bool processNoneChar(
char c );
9422 void processNameChar(
char c );
9423 bool processOtherChar(
char c );
9426 bool isControlChar(
char c )
const;
9427 void saveLastMode();
9428 void revertBackToLastMode();
9433 std::string preprocessPattern();
9435 void addNamePattern();
9437 void addTagPattern();
9439 inline void addCharToPattern(
char c) {
9446 TestSpec parseTestSpec( std::string
const& arg );
9451 #pragma clang diagnostic pop
9457 #ifndef CATCH_TEXTFLOW_HPP_INCLUDED
9458 #define CATCH_TEXTFLOW_HPP_INCLUDED
9465 namespace TextFlow {
9478 std::string m_string;
9480 size_t m_width = CATCH_CONFIG_CONSOLE_WIDTH - 1;
9482 size_t m_indent = 0;
9496 size_t m_lineStart = 0;
9498 size_t m_lineLength = 0;
9500 size_t m_parsedTo = 0;
9502 bool m_addHyphen =
false;
9505 m_column( column ), m_lineStart( m_column.m_string.size() ) {}
9511 size_t indentSize()
const;
9515 std::string addIndentAndSuffix(
size_t position,
9516 size_t length )
const;
9519 using difference_type = std::ptrdiff_t;
9520 using value_type = std::string;
9521 using pointer = value_type*;
9522 using reference = value_type&;
9523 using iterator_category = std::forward_iterator_tag;
9527 std::string operator*()
const;
9533 return m_lineStart == other.m_lineStart && &m_column == &other.m_column;
9536 return !operator==( other );
9541 explicit Column( std::string
const& text ): m_string( text ) {}
9543 Column& width(
size_t newWidth ) {
9544 assert( newWidth > 0 );
9548 Column& indent(
size_t newIndent ) {
9549 m_indent = newIndent;
9552 Column& initialIndent(
size_t newIndent ) {
9553 m_initialIndent = newIndent;
9557 size_t width()
const {
return m_width; }
9558 const_iterator begin()
const {
return const_iterator( *
this ); }
9559 const_iterator end()
const {
return { *
this, const_iterator::EndTag{} }; }
9561 friend std::ostream& operator<<( std::ostream& os,
9562 Column
const& col );
9564 Columns operator+( Column
const& other );
9568 Column
Spacer(
size_t spaceWidth );
9571 std::vector<Column> m_columns;
9578 std::vector<Column>
const& m_columns;
9579 std::vector<Column::const_iterator> m_iterators;
9580 size_t m_activeIterators;
9585 using difference_type = std::ptrdiff_t;
9586 using value_type = std::string;
9587 using pointer = value_type*;
9588 using reference = value_type&;
9589 using iterator_category = std::forward_iterator_tag;
9593 auto operator==(
iterator const& other )
const ->
bool {
9594 return m_iterators == other.m_iterators;
9596 auto operator!=(
iterator const& other )
const ->
bool {
9597 return m_iterators != other.m_iterators;
9599 std::string operator*()
const;
9606 iterator end()
const {
return { *
this, iterator::EndTag() }; }
9608 Columns& operator+=( Column
const& col );
9609 Columns operator+( Column
const& col );
9611 friend std::ostream& operator<<( std::ostream& os,
9612 Columns
const& cols );
9620 #ifndef CATCH_TO_STRING_HPP_INCLUDED
9621 #define CATCH_TO_STRING_HPP_INCLUDED
9627 template <
typename T>
9628 std::string to_string(T
const& t) {
9629 #if defined(CATCH_CONFIG_CPP11_TO_STRING)
9630 return std::to_string(t);
9632 ReusableStringStream rss;
9642 #ifndef CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
9643 #define CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
9646 bool uncaught_exceptions();
9652 #ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED
9653 #define CATCH_WINDOWS_H_PROXY_HPP_INCLUDED
9656 #if defined(CATCH_PLATFORM_WINDOWS)
9660 #if !defined(NOMINMAX)
9663 #if !defined(WIN32_LEAN_AND_MEAN)
9664 # define WIN32_LEAN_AND_MEAN
9670 #include <windows.h>
9678 #ifndef CATCH_XMLWRITER_HPP_INCLUDED
9679 #define CATCH_XMLWRITER_HPP_INCLUDED
9686 enum class XmlFormatting {
9692 XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs);
9693 XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs);
9703 enum ForWhat { ForTextNodes, ForAttributes };
9707 void encodeTo( std::ostream& os )
const;
9709 friend std::ostream& operator << ( std::ostream& os,
XmlEncode const& xmlEncode );
9730 XmlFormatting fmt = XmlFormatting::Newline |
9731 XmlFormatting::Indent );
9735 template <
typename T,
9740 typename =
typename std::enable_if_t<
9741 !std::is_convertible<T, StringRef>::value>>
9743 T
const& attribute ) {
9744 m_writer->writeAttribute( name, attribute );
9750 XmlFormatting m_fmt;
9759 XmlWriter& startElement( std::string
const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
9761 ScopedElement scopedElement( std::string
const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
9763 XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent);
9776 template <
typename T,
9781 typename =
typename std::enable_if_t<
9782 !std::is_convertible<T, StringRef>::value>>
9786 return writeAttribute( name, rss.
str() );
9791 XmlFormatting fmt = XmlFormatting::Newline |
9792 XmlFormatting::Indent );
9796 XmlFormatting fmt = XmlFormatting::Newline |
9797 XmlFormatting::Indent );
9799 void writeStylesheetRef(
StringRef url );
9801 void ensureTagClosed();
9805 void applyFormatting(XmlFormatting fmt);
9807 void writeDeclaration();
9809 void newlineIfNecessary();
9811 bool m_tagIsOpen =
false;
9812 bool m_needsNewline =
false;
9813 std::vector<std::string> m_tags;
9814 std::string m_indent;
9835 #ifndef CATCH_MATCHERS_ALL_HPP_INCLUDED
9836 #define CATCH_MATCHERS_ALL_HPP_INCLUDED
9840 #ifndef CATCH_MATCHERS_HPP_INCLUDED
9841 #define CATCH_MATCHERS_HPP_INCLUDED
9845 #ifndef CATCH_MATCHERS_IMPL_HPP_INCLUDED
9846 #define CATCH_MATCHERS_IMPL_HPP_INCLUDED
9851 template<
typename ArgT,
typename MatcherT>
9854 MatcherT
const& m_matcher;
9860 m_matcher( matcher ),
9861 m_matcherString( matcherString )
9864 void streamReconstructedExpression( std::ostream& os )
const override {
9865 os << Catch::Detail::stringify( m_arg )
9867 << m_matcher.toString();
9871 namespace Matchers {
9872 template <
typename ArgT>
9876 using StringMatcher = Matchers::MatcherBase<std::string>;
9878 void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher
const& matcher, StringRef matcherString );
9880 template<
typename ArgT,
typename MatcherT>
9881 auto makeMatchExpr( ArgT && arg, MatcherT
const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
9882 return MatchExpr<ArgT, MatcherT>(
CATCH_FORWARD(arg), matcher, matcherString );
9889 #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
9891 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
9892 INTERNAL_CATCH_TRY { \
9893 catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
9894 } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
9895 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
9900 #define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \
9902 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
9903 if( catchAssertionHandler.allowThrows() ) \
9905 static_cast<void>(__VA_ARGS__ ); \
9906 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
9908 catch( exceptionType const& ex ) { \
9909 catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \
9912 catchAssertionHandler.handleUnexpectedInflightException(); \
9915 catchAssertionHandler.handleThrowingCallSkipped(); \
9916 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
9926 namespace Matchers {
9938 std::string toString()
const;
9942 virtual std::string describe()
const = 0;
9943 mutable std::string m_cachedToString;
9947 template<
typename T>
9950 virtual bool match( T
const& arg )
const = 0;
9955 template<
typename ArgT>
9957 std::vector<MatcherBase<ArgT>
const*> m_matchers;
9967 bool match( ArgT
const& arg )
const override {
9968 for(
auto matcher : m_matchers ) {
9969 if (!matcher->match(arg))
9974 std::string describe()
const override {
9975 std::string description;
9976 description.reserve( 4 + m_matchers.size()*32 );
9977 description +=
"( ";
9979 for(
auto matcher : m_matchers ) {
9983 description +=
" and ";
9984 description += matcher->toString();
9986 description +=
" )";
9991 lhs.m_matchers.push_back(&rhs);
9995 rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
10002 template<
typename ArgT>
10006 template<
typename ArgT>
10009 template<
typename ArgT>
10011 std::vector<MatcherBase<ArgT>
const*> m_matchers;
10019 bool match( ArgT
const& arg )
const override {
10020 for(
auto matcher : m_matchers ) {
10021 if (matcher->match(arg))
10026 std::string describe()
const override {
10027 std::string description;
10028 description.reserve( 4 + m_matchers.size()*32 );
10029 description +=
"( ";
10031 for(
auto matcher : m_matchers ) {
10035 description +=
" or ";
10036 description += matcher->toString();
10038 description +=
" )";
10039 return description;
10043 lhs.m_matchers.push_back(&rhs);
10047 rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
10054 template<
typename ArgT>
10058 template<
typename ArgT>
10061 template<
typename ArgT>
10067 m_underlyingMatcher( underlyingMatcher )
10070 bool match( ArgT
const& arg )
const override {
10071 return !m_underlyingMatcher.match( arg );
10074 std::string describe()
const override {
10075 return "not " + m_underlyingMatcher.toString();
10081 template <
typename T>
10085 template <
typename T>
10086 Detail::MatchAnyOf<T> operator|| (MatcherBase<T>
const& lhs, MatcherBase<T>
const& rhs) {
10087 return Detail::MatchAnyOf<T>{} || lhs || rhs;
10090 template <
typename T>
10091 Detail::MatchNotOf<T> operator! (MatcherBase<T>
const& matcher) {
10092 return Detail::MatchNotOf<T>{ matcher };
10100 #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
10101 #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
10102 #define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
10104 #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
10105 #define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
10107 #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
10108 #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
10110 #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
10112 #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
10113 #define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
10115 #define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0)
10116 #define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
10118 #define CATCH_CHECK_THAT( arg, matcher ) (void)(0)
10119 #define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0)
10121 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE)
10123 #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
10124 #define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
10126 #define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
10127 #define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
10129 #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
10130 #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
10132 #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE)
10134 #define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
10135 #define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
10137 #define CHECK_THROWS_WITH( expr, matcher ) (void)(0)
10138 #define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
10140 #define CHECK_THAT( arg, matcher ) (void)(0)
10141 #define REQUIRE_THAT( arg, matcher ) (void)(0)
10148 #ifndef CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED
10149 #define CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED
10153 #ifndef CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED
10154 #define CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED
10158 #include <algorithm>
10160 #include <type_traits>
10163 namespace Matchers {
10178 template<std::
size_t N, std::
size_t M>
10179 std::array<void const*, N + M> array_cat(std::array<void const*, N> && lhs, std::array<void const*, M> && rhs) {
10180 std::array<void const*, N + M> arr{};
10181 std::copy_n(lhs.begin(), N, arr.begin());
10182 std::copy_n(rhs.begin(), M, arr.begin() + N);
10186 template<std::
size_t N>
10187 std::array<void const*, N+1> array_cat(std::array<void const*, N> && lhs,
void const* rhs) {
10188 std::array<void const*, N+1> arr{};
10189 std::copy_n(lhs.begin(), N, arr.begin());
10194 template<std::
size_t N>
10195 std::array<void const*, N+1> array_cat(
void const* lhs, std::array<void const*, N> && rhs) {
10196 std::array<void const*, N + 1> arr{ {lhs} };
10197 std::copy_n(rhs.begin(), N, arr.begin() + 1);
10201 #if defined( __cpp_lib_logical_traits ) && __cpp_lib_logical_traits >= 201510
10203 using std::conjunction;
10207 template<
typename... Cond>
10210 template<
typename Cond,
typename... Rest>
10211 struct conjunction<Cond, Rest...> : std::integral_constant<bool, Cond::value && conjunction<Rest...>::value> {};
10215 template<
typename T>
10216 using is_generic_matcher = std::is_base_of<
10218 std::remove_cv_t<std::remove_reference_t<T>>
10221 template<
typename... Ts>
10224 template<
typename T>
10225 using is_matcher = std::is_base_of<
10227 std::remove_cv_t<std::remove_reference_t<T>>
10231 template<std::
size_t N,
typename Arg>
10232 bool match_all_of(Arg&&, std::array<void const*, N>
const&, std::index_sequence<>) {
10237 bool match_all_of(Arg&& arg, std::array<void const*, N>
const& matchers, std::index_sequence<Idx, Indices...>) {
10238 return static_cast<T const*
>(matchers[Idx])->match(arg) && match_all_of<MatcherTs...>(arg, matchers,
std::index_sequence<Indices...>{});
10242 template<std::
size_t N,
typename Arg>
10243 bool match_any_of(Arg&&, std::array<void const*, N>
const&, std::index_sequence<>) {
10248 bool match_any_of(Arg&& arg, std::array<void const*, N>
const& matchers, std::index_sequence<Idx, Indices...>) {
10249 return static_cast<T const*
>(matchers[Idx])->match(arg) || match_any_of<MatcherTs...>(arg, matchers,
std::index_sequence<Indices...>{});
10252 std::string describe_multi_matcher(StringRef combine, std::string
const* descriptions_begin, std::string
const* descriptions_end);
10254 template<
typename... MatcherTs,
std::size_t... Idx>
10255 std::string describe_multi_matcher(StringRef combine, std::array<
void const*,
sizeof...(MatcherTs)>
const& matchers, std::index_sequence<Idx...>) {
10256 std::array<std::string,
sizeof...(MatcherTs)> descriptions {{
10257 static_cast<MatcherTs const*
>(matchers[Idx])->toString()...
10260 return describe_multi_matcher(combine, descriptions.data(), descriptions.data() + descriptions.size());
10264 template<
typename... MatcherTs>
10272 MatchAllOfGeneric(MatcherTs
const&... matchers) : m_matchers{ {std::addressof(matchers)...} } {}
10273 explicit MatchAllOfGeneric(std::array<
void const*,
sizeof...(MatcherTs)> matchers) : m_matchers{matchers} {}
10275 template<
typename Arg>
10276 bool match(Arg&& arg)
const {
10277 return match_all_of<MatcherTs...>(arg, m_matchers, std::index_sequence_for<MatcherTs...>{});
10280 std::string describe()
const override {
10281 return describe_multi_matcher<MatcherTs...>(
" and "_sr, m_matchers, std::index_sequence_for<MatcherTs...>{});
10287 std::array<
void const*,
sizeof...( MatcherTs )> m_matchers;
10291 template<
typename... MatchersRHS>
10300 template<
typename MatcherRHS>
10301 friend std::enable_if_t<is_matcher<MatcherRHS>::value,
10304 MatcherRHS
const& rhs) {
10309 template<
typename MatcherLHS>
10310 friend std::enable_if_t<is_matcher<MatcherLHS>::value,
10312 MatcherLHS
const& lhs,
10314 return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(
static_cast<void const*
>(std::addressof(lhs)),
CATCH_MOVE(rhs.m_matchers))};
10319 template<
typename... MatcherTs>
10327 MatchAnyOfGeneric(MatcherTs
const&... matchers) : m_matchers{ {std::addressof(matchers)...} } {}
10328 explicit MatchAnyOfGeneric(std::array<
void const*,
sizeof...(MatcherTs)> matchers) : m_matchers{matchers} {}
10330 template<
typename Arg>
10331 bool match(Arg&& arg)
const {
10332 return match_any_of<MatcherTs...>(arg, m_matchers, std::index_sequence_for<MatcherTs...>{});
10335 std::string describe()
const override {
10336 return describe_multi_matcher<MatcherTs...>(
" or "_sr, m_matchers, std::index_sequence_for<MatcherTs...>{});
10343 std::array<
void const*,
sizeof...( MatcherTs )> m_matchers;
10346 template<
typename... MatchersRHS>
10354 template<
typename MatcherRHS>
10355 friend std::enable_if_t<is_matcher<MatcherRHS>::value,
10358 MatcherRHS
const& rhs) {
10359 return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(
CATCH_MOVE(lhs.m_matchers),
static_cast<void const*
>(std::addressof(rhs)))};
10363 template<
typename MatcherLHS>
10364 friend std::enable_if_t<is_matcher<MatcherLHS>::value,
10366 MatcherLHS
const& lhs,
10368 return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(
static_cast<void const*
>(std::addressof(lhs)),
CATCH_MOVE(rhs.m_matchers))};
10373 template<
typename MatcherT>
10375 MatcherT
const& m_matcher;
10385 template<
typename Arg>
10386 bool match(Arg&& arg)
const {
10387 return !m_matcher.match(arg);
10390 std::string describe()
const override {
10391 return "not " + m_matcher.toString();
10396 return matcher.m_matcher;
10403 template<
typename MatcherLHS,
typename MatcherRHS>
10404 std::enable_if_t<Detail::are_generic_matchers<MatcherLHS, MatcherRHS>::value, Detail::MatchAllOfGeneric<MatcherLHS, MatcherRHS>>
10405 operator && (MatcherLHS
const& lhs, MatcherRHS
const& rhs) {
10406 return { lhs, rhs };
10409 template<
typename MatcherLHS,
typename MatcherRHS>
10410 std::enable_if_t<Detail::are_generic_matchers<MatcherLHS, MatcherRHS>::value, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherRHS>>
10411 operator || (MatcherLHS
const& lhs, MatcherRHS
const& rhs) {
10412 return { lhs, rhs };
10416 template<
typename MatcherT>
10417 std::enable_if_t<Detail::is_generic_matcher<MatcherT>::value, Detail::MatchNotOfGeneric<MatcherT>>
10418 operator ! (MatcherT
const& matcher) {
10424 template<
typename MatcherLHS,
typename ArgRHS>
10425 std::enable_if_t<Detail::is_generic_matcher<MatcherLHS>::value, Detail::MatchAllOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>
10426 operator && (MatcherLHS
const& lhs, MatcherBase<ArgRHS>
const& rhs) {
10427 return { lhs, rhs };
10430 template<
typename ArgLHS,
typename MatcherRHS>
10431 std::enable_if_t<Detail::is_generic_matcher<MatcherRHS>::value, Detail::MatchAllOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>
10432 operator && (MatcherBase<ArgLHS>
const& lhs, MatcherRHS
const& rhs) {
10433 return { lhs, rhs };
10436 template<
typename MatcherLHS,
typename ArgRHS>
10437 std::enable_if_t<Detail::is_generic_matcher<MatcherLHS>::value, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>
10438 operator || (MatcherLHS
const& lhs, MatcherBase<ArgRHS>
const& rhs) {
10439 return { lhs, rhs };
10442 template<
typename ArgLHS,
typename MatcherRHS>
10443 std::enable_if_t<Detail::is_generic_matcher<MatcherRHS>::value, Detail::MatchAnyOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>
10444 operator || (MatcherBase<ArgLHS>
const& lhs, MatcherRHS
const& rhs) {
10445 return { lhs, rhs };
10454 namespace Matchers {
10459 template <
typename RangeLike>
10460 bool match(RangeLike&& rng)
const {
10461 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
10462 using Catch::Detail::empty;
10469 std::string describe()
const override;
10476 m_target_size(target_size)
10479 template <
typename RangeLike>
10480 bool match(RangeLike&& rng)
const {
10481 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
10482 using Catch::Detail::size;
10486 return size(rng) == m_target_size;
10489 std::string describe()
const override;
10492 template <
typename Matcher>
10500 template <
typename RangeLike>
10501 bool match(RangeLike&& rng)
const {
10502 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
10503 using Catch::Detail::size;
10507 return m_matcher.match(size(rng));
10510 std::string describe()
const override {
10511 return "size matches " + m_matcher.describe();
10520 template <
typename Matcher>
10521 std::enable_if_t<Detail::is_matcher<Matcher>::value,
10532 #ifndef CATCH_MATCHERS_CONTAINS_HPP_INCLUDED
10533 #define CATCH_MATCHERS_CONTAINS_HPP_INCLUDED
10536 #include <algorithm>
10537 #include <functional>
10540 namespace Matchers {
10542 template <
typename T,
typename Equality>
10547 template <
typename T2,
typename Equality2>
10553 std::string describe()
const override {
10554 return "contains element " + Catch::Detail::stringify(m_desired);
10557 template <
typename RangeLike>
10558 bool match(RangeLike&& rng)
const {
10559 using std::begin;
using std::end;
10562 [&](
auto const& elem) {
10563 return m_eq(elem, m_desired);
10569 template <
typename Matcher>
10580 template <
typename RangeLike>
10581 bool match(RangeLike&& rng)
const {
10582 for (
auto&& elem : rng) {
10583 if (m_matcher.match(elem)) {
10590 std::string describe()
const override {
10591 return "contains element matching " + m_matcher.describe();
10600 template <
typename T>
10601 std::enable_if_t<!Detail::is_matcher<T>::value,
10607 template <
typename Matcher>
10608 std::enable_if_t<Detail::is_matcher<Matcher>::value,
10618 template <
typename T,
typename Equality>
10629 #ifndef CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED
10630 #define CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED
10634 namespace Matchers {
10637 std::string m_message;
10644 bool match(std::exception
const& ex)
const override;
10646 std::string describe()
const override;
10658 #ifndef CATCH_MATCHERS_FLOATING_POINT_HPP_INCLUDED
10659 #define CATCH_MATCHERS_FLOATING_POINT_HPP_INCLUDED
10663 namespace Matchers {
10666 enum class FloatingPointKind : uint8_t;
10672 bool match(
double const& matchee)
const override;
10673 std::string describe()
const override;
10683 Detail::FloatingPointKind baseType );
10684 bool match(
double const& matchee)
const override;
10685 std::string describe()
const override;
10689 Detail::FloatingPointKind m_type;
10701 bool match(
double const& matchee)
const override;
10702 std::string describe()
const override;
10730 #ifndef CATCH_MATCHERS_PREDICATE_HPP_INCLUDED
10731 #define CATCH_MATCHERS_PREDICATE_HPP_INCLUDED
10737 namespace Matchers {
10740 std::string finalizeDescription(
const std::string& desc);
10743 template <
typename T,
typename Predicate>
10746 std::string m_description;
10751 m_description(Detail::finalizeDescription(descr))
10754 bool match( T
const& item )
const override {
10755 return m_predicate(item);
10758 std::string describe()
const override {
10759 return m_description;
10768 template<
typename T,
typename Pred>
10770 static_assert(
is_callable<Pred(T)>::value,
"Predicate not callable with argument T");
10771 static_assert(std::is_same<
bool, FunctionReturnType<Pred, T>>::value,
"Predicate does not return bool");
10781 #ifndef CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
10782 #define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
10786 namespace Matchers {
10788 template <
typename Matcher>
10796 std::string describe()
const override {
10797 return "all match " + m_matcher.describe();
10800 template <
typename RangeLike>
10801 bool match(RangeLike&& rng)
const {
10802 for (
auto&& elem : rng) {
10803 if (!m_matcher.match(elem)) {
10812 template <
typename Matcher>
10820 std::string describe()
const override {
10821 return "none match " + m_matcher.describe();
10824 template <
typename RangeLike>
10825 bool match(RangeLike&& rng)
const {
10826 for (
auto&& elem : rng) {
10827 if (m_matcher.match(elem)) {
10836 template <
typename Matcher>
10844 std::string describe()
const override {
10845 return "any match " + m_matcher.describe();
10848 template <
typename RangeLike>
10849 bool match(RangeLike&& rng)
const {
10850 for (
auto&& elem : rng) {
10851 if (m_matcher.match(elem)) {
10860 template <
typename Matcher>
10866 template <
typename Matcher>
10867 NoneMatchMatcher<Matcher> NoneMatch(Matcher&& matcher) {
10872 template <
typename Matcher>
10873 AnyMatchMatcher<Matcher> AnyMatch(Matcher&& matcher) {
10882 #ifndef CATCH_MATCHERS_STRING_HPP_INCLUDED
10883 #define CATCH_MATCHERS_STRING_HPP_INCLUDED
10889 namespace Matchers {
10892 CasedString( std::string
const& str, CaseSensitive caseSensitivity );
10893 std::string adjustString( std::string
const& str )
const;
10894 StringRef caseSensitivitySuffix()
const;
10896 CaseSensitive m_caseSensitivity;
10908 std::string describe()
const override;
10914 bool match( std::string
const& source )
const override;
10919 bool match( std::string
const& source )
const override;
10924 bool match( std::string
const& source )
const override;
10929 bool match( std::string
const& source )
const override;
10933 std::string m_regex;
10934 CaseSensitive m_caseSensitivity;
10937 RegexMatcher( std::string regex, CaseSensitive caseSensitivity );
10938 bool match( std::string
const& matchee )
const override;
10939 std::string describe()
const override;
10951 RegexMatcher Matches( std::string
const& regex, CaseSensitive caseSensitivity = CaseSensitive::Yes );
10959 #ifndef CATCH_MATCHERS_VECTOR_HPP_INCLUDED
10960 #define CATCH_MATCHERS_VECTOR_HPP_INCLUDED
10963 #include <algorithm>
10966 namespace Matchers {
10968 template<
typename T,
typename Alloc>
10970 T
const& m_comparator;
10974 m_comparator(comparator)
10977 bool match(std::vector<T, Alloc>
const& v)
const override {
10978 for (
auto const& el : v) {
10979 if (el == m_comparator) {
10986 std::string describe()
const override {
10987 return "Contains: " + ::Catch::Detail::stringify( m_comparator );
10991 template<
typename T,
typename AllocComp,
typename AllocMatch>
10993 std::vector<T, AllocComp>
const& m_comparator;
10997 m_comparator( comparator )
11000 bool match(std::vector<T, AllocMatch>
const& v)
const override {
11002 if (m_comparator.size() > v.size())
11004 for (
auto const& comparator : m_comparator) {
11005 auto present =
false;
11006 for (
const auto& el : v) {
11007 if (el == comparator) {
11018 std::string describe()
const override {
11019 return "Contains: " + ::Catch::Detail::stringify( m_comparator );
11023 template<
typename T,
typename AllocComp,
typename AllocMatch>
11025 std::vector<T, AllocComp>
const& m_comparator;
11028 EqualsMatcher(std::vector<T, AllocComp>
const& comparator):
11029 m_comparator( comparator )
11032 bool match(std::vector<T, AllocMatch>
const& v)
const override {
11037 if (m_comparator.size() != v.size())
11040 if (m_comparator[i] != v[i])
11044 std::string describe()
const override {
11045 return "Equals: " + ::Catch::Detail::stringify( m_comparator );
11049 template<
typename T,
typename AllocComp,
typename AllocMatch>
11051 std::vector<T, AllocComp>
const& m_comparator;
11055 ApproxMatcher(std::vector<T, AllocComp>
const& comparator):
11056 m_comparator( comparator )
11059 bool match(std::vector<T, AllocMatch>
const& v)
const override {
11060 if (m_comparator.size() != v.size())
11063 if (m_comparator[i] != approx(v[i]))
11067 std::string describe()
const override {
11068 return "is approx: " + ::Catch::Detail::stringify( m_comparator );
11070 template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
11072 approx.epsilon(
static_cast<double>(newEpsilon));
11075 template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
11077 approx.margin(
static_cast<double>(newMargin));
11080 template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
11082 approx.scale(
static_cast<double>(newScale));
11087 template<
typename T,
typename AllocComp,
typename AllocMatch>
11089 std::vector<T, AllocComp>
const& m_target;
11095 bool match(std::vector<T, AllocMatch>
const& vec)
const override {
11096 if (m_target.size() != vec.size()) {
11099 return std::is_permutation(m_target.begin(), m_target.end(), vec.begin());
11102 std::string describe()
const override {
11103 return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target);
11112 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
11118 template<
typename T,
typename Alloc = std::allocator<T>>
11124 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
11130 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
11136 template<
typename T,
typename AllocComp = std::allocator<T>,
typename AllocMatch = AllocComp>
11162 #ifndef CATCH_REPORTERS_ALL_HPP_INCLUDED
11163 #define CATCH_REPORTERS_ALL_HPP_INCLUDED
11167 #ifndef CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
11168 #define CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
11172 #ifndef CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED
11173 #define CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED
11177 #ifndef CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED
11178 #define CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED
11219 void listReporters(
11220 std::vector<ReporterDescription>
const& descriptions )
override;
11227 void listListeners(
11228 std::vector<ListenerDescription>
const& descriptions )
override;
11236 void listTests( std::vector<TestCaseHandle>
const& tests )
override;
11243 void listTags( std::vector<TagInfo>
const& tags )
override;
11255 using ReporterBase::ReporterBase;
11267 void testRunStarting(
TestRunInfo const& _testRunInfo )
override;
11270 currentTestCaseInfo = &_testInfo;
11274 m_sectionStack.push_back(_sectionInfo);
11281 m_sectionStack.pop_back();
11285 currentTestCaseInfo =
nullptr;
11295 TestRunInfo currentTestRunInfo{
"test run has not started yet"_sr };
11296 TestCaseInfo
const* currentTestCaseInfo =
nullptr;
11312 using StreamingReporterBase::StreamingReporterBase;
11315 static std::string getDescription() {
11316 using namespace std::string_literals;
11317 return "Reports test results in the format of Automake .trs files"s;
11320 void testCaseEnded(
TestCaseStats const& _testCaseStats)
override;
11329 #ifndef CATCH_REPORTER_COMPACT_HPP_INCLUDED
11330 #define CATCH_REPORTER_COMPACT_HPP_INCLUDED
11339 using StreamingReporterBase::StreamingReporterBase;
11343 static std::string getDescription();
11345 void noMatchingTestCases(
StringRef unmatchedSpec )
override;
11347 void testRunStarting(
TestRunInfo const& _testInfo )
override;
11349 void assertionEnded(
AssertionStats const& _assertionStats)
override;
11351 void sectionEnded(
SectionStats const& _sectionStats)
override;
11353 void testRunEnded(
TestRunStats const& _testRunStats)
override;
11362 #ifndef CATCH_REPORTER_CONSOLE_HPP_INCLUDED
11363 #define CATCH_REPORTER_CONSOLE_HPP_INCLUDED
11368 struct SummaryColumn;
11369 class TablePrinter;
11377 static std::string getDescription();
11379 void noMatchingTestCases(
StringRef unmatchedSpec )
override;
11380 void reportInvalidTestSpec(
StringRef arg )
override;
11384 void assertionEnded(
AssertionStats const& _assertionStats)
override;
11386 void sectionStarting(
SectionInfo const& _sectionInfo)
override;
11387 void sectionEnded(
SectionStats const& _sectionStats)
override;
11389 void benchmarkPreparing(
StringRef name )
override;
11390 void benchmarkStarting(
BenchmarkInfo const& info)
override;
11392 void benchmarkFailed(
StringRef error )
override;
11394 void testCaseEnded(
TestCaseStats const& _testCaseStats)
override;
11395 void testRunEnded(
TestRunStats const& _testRunStats)
override;
11396 void testRunStarting(
TestRunInfo const& _testRunInfo)
override;
11401 void lazyPrintWithoutClosingBenchmarkTable();
11402 void lazyPrintRunInfo();
11403 void printTestCaseAndSectionHeader();
11405 void printClosedHeader(std::string
const& _name);
11406 void printOpenHeader(std::string
const& _name);
11410 void printHeaderString(std::string
const& _string,
std::size_t indent = 0);
11413 void printTotals(
Totals const& totals);
11414 void printSummaryRow(
StringRef label, std::vector<SummaryColumn>
const& cols,
std::size_t row);
11416 void printTotalsDivider(
Totals const& totals);
11417 void printSummaryDivider();
11419 bool m_headerPrinted =
false;
11420 bool m_testRunInfoPrinted =
false;
11428 #ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
11429 #define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
11450 bool isAssertion()
const;
11451 bool isBenchmark()
const;
11480 template<
typename T,
typename ChildNodeT>
11482 explicit Node( T
const& _value ) : value( _value ) {}
11484 using ChildNodes = std::vector<Detail::unique_ptr<ChildNodeT>>;
11486 ChildNodes children;
11491 bool operator == (
SectionNode const& other)
const {
11492 return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
11495 bool hasAnyAssertions()
const;
11498 std::vector<Detail::unique_ptr<SectionNode>> childSections;
11499 std::vector<Detail::AssertionOrBenchmarkResult> assertionsAndBenchmarks;
11500 std::string stdOut;
11501 std::string stdErr;
11508 using ReporterBase::ReporterBase;
11524 void sectionStarting(
SectionInfo const& sectionInfo )
override;
11528 void assertionEnded(
AssertionStats const& assertionStats )
override;
11529 void sectionEnded(
SectionStats const& sectionStats )
override;
11531 void testCaseEnded(
TestCaseStats const& testCaseStats )
override;
11532 void testRunEnded(
TestRunStats const& testRunStats )
override;
11540 bool m_shouldStoreSuccesfulAssertions =
true;
11542 bool m_shouldStoreFailedAssertions =
true;
11552 std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases;
11558 std::vector<SectionNode*> m_sectionStack;
11566 #ifndef CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED
11567 #define CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED
11581 using IEventListener::IEventListener;
11583 void reportInvalidTestSpec(
StringRef unmatchedSpec )
override;
11584 void fatalErrorEncountered(
StringRef error )
override;
11586 void benchmarkPreparing(
StringRef name )
override;
11587 void benchmarkStarting(
BenchmarkInfo const& benchmarkInfo )
override;
11589 void benchmarkFailed(
StringRef error )
override;
11591 void assertionStarting(
AssertionInfo const& assertionInfo )
override;
11592 void assertionEnded(
AssertionStats const& assertionStats )
override;
11594 void listReporters(
11595 std::vector<ReporterDescription>
const& descriptions )
override;
11596 void listListeners(
11597 std::vector<ListenerDescription>
const& descriptions )
override;
11598 void listTests( std::vector<TestCaseHandle>
const& tests )
override;
11599 void listTags( std::vector<TagInfo>
const& tagInfos )
override;
11601 void noMatchingTestCases(
StringRef unmatchedSpec )
override;
11602 void testRunStarting(
TestRunInfo const& testRunInfo )
override;
11603 void testCaseStarting(
TestCaseInfo const& testInfo )
override;
11604 void testCasePartialStarting(
TestCaseInfo const& testInfo,
11605 uint64_t partNumber )
override;
11606 void sectionStarting(
SectionInfo const& sectionInfo )
override;
11607 void sectionEnded(
SectionStats const& sectionStats )
override;
11608 void testCasePartialEnded(
TestCaseStats const& testCaseStats,
11609 uint64_t partNumber )
override;
11610 void testCaseEnded(
TestCaseStats const& testCaseStats )
override;
11611 void testRunEnded(
TestRunStats const& testRunStats )
override;
11612 void skipTest(
TestCaseInfo const& testInfo )
override;
11620 #ifndef CATCH_REPORTER_HELPERS_HPP_INCLUDED
11621 #define CATCH_REPORTER_HELPERS_HPP_INCLUDED
11631 class TestCaseHandle;
11635 std::string getFormattedDuration(
double duration );
11638 bool shouldShowDuration( IConfig
const& config,
double duration );
11640 std::string serializeFilters( std::vector<std::string>
const& filters );
11646 friend std::ostream& operator<<( std::ostream& out,
lineOfChars value );
11659 std::vector<ReporterDescription>
const& descriptions,
11660 Verbosity verbosity );
11667 std::vector<ListenerDescription>
const& descriptions );
11676 void defaultListTags( std::ostream& out, std::vector<TagInfo>
const& tags,
bool isFiltered );
11689 std::vector<TestCaseHandle>
const& tests,
11691 Verbosity verbosity );
11698 #ifndef CATCH_REPORTER_JUNIT_HPP_INCLUDED
11699 #define CATCH_REPORTER_JUNIT_HPP_INCLUDED
11711 static std::string getDescription();
11713 void testRunStarting(
TestRunInfo const& runInfo)
override;
11715 void testCaseStarting(
TestCaseInfo const& testCaseInfo)
override;
11716 void assertionEnded(
AssertionStats const& assertionStats)
override;
11718 void testCaseEnded(
TestCaseStats const& testCaseStats)
override;
11720 void testRunEndedCumulative()
override;
11723 void writeRun(
TestRunNode const& testRunNode,
double suiteTime);
11727 void writeSection( std::string
const& className,
11728 std::string
const& rootName,
11730 bool testOkToFail );
11732 void writeAssertions(
SectionNode const& sectionNode);
11737 std::string stdOutForSuite;
11738 std::string stdErrForSuite;
11739 unsigned int unexpectedExceptions = 0;
11740 bool m_okToFail =
false;
11748 #ifndef CATCH_REPORTER_MULTI_HPP_INCLUDED
11749 #define CATCH_REPORTER_MULTI_HPP_INCLUDED
11761 std::vector<IEventListenerPtr> m_reporterLikes;
11762 bool m_haveNoncapturingReporters =
false;
11766 size_t m_insertedListeners = 0;
11771 using IEventListener::IEventListener;
11778 void noMatchingTestCases(
StringRef unmatchedSpec )
override;
11779 void fatalErrorEncountered(
StringRef error )
override;
11780 void reportInvalidTestSpec(
StringRef arg )
override;
11782 void benchmarkPreparing(
StringRef name )
override;
11783 void benchmarkStarting(
BenchmarkInfo const& benchmarkInfo )
override;
11785 void benchmarkFailed(
StringRef error )
override;
11787 void testRunStarting(
TestRunInfo const& testRunInfo )
override;
11788 void testCaseStarting(
TestCaseInfo const& testInfo )
override;
11789 void testCasePartialStarting(
TestCaseInfo const& testInfo, uint64_t partNumber)
override;
11790 void sectionStarting(
SectionInfo const& sectionInfo )
override;
11791 void assertionStarting(
AssertionInfo const& assertionInfo )
override;
11793 void assertionEnded(
AssertionStats const& assertionStats )
override;
11794 void sectionEnded(
SectionStats const& sectionStats )
override;
11795 void testCasePartialEnded(
TestCaseStats const& testInfo, uint64_t partNumber)
override;
11796 void testCaseEnded(
TestCaseStats const& testCaseStats )
override;
11797 void testRunEnded(
TestRunStats const& testRunStats )
override;
11799 void skipTest(
TestCaseInfo const& testInfo )
override;
11801 void listReporters(std::vector<ReporterDescription>
const& descriptions)
override;
11802 void listListeners(std::vector<ListenerDescription>
const& descriptions)
override;
11803 void listTests(std::vector<TestCaseHandle>
const& tests)
override;
11804 void listTags(std::vector<TagInfo>
const& tags)
override;
11814 #ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
11815 #define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
11818 #include <type_traits>
11824 template <
typename T,
typename =
void>
11827 template <
typename T>
11830 void_t<decltype( T::getDescription() )>>
11831 : std::true_type {};
11843 template <
typename T>
11847 return Detail::make_unique<T>(
CATCH_MOVE(config) );
11850 std::string getDescription()
const override {
11851 return T::getDescription();
11856 template<
typename T>
11860 registerReporterImpl( name,
11865 template<
typename T>
11871 std::string getDescriptionImpl( std::true_type )
const {
11872 return T::getDescription();
11875 std::string getDescriptionImpl( std::false_type )
const {
11876 return "(No description provided)";
11880 TypedListenerFactory(
StringRef listenerName ):
11881 m_listenerName( listenerName ) {}
11884 return Detail::make_unique<T>( config );
11888 return m_listenerName;
11891 std::string getDescription()
const override {
11898 getMutableRegistryHub().registerListener( Detail::make_unique<TypedListenerFactory>(listenerName) );
11903 #if !defined(CATCH_CONFIG_DISABLE)
11905 # define CATCH_REGISTER_REPORTER( name, reporterType ) \
11906 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
11907 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
11909 Catch::ReporterRegistrar<reporterType> INTERNAL_CATCH_UNIQUE_NAME( \
11910 catch_internal_RegistrarFor )( name ); \
11912 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
11914 # define CATCH_REGISTER_LISTENER( listenerType ) \
11915 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
11916 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
11918 Catch::ListenerRegistrar<listenerType> INTERNAL_CATCH_UNIQUE_NAME( \
11919 catch_internal_RegistrarFor )( #listenerType ); \
11921 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
11925 #define CATCH_REGISTER_REPORTER(name, reporterType)
11926 #define CATCH_REGISTER_LISTENER(listenerType)
11933 #ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
11934 #define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
11945 m_preferences.shouldRedirectStdOut =
true;
11946 m_preferences.shouldReportAllAssertions =
true;
11947 m_shouldStoreSuccesfulAssertions =
false;
11952 static std::string getDescription() {
11953 using namespace std::string_literals;
11954 return "Reports test results in the Generic Test Data SonarQube XML format"s;
11957 void testRunStarting(
TestRunInfo const& testRunInfo )
override;
11960 writeRun( *m_testRun );
11964 void writeRun( TestRunNode
const& groupNode );
11966 void writeTestFile(std::string
const& filename, std::vector<TestCaseNode const*>
const& testCaseNodes);
11968 void writeTestCase(TestCaseNode
const& testCaseNode);
11970 void writeSection(std::string
const& rootName, SectionNode
const& sectionNode,
bool okToFail);
11972 void writeAssertions(SectionNode
const& sectionNode,
bool okToFail);
11974 void writeAssertion(
AssertionStats const& stats,
bool okToFail);
11986 #ifndef CATCH_REPORTER_TAP_HPP_INCLUDED
11987 #define CATCH_REPORTER_TAP_HPP_INCLUDED
11996 m_preferences.shouldReportAllAssertions =
true;
12000 static std::string getDescription() {
12001 using namespace std::string_literals;
12002 return "Reports test results in TAP format, suitable for test harnesses"s;
12005 void testRunStarting(
TestRunInfo const& testInfo )
override;
12007 void noMatchingTestCases(
StringRef unmatchedSpec )
override;
12009 void assertionEnded(
AssertionStats const& _assertionStats)
override;
12011 void testRunEnded(
TestRunStats const& _testRunStats)
override;
12022 #ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
12023 #define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
12029 # pragma clang diagnostic push
12030 # pragma clang diagnostic ignored "-Wpadded"
12040 m_preferences.shouldRedirectStdOut =
true;
12045 static std::string getDescription() {
12046 using namespace std::string_literals;
12047 return "Reports test results as TeamCity service messages"s;
12050 void testRunStarting(
TestRunInfo const& groupInfo )
override;
12051 void testRunEnded(
TestRunStats const& testGroupStats )
override;
12054 void assertionEnded(
AssertionStats const& assertionStats)
override;
12057 m_headerPrintedForThisSection =
false;
12061 void testCaseStarting(
TestCaseInfo const& testInfo)
override;
12063 void testCaseEnded(
TestCaseStats const& testCaseStats)
override;
12066 void printSectionHeader(std::ostream& os);
12068 bool m_headerPrintedForThisSection =
false;
12075 # pragma clang diagnostic pop
12081 #ifndef CATCH_REPORTER_XML_HPP_INCLUDED
12082 #define CATCH_REPORTER_XML_HPP_INCLUDED
12094 static std::string getDescription();
12096 virtual std::string getStylesheetRef()
const;
12102 void testRunStarting(
TestRunInfo const& testInfo)
override;
12104 void testCaseStarting(
TestCaseInfo const& testInfo)
override;
12106 void sectionStarting(
SectionInfo const& sectionInfo)
override;
12110 void assertionEnded(
AssertionStats const& assertionStats)
override;
12112 void sectionEnded(
SectionStats const& sectionStats)
override;
12114 void testCaseEnded(
TestCaseStats const& testCaseStats)
override;
12116 void testRunEnded(
TestRunStats const& testRunStats)
override;
12118 void benchmarkPreparing(
StringRef name )
override;
12121 void benchmarkFailed(
StringRef error )
override;
12123 void listReporters(std::vector<ReporterDescription>
const& descriptions)
override;
12124 void listListeners(std::vector<ListenerDescription>
const& descriptions)
override;
12125 void listTests(std::vector<TestCaseHandle>
const& tests)
override;
12126 void listTags(std::vector<TagInfo>
const& tags)
override;
12129 Timer m_testCaseTimer;
12131 int m_sectionDepth = 0;
WithinAbsMatcher WithinAbs(double target, double margin)
Creates a matcher that accepts numbers within certain range of target.
Definition: catch_amalgamated.cpp:7366
Column Spacer(size_t spaceWidth)
Creates a column that serves as an empty space of specific width.
Definition: catch_amalgamated.cpp:6698
void defaultListReporters(std::ostream &out, std::vector< ReporterDescription > const &descriptions, Verbosity verbosity)
Lists reporter descriptions to the provided stream in user-friendly format.
Definition: catch_amalgamated.cpp:7784
StringContainsMatcher ContainsSubstring(std::string const &str, CaseSensitive caseSensitivity)
Creates matcher that accepts strings that contain str
Definition: catch_amalgamated.cpp:7478
void defaultListListeners(std::ostream &out, std::vector< ListenerDescription > const &descriptions)
Lists listeners descriptions to the provided stream in user-friendly format.
Definition: catch_amalgamated.cpp:7817
HasSizeMatcher SizeIs(std::size_t sz)
Creates a matcher that accepts ranges/containers with specific size.
Definition: catch_amalgamated.cpp:7582
WithinRelMatcher WithinRel(double target, double eps)
Creates a matcher that accepts doubles within certain relative range of target.
Definition: catch_amalgamated.cpp:7370
StringEqualsMatcher Equals(std::string const &str, CaseSensitive caseSensitivity)
Creates matcher that accepts strings that are exactly equal to str
Definition: catch_amalgamated.cpp:7475
std::vector< std::string > splitReporterSpec(StringRef reporterSpec)
Splits the reporter spec into reporter name and kv-pair options.
Definition: catch_amalgamated.cpp:4692
WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff)
Creates a matcher that accepts doubles within certain ULP range of target.
Definition: catch_amalgamated.cpp:7358
StartsWithMatcher StartsWith(std::string const &str, CaseSensitive caseSensitivity)
Creates matcher that accepts strings that start with str
Definition: catch_amalgamated.cpp:7484
void registerReporterImpl(std::string const &name, IReporterFactoryPtr reporterPtr)
Indirection for reporter registration, so that the error handling is independent on the reporter's co...
Definition: catch_amalgamated.cpp:9588
void defaultListTags(std::ostream &out, std::vector< TagInfo > const &tags, bool isFiltered)
Lists tag information to the provided stream in user-friendly format.
Definition: catch_amalgamated.cpp:7844
IsEmptyMatcher IsEmpty()
Creates a matcher that accepts empty ranges/containers.
Definition: catch_amalgamated.cpp:7578
Optional< ReporterSpec > parseReporterSpec(StringRef reporterSpec)
Parses provided reporter spec string into.
Definition: catch_amalgamated.cpp:4764
std::string trim(std::string const &str)
Returns a new string without whitespace at the start/end.
Definition: catch_amalgamated.cpp:5674
RegexMatcher Matches(std::string const ®ex, CaseSensitive caseSensitivity)
Creates matcher that accepts strings matching regex
Definition: catch_amalgamated.cpp:7488
void defaultListTests(std::ostream &out, ColourImpl *streamColour, std::vector< TestCaseHandle > const &tests, bool isFiltered, Verbosity verbosity)
Lists test case information to the provided stream in user-friendly format.
Definition: catch_amalgamated.cpp:7866
EndsWithMatcher EndsWith(std::string const &str, CaseSensitive caseSensitivity)
Creates matcher that accepts strings that end with str
Definition: catch_amalgamated.cpp:7481
ExceptionMessageMatcher Message(std::string const &message)
Creates a matcher that checks whether a std derived exception has the provided message.
Definition: catch_amalgamated.cpp:7644
GenerateFrom
Definition: catch_amalgamated.hpp:3904
@ Default
Currently equivalent to RandomDevice, but can change at any point.
uint64_t ulpDistance(FP lhs, FP rhs)
Calculates the ULP distance between two floating point numbers.
Definition: catch_amalgamated.hpp:8483
std::enable_if_t<!Detail::is_matcher< T >::value, ContainsElementMatcher< T, std::equal_to<> > > Contains(T &&elem)
Creates a matcher that checks whether a range contains a specific element.
Definition: catch_amalgamated.hpp:10602
ResultType
Denotes type of a parsing result.
Definition: catch_amalgamated.hpp:4563
@ RuntimeError
Error in parsing inputs.
@ LogicError
Error in user-specified arguments for construction.
#define CATCH_MOVE(...)
Replacement for std::move with better compile time performance.
Definition: catch_amalgamated.hpp:741
VectorContainsElementMatcher< T, Alloc > VectorContains(T const &comparator)
Creates a matcher that matches vectors that contain comparator as an element.
Definition: catch_amalgamated.hpp:11119
UnorderedEqualsMatcher< T, AllocComp, AllocMatch > UnorderedEquals(std::vector< T, AllocComp > const &target)
Creates a matcher that matches vectors that is equal to target modulo permutation.
Definition: catch_amalgamated.hpp:11137
ColourMode
Definition: catch_amalgamated.hpp:231
@ None
Don't use any colour.
@ PlatformDefault
Let Catch2 pick implementation based on platform detection.
@ Win32
Use Win32 console colour API.
@ ANSI
Use ANSI colour code escapes.
PredicateMatcher< T, Pred > Predicate(Pred &&predicate, std::string const &description="")
Creates a matcher that calls delegates match to the provided predicate.
Definition: catch_amalgamated.hpp:10769
#define CATCH_FORWARD(...)
Replacement for std::forward with better compile time performance.
Definition: catch_amalgamated.hpp:744
Definition: catch_amalgamated.hpp:3558
Definition: catch_amalgamated.hpp:5525
Definition: catch_amalgamated.hpp:971
Definition: catch_amalgamated.hpp:11310
Definition: catch_amalgamated.hpp:5311
Definition: catch_amalgamated.hpp:4335
Definition: catch_amalgamated.hpp:4949
Definition: catch_amalgamated.hpp:5081
Definition: catch_amalgamated.hpp:4632
Definition: catch_amalgamated.hpp:4876
Definition: catch_amalgamated.hpp:4687
Definition: catch_amalgamated.hpp:4863
Definition: catch_amalgamated.hpp:4884
Definition: catch_amalgamated.hpp:4570
Definition: catch_amalgamated.hpp:4586
Definition: catch_amalgamated.hpp:4529
Definition: catch_amalgamated.hpp:5007
Definition: catch_amalgamated.hpp:4960
Definition: catch_amalgamated.hpp:5032
RAII wrapper around writing specific colour of text using specific colour impl into a stream.
Definition: catch_amalgamated.hpp:3982
friend std::ostream & operator<<(std::ostream &lhs, ColourGuard &&guard)
Engages the guard and starts using colour.
Definition: catch_amalgamated.hpp:4022
friend std::ostream & operator<<(std::ostream &lhs, ColourGuard &guard)
Engages the guard and starts using colour.
Definition: catch_amalgamated.hpp:4016
Definition: catch_amalgamated.hpp:3973
IStream * m_stream
The associated stream of this ColourImpl instance.
Definition: catch_amalgamated.hpp:3976
Definition: catch_amalgamated.hpp:11337
Definition: catch_amalgamated.hpp:4202
Definition: catch_amalgamated.hpp:11371
Utility base for reporters that need to handle all results at once.
Definition: catch_amalgamated.hpp:11478
void reportInvalidTestSpec(StringRef) override
Called for all invalid test specs from the cli.
Definition: catch_amalgamated.hpp:11517
void benchmarkPreparing(StringRef) override
Called when user-code is being probed before the actual benchmark runs.
Definition: catch_amalgamated.hpp:11511
void noMatchingTestCases(StringRef) override
Called when no test cases match provided test spec.
Definition: catch_amalgamated.hpp:11516
void testCasePartialEnded(TestCaseStats const &, uint64_t) override
Called every time a TEST_CASE is entered, including repeats (due to sections)
Definition: catch_amalgamated.hpp:11530
void benchmarkStarting(BenchmarkInfo const &) override
Called after probe but before the user-code is being benchmarked.
Definition: catch_amalgamated.hpp:11512
void benchmarkFailed(StringRef) override
Called if running the benchmarks fails for any reason.
Definition: catch_amalgamated.hpp:11514
void testRunStarting(TestRunInfo const &) override
Called once in a testing run before tests are started.
Definition: catch_amalgamated.hpp:11520
void skipTest(TestCaseInfo const &) override
Called with test cases that are skipped due to the test run aborting.
Definition: catch_amalgamated.hpp:11536
void fatalErrorEncountered(StringRef) override
Called if a fatal error (signal/structured exception) occured.
Definition: catch_amalgamated.hpp:11518
Detail::unique_ptr< TestRunNode > m_testRun
The root node of the test run tree.
Definition: catch_amalgamated.hpp:11547
void assertionStarting(AssertionInfo const &) override
Called before assertion success/failure is evaluated.
Definition: catch_amalgamated.hpp:11526
virtual void testRunEndedCumulative()=0
Customization point: called after last test finishes (testRunEnded has been handled)
void testCasePartialStarting(TestCaseInfo const &, uint64_t) override
Called every time a TEST_CASE is entered, including repeats (due to sections)
Definition: catch_amalgamated.hpp:11523
void testCaseStarting(TestCaseInfo const &) override
Called once for each TEST_CASE, no matter how many times it is entered.
Definition: catch_amalgamated.hpp:11522
Represents either an assertion or a benchmark result to be handled by cumulative reporter later.
Definition: catch_amalgamated.hpp:11440
Definition: catch_amalgamated.hpp:8302
Definition: catch_amalgamated.hpp:2948
Deriving classes become noncopyable and nonmovable.
Definition: catch_amalgamated.hpp:74
A reimplementation of std::unique_ptr for improved compilation performance.
Definition: catch_amalgamated.hpp:1137
Simple RAII class that stores the value of errno at construction and restores it at destruction.
Definition: catch_amalgamated.hpp:8325
Base class to simplify implementing listeners.
Definition: catch_amalgamated.hpp:11579
Definition: catch_amalgamated.hpp:7932
virtual std::string getDescription() const =0
Return listener's description if available.
virtual StringRef getName() const =0
Return a meaningful name for the listener, e.g. its type name.
Definition: catch_amalgamated.hpp:6943
Definition: catch_amalgamated.hpp:8349
Definition: catch_amalgamated.hpp:5427
Simple RAII guard for (dis)engaging the FatalConditionHandler.
Definition: catch_amalgamated.hpp:8409
Wrapper for platform-specific fatal error (signals/SEH) handlers.
Definition: catch_amalgamated.hpp:8382
Definition: catch_amalgamated.hpp:7083
Definition: catch_amalgamated.hpp:7595
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7618
Definition: catch_amalgamated.hpp:7458
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7481
Definition: catch_amalgamated.hpp:7264
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7276
Definition: catch_amalgamated.hpp:7113
Definition: catch_amalgamated.hpp:7226
GeneratorWrapper(IGenerator< T > *generator)
Takes ownership of the passed pointer.
Definition: catch_amalgamated.hpp:7230
Definition: catch_amalgamated.hpp:7294
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7334
Definition: catch_amalgamated.hpp:7202
Definition: catch_amalgamated.hpp:7841
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7860
Definition: catch_amalgamated.hpp:7554
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7571
Definition: catch_amalgamated.hpp:7714
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7728
Definition: catch_amalgamated.hpp:7735
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7749
Definition: catch_amalgamated.hpp:7795
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7821
Definition: catch_amalgamated.hpp:7498
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7523
Definition: catch_amalgamated.hpp:7245
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7258
Definition: catch_amalgamated.hpp:7421
bool next() override
Attempts to move the generator to the next element.
Definition: catch_amalgamated.hpp:7435
Definition: catch_amalgamated.hpp:251
Definition: catch_amalgamated.hpp:682
The common base for all reporters and event listeners.
Definition: catch_amalgamated.hpp:1440
virtual void sectionEnded(SectionStats const §ionStats)=0
Called after a SECTION has finished running.
virtual void testCasePartialEnded(TestCaseStats const &testCaseStats, uint64_t partNumber)=0
Called every time a TEST_CASE is entered, including repeats (due to sections)
virtual void testCaseStarting(TestCaseInfo const &testInfo)=0
Called once for each TEST_CASE, no matter how many times it is entered.
IConfig const * m_config
The test run's config as filled in from CLI and defaults.
Definition: catch_amalgamated.hpp:1445
virtual void skipTest(TestCaseInfo const &testInfo)=0
Called with test cases that are skipped due to the test run aborting.
virtual void testRunStarting(TestRunInfo const &testRunInfo)=0
Called once in a testing run before tests are started.
virtual void assertionEnded(AssertionStats const &assertionStats)=0
Called after assertion was fully evaluated.
virtual void listTags(std::vector< TagInfo > const &tags)=0
Writes out information about the provided tags using reporter-specific format.
virtual void listTests(std::vector< TestCaseHandle > const &tests)=0
Writes out information about provided tests using reporter-specific format.
virtual void benchmarkEnded(BenchmarkStats<> const &benchmarkStats)=0
Called with the benchmark results if benchmark successfully finishes.
virtual void assertionStarting(AssertionInfo const &assertionInfo)=0
Called before assertion success/failure is evaluated.
virtual void listReporters(std::vector< ReporterDescription > const &descriptions)=0
Writes out information about provided reporters using reporter-specific format.
virtual void benchmarkFailed(StringRef benchmarkName)=0
Called if running the benchmarks fails for any reason.
virtual void benchmarkStarting(BenchmarkInfo const &benchmarkInfo)=0
Called after probe but before the user-code is being benchmarked.
virtual void testRunEnded(TestRunStats const &testRunStats)=0
Called once after all tests in a testing run are finished.
virtual void testCasePartialStarting(TestCaseInfo const &testInfo, uint64_t partNumber)=0
Called every time a TEST_CASE is entered, including repeats (due to sections)
virtual void sectionStarting(SectionInfo const §ionInfo)=0
Called when a SECTION is being entered. Not called for skipped sections.
virtual void testCaseEnded(TestCaseStats const &testCaseStats)=0
Called once for each TEST_CASE, no matter how many times it is entered.
virtual void benchmarkPreparing(StringRef benchmarkName)=0
Called when user-code is being probed before the actual benchmark runs.
virtual void listListeners(std::vector< ListenerDescription > const &descriptions)=0
Writes out the provided listeners descriptions using reporter-specific format.
virtual void reportInvalidTestSpec(StringRef invalidArgument)=0
Called for all invalid test specs from the cli.
virtual void noMatchingTestCases(StringRef unmatchedSpec)=0
Called when no test cases match provided test spec.
ReporterPreferences m_preferences
Derived classes can set up their preferences here.
Definition: catch_amalgamated.hpp:1443
virtual void fatalErrorEncountered(StringRef error)=0
Called if a fatal error (signal/structured exception) occured.
Definition: catch_amalgamated.hpp:6929
Definition: catch_amalgamated.hpp:6923
Definition: catch_amalgamated.hpp:7174
Definition: catch_amalgamated.hpp:690
Definition: catch_amalgamated.hpp:2889
Definition: catch_amalgamated.hpp:1776
Definition: catch_amalgamated.hpp:1763
Definition: catch_amalgamated.hpp:7922
Definition: catch_amalgamated.hpp:7989
Definition: catch_amalgamated.hpp:1030
Definition: catch_amalgamated.hpp:8545
virtual bool isConsole() const
Best guess on whether the instance is writing to a console (e.g.
Definition: catch_amalgamated.hpp:8560
Definition: catch_amalgamated.hpp:8014
Definition: catch_amalgamated.hpp:5789
Definition: catch_amalgamated.hpp:5780
Definition: catch_amalgamated.hpp:5280
Definition: catch_amalgamated.hpp:11705
Definition: catch_amalgamated.hpp:928
Definition: catch_amalgamated.hpp:11866
Definition: catch_amalgamated.hpp:9852
Definition: catch_amalgamated.hpp:10789
Definition: catch_amalgamated.hpp:10837
Definition: catch_amalgamated.hpp:11050
Matcher for checking that an element in range is equal to specific element.
Definition: catch_amalgamated.hpp:10543
Meta-matcher for checking that an element in a range matches a specific matcher.
Definition: catch_amalgamated.hpp:10570
Definition: catch_amalgamated.hpp:10992
Definition: catch_amalgamated.hpp:10265
Definition: catch_amalgamated.hpp:9956
Definition: catch_amalgamated.hpp:10320
Definition: catch_amalgamated.hpp:10010
Definition: catch_amalgamated.hpp:10374
Definition: catch_amalgamated.hpp:10062
Definition: catch_amalgamated.hpp:10926
Definition: catch_amalgamated.hpp:11024
Definition: catch_amalgamated.hpp:10636
Definition: catch_amalgamated.hpp:10472
Definition: catch_amalgamated.hpp:10456
Definition: catch_amalgamated.hpp:9948
Definition: catch_amalgamated.hpp:10164
Definition: catch_amalgamated.hpp:9928
Definition: catch_amalgamated.hpp:10813
Definition: catch_amalgamated.hpp:10744
Definition: catch_amalgamated.hpp:10932
Definition: catch_amalgamated.hpp:10493
Definition: catch_amalgamated.hpp:10921
Definition: catch_amalgamated.hpp:10916
Definition: catch_amalgamated.hpp:10911
Definition: catch_amalgamated.hpp:10900
Definition: catch_amalgamated.hpp:11088
Definition: catch_amalgamated.hpp:10969
Definition: catch_amalgamated.hpp:10669
Definition: catch_amalgamated.hpp:10698
Definition: catch_amalgamated.hpp:10679
Definition: catch_amalgamated.hpp:11754
Definition: catch_amalgamated.hpp:3811
Definition: catch_amalgamated.hpp:8663
Definition: catch_amalgamated.hpp:8652
Definition: catch_amalgamated.hpp:8642
Definition: catch_amalgamated.hpp:8672
This is the base class for all reporters.
Definition: catch_amalgamated.hpp:11197
Detail::unique_ptr< IStream > m_wrapped_stream
The stream wrapper as passed to us by outside code.
Definition: catch_amalgamated.hpp:11200
std::ostream & m_stream
Cached output stream from m_wrapped_stream to reduce number of indirect calls needed to write output.
Definition: catch_amalgamated.hpp:11203
Detail::unique_ptr< ColourImpl > m_colour
Colour implementation this reporter was configured for.
Definition: catch_amalgamated.hpp:11205
std::map< std::string, std::string > m_customOptions
The custom reporter options user passed down to the reporter.
Definition: catch_amalgamated.hpp:11207
Definition: catch_amalgamated.hpp:11844
Definition: catch_amalgamated.hpp:11857
Definition: catch_amalgamated.hpp:8750
Structured reporter spec that a reporter can be created from.
Definition: catch_amalgamated.hpp:4079
Definition: catch_amalgamated.hpp:2810
std::string str() const
Returns the serialized state.
Definition: catch_amalgamated.cpp:4896
Definition: catch_amalgamated.hpp:8976
Definition: catch_amalgamated.hpp:4324
Definition: catch_amalgamated.hpp:5732
Definition: catch_amalgamated.hpp:5136
Definition: catch_amalgamated.hpp:7661
Definition: catch_amalgamated.hpp:9146
Definition: catch_amalgamated.hpp:11940
void testRunEndedCumulative() override
Customization point: called after last test finishes (testRunEnded has been handled)
Definition: catch_amalgamated.hpp:11959
Definition: catch_amalgamated.hpp:9180
Definition: catch_amalgamated.hpp:11253
void benchmarkPreparing(StringRef) override
Called when user-code is being probed before the actual benchmark runs.
Definition: catch_amalgamated.hpp:11258
void sectionStarting(SectionInfo const &_sectionInfo) override
Called when a SECTION is being entered. Not called for skipped sections.
Definition: catch_amalgamated.hpp:11273
void benchmarkEnded(BenchmarkStats<> const &) override
Called with the benchmark results if benchmark successfully finishes.
Definition: catch_amalgamated.hpp:11260
void testCaseStarting(TestCaseInfo const &_testInfo) override
Called once for each TEST_CASE, no matter how many times it is entered.
Definition: catch_amalgamated.hpp:11269
void testCaseEnded(TestCaseStats const &) override
Called once for each TEST_CASE, no matter how many times it is entered.
Definition: catch_amalgamated.hpp:11284
void assertionStarting(AssertionInfo const &) override
Called before assertion success/failure is evaluated.
Definition: catch_amalgamated.hpp:11277
std::vector< SectionInfo > m_sectionStack
Stack of all active sections in the current test case.
Definition: catch_amalgamated.hpp:11299
void sectionEnded(SectionStats const &) override
Called after a SECTION has finished running.
Definition: catch_amalgamated.hpp:11280
void testCasePartialEnded(TestCaseStats const &, uint64_t) override
Called every time a TEST_CASE is entered, including repeats (due to sections)
Definition: catch_amalgamated.hpp:11283
void assertionEnded(AssertionStats const &) override
Called after assertion was fully evaluated.
Definition: catch_amalgamated.hpp:11278
void benchmarkFailed(StringRef) override
Called if running the benchmarks fails for any reason.
Definition: catch_amalgamated.hpp:11261
void skipTest(TestCaseInfo const &) override
Called with test cases that are skipped due to the test run aborting.
Definition: catch_amalgamated.hpp:11289
void benchmarkStarting(BenchmarkInfo const &) override
Called after probe but before the user-code is being benchmarked.
Definition: catch_amalgamated.hpp:11259
void fatalErrorEncountered(StringRef) override
Called if a fatal error (signal/structured exception) occured.
Definition: catch_amalgamated.hpp:11263
void reportInvalidTestSpec(StringRef) override
Called for all invalid test specs from the cli.
Definition: catch_amalgamated.hpp:11265
void noMatchingTestCases(StringRef) override
Called when no test cases match provided test spec.
Definition: catch_amalgamated.hpp:11264
void testCasePartialStarting(TestCaseInfo const &, uint64_t) override
Called every time a TEST_CASE is entered, including repeats (due to sections)
Definition: catch_amalgamated.hpp:11272
A non-owning string class (similar to the forthcoming std::string_view) Note that,...
Definition: catch_amalgamated.hpp:103
int compare(StringRef rhs) const
Provides a three-way comparison with rhs.
Definition: catch_amalgamated.cpp:5756
Definition: catch_amalgamated.hpp:11992
Definition: catch_amalgamated.hpp:9276
Definition: catch_amalgamated.hpp:12035
void sectionStarting(SectionInfo const §ionInfo) override
Called when a SECTION is being entered. Not called for skipped sections.
Definition: catch_amalgamated.hpp:12056
Wrapper over the test case information and the test case invoker.
Definition: catch_amalgamated.hpp:6878
Definition: catch_amalgamated.hpp:9301
Definition: catch_amalgamated.hpp:8803
bool hasChildren() const
Have any children been added?
Definition: catch_amalgamated.hpp:8865
virtual bool isComplete() const =0
Returns true if tracker run to completion (successfully or not)
Definition: catch_amalgamated.hpp:8934
Definition: catch_amalgamated.hpp:8914
Definition: catch_amalgamated.hpp:8889
Definition: catch_amalgamated.hpp:9362
Definition: catch_amalgamated.hpp:5833
Definition: catch_amalgamated.hpp:9338
Definition: catch_amalgamated.hpp:9397
Definition: catch_amalgamated.hpp:3739
Iterates "lines" in Column and return sthem.
Definition: catch_amalgamated.hpp:9490
Represents a column of text with specific width and indentation.
Definition: catch_amalgamated.hpp:9476
Definition: catch_amalgamated.hpp:9574
Definition: catch_amalgamated.hpp:9570
Definition: catch_amalgamated.hpp:5716
Definition: catch_amalgamated.hpp:5387
Definition: catch_amalgamated.hpp:3707
Helper for XML-encoding text (escaping angle brackets, quotes, etc)
Definition: catch_amalgamated.hpp:9701
Definition: catch_amalgamated.hpp:12088
Definition: catch_amalgamated.hpp:9719
Definition: catch_amalgamated.hpp:9716
XmlWriter & writeAttribute(StringRef name, T const &attribute)
The attribute value must provide op<<(ostream&, T).
Definition: catch_amalgamated.hpp:9783
Helper for streaming a "count [maybe-plural-of-label]" human-friendly string.
Definition: catch_amalgamated.hpp:9249
CPP_concept type
\concept type
Definition: concepts.hpp:838
CPP_concept predicate
\concept predicate
Definition: concepts.hpp:73
CPP_concept container
\concept container
Definition: concepts.hpp:79
integer_sequence< std::size_t, Is... > index_sequence
A container for a sequence of compile-time integer constants of type std::size_t.
Definition: meta.hpp:447
std::integral_constant< std::size_t, N > size_t
An integral constant wrapper for std::size_t.
Definition: meta.hpp:163
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition: meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
meta::size_t< L::size()> size
An integral constant wrapper that is the size of the meta::list L.
Definition: meta.hpp:1696
front< pop_front< Pair > > second
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2256
meta::size_t< std::size_t(-1)> npos
A special value used to indicate no matches.
Definition: meta.hpp:1676
bool_< 0==size< L >::type::value > empty
An Boolean integral constant wrapper around true if L is an empty type list; false,...
Definition: meta.hpp:2231
list< F, S > pair
A list with exactly two elements.
Definition: meta.hpp:2246
typename detail::_cond< If >::template invoke< Then, Else > conditional_t
Select one type or another depending on a compile-time Boolean.
Definition: meta.hpp:1148
drop< L, min< find_index< L, T >, size< L > >> find
Return the tail of the list L starting at the first occurrence of T, if any such element exists; the ...
Definition: meta.hpp:2388
_t< detail::count_if_< L, Fn > > count_if
Count the number of times the predicate Fn evaluates to true for all the elements in the list L.
Definition: meta.hpp:2787
_t< detail::count_< L, T > > count
Count the number of times a type T appears in the list L.
Definition: meta.hpp:2725
_t< detail::find_if_< L, Fn > > find_if
Return the tail of the list L starting at the first element A such that invoke<Fn,...
Definition: meta.hpp:2506
_t< detail::is_callable_< T > > is_callable
An alias for std::true_type if T::invoke exists and names a class template or alias template; otherwi...
Definition: meta.hpp:689
if_c<(sizeof...(Ts) > 0), detail::lambda_< list< Ts... > >> lambda
For creating anonymous Invocables.
Definition: meta.hpp:3594
Definition: catch_amalgamated.hpp:905
Definition: catch_amalgamated.hpp:5520
Definition: catch_amalgamated.hpp:958
Definition: catch_amalgamated.hpp:1326
Definition: catch_amalgamated.hpp:5859
Definition: catch_amalgamated.hpp:1378
Definition: catch_amalgamated.hpp:1389
Definition: catch_amalgamated.hpp:2570
Definition: catch_amalgamated.hpp:1867
We need to reinvent std::function because every piece of code that might add overhead in a measuremen...
Definition: catch_amalgamated.hpp:1961
Definition: catch_amalgamated.hpp:1846
Definition: catch_amalgamated.hpp:1856
Definition: catch_amalgamated.hpp:1811
Definition: catch_amalgamated.hpp:1803
Definition: catch_amalgamated.hpp:2693
Definition: catch_amalgamated.hpp:2338
Definition: catch_amalgamated.hpp:2048
Definition: catch_amalgamated.hpp:1911
Definition: catch_amalgamated.hpp:1921
Definition: catch_amalgamated.hpp:1242
Definition: catch_amalgamated.hpp:2173
Definition: catch_amalgamated.hpp:1266
Definition: catch_amalgamated.hpp:2474
Definition: catch_amalgamated.hpp:2092
Definition: catch_amalgamated.hpp:1597
Definition: catch_amalgamated.hpp:4841
Definition: catch_amalgamated.hpp:4749
Definition: catch_amalgamated.hpp:4782
Definition: catch_amalgamated.hpp:4821
Definition: catch_amalgamated.hpp:4836
Definition: catch_amalgamated.hpp:4740
Definition: catch_amalgamated.hpp:4745
Definition: catch_amalgamated.hpp:4754
Definition: catch_amalgamated.hpp:4706
Definition: catch_amalgamated.hpp:4790
Definition: catch_amalgamated.hpp:4522
Definition: catch_amalgamated.hpp:4502
Definition: catch_amalgamated.hpp:4482
Definition: catch_amalgamated.hpp:4488
Definition: catch_amalgamated.hpp:5095
Definition: catch_amalgamated.hpp:4478
Definition: catch_amalgamated.hpp:3935
Definition: catch_amalgamated.hpp:4155
Definition: catch_amalgamated.hpp:788
Definition: catch_amalgamated.hpp:11481
Definition: catch_amalgamated.hpp:11488
Definition: catch_amalgamated.hpp:5489
Provides case-insensitive op== semantics when called.
Definition: catch_amalgamated.hpp:7964
Provides case-insensitive op< semantics when called.
Definition: catch_amalgamated.hpp:7958
Definition: catch_amalgamated.hpp:2879
Definition: catch_amalgamated.hpp:11825
Definition: catch_amalgamated.hpp:3366
Definition: catch_amalgamated.hpp:2858
Definition: catch_amalgamated.hpp:7355
Definition: catch_amalgamated.hpp:9136
Definition: catch_amalgamated.hpp:8586
Definition: catch_amalgamated.hpp:8612
Definition: catch_amalgamated.hpp:10891
Definition: catch_amalgamated.hpp:10208
Definition: catch_amalgamated.hpp:4308
Definition: catch_amalgamated.hpp:1096
Definition: catch_amalgamated.hpp:4297
ReporterSpec but with the defaults filled in.
Definition: catch_amalgamated.hpp:4142
Definition: catch_amalgamated.hpp:5211
Definition: catch_amalgamated.hpp:1299
Definition: catch_amalgamated.hpp:8609
By setting up its preferences, a reporter can modify Catch2's behaviour in some regards,...
Definition: catch_amalgamated.hpp:1419
bool shouldReportAllAssertions
Catch2 should call Reporter::assertionEnded even for passing assertions.
Definition: catch_amalgamated.hpp:1425
bool shouldRedirectStdOut
Catch2 should redirect writes to stdout and pass them to the reporter.
Definition: catch_amalgamated.hpp:1422
Definition: catch_amalgamated.hpp:885
Definition: catch_amalgamated.hpp:860
Definition: catch_amalgamated.hpp:833
Definition: catch_amalgamated.hpp:819
Definition: catch_amalgamated.hpp:1341
Definition: catch_amalgamated.hpp:757
Definition: catch_amalgamated.hpp:4277
Definition: catch_amalgamated.hpp:3001
Definition: catch_amalgamated.hpp:5190
Definition: catch_amalgamated.hpp:8617
A view of a tag string that provides case insensitive comparisons.
Definition: catch_amalgamated.hpp:6807
Various metadata about the test case.
Definition: catch_amalgamated.hpp:6838
Definition: catch_amalgamated.hpp:1353
Definition: catch_amalgamated.hpp:8788
Used to signal that an assertion macro failed.
Definition: catch_amalgamated.hpp:1688
Definition: catch_amalgamated.hpp:1321
Definition: catch_amalgamated.hpp:1367
Definition: catch_amalgamated.hpp:3776
Definition: catch_amalgamated.hpp:801
Definition: catch_amalgamated.hpp:7019
Definition: catch_amalgamated.hpp:241
Definition: catch_amalgamated.hpp:213
What
Definition: catch_amalgamated.hpp:213
@ UnmatchedTestSpec
A command line test spec matched no test cases.
Definition: catch_amalgamated.hpp:218
@ NoAssertions
A test case or leaf section did not run any assertions.
Definition: catch_amalgamated.hpp:216
Definition: catch_amalgamated.hpp:1702
Definition: catch_amalgamated.hpp:1705
Definition: catch_amalgamated.hpp:1713
Definition: catch_amalgamated.hpp:3373
Definition: catch_amalgamated.hpp:11642
Definition: catch_amalgamated.hpp:3430
Definition: catch_amalgamated.hpp:1704
Definition: catch_amalgamated.hpp:2920