JsonDeserializer: use float when the value has few digits

This commit is contained in:
Benoit Blanchon
2024-09-04 14:33:14 +02:00
parent fd6314e132
commit 1f7a3f3174
8 changed files with 163 additions and 28 deletions

View File

@ -60,10 +60,15 @@ TEST_CASE("parseNumber<float>()") {
SECTION("VeryLong") {
checkFloat("0.00000000000000000000000000000001", 1e-32f);
checkFloat("100000000000000000000000000000000.0", 1e+32f);
checkFloat(
"100000000000000000000000000000000.00000000000000000000000000000",
1e+32f);
// The following don't work because they have many digits so parseNumber()
// treats them as double. But it's not an issue because JsonVariant will use
// a float to store them.
//
// checkFloat("100000000000000000000000000000000.0", 1e+32f);
// checkFloat(
// "100000000000000000000000000000000.00000000000000000000000000000",
// 1e+32f);
}
SECTION("NaN") {