Skip to content

Commit 6836061

Browse files
authored
test that shows that isNaN call is not reliable (#1135)
1 parent e7b978b commit 6836061

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/java/com/fasterxml/jackson/core/read/NonStandardNumberParsingTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.fasterxml.jackson.core.*;
77
import com.fasterxml.jackson.core.json.JsonReadFeature;
88

9+
import java.math.BigDecimal;
10+
911
@FixMethodOrder(MethodSorters.NAME_ASCENDING) // easier to read on IDE
1012
public class NonStandardNumberParsingTest
1113
extends com.fasterxml.jackson.core.BaseTest
@@ -56,6 +58,20 @@ public void testNegativeHexadecimal() throws Exception {
5658
}
5759
}
5860

61+
public void testLargeDecimal() throws Exception {
62+
final String value = "7976931348623157e309";
63+
for (int mode : ALL_MODES) {
64+
try (JsonParser p = createParser(mode, " " + value + " ")) {
65+
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
66+
assertEquals(new BigDecimal(value), p.getDecimalValue());
67+
assertFalse(p.isNaN());
68+
assertEquals(Double.POSITIVE_INFINITY, p.getValueAsDouble());
69+
// PJF: we might want to fix the isNaN check to not be affected by us reading the value as a double
70+
assertTrue(p.isNaN());
71+
}
72+
}
73+
}
74+
5975
//JSON does not allow numbers to have f or d suffixes
6076
public void testFloatMarker() throws Exception {
6177
for (int mode : ALL_MODES) {

0 commit comments

Comments
 (0)