Remove float stringification override
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 6d3c856..7b0283c 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -465,6 +465,7 @@
namespace std { // NOLINT (cert-dcl58-cpp)
typedef decltype(nullptr) nullptr_t;
+typedef decltype(sizeof(void*)) size_t;
template <class charT>
struct char_traits;
template <>
@@ -491,8 +492,14 @@
namespace doctest {
+using std::size_t;
+
DOCTEST_INTERFACE extern bool is_running_in_test;
+#ifndef DOCTEST_CONFIG_STRING_SIZE_TYPE
+#define DOCTEST_CONFIG_STRING_SIZE_TYPE unsigned
+#endif
+
// A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length
// of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for:
// - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128)
@@ -515,14 +522,18 @@
// - relational operators as free functions - taking const char* as one of the params
class DOCTEST_INTERFACE String
{
- static const unsigned len = 24; //!OCLINT avoid private static members
- static const unsigned last = len - 1; //!OCLINT avoid private static members
+public:
+ using size_type = DOCTEST_CONFIG_STRING_SIZE_TYPE;
+
+private:
+ static DOCTEST_CONSTEXPR size_type len = 24; //!OCLINT avoid private static members
+ static DOCTEST_CONSTEXPR size_type last = len - 1; //!OCLINT avoid private static members
struct view // len should be more than sizeof(view) - because of the final byte for flags
{
char* ptr;
- unsigned size;
- unsigned capacity;
+ size_type size;
+ size_type capacity;
};
union
@@ -531,26 +542,26 @@
view data;
};
- char* allocate(unsigned sz);
+ char* allocate(size_type sz);
bool isOnStack() const { return (buf[last] & 128) == 0; }
void setOnHeap();
- void setLast(unsigned in = last);
- void setSize(unsigned sz);
+ void setLast(size_type in = last);
+ void setSize(size_type sz);
void copy(const String& other);
public:
- static DOCTEST_CONSTEXPR unsigned npos = static_cast<unsigned>(-1);
+ static DOCTEST_CONSTEXPR size_type npos = static_cast<size_type>(-1);
String();
~String();
// cppcheck-suppress noExplicitConstructor
String(const char* in);
- String(const char* in, unsigned in_size);
+ String(const char* in, size_type in_size);
- String(std::istream& in, unsigned in_size);
+ String(std::istream& in, size_type in_size);
String(const String& other);
String& operator=(const String& other);
@@ -560,8 +571,8 @@
String(String&& other);
String& operator=(String&& other);
- char operator[](unsigned i) const;
- char& operator[](unsigned i);
+ char operator[](size_type i) const;
+ char& operator[](size_type i);
// the only functions I'm willing to leave in the interface - available for inlining
const char* c_str() const { return const_cast<String*>(this)->c_str(); } // NOLINT
@@ -571,13 +582,11 @@
return data.ptr;
}
- unsigned size() const;
- unsigned capacity() const;
+ size_type size() const;
+ size_type capacity() const;
- unsigned find_last_not_of(char c, unsigned pos = npos) const;
-
- String substr(unsigned pos, unsigned len = npos) &&;
- String substr(unsigned pos, unsigned len = npos) const &;
+ String substr(size_type pos, size_type len = npos) &&;
+ String substr(size_type pos, size_type len = npos) const &;
int compare(const char* other, bool no_case = false) const;
int compare(const String& other, bool no_case = false) const;
@@ -3373,7 +3382,7 @@
#endif // DOCTEST_CONFIG_DISABLE
} // namespace detail
-char* String::allocate(unsigned sz) {
+char* String::allocate(size_type sz) {
if (sz <= last) {
buf[sz] = '\0';
setLast(last - sz);
@@ -3389,8 +3398,8 @@
}
void String::setOnHeap() { *reinterpret_cast<unsigned char*>(&buf[last]) = 128; }
-void String::setLast(unsigned in) { buf[last] = char(in); }
-void String::setSize(unsigned sz) {
+void String::setLast(size_type in) { buf[last] = char(in); }
+void String::setSize(size_type sz) {
if (isOnStack()) { buf[sz] = '\0'; setLast(last - sz); }
else { data.ptr[sz] = '\0'; data.size = sz; }
}
@@ -3417,11 +3426,11 @@
String::String(const char* in)
: String(in, strlen(in)) {}
-String::String(const char* in, unsigned in_size) {
+String::String(const char* in, size_type in_size) {
memcpy(allocate(in_size), in, in_size);
}
-String::String(std::istream& in, unsigned in_size) {
+String::String(std::istream& in, size_type in_size) {
in.read(allocate(in_size), in_size);
}
@@ -3439,9 +3448,9 @@
}
String& String::operator+=(const String& other) {
- const unsigned my_old_size = size();
- const unsigned other_size = other.size();
- const unsigned total_size = my_old_size + other_size;
+ const size_type my_old_size = size();
+ const size_type other_size = other.size();
+ const size_type total_size = my_old_size + other_size;
if(isOnStack()) {
if(total_size < len) {
// append to the current stack space
@@ -3505,39 +3514,31 @@
return *this;
}
-char String::operator[](unsigned i) const {
+char String::operator[](size_type i) const {
return const_cast<String*>(this)->operator[](i); // NOLINT
}
-char& String::operator[](unsigned i) {
+char& String::operator[](size_type i) {
if(isOnStack())
return reinterpret_cast<char*>(buf)[i];
return data.ptr[i];
}
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmaybe-uninitialized")
-unsigned String::size() const {
+String::size_type String::size() const {
if(isOnStack())
- return last - (unsigned(buf[last]) & 31); // using "last" would work only if "len" is 32
+ return last - (size_type(buf[last]) & 31); // using "last" would work only if "len" is 32
return data.size;
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
-unsigned String::capacity() const {
+String::size_type String::capacity() const {
if(isOnStack())
return len;
return data.capacity;
}
-unsigned String::find_last_not_of(char c, unsigned pos) const {
- const char* sptr = c_str();
- const char* cptr = sptr + std::min(pos, size() - 1);
- for (; *cptr == c && cptr >= sptr; cptr--);
- if (cptr >= sptr) { return static_cast<unsigned>(cptr - sptr); }
- else { return npos; }
-}
-
-String String::substr(unsigned pos, unsigned cnt) && {
+String String::substr(size_type pos, size_type cnt) && {
cnt = std::min(cnt, size() - 1);
char* cptr = c_str();
memmove(cptr, cptr + pos, cnt);
@@ -3545,7 +3546,7 @@
return std::move(*this);
}
-String String::substr(unsigned pos, unsigned cnt) const& {
+String String::substr(size_type pos, size_type cnt) const & {
cnt = std::min(cnt, size());
String ret{ c_str() + pos, cnt };
ret.setSize(cnt - 1);
@@ -3678,30 +3679,9 @@
String toString(bool in) { return in ? "true" : "false"; }
-namespace detail {
- template <typename T>
- String fpToString(T value, int precision) {
- if (std::isnan(value)) {
- return "nan";
- } else if (std::isinf(value)) {
- return value > 0 ? "inf" : "-inf";
- }
-
- *tlssPush() << std::setprecision(precision) << std::fixed << value;
- String d = tlssPop();
- auto i = d.find_last_not_of('0');
- if (i != String::npos && i != d.size() - 1) {
- if (d[i] == '.')
- i++;
- d = std::move(d).substr(0, i + 1);
- }
- return d;
- }
-}
-
-String toString(float in) { return fpToString(in, 5) + "f"; }
-String toString(double in) { return fpToString(in, 10); }
-String toString(double long in) { return fpToString(in, 15) + "L"; }
+String toString(float in) { return toStream(in); }
+String toString(double in) { return toStream(in); }
+String toString(double long in) { return toStream(in); }
String toString(char in) { return toStream(static_cast<signed>(in)); }
String toString(char signed in) { return toStream(static_cast<signed>(in)); }
diff --git a/doctest/parts/doctest.cpp b/doctest/parts/doctest.cpp
index 4cc52f5..b5f4d84 100644
--- a/doctest/parts/doctest.cpp
+++ b/doctest/parts/doctest.cpp
@@ -634,14 +634,6 @@
return data.capacity;
}
-String::size_type String::find_last_not_of(char c, size_type pos) const {
- const char* sptr = c_str();
- const char* cptr = sptr + std::min(pos, size() - 1);
- for (; *cptr == c && cptr >= sptr; cptr--);
- if (cptr >= sptr) { return static_cast<size_type>(cptr - sptr); }
- else { return npos; }
-}
-
String String::substr(size_type pos, size_type cnt) && {
cnt = std::min(cnt, size() - 1);
char* cptr = c_str();
@@ -650,7 +642,7 @@
return std::move(*this);
}
-String String::substr(size_type pos, size_type cnt) const& {
+String String::substr(size_type pos, size_type cnt) const & {
cnt = std::min(cnt, size());
String ret{ c_str() + pos, cnt };
ret.setSize(cnt - 1);
@@ -783,30 +775,9 @@
String toString(bool in) { return in ? "true" : "false"; }
-namespace detail {
- template <typename T>
- String fpToString(T value, int precision) {
- if (std::isnan(value)) {
- return "nan";
- } else if (std::isinf(value)) {
- return value > 0 ? "inf" : "-inf";
- }
-
- *tlssPush() << std::setprecision(precision) << std::fixed << value
- << std::setprecision(6) << std::defaultfloat; // Reset
- String d = tlssPop();
- String::size_type i = d.find_last_not_of('0');
- if (i != String::npos && i != d.size() - 1) {
- if (d[i] == '.') { i++; }
- d = std::move(d).substr(0, i + 1);
- }
- return d;
- }
-}
-
-String toString(float in) { return fpToString(in, 5) + "f"; }
-String toString(double in) { return fpToString(in, 10); }
-String toString(double long in) { return fpToString(in, 15) + "L"; }
+String toString(float in) { return toStream(in); }
+String toString(double in) { return toStream(in); }
+String toString(double long in) { return toStream(in); }
String toString(char in) { return toStream(static_cast<signed>(in)); }
String toString(char signed in) { return toStream(static_cast<signed>(in)); }
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index d5b0a39..e980ac7 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -462,6 +462,7 @@
namespace std { // NOLINT (cert-dcl58-cpp)
typedef decltype(nullptr) nullptr_t;
+typedef decltype(sizeof(void*)) size_t;
template <class charT>
struct char_traits;
template <>
@@ -488,6 +489,8 @@
namespace doctest {
+using std::size_t;
+
DOCTEST_INTERFACE extern bool is_running_in_test;
#ifndef DOCTEST_CONFIG_STRING_SIZE_TYPE
@@ -579,8 +582,6 @@
size_type size() const;
size_type capacity() const;
- size_type find_last_not_of(char c, size_type pos = npos) const;
-
String substr(size_type pos, size_type len = npos) &&;
String substr(size_type pos, size_type len = npos) const &;
diff --git a/examples/all_features/stringification.cpp b/examples/all_features/stringification.cpp
index 626e486..c1df937 100644
--- a/examples/all_features/stringification.cpp
+++ b/examples/all_features/stringification.cpp
@@ -123,6 +123,8 @@
doctest::toString(ex.two) + ")";
}
+#define CHECK_NOT_DEFAULT_STR(var) CHECK(toString(var) != "{?}")
+
TEST_CASE("all asserts should fail and show how the objects get stringified") {
MyTypeInherited<int> bla1;
bla1.one = 5;
@@ -177,9 +179,9 @@
CHECK_MESSAGE(s1 == s2, s1, " is not really ", s2);
}
- CHECK(doctest::IsNaN<double>(0.5));
- CHECK(doctest::IsNaN<float>(std::numeric_limits<float>::infinity()));
- CHECK(!doctest::IsNaN<double long>(std::numeric_limits<double long>::quiet_NaN()));
+ CHECK_NOT_DEFAULT_STR(doctest::IsNaN<double>(0.5));
+ CHECK_NOT_DEFAULT_STR(!doctest::IsNaN<float>(std::numeric_limits<float>::infinity()));
+ CHECK_NOT_DEFAULT_STR(doctest::IsNaN<double long>(std::numeric_limits<double long>::quiet_NaN()));
// lets see if this exception gets translated
throw_if(true, bla1);
diff --git a/examples/all_features/test_output/coverage_maxout.cpp.txt b/examples/all_features/test_output/coverage_maxout.cpp.txt
index 75975aa..e0c193d 100644
--- a/examples/all_features/test_output/coverage_maxout.cpp.txt
+++ b/examples/all_features/test_output/coverage_maxout.cpp.txt
@@ -15,24 +15,6 @@
values: CHECK_FALSE( true )
logged: should fail
-coverage_maxout.cpp(0): ERROR: CHECK( b == 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) == 5 )
-
-coverage_maxout.cpp(0): ERROR: CHECK( b < 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) < 5 )
-
-coverage_maxout.cpp(0): ERROR: CHECK( b <= 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) <= 5 )
-
-coverage_maxout.cpp(0): ERROR: CHECK( 6 == a ) is NOT correct!
- values: CHECK( 6 == Approx( 5.0 ) )
-
-coverage_maxout.cpp(0): ERROR: CHECK( 6 < a ) is NOT correct!
- values: CHECK( 6 < Approx( 5.0 ) )
-
-coverage_maxout.cpp(0): ERROR: CHECK( 6 <= a ) is NOT correct!
- values: CHECK( 6 <= Approx( 5.0 ) )
-
===============================================================================
coverage_maxout.cpp(0):
TEST SUITE: exception related
@@ -56,6 +38,6 @@
===============================================================================
[doctest] test cases: 4 | 0 passed | 4 failed |
-[doctest] assertions: 31 | 22 passed | 9 failed |
+[doctest] assertions: 31 | 28 passed | 3 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/coverage_maxout.cpp_junit.txt b/examples/all_features/test_output/coverage_maxout.cpp_junit.txt
index b85e2d1..8f1e992 100644
--- a/examples/all_features/test_output/coverage_maxout.cpp_junit.txt
+++ b/examples/all_features/test_output/coverage_maxout.cpp_junit.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="all_features" errors="3" failures="9" tests="31">
+ <testsuite name="all_features" errors="3" failures="3" tests="31">
<testcase classname="coverage_maxout.cpp" name="exercising tricky code paths of doctest" status="run">
<failure message="0 != 0" type="CHECK">
coverage_maxout.cpp(0):
@@ -23,42 +23,6 @@
logged: should fail
</failure>
- <failure message="Approx( 7.0 ) == 5" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( b == 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) == 5 )
-
- </failure>
- <failure message="Approx( 7.0 ) < 5" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( b < 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) < 5 )
-
- </failure>
- <failure message="Approx( 7.0 ) <= 5" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( b <= 5 ) is NOT correct!
- values: CHECK( Approx( 7.0 ) <= 5 )
-
- </failure>
- <failure message="6 == Approx( 5.0 )" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( 6 == a ) is NOT correct!
- values: CHECK( 6 == Approx( 5.0 ) )
-
- </failure>
- <failure message="6 < Approx( 5.0 )" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( 6 < a ) is NOT correct!
- values: CHECK( 6 < Approx( 5.0 ) )
-
- </failure>
- <failure message="6 <= Approx( 5.0 )" type="CHECK">
-coverage_maxout.cpp(0):
-CHECK( 6 <= a ) is NOT correct!
- values: CHECK( 6 <= Approx( 5.0 ) )
-
- </failure>
</testcase>
<testcase classname="coverage_maxout.cpp" name="will end from a std::string exception" status="run">
<error message="exception">
diff --git a/examples/all_features/test_output/coverage_maxout.cpp_xml.txt b/examples/all_features/test_output/coverage_maxout.cpp_xml.txt
index c47123d..9a9bf10 100644
--- a/examples/all_features/test_output/coverage_maxout.cpp_xml.txt
+++ b/examples/all_features/test_output/coverage_maxout.cpp_xml.txt
@@ -36,55 +36,7 @@
should fail
</Info>
</Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- b == 5
- </Original>
- <Expanded>
- Approx( 7.0 ) == 5
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- b < 5
- </Original>
- <Expanded>
- Approx( 7.0 ) < 5
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- b <= 5
- </Original>
- <Expanded>
- Approx( 7.0 ) <= 5
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- 6 == a
- </Original>
- <Expanded>
- 6 == Approx( 5.0 )
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- 6 < a
- </Original>
- <Expanded>
- 6 < Approx( 5.0 )
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="coverage_maxout.cpp" line="0">
- <Original>
- 6 <= a
- </Original>
- <Expanded>
- 6 <= Approx( 5.0 )
- </Expanded>
- </Expression>
- <OverallResultsAsserts successes="22" failures="9" test_case_success="false"/>
+ <OverallResultsAsserts successes="28" failures="3" test_case_success="false"/>
</TestCase>
</TestSuite>
<TestSuite name="exception related">
@@ -107,7 +59,7 @@
<OverallResultsAsserts successes="0" failures="0" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="22" failures="9"/>
+ <OverallResultsAsserts successes="28" failures="3"/>
<OverallResultsTestCases successes="0" failures="4"/>
</doctest>
Program code.
diff --git a/examples/all_features/test_output/stringification.cpp.txt b/examples/all_features/test_output/stringification.cpp.txt
index fbe1440..9c73007 100644
--- a/examples/all_features/test_output/stringification.cpp.txt
+++ b/examples/all_features/test_output/stringification.cpp.txt
@@ -64,15 +64,6 @@
logged: s1=MyOtherType: 42 s2=MyOtherType: 666
MyOtherType: 42 is not really MyOtherType: 666
-stringification.cpp(0): ERROR: CHECK( doctest::IsNaN<double>(0.5) ) is NOT correct!
- values: CHECK( IsNaN( 0.5 ) )
-
-stringification.cpp(0): ERROR: CHECK( doctest::IsNaN<float>(std::numeric_limits<float>::infinity()) ) is NOT correct!
- values: CHECK( IsNaN( inff ) )
-
-stringification.cpp(0): ERROR: CHECK( !doctest::IsNaN<double long>(std::numeric_limits<double long>::quiet_NaN()) ) is NOT correct!
- values: CHECK( ! IsNaN( nanL ) )
-
stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited<int>(5, 4)
===============================================================================
@@ -83,6 +74,6 @@
===============================================================================
[doctest] test cases: 3 | 0 passed | 3 failed |
-[doctest] assertions: 17 | 2 passed | 15 failed |
+[doctest] assertions: 17 | 5 passed | 12 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 2ef89ce..852b625 100644
--- a/examples/all_features/test_output/stringification.cpp_junit.txt
+++ b/examples/all_features/test_output/stringification.cpp_junit.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="all_features" errors="2" failures="15" tests="17">
+ <testsuite name="all_features" errors="2" failures="12" tests="17">
<testcase classname="stringification.cpp" name="no headers" status="run">
<failure message="1as == nullptr" type="CHECK">
stringification.cpp(0):
@@ -79,24 +79,6 @@
MyOtherType: 42 is not really MyOtherType: 666
</failure>
- <failure message="IsNaN( 0.5 )" type="CHECK">
-stringification.cpp(0):
-CHECK( doctest::IsNaN<double>(0.5) ) is NOT correct!
- values: CHECK( IsNaN( 0.5 ) )
-
- </failure>
- <failure message="IsNaN( inff )" type="CHECK">
-stringification.cpp(0):
-CHECK( doctest::IsNaN<float>(std::numeric_limits<float>::infinity()) ) is NOT correct!
- values: CHECK( IsNaN( inff ) )
-
- </failure>
- <failure message="! IsNaN( nanL )" type="CHECK">
-stringification.cpp(0):
-CHECK( !doctest::IsNaN<double long>(std::numeric_limits<double long>::quiet_NaN()) ) is NOT correct!
- values: CHECK( ! IsNaN( nanL ) )
-
- </failure>
<error message="exception">
MyTypeInherited<int>(5, 4)
</error>
diff --git a/examples/all_features/test_output/stringification.cpp_xml.txt b/examples/all_features/test_output/stringification.cpp_xml.txt
index 6313afe..08b162c 100644
--- a/examples/all_features/test_output/stringification.cpp_xml.txt
+++ b/examples/all_features/test_output/stringification.cpp_xml.txt
@@ -156,34 +156,10 @@
MyOtherType: 42 is not really MyOtherType: 666
</Info>
</Expression>
- <Expression success="false" type="CHECK" filename="stringification.cpp" line="0">
- <Original>
- doctest::IsNaN<double>(0.5)
- </Original>
- <Expanded>
- IsNaN( 0.5 )
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="stringification.cpp" line="0">
- <Original>
- doctest::IsNaN<float>(std::numeric_limits<float>::infinity())
- </Original>
- <Expanded>
- IsNaN( inff )
- </Expanded>
- </Expression>
- <Expression success="false" type="CHECK" filename="stringification.cpp" line="0">
- <Original>
- !doctest::IsNaN<double long>(std::numeric_limits<double long>::quiet_NaN())
- </Original>
- <Expanded>
- ! IsNaN( nanL )
- </Expanded>
- </Expression>
<Exception crash="false">
MyTypeInherited<int>(5, 4)
</Exception>
- <OverallResultsAsserts successes="0" failures="10" test_case_success="false"/>
+ <OverallResultsAsserts successes="3" failures="7" test_case_success="false"/>
</TestCase>
<TestCase name="a test case that registers an exception translator for int and then throws one" filename="stringification.cpp" line="0">
<Exception crash="false">
@@ -192,7 +168,7 @@
<OverallResultsAsserts successes="0" failures="0" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="2" failures="15"/>
+ <OverallResultsAsserts successes="5" failures="12"/>
<OverallResultsTestCases successes="0" failures="3"/>
</doctest>
Program code.
diff --git a/examples/executable_dll_and_plugin/dll.cpp b/examples/executable_dll_and_plugin/dll.cpp
index 22e498b..b436e8f 100644
--- a/examples/executable_dll_and_plugin/dll.cpp
+++ b/examples/executable_dll_and_plugin/dll.cpp
@@ -8,7 +8,6 @@
TEST_CASE("dll") {
std::cout << "I am a test from the dll!\n";
CHECK(true);
- CHECK(doctest::IsNaN<long double>(0.1L));
}
DOCTEST_SYMBOL_EXPORT void from_dll(); // to silence "-Wmissing-declarations" with GCC
diff --git a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
index 9c0af9b..bc67438 100644
--- a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
+++ b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt
@@ -1,12 +1,5 @@
[doctest] run with "--help" for options
I am a test from the dll!
-===============================================================================
-dll.cpp(0):
-TEST CASE: dll
-
-dll.cpp(0): ERROR: CHECK( doctest::IsNaN<long double>(0.1L) ) is NOT correct!
- values: CHECK( IsNaN( 0.1L ) )
-
I am a test from the implementation!
I am a test from the implementation_2!
I am a test from the executable!
@@ -33,6 +26,6 @@
logged: some info
===============================================================================
-[doctest] test cases: 5 | 2 passed | 3 failed | 0 skipped
-[doctest] assertions: 4 | 1 passed | 3 failed |
+[doctest] test cases: 5 | 3 passed | 2 failed | 0 skipped
+[doctest] assertions: 3 | 1 passed | 2 failed |
[doctest] Status: FAILURE!
diff --git a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt
index f6463c5..e5ff58e 100644
--- a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt
+++ b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt
@@ -4,15 +4,8 @@
I am a test from the implementation_2!
I am a test from the executable!
<testsuites>
- <testsuite name="executable_dll_and_plugin" errors="1" failures="2" tests="4">
- <testcase classname="dll.cpp" name="dll" status="run">
- <failure message="IsNaN( 0.1L )" type="CHECK">
-dll.cpp(0):
-CHECK( doctest::IsNaN<long double>(0.1L) ) is NOT correct!
- values: CHECK( IsNaN( 0.1L ) )
-
- </failure>
- </testcase>
+ <testsuite name="executable_dll_and_plugin" errors="1" failures="1" tests="3">
+ <testcase classname="dll.cpp" name="dll" status="run"/>
<testcase classname="implementation.cpp" name="implementation" status="run"/>
<testcase classname="implementation_2.cpp" name="implementation_2" status="run"/>
<testcase classname="main.cpp" name="executable" status="run">
diff --git a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt
index 3cd4d6a..b300e78 100644
--- a/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt
+++ b/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt
@@ -4,15 +4,7 @@
<TestSuite>
<TestCase name="dll" filename="dll.cpp" line="0">
I am a test from the dll!
- <Expression success="false" type="CHECK" filename="dll.cpp" line="0">
- <Original>
- doctest::IsNaN<long double>(0.1L)
- </Original>
- <Expanded>
- IsNaN( 0.1L )
- </Expanded>
- </Expression>
- <OverallResultsAsserts successes="1" failures="1" test_case_success="false"/>
+ <OverallResultsAsserts successes="1" failures="0" test_case_success="true"/>
</TestCase>
<TestCase name="implementation" filename="implementation.cpp" line="0">
I am a test from the implementation!
@@ -64,6 +56,6 @@
<OverallResultsAsserts successes="0" failures="2" test_case_success="false"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="1" failures="3"/>
- <OverallResultsTestCases successes="2" failures="3" skipped="0"/>
+ <OverallResultsAsserts successes="1" failures="2"/>
+ <OverallResultsTestCases successes="3" failures="2" skipped="0"/>
</doctest>
diff --git a/scripts/coverage_maxout.cpp b/scripts/coverage_maxout.cpp
index 8da5e12..ad55ef4 100644
--- a/scripts/coverage_maxout.cpp
+++ b/scripts/coverage_maxout.cpp
@@ -62,9 +62,6 @@
+ toString(nullptr) //
+ toString(true) //
+ toString(0u) //
- + toString(0.5f) //
- + toString(0.5) //
- + toString(0.1L) //
+ toString('c') //
+ toString(static_cast<signed char>('c')) //
+ toString(static_cast<unsigned char>(1)) //
@@ -87,8 +84,8 @@
#endif
str += oss.str().c_str();
str += failureString(assertType::is_normal);
- CHECK(str == "omgomgomgaaanullptrtrue00.5f0.50.1L99991111111"
- "omgomgomgaaanullptrtrue00.5f0.50.1L99991111111");
+ CHECK(str == "omgomgomgaaanullptrtrue099991111111"
+ "omgomgomgaaanullptrtrue099991111111");
// trigger code path for rawMemoryToString
bool isThereAnything = str.size() > 0u;
String unknown = toString(skip()); // trigger code path for "{?}"
@@ -99,19 +96,19 @@
a.scale(4);
Approx b = a(7);
- CHECK(b == 5);
- CHECK(b != 5);
- CHECK(b > 5);
- CHECK(b < 5);
- CHECK(b >= 5);
- CHECK(b <= 5);
+ CHECK(b == 7);
+ CHECK(b != 6);
+ CHECK(b > 6);
+ CHECK(b < 8);
+ CHECK(b >= 7);
+ CHECK(b <= 7);
- CHECK(6 == a);
+ CHECK(5 == a);
CHECK(6 != a);
CHECK(6 > a);
- CHECK(6 < a);
- CHECK(6 >= a);
- CHECK(6 <= a);
+ CHECK(4 < a);
+ CHECK(5 >= a);
+ CHECK(5 <= a);
// trigger another single line of code... lol
auto oldVal = const_cast<ContextOptions*>(getContextOptions())->no_path_in_filenames;