From b94be601d1ae4b86c31f14653c205727ac44121d Mon Sep 17 00:00:00 2001 From: Martin Pluskal Date: Thu, 25 Jun 2026 15:10:22 +0200 Subject: [PATCH] test: make ValueTest/objects float check robust against x87 excess precision ValueTest/objects stores the float literal 0.12345f into a Json::Value (widened to the stored double) and then asserts equality against the original 0.12345f. On 32-bit x86 targets where GCC defaults to x87 math (-mfpmath=387, 80-bit excess precision) and the baseline lacks SSE2, the round-trip yields the exact double 0.12345 rather than the float-widened 0.12345000356435776, so the exact double comparison fails even though the library itself is correct. Compare the stored value narrowed back to float via asFloat(): both the expected literal and asFloat() collapse to the same float value on every architecture, keeping the numeric round-trip check while making it precision-robust. --- src/test_lib_json/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 90025b443..2ef6895e1 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -352,7 +352,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, objects) { const Json::Value* numericFound = object2_.findNumeric("numeric"); JSONTEST_ASSERT(numericFound != nullptr); - JSONTEST_ASSERT_EQUAL(0.12345f, *numericFound); + JSONTEST_ASSERT_EQUAL(0.12345f, numericFound->asFloat()); JSONTEST_ASSERT(object3_.findNumeric("numeric") == nullptr); const Json::Value* stringFound = object2_.findString("string");