ICU-7784 Set some test failure errors as data loading error appropriate.

X-SVN-Rev: 28305
This commit is contained in:
Michael Ow 2010-07-14 16:09:03 +00:00
parent 9fa040e389
commit 0e8df2ba58
9 changed files with 40 additions and 32 deletions

View file

@ -1257,7 +1257,7 @@ static void TestLocaleDisplayPattern(void){
ULocaleData *uld = ulocdata_open(uloc_getDefault(), &status);
if(U_FAILURE(status)){
log_err("ulocdata_open error");
log_data_err("ulocdata_open error");
return;
}
ulocdata_getLocaleDisplayPattern(uld, pattern, 32, &status);
@ -1286,7 +1286,7 @@ static void TestCoverage(void){
ULocaleData *uld = ulocdata_open(uloc_getDefault(), &status);
if(U_FAILURE(status)){
log_err("ulocdata_open error");
log_data_err("ulocdata_open error");
return;
}

View file

@ -1513,7 +1513,7 @@ static void TestChMove(void) {
}
}
else {
log_err("Can't open collator");
log_data_err("Can't open collator");
}
ucol_close(coll);
}

View file

@ -374,7 +374,7 @@ static void TestCurrencySign(void)
if(U_SUCCESS(status) && str) {
res=(UChar*)malloc(sizeof(UChar) * (strlen("$1,234.56")+1) );
u_uastrcpy(res, "$1,234.56");
if (u_strcmp(str, res) !=0) log_err("FAIL: Expected $1,234.56\n");
if (u_strcmp(str, res) !=0) log_data_err("FAIL: Expected $1,234.56\n");
} else {
log_err_status(status, "Error formatting -> %s\n", u_errorName(status));
}
@ -395,7 +395,7 @@ static void TestCurrencySign(void)
if(str) {
res=(UChar*)malloc(sizeof(UChar) * (strlen("-$1,234.56")+1) );
u_uastrcpy(res, "-$1,234.56");
if (u_strcmp(str, res) != 0) log_err("FAIL: Expected -$1,234.56\n");
if (u_strcmp(str, res) != 0) log_data_err("FAIL: Expected -$1,234.56\n");
free(str);
free(res);
}

View file

