Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/onqtam/doctest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan <29021710+Saalvage@users.noreply.github.com>2022-04-30 19:22:49 +0300
committerGitHub <noreply@github.com>2022-04-30 19:22:49 +0300
commit4e1110012fe6031012f6e9a7f36cb33557c68dd7 (patch)
tree697ac39b3eecdd0adcfd60869175bbd7853c9537
parentf592f38d0d8350a7dde286b5ad2e9eb12f74b3e9 (diff)
Fix #508 (#640)
* Fix #508 * Missed warning suppression
-rw-r--r--doctest/doctest.h26
-rw-r--r--doctest/parts/doctest.cpp2
-rw-r--r--doctest/parts/doctest_fwd.h24
-rw-r--r--examples/all_features/CMakeLists.txt1
-rw-r--r--examples/all_features/double_stringification.cpp18
-rw-r--r--examples/all_features/test_output/double_stringification.cpp.txt6
-rw-r--r--examples/all_features/test_output/double_stringification.cpp_junit.txt7
-rw-r--r--examples/all_features/test_output/double_stringification.cpp_xml.txt12
-rw-r--r--examples/all_features/test_output/filter_2.txt2
-rw-r--r--examples/all_features/test_output/filter_2_xml.txt3
-rw-r--r--examples/all_features/test_output/no_multi_lane_atomics.txt4
-rw-r--r--examples/all_features/test_output/no_multithreading.txt4
-rw-r--r--examples/all_features/test_output/stringification.cpp.txt4
-rw-r--r--examples/all_features/test_output/stringification.cpp_junit.txt3
-rw-r--r--examples/all_features/test_output/stringification.cpp_xml.txt7
15 files changed, 94 insertions, 29 deletions
diff --git a/doctest/doctest.h b/doctest/doctest.h
index b4a109b6..f6c51081 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -1036,6 +1036,14 @@ struct StringMaker : public detail::StringMakerBase<
detail::has_insertion_operator<T>::value || detail::types::is_pointer<T>::value || detail::types::is_array<T>::value>
{};
+#ifndef DOCTEST_STRINGIFY
+#ifdef DOCTEST_CONFIG_DOUBLE_STRINGIFY
+#define DOCTEST_STRINGIFY(...) toString(toString(__VA_ARGS__))
+#else
+#define DOCTEST_STRINGIFY(...) toString(__VA_ARGS__)
+#endif
+#endif
+
template <typename T>
String toString() {
#if DOCTEST_MSVC >= 0 && DOCTEST_CLANG == 0 && DOCTEST_GCC == 0
@@ -1086,7 +1094,7 @@ DOCTEST_INTERFACE String toString(long long unsigned in);
template <typename T, typename detail::types::enable_if<detail::types::is_enum<T>::value, bool>::type = true>
String toString(const DOCTEST_REF_WRAP(T) value) {
typedef typename detail::types::underlying_type<T>::type UT;
- return toString(static_cast<UT>(value));
+ return (DOCTEST_STRINGIFY(static_cast<UT>(value)));
}
namespace detail {
@@ -1108,7 +1116,7 @@ namespace detail {
*stream << "[";
for (size_t i = 0; i < N; i++) {
if (i != 0) { *stream << ", "; }
- *stream << toString(in[i]);
+ *stream << (DOCTEST_STRINGIFY(in[i]));
}
*stream << "]";
}
@@ -1279,7 +1287,7 @@ namespace detail {
String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op,
const DOCTEST_REF_WRAP(R) rhs) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
- return toString(lhs) + op + toString(rhs);
+ return (DOCTEST_STRINGIFY(lhs)) + op + (DOCTEST_STRINGIFY(rhs));
}
#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
@@ -1446,7 +1454,7 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP
res = !res;
if(!res || getContextOptions()->success)
- return Result(res, toString(lhs));
+ return Result(res, (DOCTEST_STRINGIFY(lhs)));
return Result(res);
}
@@ -1630,7 +1638,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
m_failed = !m_failed;
if(m_failed || getContextOptions()->success)
- m_decomp = toString(val);
+ m_decomp = (DOCTEST_STRINGIFY(val));
return !m_failed;
}
@@ -1709,8 +1717,8 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
// IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
// THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
// ###################################################################################
- DOCTEST_ASSERT_OUT_OF_TESTS(toString(val));
- DOCTEST_ASSERT_IN_TESTS(toString(val));
+ DOCTEST_ASSERT_OUT_OF_TESTS((DOCTEST_STRINGIFY(val)));
+ DOCTEST_ASSERT_IN_TESTS((DOCTEST_STRINGIFY(val)));
return !failed;
}
@@ -1789,7 +1797,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
// the preferred way of chaining parameters for stringification
template <typename T>
MessageBuilder& operator,(const T& in) {
- *m_stream << toString(in);
+ *m_stream << (DOCTEST_STRINGIFY(in));
return *this;
}
@@ -6620,7 +6628,7 @@ void Context::setOption(const char* option, bool value) {
// allows the user to override procedurally the int options from the command line
void Context::setOption(const char* option, int value) {
- setOption(option, toString(value).c_str());
+ setOption(option, (DOCTEST_STRINGIFY(value)).c_str());
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
}
diff --git a/doctest/parts/doctest.cpp b/doctest/parts/doctest.cpp
index 1115912a..1c914411 100644
--- a/doctest/parts/doctest.cpp
+++ b/doctest/parts/doctest.cpp
@@ -3633,7 +3633,7 @@ void Context::setOption(const char* option, bool value) {
// allows the user to override procedurally the int options from the command line
void Context::setOption(const char* option, int value) {
- setOption(option, toString(value).c_str());
+ setOption(option, (DOCTEST_STRINGIFY(value)).c_str());
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
}
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index 3e663b73..8a5a6783 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -1033,6 +1033,14 @@ struct StringMaker : public detail::StringMakerBase<
detail::has_insertion_operator<T>::value || detail::types::is_pointer<T>::value || detail::types::is_array<T>::value>
{};
+#ifndef DOCTEST_STRINGIFY
+#ifdef DOCTEST_CONFIG_DOUBLE_STRINGIFY
+#define DOCTEST_STRINGIFY(...) toString(toString(__VA_ARGS__))
+#else
+#define DOCTEST_STRINGIFY(...) toString(__VA_ARGS__)
+#endif
+#endif
+
template <typename T>
String toString() {
#if DOCTEST_MSVC >= 0 && DOCTEST_CLANG == 0 && DOCTEST_GCC == 0
@@ -1083,7 +1091,7 @@ DOCTEST_INTERFACE String toString(long long unsigned in);
template <typename T, typename detail::types::enable_if<detail::types::is_enum<T>::value, bool>::type = true>
String toString(const DOCTEST_REF_WRAP(T) value) {
typedef typename detail::types::underlying_type<T>::type UT;
- return toString(static_cast<UT>(value));
+ return (DOCTEST_STRINGIFY(static_cast<UT>(value)));
}
namespace detail {
@@ -1105,7 +1113,7 @@ namespace detail {
*stream << "[";
for (size_t i = 0; i < N; i++) {
if (i != 0) { *stream << ", "; }
- *stream << toString(in[i]);
+ *stream << (DOCTEST_STRINGIFY(in[i]));
}
*stream << "]";
}
@@ -1276,7 +1284,7 @@ namespace detail {
String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op,
const DOCTEST_REF_WRAP(R) rhs) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
- return toString(lhs) + op + toString(rhs);
+ return (DOCTEST_STRINGIFY(lhs)) + op + (DOCTEST_STRINGIFY(rhs));
}
#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
@@ -1443,7 +1451,7 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP
res = !res;
if(!res || getContextOptions()->success)
- return Result(res, toString(lhs));
+ return Result(res, (DOCTEST_STRINGIFY(lhs)));
return Result(res);
}
@@ -1627,7 +1635,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
m_failed = !m_failed;
if(m_failed || getContextOptions()->success)
- m_decomp = toString(val);
+ m_decomp = (DOCTEST_STRINGIFY(val));
return !m_failed;
}
@@ -1706,8 +1714,8 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
// IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
// THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
// ###################################################################################
- DOCTEST_ASSERT_OUT_OF_TESTS(toString(val));
- DOCTEST_ASSERT_IN_TESTS(toString(val));
+ DOCTEST_ASSERT_OUT_OF_TESTS((DOCTEST_STRINGIFY(val)));
+ DOCTEST_ASSERT_IN_TESTS((DOCTEST_STRINGIFY(val)));
return !failed;
}
@@ -1786,7 +1794,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP
// the preferred way of chaining parameters for stringification
template <typename T>
MessageBuilder& operator,(const T& in) {
- *m_stream << toString(in);
+ *m_stream << (DOCTEST_STRINGIFY(in));
return *this;
}
diff --git a/examples/all_features/CMakeLists.txt b/examples/all_features/CMakeLists.txt
index 80105c98..86dfc9e5 100644
--- a/examples/all_features/CMakeLists.txt
+++ b/examples/all_features/CMakeLists.txt
@@ -9,6 +9,7 @@ set(files_with_output
alternative_macros.cpp
assertion_macros.cpp
stringification.cpp
+ double_stringification.cpp
reporters_and_listeners.cpp
subcases.cpp
logging.cpp
diff --git a/examples/all_features/double_stringification.cpp b/examples/all_features/double_stringification.cpp
new file mode 100644
index 00000000..5a1ebb53
--- /dev/null
+++ b/examples/all_features/double_stringification.cpp
@@ -0,0 +1,18 @@
+#define DOCTEST_CONFIG_DOUBLE_STRINGIFY
+#include <doctest_fwd.h>
+
+DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
+#include <string>
+DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
+
+namespace App {
+ struct Foo { };
+ static std::string toString(Foo*) { return "Foo"; }
+}
+
+TEST_CASE("toString std::string ret type") {
+ App::Foo foo;
+ CHECK(&foo != nullptr);
+ CHECK_NE(&foo, nullptr);
+ CHECK(&foo);
+}
diff --git a/examples/all_features/test_output/double_stringification.cpp.txt b/examples/all_features/test_output/double_stringification.cpp.txt
new file mode 100644
index 00000000..75be56a8
--- /dev/null
+++ b/examples/all_features/test_output/double_stringification.cpp.txt
@@ -0,0 +1,6 @@
+[doctest] run with "--help" for options
+===============================================================================
+[doctest] test cases: 1 | 1 passed | 0 failed |
+[doctest] assertions: 3 | 3 passed | 0 failed |
+[doctest] Status: SUCCESS!
+Program code.
diff --git a/examples/all_features/test_output/double_stringification.cpp_junit.txt b/examples/all_features/test_output/double_stringification.cpp_junit.txt
new file mode 100644
index 00000000..982ca2e8
--- /dev/null
+++ b/examples/all_features/test_output/double_stringification.cpp_junit.txt
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuites>
+ <testsuite name="all_features" errors="0" failures="0" tests="3">
+ <testcase classname="double_stringification.cpp" name="toString std::string ret type" status="run"/>
+ </testsuite>
+</testsuites>
+Program code.
diff --git a/examples/all_features/test_output/double_stringification.cpp_xml.txt b/examples/all_features/test_output/double_stringification.cpp_xml.txt
new file mode 100644
index 00000000..9403b1c1
--- /dev/null
+++ b/examples/all_features/test_output/double_stringification.cpp_xml.txt
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doctest binary="all_features">
+ <Options order_by="file" rand_seed="324" first="0" last="4294967295" abort_after="0" subcase_filter_levels="2147483647" case_sensitive="false" no_throw="false" no_skip="false"/>
+ <TestSuite>
+ <TestCase name="toString std::string ret type" filename="double_stringification.cpp" line="0">
+ <OverallResultsAsserts successes="3" failures="0" test_case_success="true"/>
+ </TestCase>
+ </TestSuite>
+ <OverallResultsAsserts successes="3" failures="0"/>
+ <OverallResultsTestCases successes="1" failures="0"/>
+</doctest>
+Program code.
diff --git a/examples/all_features/test_output/filter_2.txt b/examples/all_features/test_output/filter_2.txt
index 51219ab7..dd726cdf 100644
--- a/examples/all_features/test_output/filter_2.txt
+++ b/examples/all_features/test_output/filter_2.txt
@@ -1,6 +1,6 @@
[doctest] run with "--help" for options
===============================================================================
-[doctest] test cases: 0 | 0 passed | 0 failed | 102 skipped
+[doctest] test cases: 0 | 0 passed | 0 failed | 103 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_2_xml.txt b/examples/all_features/test_output/filter_2_xml.txt
index 211dddef..fd8a050a 100644
--- a/examples/all_features/test_output/filter_2_xml.txt
+++ b/examples/all_features/test_output/filter_2_xml.txt
@@ -129,6 +129,7 @@
<TestCase name="test case should fail even though the last subcase passes" filename="subcases.cpp" line="0" skipped="true"/>
<TestCase name="third party asserts can report failures to doctest" filename="logging.cpp" line="0" skipped="true"/>
<TestCase name="threads..." filename="concurrency.cpp" line="0" skipped="true"/>
+ <TestCase name="toString std::string ret type" filename="double_stringification.cpp" line="0" skipped="true"/>
</TestSuite>
<TestSuite name="skipped test cases">
<TestCase name="unskipped" filename="test_cases_and_suites.cpp" line="0" description="this test has overridden its skip decorator" skipped="true"/>
@@ -146,6 +147,6 @@
<TestCase name="without a funny name:" filename="subcases.cpp" line="0" skipped="true"/>
</TestSuite>
<OverallResultsAsserts successes="0" failures="0"/>
- <OverallResultsTestCases successes="0" failures="0" skipped="102"/>
+ <OverallResultsTestCases successes="0" failures="0" skipped="103"/>
</doctest>
Program code.
diff --git a/examples/all_features/test_output/no_multi_lane_atomics.txt b/examples/all_features/test_output/no_multi_lane_atomics.txt
index 51ce44d0..8500e165 100644
--- a/examples/all_features/test_output/no_multi_lane_atomics.txt
+++ b/examples/all_features/test_output/no_multi_lane_atomics.txt
@@ -922,7 +922,7 @@ TEST CASE: without a funny name:
subcases.cpp(0): MESSAGE: Nooo
===============================================================================
-[doctest] test cases: 82 | 31 passed | 51 failed |
-[doctest] assertions: 224 | 105 passed | 119 failed |
+[doctest] test cases: 83 | 32 passed | 51 failed |
+[doctest] assertions: 227 | 108 passed | 119 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/no_multithreading.txt b/examples/all_features/test_output/no_multithreading.txt
index 51ce44d0..8500e165 100644
--- a/examples/all_features/test_output/no_multithreading.txt
+++ b/examples/all_features/test_output/no_multithreading.txt
@@ -922,7 +922,7 @@ TEST CASE: without a funny name:
subcases.cpp(0): MESSAGE: Nooo
===============================================================================
-[doctest] test cases: 82 | 31 passed | 51 failed |
-[doctest] assertions: 224 | 105 passed | 119 failed |
+[doctest] test cases: 83 | 32 passed | 51 failed |
+[doctest] assertions: 227 | 108 passed | 119 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp.txt b/examples/all_features/test_output/stringification.cpp.txt
index 9f4cece4..4fe9a9a5 100644
--- a/examples/all_features/test_output/stringification.cpp.txt
+++ b/examples/all_features/test_output/stringification.cpp.txt
@@ -90,7 +90,7 @@ TEST CASE: a test case that registers an exception translator for int and then
stringification.cpp(0): ERROR: test case THREW exception: 5
===============================================================================
-[doctest] test cases: 4 | 1 passed | 3 failed |
-[doctest] assertions: 18 | 5 passed | 13 failed |
+[doctest] test cases: 5 | 2 passed | 3 failed |
+[doctest] assertions: 21 | 8 passed | 13 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp_junit.txt b/examples/all_features/test_output/stringification.cpp_junit.txt
index 93cc0769..3044abdf 100644
--- a/examples/all_features/test_output/stringification.cpp_junit.txt
+++ b/examples/all_features/test_output/stringification.cpp_junit.txt
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="all_features" errors="2" failures="13" tests="18">
+ <testsuite name="all_features" errors="2" failures="13" tests="21">
+ <testcase classname="double_stringification.cpp" name="toString std::string ret type" status="run"/>
<testcase classname="stringification.cpp" name="operator&lt;&lt;" status="run"/>
<testcase classname="stringification.cpp" name="no headers" status="run">
<failure message="1as == nullptr" type="CHECK">
diff --git a/examples/all_features/test_output/stringification.cpp_xml.txt b/examples/all_features/test_output/stringification.cpp_xml.txt
index e4de969a..cf7cf011 100644
--- a/examples/all_features/test_output/stringification.cpp_xml.txt
+++ b/examples/all_features/test_output/stringification.cpp_xml.txt
@@ -2,6 +2,9 @@
<doctest binary="all_features">
<Options order_by="file" rand_seed="324" first="0" last="4294967295" abort_after="0" subcase_filter_levels="2147483647" case_sensitive="false" no_throw="false" no_skip="false"/>
<TestSuite>
+ <TestCase name="toString std::string ret type" filename="double_stringification.cpp" line="0">
+ <OverallResultsAsserts successes="3" failures="0" test_case_success="true"/>
+ </TestCase>
<TestCase name="operator&lt;&lt;" filename="stringification.cpp" line="0">
<Message type="WARNING" filename="stringification.cpp" line="0">
<Text>
@@ -204,7 +207,7 @@
<OverallResultsAsserts successes="0" failures="0" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="5" failures="13"/>
- <OverallResultsTestCases successes="1" failures="3"/>
+ <OverallResultsAsserts successes="8" failures="13"/>
+ <OverallResultsTestCases successes="2" failures="3"/>
</doctest>
Program code.