ICU-3378 Fixed Java 1.3/1.4 compatibility problem in the test code.

X-SVN-Rev: 25418
This commit is contained in:
Yoshito Umaoka 2009-02-14 08:18:07 +00:00
parent 52ba8e4efa
commit af47e92167
4 changed files with 28 additions and 9 deletions

View File

@ -11,12 +11,12 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.MissingResourceException;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.text.SimpleDateFormat;
@ -2136,7 +2136,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
if (!matchPref) {
errln("FAIL: Preferred values for locale " + loc
+ " got:" + Arrays.toString(pref) + " expected:" + Arrays.toString(expected));
+ " got:" + Utility.arrayToString(pref) + " expected:" + Utility.arrayToString(expected));
}
String[] all = Calendar.getKeywordValuesForLocale("calendar", loc, false);
@ -2152,7 +2152,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
}
if (!matchAll) {
errln("FAIL: All values for locale " + loc
+ " got:" + Arrays.toString(all));
+ " got:" + Utility.arrayToString(all));
}
}
}

View File

@ -7,7 +7,6 @@
package com.ibm.icu.dev.test.collator;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -18,6 +17,7 @@ import java.util.MissingResourceException;
import java.util.Set;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.Collator.CollatorFactory;
import com.ibm.icu.util.ULocale;
@ -479,7 +479,7 @@ public class CollationServiceTest extends TestFmwk {
}
if (!matchPref) {
errln("FAIL: Preferred values for locale " + loc
+ " got:" + Arrays.toString(pref) + " expected:" + Arrays.toString(expected));
+ " got:" + Utility.arrayToString(pref) + " expected:" + Utility.arrayToString(expected));
}
String[] all = Collator.getKeywordValuesForLocale("collation", loc, true);
@ -505,7 +505,7 @@ public class CollationServiceTest extends TestFmwk {
}
if (!matchAll) {
errln("FAIL: All values for locale " + loc
+ " got:" + Arrays.toString(all) + " expected:" + Arrays.toString(pref));
+ " got:" + Utility.arrayToString(all) + " expected:" + Utility.arrayToString(pref));
}
}
}

View File

@ -10,12 +10,12 @@
*/
package com.ibm.icu.dev.test.util;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.text.DecimalFormatSymbols;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.ULocale;
@ -464,7 +464,7 @@ public class CurrencyTest extends TestFmwk {
}
if (!matchPref) {
errln("FAIL: Preferred values for locale " + loc
+ " got:" + Arrays.toString(pref) + " expected:" + Arrays.toString(expected));
+ " got:" + Utility.arrayToString(pref) + " expected:" + Utility.arrayToString(expected));
}
String[] all = Currency.getKeywordValuesForLocale("currency", loc, false);
@ -480,7 +480,7 @@ public class CurrencyTest extends TestFmwk {
}
if (!matchAll) {
errln("FAIL: All values for locale " + loc
+ " got:" + Arrays.toString(all));
+ " got:" + Utility.arrayToString(all));
}
}
}

View File

@ -6,6 +6,7 @@
*******************************************************************************
*/
package com.ibm.icu.impl;
import java.util.ArrayList;
import com.ibm.icu.lang.*;
@ -1950,4 +1951,22 @@ public final class Utility {
}
return new Integer(val);
}
// !!! 1.3/1.4 compatibility
// Arrays.toString(Object[])
public static String arrayToString(Object[] a) {
StringBuffer buf = new StringBuffer("[");
for (int i = 0; i < a.length; i++) {
if (i != 0) {
buf.append(", ");
}
if (a[i] == null) {
buf.append("null");
} else {
buf.append(a[i].toString());
}
}
buf.append("]");
return buf.toString();
}
}