From c76d838cd571ce3f71fb53bb51d17a162b314eb8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Oct 2026 23:14:39 +0200 Subject: [PATCH] Avoid floating-point equality in custom key type test GCC with -Werror=float-equal rejects comparing the double value with ==. Signed-off-by: Niels Lohmann --- tests/src/unit-custom-object-key-type.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-custom-object-key-type.cpp b/tests/src/unit-custom-object-key-type.cpp index f264a3971..40de28ed2 100644 --- a/tests/src/unit-custom-object-key-type.cpp +++ b/tests/src/unit-custom-object-key-type.cpp @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -273,7 +274,7 @@ bool check_shallow(const J& value) return a->template get() == 1 && b->is_array() && b->size() == 3 && (*b)[0].template get() && (*b)[1].is_null() && (*b)[2].template get() == "x" - && d != c->end() && d->template get() == 2.5 + && d != c->end() && std::abs(d->template get() - 2.5) < 1e-9 && value.find(key_t(std::string(23, 'x')))->template get() == 2 && value.find(key_t(std::string(36, 'y')))->template get() == 3 && value.find(key_t(std::string(300, 'z')))->template get() == 4;