refine tests

This commit is contained in:
XenoAmess 2020-06-26 16:54:16 +08:00
parent acb237c52d
commit dd5d284e86
1 changed files with 13 additions and 5 deletions

View File

@ -708,29 +708,37 @@ public void testLang1380() throws ParseException {
assertEquals(expected.getTime(), fdp.parse("14 avr 2014"));
}
@Test
public void java15BuggyLocaleTestAll() throws ParseException {
for (final Locale locale : Locale.getAvailableLocales()) {
testSingleLocale(locale);
}
}
@Test
public void java15BuggyLocaleTest() throws ParseException {
final String buggyLocaleName = "ff_LR_#Adlm";
Locale buggyLocale = null;
for (final Locale locale : Locale.getAvailableLocales()) {
if (buggyLocaleName.equals(locale.toString())) {
buggyLocale = locale;
break;
}
}
if (buggyLocale == null) {
return;
}
testSingleLocale(buggyLocale);
}
private void testSingleLocale(Locale locale) throws ParseException {
final Calendar cal = Calendar.getInstance(GMT);
cal.clear();
cal.set(2003, Calendar.FEBRUARY, 10);
final SimpleDateFormat sdf = new SimpleDateFormat(LONG_FORMAT, buggyLocale);
final SimpleDateFormat sdf = new SimpleDateFormat(LONG_FORMAT, locale);
final String formattedDate = sdf.format(cal.getTime());
sdf.parse(formattedDate);
sdf.parse(formattedDate.toUpperCase(buggyLocale));
sdf.parse(formattedDate.toLowerCase(buggyLocale));
sdf.parse(formattedDate.toUpperCase(locale));
sdf.parse(formattedDate.toLowerCase(locale));
}
}