ICU-3938 CLDR 1.2 test updates

X-SVN-Rev: 16384
This commit is contained in:
Steven R. Loomis 2004-10-01 21:07:02 +00:00
parent 61d6352299
commit 164b735f3f
6 changed files with 74 additions and 48 deletions

View File

@ -356,7 +356,7 @@ CollationAPITest::TestRules()
coll->getRules(UCOL_TAILORING_ONLY, rules);
if (rules.length() != 0x0e) {
errln("English tailored rules failed");
errln("English tailored rules failed - length is 0x%x expected 0x%x", rules.length(), 0x0e);
}
coll->getRules(UCOL_FULL_RULES, rules);
@ -381,17 +381,17 @@ CollationAPITest::TestDecomposition() {
/* there is no reason to have canonical decomposition in en_US OR default locale */
if (vi_VN->getAttribute(UCOL_NORMALIZATION_MODE, status) != UCOL_ON)
{
errln("ERROR: vi_VN collation did not have cannonical decomposition for normalization!\n");
errln("ERROR: vi_VN collation did not have canonical decomposition for normalization!\n");
}
if (el_GR->getAttribute(UCOL_NORMALIZATION_MODE, status) != UCOL_ON)
{
errln("ERROR: el_GR collation did not have cannonical decomposition for normalization!\n");
errln("ERROR: el_GR collation did not have canonical decomposition for normalization!\n");
}
if (en_US->getAttribute(UCOL_NORMALIZATION_MODE, status) != UCOL_OFF)
{
errln("ERROR: en_US collation had cannonical decomposition for normalization!\n");
errln("ERROR: en_US collation had canonical decomposition for normalization!\n");
}
delete en_US;

View File

@ -277,7 +277,7 @@ IntlTestDateFormatAPI::TestNameHiding(void) {
fmt->format(numObj, str, fpos, status);
delete fmt;
} else {
errln("FAIL: Can't create NumberFormat");
errln("FAIL: Can't create NumberFormat()");
}
}

View File

