Skip to content

Commit

Permalink
add tests for ints with 19 chars (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Sep 21, 2024
1 parent 4d47aae commit b9d56af
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void bigNumbers() throws Exception
BigInteger biggie = new BigInteger(NUMBER_STR);

for (int mode : ALL_MODES) {
try (JsonParser p = createParser(jsonFactory(), mode, NUMBER_STR +" ")) {
try (JsonParser p = createParser(jsonFactory(), mode, NUMBER_STR + " ")) {
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonParser.NumberType.BIG_INTEGER, p.getNumberType());
assertEquals(NUMBER_STR, p.getText());
Expand All @@ -463,6 +463,26 @@ void bigNumbers() throws Exception
}
}

@Test
void intsWith19Chars() throws Exception
{
final String[] values = new String[] {
"9223372036854775808", "9999999999999999999"
};
for (String value : values) {
BigInteger biggie = new BigInteger(value);

for (int mode : ALL_MODES) {
try (JsonParser p = createParser(jsonFactory(), mode, value + " ")) {
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(JsonParser.NumberType.BIG_INTEGER, p.getNumberType());
assertEquals(biggie, p.getBigIntegerValue());
assertEquals(value, p.getText());
}
}
}
}

// Related to [core#1135]: JsonParser.isNaN() should not be fooled
// by possible Double overflow
@Test
Expand Down

0 comments on commit b9d56af

Please sign in to comment.