1
0
mirror of https://github.com/nlohmann/json synced 2024-11-10 14:30:08 +00:00

finished the last of the warnings

This commit is contained in:
onqtam 2019-03-27 01:09:47 +02:00
parent 5d511a6e96
commit a0000c3235
6 changed files with 18 additions and 0 deletions

View File

@ -876,7 +876,9 @@ TEST_CASE("CBOR")
{
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
json::number_float_t d = j;
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
DOCTEST_GCC_SUPPRESS_WARNING_POP
CHECK(j.dump() == "null");
}
@ -895,7 +897,9 @@ TEST_CASE("CBOR")
{
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
json::number_float_t d = j;
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(d == 1);
DOCTEST_GCC_SUPPRESS_WARNING_POP
}
SECTION("-2 (1 10000 0000000000)")

View File

@ -351,7 +351,9 @@ TEST_CASE("constructors")
CHECK(jva.size() == va.size());
for (size_t i = 0; i < jva.size(); ++i)
{
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(va[i] == jva[i]);
DOCTEST_GCC_SUPPRESS_WARNING_POP
}
}

View File

@ -28,6 +28,7 @@ SOFTWARE.
*/
#include "doctest_compatibility.h"
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo")
#define private public
#include <nlohmann/json.hpp>

View File

@ -269,7 +269,9 @@ TEST_CASE("README" * doctest::skip())
int i = 42;
json jn = i;
double f = jn;
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(f == 42);
DOCTEST_GCC_SUPPRESS_WARNING_POP
// etc.

View File

@ -287,7 +287,9 @@ TEST_CASE("reference access")
// check if references are returned correctly
test_type& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>());
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(p1 == value.get<test_type>());
DOCTEST_GCC_SUPPRESS_WARNING_POP
const test_type& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>());

View File

@ -28,6 +28,7 @@ SOFTWARE.
*/
#include "doctest_compatibility.h"
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo")
// for some reason including this after the json header leads to linker errors with VS 2017...
#include <locale>
@ -314,7 +315,9 @@ TEST_CASE("regression tests")
// unsigned integer parsing - expected to overflow and be stored as a float
j = custom_json::parse("4294967296"); // 2^32
CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_float));
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(j.get<float>() == 4294967296.0f);
DOCTEST_GCC_SUPPRESS_WARNING_POP
// integer object creation - expected to wrap and still be stored as an integer
j = -2147483649LL; // -2^31-1
@ -479,7 +482,9 @@ TEST_CASE("regression tests")
json j;
j = json::parse("-0.0");
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(j.get<double>() == -0.0);
DOCTEST_GCC_SUPPRESS_WARNING_POP
j = json::parse("2.22507385850720113605740979670913197593481954635164564e-308");
CHECK(j.get<double>() == 2.2250738585072009e-308);
@ -517,7 +522,9 @@ TEST_CASE("regression tests")
// long double
nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, long double>
j_long_double = 1.23e45L;
DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal")
CHECK(j_long_double.get<long double>() == 1.23e45L);
DOCTEST_GCC_SUPPRESS_WARNING_POP
}
SECTION("issue #228 - double values are serialized with commas as decimal points")