@ -899,7 +899,7 @@ static void TestSigDigRounding()
fmt=unum_open(UNUM_DECIMAL, NULL, 0, NULL /* "en_US"*/, NULL, &status);
if (U_FAILURE(status)) {
log_err("got unexpected error for unum_open: '%s'\n", u_errorName(status));
log_data_err("got unexpected error for unum_open: '%s'\n", u_errorName(status));
return;
}
unum_setAttribute(fmt, UNUM_LENIENT_PARSE, FALSE);
@ -1007,7 +1007,7 @@ free(result);
if(u_strcmp(result, temp1)==0)
log_verbose("Pass: Number Formatting using unum_formatDouble() padding Successful\n");
else
log_err("FAIL: Error in number formatting using unum_formatDouble() with padding\n");
log_data_err("FAIL: Error in number formatting using unum_formatDouble() with padding\n");
if(pos1.beginIndex == 13 && pos1.endIndex == 15)
log_verbose("Pass: Complete number formatting using unum_formatDouble() successful\n");
else
@ -1347,24 +1347,28 @@ static void TestRBNFFormat() {
formats[0] = unum_open(UNUM_PATTERN_DECIMAL, pat, -1, "en_US", &perr, &status);
if (U_FAILURE(status)) {
log_err_status(status, "unable to open decimal pattern -> %s\n", u_errorName(status));
return;
}
status = U_ZERO_ERROR;
formats[1] = unum_open(UNUM_SPELLOUT, NULL, 0, "en_US", &perr, &status);
if (U_FAILURE(status)) {
log_err_status(status, "unable to open spellout -> %s\n", u_errorName(status));
return;
}
status = U_ZERO_ERROR;
formats[2] = unum_open(UNUM_ORDINAL, NULL, 0, "en_US", &perr, &status);
if (U_FAILURE(status)) {
log_err_status(status, "unable to open ordinal -> %s\n", u_errorName(status));
return;
}
status = U_ZERO_ERROR;
formats[3] = unum_open(UNUM_DURATION, NULL, 0, "en_US", &perr, &status);
if (U_FAILURE(status)) {
log_err_status(status, "unable to open duration %s\n", u_errorName(status));
return;
}
status = U_ZERO_ERROR;

View file

@ -3360,7 +3360,7 @@ void DateFormatTest::TestISOEra() {
// create formatter
SimpleDateFormat *fmt1 = new SimpleDateFormat(UnicodeString("GGG yyyy-MM-dd'T'HH:mm:ss'Z"), status);
failure(status, "new SimpleDateFormat");
failure(status, "new SimpleDateFormat", TRUE);
for(int i=0; i < numData; i+=2) {
// create input string
@ -3368,7 +3368,7 @@ void DateFormatTest::TestISOEra() {
// parse string to date
UDate dt1 = fmt1->parse(in, status);
failure(status, "fmt->parse");
failure(status, "fmt->parse", TRUE);
// format date back to string
UnicodeString out;
@ -3378,7 +3378,7 @@ void DateFormatTest::TestISOEra() {
// check that roundtrip worked as expected
UnicodeString expected = data[i+1];
if (out != expected) {
errln((UnicodeString)"FAIL: " + in + " -> " + out + " expected -> " + expected);
dataerrln((UnicodeString)"FAIL: " + in + " -> " + out + " expected -> " + expected);
}
}

View file

@ -48,6 +48,7 @@ static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
#define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
#define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
#define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
{
@ -630,11 +631,11 @@ NumberFormatTest::TestCurrencySign(void)
pat.truncate(0);
logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
if (s != "$1,234.56") errln((UnicodeString)"FAIL: Expected $1,234.56");
if (s != "$1,234.56") dataerrln((UnicodeString)"FAIL: Expected $1,234.56");
s.truncate(0);
((NumberFormat*)fmt)->format(- 1234.56, s);
logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
if (s != "-$1,234.56") errln((UnicodeString)"FAIL: Expected -$1,234.56");
if (s != "-$1,234.56") dataerrln((UnicodeString)"FAIL: Expected -$1,234.56");
delete fmt;
pat.truncate(0);
// "\xA4\xA4 #,##0.00;\xA4\xA4 -#,##0.00"
@ -647,11 +648,11 @@ NumberFormatTest::TestCurrencySign(void)
((NumberFormat*)fmt)->format(1234.56, s);
logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
if (s != "USD 1,234.56") errln((UnicodeString)"FAIL: Expected USD 1,234.56");
if (s != "USD 1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD 1,234.56");
s.truncate(0);
((NumberFormat*)fmt)->format(-1234.56, s);
logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
if (s != "USD -1,234.56") errln((UnicodeString)"FAIL: Expected USD -1,234.56");
if (s != "USD -1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD -1,234.56");
delete fmt;
delete sym;
if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + u_errorName(status));
@ -887,7 +888,7 @@ void NumberFormatTest::TestSecondaryGrouping(void) {
expect2(f, (int32_t)123456789L, "12,3456,789");
expectPat(f, "#,####,###");
NumberFormat *g = NumberFormat::createInstance(Locale("hi", "IN"), status);
CHECK(status, "createInstance(hi_IN)");
CHECK_DATA(status, "createInstance(hi_IN)");
UnicodeString out;
int32_t l = (int32_t)1876543210L;
@ -1718,7 +1719,7 @@ void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
if (str == "$ 2,350.75") {
logln(str);
} else {
errln("Fail: " + str + ", expected $ 2,350.75");
dataerrln("Fail: " + str + ", expected $ 2,350.75");
}
sym = new DecimalFormatSymbols(Locale::getUS(), ec);
@ -1735,7 +1736,7 @@ void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
if (str == "Q 2,350.75") {
logln(str);
} else {
errln("Fail: adoptDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
dataerrln("Fail: adoptDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
}
sym = new DecimalFormatSymbols(Locale::getUS(), ec);
@ -1763,7 +1764,7 @@ void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
if (str == "Q 2,350.75") {
logln(str);
} else {
errln("Fail: setDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
dataerrln("Fail: setDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
}
}
@ -2116,8 +2117,8 @@ void NumberFormatTest::expect2(NumberFormat& fmt, const Formattable& n, const Un
void NumberFormatTest::expect2(NumberFormat* fmt, const Formattable& n,
const UnicodeString& exp,
UErrorCode status) {
if (U_FAILURE(status)) {
errln("FAIL: NumberFormat constructor");
if (fmt == NULL || U_FAILURE(status)) {
dataerrln("FAIL: NumberFormat constructor");
} else {
expect2(*fmt, n, exp);
}
@ -2129,7 +2130,7 @@ void NumberFormatTest::expect(NumberFormat& fmt, const UnicodeString& str, const
Formattable num;
fmt.parse(str, num, status);
if (U_FAILURE(status)) {
errln(UnicodeString("FAIL: Parse failed for \"") + str + "\"");
dataerrln(UnicodeString("FAIL: Parse failed for \"") + str + "\" - " + u_errorName(status));
return;
}
UnicodeString pat;
@ -2139,7 +2140,7 @@ void NumberFormatTest::expect(NumberFormat& fmt, const UnicodeString& str, const
pat + " = " +
toString(num));
} else {
errln(UnicodeString("FAIL \"") + str + "\" x " +
dataerrln(UnicodeString("FAIL \"") + str + "\" x " +
pat + " = " +
toString(num) + ", expected " + toString(n));
}
@ -2218,7 +2219,7 @@ void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n,
Formattable n2;
fmt.parse(exp, n2, status);
if (U_FAILURE(status)) {
errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\"");
errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\" - " + u_errorName(status));
return;
}
UnicodeString saw2;
@ -2230,7 +2231,7 @@ void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n,
}
}
} else {
errln(UnicodeString("FAIL ") + toString(n) + " x " +
dataerrln(UnicodeString("FAIL ") + toString(n) + " x " +
escape(pat) + " = \"" +
escape(saw) + "\", expected \"" + exp + "\"");
}
@ -2239,8 +2240,8 @@ void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n,
void NumberFormatTest::expect(NumberFormat* fmt, const Formattable& n,
const UnicodeString& exp,
UErrorCode status) {
if (U_FAILURE(status)) {
errln("FAIL: NumberFormat constructor");
if (fmt == NULL || U_FAILURE(status)) {
dataerrln("FAIL: NumberFormat constructor");
} else {
expect(*fmt, n, exp);
}
@ -6188,7 +6189,7 @@ void NumberFormatTest::TestExponentParse() {
)
{
errln("ERROR: parse failed - expected 123.0, 3 - returned %d, %i",
result.getDouble(), parsePos);
result.getDouble(), parsePos.getIndex());
}
}

View file

@ -1241,7 +1241,7 @@ void NumberFormatRegressionTest::Test4074454(void)
FieldPosition pos(FieldPosition::DONT_CARE);
tempString = newFmt->format(3456.78, tempString, pos);
if (tempString != UnicodeString("3,456.78 p'ieces"))
errln("Failed! 3456.78 p'ieces expected, but got : " + tempString);
dataerrln("Failed! 3456.78 p'ieces expected, but got : " + tempString);
/*} catch (Exception foo) {
errln("An exception was thrown for any inconsistent negative pattern.");
}*/

View file

@ -1109,7 +1109,7 @@ BasicNormalizerTest::TestCompare() {
const Normalizer2Impl *nfcImpl=Normalizer2Factory::getNFCImpl(errorCode);
if(U_FAILURE(errorCode) || !nfcImpl->ensureCanonIterData(errorCode)) {
errln("Normalizer2Factory::getNFCImpl().ensureCanonIterData() failed: %s",
dataerrln("Normalizer2Factory::getNFCImpl().ensureCanonIterData() failed: %s",
u_errorName(errorCode));
return;
}
@ -1776,7 +1776,7 @@ BasicNormalizerTest::TestCustomComp() {
const Normalizer2 *customNorm2=
Normalizer2::getInstance(loadTestData(errorCode), "testnorm",
UNORM2_COMPOSE, errorCode);
if(errorCode.logIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
if(errorCode.logDataIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
return;
}
for(int32_t i=0; i<LENGTHOF(pairs); ++i) {
@ -1808,7 +1808,7 @@ BasicNormalizerTest::TestCustomFCC() {
const Normalizer2 *customNorm2=
Normalizer2::getInstance(loadTestData(errorCode), "testnorm",
UNORM2_COMPOSE_CONTIGUOUS, errorCode);
if(errorCode.logIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
if(errorCode.logDataIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
return;
}
for(int32_t i=0; i<LENGTHOF(pairs); ++i) {

View file

@ -172,6 +172,9 @@ UObject *UObjectTest::testClass(UObject *obj,
UObject *UObjectTest::testClassNoClassID(UObject *obj, const char *className, const char *factory)
{
if (!obj) {
return NULL;
}
UnicodeString what = UnicodeString(className) + " * x= " + UnicodeString(factory?factory:" ABSTRACT ") + "; ";
UClassID dynamicID = obj->getDynamicClassID();
@ -562,7 +565,7 @@ void UObjectTest::TestCompilerRTTI() {
UErrorCode errorCode = U_ZERO_ERROR;
NumberFormat *nf = NumberFormat::createInstance("de", errorCode);
if (U_FAILURE(errorCode)) {
errln("NumberFormat::createInstance(de) failed - %s", u_errorName(errorCode));
dataerrln("NumberFormat::createInstance(de) failed - %s", u_errorName(errorCode));
return;
}
if (dynamic_cast<DecimalFormat *>(nf) == NULL || dynamic_cast<ChoiceFormat *>(nf) != NULL) {