Skip to content

Commit edc01ab

Browse files
pluskybaylesj
andauthored
test: make ValueTest/objects float check robust against x87 excess precision (#1700)
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. Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
1 parent affc500 commit edc01ab

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/test_lib_json/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, objects) {
352352

353353
const Json::Value* numericFound = object2_.findNumeric("numeric");
354354
JSONTEST_ASSERT(numericFound != nullptr);
355-
JSONTEST_ASSERT_EQUAL(0.12345f, *numericFound);
355+
JSONTEST_ASSERT_EQUAL(0.12345f, numericFound->asFloat());
356356
JSONTEST_ASSERT(object3_.findNumeric("numeric") == nullptr);
357357

358358
const Json::Value* stringFound = object2_.findString("string");

0 commit comments

Comments
 (0)