diff --git a/icu4c/source/common/unormcmp.cpp b/icu4c/source/common/unormcmp.cpp index 0732b55a7d1..35b96b89f04 100644 --- a/icu4c/source/common/unormcmp.cpp +++ b/icu4c/source/common/unormcmp.cpp @@ -580,6 +580,9 @@ unorm_compare(const UChar *s1, int32_t length1, } else { n2=Normalizer2Factory::getFCDInstance(*pErrorCode); } + if (U_FAILURE(*pErrorCode)) { + return 0; + } // check if s1 and/or s2 fulfill the FCD conditions const UnicodeSet *uni32; diff --git a/icu4c/source/i18n/regexst.cpp b/icu4c/source/i18n/regexst.cpp index c2a8933a8cc..b8ad297d663 100644 --- a/icu4c/source/i18n/regexst.cpp +++ b/icu4c/source/i18n/regexst.cpp @@ -146,7 +146,8 @@ RegexStaticSets *RegexStaticSets::gStaticSets = NULL; RegexStaticSets::RegexStaticSets(UErrorCode *status) : fUnescapeCharSet(UnicodeString(TRUE, gUnescapeCharPattern, -1), *status), -fRuleDigitsAlias(NULL) +fRuleDigitsAlias(NULL), +fEmptyText(NULL) { // First zero out everything int i; diff --git a/icu4c/source/i18n/rematch.cpp b/icu4c/source/i18n/rematch.cpp index eb9ec583d02..06c70aaad69 100644 --- a/icu4c/source/i18n/rematch.cpp +++ b/icu4c/source/i18n/rematch.cpp @@ -109,6 +109,10 @@ RegexMatcher::RegexMatcher(UText *regexp, UText *input, } UParseError pe; fPatternOwned = RegexPattern::compile(regexp, flags, pe, status); + if (U_FAILURE(status)) { + return; + } + fPattern = fPatternOwned; init2(input, status); } @@ -122,6 +126,9 @@ RegexMatcher::RegexMatcher(const UnicodeString ®exp, } UParseError pe; fPatternOwned = RegexPattern::compile(regexp, flags, pe, status); + if (U_FAILURE(status)) { + return; + } fPattern = fPatternOwned; init2(RegexStaticSets::gStaticSets->fEmptyText, status); } @@ -134,6 +141,10 @@ RegexMatcher::RegexMatcher(UText *regexp, } UParseError pe; fPatternOwned = RegexPattern::compile(regexp, flags, pe, status); + if (U_FAILURE(status)) { + return; + } + fPattern = fPatternOwned; init2(RegexStaticSets::gStaticSets->fEmptyText, status); } diff --git a/icu4c/source/test/cintltst/ccaltst.c b/icu4c/source/test/cintltst/ccaltst.c index 41ae1d29433..d6548a1904f 100644 --- a/icu4c/source/test/cintltst/ccaltst.c +++ b/icu4c/source/test/cintltst/ccaltst.c @@ -240,27 +240,27 @@ static void TestCalendar() u_uastrcpy(tzID, "PST"); caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status)); + log_data_err("FAIL: error in ucal_open caldef : %s\n - (Are you missing data?)", u_errorName(status)); } caldef2=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status)); + log_data_err("FAIL: error in ucal_open caldef : %s - (Are you missing data?)\n", u_errorName(status)); } u_strcpy(tzID, fgGMTID); calfr=ucal_open(tzID, u_strlen(tzID), "fr_FR", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("FAIL: error in ucal_open calfr : %s\n", u_errorName(status)); + log_data_err("FAIL: error in ucal_open calfr : %s - (Are you missing data?)\n", u_errorName(status)); } calit=ucal_open(tzID, u_strlen(tzID), "it_IT", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)) { - log_err("FAIL: error in ucal_open calit : %s\n", u_errorName(status)); + log_data_err("FAIL: error in ucal_open calit : %s - (Are you missing data?)\n", u_errorName(status)); } /*Testing the clone() function*/ calfrclone = ucal_clone(calfr, &status); if(U_FAILURE(status)){ - log_err("FAIL: error in ucal_clone calfr : %s\n", u_errorName(status)); + log_data_err("FAIL: error in ucal_clone calfr : %s - (Are you missing data?)\n", u_errorName(status)); } /*Testing udat_getAvailable() and udat_countAvailable()*/ @@ -651,7 +651,7 @@ static void TestFieldGetSet() /*open the calendar used */ cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if (U_FAILURE(status)) { - log_err("ucal_open failed: %s\n", u_errorName(status)); + log_data_err("ucal_open failed: %s - (Are you missing data?)\n", u_errorName(status)); return; } datdef=udat_open(UDAT_SHORT,UDAT_SHORT ,NULL,fgGMTID,-1,NULL, 0, &status); @@ -803,7 +803,7 @@ static void TestAddRollExtensive() /*open the calendar used */ cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);; if (U_FAILURE(status)) { - log_err("ucal_open() failed : %s\n", u_errorName(status)); + log_data_err("ucal_open() failed : %s - (Are you missing data?)\n", u_errorName(status)); return; } @@ -963,7 +963,7 @@ static void TestGetLimits() /*open the calendar used */ cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);; if (U_FAILURE(status)) { - log_err("ucal_open() for gregorian calendar failed in TestGetLimits: %s\n", u_errorName(status)); + log_data_err("ucal_open() for gregorian calendar failed in TestGetLimits: %s - (Are you missing data?)\n", u_errorName(status)); return; } @@ -1061,7 +1061,7 @@ static void TestDOWProgression() /*open the calendar used */ cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);; if (U_FAILURE(status)) { - log_err("ucal_open failed: %s\n", u_errorName(status)); + log_data_err("ucal_open failed: %s - (Are you missing data?)\n", u_errorName(status)); return; } @@ -1134,7 +1134,7 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn u_strcpy(tzID, fgGMTID); gmtcal=ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);; if (U_FAILURE(status)) { - log_err("ucal_open failed: %s\n", u_errorName(status)); + log_data_err("ucal_open failed: %s - (Are you missing data?)\n", u_errorName(status)); return; } u_uastrcpy(tzID, "PST"); @@ -1359,7 +1359,7 @@ void TestGregorianChange() { errorCode = U_ZERO_ERROR; cal = ucal_open(utc, -1, "", UCAL_GREGORIAN, &errorCode); if(U_FAILURE(errorCode)) { - log_err("ucal_open(UTC) failed: %s\n", u_errorName(errorCode)); + log_data_err("ucal_open(UTC) failed: %s - (Are you missing data?)\n", u_errorName(errorCode)); return; } ucal_setGregorianChange(cal, -365 * (dayMillis * (UDate)1), &errorCode); @@ -1620,7 +1620,7 @@ static void TestWeekend() { } ucal_close(cal); } else { - log_err("FAIL: ucal_open for locale %s failed: %s\n", testDatesPtr->locale, u_errorName(status) ); + log_data_err("FAIL: ucal_open for locale %s failed: %s - (Are you missing data?)\n", testDatesPtr->locale, u_errorName(status) ); } } if (U_SUCCESS(fmtStatus)) { @@ -1650,7 +1650,7 @@ static void TestWeekend() { } ucal_close(cal); } else { - log_err("FAIL: ucal_open for locale %s failed: %s\n", testDaysPtr->locale, u_errorName(status) ); + log_data_err("FAIL: ucal_open for locale %s failed: %s - (Are you missing data?)\n", testDaysPtr->locale, u_errorName(status) ); } } } diff --git a/icu4c/source/test/cintltst/cdattst.c b/icu4c/source/test/cintltst/cdattst.c index 6efe1d11824..697f34d74bb 100644 --- a/icu4c/source/test/cintltst/cdattst.c +++ b/icu4c/source/test/cintltst/cdattst.c @@ -411,7 +411,7 @@ static void TestRelativeDateFormat() ucal_close(ucal); } if ( U_FAILURE(status) || today == 0.0 ) { - log_err("Generate UDate for a specified time today fails, error %s\n", myErrorName(status) ); + log_data_err("Generate UDate for a specified time today fails, error %s - (Are you missing data?)\n", myErrorName(status) ); return; } for (stylePtr = dateStylesList, monthPtnPtr = monthPatnsList; *stylePtr != UDAT_NONE; ++stylePtr, ++monthPtnPtr) { diff --git a/icu4c/source/test/cintltst/cdtdptst.c b/icu4c/source/test/cintltst/cdtdptst.c index cd3515c0682..48230f07ed7 100644 --- a/icu4c/source/test/cintltst/cdtdptst.c +++ b/icu4c/source/test/cintltst/cdtdptst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************** @@ -59,7 +59,7 @@ void TestTwoDigitYearDSTParse() u_uastrcpy(pattern, "EEE MMM dd HH:mm:ss.SSS zzz yyyy G"); fullFmt= udat_open(UDAT_IGNORE, UDAT_IGNORE,"en_US",NULL,0,pattern, u_strlen(pattern),&status); if(U_FAILURE(status)) { - log_err_status(status, "FAIL: Error in creating a date format using udat_openPattern %s\n", + log_data_err("FAIL: Error in creating a date format using udat_openPattern %s - (Are you missing data?)\n", myErrorName(status) ); } else { @@ -202,7 +202,7 @@ void TestRunTogetherPattern985() u_uastrcpy(pattern, "yyyyMMddHHmmssSSS"); format = udat_open(UDAT_IGNORE, UDAT_IGNORE, NULL, NULL, 0,pattern, u_strlen(pattern), &status); if(U_FAILURE(status)){ - log_err_status(status, "FAIL: Error in date format construction with pattern: %s\n", myErrorName(status)); + log_data_err("FAIL: Error in date format construction with pattern: %s - (Are you missing data?)\n", myErrorName(status)); return; } date1 = ucal_getNow(); @@ -318,7 +318,7 @@ void TestQuotePattern161() /* format= udat_openPattern(pattern, u_strlen(pattern), NULL, &status); */ format= udat_open(UDAT_IGNORE, UDAT_IGNORE,"en_US", NULL, 0,pattern, u_strlen(pattern), &status); if(U_FAILURE(status)){ - log_err_status(status, "error in udat_open: %s\n", myErrorName(status)); + log_data_err("error in udat_open: %s - (Are you missing data?)\n", myErrorName(status)); return; } tzID=(UChar*)malloc(sizeof(UChar) * 4); diff --git a/icu4c/source/test/cintltst/cdtrgtst.c b/icu4c/source/test/cintltst/cdtrgtst.c index d82548915d3..cc71968733a 100644 --- a/icu4c/source/test/cintltst/cdtrgtst.c +++ b/icu4c/source/test/cintltst/cdtrgtst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************** @@ -143,7 +143,8 @@ void Test4056591() log_verbose("Testing s[get] 2 digit year start regressively\n"); cal=ucal_open(NULL, 0, "en_US", UCAL_GREGORIAN, &status); if(U_FAILURE(status)){ - log_err("error in ucal_open caldef : %s\n", myErrorName(status)); + log_data_err("error in ucal_open caldef : %s - (Are you missing data?)\n", myErrorName(status)); + return; } ucal_setDateTime(cal, 1809, UCAL_DECEMBER, 25, 17, 40, 30, &status); d[0]=ucal_getMillis(cal, &status); @@ -213,7 +214,7 @@ void Test4059917() def = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,tzID,-1,pattern, u_strlen(pattern),&status); if(U_FAILURE(status)) { - log_err_status(status, "FAIL: error in creating the dateformat using openPattern: %s\n", myErrorName(status)); + log_data_err("FAIL: error in creating the dateformat using openPattern: %s - (Are you missing data?)\n", myErrorName(status)); return; } myDate=(UChar*)malloc(sizeof(UChar) * 11); @@ -292,7 +293,7 @@ void Test4060212() fmt = udat_open(UDAT_FULL,UDAT_LONG ,NULL, tzID, -1, NULL, 0, &status); if(U_FAILURE(status)) { - log_err_status(status, "FAIL: error in creating the dateformat using default date and time style: %s\n", + log_data_err("FAIL: error in creating the dateformat using default date and time style: %s - (Are you missing data?)\n", myErrorName(status) ); return; } @@ -330,7 +331,7 @@ void Test4061287() log_verbose("Testing parsing by changing the attribute lenient\n"); df = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,NULL,0,pattern, u_strlen(pattern),&status); if(U_FAILURE(status)){ - log_err_status(status, "ERROR: failure in open pattern of test4061287: %s\n", myErrorName(status)); + log_data_err("ERROR: failure in open pattern of test4061287: %s - (Are you missing data?)\n", myErrorName(status)); return; } diff --git a/icu4c/source/test/cintltst/cmsgtst.c b/icu4c/source/test/cintltst/cmsgtst.c index 1a8a6ff6769..a4592bc4cba 100644 --- a/icu4c/source/test/cintltst/cmsgtst.c +++ b/icu4c/source/test/cintltst/cmsgtst.c @@ -381,7 +381,7 @@ static void TestNewFormatAndParseAPI(void) u_uastrcpy(tzID, "PST"); cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("error in ucal_open caldef : %s\n", myErrorName(status) ); + log_data_err("error in ucal_open caldef : %s - (Are you missing data?)\n", myErrorName(status) ); return; } ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status); @@ -483,12 +483,12 @@ static void TestSampleFormatAndParseWithError(void) u_uastrcpy(tzID, "PST"); cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("error in ucal_open caldef : %s\n", myErrorName(status) ); + log_data_err("error in ucal_open caldef : %s - (Are you missing data?)\n", myErrorName(status) ); } ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status); d1=ucal_getMillis(cal, &status); if(U_FAILURE(status)){ - log_err("Error: failure in get millis: %s\n", myErrorName(status) ); + log_data_err("Error: failure in get millis: %s - (Are you missing data?)\n", myErrorName(status) ); } log_verbose("\nTesting with pattern test#4"); @@ -576,12 +576,12 @@ static void TestSampleFormatAndParse(void) u_uastrcpy(tzID, "PST"); cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); if(U_FAILURE(status)){ - log_err("error in ucal_open caldef : %s\n", myErrorName(status) ); + log_data_err("error in ucal_open caldef : %s - (Are you missing data?)\n", myErrorName(status) ); } ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status); d1=ucal_getMillis(cal, &status); if(U_FAILURE(status)){ - log_err("Error: failure in get millis: %s\n", myErrorName(status) ); + log_data_err("Error: failure in get millis: %s - (Are you missing data?)\n", myErrorName(status) ); } log_verbose("\nTesting with pattern test#4"); diff --git a/icu4c/source/test/cintltst/cnormtst.c b/icu4c/source/test/cintltst/cnormtst.c index cbd391822d9..11f731e77da 100644 --- a/icu4c/source/test/cintltst/cnormtst.c +++ b/icu4c/source/test/cintltst/cnormtst.c @@ -159,7 +159,7 @@ void TestDecomp() unorm_normalize(source, u_strlen(source), UNORM_NFD, 0, result, resLen, &status); } if(U_FAILURE(status)){ - log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) ); + log_data_err("ERROR in unorm_normalize at %s: %s - (Are you missing data?)\n", austrdup(source), myErrorName(status) ); } else { assertEqual(result, canonTests[x][1], x); } @@ -188,7 +188,7 @@ void TestCompatDecomp() unorm_normalize(source, u_strlen(source), UNORM_NFKD, 0, result, resLen, &status); } if(U_FAILURE(status)){ - log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) ); + log_data_err("ERROR in unorm_normalize at %s: %s - (Are you missing data?)\n", austrdup(source), myErrorName(status) ); } else { assertEqual(result, compatTests[x][1], x); } @@ -217,7 +217,7 @@ void TestCanonDecompCompose() unorm_normalize(source, u_strlen(source), UNORM_NFC, 0, result, resLen, &status); } if(U_FAILURE(status)){ - log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source),myErrorName(status) ); + log_data_err("ERROR in unorm_normalize at %s: %s - (Are you missing data?)\n", austrdup(source),myErrorName(status) ); } else { assertEqual(result, canonTests[x][2], x); } @@ -246,7 +246,7 @@ void TestCompatDecompCompose() unorm_normalize(source, u_strlen(source), UNORM_NFKC, 0, result, resLen, &status); } if(U_FAILURE(status)){ - log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) ); + log_data_err("ERROR in unorm_normalize at %s: %s - (Are you missing data?)\n", austrdup(source), myErrorName(status) ); } else { assertEqual(result, compatTests[x][2], x); } @@ -297,7 +297,7 @@ static void TestNull_check(UChar *src, int32_t srcLen, len = unorm_normalize(src, srcLen, mode, 0, result, 50, &status); if(U_FAILURE(status)) { - log_err("unorm_normalize(%s) with 0x0000 failed: %s\n", name, u_errorName(status)); + log_data_err("unorm_normalize(%s) with 0x0000 failed: %s - (Are you missing data?)\n", name, u_errorName(status)); } else if (len != expLen) { log_err("unorm_normalize(%s) with 0x0000 failed: Expected len %d, got %d\n", name, expLen, len); } @@ -423,7 +423,7 @@ static void TestQuickCheckResultYES() { if (unorm_quickCheck(&cp, 1, UNORM_NFD, &error) != UNORM_YES) { - log_err("ERROR in NFD quick check at U+%04x\n", cp); + log_data_err("ERROR in NFD quick check at U+%04x - (Are you missing data?)\n", cp); return; } if (unorm_quickCheck(&cp, 1, UNORM_NFC, &error) != @@ -494,7 +494,7 @@ static void TestQuickCheckResultMAYBE() if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error) != UNORM_MAYBE) { - log_err("ERROR in NFC quick check at U+%04x\n", CPNFC[count]); + log_data_err("ERROR in NFC quick check at U+%04x - (Are you missing data?)\n", CPNFC[count]); return; } if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) != @@ -520,7 +520,7 @@ static void TestQuickCheckStringResult() if (unorm_quickCheck(d, u_strlen(d), UNORM_NFD, &error) != UNORM_YES) { - log_err("ERROR in NFD quick check for string at count %d\n", count); + log_data_err("ERROR in NFD quick check for string at count %d - (Are you missing data?)\n", count); return; } @@ -592,7 +592,7 @@ static void TestIsNormalized(void) { /* normal case with length>=0 (length -1 used for special cases below) */ errorCode=U_ZERO_ERROR; if(!unorm_isNormalized(notNFC[0]+2, 1, UNORM_NFC, &errorCode) || U_FAILURE(errorCode)) { - log_err("error: !isNormalized(, NFC) (%s)\n", u_errorName(errorCode)); + log_data_err("error: !isNormalized(, NFC) (%s) - (Are you missing data?)\n", u_errorName(errorCode)); } /* incoming U_FAILURE */ @@ -606,31 +606,31 @@ static void TestIsNormalized(void) { errorCode=U_ZERO_ERROR; (void)unorm_isNormalized(NULL, 1, UNORM_NFC, &errorCode); if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { - log_err("error: isNormalized(NULL) did not set U_ILLEGAL_ARGUMENT_ERROR but %s\n", u_errorName(errorCode)); + log_data_err("error: isNormalized(NULL) did not set U_ILLEGAL_ARGUMENT_ERROR but %s - (Are you missing data?)\n", u_errorName(errorCode)); } /* bad length */ errorCode=U_ZERO_ERROR; (void)unorm_isNormalized(notNFC[0]+2, -2, UNORM_NFC, &errorCode); if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { - log_err("error: isNormalized([-2]) did not set U_ILLEGAL_ARGUMENT_ERROR but %s\n", u_errorName(errorCode)); + log_data_err("error: isNormalized([-2]) did not set U_ILLEGAL_ARGUMENT_ERROR but %s - (Are you missing data?)\n", u_errorName(errorCode)); } /* specific cases */ for(i=0; igetIndex(iter, UITER_CURRENT); if(U_FAILURE(errorCode)) { - log_err("error unorm iteration (next/previous %d %s)[%d]: %s\n", + log_data_err("error unorm iteration (next/previous %d %s)[%d]: %s - (Are you missing data?)\n", forward, _modeString[mode], i, u_errorName(errorCode)); return; } @@ -1271,7 +1271,7 @@ TestNextPrevious() { UNORM_NFD, 0, TRUE, NULL, &errorCode); if(U_FAILURE(errorCode) || length!=2 || buffer[0]!=nfd[2] || buffer[1]!=nfd[3]) { - log_err("error unorm_next(without needed) %s\n", u_errorName(errorCode)); + log_data_err("error unorm_next(without needed) %s - (Are you missing data?)\n", u_errorName(errorCode)); return; } @@ -1365,7 +1365,7 @@ TestFCNFKCClosure(void) { errorCode=U_ZERO_ERROR; length=u_getFC_NFKC_Closure(tests[i].c, buffer, LENGTHOF(buffer), &errorCode); if(U_FAILURE(errorCode) || length!=u_strlen(buffer) || 0!=u_strcmp(tests[i].s, buffer)) { - log_err("u_getFC_NFKC_Closure(U+%04lx) is wrong (%s)\n", tests[i].c, u_errorName(errorCode)); + log_data_err("u_getFC_NFKC_Closure(U+%04lx) is wrong (%s) - (Are you missing data?)\n", tests[i].c, u_errorName(errorCode)); } } @@ -1414,25 +1414,25 @@ TestQuickCheckPerCP() { qc1=u_getIntPropertyValue(c, UCHAR_NFC_QUICK_CHECK); qc2=unorm_quickCheck(s, length, UNORM_NFC, &errorCode); if(qc1!=qc2) { - log_err("u_getIntPropertyValue(NFC)=%d != %d=unorm_quickCheck(NFC) for U+%04x\n", qc1, qc2, c); + log_data_err("u_getIntPropertyValue(NFC)=%d != %d=unorm_quickCheck(NFC) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); } qc1=u_getIntPropertyValue(c, UCHAR_NFD_QUICK_CHECK); qc2=unorm_quickCheck(s, length, UNORM_NFD, &errorCode); if(qc1!=qc2) { - log_err("u_getIntPropertyValue(NFD)=%d != %d=unorm_quickCheck(NFD) for U+%04x\n", qc1, qc2, c); + log_data_err("u_getIntPropertyValue(NFD)=%d != %d=unorm_quickCheck(NFD) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); } qc1=u_getIntPropertyValue(c, UCHAR_NFKC_QUICK_CHECK); qc2=unorm_quickCheck(s, length, UNORM_NFKC, &errorCode); if(qc1!=qc2) { - log_err("u_getIntPropertyValue(NFKC)=%d != %d=unorm_quickCheck(NFKC) for U+%04x\n", qc1, qc2, c); + log_data_err("u_getIntPropertyValue(NFKC)=%d != %d=unorm_quickCheck(NFKC) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); } qc1=u_getIntPropertyValue(c, UCHAR_NFKD_QUICK_CHECK); qc2=unorm_quickCheck(s, length, UNORM_NFKD, &errorCode); if(qc1!=qc2) { - log_err("u_getIntPropertyValue(NFKD)=%d != %d=unorm_quickCheck(NFKD) for U+%04x\n", qc1, qc2, c); + log_data_err("u_getIntPropertyValue(NFKD)=%d != %d=unorm_quickCheck(NFKD) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); } length=unorm_normalize(s, length, UNORM_NFD, 0, nfd, LENGTHOF(nfd), &errorCode); @@ -1496,7 +1496,7 @@ TestComposition(void) { length!=u_strlen(cases[i].expect) || 0!=u_memcmp(output, cases[i].expect, length) ) { - log_err("unexpected result for case %d\n", i); + log_data_err("unexpected result for case %d - (Are you missing data?)\n", i); } } } diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 643d8c51dd2..0ac568ed5d3 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -2638,14 +2638,14 @@ TestAdditionalProperties() { if(whichlocale); + log_data_err("ERROR udatpg_open failed for locale %s : %s - (Are you missing data?)\n", testDataPtr->locale, myErrorName(status)); } } } diff --git a/icu4c/source/test/cintltst/utmstest.c b/icu4c/source/test/cintltst/utmstest.c index 069a8039479..bc9f614fb07 100644 --- a/icu4c/source/test/cintltst/utmstest.c +++ b/icu4c/source/test/cintltst/utmstest.c @@ -1,6 +1,6 @@ /* **************************************************************************** - * Copyright (c) 1997-2007, International Business Machines Corporation and * + * Copyright (c) 1997-2010, International Business Machines Corporation and * * others. All Rights Reserved. * **************************************************************************** */ @@ -455,7 +455,7 @@ TestDotNet() { cal = ucal_open(utc, -1, "", UCAL_GREGORIAN, &errorCode); ucal_setGregorianChange(cal, -1000000 * (dayMillis * (UDate)1), &errorCode); if(U_FAILURE(errorCode)) { - log_err("ucal_open(UTC/proleptic Gregorian) failed: %s\n", u_errorName(errorCode)); + log_data_err("ucal_open(UTC/proleptic Gregorian) failed: %s - (Are you missing data?)\n", u_errorName(errorCode)); ucal_close(cal); return; } diff --git a/icu4c/source/test/intltest/astrotst.cpp b/icu4c/source/test/intltest/astrotst.cpp index 630019be579..6dc72f5dca0 100644 --- a/icu4c/source/test/intltest/astrotst.cpp +++ b/icu4c/source/test/intltest/astrotst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1996-2009, International Business Machines Corporation and + * Copyright (c) 1996-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -43,7 +43,7 @@ void AstroTest::runIndexedTest( int32_t index, UBool exec, const char* &name, ch #undef CASE -#define ASSERT_OK(x) if(U_FAILURE(x)) { errln("%s:%d: %s\n", __FILE__, __LINE__, u_errorName(x)); return; } +#define ASSERT_OK(x) if(U_FAILURE(x)) { dataerrln("%s:%d: %s\n", __FILE__, __LINE__, u_errorName(x)); return; } void AstroTest::initAstro(UErrorCode &status) { diff --git a/icu4c/source/test/intltest/calcasts.cpp b/icu4c/source/test/intltest/calcasts.cpp index 83cb6b123e7..5db6503717a 100644 --- a/icu4c/source/test/intltest/calcasts.cpp +++ b/icu4c/source/test/intltest/calcasts.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2003-2008, International Business Machines Corporation + * Copyright (c) 2003-2010, International Business Machines Corporation * and others. All Rights Reserved. ******************************************************************** * Calendar Case Test is a type of CalendarTest which compares the @@ -164,6 +164,7 @@ void CalendarCaseTest::IslamicCivil() UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("ar@calendar=islamic-civil", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(TRUE); doTestCases(tests, c); @@ -295,6 +296,7 @@ void CalendarCaseTest::Hebrew() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("he_HE@calendar=hebrew", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(TRUE); doTestCases(tests, c); @@ -380,6 +382,7 @@ void CalendarCaseTest::Indian() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("hi_IN@calendar=indian", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(TRUE); doTestCases(tests, c); @@ -423,6 +426,8 @@ void CalendarCaseTest::Coptic() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("cop_EG@calendar=coptic", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; + c->setLenient(TRUE); doTestCases(tests, c); @@ -470,6 +475,7 @@ void CalendarCaseTest::Ethiopic() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("am_ET@calendar=ethiopic", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(TRUE); doTestCases(tests, c); @@ -485,6 +491,7 @@ void CalendarCaseTest::Ethiopic() { } } c = Calendar::createInstance("am_ET@calendar=ethiopic-amete-alem", status); + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(TRUE); doTestCases(tests, c); diff --git a/icu4c/source/test/intltest/callimts.cpp b/icu4c/source/test/intltest/callimts.cpp index 5c3b0b33671..ceb6e928485 100644 --- a/icu4c/source/test/intltest/callimts.cpp +++ b/icu4c/source/test/intltest/callimts.cpp @@ -1,6 +1,6 @@ /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -97,7 +97,7 @@ CalendarLimitTest::TestCalendarExtremeLimit() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); - if (failure(status, "Calendar::createInstance")) return; + if (failure(status, "Calendar::createInstance", TRUE)) return; cal->adoptTimeZone(TimeZone::createTimeZone("GMT")); DateFormat *fmt = DateFormat::createDateTimeInstance(); if(!fmt || !cal) { @@ -172,7 +172,7 @@ CalendarLimitTest::TestLimits(void) { uprv_strcpy(buf, "root@calendar="); strcat(buf, TestCases[i].type); Calendar *cal = Calendar::createInstance(buf, status); - if (failure(status, "Calendar::createInstance")) { + if (failure(status, "Calendar::createInstance", TRUE)) { continue; } if (uprv_strcmp(cal->getType(), TestCases[i].type) != 0) { diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index 8a3fcf20c9d..9b04b2f3647 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************/ @@ -129,7 +129,7 @@ CalendarRegressionTest::test4100311() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -152,7 +152,7 @@ CalendarRegressionTest::test4074758() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -175,7 +175,7 @@ CalendarRegressionTest::test4028518() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal1 = new GregorianCalendar(status) ; if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal1; return; } @@ -220,7 +220,11 @@ CalendarRegressionTest::test4031502() TimeZone* tz =TimeZone::createTimeZone("Asia/Riyadh87"); failure(status, "new TimeZone"); GregorianCalendar *cl = new GregorianCalendar(tz, status); - failure(status, "new GregorianCalendar"); + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + delete tz; + return; + } cl->clear(); cl->set(1900, 15, 5, 5, 8, 13); cl->get(UCAL_HOUR, status); @@ -264,7 +268,7 @@ void CalendarRegressionTest::test4035301() c->before(*c,status) || *c != *c || *c != *d) - errln("Fail"); + dataerrln("Fail"); delete c; delete d; } @@ -282,7 +286,10 @@ void CalendarRegressionTest::test4040996() pdt->setStartRule(UCAL_APRIL, 1, UCAL_SUNDAY, 2 * 60 * 60 * 1000, status); pdt->setEndRule(UCAL_OCTOBER, -1, UCAL_SUNDAY, 2 * 60 * 60 * 1000, status); Calendar *calendar = new GregorianCalendar(pdt, status); - + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + return; + } calendar->set(UCAL_MONTH,3); calendar->set(UCAL_DATE,18); calendar->set(UCAL_SECOND, 30); @@ -320,7 +327,7 @@ void CalendarRegressionTest::test4051765() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -403,7 +410,7 @@ void CalendarRegressionTest::test4059654() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *gc = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete gc; return; } @@ -435,7 +442,7 @@ void CalendarRegressionTest::test4061476() Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone("GMT"), Locale::getUK(),status); if(U_FAILURE(status)) { - errcheckln(status, "Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; delete fmt; return; @@ -465,7 +472,7 @@ void CalendarRegressionTest::test4070502() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = new GregorianCalendar(status); - if(status == U_USING_FALLBACK_WARNING) { + if(status == U_USING_FALLBACK_WARNING || U_FAILURE(status)) { dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; @@ -522,7 +529,7 @@ void CalendarRegressionTest::dowTest(UBool lenient) UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -579,7 +586,7 @@ void CalendarRegressionTest::test4071385() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -600,7 +607,7 @@ void CalendarRegressionTest::test4073929() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *foo1 = new GregorianCalendar(1997, 8, 27,status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete foo1; return; } @@ -656,7 +663,7 @@ void CalendarRegressionTest::test4083167() UDate firstDate = Calendar::getNow(); Calendar *cal = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; return; } @@ -706,7 +713,7 @@ void CalendarRegressionTest::test4086724() date = new SimpleDateFormat(UnicodeString("dd MMM yyy (zzzz) 'is in week' ww"),status); Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errcheckln(status, "Error creating Calendar: %s", u_errorName(status)); + dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; delete newZone; delete date; @@ -745,6 +752,11 @@ delete saveZone; void CalendarRegressionTest::test4092362() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + delete cal1; + return; + } /*cal1.set( Calendar::YEAR, 1997 ); cal1.set( Calendar::MONTH, 10 ); cal1.set( Calendar::DATE, 11 ); @@ -780,6 +792,11 @@ void CalendarRegressionTest::test4095407() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *a = new GregorianCalendar(1997,UCAL_NOVEMBER, 13,status); + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + delete a; + return; + } int32_t dow = a->get(UCAL_DAY_OF_WEEK, status); if (dow != UCAL_THURSDAY) errln("Fail: Want THURSDAY Got " + dow); @@ -798,6 +815,13 @@ void CalendarRegressionTest::test4096231() int32_t sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997; Calendar *cal1 = new GregorianCalendar(*PST,status); + if (U_FAILURE(status)) { + dataerrln("Failure new GregorianCalendar: %s", u_errorName(status)); + delete GMT; + delete PST; + delete cal1; + return; + } cal1->setTime(880698639000.0,status); // Issue 1: Changing the timezone doesn't change the // represented time. The old API, pre 1.2.2a requires @@ -861,6 +885,11 @@ void CalendarRegressionTest::test4096539() for (int32_t x=0;x<12;x++) { GregorianCalendar *gc = new GregorianCalendar(1997,x,y[x], status); + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + delete gc; + return; + } int32_t m1,m2; log(UnicodeString("") + (m1=gc->get(UCAL_MONTH,status)+1)+UnicodeString("/")+ gc->get(UCAL_DATE,status)+"/"+gc->get(UCAL_YEAR,status)+ @@ -886,7 +915,7 @@ void CalendarRegressionTest::test41003112() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar: %s", u_errorName(status)); + dataerrln("Error creating calendar: %s", u_errorName(status)); delete cal; return; } @@ -910,7 +939,7 @@ void CalendarRegressionTest::test4103271() UnicodeString output, testDesc, str, str2; GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { - errcheckln(status, "Error creating calendar: %s", u_errorName(status)); + dataerrln("Error creating calendar: %s", u_errorName(status)); delete testCal; return; } @@ -1188,7 +1217,7 @@ void CalendarRegressionTest::test4108764() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1238,7 +1267,7 @@ void CalendarRegressionTest::test4114578() double ONE_HOUR = 60*60*1000; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1306,7 +1335,7 @@ void CalendarRegressionTest::test4118384() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1364,7 +1393,7 @@ void CalendarRegressionTest::test4125881() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*) Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1394,7 +1423,7 @@ void CalendarRegressionTest::test4125892() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*) Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1425,7 +1454,7 @@ void CalendarRegressionTest::test4141665() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -1454,7 +1483,7 @@ void CalendarRegressionTest::test4142933() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete calendar; return; } @@ -1527,7 +1556,7 @@ void CalendarRegressionTest::test4145983() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete calendar; return; } @@ -1612,7 +1641,7 @@ CalendarRegressionTest::Test4149677() for (int32_t i=0; i < 3; ++i) { GregorianCalendar *calendar = new GregorianCalendar(zones[i], status); if(U_FAILURE(status)) { - errln("Couldnt' create calendar."); + dataerrln("Couldnt' create calendar.: %s", u_errorName(status)); return; } @@ -1664,7 +1693,7 @@ CalendarRegressionTest::Test4162587() GregorianCalendar *cal = new GregorianCalendar(tz, status); if(U_FAILURE(status)) { - errln("Couldn't create calendar"); + dataerrln("Couldn't create calendar.: %s", u_errorName(status)); return; } UDate d0, dPlus, dMinus; @@ -1716,7 +1745,7 @@ CalendarRegressionTest::Test4165343() UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(1996, UCAL_FEBRUARY, 29, status); if(U_FAILURE(status)) { - errln("Couldn't create calendar"); + dataerrln("Couldn't create calendar.: %s", u_errorName(status)); return; } UDate start = calendar->getTime(status); @@ -1771,7 +1800,7 @@ CalendarRegressionTest::Test4166109() GregorianCalendar *calendar = new GregorianCalendar(Locale::getUS(), status); if(U_FAILURE(status)) { - errln("Couldn't create calendar"); + dataerrln("Couldn't create calendar.: %s", u_errorName(status)); return; } calendar->set(1998, UCAL_MARCH, 1); @@ -1815,7 +1844,7 @@ CalendarRegressionTest::Test4167060() DateFormat *format = new SimpleDateFormat(UnicodeString("EEE MMM dd HH:mm:ss zzz yyyy G"), Locale::getUS(), status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat - %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat - %s", u_errorName(status)); return; } @@ -1906,7 +1935,7 @@ void CalendarRegressionTest::Test4197699() { Locale::getUS(), status); fmt.setCalendar(cal); if (U_FAILURE(status)) { - errcheckln(status, "Couldn't initialize test - %s", u_errorName(status)); + dataerrln("Couldn't initialize test - %s", u_errorName(status)); return; } @@ -1968,7 +1997,7 @@ void CalendarRegressionTest::TestJ81() { GregorianCalendar cal(TimeZone::createTimeZone("GMT"), Locale::getUS(), status); SimpleDateFormat fmt("HH:mm 'w'w 'd'D E d MMM yyyy", Locale::getUS(), status); if (U_FAILURE(status)) { - errcheckln(status, "Error: Cannot create calendar or format - %s", u_errorName(status)); + dataerrln("Error: Cannot create calendar or format - %s", u_errorName(status)); return; } fmt.setCalendar(cal); @@ -2184,7 +2213,7 @@ void CalendarRegressionTest::TestJ438(void) { int32_t DATA_length = (int32_t)(sizeof(DATA)/sizeof(DATA[0])); Calendar* pcal = Calendar::createInstance(Locale::getUS(), ec); if(U_FAILURE(ec)) { - errcheckln(ec, "Error creating calendar %s", u_errorName(ec)); + dataerrln("Error creating calendar %s", u_errorName(ec)); delete pcal; return; } @@ -2280,7 +2309,7 @@ void CalendarRegressionTest::TestT5555() Calendar *cal = Calendar::createInstance(ec); if (cal == NULL || U_FAILURE(ec)) { - errln("FAIL: Calendar::createInstance()"); + dataerrln("FAIL: Calendar::createInstance(): %s", u_errorName(ec)); delete cal; return; } @@ -2356,7 +2385,7 @@ void CalendarRegressionTest::TestT6745() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(Locale(testLocalePtr->locale), status); if ( U_FAILURE(status) ) { - errln((UnicodeString)"FAIL: Calendar::createInstance, locale " + testLocalePtr->locale + ", status " + u_errorName(status)); + dataerrln((UnicodeString)"FAIL: Calendar::createInstance, locale " + testLocalePtr->locale + ", status " + u_errorName(status)); continue; } const CoptEthCalTestItem * testItemPtr; @@ -2392,7 +2421,7 @@ void CalendarRegressionTest::TestLeapFieldDifference() { UErrorCode ec = U_ZERO_ERROR; Calendar* cal = Calendar::createInstance(ec); if (cal == NULL || U_FAILURE(ec)) { - errln("FAIL: Calendar::createInstance()"); + dataerrln("FAIL: Calendar::createInstance(): %s", u_errorName(ec)); delete cal; return; } @@ -2465,7 +2494,7 @@ void CalendarRegressionTest::TestMalaysianInstance() { UErrorCode ec = U_ZERO_ERROR; Calendar* cal = Calendar::createInstance(loc, ec); if (U_FAILURE(ec)) { - errln("FAIL: Can't construct calendar for ms_MY"); + dataerrln("FAIL: Can't construct calendar for ms_MY: %s", u_errorName(ec)); } delete cal; } @@ -2479,6 +2508,10 @@ void CalendarRegressionTest::TestWeekShift() { UErrorCode ec = U_ZERO_ERROR; GregorianCalendar cal(TimeZone::createTimeZone("America/Los_Angeles"), Locale("en", "US"), ec); + if (U_FAILURE(ec)) { + dataerrln("Fail GregorianCalendar: %s", u_errorName(ec)); + return; + } cal.setTime(UDate(997257600000.0), ec); // Wed Aug 08 01:00:00 PDT 2001 // In pass one, change the first day of week so that the weeks // shift in August 2001. In pass two, change the minimal days @@ -2605,7 +2638,7 @@ void CalendarRegressionTest::TestTimeZoneTransitionAdd() { } if (U_FAILURE(ec)) { - errcheckln(ec, "FAIL: %s", u_errorName(ec)); + dataerrln("FAIL: %s", u_errorName(ec)); } delete tz; @@ -2643,7 +2676,7 @@ void CalendarRegressionTest::TestDeprecates(void) Calendar *c2 = Calendar::createInstance("ja_JP_TRADITIONAL",status); if(!c1 || !c2 || U_FAILURE(status)) { - errln("Couldn't create calendars for roll of HOUR"); + dataerrln("Couldn't create calendars for roll of HOUR: %s", u_errorName(status)); return; } diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index bcda6c3c910..521e4d8171c 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -284,7 +284,7 @@ CalendarTest::TestGenericAPI() SimpleTimeZone *zone = new SimpleTimeZone(tzoffset, tzid); Calendar *cal = Calendar::createInstance(zone->clone(), status); - if (failure(status, "Calendar::createInstance")) return; + if (failure(status, "Calendar::createInstance", TRUE)) return; if (*zone != cal->getTimeZone()) errln("FAIL: Calendar::getTimeZone failed"); @@ -525,7 +525,7 @@ CalendarTest::TestRog() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar* gc = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; int32_t year = 1997, month = UCAL_APRIL, date = 1; gc->set(year, month, date); gc->set(UCAL_HOUR_OF_DAY, 23); @@ -559,7 +559,7 @@ void CalendarTest::dowTest(UBool lenient) { UErrorCode status = U_ZERO_ERROR; GregorianCalendar* cal = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; logln("cal - Aug 12, 1997\n"); cal->set(1997, UCAL_AUGUST, 12); cal->getTime(status); @@ -591,7 +591,7 @@ CalendarTest::TestClonesUnique908() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance(status); - if (U_FAILURE(status)) { errln("Calendar::createInstance failed"); return; } + if (failure(status, "Calendar::createInstance", TRUE)) return; Calendar *d = (Calendar*) c->clone(); c->set(UCAL_MILLISECOND, 123); d->set(UCAL_MILLISECOND, 456); @@ -616,7 +616,7 @@ CalendarTest::TestGregorianChange768() UErrorCode status = U_ZERO_ERROR; UnicodeString str; GregorianCalendar* c = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; logln(UnicodeString("With cutoff ") + dateToString(c->getGregorianChange(), str)); b = c->isLeapYear(1800); logln(UnicodeString(" isLeapYear(1800) = ") + (b ? "true" : "false")); @@ -642,7 +642,7 @@ CalendarTest::TestDisambiguation765() { UErrorCode status = U_ZERO_ERROR; Calendar *c = Calendar::createInstance("en_US", status); - if (U_FAILURE(status)) { errln("Calendar::createInstance failed"); return; } + if (failure(status, "Calendar::createInstance", TRUE)) return; c->setLenient(FALSE); c->clear(); c->set(UCAL_YEAR, 1997); @@ -792,7 +792,7 @@ CalendarTest::test4064654(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_ UErrorCode status = U_ZERO_ERROR; UnicodeString str; Calendar *gmtcal = Calendar::createInstance(status); - if (U_FAILURE(status)) { errln("Calendar::createInstance failed"); return; } + if (failure(status, "Calendar::createInstance", TRUE)) return; gmtcal->adoptTimeZone(TimeZone::createTimeZone("Africa/Casablanca")); gmtcal->set(yr, mo - 1, dt, hr, mn, sc); gmtcal->set(UCAL_MILLISECOND, 0); @@ -835,11 +835,8 @@ CalendarTest::TestAddSetOrder621() UDate d = date(97, 4, 14, 13, 23, 45); UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); - if (U_FAILURE(status)) { - errln("Calendar::createInstance failed"); - delete cal; - return; - } + if (failure(status, "Calendar::createInstance", TRUE)) return; + cal->setTime(d, status); if (U_FAILURE(status)) { errln("Calendar::setTime failed"); @@ -910,7 +907,7 @@ CalendarTest::TestAdd520() int32_t y = 1997, m = UCAL_FEBRUARY, d = 1; UErrorCode status = U_ZERO_ERROR; GregorianCalendar *temp = new GregorianCalendar(y, m, d, status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; check520(temp, y, m, d); temp->add(UCAL_YEAR, 1, status); if (U_FAILURE(status)) { errln("Calendar::add failed"); return; } @@ -947,7 +944,7 @@ CalendarTest::TestAddRollExtensive() int32_t y = 1997, m = UCAL_FEBRUARY, d = 1, hr = 1, min = 1, sec = 0, ms = 0; UErrorCode status = U_ZERO_ERROR; GregorianCalendar *temp = new GregorianCalendar(y, m, d, status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; temp->set(UCAL_HOUR, hr); temp->set(UCAL_MINUTE, min); @@ -1078,7 +1075,7 @@ CalendarTest::TestFieldSet4781() // try { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *g = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; GregorianCalendar *g2 = new GregorianCalendar(status); if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } g2->set(UCAL_HOUR, 12, status); @@ -1151,7 +1148,7 @@ CalendarTest::TestSecondsZero121() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; cal->setTime(Calendar::getNow(), status); if (U_FAILURE(status)) { errln("Calendar::setTime failed"); return; } cal->set(UCAL_SECOND, 0); @@ -1182,7 +1179,7 @@ CalendarTest::TestAddSetGet0610() UErrorCode status = U_ZERO_ERROR; { Calendar *calendar = new GregorianCalendar(status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; calendar->set(1993, UCAL_JANUARY, 4); logln("1A) " + value(calendar)); calendar->add(UCAL_DATE, 1, status); @@ -1248,7 +1245,7 @@ CalendarTest::TestFields060() int32_t dDate = 22; GregorianCalendar *calendar = 0; calendar = new GregorianCalendar(year, month, dDate, status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; for (int32_t i = 0; i < EXPECTED_FIELDS_length;) { UCalendarDateFields field = (UCalendarDateFields)EXPECTED_FIELDS[i++]; int32_t expected = EXPECTED_FIELDS[i++]; @@ -1285,7 +1282,7 @@ CalendarTest::TestEpochStartFields() UErrorCode status = U_ZERO_ERROR; TimeZone *z = TimeZone::createDefault(); Calendar *c = Calendar::createInstance(status); - if (U_FAILURE(status)) { errln("Calendar::createInstance failed"); return; } + if (failure(status, "Calendar::createInstance", TRUE)) return; UDate d = - z->getRawOffset(); GregorianCalendar *gc = new GregorianCalendar(status); if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } @@ -1340,7 +1337,7 @@ CalendarTest::TestDOWProgression() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = new GregorianCalendar(1972, UCAL_OCTOBER, 26, status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "new GregorianCalendar", TRUE)) return; marchByDelta(cal, 24); delete cal; } @@ -1359,7 +1356,7 @@ CalendarTest::TestDOW_LOCALandYEAR_WOY() UErrorCode status = U_ZERO_ERROR; int32_t times = 20; Calendar *cal=Calendar::createInstance(Locale::getGermany(), status); - if (U_FAILURE(status)) { errln("Couldn't create GregorianCalendar"); return; } + if (failure(status, "Calendar::createInstance", TRUE)) return; SimpleDateFormat *sdf=new SimpleDateFormat(UnicodeString("YYYY'-W'ww-ee"), Locale::getGermany(), status); if (U_FAILURE(status)) { errcheckln(status, "Couldn't create SimpleDateFormat - %s", u_errorName(status)); return; } @@ -1649,7 +1646,7 @@ void CalendarTest::TestWOY(void) { GregorianCalendar cal(status); SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy', WOY' w"), status); - CHECK(status, "Fail: Cannot construct calendar/format"); + if (failure(status, "Cannot construct calendar/format", TRUE)) return; UCalendarDaysOfWeek fdw = (UCalendarDaysOfWeek) 0; @@ -1874,7 +1871,7 @@ void CalendarTest::TestYWOY() UErrorCode status = U_ZERO_ERROR; GregorianCalendar cal(status); - CHECK(status, "Fail: Cannot construct calendar/format"); + if (failure(status, "construct GregorianCalendar", TRUE)) return; cal.setFirstDayOfWeek(UCAL_SUNDAY); cal.setMinimalDaysInFirstWeek(1); @@ -1932,6 +1929,7 @@ void CalendarTest::TestJD() static const int32_t kEpochStartAsJulianDay = 2440588; UErrorCode status = U_ZERO_ERROR; GregorianCalendar cal(status); + if (failure(status, "construct GregorianCalendar", TRUE)) return; cal.setTimeZone(*TimeZone::getGMT()); cal.clear(); jd = cal.get(UCAL_JULIAN_DAY, status); @@ -2058,7 +2056,7 @@ void CalendarTest::Test6703() Locale loc1("en@calendar=fubar"); cal = Calendar::createInstance(loc1, status); - if (failure(status, "Calendar::createInstance")) return; + if (failure(status, "Calendar::createInstance", TRUE)) return; delete cal; status = U_ZERO_ERROR; @@ -2110,7 +2108,6 @@ void CalendarTest::Test1624() { UErrorCode status = U_ZERO_ERROR; Locale loc("he_IL@calendar=hebrew"); HebrewCalendar hc(loc,status); - Calendar* cal = (Calendar *)&hc; for (int32_t year = 5600; year < 5800; year++ ) { @@ -2125,6 +2122,8 @@ void CalendarTest::Test1624() { int32_t monthHC = hc.get(UCAL_MONTH,status); int32_t yearHC = hc.get(UCAL_YEAR,status); + if (failure(status, "HebrewCalendar.get()", TRUE)) continue; + if (dayHC != day) { errln(" ==> day %d incorrect, should be: %d\n",dayHC,day); break; diff --git a/icu4c/source/test/intltest/caltztst.cpp b/icu4c/source/test/intltest/caltztst.cpp index 0c4e23439c5..9b5b4a0d98a 100644 --- a/icu4c/source/test/intltest/caltztst.cpp +++ b/icu4c/source/test/intltest/caltztst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /* @@ -61,7 +61,7 @@ DateFormat* CalendarTimeZoneTest::getDateFormat() { delete theFormat; theFormat = 0; - errcheckln(status, "FAIL: Could not create SimpleDateFormat - %s", u_errorName(status)); + dataerrln("FAIL: Could not create SimpleDateFormat - %s", u_errorName(status)); } } @@ -108,7 +108,7 @@ Calendar* CalendarTimeZoneTest::getCalendar() { delete theCalendar; theCalendar = 0; - errln("FAIL: Calendar::createInstance failed"); + dataerrln("FAIL: Calendar::createInstance failed: %s", u_errorName(status)); } } return theCalendar; @@ -189,7 +189,7 @@ CalendarTimeZoneTest::date(int32_t y, int32_t m, int32_t d, int32_t hr, int32_t releaseCalendar(cal); if (U_FAILURE(status)) { - errln("FAIL: Calendar::getTime failed"); + errln("FAIL: Calendar::getTime failed: %s", u_errorName(status)); return 0.0; } return dt; diff --git a/icu4c/source/test/intltest/canittst.cpp b/icu4c/source/test/intltest/canittst.cpp index ed04269b6d6..a1b9a2ad318 100644 --- a/icu4c/source/test/intltest/canittst.cpp +++ b/icu4c/source/test/intltest/canittst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2006, International Business Machines Corporation and + * Copyright (c) 2002-2010, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************** * @@ -71,6 +71,10 @@ CanonicalIteratorTest::~CanonicalIteratorTest() void CanonicalIteratorTest::TestExhaustive() { UErrorCode status = U_ZERO_ERROR; CanonicalIterator it("", status); + if (U_FAILURE(status)) { + dataerrln("Error creating CanonicalIterator: %s", u_errorName(status)); + return; + } UChar32 i = 0; UnicodeString s; // Test static and dynamic class IDs @@ -163,7 +167,7 @@ void CanonicalIteratorTest::TestBasic() { } } else { - errln("Couldn't instantiate canonical iterator. Error: %s", u_errorName(status)); + dataerrln("Couldn't instantiate canonical iterator. Error: %s", u_errorName(status)); } delete set; } @@ -303,6 +307,10 @@ void CanonicalIteratorTest::TestAPI() { logln("Testing CanonicalIterator::getSource"); logln("Instantiating canonical iterator with string "+start); CanonicalIterator can(start, status); + if (U_FAILURE(status)) { + dataerrln("Error creating CanonicalIterator: %s", u_errorName(status)); + return; + } UnicodeString source = can.getSource(); logln("CanonicalIterator::getSource returned "+source); if(start != source) { diff --git a/icu4c/source/test/intltest/dadrcal.cpp b/icu4c/source/test/intltest/dadrcal.cpp index e096d929320..ae7768fc7d9 100644 --- a/icu4c/source/test/intltest/dadrcal.cpp +++ b/icu4c/source/test/intltest/dadrcal.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -88,7 +88,7 @@ void DataDrivenCalendarTest::testOps(TestData *testData, SimpleDateFormat fmt(UnicodeString("EEE MMM dd yyyy / YYYY'-W'ww-ee"), status); if (U_FAILURE(status)) { - errcheckln(status, "FAIL: Couldn't create SimpleDateFormat: %s", + dataerrln("FAIL: Couldn't create SimpleDateFormat: %s", u_errorName(status)); return; } @@ -374,7 +374,7 @@ void DataDrivenCalendarTest::testConvert(TestData *testData, testSetting.extract(0, testSetting.length(), toCalLoc, (const char*)0); toCalendar = Calendar::createInstance(toCalLoc, status); if (U_FAILURE(status)) { - errln("Unable to instantiate ToCalendar for "+testSetting); + dataerrln(UnicodeString("Unable to instantiate ToCalendar for ")+testSetting); return; } } diff --git a/icu4c/source/test/intltest/dadrfmt.cpp b/icu4c/source/test/intltest/dadrfmt.cpp index 355d1e95967..87b20c26387 100644 --- a/icu4c/source/test/intltest/dadrfmt.cpp +++ b/icu4c/source/test/intltest/dadrfmt.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -99,7 +99,7 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData, SimpleDateFormat basicFmt(UnicodeString("EEE MMM dd yyyy / YYYY'-W'ww-ee"), status); if (U_FAILURE(status)) { - errcheckln(status, "FAIL: Couldn't create basic SimpleDateFormat: %s\n", + dataerrln("FAIL: Couldn't create basic SimpleDateFormat: %s", u_errorName(status)); return; } diff --git a/icu4c/source/test/intltest/dtfmapts.cpp b/icu4c/source/test/intltest/dtfmapts.cpp index adf621871d3..86160f58ebb 100644 --- a/icu4c/source/test/intltest/dtfmapts.cpp +++ b/icu4c/source/test/intltest/dtfmapts.cpp @@ -1,6 +1,6 @@ /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -254,7 +254,7 @@ if (fr != NULL && it != NULL && de != NULL) status = U_ZERO_ERROR; DateFormat *test = new SimpleDateFormat(status); if(U_FAILURE(status)) { - errcheckln(status, "ERROR: Couldn't create a DateFormat - %s", u_errorName(status)); + dataerrln("ERROR: Couldn't create a DateFormat - %s", u_errorName(status)); } if(test->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) { diff --git a/icu4c/source/test/intltest/dtfmrgts.cpp b/icu4c/source/test/intltest/dtfmrgts.cpp index 777e4751435..fb474cb105e 100644 --- a/icu4c/source/test/intltest/dtfmrgts.cpp +++ b/icu4c/source/test/intltest/dtfmrgts.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -224,7 +224,7 @@ void DateFormatRegressionTest::Test4056591(void) //try { SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("yyMMdd"), Locale::getUS(), status); - if (failure(status, "new SimpleDateFormat")) { + if (failure(status, "new SimpleDateFormat", TRUE)) { delete fmt; return; } @@ -283,7 +283,7 @@ void DateFormatRegressionTest::Test4059917(void) UnicodeString myDate; fmt = new SimpleDateFormat( UnicodeString("yyyy/MM/dd"), status ); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; myDate = "1997/01/01"; aux917( fmt, myDate ); @@ -339,7 +339,7 @@ void DateFormatRegressionTest::Test4060212(void) logln("Using yyyy-DDD.hh:mm:ss"); UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *formatter = new SimpleDateFormat(UnicodeString("yyyy-DDD.hh:mm:ss"), status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; ParsePosition pos(0); UDate myDate = formatter->parse( dateString, pos ); UnicodeString myString; @@ -390,10 +390,10 @@ void DateFormatRegressionTest::Test4061287(void) UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("dd/MM/yyyy"), status); - if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error: %s", u_errorName(status)); - delete df; - return; + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + delete df; + return; } failure(status, "new SimpleDateFormat"); //try { @@ -569,7 +569,7 @@ void DateFormatRegressionTest::Test4073003(void) UErrorCode ec = U_ZERO_ERROR; SimpleDateFormat fmt("dd/MM/yy", Locale::getUK(), ec); if (U_FAILURE(ec)) { - errcheckln(ec, "FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); + dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); return; } UnicodeString tests [] = { @@ -608,7 +608,7 @@ void DateFormatRegressionTest::Test4089106(void) UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *f = new SimpleDateFormat(status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat, error %s", u_errorName(status)); delete f; delete def; delete z; @@ -707,7 +707,7 @@ void DateFormatRegressionTest::Test4101483(void) { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *sdf = new SimpleDateFormat(UnicodeString("z"), Locale::getUS(), status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; FieldPosition fp(UDAT_TIMEZONE_FIELD); //Date d = date(9234567890L); UDate d = 9234567890.0; @@ -740,7 +740,7 @@ void DateFormatRegressionTest::Test4103340(void) // and some arbitrary time UDate d = date(97, 3, 1, 1, 1, 1); SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("MMMM"), Locale::getUS(), status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; UnicodeString s; s = dateToString(d, s); @@ -770,7 +770,7 @@ void DateFormatRegressionTest::Test4103341(void) UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *simple = new SimpleDateFormat(UnicodeString("MM/dd/yyyy HH:mm"), status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat, error %s", u_errorName(status)); delete simple; return; } @@ -795,7 +795,7 @@ void DateFormatRegressionTest::Test4104136(void) UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *sdf = new SimpleDateFormat(status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat, error %s", u_errorName(status)); delete sdf; return; } @@ -860,7 +860,7 @@ void DateFormatRegressionTest::Test4104522(void) SimpleDateFormat *sdf = new SimpleDateFormat(status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat, error %s", u_errorName(status)); delete sdf; return; } @@ -903,7 +903,7 @@ void DateFormatRegressionTest::Test4106807(void) new SimpleDateFormat(UnicodeString("yyyyMMddHHmmss %"), status) }; if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat, error %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat, error %s", u_errorName(status)); delete sdfs[0]; delete sdfs[1]; delete sdfs[2]; @@ -1006,7 +1006,7 @@ void DateFormatRegressionTest::Test4134203(void) UErrorCode status = U_ZERO_ERROR; UnicodeString dateFormat = "MM/dd/yy HH:mm:ss zzz"; SimpleDateFormat *fmt = new SimpleDateFormat(dateFormat, status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; ParsePosition p0(0); UDate d = fmt->parse("01/22/92 04:52:00 GMT", p0); logln(dateToString(d)); @@ -1028,7 +1028,7 @@ void DateFormatRegressionTest::Test4151631(void) logln("pattern=" + pattern); UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *format = new SimpleDateFormat(pattern, Locale::getUS(), status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; UnicodeString result; FieldPosition pos(FieldPosition::DONT_CARE); result = format->format(date(1998-1900, UCAL_JUNE, 30, 13, 30, 0), result, pos); @@ -1052,7 +1052,7 @@ void DateFormatRegressionTest::Test4151706(void) UnicodeString dateString("Thursday, 31-Dec-98 23:00:00 GMT"); UErrorCode status = U_ZERO_ERROR; SimpleDateFormat fmt(UnicodeString("EEEE, dd-MMM-yy HH:mm:ss z"), Locale::getUS(), status); - if(failure(status, "new SimpleDateFormat")) return; + if (failure(status, "new SimpleDateFormat", TRUE)) return; //try { UDate d = fmt.parse(dateString, status); failure(status, "fmt->parse"); @@ -1080,7 +1080,7 @@ DateFormatRegressionTest::Test4162071(void) UErrorCode status = U_ZERO_ERROR; SimpleDateFormat df(format, Locale::getUS(), status); if(U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat - %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat - %s", u_errorName(status)); return; } @@ -1106,7 +1106,7 @@ void DateFormatRegressionTest::Test4182066(void) { SimpleDateFormat fmt("MM/dd/yy", Locale::getUS(), status); SimpleDateFormat dispFmt("MMM dd yyyy GG", Locale::getUS(), status); if (U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat - %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat - %s", u_errorName(status)); return; } @@ -1191,7 +1191,7 @@ DateFormatRegressionTest::Test4210209(void) { DateFormat& fmt = *(DateFormat*)&sfmt; // Yuck: See j25 DateFormat& disp = *(DateFormat*)&sdisp; // Yuck: See j25 if (U_FAILURE(status)) { - errcheckln(status, "Couldn't create SimpleDateFormat - %s", u_errorName(status)); + dataerrln("Couldn't create SimpleDateFormat - %s", u_errorName(status)); return; } Calendar* calx = (Calendar*)fmt.getCalendar(); // cast away const! diff --git a/icu4c/source/test/intltest/dtfmtrtts.cpp b/icu4c/source/test/intltest/dtfmtrtts.cpp index b313e718c35..f3c4b84cb06 100644 --- a/icu4c/source/test/intltest/dtfmtrtts.cpp +++ b/icu4c/source/test/intltest/dtfmtrtts.cpp @@ -1,6 +1,6 @@ /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -89,7 +89,10 @@ void DateFormatRoundTripTest::TestCentury() Locale locale("es_PA"); UnicodeString pattern = "MM/dd/yy hh:mm:ss a z"; SimpleDateFormat fmt(pattern, locale, status); - if(!assertSuccess("trying to construct", status))return; + if (U_FAILURE(status)) { + dataerrln("Fail: construct SimpleDateFormat: %s", u_errorName(status)); + return; + } UDate date[] = {-55018555891590.05, 0, 0}; UnicodeString result[2]; @@ -126,8 +129,10 @@ void DateFormatRoundTripTest::TestDateFormatRoundTrip() UErrorCode status = U_ZERO_ERROR; getFieldCal = Calendar::createInstance(status); - failure(status, "Calendar::createInstance"); - if(!assertSuccess("trying to construct", status))return; + if (U_FAILURE(status)) { + dataerrln("Fail: Calendar::createInstance: %s", u_errorName(status)); + return; + } int32_t locCount = 0; diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index b3778f00ad0..37d7f2d2a2a 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -237,7 +237,7 @@ DateFormatTest::TestTwoDigitYearDSTParse(void) UnicodeString str; if(U_FAILURE(status)) { - errcheckln(status, "Could not set up test. exitting - %s", u_errorName(status)); + dataerrln("Could not set up test. exitting - %s", u_errorName(status)); return; } @@ -481,8 +481,8 @@ DateFormatTest::TestPartialParse994() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat* f = new SimpleDateFormat(status); - ASSERT_OK(status); if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); delete f; return; } @@ -547,7 +547,11 @@ DateFormatTest::TestRunTogetherPattern985() UnicodeString now, then; //UBool flag; SimpleDateFormat *formatter = new SimpleDateFormat(format, status); - ASSERT_OK(status); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + delete formatter; + return; + } UDate date1 = Calendar::getNow(); ((DateFormat*)formatter)->format(date1, now); logln(now); @@ -574,7 +578,11 @@ DateFormatTest::TestRunTogetherPattern917() SimpleDateFormat* fmt; UnicodeString myDate; fmt = new SimpleDateFormat((UnicodeString)"yyyy/MM/dd", status); - ASSERT_OK(status); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + delete fmt; + return; + } myDate = "1997/02/03"; testIt917(fmt, myDate, date(97, 2 - 1, 3)); delete fmt; @@ -670,7 +678,11 @@ DateFormatTest::TestLetterDPattern212() expLittleD = expBigD; // Expect the same, with default lenient parsing logln((UnicodeString)"dateString= " + dateString); SimpleDateFormat *formatter = new SimpleDateFormat(bigD, status); - ASSERT_OK(status); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + delete formatter; + return; + } ParsePosition pos(0); UDate myDate = formatter->parse(dateString, pos); logln((UnicodeString)"Using " + bigD + " -> " + myDate); @@ -745,7 +757,11 @@ DateFormatTest::TestQuotePattern161() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat* formatter = new SimpleDateFormat((UnicodeString)"MM/dd/yyyy 'at' hh:mm:ss a zzz", status); - ASSERT_OK(status); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + delete formatter; + return; + } UDate currentTime_1 = date(97, UCAL_AUGUST, 13, 10, 42, 28); UnicodeString dateString; ((DateFormat*)formatter)->format(currentTime_1, dateString); UnicodeString exp("08/13/1997 at 10:42:28 AM "); @@ -860,7 +876,7 @@ DateFormatTest::TestBadInput135a() UErrorCode status = U_ZERO_ERROR; SimpleDateFormat* dateParse = new SimpleDateFormat(status); if(U_FAILURE(status)) { - errcheckln(status, "Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status)); + dataerrln("Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status)); delete dateParse; return; } @@ -941,7 +957,7 @@ DateFormatTest::TestTwoDigitYear() UErrorCode ec = U_ZERO_ERROR; SimpleDateFormat fmt("dd/MM/yy", Locale::getUK(), ec); if (U_FAILURE(ec)) { - errcheckln(ec, "FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); + dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); return; } parse2DigitYear(fmt, "5/6/17", date(117, UCAL_JUNE, 5)); @@ -982,7 +998,7 @@ DateFormatTest::TestDateFormatZone061() logln((UnicodeString)"Date 1997/3/25 00:00 GMT: " + date); formatter = new SimpleDateFormat((UnicodeString)"dd-MMM-yyyyy HH:mm", Locale::getUK(), status); if(U_FAILURE(status)) { - errcheckln(status, "Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status)); + dataerrln("Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status)); delete formatter; return; } @@ -1029,38 +1045,41 @@ DateFormatTest::TestDateFormatZone146() // now try to use the default GMT time zone GregorianCalendar *greenwichcalendar = new GregorianCalendar(1997, 3, 4, 23, 0, status); - failure(status, "new GregorianCalendar"); - //*****************************greenwichcalendar.setTimeZone(TimeZone.getDefault()); - //greenwichcalendar.set(1997, 3, 4, 23, 0); - // try anything to set hour to 23:00 !!! - greenwichcalendar->set(UCAL_HOUR_OF_DAY, 23); - // get time - UDate greenwichdate = greenwichcalendar->getTime(status); - // format every way - UnicodeString DATA [] = { - UnicodeString("simple format: "), UnicodeString("04/04/97 23:00 GMT+00:00"), - UnicodeString("MM/dd/yy HH:mm z"), - UnicodeString("full format: "), UnicodeString("Friday, April 4, 1997 11:00:00 o'clock PM GMT+00:00"), - UnicodeString("EEEE, MMMM d, yyyy h:mm:ss 'o''clock' a z"), - UnicodeString("long format: "), UnicodeString("April 4, 1997 11:00:00 PM GMT+00:00"), - UnicodeString("MMMM d, yyyy h:mm:ss a z"), - UnicodeString("default format: "), UnicodeString("04-Apr-97 11:00:00 PM"), - UnicodeString("dd-MMM-yy h:mm:ss a"), - UnicodeString("short format: "), UnicodeString("4/4/97 11:00 PM"), - UnicodeString("M/d/yy h:mm a") - }; - int32_t DATA_length = (int32_t)(sizeof(DATA) / sizeof(DATA[0])); + if (U_FAILURE(status)) { + dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); + } else { + //*****************************greenwichcalendar.setTimeZone(TimeZone.getDefault()); + //greenwichcalendar.set(1997, 3, 4, 23, 0); + // try anything to set hour to 23:00 !!! + greenwichcalendar->set(UCAL_HOUR_OF_DAY, 23); + // get time + UDate greenwichdate = greenwichcalendar->getTime(status); + // format every way + UnicodeString DATA [] = { + UnicodeString("simple format: "), UnicodeString("04/04/97 23:00 GMT+00:00"), + UnicodeString("MM/dd/yy HH:mm z"), + UnicodeString("full format: "), UnicodeString("Friday, April 4, 1997 11:00:00 o'clock PM GMT+00:00"), + UnicodeString("EEEE, MMMM d, yyyy h:mm:ss 'o''clock' a z"), + UnicodeString("long format: "), UnicodeString("April 4, 1997 11:00:00 PM GMT+00:00"), + UnicodeString("MMMM d, yyyy h:mm:ss a z"), + UnicodeString("default format: "), UnicodeString("04-Apr-97 11:00:00 PM"), + UnicodeString("dd-MMM-yy h:mm:ss a"), + UnicodeString("short format: "), UnicodeString("4/4/97 11:00 PM"), + UnicodeString("M/d/yy h:mm a") + }; + int32_t DATA_length = (int32_t)(sizeof(DATA) / sizeof(DATA[0])); - for (int32_t i=0; isetCalendar(*greenwichcalendar); - UnicodeString result; - result = fmt->format(greenwichdate, result); - logln(DATA[i] + result); - if (result != DATA[i+1]) - errln("FAIL: Expected " + DATA[i+1] + ", got " + result); - delete fmt; + for (int32_t i=0; isetCalendar(*greenwichcalendar); + UnicodeString result; + result = fmt->format(greenwichdate, result); + logln(DATA[i] + result); + if (result != DATA[i+1]) + errln("FAIL: Expected " + DATA[i+1] + ", got " + result); + delete fmt; + } } //} //finally { @@ -1259,7 +1278,10 @@ void DateFormatTest::TestWhiteSpaceParsing() { void DateFormatTest::TestInvalidPattern() { UErrorCode ec = U_ZERO_ERROR; SimpleDateFormat f(UnicodeString("Yesterday"), ec); - ASSERT_OK(ec); + if (U_FAILURE(ec)) { + dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec)); + return; + } UnicodeString out; FieldPosition pos; f.format((UDate)0, out, pos); @@ -1272,7 +1294,10 @@ void DateFormatTest::TestGreekMay() { UErrorCode ec = U_ZERO_ERROR; UDate date = -9896080848000.0; SimpleDateFormat fmt("EEEE, dd MMMM yyyy h:mm:ss a", Locale("el", "", ""), ec); - if (!assertSuccess("SimpleDateFormat::ct", ec)) return; + if (U_FAILURE(ec)) { + dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec)); + return; + } UnicodeString str; fmt.format(date, str); ParsePosition pos(0); @@ -1574,7 +1599,7 @@ void DateFormatTest::expectParse(const char** data, int32_t data_length, SimpleDateFormat ref(data[i++], loc, ec); SimpleDateFormat gotfmt("G yyyy MM dd HH:mm:ss z", loc, ec); if (U_FAILURE(ec)) { - errcheckln(ec, "FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); + dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec)); return; } @@ -1657,7 +1682,10 @@ void DateFormatTest::expect(const char** data, int32_t data_length, SimpleDateFormat fmt("", loc, ec); SimpleDateFormat ref(data[i++], loc, ec); SimpleDateFormat univ("EE G yyyy MM dd HH:mm:ss.SSS z", loc, ec); - if (!assertSuccess("construct SimpleDateFormat", ec)) return; + if (U_FAILURE(ec)) { + dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec)); + return; + } UnicodeString currentPat; while (ioptions; DateTimePatternGenerator * dtpgen = DateTimePatternGenerator::createInstance(locale, status); + if (U_FAILURE(status)) { + dataerrln("Unable to create DateTimePatternGenerator instance for locale(%s): %s", locale.getName(), u_errorName(status)); + delete dtpgen; + continue; + } UnicodeString pattern = dtpgen->getBestPattern(skel, options, status); if (pattern.compare(expectedPattern) != 0) { errln( UnicodeString("ERROR in getBestPattern, locale ") + UnicodeString(testDataPtr->locale) + diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp index 7932df59f48..66af5b2328f 100644 --- a/icu4c/source/test/intltest/incaltst.cpp +++ b/icu4c/source/test/intltest/incaltst.cpp @@ -18,7 +18,7 @@ #define CHECK(status, msg) \ if (U_FAILURE(status)) { \ - errcheckln(status, (UnicodeString(u_errorName(status)) + UnicodeString(" : " ) )+ msg); \ + dataerrln((UnicodeString(u_errorName(status)) + UnicodeString(" : " ) )+ msg); \ return; \ } diff --git a/icu4c/source/test/intltest/itutil.cpp b/icu4c/source/test/intltest/itutil.cpp index 94cf1026526..8da8d0e7964 100644 --- a/icu4c/source/test/intltest/itutil.cpp +++ b/icu4c/source/test/intltest/itutil.cpp @@ -294,7 +294,7 @@ void LocalPointerTest::TestLocalXyzPointer() { #if !UCONFIG_NO_FORMATTING LocalUCalendarPointer cal(ucal_open(NULL, 0, "root", UCAL_GREGORIAN, errorCode)); - if(errorCode.logIfFailureAndReset("ucal_open()")) { + if(errorCode.logDataIfFailureAndReset("ucal_open()")) { return; } if(cal.isNull()) { @@ -389,7 +389,9 @@ void LocalPointerTest::TestLocalXyzPointerNull() { IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUCalendarPointer"); LocalUCalendarPointer null; LocalUCalendarPointer cal(ucal_open(NULL, 0, "root", UCAL_GREGORIAN, errorCode)); - cal.adoptInstead(NULL); + if(!errorCode.logDataIfFailureAndReset("ucal_open()")) { + cal.adoptInstead(NULL); + } } { IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUDateTimePatternGeneratorPointer"); @@ -414,7 +416,9 @@ void LocalPointerTest::TestLocalXyzPointerNull() { LocalURegularExpressionPointer null; LocalURegularExpressionPointer regex( uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, errorCode)); - regex.adoptInstead(NULL); + if(!errorCode.logDataIfFailureAndReset("urege_open()")) { + regex.adoptInstead(NULL); + } } #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ @@ -425,7 +429,9 @@ void LocalPointerTest::TestLocalXyzPointerNull() { LocalUTransliteratorPointer null; LocalUTransliteratorPointer trans( utrans_openU(id.getBuffer(), id.length(), UTRANS_FORWARD, NULL, 0, NULL, errorCode)); - trans.adoptInstead(NULL); + if(!errorCode.logDataIfFailureAndReset("utrans_openU()")) { + trans.adoptInstead(NULL); + } } #endif /* !UCONFIG_NO_TRANSLITERATION */ diff --git a/icu4c/source/test/intltest/jamotest.cpp b/icu4c/source/test/intltest/jamotest.cpp index cb74804114b..e3053114f5c 100644 --- a/icu4c/source/test/intltest/jamotest.cpp +++ b/icu4c/source/test/intltest/jamotest.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************** ************************************************************************ @@ -161,7 +161,7 @@ void JamoTest::TestPiecemeal(void) { t = Transliterator::createInstance("NFD", UTRANS_FORWARD, status); // was Hangul-Jamo if (U_FAILURE(status) || t == 0) { - errln("FAIL: createInstance failed"); + dataerrln("FAIL: createInstance failed"); return; } expect(*t, hangul, jamo); diff --git a/icu4c/source/test/intltest/locnmtst.cpp b/icu4c/source/test/intltest/locnmtst.cpp index b453d16a213..73b8994ae73 100644 --- a/icu4c/source/test/intltest/locnmtst.cpp +++ b/icu4c/source/test/intltest/locnmtst.cpp @@ -46,7 +46,7 @@ { \ if (UnicodeString(target)!=(value)) { \ logln("unexpected value '" + (value) + "'"); \ - errln("FAIL: " #target " == " #value " was not true. In " __FILE__ " on line %d", __LINE__); \ + dataerrln("FAIL: " #target " == " #value " was not true. In " __FILE__ " on line %d", __LINE__); \ } else { \ logln("PASS: asserted " #target " == " #value); \ } \ diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 718bbad1b12..1accecddcd2 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -1306,7 +1306,7 @@ LocaleTest::Test4139940() UErrorCode status = U_ZERO_ERROR; SimpleDateFormat df_full("EEEE", mylocale, status); if(U_FAILURE(status)){ - errcheckln(status, UnicodeString("Could not create SimpleDateFormat object for locale hu. Error: " )+ UnicodeString(u_errorName(status))); + dataerrln(UnicodeString("Could not create SimpleDateFormat object for locale hu. Error: ") + UnicodeString(u_errorName(status))); return; } UnicodeString str; @@ -1813,7 +1813,7 @@ void LocaleTest::TestGetLocale(void) { req = "en_US_BROOKLYN"; Calendar* cal = Calendar::createInstance(Locale::createFromName(req), ec); if (U_FAILURE(ec)) { - errln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec)); + dataerrln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec)); } else { valid = cal->getLocale(ULOC_VALID_LOCALE, ec); actual = cal->getLocale(ULOC_ACTUAL_LOCALE, ec); diff --git a/icu4c/source/test/intltest/miscdtfm.cpp b/icu4c/source/test/intltest/miscdtfm.cpp index 7ecb0fe2eed..e6f4c39998c 100644 --- a/icu4c/source/test/intltest/miscdtfm.cpp +++ b/icu4c/source/test/intltest/miscdtfm.cpp @@ -113,7 +113,10 @@ DateFormatMiscTests::test4097450() UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *formatter; SimpleDateFormat *resultFormatter = new SimpleDateFormat((UnicodeString)"yyyy", status); - failure(status, "new SimpleDateFormat"); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + return; + } logln("Format\tSource\tResult"); logln("-------\t-------\t-------"); diff --git a/icu4c/source/test/intltest/normconf.cpp b/icu4c/source/test/intltest/normconf.cpp index 2c6a955d8f4..98958095123 100644 --- a/icu4c/source/test/intltest/normconf.cpp +++ b/icu4c/source/test/intltest/normconf.cpp @@ -1,6 +1,6 @@ /* ************************************************************************ -* Copyright (c) 1997-2009, International Business Machines +* Copyright (c) 1997-2010, International Business Machines * Corporation and others. All Rights Reserved. ************************************************************************ */ @@ -227,7 +227,7 @@ void NormalizerConformanceTest::TestConformance(FileStream *input, int32_t optio } else { ++failCount; if(status == U_FILE_ACCESS_ERROR) { - errln("Something is wrong with the normalizer, skipping the rest of the test."); + dataerrln("Something is wrong with the normalizer, skipping the rest of the test."); break; } } @@ -263,7 +263,7 @@ void NormalizerConformanceTest::TestConformance(FileStream *input, int32_t optio } else { ++failCount; if(status == U_FILE_ACCESS_ERROR) { - errln("Something is wrong with the normalizer, skipping the rest of the test."); + dataerrln("Something is wrong with the normalizer, skipping the rest of the test.: %s", u_errorName(status)); break; } } @@ -273,7 +273,7 @@ void NormalizerConformanceTest::TestConformance(FileStream *input, int32_t optio } if (failCount != 0) { - errln((UnicodeString)"Total: " + failCount + " lines/code points failed, " + + dataerrln((UnicodeString)"Total: " + failCount + " lines/code points failed, " + passCount + " lines/code points passed"); } else { logln((UnicodeString)"Total: " + passCount + " lines/code points passed"); @@ -308,32 +308,48 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, fieldNum = i+1; if (i<3) { Normalizer::normalize(field[i], UNORM_NFC, options, out, status); - pass &= assertEqual("C", field[i], out, field[1], "c2!=C(c", fieldNum); - iterativeNorm(field[i], UNORM_NFC, options, out, +1); - pass &= assertEqual("C(+1)", field[i], out, field[1], "c2!=C(c", fieldNum); - iterativeNorm(field[i], UNORM_NFC, options, out, -1); - pass &= assertEqual("C(-1)", field[i], out, field[1], "c2!=C(c", fieldNum); + if (U_FAILURE(status)) { + dataerrln("Error running normalize UNORM_NFC: %s", u_errorName(status)); + } else { + pass &= assertEqual("C", field[i], out, field[1], "c2!=C(c", fieldNum); + iterativeNorm(field[i], UNORM_NFC, options, out, +1); + pass &= assertEqual("C(+1)", field[i], out, field[1], "c2!=C(c", fieldNum); + iterativeNorm(field[i], UNORM_NFC, options, out, -1); + pass &= assertEqual("C(-1)", field[i], out, field[1], "c2!=C(c", fieldNum); + } Normalizer::normalize(field[i], UNORM_NFD, options, out, status); - pass &= assertEqual("D", field[i], out, field[2], "c3!=D(c", fieldNum); - iterativeNorm(field[i], UNORM_NFD, options, out, +1); - pass &= assertEqual("D(+1)", field[i], out, field[2], "c3!=D(c", fieldNum); - iterativeNorm(field[i], UNORM_NFD, options, out, -1); - pass &= assertEqual("D(-1)", field[i], out, field[2], "c3!=D(c", fieldNum); + if (U_FAILURE(status)) { + dataerrln("Error running normalize UNORM_NFD: %s", u_errorName(status)); + } else { + pass &= assertEqual("D", field[i], out, field[2], "c3!=D(c", fieldNum); + iterativeNorm(field[i], UNORM_NFD, options, out, +1); + pass &= assertEqual("D(+1)", field[i], out, field[2], "c3!=D(c", fieldNum); + iterativeNorm(field[i], UNORM_NFD, options, out, -1); + pass &= assertEqual("D(-1)", field[i], out, field[2], "c3!=D(c", fieldNum); + } } Normalizer::normalize(field[i], UNORM_NFKC, options, out, status); - pass &= assertEqual("KC", field[i], out, field[3], "c4!=KC(c", fieldNum); - iterativeNorm(field[i], UNORM_NFKC, options, out, +1); - pass &= assertEqual("KC(+1)", field[i], out, field[3], "c4!=KC(c", fieldNum); - iterativeNorm(field[i], UNORM_NFKC, options, out, -1); - pass &= assertEqual("KC(-1)", field[i], out, field[3], "c4!=KC(c", fieldNum); + if (U_FAILURE(status)) { + dataerrln("Error running normalize UNORM_NFKC: %s", u_errorName(status)); + } else { + pass &= assertEqual("KC", field[i], out, field[3], "c4!=KC(c", fieldNum); + iterativeNorm(field[i], UNORM_NFKC, options, out, +1); + pass &= assertEqual("KC(+1)", field[i], out, field[3], "c4!=KC(c", fieldNum); + iterativeNorm(field[i], UNORM_NFKC, options, out, -1); + pass &= assertEqual("KC(-1)", field[i], out, field[3], "c4!=KC(c", fieldNum); + } Normalizer::normalize(field[i], UNORM_NFKD, options, out, status); - pass &= assertEqual("KD", field[i], out, field[4], "c5!=KD(c", fieldNum); - iterativeNorm(field[i], UNORM_NFKD, options, out, +1); - pass &= assertEqual("KD(+1)", field[i], out, field[4], "c5!=KD(c", fieldNum); - iterativeNorm(field[i], UNORM_NFKD, options, out, -1); - pass &= assertEqual("KD(-1)", field[i], out, field[4], "c5!=KD(c", fieldNum); + if (U_FAILURE(status)) { + dataerrln("Error running normalize UNORM_NFKD: %s", u_errorName(status)); + } else { + pass &= assertEqual("KD", field[i], out, field[4], "c5!=KD(c", fieldNum); + iterativeNorm(field[i], UNORM_NFKD, options, out, +1); + pass &= assertEqual("KD(+1)", field[i], out, field[4], "c5!=KD(c", fieldNum); + iterativeNorm(field[i], UNORM_NFKD, options, out, -1); + pass &= assertEqual("KD(-1)", field[i], out, field[4], "c5!=KD(c", fieldNum); + } } compare(field[1],field[2]); compare(field[0],field[1]); @@ -362,7 +378,7 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, result = Normalizer::isNormalized(field[1], UNORM_NFC, options, status); } if(!result) { - errln("Normalizer error: isNormalized(NFC(s), UNORM_NFC) is FALSE"); + dataerrln("Normalizer error: isNormalized(NFC(s), UNORM_NFC) is FALSE"); pass = FALSE; } if(field[0]!=field[1] && Normalizer::isNormalized(field[0], UNORM_NFC, options, status)) { @@ -370,7 +386,7 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, pass = FALSE; } if(!Normalizer::isNormalized(field[3], UNORM_NFKC, options, status)) { - errln("Normalizer error: isNormalized(NFKC(s), UNORM_NFKC) is FALSE"); + dataerrln("Normalizer error: isNormalized(NFKC(s), UNORM_NFKC) is FALSE"); pass = FALSE; } if(field[0]!=field[3] && Normalizer::isNormalized(field[0], UNORM_NFKC, options, status)) { @@ -395,12 +411,12 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, Normalizer::normalize(fcd, UNORM_NFD, options, out, status); if(out != field[2]) { - errln("Normalizer error: NFD(FCD(s))!=NFD(s)"); + dataerrln("Normalizer error: NFD(FCD(s))!=NFD(s)"); pass = FALSE; } if (U_FAILURE(status)) { - errln("Normalizer::normalize returned error status"); + dataerrln("Normalizer::normalize returned error status: %s", u_errorName(status)); pass = FALSE; } @@ -414,7 +430,7 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, status=U_ZERO_ERROR; rc=Normalizer::compare(field[0], field[2], (options<format( args , numOfArgs , result, ignore, status); if (U_FAILURE(status)) { - errln( "%serror while formatting with ErrorCode as %s" ,errMsg, u_errorName(status) ); + dataerrln( "%serror while formatting with ErrorCode as %s" ,errMsg, u_errorName(status) ); } //Compare expected with obtained result if ( result!= expected ) { UnicodeString err = UnicodeString(errMsg); - err+= UnicodeString(":Unexpected Result \n Expected: " + expected + "\n Obtained: " + result); - errln(err); + err+= UnicodeString(":Unexpected Result \n Expected: " + expected + "\n Obtained: " + result + "\n"); + dataerrln(err); } } @@ -645,7 +645,7 @@ MessageFormat* TestMessageFormat::internalCreate( //Create the MessageFormat with simple SelectFormat MessageFormat* msgFmt = new MessageFormat(pattern, locale, status); if (U_FAILURE(status)) { - errln( "%serror while constructing with ErrorCode as %s" ,errMsg, u_errorName(status) ); + dataerrln( "%serror while constructing with ErrorCode as %s" ,errMsg, u_errorName(status) ); logln(UnicodeString("TestMessageFormat::testMsgFormatSelect #1 with error code ")+(int32_t)status); return NULL; } diff --git a/icu4c/source/test/intltest/transtst.cpp b/icu4c/source/test/intltest/transtst.cpp index 2550edda7f2..42a061f070d 100644 --- a/icu4c/source/test/intltest/transtst.cpp +++ b/icu4c/source/test/intltest/transtst.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1999-2009, International Business Machines +* Copyright (C) 1999-2010, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -243,7 +243,7 @@ void TransliteratorTest::TestInstantiation() { // If UCONFIG_NO_BREAK_ITERATION is on, then only Thai should fail. if (id.compare((UnicodeString)"Thai-Latin") != 0) #endif - errln(UnicodeString("FAIL: Couldn't create ") + id + + dataerrln(UnicodeString("FAIL: Couldn't create ") + id + /*", parse error " + parseError.code +*/ ", line " + parseError.line + ", offset " + parseError.offset + @@ -1459,7 +1459,7 @@ void TransliteratorTest::TestNormalizationTransliterator() { Transliterator* NFD = Transliterator::createInstance("NFD", UTRANS_FORWARD, parseError, status); Transliterator* NFC = Transliterator::createInstance("NFC", UTRANS_FORWARD, parseError, status); if (!NFD || !NFC) { - errln("FAIL: createInstance failed"); + dataerrln("FAIL: createInstance failed: %s", u_errorName(status)); delete NFD; delete NFC; return; @@ -2104,7 +2104,7 @@ void TransliteratorTest::TestNFDChainRBT() { "TEST", "::NFD; aa > Q; a > q;", UTRANS_FORWARD, pe, ec); if (t == NULL || U_FAILURE(ec)) { - errln("FAIL: Transliterator::createFromRules failed with %s", u_errorName(ec)); + dataerrln("FAIL: Transliterator::createFromRules failed with %s", u_errorName(ec)); return; } expect(*t, "aa", "Q"); @@ -3561,7 +3561,7 @@ void TransliteratorTest::TestIncrementalProgress(void) { Transliterator *t = Transliterator::createInstance(id, UTRANS_FORWARD, err, status); if (U_FAILURE(status)) { - errln((UnicodeString)"FAIL: Could not create " + id); + dataerrln((UnicodeString)"FAIL: Could not create " + id); delete t; continue; } diff --git a/icu4c/source/test/intltest/tstnorm.cpp b/icu4c/source/test/intltest/tstnorm.cpp index 18cfd23eef8..8d9d11fedb3 100644 --- a/icu4c/source/test/intltest/tstnorm.cpp +++ b/icu4c/source/test/intltest/tstnorm.cpp @@ -354,21 +354,29 @@ void BasicNormalizerTest::TestZeroIndex(void) { a = a.unescape(); UnicodeString b; Normalizer::normalize(a, UNORM_NFKC, 0, b, status); - UnicodeString exp(DATA[i+1], ""); - exp = exp.unescape(); - if (b == exp) { - logln((UnicodeString)"Ok: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b)); + if (U_FAILURE(status)) { + dataerrln("Error calling normalize UNORM_NFKC: %s", u_errorName(status)); } else { - errln((UnicodeString)"FAIL: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b) + - ", expect " + hex(exp)); + UnicodeString exp(DATA[i+1], ""); + exp = exp.unescape(); + if (b == exp) { + logln((UnicodeString)"Ok: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b)); + } else { + errln((UnicodeString)"FAIL: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b) + + ", expect " + hex(exp)); + } } Normalizer::normalize(b, UNORM_NFD, 0, a, status); - exp = UnicodeString(DATA[i+2], "").unescape(); - if (a == exp) { - logln((UnicodeString)"Ok: " + hex(b) + " x DECOMP => " + hex(a)); + if (U_FAILURE(status)) { + dataerrln("Error calling normalize UNORM_NFD: %s", u_errorName(status)); } else { - errln((UnicodeString)"FAIL: " + hex(b) + " x DECOMP => " + hex(a) + - ", expect " + hex(exp)); + UnicodeString exp = UnicodeString(DATA[i+2], "").unescape(); + if (a == exp) { + logln((UnicodeString)"Ok: " + hex(b) + " x DECOMP => " + hex(a)); + } else { + errln((UnicodeString)"FAIL: " + hex(b) + " x DECOMP => " + hex(a) + + ", expect " + hex(exp)); + } } } } @@ -529,7 +537,7 @@ void BasicNormalizerTest::staticTest(UNormalizationMode mode, int options, Normalizer::normalize(input, mode, options, output, status); if (output != expect) { - errln(UnicodeString("ERROR: case ") + i + " normalized " + hex(input) + "\n" + dataerrln(UnicodeString("ERROR: case ") + i + " normalized " + hex(input) + "\n" + " expected " + hex(expect) + "\n" + " static got " + hex(output) ); } @@ -563,7 +571,7 @@ void BasicNormalizerTest::assertEqual(const UnicodeString& input, result += ch; } if (result != expected) { - errln(errPrefix + "normalized " + hex(input) + "\n" + dataerrln(errPrefix + "normalized " + hex(input) + "\n" + " expected " + hex(expected) + "\n" + " iterate got " + hex(result) ); } @@ -653,8 +661,8 @@ BasicNormalizerTest::TestPreviousNext(const UChar *src, int32_t srcLength, char history[64]; uprv_strcpy(history, moves); history[move-moves]=0; - errln("error: mismatch in Normalizer iteration (%s) at %s: " - "got c1=U+%04lx != expected c2=U+%04lx\n", + dataerrln("error: mismatch in Normalizer iteration (%s) at %s: " + "got c1=U+%04lx != expected c2=U+%04lx", name, history, c1, c2); break; } @@ -810,7 +818,7 @@ void BasicNormalizerTest::TestConcatenate() { r=Normalizer::concatenate(left, right, result, mode, 0, errorCode); if(U_FAILURE(errorCode) || /*result!=r ||*/ result!=expect) { - errln("error in Normalizer::concatenate(), cases[] fails with "+ + dataerrln("error in Normalizer::concatenate(), cases[] fails with "+ UnicodeString(u_errorName(errorCode))+", result==expect: expected: "+ hex(expect)+" =========> got: " + hex(result)); } @@ -1120,7 +1128,7 @@ BasicNormalizerTest::TestCompare() { errorCode=U_ZERO_ERROR; Normalizer::decompose(s1, FALSE, 0, s2, errorCode); if(U_FAILURE(errorCode)) { - errln("Normalizer::decompose(U+%04x) failed: %s", start, u_errorName(errorCode)); + dataerrln("Normalizer::decompose(U+%04x) failed: %s", start, u_errorName(errorCode)); return; } @@ -1210,7 +1218,7 @@ BasicNormalizerTest::countFoldFCDExceptions(uint32_t foldingOptions) { if (U_FAILURE(errorCode)) { ++count; - errln("U+%04lx: Failed with error %s", u_errorName(errorCode)); + dataerrln("U+%04lx: Failed with error %s", u_errorName(errorCode)); } // bad: @@ -1222,8 +1230,8 @@ BasicNormalizerTest::countFoldFCDExceptions(uint32_t foldingOptions) { (cc!=foldCC && foldCC!=0) || (trailCC!=foldTrailCC && foldTrailCC!=0) ) { ++count; - errln("U+%04lx: case-folding may un-FCD a string (folding options %04lx)", c, foldingOptions); - errln(" cc %02x trailCC %02x foldCC(U+%04lx) %02x foldTrailCC(U+%04lx) %02x quickCheck(folded)=%d", cc, trailCC, d.char32At(0), foldCC, d.char32At(d.length()-1), foldTrailCC, qcResult); + dataerrln("U+%04lx: case-folding may un-FCD a string (folding options %04lx)", c, foldingOptions); + dataerrln(" cc %02x trailCC %02x foldCC(U+%04lx) %02x foldTrailCC(U+%04lx) %02x quickCheck(folded)=%d", cc, trailCC, d.char32At(0), foldCC, d.char32At(d.length()-1), foldTrailCC, qcResult); continue; } @@ -1253,7 +1261,7 @@ BasicNormalizerTest::FindFoldFCDExceptions() { * It currently assumes that one can check for FCD then case-fold * and then still have FCD strings for raw decomposition without reordering. */ - errln("error: There are %ld code points for which case-folding may un-FCD a string for all folding options.\n" + dataerrln("error: There are %ld code points for which case-folding may un-FCD a string for all folding options.\n" "See comment in BasicNormalizerTest::FindFoldFCDExceptions()!", count); } } @@ -1727,7 +1735,7 @@ BasicNormalizerTest::TestSkippable() { skipSets[UNORM_NFKD].applyPattern(UNICODE_STRING_SIMPLE("[:NFKD_Inert:]"), errorCode); skipSets[UNORM_NFC].applyPattern(UNICODE_STRING_SIMPLE("[:NFC_Inert:]"), errorCode); skipSets[UNORM_NFKC].applyPattern(UNICODE_STRING_SIMPLE("[:NFKC_Inert:]"), errorCode); - if(errorCode.logIfFailureAndReset("UnicodeSet(NF..._Inert) failed")) { + if(errorCode.logDataIfFailureAndReset("UnicodeSet(NF..._Inert) failed")) { return; } diff --git a/icu4c/source/test/intltest/tstnrapi.cpp b/icu4c/source/test/intltest/tstnrapi.cpp index cb51594b0d9..61d8398f7f3 100644 --- a/icu4c/source/test/intltest/tstnrapi.cpp +++ b/icu4c/source/test/intltest/tstnrapi.cpp @@ -26,13 +26,13 @@ BasicNormalizerTest::TestNormalizerAPI() { StringCharacterIterator iter(s); Normalizer norm(iter, UNORM_NFC); if(norm.next()!=0xe4) { - errln("error in Normalizer(CharacterIterator).next()"); + dataerrln("error in Normalizer(CharacterIterator).next()"); } // test copy constructor Normalizer copy(norm); if(copy.next()!=0xac00) { - errln("error in Normalizer(Normalizer(CharacterIterator)).next()"); + dataerrln("error in Normalizer(Normalizer(CharacterIterator)).next()"); } // test clone(), ==, and hashCode() @@ -45,7 +45,7 @@ BasicNormalizerTest::TestNormalizerAPI() { errln("error in Normalizer(Normalizer(CharacterIterator)).clone()->hashCode()!=copy.hashCode()"); } if(clone->next()!=0x4e3d) { - errln("error in Normalizer(Normalizer(CharacterIterator)).clone()->next()"); + dataerrln("error in Normalizer(Normalizer(CharacterIterator)).clone()->next()"); } // position changed, must change hashCode() if(clone->hashCode()==copy.hashCode()) { @@ -63,7 +63,7 @@ BasicNormalizerTest::TestNormalizerAPI() { Normalizer::compose(tel, TRUE, 0, nfkc, errorCode); Normalizer::decompose(tel, TRUE, 0, nfkd, errorCode); if(U_FAILURE(errorCode)) { - errln("error in Normalizer::(de)compose(): %s", u_errorName(errorCode)); + dataerrln("error in Normalizer::(de)compose(): %s", u_errorName(errorCode)); } else if( nfkc!=UnicodeString("TE\\u0139TELTELTELTELTELTELTELTELTEL", "").unescape() || nfkd!=UnicodeString("TEL\\u0301TELTELTELTELTELTELTELTELTEL", "").unescape() @@ -74,7 +74,7 @@ BasicNormalizerTest::TestNormalizerAPI() { // test setIndex() norm.setIndexOnly(3); if(norm.current()!=0x4e3d) { - errln("error in Normalizer(CharacterIterator).setIndex(3)"); + dataerrln("error in Normalizer(CharacterIterator).setIndex(3)"); } // test setText(CharacterIterator) and getText() @@ -102,7 +102,7 @@ BasicNormalizerTest::TestNormalizerAPI() { errln("error in Normalizer::setMode() or Normalizer::getUMode()"); } if(copy.next()!=0x308 || copy.next()!=0x1100) { - errln("error in Normalizer::setText(UChar *) or Normalizer::setMode()"); + dataerrln("error in Normalizer::setText(UChar *) or Normalizer::setMode()"); } // test setText(UChar *, length=-1) @@ -145,23 +145,23 @@ BasicNormalizerTest::TestNormalizerAPI() { s.setTo((UChar)0xe4); Normalizer::normalize(s, UNORM_NFD, 0, s, status); if(s.charAt(1)!=0x308) { - errln("error in Normalizer::normalize(UNORM_NFD, self)"); + dataerrln("error in Normalizer::normalize(UNORM_NFD, self)"); } Normalizer::normalize(s, UNORM_NFC, 0, s, status); if(s.charAt(0)!=0xe4) { - errln("error in Normalizer::normalize(UNORM_NFC, self)"); + dataerrln("error in Normalizer::normalize(UNORM_NFC, self)"); } Normalizer::decompose(s, FALSE, 0, s, status); if(s.charAt(1)!=0x308) { - errln("error in Normalizer::decompose(self)"); + dataerrln("error in Normalizer::decompose(self)"); } Normalizer::compose(s, FALSE, 0, s, status); if(s.charAt(0)!=0xe4) { - errln("error in Normalizer::compose(self)"); + dataerrln("error in Normalizer::compose(self)"); } Normalizer::concatenate(s, s, s, UNORM_NFC, 0, status); if(s.charAt(1)!=0xe4) { - errln("error in Normalizer::decompose(self)"); + dataerrln("error in Normalizer::decompose(self)"); } } diff --git a/icu4c/source/test/intltest/tzbdtest.cpp b/icu4c/source/test/intltest/tzbdtest.cpp index 7d753ab85ca..5df0f4b856a 100644 --- a/icu4c/source/test/intltest/tzbdtest.cpp +++ b/icu4c/source/test/intltest/tzbdtest.cpp @@ -1,6 +1,6 @@ /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -123,7 +123,7 @@ TimeZoneBoundaryTest::findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInD dataerrln("FAIL: " + tz->getID(str) + " inDaylightTime(" + dateToString(d) + ") != " + (startsInDST ? "true" : "false")); startsInDST = !startsInDST; } - if (failure(status, "TimeZone::inDaylightTime")) return; + if (failure(status, "TimeZone::inDaylightTime", TRUE)) return; if (tz->inDaylightTime(max, status) == startsInDST) { dataerrln("FAIL: " + tz->getID(str) + " inDaylightTime(" + dateToString(max) + ") != " + (startsInDST ? "false" : "true")); return; @@ -195,7 +195,7 @@ TimeZoneBoundaryTest::verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylig logln(UnicodeString("PASS: inDaylightTime = ") + (time_zone->inDaylightTime(d, status)?"true":"false")); else dataerrln(UnicodeString("FAIL: inDaylightTime = ") + (time_zone->inDaylightTime(d, status)?"true":"false")); - if (failure(status, "TimeZone::inDaylightTime")) + if (failure(status, "TimeZone::inDaylightTime", TRUE)) return; if (time_zone->useDaylightTime() == expUseDaylightTime) logln(UnicodeString("PASS: useDaylightTime = ") + (time_zone->useDaylightTime()?"true":"false")); @@ -286,30 +286,32 @@ TimeZoneBoundaryTest::TestBoundaries() verifyMapping(*tempcal, 1997, Calendar::APRIL, 6, 1, 238977.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 6, 3, 238978.0); }else{ - errln("Could not create calendar. Error: %s", u_errorName(status)); + dataerrln("Could not create calendar. Error: %s", u_errorName(status)); } TimeZone* utc = TimeZone::createTimeZone("UTC"); Calendar* utccal = Calendar::createInstance(utc, status); if(U_SUCCESS(status)){ verifyMapping(*utccal, 1997, Calendar::APRIL, 6, 0, 238968.0); }else{ - errln("Could not create calendar. Error: %s", u_errorName(status)); + dataerrln("Could not create calendar. Error: %s", u_errorName(status)); } TimeZone* save = TimeZone::createDefault(); TimeZone::setDefault(*pst); - - // DST changeover for PST is 4/6/1997 at 2 hours past midnight - // at 238978.0 epoch hours. - tempcal->clear(); - tempcal->set(1997, Calendar::APRIL, 6); - UDate d = tempcal->getTime(status); + + if (tempcal != NULL) { + // DST changeover for PST is 4/6/1997 at 2 hours past midnight + // at 238978.0 epoch hours. + tempcal->clear(); + tempcal->set(1997, Calendar::APRIL, 6); + UDate d = tempcal->getTime(status); - // i is minutes past midnight standard time - for (int i=-120; i<=180; i+=60) - { - UBool inDST = (i >= 120); - tempcal->setTime(d + i*60*1000, status); - verifyDST(tempcal->getTime(status),pst, TRUE, inDST, -8*ONE_HOUR,inDST ? -7*ONE_HOUR : -8*ONE_HOUR); + // i is minutes past midnight standard time + for (int i=-120; i<=180; i+=60) + { + UBool inDST = (i >= 120); + tempcal->setTime(d + i*60*1000, status); + verifyDST(tempcal->getTime(status),pst, TRUE, inDST, -8*ONE_HOUR,inDST ? -7*ONE_HOUR : -8*ONE_HOUR); + } } TimeZone::setDefault(*save); delete save; @@ -383,7 +385,7 @@ TimeZoneBoundaryTest::testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate e UDate min = d; UDate max = min + SIX_MONTHS; UBool startsInDST = tz->inDaylightTime(d, status); - if (failure(status, "SimpleTimeZone::inDaylightTime")) return; + if (failure(status, "SimpleTimeZone::inDaylightTime", TRUE)) return; if (tz->inDaylightTime(max, status) == startsInDST) { errln("Error: inDaylightTime(" + dateToString(max) + ") != " + ((!startsInDST)?"true":"false")); } @@ -452,7 +454,7 @@ TimeZoneBoundaryTest::findBoundariesStepwise(int32_t year, UDate interval, TimeZ UDate time = d; UDate limit = time + ONE_YEAR + ONE_DAY; UBool lastState = z->inDaylightTime(d, status); - if (failure(status, "TimeZone::inDaylightTime")) return; + if (failure(status, "TimeZone::inDaylightTime", TRUE)) return; int32_t changes = 0; logln(UnicodeString("-- Zone ") + z->getID(str) + " starts in " + year + " with DST = " + (lastState?"true":"false")); logln(UnicodeString("useDaylightTime = ") + (z->useDaylightTime()?"true":"false")); diff --git a/icu4c/source/test/intltest/tzfmttst.cpp b/icu4c/source/test/intltest/tzfmttst.cpp index d50b6c4a602..d86c9630c0d 100644 --- a/icu4c/source/test/intltest/tzfmttst.cpp +++ b/icu4c/source/test/intltest/tzfmttst.cpp @@ -55,7 +55,7 @@ TimeZoneFormatTest::TestTimeZoneRoundTrip(void) { Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone((UnicodeString)"UTC"), status); if (U_FAILURE(status)) { - errln("Calendar::createInstance failed"); + dataerrln("Calendar::createInstance failed: %s", u_errorName(status)); return; } @@ -448,7 +448,7 @@ TimeZoneFormatTest::TestTimeRoundTrip(void) { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone((UnicodeString) "UTC"), status); if (U_FAILURE(status)) { - errln("Calendar::createInstance failed"); + dataerrln("Calendar::createInstance failed: %s", u_errorName(status)); return; } diff --git a/icu4c/source/test/intltest/tzoffloc.cpp b/icu4c/source/test/intltest/tzoffloc.cpp index 5b0d86f47d4..db3d2e60958 100644 --- a/icu4c/source/test/intltest/tzoffloc.cpp +++ b/icu4c/source/test/intltest/tzoffloc.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2007-2009, International Business Machines Corporation and * +* Copyright (C) 2007-2010, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -121,7 +121,7 @@ TimeZoneOffsetLocalTest::TestGetOffsetAroundTransition() { TimeZone* utc = TimeZone::createTimeZone("UTC"); Calendar* cal = Calendar::createInstance(*utc, status); if (U_FAILURE(status)) { - errln("Calendar::createInstance failed"); + dataerrln("Calendar::createInstance failed: %s", u_errorName(status)); return; } cal->clear(); diff --git a/icu4c/source/test/intltest/tzregts.cpp b/icu4c/source/test/intltest/tzregts.cpp index b4ac1614d1c..187c1922ed5 100644 --- a/icu4c/source/test/intltest/tzregts.cpp +++ b/icu4c/source/test/intltest/tzregts.cpp @@ -139,7 +139,7 @@ void TimeZoneRegressionTest:: Test4073215() GregorianCalendar cal(1997, UCAL_JANUARY, 31, status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); return; } failure(status, "new GregorianCalendar"); @@ -310,7 +310,7 @@ void TimeZoneRegressionTest:: Test4109314() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete testCal; return; } @@ -452,7 +452,7 @@ void TimeZoneRegressionTest:: Test4126678() UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { - errln("Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; return; } @@ -480,6 +480,7 @@ void TimeZoneRegressionTest:: Test4126678() failure(status, "cal->get"); int32_t offset = tz->getOffset((uint8_t)era, year, month, day, (uint8_t)dayOfWeek, millis, status); int32_t raw_offset = tz->getRawOffset(); + if (offset == raw_offset) errln("Offsets should match"); @@ -837,7 +838,7 @@ TimeZoneRegressionTest::Test4162593() UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *fmt = new SimpleDateFormat("z", Locale::getUS(), status); if(U_FAILURE(status)) { - errcheckln(status, "Error creating calendar %s", u_errorName(status)); + dataerrln("Error creating calendar %s", u_errorName(status)); delete fmt; return; } @@ -926,7 +927,10 @@ void TimeZoneRegressionTest::Test4176686() { // Also check DateFormat DateFormat* fmt1 = new SimpleDateFormat(UnicodeString("z"), status); - if(!assertSuccess("trying to construct", status))return; + if (U_FAILURE(status)) { + dataerrln("Failure trying to construct: %s", u_errorName(status)); + return; + } fmt1->setTimeZone(*z1); // Format uses standard zone DateFormat* fmt2 = new SimpleDateFormat(UnicodeString("z"), status); if(!assertSuccess("trying to construct", status))return; diff --git a/icu4c/source/test/intltest/tzrulets.cpp b/icu4c/source/test/intltest/tzrulets.cpp index c879f31d328..ec81e155b69 100644 --- a/icu4c/source/test/intltest/tzrulets.cpp +++ b/icu4c/source/test/intltest/tzrulets.cpp @@ -272,7 +272,12 @@ TimeZoneRuleTest::TestSimpleRuleBasedTimeZone(void) { GregorianCalendar *cal = new GregorianCalendar(status); if (U_FAILURE(status)) { - errln("FAIL: Could not create a Gregorian calendar instance."); + dataerrln("FAIL: Could not create a Gregorian calendar instance.: %s", u_errorName(status)); + delete rbtz1; + delete rbtz2; + delete rbtz3; + delete rbtz1c; + return; } cal->setTimeZone(*rbtz1); cal->clear(); @@ -1316,12 +1321,12 @@ TimeZoneRuleTest::TestTimeZoneRuleCoverage(void) { } b1 = a3->getNextStart(time2, -3*HOUR, 0, FALSE, d1); if (b1) { - errln("FAIL: getNextStart must return FALSE when no start time is available after the base time"); + dataerrln("FAIL: getNextStart must return FALSE when no start time is available after the base time"); } b1 = a3->getFinalStart(-3*HOUR, 0, d1); b2 = a3->getPreviousStart(time2, -3*HOUR, 0, FALSE, d2); if (!b1 || !b2 || d1 != d2) { - errln("FAIL: getPreviousStart does not match with getFinalStart after the end year"); + dataerrln("FAIL: getPreviousStart does not match with getFinalStart after the end year"); } // AnnualTimeZone::isEquavalentTo @@ -1448,11 +1453,11 @@ TimeZoneRuleTest::TestTimeZoneRuleCoverage(void) { // TimeArrayTimeZoneRule::getNextStart/getPreviousStart b1 = t3->getNextStart(time1, -3*HOUR, 1*HOUR, FALSE, d1); if (b1) { - errln("FAIL: getNextStart returned TRUE after the final transition for t3"); + dataerrln("FAIL: getNextStart returned TRUE after the final transition for t3"); } b1 = t3->getPreviousStart(time1, -3*HOUR, 1*HOUR, FALSE, d1); if (!b1 || d1 != trtimes2[1]) { - errln("FAIL: Bad start time returned by getPreviousStart for t3"); + dataerrln("FAIL: Bad start time returned by getPreviousStart for t3"); } else { b2 = t3->getPreviousStart(d1, -3*HOUR, 1*HOUR, FALSE, d2); if (!b2 || d2 != trtimes2[0]) { @@ -1663,11 +1668,11 @@ TimeZoneRuleTest::TestVTimeZoneCoverage(void) { UBool inDst1, inDst2; inDst1 = otz->inDaylightTime(t, status); if (U_FAILURE(status)) { - errln("FAIL: inDaylightTime failed for otz"); + dataerrln("FAIL: inDaylightTime failed for otz: %s", u_errorName(status)); } inDst2 = vtz->inDaylightTime(t, status); if (U_FAILURE(status)) { - errln("FAIL: inDaylightTime failed for vtz"); + dataerrln("FAIL: inDaylightTime failed for vtz: %s", u_errorName(status)); } if (inDst1 != inDst2) { errln("FAIL: inDaylightTime returned different results in VTimeZone and OlsonTimeZone"); @@ -1741,10 +1746,10 @@ TimeZoneRuleTest::TestVTimeZoneCoverage(void) { UDate time2 = getUTCMillis(2020, UCAL_JANUARY, 1); UBool equiv = vtz->hasEquivalentTransitions(*otz, time1, time2, FALSE, status); if (U_FAILURE(status)) { - errln("FAIL: hasEquivalentTransitions failed for vtz/otz"); + dataerrln("FAIL: hasEquivalentTransitions failed for vtz/otz: %s", u_errorName(status)); } if (!equiv) { - errln("FAIL: hasEquivalentTransitons returned false for the same time zone"); + dataerrln("FAIL: hasEquivalentTransitons returned false for the same time zone"); } // operator=/operator==/operator!= @@ -2053,7 +2058,7 @@ TimeZoneRuleTest::TestT6216(void) { TimeZone *utc = TimeZone::createTimeZone("Etc/GMT"); GregorianCalendar cal(utc, status); if (U_FAILURE(status)) { - errln("FAIL: Failed to creat a GregorianCalendar"); + dataerrln("FAIL: Failed to creat a GregorianCalendar: %s", u_errorName(status)); return; } for (i = 0; TestDates[i][2] != 0; i++) { @@ -2249,7 +2254,7 @@ TimeZoneRuleTest::getUTCMillis(int32_t y, int32_t m, int32_t d, Calendar *cal = Calendar::createInstance(*tz, status); if (U_FAILURE(status)) { delete cal; - errln("FAIL: Calendar::createInstance failed"); + dataerrln("FAIL: Calendar::createInstance failed: %s", u_errorName(status)); return 0.0; } cal->set(y, m, d, hr, min, sec); diff --git a/icu4c/source/test/intltest/tztest.cpp b/icu4c/source/test/intltest/tztest.cpp index 10ab4565b05..06686050a86 100644 --- a/icu4c/source/test/intltest/tztest.cpp +++ b/icu4c/source/test/intltest/tztest.cpp @@ -1,6 +1,6 @@ /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2009, International Business Machines Corporation + * Copyright (c) 1997-2010, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -165,7 +165,7 @@ TimeZoneTest::TestRuleAPI() // Establish our expected transition times. Do this with a non-DST // calendar with the (above) declared local offset. GregorianCalendar *gc = new GregorianCalendar(*zone, status); - if (failure(status, "new GregorianCalendar")) return; + if (failure(status, "new GregorianCalendar", TRUE)) return; gc->clear(); gc->set(1990, UCAL_MARCH, 1); UDate marchOneStd = gc->getTime(status); // Local Std time midnight @@ -335,7 +335,7 @@ TimeZoneTest::TestVariousAPI518() UnicodeString str; logln("The timezone is " + time_zone->getID(str)); if (!time_zone->inDaylightTime(d, status)) dataerrln("FAIL: inDaylightTime returned FALSE"); - if (U_FAILURE(status)) { errln("FAIL: TimeZone::inDaylightTime failed"); return; } + if (failure(status, "TimeZone::inDaylightTime", TRUE)) return; if (!time_zone->useDaylightTime()) dataerrln("FAIL: useDaylightTime returned FALSE"); if (time_zone->getRawOffset() != - 8 * millisPerHour) dataerrln("FAIL: getRawOffset returned wrong value"); GregorianCalendar *gc = new GregorianCalendar(status); @@ -1250,7 +1250,7 @@ TimeZoneTest::TestDisplayName() logln(UnicodeString("Modified PST inDaylightTime->") + inDaylight ); if(U_FAILURE(status)) { - errln("Some sort of error..." + UnicodeString(u_errorName(status))); // REVISIT + dataerrln("Some sort of error..." + UnicodeString(u_errorName(status))); // REVISIT } name.remove(); name = zone2->getDisplayName(Locale::getEnglish(),name); @@ -1276,7 +1276,7 @@ TimeZoneTest::TestDisplayName() ResourceBundle enRB(NULL, Locale::getEnglish(), status); if(U_FAILURE(status)) - errcheckln(status, "Couldn't get ResourceBundle for en - %s", u_errorName(status)); + dataerrln("Couldn't get ResourceBundle for en - %s", u_errorName(status)); ResourceBundle mtRB(NULL, mt_MT, status); @@ -1663,7 +1663,7 @@ void TimeZoneTest::TestFebruary() { // Gregorian calendar with the UTC time zone for getting sample test date/times. GregorianCalendar gc(*TimeZone::getGMT(), status); if (U_FAILURE(status)) { - errln("Unable to create the UTC calendar: %s", u_errorName(status)); + dataerrln("Unable to create the UTC calendar: %s", u_errorName(status)); return; } @@ -1925,7 +1925,7 @@ static struct { void TimeZoneTest::TestDisplayNamesMeta() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar cal(*TimeZone::getGMT(), status); - if (failure(status, "GregorianCalendar")) return; + if (failure(status, "GregorianCalendar", TRUE)) return; UBool isReferenceYear = TRUE; if (cal.get(UCAL_YEAR, status) != TimeZoneTest::REFERENCE_YEAR) { diff --git a/icu4c/source/test/intltest/ucdtest.cpp b/icu4c/source/test/intltest/ucdtest.cpp index 9ab420d7e29..9cb3d887fc9 100644 --- a/icu4c/source/test/intltest/ucdtest.cpp +++ b/icu4c/source/test/intltest/ucdtest.cpp @@ -244,9 +244,9 @@ void UnicodeTest::TestAdditionalProperties() { end=derivedProps[i].getRangeEnd(range); for(; start<=end; ++start) { if(!u_hasBinaryProperty(start, derivedPropsIndex[i])) { - errln("UnicodeTest error: u_hasBinaryProperty(U+%04lx, %s)==FALSE is wrong\n", start, derivedPropsNames[i]); + dataerrln("UnicodeTest error: u_hasBinaryProperty(U+%04lx, %s)==FALSE is wrong", start, derivedPropsNames[i]); if(++numErrors[i]>=MAX_ERRORS) { - errln("Too many errors, moving to the next test"); + dataerrln("Too many errors, moving to the next test"); break; } } diff --git a/icu4c/source/test/intltest/uobjtest.cpp b/icu4c/source/test/intltest/uobjtest.cpp index 5278c17a428..d0b011ed5ac 100644 --- a/icu4c/source/test/intltest/uobjtest.cpp +++ b/icu4c/source/test/intltest/uobjtest.cpp @@ -34,7 +34,7 @@ */ -#define TESTCLASSID_FACTORY(c, f) { delete testClass(f, #c, #f, c ::getStaticClassID()); if(U_FAILURE(status)) { errcheckln(status, UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); status = U_ZERO_ERROR; } } +#define TESTCLASSID_FACTORY(c, f) { delete testClass(f, #c, #f, c ::getStaticClassID()); if(U_FAILURE(status)) { dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); status = U_ZERO_ERROR; } } #define TESTCLASSID_TRANSLIT(c, t) { delete testClass(Transliterator::createInstance(UnicodeString(t), UTRANS_FORWARD,parseError,status), #c, "Transliterator: " #t, c ::getStaticClassID()); if(U_FAILURE(status)) { dataerrln(UnicodeString(#c " - Transliterator: " #t " - got err status ") + UnicodeString(u_errorName(status))); status = U_ZERO_ERROR; } } #define TESTCLASSID_CTOR(c, x) { delete testClass(new c x, #c, "new " #c #x, c ::getStaticClassID()); if(U_FAILURE(status)) { dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); status = U_ZERO_ERROR; } } #define TESTCLASSID_DEFAULT(c) delete testClass(new c, #c, "new " #c , c::getStaticClassID()) diff --git a/icu4c/source/tools/ctestfw/tstdtmod.cpp b/icu4c/source/tools/ctestfw/tstdtmod.cpp index a7f7f6eae10..27e3cbeb4e2 100644 --- a/icu4c/source/tools/ctestfw/tstdtmod.cpp +++ b/icu4c/source/tools/ctestfw/tstdtmod.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2009, International Business Machines Corporation and + * Copyright (c) 2002-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -38,11 +38,35 @@ UBool IcuTestErrorCode::logIfFailureAndReset(const char *fmt, ...) { } } +UBool IcuTestErrorCode::logDataIfFailureAndReset(const char *fmt, ...) { + if(isFailure()) { + char buffer[4000]; + va_list ap; + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + va_end(ap); + UnicodeString msg(testName, -1, US_INV); + msg.append(UNICODE_STRING_SIMPLE(" failure: ")).append(UnicodeString(errorName(), -1, US_INV)); + msg.append(UNICODE_STRING_SIMPLE(" - ")).append(UnicodeString(buffer, -1, US_INV)); + testClass.dataerrln(msg); + reset(); + return TRUE; + } else { + reset(); + return FALSE; + } +} + void IcuTestErrorCode::handleFailure() const { // testClass.errln("%s failure - %s", testName, errorName()); UnicodeString msg(testName, -1, US_INV); msg.append(UNICODE_STRING_SIMPLE(" failure: ")).append(UnicodeString(errorName(), -1, US_INV)); - testClass.errln(msg); + + if (get() == U_MISSING_RESOURCE_ERROR) { + testClass.dataerrln(msg); + } else { + testClass.errln(msg); + } } TestDataModule *TestDataModule::getTestDataModule(const char* name, TestLog& log, UErrorCode &status) diff --git a/icu4c/source/tools/ctestfw/unicode/testlog.h b/icu4c/source/tools/ctestfw/unicode/testlog.h index f31377ede19..6a6e0678b42 100644 --- a/icu4c/source/tools/ctestfw/unicode/testlog.h +++ b/icu4c/source/tools/ctestfw/unicode/testlog.h @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2004-2009, International Business Machines Corporation and + * Copyright (c) 2004-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -35,6 +35,7 @@ public: virtual ~IcuTestErrorCode(); // Returns TRUE if isFailure(). UBool logIfFailureAndReset(const char *fmt, ...); + UBool logDataIfFailureAndReset(const char *fmt, ...); protected: virtual void handleFailure() const; private: