Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test that shows that isNaN call is not reliable #1135

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.json.JsonReadFeature;

import java.math.BigDecimal;

@FixMethodOrder(MethodSorters.NAME_ASCENDING) // easier to read on IDE
public class NonStandardNumberParsingTest
extends com.fasterxml.jackson.core.BaseTest
Expand Down Expand Up @@ -56,6 +58,20 @@ public void testNegativeHexadecimal() throws Exception {
}
}

public void testLargeDecimal() throws Exception {
final String value = "7976931348623157e309";
for (int mode : ALL_MODES) {
try (JsonParser p = createParser(mode, " " + value + " ")) {
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(new BigDecimal(value), p.getDecimalValue());
assertFalse(p.isNaN());
assertEquals(Double.POSITIVE_INFINITY, p.getValueAsDouble());
// PJF: we might want to fix the isNaN check to not be affected by us reading the value as a double
assertTrue(p.isNaN());
}
}
}

//JSON does not allow numbers to have f or d suffixes
public void testFloatMarker() throws Exception {
for (int mode : ALL_MODES) {
Expand Down