• Home
  • Raw
  • Download

Lines Matching +full:clang +full:- +full:analyzer

1 // ====================================================================== lgtm [cpp/missing-header-
2 // == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! ==
5 // doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD
7 // Copyright (c) 2016-2023 Viktor Kirilov
20 // The library is heavily influenced by Catch - https://github.com/catchorg/Catch2
21 // which uses the Boost Software License - Version 1.0
22 // see here - https://github.com/catchorg/Catch2/blob/master/LICENSE.txt
26 // - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<>
27 // - the Approx() helper class for floating point comparison
28 // - colors in the console
29 // - breaking into a debugger
30 // - signal / SEH handling
31 // - timer
32 // - XmlWriter class - thanks to Phil Nash for allowing the direct reuse (AKA copy/paste)
34 // The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest
35 // which uses the Boost Software License - Version 1.0
36 // see here - https://github.com/martinmoene/lest/blob/master/LICENSE.txt
79 // GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl...
117 #define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
118 #define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w)
119 #define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
164 DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") \
165 DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") \
166 DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded") \
167 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") \
168 DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
169 DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
172 DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \
173 DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") \
174 DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") \
175 DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") \
176 DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") \
177 DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") \
178 DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") \
179 DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") \
199 DOCTEST_MSVC_SUPPRESS_WARNING(4640) /* construction of local static object not thread-safe */ \
201 DOCTEST_MSVC_SUPPRESS_WARNING(5264) /* 'variable-name': 'const' variable is not used */ \
217 DOCTEST_CLANG_SUPPRESS_WARNING("-Wnon-virtual-dtor")
218 DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated")
221 DOCTEST_GCC_SUPPRESS_WARNING("-Wctor-dtor-privacy")
222 DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor")
223 DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-promo")
230 DOCTEST_MSVC_SUPPRESS_WARNING(4548) /* before comma no effect; expected side - effect */ \
247 DOCTEST_MSVC_SUPPRESS_WARNING(5262) /* implicit fall-through */
256 // MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
257 // GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
451 … DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \
460 #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler)
467 #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler)
469 // https://www.cocoawithlove.com/2008/03/break-into-debugger.html
470 …c\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n": : : "memory","r0","r3","r4") // NOLINT(hicpp-no-assembler)
472 #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("brk #0"); // NOLINT(hicpp-no-assembler)
477 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wredundant-decls")
493 // for clang - always include ciso646 (which drags some std stuff) because
495 // which case we don't want to forward declare stuff from std - for reference:
500 #endif // clang
522 namespace std { // NOLINT(cert-dcl58-cpp)
523 typedef decltype(nullptr) nullptr_t; // NOLINT(modernize-use-using)
524 typedef decltype(sizeof(void*)) size_t; // NOLINT(modernize-use-using)
530 class basic_ostream; // NOLINT(fuchsia-virtual-inheritance)
531 typedef basic_ostream<char, char_traits<char>> ostream; // NOLINT(modernize-use-using)
537 typedef basic_istream<char, char_traits<char>> istream; // NOLINT(modernize-use-using)
569 // of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used fo…
570 // - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128)
571 // - if small - capacity left before going on the heap - using the lowest 5 bits
572 // - if small - 2 bits are left unused - the second and third highest ones
573 // - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator)
575 // Idea taken from this lecture about the string implementation of facebook/folly - fbstring
576 // https://www.youtube.com/watch?v=kPR8h4-qZdk
578 // - optimizations - like not deleting memory unnecessarily in operator= and etc.
579 // - resize/reserve/clear
580 // - replace
581 // - back/front
582 // - iterator stuff
583 // - find & friends
584 // - push_back/pop_back
585 // - assign/insert/erase
586 // - relational operators as free functions - taking const char* as one of the params
594 static DOCTEST_CONSTEXPR size_type last = len - 1; //!OCLINT avoid private static members
596 struct view // len should be more than sizeof(view) - because of the final byte for flags
605 char buf[len]; // NOLINT(*-avoid-c-arrays)
619 static DOCTEST_CONSTEXPR size_type npos = static_cast<size_type>(-1);
624 // cppcheck-suppress noExplicitConstructor
641 // the only functions I'm willing to leave in the interface - available for inlining
642 const char* c_str() const { return const_cast<String*>(this)->c_str(); } // NOLINT in c_str()
729 is_unary = 2 * is_false, // not checked anywhere - used just to distinguish the types
810 String m_file; // the file in which the test was registered (using String - see #350)
826 // common - for all asserts
834 // exception-related - for all asserts
841 // for specific exception-related asserts
917 bool no_throw; // to skip exceptions-related assertion macros
973 // NOLINTNEXTLINE(*-avoid-c-arrays)
1057 void filloss(std::ostream* stream, const T (&in)[N]) { // NOLINT(*-avoid-c-arrays)
1097 …return ret.substr(beginPos + 1, ret.size() - beginPos - static_cast<String::size_type>(sizeof(">(v…
1101 return ret.substr(begin, ret.size() - begin - 1);
1161 // NOLINTBEGIN(*-avoid-c-arrays)
1173 // NOLINTEND(*-avoid-c-arrays)
1177 // NOLINTBEGIN(*-avoid-c-arrays)
1181 *stream << String(in, in[N - 1] ? N : N - 1);
1182 } // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
1184 // NOLINTEND(*-avoid-c-arrays)
1196 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wmicrosoft-cast")
1246 // clang-format off
1279 // clang-format on
1310 // clang-format off
1322 // clang-format on
1360 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-comparison")
1379 if(!res || doctest::getContextOptions()->success) \
1384 // more checks could be added - like in Catch:
1395 struct DOCTEST_INTERFACE Result // NOLINT(*-member-init)
1417 DOCTEST_FORBIT_EXPRESSION(Result, -=)
1431 DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion")
1432 DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-compare")
1433 //DOCTEST_CLANG_SUPPRESS_WARNING("-Wdouble-promotion")
1434 //DOCTEST_CLANG_SUPPRESS_WARNING("-Wconversion")
1435 //DOCTEST_CLANG_SUPPRESS_WARNING("-Wfloat-equal")
1438 DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion")
1439 DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-compare")
1440 //DOCTEST_GCC_SUPPRESS_WARNING("-Wdouble-promotion")
1441 //DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion")
1442 //DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal")
1453 // clang-format off
1465 // clang-format on
1498 // cppcheck-suppress copyCtorAndEqOperator
1517 if(!res || getContextOptions()->success) {
1523 /* This is required for user-defined conversions from Expression_lhs to L */
1526 // clang-format off
1533 // clang-format on
1543 DOCTEST_FORBIT_EXPRESSION(Expression_lhs, -=)
1552 …// these 2 are unfortunate because they should be allowed - they have higher precedence over the c…
1577 …// but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problem…
1618 String m_type; // for templated test cases - gets appended to the real name
1623 const String& type = String(), int template_id = -1);
1628 DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function
1667 // clang-format off
1672 // clang-format on
1695 if (m_failed || getContextOptions()->success) {
1709 if (m_failed || getContextOptions()->success) {
1744 if(isDebuggerActive() && !getContextOptions()->no_breaks) \
1756 if(rb.m_failed || getContextOptions()->success) \
1770 // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
1787 // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
1811 throw; // lgtm [cpp/rethrow-no-exception]
1812 // cppcheck-suppress catchExceptionByValue
1816 } catch(...) {} //!OCLINT - empty catch statement
1818 static_cast<void>(res); // to silence -Wunused-parameter
1893 // kept here just for backwards-compatibility - the comma operator should be preferred now
1895 MessageBuilder& operator<<(const T& in) { return this->operator,(in); }
1897 // the `,` operator has the lowest operator precedence - if `<<` is used by the user then
1902 MessageBuilder& operator*(const T& in) { return this->operator,(in); }
1936 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors")
1979 ~Context(); // NOLINT(performance-trivially-destructible)
2007 TooManyFailedAsserts = 8, // the abort-after option
2135 // common code in asserts - for convenience
2152 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \
2180 DOCTEST_INLINE_NOINLINE void der::f() // NOLINT(misc-definitions-in-headers)
2196 // for registering tests in classes - requires C++17 for inline variables!
2256 …AL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY), /* NOLINT(cert-err58-cpp, fuchsia-statically-constructed-
2287 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \
2288 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmissing-field-initializers") \
2309 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), /* NOLINT(cert-err58-cpp) */ \
2315 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), /* NOLINT(cert-err58-cpp) */ \
2322 …DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_), /* NOLINT(cert-err58-cpp) …
2332 …DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), /* NOLINT(cert-err58-cpp) */…
2338 …DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), /* NOLINT(cert-err58-cpp) */…
2342 // clang-format off
2343 // for logging - disabling formatting because it's important to have these on 2 separate lines - se…
2348 // clang-format on
2369 // clang-format off
2373 // clang-format on
2384 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
2385 /* NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) */ \
2390 << __VA_ARGS__)) /* NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) */ \
2397 } DOCTEST_FUNC_SCOPE_END // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
2423 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
2446 // clang-format off
2453 // clang-format on
2485 if(!doctest::getContextOptions()->no_throw) { \
2496 } else { /* NOLINT(*-else-after-return) */ \
2503 if(!doctest::getContextOptions()->no_throw) { \
2510 } else { /* NOLINT(*-else-after-return) */ \
2525 // clang-format off
2561 // clang-format on
2888 // clang-format off
2889 // KEPT FOR BACKWARDS COMPATIBILITY - FORWARDING TO THE RIGHT MACROS
2917 // clang-format on
2920 // clang-format off
2931 // clang-format on
3074 // this is here to clear the 'current test suite' for the current translation unit - at the top
3097 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-macros")
3107 DOCTEST_CLANG_SUPPRESS_WARNING("-Wglobal-constructors")
3108 DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
3109 DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion")
3110 DOCTEST_CLANG_SUPPRESS_WARNING("-Wshorten-64-to-32")
3111 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-variable-declarations")
3112 DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch")
3113 DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch-enum")
3114 DOCTEST_CLANG_SUPPRESS_WARNING("-Wcovered-switch-default")
3115 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-noreturn")
3116 DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion")
3117 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces")
3118 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers")
3119 DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-member-function")
3120 DOCTEST_CLANG_SUPPRESS_WARNING("-Wnonportable-system-include-path")
3123 DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion")
3124 DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion")
3125 DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-field-initializers")
3126 DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-braces")
3127 DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch")
3128 DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum")
3129 DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default")
3130 DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations")
3131 DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast")
3132 DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-function")
3133 DOCTEST_GCC_SUPPRESS_WARNING("-Wmultiple-inheritance")
3134 DOCTEST_GCC_SUPPRESS_WARNING("-Wsuggest-attribute")
3148 // required includes - will go only in one translation unit!
3152 // borland (Embarcadero) compiler requires math.h and not cmath - https://github.com/doctest/doctes…
3210 // not sure what AfxWin.h is for - here I do what Catch does
3226 // https://mail.gnome.org/archives/xml/2012-January/msg00000.html
3243 #define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-"
3309 const int d = tolower(*a) - tolower(*b);
3352 unsigned sz = static_cast<unsigned>(ss.tellp() - pos);
3353 ss.rdbuf()->pubseekpos(pos, std::ios::in | std::ios::out);
3391 return ((t.QuadPart - hzo.QuadPart) * LONGLONG(1000000)) / hz.QuadPart;
3405 return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
3410 …double getElapsedSeconds() const { return static_cast<double>(getCurrentTicks() - m_ticks) / 10000…
3444 char padding[DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE - sizeof(Atomic<T>)];
3474 T operator=(T desired) DOCTEST_NOEXCEPT { // lgtm [cpp/assignment-does-not-return-this]
3497 // assigned in a round-robin fashion.
3548 // update the non-atomic counters
3557 if(Approx(currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
3558 Approx(seconds).epsilon(DBL_EPSILON) > currentTest->m_timeout)
3561 if(currentTest->m_should_fail) {
3567 } else if(failure_flags && currentTest->m_may_fail) {
3569 } else if(currentTest->m_expected_failures > 0) {
3570 if(numAssertsFailedCurrentTest == currentTest->m_expected_failures) {
3581 // if any subcase has failed - the whole test case has failed
3591 // TODO: figure out if this is indeed necessary/correct - seems like either there still
3601 setLast(last - sz);
3616 if (isOnStack()) { buf[sz] = '\0'; setLast(last - sz); }
3636 } // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
3670 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
3671 setLast(last - total_size);
3730 return const_cast<String*>(this)->operator[](i);
3739 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmaybe-uninitialized")
3742 return last - (size_type(buf[last]) & 31); // using "last" would work only if "len" is 32
3754 cnt = std::min(cnt, size() - 1 - pos);
3762 cnt = std::min(cnt, size() - 1 - pos);
3771 if (it < end) { return static_cast<size_type>(it - begin); }
3777 const char* it = begin + std::min(pos, size() - 1);
3778 for (; it >= begin && *it != ch; it--);
3779 if (it >= begin) { return static_cast<size_type>(it - begin); }
3830 // clang-format off
3869 // clang-format on
3881 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference")
3882 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference")
3886 if(getContextOptions()->no_path_in_filenames) {
3926 os->operator<<(t);
3985 return std::fabs(lhs - rhs.m_value) <
4068 // the int (priority) is part of the key for automatic sorting - sadly one can register a
4083 for(auto& curr_rep : g_cs->reporters_currently_used) \
4084 curr_rep->function(__VA_ARGS__)
4091 && getContextOptions()->abort_after > 0 &&
4092 (g_cs->numAssertsFailed + g_cs->numAssertsFailedCurrentTest_atomic) >=
4093 getContextOptions()->abort_after)
4101 g_cs->shouldLogCurrentException = false;
4102 throw TestFailureException(); // NOLINT(hicpp-exception-baseclass)
4112 // https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing
4165 // C string hash function (djb2) - taken from http://www.cse.yorku.ca/~oz/hash.html
4198 if (g_cs->subcaseStack.size() < size_t(g_cs->subcase_filter_levels)) {
4199 … if (!matchesAny(m_signature.m_name.c_str(), g_cs->filters[6], true, g_cs->case_sensitive))
4201 … if (matchesAny(m_signature.m_name.c_str(), g_cs->filters[7], false, g_cs->case_sensitive))
4209 if (!g_cs->reachedLeaf) {
4210 if (g_cs->nextSubcaseStack.size() <= g_cs->subcaseStack.size()
4211 || g_cs->nextSubcaseStack[g_cs->subcaseStack.size()] == m_signature) {
4215 g_cs->subcaseStack.push_back(m_signature);
4216 g_cs->currentSubcaseDepth++;
4221 if (g_cs->subcaseStack[g_cs->currentSubcaseDepth] == m_signature) {
4223 g_cs->currentSubcaseDepth++;
4226 } else if (g_cs->nextSubcaseStack.size() <= g_cs->currentSubcaseDepth
4227 …&& g_cs->fullyTraversedSubcases.find(hash(hash(g_cs->subcaseStack, g_cs->currentSubcaseDepth), has…
4228 == g_cs->fullyTraversedSubcases.end()) {
4231 g_cs->nextSubcaseStack.clear();
4232 g_cs->nextSubcaseStack.insert(g_cs->nextSubcaseStack.end(),
4233 … g_cs->subcaseStack.begin(), g_cs->subcaseStack.begin() + g_cs->currentSubcaseDepth);
4234 g_cs->nextSubcaseStack.push_back(m_signature);
4240 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
4241 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
4245 g_cs->currentSubcaseDepth--;
4247 if (!g_cs->reachedLeaf) {
4249 g_cs->fullyTraversedSubcases.insert(hash(g_cs->subcaseStack));
4250 g_cs->nextSubcaseStack.clear();
4251 g_cs->reachedLeaf = true;
4252 } else if (g_cs->nextSubcaseStack.empty()) {
4254 g_cs->fullyTraversedSubcases.insert(hash(g_cs->subcaseStack));
4262 && g_cs->shouldLogCurrentException) {
4264 test_case_exception, {"exception thrown in subcase - will translate later "
4268 g_cs->shouldLogCurrentException = false;
4318 DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function
4326 if(m_template_id != -1)
4335 if(m_template_id != -1) {
4344 // this will be used only to differentiate between test cases - not relevant for sorting
4368 const int res = lhs->m_file.compare(rhs->m_file, bool(DOCTEST_MSVC));
4371 if(lhs->m_line != rhs->m_line)
4372 return lhs->m_line < rhs->m_line;
4373 return lhs->m_template_id < rhs->m_template_id;
4378 const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite);
4386 const int res = std::strcmp(lhs->m_name, rhs->m_name);
4392 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
4398 (isatty(STDOUT_FILENO) == false && getContextOptions()->force_colors == false))
4402 // clang-format off
4419 // clang-format on
4425 (_isatty(_fileno(stdout)) == false && getContextOptions()->force_colors == false))
4446 // clang-format off
4463 // clang-format on
4478 if(curr->translate(res))
4480 // clang-format off
4481 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wcatch-value")
4494 // clang-format on
4526 // https://github.com/catchorg/Catch2/blob/v2.13.1/include/internal/catch_debugger.cpp#L79-L102
4559 std::cerr << "\nCall to sysctl failed - unable to determine if debugger is active **\n";
4593 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
4594 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
4606 this->stringify(&s);
4607 g_cs->stringifiedContexts.push_back(s.str().c_str());
4637 // There is no 1-1 mapping between signals and windows exceptions.
4642 "SIGILL - Illegal instruction signal"},
4643 {static_cast<DWORD>(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow"},
4645 "SIGSEGV - Segmentation violation signal"},
4661 if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
4669 if(isDebuggerActive() && !g_cs->no_breaks)
4694 // - std::terminate is called FROM THE TEST RUNNER THREAD
4695 // - an exception is thrown from a destructor FROM THE TEST RUNNER THREAD
4699 if(isDebuggerActive() && !g_cs->no_breaks)
4701 … std::exit(EXIT_FAILURE); // explicitly exit - otherwise the SIGABRT handler may be called as well
4705 // - std::terminate is called FROM A DIFFERENT THREAD
4706 // - an exception is thrown from a destructor FROM A DIFFERENT THREAD
4707 // - an uncaught exception is thrown FROM A DIFFERENT THREAD
4710 reportFatal("SIGABRT - Abort (abnormal termination) signal");
4711 if(isDebuggerActive() && !g_cs->no_breaks)
4720 // the user does not want to see pop-up dialogs about crashes
4726 // offering a choice to debug the aborted program - we want to disable that.
4731 // Instead ask the CRT to dump such assertions to stderr non-interactively.
4785 SignalDefs signalDefs[] = {{SIGINT, "SIGINT - Terminal interrupt signal"},
4786 {SIGILL, "SIGILL - Illegal instruction signal"},
4787 {SIGFPE, "SIGFPE - Floating point error signal"},
4788 {SIGSEGV, "SIGSEGV - Segmentation violation signal"},
4789 {SIGTERM, "SIGTERM - Termination request signal"},
4790 {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}};
4840 … // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
4874 g_cs->numAssertsCurrentTest_atomic++;
4879 g_cs->numAssertsFailedCurrentTest_atomic++;
4884 g_cs->failure_flags |= TestCaseFailureReason::Crash;
4888 while (g_cs->subcaseStack.size()) {
4889 g_cs->subcaseStack.pop_back();
4893 g_cs->finalizeTestCaseData();
4904 : m_test_case(g_cs->currentTest), m_at(at), m_file(file), m_line(line), m_expr(expr),
4958 return m_failed && isDebuggerActive() && !getContextOptions()->no_breaks &&
4959 … (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger
4968 if(g_cs->ah)
4969 g_cs->ah(ad);
4979 // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
5017 return isDebuggerActive() && !getContextOptions()->no_breaks && !isWarn &&
5018 … (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger
5029 // clang-format off
5033 // This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched.
5067 m_writer->writeAttribute( name, attribute );
5129 // This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched.
5146 DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
5159 DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
5189 if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']')
5203 // Check for control characters and invalid utf-8
5206 … // see https://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
5218 // UTF-8 territory
5231 // Are there enough bytes left to avoid accessing out-of-bounds memory?
5232 if (idx + encBytes - 1 >= m_str.size()) {
5237 // The next encBytes bytes must together be a valid utf-8
5261 // If we got here, this is in fact a valid(ish) utf-8 sequence
5265 idx += encBytes - 1;
5286 m_writer->endElement();
5296 m_writer->endElement();
5300 m_writer->writeText( text, indent );
5306 …// writeDeclaration(); // called explicitly by the reporters that use the writer class - see issue…
5332 m_indent = m_indent.substr( 0, m_indent.size()-2 );
5376 // m_os << m_indent << "<!--" << text << "-->";
5382 // m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
5399 m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
5410 // End of copy-pasted code from Catch
5413 // clang-format on
5420 // caching pointers/references to objects of these types - safe to do
5434 contexts[i]->stringify(&ss);
5446 if(std::strcmp(tc->m_test_suite, in.m_test_suite) != 0) {
5492 xml.scopedElement("TestCase").writeAttribute("name", in.data[i]->m_name)
5493 .writeAttribute("testsuite", in.data[i]->m_test_suite)
5494 … .writeAttribute("filename", skipPathFromFilename(in.data[i]->m_file.c_str()))
5495 .writeAttribute("line", line(in.data[i]->m_line))
5496 .writeAttribute("skipped", in.data[i]->m_skip);
5499 .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters);
5502 xml.scopedElement("TestSuite").writeAttribute("name", in.data[i]->m_test_suite);
5504 .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters);
5506 .writeAttribute("unskipped", in.run_stats->numTestSuitesPassingFilters);
5514 // remove .exe extension - mainly to have the same output on UNIX and Windows
5518 binary_name = binary_name.substr(0, binary_name.length() - 4);
5539 if(tc) // the TestSuite tag - only if there has been at least 1 test case
5543 .writeAttribute("successes", p.numAsserts - p.numAssertsFailed)
5548 p.numTestCasesPassingFilters - p.numTestCasesFailed)
5551 xml.writeAttribute("skipped", p.numTestCases - p.numTestCasesPassingFilters);
5567 st.numAssertsCurrentTest - st.numAssertsFailedCurrentTest)
5572 if(tc->m_expected_failures)
5573 xml.writeAttribute("expected_failures", tc->m_expected_failures);
5705 // - log_message()
5706 // - respond to queries
5707 // - honor remaining options
5708 // - more attributes in tags
5723 auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
5733 const char* const fmt = "%Y-%m-%dT%H:%M:%SZ";
5771 if(time < 1e-4)
5794 // caching pointers/references to objects of these types - safe to do
5817 // remove .exe extension - mainly to have the same output on UNIX and Windows
5821 binary_name = binary_name.substr(0, binary_name.length() - 4);
5936 contexts[i]->stringify(&s);
5966 // caching pointers/references to objects of these types - safe to do
6014 contexts[i]->stringify(&s);
6035 file_line_to_stream(tc->m_file.c_str(), tc->m_line, "\n");
6036 if(tc->m_description)
6037 s << Color::Yellow << "DESCRIPTION: " << Color::None << tc->m_description << "\n";
6038 if(tc->m_test_suite && tc->m_test_suite[0] != '\0')
6039 s << Color::Yellow << "TEST SUITE: " << Color::None << tc->m_test_suite << "\n";
6040 if(strncmp(tc->m_name, " Scenario:", 11) != 0)
6042 s << Color::None << tc->m_name << "\n";
6072 << "run with \"--" DOCTEST_OPTIONS_PREFIX_DISPLAY "help\" for options\n";
6079 // clang-format off
6097 s << "Query flags - the program quits after them. Available:\n\n";
6098 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "?, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "help, -" DOCTES…
6100 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "v, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "version …
6102 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "c, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "count …
6104 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ltc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-cases…
6106 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-suite…
6108 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-reporters …
6113 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case=<filt…
6115 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case-exclu…
6117 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file=<fi…
6119 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sfe, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file-exc…
6121 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite=<fil…
6123 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tse, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite-excl…
6125 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase=<filter…
6127 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-exclude…
6129 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "reporters=<filt…
6131 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "o, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "out=<string> …
6133 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by=<strin…
6135 …ce(sizePrefixDisplay*3) << " <string> - [file/suite/name/ran…
6136 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed=<int>…
6138 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first=<int> …
6140 …zePrefixDisplay*3) << " execute - for range-based execution\…
6141 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "l, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "last=<int> …
6143 …zePrefixDisplay*3) << " execute - for range-based execution\…
6144 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "aa, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "abort-after=<in…
6146 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "scfl,--" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-filter-
6149 s << "Bool options - can be used like flags and true is assumed. Available:\n\n";
6150 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "s, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "success=<bool> …
6152 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "cs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "case-sensitive=…
6154 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "e, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "exit=<bool> …
6156 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "d, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "duration=<bool>…
6158 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "m, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "minimal=<bool> …
6160 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "q, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "quiet=<bool> …
6162 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nt, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-throw=<bool>…
6163 << Whitespace(sizePrefixDisplay*1) << "skips exceptions-related assert checks\n";
6164 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ne, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-exitcode=<bo…
6166 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-run=<bool> …
6168 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ni, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-intro=<bool>…
6170 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nv, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-version=<boo…
6172 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-colors=<bool…
6174 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "fc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "force-colors=<b…
6176 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nb, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-breaks=<bool…
6178 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ns, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-skip=<bool> …
6180 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "gfl, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "gnu-file-line=<…
6182 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenam…
6184 …s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers…
6187 // clang-format on
6226 s << Color::None << in.data[i]->m_name << "\n";
6232 << g_cs->numTestCasesPassingFilters << "\n";
6239 s << Color::None << in.data[i]->m_test_suite << "\n";
6245 << g_cs->numTestCasesPassingFilters << "\n";
6248 << g_cs->numTestSuitesPassingFilters << "\n";
6265 …double>(std::max(p.numTestCasesPassingFilters - p.numTestCasesFailed, static_cast<unsigned>(p.numA…
6272 … << std::setw(passwidth) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed"
6276 const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters;
6284 … << std::setw(passwidth) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None
6304 if(tc->m_no_output)
6308 // else to print - something other than that an assert has failed
6315 << " s: " << tc->m_name << "\n";
6319 << std::fixed << tc->m_timeout << "!\n";
6328 s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures
6331 s << Color::Yellow << "Failed exactly " << tc->m_expected_failures
6335 s << Color::Red << "Aborting - too many failed asserts!\n";
6337 s << Color::None; // lgtm [cpp/useless-expression]
6342 if(tc->m_no_output)
6347 file_line_to_stream(tc->m_file.c_str(), tc->m_line, " ");
6357 for(int i = num_stringified_contexts; i > 0; --i) {
6359 << stringified_contexts[i - 1] << "\n";
6372 --currentSubcaseLevel;
6377 if((!rb.m_failed && !opt.success) || tc->m_no_output)
6393 if(tc->m_no_output)
6452 for(int i = argc; i > 0; --i) {
6453 auto index = i - 1;
6456 // eliminate matches in which the chars before the option are not '-'
6460 if(*curr++ != '-') {
6465 if(noBadCharsFound && argv[index][0] == '-') {
6475 // just a flag - no value
6490 // offset (normally 3 for "dt-") to skip prefix
6563 …is to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on faile…
6571 const char positive[][5] = { "1", "true", "on", "yes" }; // 5 - strlen("true") + 1
6572 const char negative[][6] = { "0", "false", "off", "no" }; // 6 - strlen("false") + 1
6594 p->binary_name = argv[0];
6606 p->binary_name = argv[0];
6613 // clang-format off
6614 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file=", p->filters[0]);
6615 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sf=", p->filters[0]);
6616 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file-exclude=",p->filters[1]);
6617 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sfe=", p->filters[1]);
6618 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite=", p->filters[2]);
6619 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ts=", p->filters[2]);
6620 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite-exclude=", p->filters[3]);
6621 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tse=", p->filters[3]);
6622 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case=", p->filters[4]);
6623 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tc=", p->filters[4]);
6624 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case-exclude=", p->filters[5]);
6625 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tce=", p->filters[5]);
6626 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase=", p->filters[6]);
6627 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sc=", p->filters[6]);
6628 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase-exclude=", p->filters[7]);
6629 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sce=", p->filters[7]);
6630 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "reporters=", p->filters[8]);
6631 … parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "r=", p->filters[8]);
6632 // clang-format on
6640 p->var = static_cast<bool>(intRes); \
6643 p->var = true; \
6645 p->var = default
6650 p->var = intRes; \
6652 p->var = default
6658 p->var = strRes
6660 // clang-format off
6662 DOCTEST_PARSE_STR_OPTION("order-by", "ob", order_by, "file");
6663 DOCTEST_PARSE_INT_OPTION("rand-seed", "rs", rand_seed, 0);
6668 DOCTEST_PARSE_INT_OPTION("abort-after", "aa", abort_after, 0);
6669 DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, INT_MAX);
6672 DOCTEST_PARSE_AS_BOOL_OR_FLAG("case-sensitive", "cs", case_sensitive, false);
6677 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-throw", "nt", no_throw, false);
6678 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-exitcode", "ne", no_exitcode, false);
6679 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-run", "nr", no_run, false);
6680 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-intro", "ni", no_intro, false);
6681 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-version", "nv", no_version, false);
6682 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-colors", "nc", no_colors, false);
6683 DOCTEST_PARSE_AS_BOOL_OR_FLAG("force-colors", "fc", force_colors, false);
6684 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-breaks", "nb", no_breaks, false);
6685 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false);
6686 DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC));
6687 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false);
6688 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false);
6689 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-debug-output", "ndo", no_debug_output, false);
6690 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false);
6691 DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-time-in-output", "ntio", no_time_in_output, false);
6692 // clang-format on
6695 p->help = false;
6696 p->version = false;
6697 p->count = false;
6698 p->list_test_cases = false;
6699 p->list_test_suites = false;
6700 p->list_reporters = false;
6705 p->help = true;
6706 p->exit = true;
6710 p->version = true;
6711 p->exit = true;
6715 p->count = true;
6716 p->exit = true;
6718 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-cases") ||
6720 p->list_test_cases = true;
6721 p->exit = true;
6723 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-suites") ||
6725 p->list_test_suites = true;
6726 p->exit = true;
6728 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-reporters") ||
6730 p->list_reporters = true;
6731 p->exit = true;
6740 for(auto& curr : p->filters)
6756 auto argv = String("-") + option + "=" + value;
6762 bool Context::shouldExit() { return p->exit; }
6766 void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; }
6768 void Context::setCout(std::ostream* out) { p->cout = out; }
6797 … // save the old context state in case such was setup - for using asserts out of a testing context
6803 g_no_colors = p->no_colors;
6804 p->resetRunData();
6807 if(p->cout == nullptr) {
6808 if(p->quiet) {
6809 p->cout = &discardOut;
6810 } else if(p->out.size()) {
6812 fstr.open(p->out.c_str(), std::fstream::out);
6813 p->cout = &fstr;
6817 p->cout = &std::cout;
6837 for(auto& curr : p->reporters_currently_used)
6839 p->reporters_currently_used.clear();
6841 if(p->numTestCasesFailed && !p->no_exitcode)
6847 if(p->filters[8].empty())
6848 p->filters[8].push_back("console");
6852 if(matchesAny(curr.first.second.c_str(), p->filters[8], false, p->case_sensitive))
6853 p->reporters_currently_used.push_back(curr.second(*g_cs));
6860 p->reporters_currently_used.insert(p->reporters_currently_used.begin(), curr.second(*g_cs));
6863 if(isDebuggerActive() && p->no_debug_output == false)
6864 p->reporters_currently_used.push_back(new DebugOutputWindowReporter(*g_cs));
6868 if(p->no_run || p->version || p->help || p->list_reporters) {
6877 p->numTestCases = testArray.size();
6881 if(p->order_by.compare("file", true) == 0) {
6883 } else if(p->order_by.compare("suite", true) == 0) {
6885 } else if(p->order_by.compare("name", true) == 0) {
6887 } else if(p->order_by.compare("rand", true) == 0) {
6888 std::srand(p->rand_seed);
6892 for(size_t i = testArray.size() - 1; i > 0; --i) {
6900 } else if(p->order_by.compare("none", true) == 0) {
6901 // means no sorting - beneficial for death tests which call into the executable
6902 // with a specific test case in mind - we don't want to slow down the startup times
6908 …bool query_mode = p->count || p->list_test_cases || p->list_test_suite…
6919 if(tc.m_skip && !p->no_skip)
6922 if(!matchesAny(tc.m_file.c_str(), p->filters[0], true, p->case_sensitive))
6924 if(matchesAny(tc.m_file.c_str(), p->filters[1], false, p->case_sensitive))
6926 if(!matchesAny(tc.m_test_suite, p->filters[2], true, p->case_sensitive))
6928 if(matchesAny(tc.m_test_suite, p->filters[3], false, p->case_sensitive))
6930 if(!matchesAny(tc.m_name, p->filters[4], true, p->case_sensitive))
6932 if(matchesAny(tc.m_name, p->filters[5], false, p->case_sensitive))
6936 p->numTestCasesPassingFilters++;
6939 if((p->last < p->numTestCasesPassingFilters && p->first <= p->last) ||
6940 (p->first > p->numTestCasesPassingFilters))
6950 if(p->count)
6954 if(p->list_test_cases) {
6960 if(p->list_test_suites) {
6964 p->numTestSuitesPassingFilters++;
6971 p->currentTest = &tc;
6973 p->failure_flags = TestCaseFailureReason::None;
6974 p->seconds = 0;
6977 p->numAssertsFailedCurrentTest_atomic = 0;
6978 p->numAssertsCurrentTest_atomic = 0;
6980 p->fullyTraversedSubcases.clear();
6984 p->timer.start();
6990 p->reachedLeaf = false;
6992 p->subcaseStack.clear();
6993 p->currentSubcaseDepth = 0;
6995 p->shouldLogCurrentException = true;
6998 p->stringifiedContexts.clear();
7012 p->failure_flags |= TestCaseFailureReason::AssertFailure;
7016 p->failure_flags |= TestCaseFailureReason::Exception;
7020 // exit this loop if enough assertions have failed - even if there are more subcases
7021 if(p->abort_after > 0 &&
7022 p->numAssertsFailed + p->numAssertsFailedCurrentTest_atomic >= p->abort_after) {
7024 p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts;
7027 if(!p->nextSubcaseStack.empty() && run_test)
7029 if(p->nextSubcaseStack.empty())
7033 p->finalizeTestCaseData();
7037 p->currentTest = nullptr;
7040 if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after)
7065 int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); }
7067 return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr;
7084 DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007) // 'function' : must be 'attribute' - see issue #182