|
21 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse; |
22 | 22 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
23 | 23 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertNull; |
24 | 25 | import static org.junit.jupiter.api.Assertions.assertThrows; |
25 | 26 | import static org.junit.jupiter.api.Assertions.assertTrue; |
26 | 27 | import static org.junit.jupiter.api.Assertions.fail; |
@@ -411,6 +412,20 @@ void testLang1121(final TriFunction<String, TimeZone, Locale, DateParser> dpProv |
411 | 412 | assertEquals(expected, actual); |
412 | 413 | } |
413 | 414 |
|
| 415 | + @ParameterizedTest |
| 416 | + @MethodSource(DATE_PARSER_PARAMETERS) |
| 417 | + void testLang1359(final TriFunction<String, TimeZone, Locale, DateParser> dpProvider) { |
| 418 | + // A trailing numeric field is unbounded, so a digit run that overflows int must fail the parse |
| 419 | + // through the ParsePosition/ParseException contract, not escape as a NumberFormatException. |
| 420 | + final DateParser fdp = getInstance(dpProvider, "yyyy", TimeZones.GMT, Locale.US); |
| 421 | + final String overflow = "99999999999"; |
| 422 | + assertThrows(ParseException.class, () -> fdp.parse(overflow)); |
| 423 | + final ParsePosition pos = new ParsePosition(0); |
| 424 | + assertNull(fdp.parseObject(overflow, pos)); |
| 425 | + assertTrue(pos.getErrorIndex() >= 0); |
| 426 | + assertEquals(0, pos.getIndex()); |
| 427 | + } |
| 428 | + |
414 | 429 | @ParameterizedTest |
415 | 430 | @MethodSource(DATE_PARSER_PARAMETERS) |
416 | 431 | void testLang1380(final TriFunction<String, TimeZone, Locale, DateParser> dpProvider) throws ParseException { |
|
0 commit comments