|
23 | 23 |
|
24 | 24 | /*
|
25 | 25 | * @test
|
26 |
| - * @bug 8327640 8331485 |
| 26 | + * @bug 8327640 8331485 8333456 |
27 | 27 | * @summary Test suite for NumberFormat parsing when lenient.
|
28 | 28 | * @run junit/othervm -Duser.language=en -Duser.country=US LenientParseTest
|
29 | 29 | * @run junit/othervm -Duser.language=ja -Duser.country=JP LenientParseTest
|
@@ -209,6 +209,18 @@ public void compactFmtSuccessParseTest(String toParse, double expectedValue) {
|
209 | 209 | assertEquals(expectedValue, successParse(cmpctFmt, toParse, toParse.length()));
|
210 | 210 | }
|
211 | 211 |
|
| 212 | + // 8333456: Parse values with no compact suffix -> which allows parsing to iterate |
| 213 | + // position to the same value as string length which throws |
| 214 | + // StringIndexOutOfBoundsException upon charAt invocation |
| 215 | + @ParameterizedTest |
| 216 | + @MethodSource("compactValidNoSuffixParseStrings") |
| 217 | + @EnabledIfSystemProperty(named = "user.language", matches = "en") |
| 218 | + public void compactFmtSuccessParseIntOnlyTest(String toParse, double expectedValue) { |
| 219 | + cmpctFmt.setParseIntegerOnly(true); |
| 220 | + assertEquals(expectedValue, successParse(cmpctFmt, toParse, toParse.length())); |
| 221 | + cmpctFmt.setParseIntegerOnly(false); |
| 222 | + } |
| 223 | + |
212 | 224 | // ---- Helper test methods ----
|
213 | 225 |
|
214 | 226 | // Method is used when a String should parse successfully. This does not indicate
|
@@ -407,6 +419,18 @@ private static Stream<Arguments> compactValidFullParseStrings() {
|
407 | 419 | );
|
408 | 420 | }
|
409 | 421 |
|
| 422 | + // No compact suffixes |
| 423 | + private static Stream<Arguments> compactValidNoSuffixParseStrings() { |
| 424 | + return Stream.of( |
| 425 | + Arguments.of("5", 5), |
| 426 | + Arguments.of("50", 50), |
| 427 | + Arguments.of("50.", 50), |
| 428 | + Arguments.of("5,000", 5000), |
| 429 | + Arguments.of("5,000.", 5000), |
| 430 | + Arguments.of("5,000.00", 5000) |
| 431 | + ); |
| 432 | + } |
| 433 | + |
410 | 434 | // Replace the grouping and decimal separators with localized variants
|
411 | 435 | // Used during localization of data
|
412 | 436 | private static String localizeText(String text) {
|
|
0 commit comments