diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 110b1c7b..3d7be8c1 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -876,7 +876,9 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); json::number_float_t d = j; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(d == std::numeric_limits::infinity()); + DOCTEST_GCC_SUPPRESS_WARNING_POP CHECK(j.dump() == "null"); } @@ -895,7 +897,9 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({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)") diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index b6c20332..115df7b7 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -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 } } diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 1476b6e6..53ac1200 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo") #define private public #include diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 3a93f57f..8a64d680 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -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. diff --git a/test/src/unit-reference_access.cpp b/test/src/unit-reference_access.cpp index fb8d8ea9..f0c64422 100644 --- a/test/src/unit-reference_access.cpp +++ b/test/src/unit-reference_access.cpp @@ -287,7 +287,9 @@ TEST_CASE("reference access") // check if references are returned correctly test_type& p1 = value.get_ref(); CHECK(&p1 == value.get_ptr()); + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(p1 == value.get()); + DOCTEST_GCC_SUPPRESS_WARNING_POP const test_type& p2 = value.get_ref(); CHECK(&p2 == value.get_ptr()); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6fc8eeaa..bb3cc756 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -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 @@ -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(j.type()) == static_cast(custom_json::value_t::number_float)); + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j.get() == 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() == -0.0); + DOCTEST_GCC_SUPPRESS_WARNING_POP j = json::parse("2.22507385850720113605740979670913197593481954635164564e-308"); CHECK(j.get() == 2.2250738585072009e-308); @@ -517,7 +522,9 @@ TEST_CASE("regression tests") // long double nlohmann::basic_json j_long_double = 1.23e45L; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j_long_double.get() == 1.23e45L); + DOCTEST_GCC_SUPPRESS_WARNING_POP } SECTION("issue #228 - double values are serialized with commas as decimal points")