moved to nullptr, removed c++98-compat warning suppressions for clang (also long-long and 0 as null for gcc/clang)
diff --git a/.travis.yml b/.travis.yml
index 6ec4e84..171bcf4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -390,7 +390,7 @@
# clang-tidy
cd scripts/playground
cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} . || exit 1
- clang-tidy-4.0 -p=. *.cpp -header-filter=.* -warnings-as-errors=* -checks='*,-misc-misplaced-widening-cast,-misc-macro-parentheses,-misc-definitions-in-headers,-misc-unused-parameters,-llvm-header-guard,-llvm-include-order,-google-readability-braces-around-statements,-google-runtime-references,-google-readability-todo,-google-build-using-namespace,-google-explicit-constructor,-cert-err58-cpp,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-union-access,-clang-analyzer-security.insecureAPI.strcpy,-modernize-loop-convert,-modernize-use-auto,-modernize-use-bool-literals,-readability-braces-around-statements,-readability-named-parameter,-readability-else-after-return,-readability-redundant-declaration,-readability-implicit-bool-cast,-clang-diagnostic-variadic-macros' || exit 1
+ clang-tidy-4.0 -std=c++11 -p=. *.cpp -header-filter=.* -warnings-as-errors=* -checks='*,-misc-misplaced-widening-cast,-misc-macro-parentheses,-misc-definitions-in-headers,-misc-unused-parameters,-llvm-header-guard,-llvm-include-order,-google-readability-braces-around-statements,-google-runtime-references,-google-readability-todo,-google-build-using-namespace,-google-explicit-constructor,-cert-err58-cpp,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-union-access,-clang-analyzer-security.insecureAPI.strcpy,-modernize-loop-convert,-modernize-use-auto,-modernize-use-bool-literals,-readability-braces-around-statements,-readability-named-parameter,-readability-else-after-return,-readability-redundant-declaration,-readability-implicit-bool-cast,-clang-diagnostic-variadic-macros,-clang-diagnostic-c++11-compat' || exit 1
# do not continue with other build configurations after that
exit
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 6acddea..133564c 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -162,12 +162,6 @@
DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++11-long-long")
-#if DOCTEST_CLANG && DOCTEST_CLANG_HAS_WARNING("-Wzero-as-null-pointer-constant")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
-#endif // clang - 0 as null
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
@@ -179,8 +173,6 @@
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor")
DOCTEST_GCC_SUPPRESS_WARNING("-Winline")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wlong-long")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
@@ -777,9 +769,6 @@
// cppcheck-suppress unusedStructMember
{ static const bool value = false; };
- // to silence the warning "-Wzero-as-null-pointer-constant" only for gcc 5 for the Approx template ctor - pragmas don't work for it...
- inline void* getNull() { return 0; }
-
namespace has_insertion_operator_impl {
typedef char no;
typedef char yes[2];
@@ -915,7 +904,7 @@
template <typename T>
explicit Approx(const T& value,
typename detail::enable_if<std::is_constructible<double, T>::value>::type* =
- static_cast<T*>(detail::getNull())) {
+ static_cast<T*>(nullptr)) {
*this = Approx(static_cast<double>(value));
}
#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
@@ -1578,8 +1567,8 @@
Chunk stackChunks[DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK];
int numCaptures = 0;
- Node* head = 0;
- Node* tail = 0;
+ Node* head = nullptr;
+ Node* tail = nullptr;
ContextBuilder(ContextBuilder& other);
@@ -1602,7 +1591,7 @@
my_memcpy(stackChunks[numCaptures].buf, &temp, sizeof(Chunk));
} else {
auto curr = new Node;
- curr->next = 0;
+ curr->next = nullptr;
if(tail) {
tail->next = curr;
tail = curr;
@@ -1715,7 +1704,7 @@
void parseArgs(int argc, const char* const* argv, bool withDefaults = false);
public:
- explicit Context(int argc = 0, const char* const* argv = 0);
+ explicit Context(int argc = 0, const char* const* argv = nullptr);
DOCTEST_DELETE_COPIES(Context);
@@ -1903,9 +1892,6 @@
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon) \
template <typename T> \
inline void anon(); \
- DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
template <typename Type, typename... Rest> \
struct DOCTEST_CAT(id, ITERATOR) \
{ \
@@ -1914,7 +1900,6 @@
DOCTEST_CAT(id, ITERATOR)<Rest...>(line, index + 1); \
} \
}; \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP \
template <typename Type> \
struct DOCTEST_CAT(id, ITERATOR)<Type> \
{ \
@@ -1932,16 +1917,12 @@
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \
- DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = []() { \
DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__> DOCTEST_UNUSED DOCTEST_CAT(anon, inner_dummy)( \
__LINE__, 0); \
return 0; \
}(); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ DOCTEST_GLOBAL_NO_WARNINGS_END()
#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \
DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), \
@@ -1959,11 +1940,8 @@
// for subcases
#define DOCTEST_SUBCASE(name) \
- if(DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wc++98-compat-bind-to-temporary-copy") \
- const doctest::detail::Subcase & \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
- doctest::detail::Subcase(name, __FILE__, __LINE__) \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP)
+ if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
+ doctest::detail::Subcase(name, __FILE__, __LINE__))
// for grouping tests in test suites by using code blocks
#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
@@ -2674,12 +2652,6 @@
DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++11-long-long")
-#if DOCTEST_CLANG && DOCTEST_CLANG_HAS_WARNING("-Wzero-as-null-pointer-constant")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
-#endif // clang - 0 as null
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
@@ -2697,9 +2669,7 @@
DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum")
DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wlong-long")
DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
@@ -2728,7 +2698,7 @@
DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept'
DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable
DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ...
-DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtr...
+DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtor...
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
@@ -2864,9 +2834,9 @@
std::vector<IReporter*> reporters_currently_used;
- const TestCase* currentTest = 0;
+ const TestCase* currentTest = nullptr;
- assert_handler ah = 0;
+ assert_handler ah = nullptr;
std::vector<IContextScope*> contexts; // for logging with INFO() and friends
std::vector<String> stringifiedContexts; // logging from INFO() due to an exception
@@ -2886,7 +2856,7 @@
}
};
- ContextState* g_contextState = 0;
+ ContextState* g_cs = nullptr;
#endif // DOCTEST_CONFIG_DISABLE
} // namespace detail
@@ -3276,9 +3246,7 @@
String toString(const Approx& in) {
return String("Approx( ") + doctest::toString(in.m_value) + " )";
}
-const ContextOptions* getContextOptions() {
- return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_contextState);
-}
+const ContextOptions* getContextOptions() { return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_cs); }
} // namespace doctest
@@ -3303,9 +3271,9 @@
IReporter::~IReporter() = default;
int IReporter::get_num_active_contexts() { return 0; }
-const IContextScope* const* IReporter::get_active_contexts() { return 0; }
+const IContextScope* const* IReporter::get_active_contexts() { return nullptr; }
int IReporter::get_num_stringified_contexts() { return 0; }
-const String* IReporter::get_stringified_contexts() { return 0; }
+const String* IReporter::get_stringified_contexts() { return nullptr; }
int registerReporter(const char*, int, IReporter*) { return 0; }
@@ -3393,7 +3361,7 @@
} // namespace
namespace detail {
#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, args) \
- for(auto& curr_rep : g_contextState->reporters_currently_used) \
+ for(auto& curr_rep : g_cs->reporters_currently_used) \
curr_rep->function(args)
DOCTEST_DEFINE_DEFAULTS(TestFailureException);
@@ -3404,7 +3372,7 @@
if((at & assertType::is_check) //!OCLINT bitwise operator in conditional
&& getContextOptions()->abort_after > 0 &&
- g_contextState->numAssertsFailed >= getContextOptions()->abort_after)
+ g_cs->numAssertsFailed >= getContextOptions()->abort_after)
return true;
return false;
@@ -3421,8 +3389,8 @@
// matching of a string against a wildcard mask (case sensitivity configurable) taken from
// https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing
int wildcmp(const char* str, const char* wild, bool caseSensitive) {
- const char* cp = 0;
- const char* mp = 0;
+ const char* cp = nullptr;
+ const char* mp = nullptr;
while((*str) && (*wild != '*')) {
if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) &&
@@ -3522,7 +3490,7 @@
Subcase::Subcase(const char* name, const char* file, int line)
: m_signature(name, file, line) {
- ContextState* s = g_contextState;
+ ContextState* s = g_cs;
// if we have already completed it
if(s->subcasesPassed.count(m_signature) != 0)
@@ -3550,7 +3518,7 @@
Subcase::~Subcase() {
if(m_entered) {
- ContextState* s = g_contextState;
+ ContextState* s = g_cs;
s->subcasesCurrentLevel--;
// only mark the subcase as passed if no subcases have been skipped
@@ -3581,7 +3549,7 @@
TestSuite& TestSuite::operator*(const char* in) {
m_test_suite = in;
// clear state
- m_description = 0;
+ m_description = nullptr;
m_skip = false;
m_may_fail = false;
m_should_fail = false;
@@ -3594,7 +3562,7 @@
const char* type, int template_id) {
m_file = file;
m_line = line;
- m_name = 0;
+ m_name = nullptr;
m_test_suite = test_suite.m_test_suite;
m_description = test_suite.m_description;
m_skip = test_suite.m_skip;
@@ -3900,8 +3868,8 @@
, head(other.head)
, tail(other.tail) {
other.numCaptures = 0;
- other.head = 0;
- other.tail = 0;
+ other.head = nullptr;
+ other.tail = nullptr;
memcpy(stackChunks, other.stackChunks,
unsigned(int(sizeof(Chunk)) * DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK));
}
@@ -3936,7 +3904,7 @@
ContextScope::ContextScope(ContextBuilder& temp)
: contextBuilder(temp) {
- g_contextState->contexts.push_back(this);
+ g_cs->contexts.push_back(this);
}
DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17
@@ -3945,9 +3913,9 @@
if(std::uncaught_exception()) {
std::ostringstream s;
this->stringify(&s);
- g_contextState->stringifiedContexts.push_back(s.str().c_str());
+ g_cs->stringifiedContexts.push_back(s.str().c_str());
}
- g_contextState->contexts.pop_back();
+ g_cs->contexts.pop_back();
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_MSVC_SUPPRESS_WARNING_POP
@@ -4116,32 +4084,32 @@
void addAssert(assertType::Enum at) {
if((at & assertType::is_warn) == 0) { //!OCLINT bitwise operator in conditional
- g_contextState->numAsserts++;
- g_contextState->numAssertsForCurrentTestCase++;
+ g_cs->numAsserts++;
+ g_cs->numAssertsForCurrentTestCase++;
}
}
void addFailedAssert(assertType::Enum at) {
if((at & assertType::is_warn) == 0) { //!OCLINT bitwise operator in conditional
- g_contextState->numAssertsFailed++;
- g_contextState->numAssertsFailedForCurrentTestCase++;
+ g_cs->numAssertsFailed++;
+ g_cs->numAssertsFailedForCurrentTestCase++;
}
}
#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH)
void reportFatal(const std::string& message) {
- g_contextState->seconds_so_far += g_timer.getElapsedSeconds();
- g_contextState->failure_flags |= TestCaseFailureReason::Crash;
- g_contextState->error_string = message.c_str();
- g_contextState->should_reenter = false;
+ g_cs->seconds_so_far += g_timer.getElapsedSeconds();
+ g_cs->failure_flags |= TestCaseFailureReason::Crash;
+ g_cs->error_string = message.c_str();
+ g_cs->should_reenter = false;
// TODO: end all currently opened subcases...?
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
- g_contextState->numTestCasesFailed++;
+ g_cs->numTestCasesFailed++;
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
}
#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
} // namespace
@@ -4149,7 +4117,7 @@
ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
const char* exception_type) {
- m_test_case = g_contextState->currentTest;
+ m_test_case = g_cs->currentTest;
m_at = at;
m_file = file;
m_line = line;
@@ -4205,8 +4173,8 @@
}
void failed_out_of_a_testing_context(const AssertData& ad) {
- if(g_contextState->ah)
- g_contextState->ah(ad);
+ if(g_cs->ah)
+ g_cs->ah(ad);
else
std::abort();
}
@@ -4592,14 +4560,14 @@
if(getContextOptions()->count || getContextOptions()->list_test_cases) {
s << Color::Cyan << "[doctest] " << Color::None
<< "unskipped test cases passing the current filters: "
- << g_contextState->numTestCasesPassingFilters << "\n";
+ << g_cs->numTestCasesPassingFilters << "\n";
} else if(getContextOptions()->list_test_suites) {
s << Color::Cyan << "[doctest] " << Color::None
<< "unskipped test cases passing the current filters: "
- << g_contextState->numTestCasesPassingFilters << "\n";
+ << g_cs->numTestCasesPassingFilters << "\n";
s << Color::Cyan << "[doctest] " << Color::None
<< "test suites with unskipped test cases passing the current filters: "
- << g_contextState->numTestSuitesPassingFilters << "\n";
+ << g_cs->numTestSuitesPassingFilters << "\n";
}
}
@@ -4627,12 +4595,12 @@
#define DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(func, type) \
void func(type in) override { \
if(isDebuggerActive()) { \
- bool with_col = getContextOptions()->no_colors; \
- g_contextState->no_colors = false; \
+ bool with_col = getContextOptions()->no_colors; \
+ g_cs->no_colors = false; \
ConsoleReporter::func(in); \
DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \
oss.str(""); \
- g_contextState->no_colors = with_col; \
+ g_cs->no_colors = with_col; \
} \
}
@@ -4725,12 +4693,12 @@
// tokenize with "," as a separator
// cppcheck-suppress strtokCalled
auto pch = std::strtok(filtersString.c_str(), ","); // modifies the string
- while(pch != 0) {
+ while(pch != nullptr) {
if(strlen(pch))
res.push_back(pch);
// uses the strtok() internal state to go to the next token
// cppcheck-suppress strtokCalled
- pch = std::strtok(0, ",");
+ pch = std::strtok(nullptr, ",");
}
return true;
}
@@ -4785,8 +4753,8 @@
}
Context::~Context() {
- if(g_contextState == p)
- g_contextState = 0;
+ if(g_cs == p)
+ g_cs = nullptr;
delete p;
}
@@ -4928,7 +4896,7 @@
// users should query this in their main() and exit the program if true
bool Context::shouldExit() { return p->exit; }
-void Context::setAsDefaultForAssertsOutOfTestCases() { g_contextState = p; }
+void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; }
void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; }
@@ -4936,8 +4904,8 @@
int Context::run() {
using namespace detail;
- auto old_cs = g_contextState;
- g_contextState = p;
+ auto old_cs = g_cs;
+ g_cs = p;
is_running_in_test = true;
p->resetRunData();
@@ -4970,7 +4938,7 @@
if(p->list_reporters)
g_con_rep.printRegisteredReporters();
- g_contextState = old_cs;
+ g_cs = old_cs;
is_running_in_test = false;
return EXIT_SUCCESS;
@@ -5017,7 +4985,7 @@
bool query_mode = p->count || p->list_test_cases || p->list_test_suites;
if(!query_mode)
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_cs);
// invoke the registered functions if they match the filter criteria (or just count them)
for(auto& curr : testArray) {
@@ -5125,13 +5093,13 @@
// call it from here only if we will continue looping for other subcases and
// call it again outside of the loop for one final time - with updated flags
if(p->should_reenter == true) {
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
p->failure_flags &= ~TestCaseFailureReason::Exception;
p->failure_flags &= ~TestCaseFailureReason::AssertFailure;
}
} while(p->should_reenter == true);
- if(g_contextState->numAssertsFailedForCurrentTestCase)
+ if(g_cs->numAssertsFailedForCurrentTestCase)
p->failure_flags |= TestCaseFailureReason::AssertFailure;
if(Approx(p->currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
@@ -5162,9 +5130,9 @@
if(p->failure_flags && !ok_to_fail)
p->numTestCasesFailed++;
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
- p->currentTest = 0;
+ p->currentTest = nullptr;
// stop executing tests if enough assertions have failed
if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after)
@@ -5173,11 +5141,11 @@
}
if(!query_mode)
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
else
g_con_rep.output_query_results();
- g_contextState = old_cs;
+ g_cs = old_cs;
is_running_in_test = false;
if(p->numTestCasesFailed && !p->no_exitcode)
@@ -5191,16 +5159,14 @@
IReporter::~IReporter() = default;
-int IReporter::get_num_active_contexts() { return detail::g_contextState->contexts.size(); }
+int IReporter::get_num_active_contexts() { return detail::g_cs->contexts.size(); }
const IContextScope* const* IReporter::get_active_contexts() {
- return get_num_active_contexts() ? &detail::g_contextState->contexts[0] : 0;
+ return get_num_active_contexts() ? &detail::g_cs->contexts[0] : nullptr;
}
-int IReporter::get_num_stringified_contexts() {
- return detail::g_contextState->stringifiedContexts.size();
-}
+int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); }
const String* IReporter::get_stringified_contexts() {
- return get_num_stringified_contexts() ? &detail::g_contextState->stringifiedContexts[0] : 0;
+ return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr;
}
int registerReporter(const char* name, int priority, IReporter* r) {
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index 9eac365..ba93f3e 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -159,12 +159,6 @@
DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++11-long-long")
-#if DOCTEST_CLANG && DOCTEST_CLANG_HAS_WARNING("-Wzero-as-null-pointer-constant")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
-#endif // clang - 0 as null
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
@@ -176,8 +170,6 @@
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor")
DOCTEST_GCC_SUPPRESS_WARNING("-Winline")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wlong-long")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
@@ -774,9 +766,6 @@
// cppcheck-suppress unusedStructMember
{ static const bool value = false; };
- // to silence the warning "-Wzero-as-null-pointer-constant" only for gcc 5 for the Approx template ctor - pragmas don't work for it...
- inline void* getNull() { return 0; }
-
namespace has_insertion_operator_impl {
typedef char no;
typedef char yes[2];
@@ -912,7 +901,7 @@
template <typename T>
explicit Approx(const T& value,
typename detail::enable_if<std::is_constructible<double, T>::value>::type* =
- static_cast<T*>(detail::getNull())) {
+ static_cast<T*>(nullptr)) {
*this = Approx(static_cast<double>(value));
}
#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
@@ -1575,8 +1564,8 @@
Chunk stackChunks[DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK];
int numCaptures = 0;
- Node* head = 0;
- Node* tail = 0;
+ Node* head = nullptr;
+ Node* tail = nullptr;
ContextBuilder(ContextBuilder& other);
@@ -1599,7 +1588,7 @@
my_memcpy(stackChunks[numCaptures].buf, &temp, sizeof(Chunk));
} else {
auto curr = new Node;
- curr->next = 0;
+ curr->next = nullptr;
if(tail) {
tail->next = curr;
tail = curr;
@@ -1712,7 +1701,7 @@
void parseArgs(int argc, const char* const* argv, bool withDefaults = false);
public:
- explicit Context(int argc = 0, const char* const* argv = 0);
+ explicit Context(int argc = 0, const char* const* argv = nullptr);
DOCTEST_DELETE_COPIES(Context);
@@ -1900,9 +1889,6 @@
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon) \
template <typename T> \
inline void anon(); \
- DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
template <typename Type, typename... Rest> \
struct DOCTEST_CAT(id, ITERATOR) \
{ \
@@ -1911,7 +1897,6 @@
DOCTEST_CAT(id, ITERATOR)<Rest...>(line, index + 1); \
} \
}; \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP \
template <typename Type> \
struct DOCTEST_CAT(id, ITERATOR)<Type> \
{ \
@@ -1929,16 +1914,12 @@
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \
- DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
- DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = []() { \
DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__> DOCTEST_UNUSED DOCTEST_CAT(anon, inner_dummy)( \
__LINE__, 0); \
return 0; \
}(); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ DOCTEST_GLOBAL_NO_WARNINGS_END()
#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \
DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), \
@@ -1956,11 +1937,8 @@
// for subcases
#define DOCTEST_SUBCASE(name) \
- if(DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wc++98-compat-bind-to-temporary-copy") \
- const doctest::detail::Subcase & \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
- doctest::detail::Subcase(name, __FILE__, __LINE__) \
- DOCTEST_CLANG_SUPPRESS_WARNING_POP)
+ if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
+ doctest::detail::Subcase(name, __FILE__, __LINE__))
// for grouping tests in test suites by using code blocks
#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
diff --git a/doctest/parts/doctest_impl.h b/doctest/parts/doctest_impl.h
index 16eea0b..5a45c85 100644
--- a/doctest/parts/doctest_impl.h
+++ b/doctest/parts/doctest_impl.h
@@ -24,12 +24,6 @@
DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++11-long-long")
-#if DOCTEST_CLANG && DOCTEST_CLANG_HAS_WARNING("-Wzero-as-null-pointer-constant")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
-#endif // clang - 0 as null
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
@@ -47,9 +41,7 @@
DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum")
DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wlong-long")
DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast")
-DOCTEST_GCC_SUPPRESS_WARNING("-Wzero-as-null-pointer-constant")
DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
@@ -78,7 +70,7 @@
DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept'
DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable
DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ...
-DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtr...
+DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtor...
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
@@ -214,9 +206,9 @@
std::vector<IReporter*> reporters_currently_used;
- const TestCase* currentTest = 0;
+ const TestCase* currentTest = nullptr;
- assert_handler ah = 0;
+ assert_handler ah = nullptr;
std::vector<IContextScope*> contexts; // for logging with INFO() and friends
std::vector<String> stringifiedContexts; // logging from INFO() due to an exception
@@ -236,7 +228,7 @@
}
};
- ContextState* g_contextState = 0;
+ ContextState* g_cs = nullptr;
#endif // DOCTEST_CONFIG_DISABLE
} // namespace detail
@@ -626,9 +618,7 @@
String toString(const Approx& in) {
return String("Approx( ") + doctest::toString(in.m_value) + " )";
}
-const ContextOptions* getContextOptions() {
- return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_contextState);
-}
+const ContextOptions* getContextOptions() { return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_cs); }
} // namespace doctest
@@ -653,9 +643,9 @@
IReporter::~IReporter() = default;
int IReporter::get_num_active_contexts() { return 0; }
-const IContextScope* const* IReporter::get_active_contexts() { return 0; }
+const IContextScope* const* IReporter::get_active_contexts() { return nullptr; }
int IReporter::get_num_stringified_contexts() { return 0; }
-const String* IReporter::get_stringified_contexts() { return 0; }
+const String* IReporter::get_stringified_contexts() { return nullptr; }
int registerReporter(const char*, int, IReporter*) { return 0; }
@@ -743,7 +733,7 @@
} // namespace
namespace detail {
#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, args) \
- for(auto& curr_rep : g_contextState->reporters_currently_used) \
+ for(auto& curr_rep : g_cs->reporters_currently_used) \
curr_rep->function(args)
DOCTEST_DEFINE_DEFAULTS(TestFailureException);
@@ -754,7 +744,7 @@
if((at & assertType::is_check) //!OCLINT bitwise operator in conditional
&& getContextOptions()->abort_after > 0 &&
- g_contextState->numAssertsFailed >= getContextOptions()->abort_after)
+ g_cs->numAssertsFailed >= getContextOptions()->abort_after)
return true;
return false;
@@ -771,8 +761,8 @@
// matching of a string against a wildcard mask (case sensitivity configurable) taken from
// https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing
int wildcmp(const char* str, const char* wild, bool caseSensitive) {
- const char* cp = 0;
- const char* mp = 0;
+ const char* cp = nullptr;
+ const char* mp = nullptr;
while((*str) && (*wild != '*')) {
if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) &&
@@ -872,7 +862,7 @@
Subcase::Subcase(const char* name, const char* file, int line)
: m_signature(name, file, line) {
- ContextState* s = g_contextState;
+ ContextState* s = g_cs;
// if we have already completed it
if(s->subcasesPassed.count(m_signature) != 0)
@@ -900,7 +890,7 @@
Subcase::~Subcase() {
if(m_entered) {
- ContextState* s = g_contextState;
+ ContextState* s = g_cs;
s->subcasesCurrentLevel--;
// only mark the subcase as passed if no subcases have been skipped
@@ -931,7 +921,7 @@
TestSuite& TestSuite::operator*(const char* in) {
m_test_suite = in;
// clear state
- m_description = 0;
+ m_description = nullptr;
m_skip = false;
m_may_fail = false;
m_should_fail = false;
@@ -944,7 +934,7 @@
const char* type, int template_id) {
m_file = file;
m_line = line;
- m_name = 0;
+ m_name = nullptr;
m_test_suite = test_suite.m_test_suite;
m_description = test_suite.m_description;
m_skip = test_suite.m_skip;
@@ -1250,8 +1240,8 @@
, head(other.head)
, tail(other.tail) {
other.numCaptures = 0;
- other.head = 0;
- other.tail = 0;
+ other.head = nullptr;
+ other.tail = nullptr;
memcpy(stackChunks, other.stackChunks,
unsigned(int(sizeof(Chunk)) * DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK));
}
@@ -1286,7 +1276,7 @@
ContextScope::ContextScope(ContextBuilder& temp)
: contextBuilder(temp) {
- g_contextState->contexts.push_back(this);
+ g_cs->contexts.push_back(this);
}
DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17
@@ -1295,9 +1285,9 @@
if(std::uncaught_exception()) {
std::ostringstream s;
this->stringify(&s);
- g_contextState->stringifiedContexts.push_back(s.str().c_str());
+ g_cs->stringifiedContexts.push_back(s.str().c_str());
}
- g_contextState->contexts.pop_back();
+ g_cs->contexts.pop_back();
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_MSVC_SUPPRESS_WARNING_POP
@@ -1466,32 +1456,32 @@
void addAssert(assertType::Enum at) {
if((at & assertType::is_warn) == 0) { //!OCLINT bitwise operator in conditional
- g_contextState->numAsserts++;
- g_contextState->numAssertsForCurrentTestCase++;
+ g_cs->numAsserts++;
+ g_cs->numAssertsForCurrentTestCase++;
}
}
void addFailedAssert(assertType::Enum at) {
if((at & assertType::is_warn) == 0) { //!OCLINT bitwise operator in conditional
- g_contextState->numAssertsFailed++;
- g_contextState->numAssertsFailedForCurrentTestCase++;
+ g_cs->numAssertsFailed++;
+ g_cs->numAssertsFailedForCurrentTestCase++;
}
}
#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH)
void reportFatal(const std::string& message) {
- g_contextState->seconds_so_far += g_timer.getElapsedSeconds();
- g_contextState->failure_flags |= TestCaseFailureReason::Crash;
- g_contextState->error_string = message.c_str();
- g_contextState->should_reenter = false;
+ g_cs->seconds_so_far += g_timer.getElapsedSeconds();
+ g_cs->failure_flags |= TestCaseFailureReason::Crash;
+ g_cs->error_string = message.c_str();
+ g_cs->should_reenter = false;
// TODO: end all currently opened subcases...?
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
- g_contextState->numTestCasesFailed++;
+ g_cs->numTestCasesFailed++;
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
}
#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
} // namespace
@@ -1499,7 +1489,7 @@
ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
const char* exception_type) {
- m_test_case = g_contextState->currentTest;
+ m_test_case = g_cs->currentTest;
m_at = at;
m_file = file;
m_line = line;
@@ -1555,8 +1545,8 @@
}
void failed_out_of_a_testing_context(const AssertData& ad) {
- if(g_contextState->ah)
- g_contextState->ah(ad);
+ if(g_cs->ah)
+ g_cs->ah(ad);
else
std::abort();
}
@@ -1942,14 +1932,14 @@
if(getContextOptions()->count || getContextOptions()->list_test_cases) {
s << Color::Cyan << "[doctest] " << Color::None
<< "unskipped test cases passing the current filters: "
- << g_contextState->numTestCasesPassingFilters << "\n";
+ << g_cs->numTestCasesPassingFilters << "\n";
} else if(getContextOptions()->list_test_suites) {
s << Color::Cyan << "[doctest] " << Color::None
<< "unskipped test cases passing the current filters: "
- << g_contextState->numTestCasesPassingFilters << "\n";
+ << g_cs->numTestCasesPassingFilters << "\n";
s << Color::Cyan << "[doctest] " << Color::None
<< "test suites with unskipped test cases passing the current filters: "
- << g_contextState->numTestSuitesPassingFilters << "\n";
+ << g_cs->numTestSuitesPassingFilters << "\n";
}
}
@@ -1977,12 +1967,12 @@
#define DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(func, type) \
void func(type in) override { \
if(isDebuggerActive()) { \
- bool with_col = getContextOptions()->no_colors; \
- g_contextState->no_colors = false; \
+ bool with_col = getContextOptions()->no_colors; \
+ g_cs->no_colors = false; \
ConsoleReporter::func(in); \
DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \
oss.str(""); \
- g_contextState->no_colors = with_col; \
+ g_cs->no_colors = with_col; \
} \
}
@@ -2075,12 +2065,12 @@
// tokenize with "," as a separator
// cppcheck-suppress strtokCalled
auto pch = std::strtok(filtersString.c_str(), ","); // modifies the string
- while(pch != 0) {
+ while(pch != nullptr) {
if(strlen(pch))
res.push_back(pch);
// uses the strtok() internal state to go to the next token
// cppcheck-suppress strtokCalled
- pch = std::strtok(0, ",");
+ pch = std::strtok(nullptr, ",");
}
return true;
}
@@ -2135,8 +2125,8 @@
}
Context::~Context() {
- if(g_contextState == p)
- g_contextState = 0;
+ if(g_cs == p)
+ g_cs = nullptr;
delete p;
}
@@ -2278,7 +2268,7 @@
// users should query this in their main() and exit the program if true
bool Context::shouldExit() { return p->exit; }
-void Context::setAsDefaultForAssertsOutOfTestCases() { g_contextState = p; }
+void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; }
void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; }
@@ -2286,8 +2276,8 @@
int Context::run() {
using namespace detail;
- auto old_cs = g_contextState;
- g_contextState = p;
+ auto old_cs = g_cs;
+ g_cs = p;
is_running_in_test = true;
p->resetRunData();
@@ -2320,7 +2310,7 @@
if(p->list_reporters)
g_con_rep.printRegisteredReporters();
- g_contextState = old_cs;
+ g_cs = old_cs;
is_running_in_test = false;
return EXIT_SUCCESS;
@@ -2367,7 +2357,7 @@
bool query_mode = p->count || p->list_test_cases || p->list_test_suites;
if(!query_mode)
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_cs);
// invoke the registered functions if they match the filter criteria (or just count them)
for(auto& curr : testArray) {
@@ -2475,13 +2465,13 @@
// call it from here only if we will continue looping for other subcases and
// call it again outside of the loop for one final time - with updated flags
if(p->should_reenter == true) {
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
p->failure_flags &= ~TestCaseFailureReason::Exception;
p->failure_flags &= ~TestCaseFailureReason::AssertFailure;
}
} while(p->should_reenter == true);
- if(g_contextState->numAssertsFailedForCurrentTestCase)
+ if(g_cs->numAssertsFailedForCurrentTestCase)
p->failure_flags |= TestCaseFailureReason::AssertFailure;
if(Approx(p->currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
@@ -2512,9 +2502,9 @@
if(p->failure_flags && !ok_to_fail)
p->numTestCasesFailed++;
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
- p->currentTest = 0;
+ p->currentTest = nullptr;
// stop executing tests if enough assertions have failed
if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after)
@@ -2523,11 +2513,11 @@
}
if(!query_mode)
- DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_contextState);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
else
g_con_rep.output_query_results();
- g_contextState = old_cs;
+ g_cs = old_cs;
is_running_in_test = false;
if(p->numTestCasesFailed && !p->no_exitcode)
@@ -2541,16 +2531,14 @@
IReporter::~IReporter() = default;
-int IReporter::get_num_active_contexts() { return detail::g_contextState->contexts.size(); }
+int IReporter::get_num_active_contexts() { return detail::g_cs->contexts.size(); }
const IContextScope* const* IReporter::get_active_contexts() {
- return get_num_active_contexts() ? &detail::g_contextState->contexts[0] : 0;
+ return get_num_active_contexts() ? &detail::g_cs->contexts[0] : nullptr;
}
-int IReporter::get_num_stringified_contexts() {
- return detail::g_contextState->stringifiedContexts.size();
-}
+int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); }
const String* IReporter::get_stringified_contexts() {
- return get_num_stringified_contexts() ? &detail::g_contextState->stringifiedContexts[0] : 0;
+ return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr;
}
int registerReporter(const char* name, int priority, IReporter* r) {
diff --git a/examples/all_features/asserts_used_outside_of_tests.cpp b/examples/all_features/asserts_used_outside_of_tests.cpp
index e441f09..a2afd17 100644
--- a/examples/all_features/asserts_used_outside_of_tests.cpp
+++ b/examples/all_features/asserts_used_outside_of_tests.cpp
@@ -1,12 +1,16 @@
+#ifndef DOCTEST_CONFIG_DISABLE
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS // defined so the fast asserts are crazy fast - both for compilation and execution
+#endif
+
#include "doctest.h"
+#include "header.h"
+
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
#include <iostream>
#include <cstring>
#include <algorithm>
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
-DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow")
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
diff --git a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
index 9fa4154..a5212b1 100644
--- a/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
+++ b/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt
@@ -4,19 +4,19 @@
[doctest] assertions: 0 | 0 passed | 0 failed |
[doctest] Status: SUCCESS!
Program code.
-asserts_used_outside_of_tests.cpp(15): ERROR: FAST_CHECK_EQ( true, false ) is NOT correct!
+asserts_used_outside_of_tests.cpp(19): ERROR: FAST_CHECK_EQ( true, false ) is NOT correct!
values: FAST_CHECK_EQ( true, false )
-asserts_used_outside_of_tests.cpp(16): ERROR: FAST_CHECK_UNARY( false ) is NOT correct!
+asserts_used_outside_of_tests.cpp(20): ERROR: FAST_CHECK_UNARY( false ) is NOT correct!
values: FAST_CHECK_UNARY( false )
-asserts_used_outside_of_tests.cpp(17): ERROR: FAST_CHECK_UNARY_FALSE( true ) is NOT correct!
+asserts_used_outside_of_tests.cpp(21): ERROR: FAST_CHECK_UNARY_FALSE( true ) is NOT correct!
values: FAST_CHECK_UNARY_FALSE( true )
-asserts_used_outside_of_tests.cpp(19): ERROR: CHECK_EQ( true, false ) is NOT correct!
+asserts_used_outside_of_tests.cpp(23): ERROR: CHECK_EQ( true, false ) is NOT correct!
values: CHECK_EQ( true, false )
-asserts_used_outside_of_tests.cpp(20): ERROR: CHECK_UNARY( false ) is NOT correct!
+asserts_used_outside_of_tests.cpp(24): ERROR: CHECK_UNARY( false ) is NOT correct!
values: CHECK_UNARY( false )
-asserts_used_outside_of_tests.cpp(21): ERROR: CHECK_UNARY_FALSE( true ) is NOT correct!
+asserts_used_outside_of_tests.cpp(25): ERROR: CHECK_UNARY_FALSE( true ) is NOT correct!
values: CHECK_UNARY_FALSE( true )
-asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct!
+asserts_used_outside_of_tests.cpp(27): ERROR: CHECK( false ) is NOT correct!
values: CHECK( false )
hello!
-asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed!
+asserts_used_outside_of_tests.cpp(28): ERROR: an assert dealing with exceptions has failed!
diff --git a/scripts/cmake/common.cmake b/scripts/cmake/common.cmake
index 800b80a..7ed585b 100644
--- a/scripts/cmake/common.cmake
+++ b/scripts/cmake/common.cmake
@@ -148,6 +148,10 @@
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compiler_flags(-Weverything)
+ add_compiler_flags(-Wno-c++98-compat)
+ add_compiler_flags(-Wno-c++98-compat-pedantic)
+ add_compiler_flags(-Wno-c++98-compat-bind-to-temporary-copy)
+ add_compiler_flags(-Wno-c++98-compat-local-type-template-args)
add_compiler_flags(-Qunused-arguments -fcolor-diagnostics) # needed for ccache integration on travis
endif()
diff --git a/scripts/coverage_maxout.cpp b/scripts/coverage_maxout.cpp
index faa77cb..95edcaa 100644
--- a/scripts/coverage_maxout.cpp
+++ b/scripts/coverage_maxout.cpp
@@ -19,10 +19,6 @@
#ifndef DOCTEST_CONFIG_DISABLE
-DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
-DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
-
// =================================================================================================
// !!! THESE ARE NOT PROPER EXAMPLES OF LIBRARY USAGE !!! THESE ARE MEANT FOR CODE COVERAGE ONLY !!!
// =================================================================================================
@@ -142,6 +138,4 @@
}
}
-DOCTEST_CLANG_SUPPRESS_WARNING_POP
-
#endif // DOCTEST_CONFIG_DISABLE