Skip to content

Commit

Permalink
ICU-22279 Fix invalid new Locale in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mihnita committed Mar 10, 2023
1 parent 57e4b0c commit a366190
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ public boolean visible(){
*/
try {
TestCreateCollator tcc = new TestCreateCollator();
tcc.createCollator(new Locale("en_US"));
tcc.createCollator(new Locale("en", "US"));
} catch (Exception e) {
errln("Collator.createCollator(Locale) was not suppose to " + "return an exception.");
}
Expand All @@ -1602,7 +1602,7 @@ public boolean visible(){
*/
try {
TestCreateCollator tcc = new TestCreateCollator();
tcc.getDisplayName(new Locale("en_US"), new Locale("jp_JP"));
tcc.getDisplayName(new Locale("en", "US"), new Locale("jp", "JP"));
} catch (Exception e) {
errln("Collator.getDisplayName(Locale,Locale) was not suppose to return an exception.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ public void TestHangulTailoring() {

// no such locale in icu4j
// logln("Using ko__LOTUS locale\n");
// genericLocaleStarter(new Locale("ko__LOTUS", ""), koreanData);
// genericLocaleStarter(new Locale("ko", "", "LOTUS"), koreanData);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void Test5345parse() {
SimpleDateFormat fmt = (SimpleDateFormat)c.getDateTimeFormat(1,1,new ULocale("en_US@calendar=japanese"));
fmt.applyPattern("G y");
logln("fmt's locale = " + fmt.getLocale(ULocale.ACTUAL_LOCALE));
//SimpleDateFormat fmt = new SimpleDateFormat("G y", new Locale("en_US@calendar=japanese"));
//SimpleDateFormat fmt = new SimpleDateFormat("G y", new ULocale("en_US@calendar=japanese"));
long aDateLong = -3197117222000L; // 1868-09-08 00:00 Pacific Time (GMT-07:52:58)
if (TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK) {
// Java time zone implementation does not support LMTs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void TestEnglishShort() {
@Test
public void TestArabicLongStyle() {
NumberFormat cdf =
CompactDecimalFormat.getInstance(new Locale("ar-EG"), CompactStyle.LONG);
CompactDecimalFormat.getInstance(new Locale("ar", "EG"), CompactStyle.LONG);
assertEquals("Arabic Long", "\u061C-\u0665\u066B\u0663 \u0623\u0644\u0641", cdf.format(-5300));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ public void Test12902_yWithGregoCalInThaiLoc() {
@Test
public void TestT10110() {
try {
SimpleDateFormat formatter = new SimpleDateFormat("Gy年M月d日E", new Locale("zh_Hans"));
SimpleDateFormat formatter = new SimpleDateFormat("Gy年M月d日E", Locale.forLanguageTag("zh-Hans"));
/* Object parsed = */ formatter.parseObject("610000");
}
catch(ParseException pe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2465,13 +2465,13 @@ public void TestCoverage() {
sym.equals(null);

sym = new ChineseDateFormatSymbols();
sym = new ChineseDateFormatSymbols(new Locale("en_US"));
sym = new ChineseDateFormatSymbols(new Locale("en", "US"));
try{
sym = new ChineseDateFormatSymbols(null, new Locale("en_US"));
sym = new ChineseDateFormatSymbols(null, new Locale("en", "US"));
errln("ChineseDateFormatSymbols(Calender, Locale) was suppose to return a null " +
"pointer exception for a null paramater.");
} catch(Exception e){}
sym = new ChineseDateFormatSymbols(new ChineseCalendar(), new Locale("en_US"));
sym = new ChineseDateFormatSymbols(new ChineseCalendar(), new Locale("en", "US"));
try{
sym = new ChineseDateFormatSymbols(null, new ULocale("en_US"));
errln("ChineseDateFormatSymbols(Calender, ULocale) was suppose to return a null " +
Expand Down Expand Up @@ -4011,8 +4011,8 @@ public void TestGetPatternInstance(){
try{
@SuppressWarnings("unused")
DateFormat df = DateFormat.getPatternInstance("");
df = DateFormat.getPatternInstance("", new Locale("en_US"));
df = DateFormat.getPatternInstance(null, "", new Locale("en_US"));
df = DateFormat.getPatternInstance("", new Locale("en", "US"));
df = DateFormat.getPatternInstance(null, "", new Locale("en", "US"));
} catch(Exception e) {
errln("DateFormat.getPatternInstance is not suppose to return an exception, got: " + e.toString());
//e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2241,13 +2241,13 @@ public void testCreateInstanceForAllLocales() {
public void testTicket20707() {
TimeZone tz = TimeZone.getTimeZone("UTC");
Locale locales[] = {
new Locale("en-u-hc-h24"),
new Locale("en-u-hc-h23"),
new Locale("en-u-hc-h12"),
new Locale("en-u-hc-h11"),
new Locale("en"),
new Locale("en-u-hc-h25"),
new Locale("hi-IN-u-hc-h11")
Locale.forLanguageTag("en-u-hc-h24"),
Locale.forLanguageTag("en-u-hc-h23"),
Locale.forLanguageTag("en-u-hc-h12"),
Locale.forLanguageTag("en-u-hc-h11"),
Locale.forLanguageTag("en"),
Locale.forLanguageTag("en-u-hc-h25"),
Locale.forLanguageTag("hi-IN-u-hc-h11")
};

// Clomuns: hh, HH, kk, KK, jj, JJs, CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void TestAPI() {
format.setLocale(es);
formatParsing(format);

format.setLocale(new Locale("pt_BR"));
format.setLocale(new Locale("pt", "BR"));
formatParsing(format);
format = new TimeUnitFormat(new Locale("de"));
formatParsing(format);
Expand Down Expand Up @@ -343,7 +343,7 @@ public void TestTimeUnitFormat() {
}
for (int i = 0; i < cases.length; i++) {
try {
TimeUnitFormat tuf = new TimeUnitFormat(new Locale("en_US"), cases[i]);
TimeUnitFormat tuf = new TimeUnitFormat(new Locale("en", "US"), cases[i]);
errln("TimeUnitFormat(ULocale,int) was suppose to return an " + "exception for a style value of "
+ cases[i] + "passed into the constructor.");
} catch (Exception e) {
Expand All @@ -358,7 +358,7 @@ public void TestTimeUnitFormat() {
public void TestSetLocale() {
// Tests when "if ( locale != this.locale )" is false
TimeUnitFormat tuf = new TimeUnitFormat(new ULocale("en_US"));
if (!tuf.setLocale(new ULocale("en_US")).equals(tuf) && !tuf.setLocale(new Locale("en_US")).equals(tuf)) {
if (!tuf.setLocale(new ULocale("en_US")).equals(tuf) && !tuf.setLocale(new Locale("en", "US")).equals(tuf)) {
errln("TimeUnitFormat.setLocale(ULocale) was suppose to "
+ "return the same TimeUnitFormat object if the same " + "ULocale is entered as a parameter.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ public Object[] getTestObjects()
{
CurrencyPluralInfo currencyPluralInfo[] = {
new CurrencyPluralInfo(), new CurrencyPluralInfo(new ULocale("en_US")),
CurrencyPluralInfo.getInstance(), CurrencyPluralInfo.getInstance(new Locale("en_US")),
CurrencyPluralInfo.getInstance(), CurrencyPluralInfo.getInstance(new Locale("en", "US")),
CurrencyPluralInfo.getInstance(new ULocale("en_US"))
};
for(int i=0; i<currencyPluralInfo.length; i++){
Expand Down

0 comments on commit a366190

Please sign in to comment.