diff --git a/icu4c/source/i18n/bms.cpp b/icu4c/source/i18n/bms.cpp index 99a45896c78..0a1de08b6fc 100644 --- a/icu4c/source/i18n/bms.cpp +++ b/icu4c/source/i18n/bms.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2009, International Business Machines Corporation and Others. + * Copyright (C) 2008-2011, International Business Machines Corporation and Others. * All rights reserved. */ @@ -34,9 +34,11 @@ ucd_open(UCollator *coll, UErrorCode *status) U_CAPI void U_EXPORT2 ucd_close(UCD *ucd) { - CollData *data = STATIC_CAST(CollData *, ucd); + if (ucd != NULL) { + CollData *data = STATIC_CAST(CollData *, ucd); - CollData::close(data); + CollData::close(data); + } } U_CAPI UCollator * U_EXPORT2 diff --git a/icu4c/source/test/cintltst/ccaltst.c b/icu4c/source/test/cintltst/ccaltst.c index dd3917b5d5b..ab6c9aee71b 100644 --- a/icu4c/source/test/cintltst/ccaltst.c +++ b/icu4c/source/test/cintltst/ccaltst.c @@ -154,7 +154,7 @@ static void TestCalendar() break; } if (U_FAILURE(status)) { - log_err("FAIL: %s failed with %s", api, + log_err_status(status, "FAIL: %s failed with %s\n", api, u_errorName(status)); } else { const char* id; @@ -1607,6 +1607,9 @@ static void TestWeekend() { UDateFormat * fmt = udat_open(UDAT_NONE, UDAT_NONE, "en", NULL, 0, NULL, 0, &fmtStatus); if (U_SUCCESS(fmtStatus)) { udat_applyPattern(fmt, FALSE, logDateFormat, -1); + } else { + log_data_err("Unable to create UDateFormat - %s\n", u_errorName(fmtStatus)); + return; } for (count = sizeof(testDates)/sizeof(testDates[0]); count-- > 0; ++testDatesPtr) { UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/test/cintltst/citertst.c b/icu4c/source/test/cintltst/citertst.c index df66e4fb9aa..acb7a3d3801 100644 --- a/icu4c/source/test/cintltst/citertst.c +++ b/icu4c/source/test/cintltst/citertst.c @@ -2151,7 +2151,7 @@ static void TestSearchCollatorElements(void) } ucol_close(ucol); } else { - log_err("error, locale %s, ucol_open failed: %s\n", tsceItemPtr->locale, u_errorName(status) ); + log_data_err("error, locale %s, ucol_open failed: %s\n", tsceItemPtr->locale, u_errorName(status) ); } } } diff --git a/icu4c/source/test/cintltst/cldrtest.c b/icu4c/source/test/cintltst/cldrtest.c index 3a566695667..5a7f9559cf7 100644 --- a/icu4c/source/test/cintltst/cldrtest.c +++ b/icu4c/source/test/cintltst/cldrtest.c @@ -1249,7 +1249,7 @@ static void TestIndexChars(void) { ulocdata_getExemplarSet(uld, exemplarChars, 0, ULOCDATA_ES_STANDARD, &status); ulocdata_getExemplarSet(uld, indexChars, 0, ULOCDATA_ES_INDEX, &status); if (U_FAILURE(status)) { - log_err("File %s, line %d, Failure opening exemplar chars: %s", __FILE__, __LINE__, u_errorName(status)); + log_data_err("File %s, line %d, Failure opening exemplar chars: %s", __FILE__, __LINE__, u_errorName(status)); goto close_sets; } /* en data, standard exemplars are [a-z], lower case. */ diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 9bd61893cad..44e9c858db7 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2010, International Business Machines Corporation and + * Copyright (c) 1997-2011, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************* @@ -2985,9 +2985,8 @@ TestConsistency() { while(start<=end) { length=u_charName(start, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); if(U_FAILURE(errorCode)) { - log_err("error getting the name of U+%04x - %s\n", start, u_errorName(errorCode)); + log_data_err("error getting the name of U+%04x - %s\n", start, u_errorName(errorCode)); errorCode=U_ZERO_ERROR; - continue; } if( (strstr(buffer, "SMALL")==NULL || strstr(buffer, "CAPITAL")!=NULL) && strstr(buffer, "SMALL CAPITAL")==NULL diff --git a/icu4c/source/test/cintltst/nucnvtst.c b/icu4c/source/test/cintltst/nucnvtst.c index 38ffc41c2d3..1d3adee2771 100644 --- a/icu4c/source/test/cintltst/nucnvtst.c +++ b/icu4c/source/test/cintltst/nucnvtst.c @@ -5566,22 +5566,26 @@ TestIsFixedWidth() { for (i = 0; i < fixedWidthLength; i++) { cnv = ucnv_open(fixedWidth[i], &status); if (cnv == NULL || U_FAILURE(status)) { - log_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status)); + log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status)); + continue; } if (!ucnv_isFixedWidth(cnv, &status)) { log_err("%s is a fixedWidth converter but returned FALSE.\n", fixedWidth[i]); } + ucnv_close(cnv); } for (i = 0; i < notFixedWidthLength; i++) { cnv = ucnv_open(notFixedWidth[i], &status); if (cnv == NULL || U_FAILURE(status)) { - log_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status)); + log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status)); + continue; } if (ucnv_isFixedWidth(cnv, &status)) { log_err("%s is NOT a fixedWidth converter but returned TRUE.\n", fixedWidth[i]); } + ucnv_close(cnv); } } diff --git a/icu4c/source/test/cintltst/usrchtst.c b/icu4c/source/test/cintltst/usrchtst.c index 06d672c6962..816b781a221 100644 --- a/icu4c/source/test/cintltst/usrchtst.c +++ b/icu4c/source/test/cintltst/usrchtst.c @@ -2711,7 +2711,7 @@ static void TestUsingSearchCollator(void) } ucol_close(ucol); } else { - log_err("error, locale %s, ucol_open failed: %s\n", tuscItemPtr->locale, u_errorName(status) ); + log_data_err("error, locale %s, ucol_open failed: %s\n", tuscItemPtr->locale, u_errorName(status) ); } } } diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index cfae8a49443..0c3ad2b606b 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -83,7 +83,7 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* & CASE(44,TestDeprecates); CASE(45,TestT5555); CASE(46,TestT6745); - CASE(47,TestT8057); + CASE(47,TestT8057); default: name = ""; break; } } @@ -217,6 +217,10 @@ CalendarRegressionTest::test4031502() // require the host zone to be set; it can be set in Java. UErrorCode status = U_ZERO_ERROR; StringEnumeration* ids = TimeZone::createEnumeration(); + if (ids == NULL) { + dataerrln("Unable to create TimeZone Enumeration."); + return; + } UBool bad = FALSE; TimeZone* tz =TimeZone::createTimeZone("Asia/Riyadh87"); failure(status, "new TimeZone"); @@ -281,6 +285,10 @@ void CalendarRegressionTest::test4040996() { int32_t count = 0; StringEnumeration* ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000); + if (ids == NULL) { + dataerrln("Unable to create TimeZone enumeration."); + return; + } UErrorCode status = U_ZERO_ERROR; count = ids->count(status); SimpleTimeZone *pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, *ids->snext(status)); @@ -2590,7 +2598,7 @@ void CalendarRegressionTest::TestTimeZoneTransitionAdd() { StringEnumeration *tz = TimeZone::createEnumeration(); if (tz == NULL) { - errln("FAIL: TimeZone::createEnumeration"); + dataerrln("FAIL: TimeZone::createEnumeration"); return; } @@ -2793,7 +2801,7 @@ void CalendarRegressionTest::TestT8057(void) { t = cal->getTime(status); if (U_SUCCESS(status)) { if (t != expected) { - errln((UnicodeString)"FAIL: wrong date after add: expected=" + expected + " returned=" + t); + dataerrln((UnicodeString)"FAIL: wrong date after add: expected=" + expected + " returned=" + t); } } else { errln("FAIL: error while adding one year"); diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index b418fc736d6..38b39d2995c 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -1,6 +1,6 @@ /************************************************************************ * COPYRIGHT: - * Copyright (c) 1997-2010, International Business Machines Corporation + * Copyright (c) 1997-2011, International Business Machines Corporation * and others. All Rights Reserved. ************************************************************************/ @@ -1307,7 +1307,7 @@ CalendarTest::TestEpochStartFields() if (U_FAILURE(status)) { errln("Calendar::setTime failed"); return; } for (int32_t i = 0; i < UCAL_ZONE_OFFSET;++i) { if (c->get((UCalendarDateFields)i, status) != EPOCH_FIELDS[i]) - errln(UnicodeString("Expected field ") + i + " to have value " + EPOCH_FIELDS[i] + + dataerrln(UnicodeString("Expected field ") + i + " to have value " + EPOCH_FIELDS[i] + "; saw " + c->get((UCalendarDateFields)i, status) + " instead"); if (U_FAILURE(status)) { errln("Calendar::get failed"); return; } } diff --git a/icu4c/source/test/intltest/csdetest.cpp b/icu4c/source/test/intltest/csdetest.cpp index cbc18452fa4..77c3bcc8cb1 100644 --- a/icu4c/source/test/intltest/csdetest.cpp +++ b/icu4c/source/test/intltest/csdetest.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (C) 2005-2009, International Business Machines + * Copyright (C) 2005-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ @@ -161,7 +161,7 @@ void CharsetDetectionTest::checkEncoding(const UnicodeString &testString, const if (bytes == NULL) { #if !UCONFIG_NO_LEGACY_CONVERSION - errln("Can't open a " + encoding + " converter for " + id); + dataerrln("Can't open a " + encoding + " converter for " + id); #endif return; } diff --git a/icu4c/source/test/intltest/dcfmtest.cpp b/icu4c/source/test/intltest/dcfmtest.cpp index 00b1b6fe633..2337f8a7920 100644 --- a/icu4c/source/test/intltest/dcfmtest.cpp +++ b/icu4c/source/test/intltest/dcfmtest.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2010, International Business Machines Corporation and + * Copyright (c) 2002-2011, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -234,7 +234,7 @@ void DecimalFormatTest::DataDrivenTests() { while (lineMat.find()) { lineNum++; if (U_FAILURE(status)) { - errln("File dcfmtest.txt, line %d: ICU Error \"%s\"", lineNum, u_errorName(status)); + dataerrln("File dcfmtest.txt, line %d: ICU Error \"%s\"", lineNum, u_errorName(status)); } status = U_ZERO_ERROR; @@ -312,7 +312,7 @@ void DecimalFormatTest::execParseTest(int32_t lineNum, DecimalFormat format(pattern, symbols, status); Formattable result; if (U_FAILURE(status)) { - errln("file dcfmtest.txt, line %d: %s error creating the formatter.", + dataerrln("file dcfmtest.txt, line %d: %s error creating the formatter.", lineNum, u_errorName(status)); return; } @@ -377,7 +377,7 @@ void DecimalFormatTest::execFormatTest(int32_t lineNum, // printf("Pattern = %s\n", UnicodeStringPiece(pattern).data()); DecimalFormat fmtr(pattern, symbols, status); if (U_FAILURE(status)) { - errln("file dcfmtest.txt, line %d: %s error creating the formatter.", + dataerrln("file dcfmtest.txt, line %d: %s error creating the formatter.", lineNum, u_errorName(status)); return; } diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index 924afbac959..e3398ff59eb 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2010, International Business Machines + * Copyright (c) 1997-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************/ @@ -111,6 +111,13 @@ void DateFormatTest::TestWallyWedel() */ int32_t ids_length; StringEnumeration* ids = TimeZone::createEnumeration(); + if (ids == NULL) { + dataerrln("Unable to create TimeZone enumeration."); + if (sdf != NULL) { + delete sdf; + } + return; + } ids_length = ids->count(status); /* * How many ids do we have? @@ -1042,7 +1049,7 @@ DateFormatTest::TestDateFormatZone146() if (testtimezone == "GMT") logln("Test timezone = " + testtimezone); else - errln("Test timezone should be GMT, not " + testtimezone); + dataerrln("Test timezone should be GMT, not " + testtimezone); UErrorCode status = U_ZERO_ERROR; // now try to use the default GMT time zone @@ -3365,7 +3372,12 @@ void DateFormatTest::TestISOEra() { // create formatter SimpleDateFormat *fmt1 = new SimpleDateFormat(UnicodeString("GGG yyyy-MM-dd'T'HH:mm:ss'Z"), status); failure(status, "new SimpleDateFormat", TRUE); - + if (status == U_MISSING_RESOURCE_ERROR) { + if (fmt1 != NULL) { + delete fmt1; + } + return; + } for(int i=0; i < numData; i+=2) { // create input string UnicodeString in = data[i]; @@ -3417,7 +3429,7 @@ void DateFormatTest::TestFormalChineseDate() { UnicodeString parsedres,expres; usf->format(parsedate,parsedres,pos); usf->format(thedate,expres,pos); - errln((UnicodeString)"FAIL: parsed -> " + parsedres + " expected -> " + expres); + dataerrln((UnicodeString)"FAIL: parsed -> " + parsedres + " expected -> " + expres); delete usf; } delete sdf; diff --git a/icu4c/source/test/intltest/itutil.cpp b/icu4c/source/test/intltest/itutil.cpp index 38e1a925f91..3e30f05857b 100644 --- a/icu4c/source/test/intltest/itutil.cpp +++ b/icu4c/source/test/intltest/itutil.cpp @@ -322,7 +322,7 @@ void LocalPointerTest::TestLocalXyzPointer() { } LocalUDateTimePatternGeneratorPointer patgen(udatpg_open("root", errorCode)); - if(errorCode.logIfFailureAndReset("udatpg_open()")) { + if(errorCode.logDataIfFailureAndReset("udatpg_open()")) { return; } if(patgen.isNull()) { diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 78506eba44c..91909bb418d 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -6250,7 +6250,7 @@ void NumberFormatTest::TestExplicitParents() { uloc_canonicalize(localeID, loc, 256, &status); NumberFormat *fmt= NumberFormat::createInstance(Locale(loc), status); if(U_FAILURE(status)){ - errln("Could not create number formatter for locale %s",localeID); + dataerrln("Could not create number formatter for locale %s - %s",localeID, u_errorName(status)); continue; } s.remove(); diff --git a/icu4c/source/test/intltest/numrgts.cpp b/icu4c/source/test/intltest/numrgts.cpp index 3d864ba0300..9f6cbea8a2f 100644 --- a/icu4c/source/test/intltest/numrgts.cpp +++ b/icu4c/source/test/intltest/numrgts.cpp @@ -2709,6 +2709,10 @@ void NumberFormatRegressionTest::TestJ691(void) { void NumberFormatRegressionTest::Test8199(void) { UErrorCode status = U_ZERO_ERROR; NumberFormat *nf = NumberFormat::createInstance(Locale::getEnglish(), status); + if (nf == NULL) { + dataerrln("Fail: NumberFormat::createInstance(Locale::getEnglish(), status)"); + return; + } TEST_CHECK_STATUS(status); // Note: Retrieving parsed values from a Formattable as a reduced-precision type diff --git a/icu4c/source/test/intltest/rbbitst.cpp b/icu4c/source/test/intltest/rbbitst.cpp index 2759fdf2ff3..c57c667c3b4 100644 --- a/icu4c/source/test/intltest/rbbitst.cpp +++ b/icu4c/source/test/intltest/rbbitst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1999-2010, International Business Machines Corporation and + * Copyright (c) 1999-2011, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /************************************************************************ @@ -1793,7 +1793,7 @@ void RBBITest::TestExtended() { if (U_FAILURE(status)) { - errln("ICU Error %s while parsing test file at line %d.", + dataerrln("ICU Error %s while parsing test file at line %d.", u_errorName(status), lineNum); status = U_ZERO_ERROR; goto end_test; // Stop the test diff --git a/icu4c/source/test/intltest/regextst.cpp b/icu4c/source/test/intltest/regextst.cpp index ee985498025..866dc72c6f7 100644 --- a/icu4c/source/test/intltest/regextst.cpp +++ b/icu4c/source/test/intltest/regextst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2010, International Business Machines Corporation and + * Copyright (c) 2002-2011, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -3205,7 +3205,7 @@ void RegexTest::regex_find(const UnicodeString &pattern, goto cleanupAndReturn; } else { // Unexpected pattern compilation error. - errln("Line %d: error %s compiling pattern.", line, u_errorName(status)); + dataerrln("Line %d: error %s compiling pattern.", line, u_errorName(status)); goto cleanupAndReturn; } } @@ -3441,7 +3441,7 @@ void RegexTest::regex_find(const UnicodeString &pattern, // G option in test means that capture group data is not available in the // expected results, so the check needs to be suppressed. if (isMatch == FALSE && groupStarts.size() != 0) { - errln("Error at line %d: Match expected, but none found.", line); + dataerrln("Error at line %d: Match expected, but none found.", line); failed = TRUE; goto cleanupAndReturn; } else if (UTF8Matcher != NULL && isUTF8Match == FALSE && groupStarts.size() != 0) { diff --git a/icu4c/source/test/intltest/transrt.cpp b/icu4c/source/test/intltest/transrt.cpp index c639c2b1f5f..fc3a22f5d28 100644 --- a/icu4c/source/test/intltest/transrt.cpp +++ b/icu4c/source/test/intltest/transrt.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2000-2010, International Business Machines +* Copyright (C) 2000-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -566,7 +566,7 @@ void RTTest::test2(UBool quickRt, int32_t density) { Transliterator::createInstance(transliteratorID, UTRANS_FORWARD, parseError, status)); if ((Transliterator *)sourceToTarget == NULL) { - parent->errln("FAIL: createInstance(" + transliteratorID + + parent->dataerrln("FAIL: createInstance(" + transliteratorID + ") returned NULL. Error: " + u_errorName(status) + "\n\tpreContext : " + prettify(parseError.preContext) + "\n\tpostContext : " + prettify(parseError.postContext)); diff --git a/icu4c/source/test/intltest/transtst.cpp b/icu4c/source/test/intltest/transtst.cpp index 42a061f070d..e2fd290b7cd 100644 --- a/icu4c/source/test/intltest/transtst.cpp +++ b/icu4c/source/test/intltest/transtst.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1999-2010, International Business Machines +* Copyright (C) 1999-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -3905,7 +3905,7 @@ void TransliteratorTest::TestAny(void) { Transliterator* anyLatin = Transliterator::createInstance("Any-Latin", UTRANS_FORWARD, parseError, status); if (U_FAILURE(status)) { - errln("Failure: file %s, line %d, status = %s", __FILE__, __LINE__, u_errorName(status)); + dataerrln("Failure: file %s, line %d, status = %s", __FILE__, __LINE__, u_errorName(status)); return; } @@ -4011,7 +4011,7 @@ void TransliteratorTest::TestAllCodepoints(){ for(uint32_t i = 0; i<=0x10ffff; i++){ code = uscript_getScript(i,&status); if(code == USCRIPT_INVALID_CODE){ - errln("uscript_getScript for codepoint \\U%08X failed.\n", i); + dataerrln("uscript_getScript for codepoint \\U%08X failed.", i); } const char* myId = uscript_getName(code); if(!myId) { @@ -4032,14 +4032,14 @@ void TransliteratorTest::TestAllCodepoints(){ if(uprv_strcmp(newId,oldId)!=0){ Transliterator* t = Transliterator::createInstance(newId,UTRANS_FORWARD,pe,status); if(t==NULL || U_FAILURE(status)){ - errln((UnicodeString)"FAIL: Could not create " + id); + dataerrln((UnicodeString)"FAIL: Could not create " + id + " - " + u_errorName(status)); } delete t; } if(uprv_strcmp(newAbbrId,oldAbbrId)!=0){ Transliterator* t = Transliterator::createInstance(newAbbrId,UTRANS_FORWARD,pe,status); if(t==NULL || U_FAILURE(status)){ - errln((UnicodeString)"FAIL: Could not create " + id); + dataerrln((UnicodeString)"FAIL: Could not create " + id + " - " + u_errorName(status)); } delete t; } diff --git a/icu4c/source/test/intltest/tzregts.cpp b/icu4c/source/test/intltest/tzregts.cpp index 0f068174ecc..89e73f9be4c 100644 --- a/icu4c/source/test/intltest/tzregts.cpp +++ b/icu4c/source/test/intltest/tzregts.cpp @@ -1,5 +1,5 @@ /******************************************************************** - * Copyright (c) 1997-2010, International Business Machines + * Copyright (c) 1997-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************/ @@ -482,7 +482,7 @@ void TimeZoneRegressionTest:: Test4126678() int32_t raw_offset = tz->getRawOffset(); if (offset == raw_offset) - errln("Offsets should match"); + dataerrln("Offsets should match"); delete cal; } @@ -506,6 +506,10 @@ void TimeZoneRegressionTest:: Test4151406() { UErrorCode ec = U_ZERO_ERROR; int32_t count; StringEnumeration* ids = TimeZone::createEnumeration(rawoffset); + if (ids == NULL) { + dataerrln("Fail: TimeZone::createEnumeration(rawoffset)"); + continue; + } count = ids->count(ec); if (count> max) max = count; diff --git a/icu4c/source/test/intltest/tztest.cpp b/icu4c/source/test/intltest/tztest.cpp index 539ac0bb7db..065d2fc4626 100644 --- a/icu4c/source/test/intltest/tztest.cpp +++ b/icu4c/source/test/intltest/tztest.cpp @@ -415,6 +415,10 @@ TimeZoneTest::TestGetAvailableIDs913() UnicodeString *buf = new UnicodeString("TimeZone::createEnumeration() = { "); int32_t s_length; StringEnumeration* s = TimeZone::createEnumeration(); + if (s == NULL) { + dataerrln("Unable to create TimeZone enumeration"); + return; + } s_length = s->count(ec); for (i = 0; i < s_length;++i) { if (i > 0) *buf += ", "; @@ -526,9 +530,11 @@ TimeZoneTest::TestGetAvailableIDsNew() char region[4]; int32_t zoneCount; + any = canonical = canonicalLoc = any_US = canonical_US = canonicalLoc_US = any_W5 = any_CA_W5 = any_US_E14 = NULL; + any = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_ANY, NULL, NULL, ec); if (U_FAILURE(ec)) { - errln("Failed to create enumration for ANY"); + dataerrln("Failed to create enumration for ANY"); goto cleanup; } @@ -1709,6 +1715,10 @@ void TimeZoneTest::TestCountries() { UErrorCode ec = U_ZERO_ERROR; int32_t n; StringEnumeration* s = TimeZone::createEnumeration("US"); + if (s == NULL) { + dataerrln("Unable to create TimeZone enumeration for US"); + return; + } n = s->count(ec); UBool la = FALSE, tokyo = FALSE; UnicodeString laZone("America/Los_Angeles", ""); @@ -2005,6 +2015,10 @@ void TimeZoneTest::TestCanonicalID() { UErrorCode ec = U_ZERO_ERROR; int32_t s_length, i, j, k; StringEnumeration* s = TimeZone::createEnumeration(); + if (s == NULL) { + dataerrln("Unable to create TimeZone enumeration"); + return; + } UnicodeString canonicalID, tmpCanonical; s_length = s->count(ec); for (i = 0; i < s_length;++i) { @@ -2246,7 +2260,7 @@ void TimeZoneTest::TestGetRegion() } } else if (sts == U_ILLEGAL_ARGUMENT_ERROR) { if (data[i].region != 0) { - errln((UnicodeString)"Fail: getRegion(\"" + data[i].id + dataerrln((UnicodeString)"Fail: getRegion(\"" + data[i].id + "\") returns error status U_ILLEGAL_ARGUMENT_ERROR [expected: " + data[i].region + "]"); } @@ -2262,25 +2276,33 @@ void TimeZoneTest::TestGetRegion() sts = U_ZERO_ERROR; len = TimeZone::getRegion("America/New_York", region2, sizeof(region2), sts); - if (sts != U_STRING_NOT_TERMINATED_WARNING) { - errln("Expected U_STRING_NOT_TERMINATED_WARNING"); - } - if (len != 2) { // length of "US" - errln("Incorrect result length"); - } - if (uprv_strncmp(region2, "US", 2) != 0) { - errln("Incorrect result"); + if (sts == U_ILLEGAL_ARGUMENT_ERROR) { + dataerrln("Error calling TimeZone::getRegion"); + } else { + if (sts != U_STRING_NOT_TERMINATED_WARNING) { + errln("Expected U_STRING_NOT_TERMINATED_WARNING"); + } + if (len != 2) { // length of "US" + errln("Incorrect result length"); + } + if (uprv_strncmp(region2, "US", 2) != 0) { + errln("Incorrect result"); + } } char region1[1]; sts = U_ZERO_ERROR; len = TimeZone::getRegion("America/Chicago", region1, sizeof(region1), sts); - if (sts != U_BUFFER_OVERFLOW_ERROR) { - errln("Expected U_BUFFER_OVERFLOW_ERROR"); - } - if (len != 2) { // length of "US" - errln("Incorrect result length"); + if (sts == U_ILLEGAL_ARGUMENT_ERROR) { + dataerrln("Error calling TimeZone::getRegion"); + } else { + if (sts != U_BUFFER_OVERFLOW_ERROR) { + errln("Expected U_BUFFER_OVERFLOW_ERROR"); + } + if (len != 2) { // length of "US" + errln("Incorrect result length"); + } } } #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/tools/ctestfw/ctest.c b/icu4c/source/tools/ctestfw/ctest.c index 1336967a2fc..c1eb0de8d6a 100644 --- a/icu4c/source/tools/ctestfw/ctest.c +++ b/icu4c/source/tools/ctestfw/ctest.c @@ -1,7 +1,7 @@ /* ******************************************************************************** * -* Copyright (C) 1996-2010, International Business Machines +* Copyright (C) 1996-2011, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************** @@ -766,27 +766,28 @@ log_err_status(UErrorCode status, const char* pattern, ...) va_list ap; va_start(ap, pattern); - first_line_err(); if ((status == U_FILE_ACCESS_ERROR || status == U_MISSING_RESOURCE_ERROR)) { ++DATA_ERROR_COUNT; /* for informational message at the end */ if (WARN_ON_MISSING_DATA == 0) { + first_line_err(); /* Fatal error. */ if (strchr(pattern, '\n') != NULL) { ++ERROR_COUNT; } else { - ++ONE_ERROR; + ++ONE_ERROR; } vlog_err(NULL, pattern, ap); /* no need for prefix in default case */ } else { vlog_info("[DATA] ", pattern, ap); } } else { + first_line_err(); /* Fatal error. */ if(strchr(pattern, '\n') != NULL) { ++ERROR_COUNT; } else { - ++ONE_ERROR; + ++ONE_ERROR; } vlog_err(NULL, pattern, ap); /* no need for prefix in default case */ }