**/
package com.ibm.icu.dev.test.format;
+
import java.util.Locale;
import java.util.Random;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.text.DecimalFormat;
import com.ibm.icu.text.NumberFormat;
+import com.ibm.icu.util.ULocale;
/**
* This test does round-trip testing (format -> parse -> format -> parse -> etc.) of
boolean dump = false;
int i;
+ String message = "Locale: " + fNumberFormat.getLocale(ULocale.VALID_LOCALE);
+
for (i = 0; i < DEPTH; i++) {
if (i == 0) {
number[i] = aNumber;
try {
number[i - 1] = fNumberFormat.parse(string[i - 1]).doubleValue();
} catch(java.text.ParseException pe) {
- errln("**** FAIL: Parse of " + string[i-1] + " failed.");
+ errln("**** FAIL: Parse of " + string[i-1] + " failed: " + message);
dump = true;
break;
}
numberMatch = i;
else if (numberMatch > 0 && number[i] != number[i-1])
{
- errln("**** FAIL: Numeric mismatch after match.");
+ errln("**** FAIL: Numeric mismatch after match: " + message);
dump = true;
break;
}
stringMatch = i;
else if (stringMatch > 0 && string[i] != string[i-1])
{
- errln("**** FAIL: String mismatch after match.");
+ errln("**** FAIL: String mismatch after match: " + message);
dump = true;
break;
}
if (stringMatch > 2 || numberMatch > 2)
{
- errln("**** FAIL: No string and/or number match within 2 iterations.");
+ errln("**** FAIL: No string and/or number match within 2 iterations: " + message);
dump = true;
}
public void tryIt(int aNumber) {
long number;
+ String message = "Locale: " + fNumberFormat.getLocale(ULocale.VALID_LOCALE);
+
String stringNum = fNumberFormat.format(aNumber);
try {
number = fNumberFormat.parse(stringNum).longValue();
} catch (java.text.ParseException pe) {
- errln("**** FAIL: Parse of " + stringNum + " failed.");
+ errln("**** FAIL: Parse of " + stringNum + " failed: " + message);
return;
}
if (number != aNumber) {
- errln("**** FAIL: Parse of " + stringNum + " failed. Got:" + number
+ errln("**** FAIL: Parse of " + stringNum + " failed: " + message
+ + " Got:" + number
+ " Expected:" + aNumber);
}
count = locales.length;
if (count != 0)
{
- if (TestFmwk.getExhaustiveness() < 10 && count > 6) {
- count = 6;
- locales = new Locale[6];
+ if (TestFmwk.getExhaustiveness() < 10 && count > 7) {
+ count = 7;
+ locales = new Locale[count];
locales[0] = allLocales[0];
locales[1] = allLocales[1];
locales[2] = allLocales[2];
locales[3] = new Locale("ar", "AE", "");
locales[4] = new Locale("cs", "CZ", "");
locales[5] = new Locale("en", "IN", "");
+ locales[6] = new Locale("su", "", "");
}
for (int i=0; i<count; ++i)
{