@ -1312,7 +1312,7 @@ void NumberFormatTest::TestCurrencyPatterns(void) {
UErrorCode ec = U_ZERO_ERROR;
NumberFormat* nf = NumberFormat::createCurrencyInstance(locs[i], ec);
if (U_FAILURE(ec)) {
errln("FAIL: Can't create NumberFormat");
errln("FAIL: Can't create NumberFormat(%s) - %s", locs[i], u_errorName(ec));
} else {
// Make sure currency formats do not have a variable number
// of fraction digits

View File

@ -103,12 +103,36 @@ NumberFormatRegressionTest::runIndexedTest( int32_t index, UBool exec, const cha
}
}
UBool
NumberFormatRegressionTest::failure(UErrorCode status, const UnicodeString& msg, const Locale& l)
{
if(U_FAILURE(status)) {
errln(UnicodeString("FAIL: ", "") + msg
+ UnicodeString(" failed, error ", "") + UnicodeString(u_errorName(status), "") + UnicodeString(l.getName(),""));
return TRUE;
}
return FALSE;
}
UBool
NumberFormatRegressionTest::failure(UErrorCode status, const UnicodeString& msg, const char *l)
{
if(U_FAILURE(status)) {
errln(UnicodeString("FAIL: ", "") + msg
+ UnicodeString(" failed, error ", "") + UnicodeString(u_errorName(status), "") + UnicodeString(l, ""));
return TRUE;
}
return FALSE;
}
UBool
NumberFormatRegressionTest::failure(UErrorCode status, const UnicodeString& msg)
{
if(U_FAILURE(status)) {
errln(UnicodeString("FAIL: ", "") + msg
+ UnicodeString(" failed, error ", "") + UnicodeString(u_errorName(status), ""));
+ UnicodeString(" failed, error ", "") + UnicodeString(u_errorName(status), ""));
return TRUE;
}
@ -171,7 +195,7 @@ void NumberFormatRegressionTest::Test4088161 (void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *df = new DecimalFormat(status);
failure(status, "new DecimalFormat");
failure(status, "new DecimalFormat", "");
double d = 100;
df->setMinimumFractionDigits(0);
df->setMaximumFractionDigits(16);
@ -200,13 +224,13 @@ void NumberFormatRegressionTest::Test4087245 (void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols *symbols = new DecimalFormatSymbols(status);
failure(status, "new DecimalFormatSymbols");
failure(status, "new DecimalFormatSymbols", "");
// {sfb} One note about this test: if you pass in a pointer
// to the symbols, they are adopted and this test will fail,
// even though that is the correct behavior. To test the cloning
// of the symbols, it is necessary to pass in a reference to the symbols
DecimalFormat *df = new DecimalFormat("#,##0.0", *symbols, status);
failure(status, "new DecimalFormat with symbols");
failure(status, "new DecimalFormat with symbols", "");
int32_t n = 123;
UnicodeString buf1;
UnicodeString buf2;
@ -230,7 +254,7 @@ void NumberFormatRegressionTest::Test4087535 (void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *df = new DecimalFormat(status);
failure(status, "new DecimalFormat");
failure(status, "new DecimalFormat", "");
df->setMinimumIntegerDigits(0);
double n = 0;
@ -255,7 +279,7 @@ void NumberFormatRegressionTest::Test4088503 (void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *df = new DecimalFormat(status);
failure(status, "new DecimalFormat");
failure(status, "new DecimalFormat", "");
df->setGroupingSize(0);
UnicodeString sBuf;
FieldPosition fp(FieldPosition::DONT_CARE);
@ -286,7 +310,7 @@ NumberFormatRegressionTest::assignFloatValue(float returnfloat)
logln(UnicodeString(" VALUE ") + returnfloat);
UErrorCode status = U_ZERO_ERROR;
NumberFormat *nfcommon = NumberFormat::createCurrencyInstance(Locale::getUS(), status);
failure(status, "NumberFormat::createCurrencyInstance");
failure(status, "NumberFormat::createCurrencyInstance", Locale::getUS());
nfcommon->setGroupingUsed(FALSE);
UnicodeString stringValue;
@ -294,7 +318,7 @@ NumberFormatRegressionTest::assignFloatValue(float returnfloat)
logln(" DISPLAYVALUE " + stringValue);
Formattable result;
nfcommon->parse(stringValue, result, status);
failure(status, "nfcommon->parse");
failure(status, "nfcommon->parse", Locale::getUS());
float floatResult = (float) (result.getType() == Formattable::kDouble
? result.getDouble() : result.getLong());
if( uprv_fabs(floatResult - returnfloat) > 0.0001)
@ -313,12 +337,12 @@ void NumberFormatRegressionTest::Test4059870(void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *format = new DecimalFormat("00", status);
failure(status, "new Decimalformat");
failure(status, "new Decimalformat", Locale::getUS());
//try {
Formattable result;
UnicodeString str;
format->parse(UnicodeString("0"), result, status);
failure(status, "format->parse");
failure(status, "format->parse", Locale::getUS());
/*}
catch (Exception e) {
@ -336,7 +360,7 @@ void NumberFormatRegressionTest::Test4083018 (void)
{
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols *dfs = new DecimalFormatSymbols(status);
failure(status, "new DecimalFormatSymbols");
failure(status, "new DecimalFormatSymbols", Locale::getUS());
//try {
if (dfs != NULL)
logln("Test Passed!");
@ -357,7 +381,7 @@ void NumberFormatRegressionTest::Test4071492 (void)
double x = 0.00159999;
UErrorCode status = U_ZERO_ERROR;
NumberFormat *nf = NumberFormat::createInstance(status);
failure(status, "NumberFormat::createInstance");
failure(status, "NumberFormat::createInstance", Locale::getUS());
nf->setMaximumFractionDigits(4);
UnicodeString out;
FieldPosition pos(FieldPosition::DONT_CARE);
@ -386,7 +410,7 @@ void NumberFormatRegressionTest::Test4086575(void)
delete nf1;
return;
}
failure(status, "NumberFormat::createInstance");
failure(status, "NumberFormat::createInstance", Locale::getFrance());
// C++ workaround to make sure cast works
// Wouldn't dynamic_cast<DecimalFormat*> be great?
@ -403,7 +427,7 @@ void NumberFormatRegressionTest::Test4086575(void)
// No group separator
logln("...applyLocalizedPattern ###,00;(###,00) ");
nf->applyLocalizedPattern(UnicodeString("###,00;(###,00)"), status);
failure(status, "nf->applyLocalizedPattern");
failure(status, "nf->applyLocalizedPattern", Locale::getFrance());
logln("nf toPattern2: " + nf->toPattern(temp));
logln("nf toLocPattern2: " + nf->toLocalizedPattern(temp));
@ -422,7 +446,7 @@ void NumberFormatRegressionTest::Test4086575(void)
};
UnicodeString pat(patChars, 19, 19);
nf->applyLocalizedPattern(pat, status);
failure(status, "nf->applyLocalizedPattern");
failure(status, "nf->applyLocalizedPattern", Locale::getFrance());
logln("nf toPattern2: " + nf->toPattern(temp));
logln("nf toLocPattern2: " + nf->toLocalizedPattern(temp));
UnicodeString buffer;
@ -617,7 +641,7 @@ void NumberFormatRegressionTest::Test4095713 (void)
delete df;
return;
}
failure(status, "new DecimalFOrmat");
failure(status, "new DecimalFormat");
UnicodeString str("0.1234");
double d1 = 0.1234;
//Double d1 = new Double(str);
@ -793,7 +817,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
delete formatter;
return;
}
failure(status, "NumberFormat::createNumberInstance");
failure(status, "NumberFormat::createNumberInstance", loc);
tempString = formatter->format (-5789.9876, tempString);
if (tempString == expectedDefault) {
@ -806,7 +830,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
delete formatter;
len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
formatter = NumberFormat::createCurrencyInstance(loc, status);
failure(status, "NumberFormat::createCurrencyInstance");
failure(status, "NumberFormat::createCurrencyInstance", loc);
tempString.remove();
tempString = formatter->format( 5789.9876, tempString );
@ -821,7 +845,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
formatter = NumberFormat::createPercentInstance(Locale(loc), status);
failure(status, "NumberFormat::createPercentInstance");
failure(status, "NumberFormat::createPercentInstance", loc);
tempString.remove();
tempString = formatter->format (-5789.9876, tempString);
@ -862,7 +886,7 @@ void NumberFormatRegressionTest::Test4071005 (void)
UErrorCode status = U_ZERO_ERROR;
formatter = NumberFormat::createInstance(Locale::getCanadaFrench(), status);
failure(status, "NumberFormat::createNumberInstance");
failure(status, "NumberFormat::createNumberInstance", Locale::getCanadaFrench());
tempString = formatter->format (-5789.9876, tempString);
if (tempString == expectedDefault) {
@ -875,7 +899,7 @@ void NumberFormatRegressionTest::Test4071005 (void)
delete formatter;
formatter = NumberFormat::createCurrencyInstance(Locale::getCanadaFrench(), status);
failure(status, "NumberFormat::createCurrencyInstance");
failure(status, "NumberFormat::createCurrencyInstance", Locale::getCanadaFrench());
tempString.remove();
tempString = formatter->format( 5789.9876, tempString );
@ -889,7 +913,7 @@ void NumberFormatRegressionTest::Test4071005 (void)
delete formatter;
formatter = NumberFormat::createPercentInstance(Locale::getCanadaFrench(), status);
failure(status, "NumberFormat::createPercentInstance");
failure(status, "NumberFormat::createPercentInstance", Locale::getCanadaFrench());
tempString.remove();
tempString = formatter->format (-5789.9876, tempString);
@ -924,7 +948,7 @@ void NumberFormatRegressionTest::Test4071014 (void)
char loc[256]={0};
uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
formatter = NumberFormat::createInstance(Locale(loc), status);
failure(status, "NumberFormat::createNumberInstance");
failure(status, "NumberFormat::createNumberInstance", loc);
tempString.remove();
tempString = formatter->format (-5789.9876, tempString);
@ -938,7 +962,7 @@ void NumberFormatRegressionTest::Test4071014 (void)
delete formatter;
uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
formatter = NumberFormat::createCurrencyInstance(Locale(loc), status);
failure(status, "NumberFormat::createCurrencyInstance");
failure(status, "NumberFormat::createCurrencyInstance", loc);
tempString.remove();
tempString = formatter->format( 5789.9876, tempString );
@ -952,7 +976,7 @@ void NumberFormatRegressionTest::Test4071014 (void)
delete formatter;
formatter = NumberFormat::createPercentInstance(Locale::getGermany(), status);
failure(status, "NumberFormat::createPercentInstance");
failure(status, "NumberFormat::createPercentInstance", Locale::getGermany());
tempString.remove();
tempString = formatter->format (-5789.9876, tempString);
@ -2119,9 +2143,9 @@ void NumberFormatRegressionTest::Test4212072(void) {
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols sym(Locale::getUS(), status);
failure(status, "DecimalFormatSymbols ct");
failure(status, "DecimalFormatSymbols ct", Locale::getUS());
DecimalFormat fmt(UnicodeString("#"), sym, status);
failure(status, "DecimalFormat ct");
failure(status, "DecimalFormat ct", Locale::getUS());
UnicodeString s;
FieldPosition pos;
@ -2220,15 +2244,15 @@ void NumberFormatRegressionTest::Test4212072(void) {
switch (j) {
case 0:
nf = NumberFormat::createInstance(avail[i], status);
failure(status, "createInstance");
failure(status, "createInstance", avail[i]);
break;
case 1:
nf = NumberFormat::createCurrencyInstance(avail[i], status);
failure(status, "createCurrencyInstance");
failure(status, "createCurrencyInstance", avail[i]);
break;
default:
nf = NumberFormat::createPercentInstance(avail[i], status);
failure(status, "createPercentInstance");
failure(status, "createPercentInstance", avail[i]);
break;
}
if (U_FAILURE(status)) {
@ -2240,7 +2264,7 @@ void NumberFormatRegressionTest::Test4212072(void) {
UnicodeString pat;
df->toPattern(pat);
DecimalFormatSymbols symb(avail[i], status);
failure(status, "Construct DecimalFormatSymbols");
failure(status, "Construct DecimalFormatSymbols", avail[i]);
DecimalFormat f2(pat, symb, status);
if (failure(status,
UnicodeString("Construct DecimalFormat(") + pat + ")")) {
@ -2257,7 +2281,7 @@ void NumberFormatRegressionTest::Test4212072(void) {
df->toLocalizedPattern(pat);
f2.applyLocalizedPattern(pat, status);
failure(status,
UnicodeString("applyLocalizedPattern(") + pat + ")");
UnicodeString("applyLocalizedPattern(") + pat + ")", avail[i]);
if (U_FAILURE(status)) {
continue;
}
@ -2283,7 +2307,7 @@ void NumberFormatRegressionTest::Test4212072(void) {
void NumberFormatRegressionTest::Test4216742(void) {
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *fmt = (DecimalFormat*) NumberFormat::createInstance(Locale::getUS(), status);
failure(status, "createInstance");
failure(status, "createInstance", Locale::getUS());
int32_t DATA[] = { INT32_MIN, INT32_MAX, -100000000, 100000000 };
int DATA_length = (int)(sizeof(DATA) / sizeof(DATA[0]));
for (int i=0; i<DATA_length; ++i) {
@ -2292,7 +2316,7 @@ void NumberFormatRegressionTest::Test4216742(void) {
fmt->setMultiplier(m);
Formattable num;
fmt->parse(str, num, status);
failure(status, "parse");
failure(status, "parse", Locale::getUS());
if (num.getType() != Formattable::kLong &&
num.getType() != Formattable::kDouble) {
errln(UnicodeString("FAIL: Wanted number, got ") +
@ -2322,7 +2346,7 @@ void NumberFormatRegressionTest::Test4217661(void) {
int D_length = (int)(sizeof(D) / sizeof(D[0]));
UErrorCode status = U_ZERO_ERROR;
NumberFormat *fmt = NumberFormat::createInstance(Locale::getUS(), status);
failure(status, "createInstance");
failure(status, "createInstance", Locale::getUS());
fmt->setMaximumFractionDigits(2);
for (int i=0; i<D_length; i++) {
UnicodeString s;
@ -2340,7 +2364,7 @@ void NumberFormatRegressionTest::Test4217661(void) {
void NumberFormatRegressionTest::Test4161100(void) {
UErrorCode status = U_ZERO_ERROR;
NumberFormat *nf = NumberFormat::createInstance(Locale::getUS(), status);
failure(status, "createInstance");
failure(status, "createInstance", Locale::getUS());
nf->setMinimumFractionDigits(1);
nf->setMaximumFractionDigits(1);
double a = -0.09;
@ -2362,9 +2386,9 @@ void NumberFormatRegressionTest::Test4161100(void) {
void NumberFormatRegressionTest::Test4243011(void) {
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols sym(Locale::getUS(), status);
failure(status, "DecimalFormatSymbols ct");
failure(status, "DecimalFormatSymbols ct", Locale::getUS());
DecimalFormat fmt(UnicodeString("0."), sym, status);
failure(status, "DecimalFormat ct");
failure(status, "DecimalFormat ct", Locale::getUS());
const double NUM[] = { -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5 };
const char* STR[] = { "-2.", "-2.", "-0.", "0.", "2.", "2.", "4.", "4." };
@ -2392,9 +2416,9 @@ void NumberFormatRegressionTest::Test4243011(void) {
void NumberFormatRegressionTest::Test4243108(void) {
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols sym(Locale::getUS(), status);
failure(status, "DecimalFormatSymbols ct");
failure(status, "DecimalFormatSymbols ct", Locale::getUS());
DecimalFormat fmt(UnicodeString("#.#"), sym, status);
failure(status, "DecimalFormat ct");
failure(status, "DecimalFormat ct", Locale::getUS());
UnicodeString str;
FieldPosition pos;
@ -2411,7 +2435,7 @@ void NumberFormatRegressionTest::Test4243108(void) {
str = "99.99";
Formattable val;
fmt.parse(str, val, status);
failure(status, "DecimalFormat.parse(99.99)");
failure(status, "DecimalFormat.parse(99.99)", Locale::getUS());
if (val.getType() == Formattable::kDouble &&
val.getDouble() == 99.99) {
logln(UnicodeString("Ok 99.99 / #.# = ") + toString(val));

View File

@ -93,6 +93,8 @@ public:
protected:
UBool failure(UErrorCode status, const UnicodeString& msg);
UBool failure(UErrorCode status, const UnicodeString& msg, const char *l);
UBool failure(UErrorCode status, const UnicodeString& msg, const Locale& l);
};
class MyNumberFormatTest : public NumberFormat

View File

@ -82,7 +82,7 @@ void UCAConformanceTest::initRbUCA()
rbUCA = ucol_openRules(ucarules, size, UCOL_DEFAULT, UCOL_TERTIARY,
&parseError, &status);
if (U_FAILURE(status)) {
errln("Failure creating UCA rule-based collator.");
errln("Failure creating UCA rule-based collator: %s", u_errorName(status));
return;
}
}