]> granicus.if.org Git - icu/commitdiff
ICU-8553 Ensure cintltst and intltest passes gracefully with warning without data...
authorMichael Ow <mow@svn.icu-project.org>
Tue, 10 May 2011 22:01:46 +0000 (22:01 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Tue, 10 May 2011 22:01:46 +0000 (22:01 +0000)
X-SVN-Rev: 30088

14 files changed:
icu4c/source/test/cintltst/ccaltst.c
icu4c/source/test/cintltst/cdateintervalformattest.c
icu4c/source/test/cintltst/cldrtest.c
icu4c/source/test/cintltst/cloctst.c
icu4c/source/test/cintltst/cnumtst.c
icu4c/source/test/cintltst/cpluralrulestest.c
icu4c/source/test/cintltst/usrchtst.c
icu4c/source/test/intltest/dtfmttst.cpp
icu4c/source/test/intltest/msfmrgts.cpp
icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/plurfmts.cpp
icu4c/source/test/intltest/rbbiapts.cpp
icu4c/source/test/intltest/tmsgfmt.cpp
icu4c/source/test/intltest/tzfmttst.cpp

index a6b6367aa3b2950c8455719ea5f84f2c3bf61023..f0ae5b175af54199957b6c8440fa68baf32706c0 100644 (file)
@@ -1733,7 +1733,7 @@ void TestFieldDifference() {
                         dDf !=  tfdItemPtr->dDiff ||
                         HDf !=  tfdItemPtr->HDiff ||
                         mDf !=  tfdItemPtr->mDiff ) {
-                log_err("FAIL: for locale \"%s\", start %.1f, target %.1f, expected y-M-d-H-m diffs %d-%d-%d-%d-%d, got %d-%d-%d-%d-%d\n",
+                log_data_err("FAIL: for locale \"%s\", start %.1f, target %.1f, expected y-M-d-H-m diffs %d-%d-%d-%d-%d, got %d-%d-%d-%d-%d\n",
                         tfdItemPtr->locale, tfdItemPtr->start, tfdItemPtr->target,
                         tfdItemPtr->yDiff, tfdItemPtr->MDiff, tfdItemPtr->dDiff, tfdItemPtr->HDiff, tfdItemPtr->mDiff, yDf, MDf, dDf, HDf, mDf);
             }
index a6ec9dd3a51e94337d7411ce969ea1c1db84c00a..5975f1cc5c44ae903f0f0e9517b8644fbc8c0583 100644 (file)
@@ -107,7 +107,7 @@ static void TestDateIntervalFormat()
             }
             udtitvfmt_close(udtitvfmt);
         } else {
-            log_err("FAIL: udtitvfmt_open for locale %s, skeleton %s, tzid %s: %s\n",
+            log_data_err("FAIL: udtitvfmt_open for locale %s, skeleton %s, tzid %s - %s\n",
                     testItemPtr->locale, testItemPtr->skeleton, tzidForLog, myErrorName(status) );
         }
     }
index b4dddd7e50cfda096a7e2c5d31ee6f08525044f4..22ff5a0202a7a4112d17eaf4557af3b0e3426a4f 100644 (file)
@@ -1325,12 +1325,12 @@ static void TestAvailableIsoCodes(void){
     /* testing available codes with no time ranges */
     u_charsToUChars(eurCode, isoCode, uprv_strlen(usdCode) + 1);
     if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) is not found.\n", eurCode);
+       log_data_err("FAIL: ISO code (%s) is not found.\n", eurCode);
     }
 
     u_charsToUChars(usdCode, isoCode, uprv_strlen(zzzCode) + 1);
     if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) is not found.\n", usdCode);
+       log_data_err("FAIL: ISO code (%s) is not found.\n", usdCode);
     }
 
     u_charsToUChars(zzzCode, isoCode, uprv_strlen(zzzCode) + 1);
@@ -1340,18 +1340,18 @@ static void TestAvailableIsoCodes(void){
 
     u_charsToUChars(lastCode, isoCode, uprv_strlen(zzzCode) + 1);
     if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) is not found.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) is not found.\n", lastCode);
     }
 
     /* RHD was used from 1970-02-17  to 1980-04-18*/
     
     /* to = null */
     if (ucurr_isAvailable(isoCode, date1970, U_DATE_MAX, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range >1970-01-01.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range >1970-01-01.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1975, U_DATE_MAX, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range >1975.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range >1975.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1981, U_DATE_MAX, &errorCode) == TRUE) {
@@ -1364,28 +1364,28 @@ static void TestAvailableIsoCodes(void){
     }
 
     if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1975, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range <1975.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range <1975.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1981, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range <1981.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range <1981.\n", lastCode);
     }
 
     /* full ranges */
     if (ucurr_isAvailable(isoCode, date1975, date1978, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range 1975-1978.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range 1975-1978.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1970, date1975, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range 1970-1975.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range 1970-1975.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1975, date1981, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range 1975-1981.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range 1975-1981.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1970,  date1981, &errorCode) == FALSE) {
-       log_err("FAIL: ISO code (%s) was available in time range 1970-1981.\n", lastCode);
+       log_data_err("FAIL: ISO code (%s) was available in time range 1970-1981.\n", lastCode);
     }
 
     if (ucurr_isAvailable(isoCode, date1981,  date1992, &errorCode) == TRUE) {
@@ -1400,7 +1400,7 @@ static void TestAvailableIsoCodes(void){
     if (ucurr_isAvailable(isoCode, date1975,  date1970, &errorCode) == TRUE) {
        log_err("FAIL: Wrong range 1975-1970 for ISO code (%s) was not reported.\n", lastCode);
     } else if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
-       log_err("FAIL: Error code not reported for wrong range 1975-1970 for ISO code (%s).\n", lastCode);
+       log_data_err("FAIL: Error code not reported for wrong range 1975-1970 for ISO code (%s).\n", lastCode);
     }
 
     free(isoCode);
index 0a9dd1c0eab302441817e48e1b41a29691e6774e..55af3c43c48ebf00ee3181d1be9bd17f14627969 100644 (file)
@@ -740,7 +740,7 @@ static void TestDisplayNames()
             int32_t expectedLen=u_strlen(expected);
 
             if(len!=expectedLen) {
-                log_err("uloc_getDisplayName(%s, %s...) returned string of length %d, expected length %d",
+                log_data_err("uloc_getDisplayName(%s, %s...) returned string of length %d, expected length %d",
                         locale, displayLocale, len, expectedLen);
             } else if(preflightLen!=expectedLen) {
                 log_err("uloc_getDisplayName(%s, %s...) returned preflight length %d, expected length %d",
index 771e3487c4039f4da916ede91539c6c6c34b56b4..2f732adbeb510f501d4a660edf5af9191929e49b 100644 (file)
@@ -983,7 +983,7 @@ static void TestParseZero(void)
 
     dbl = unum_parseDouble( unum, input, -1 /*u_strlen(input)*/, 0 /* 0 = start */, &errorCode );
     if (U_FAILURE(errorCode)) {
-        log_err("Result: %s\n", u_errorName(errorCode));
+        log_data_err("Result - %s\n", u_errorName(errorCode));
     } else {
         log_verbose("Double: %f\n", dbl);
     }
@@ -1062,7 +1062,7 @@ static void TestSignificantDigits()
     u_uastrcpy(temp, "###0.0#");
     fmt=unum_open(UNUM_IGNORE, temp, -1, NULL, NULL,&status);
     if (U_FAILURE(status)) {
-        log_err("got unexpected error for unum_open: '%s'\n", u_errorName(status));
+        log_data_err("got unexpected error for unum_open: '%s'\n", u_errorName(status));
         return;
     }
     unum_setAttribute(fmt, UNUM_SIGNIFICANT_DIGITS_USED, TRUE);
@@ -1262,7 +1262,7 @@ static void TestInt64Format() {
     u_uastrcpy(temp1, "#.#E0");
     fmt = unum_open(UNUM_IGNORE, temp1, u_strlen(temp1), NULL, NULL, &status);
     if(U_FAILURE(status)) {
-        log_err("error in unum_openPattern(): %s\n", myErrorName(status));
+        log_data_err("error in unum_openPattern() - %s\n", myErrorName(status));
     } else {
         unum_setAttribute(fmt, UNUM_MAX_FRACTION_DIGITS, 20);
         unum_formatInt64(fmt, U_INT64_MAX, result, 512, NULL, &status);
index 18405a2fc85a6793d8d8ec11d00ee50f4198d4fd..7b12fadd9f177ae04927874e0f46a0a9f02469ea 100644 (file)
@@ -75,7 +75,7 @@ static void TestPluralRules()
                 u_unescape(testItemPtr->keywordExpected, keywordExpected, kKeywordBufLen);
                 if ( u_strcmp(keyword, keywordExpected) != 0 ) {
                     char bcharBuf[kKeywordBufLen];
-                    log_err("ERROR: uplrules_select for locale %s, number %.1f: expect %s, get %s\n",
+                    log_data_err("ERROR: uplrules_select for locale %s, number %.1f: expect %s, get %s\n",
                              testItemPtr->locale, testItemPtr->number, testItemPtr->keywordExpected, u_austrcpy(bcharBuf,keyword) );
                 }
             } else {
index fa85e1e5a279b44490d3ab4b82f050033d886b40..e98e46150fbf5efd11de4a90529745ab16459f54 100644 (file)
@@ -2831,7 +2831,7 @@ static void TestPCEBuffer_with(const UChar *search, uint32_t searchLen, const UC
                                     &icuStatus );
    if ( U_FAILURE(icuStatus) )
    {
-     log_err( "ucol_openFromShortString error %s\n" , u_errorName(icuStatus));
+     log_data_err( "ucol_openFromShortString error %s\n" , u_errorName(icuStatus));
       goto exit;
    }
 
@@ -2937,14 +2937,14 @@ static void TestMatchFollowedByIgnorables(void) {
                                     NULL,
                                     &icuStatus);
     if (U_FAILURE(icuStatus)) {
-        log_err("ucol_openFromShortString error\n");
+        log_data_err("ucol_openFromShortString error - %s\n", u_errorName(icuStatus));
     }
 
     locale = ucol_getLocaleByType(coll,
                                     ULOC_VALID_LOCALE,
                                     &icuStatus);
     if (U_FAILURE(icuStatus)) {
-        log_err("ucol_getLocaleByType error\n");
+        log_data_err("ucol_getLocaleByType error - %s\n", u_errorName(icuStatus));
     }
 
     ubrk = ubrk_open(UBRK_CHARACTER,
@@ -2953,7 +2953,7 @@ static void TestMatchFollowedByIgnorables(void) {
                         sourceLen,
                         &icuStatus);
     if (U_FAILURE(icuStatus)) {
-        log_err("ubrk_open error\n");
+        log_data_err("ubrk_open error - %s\n", u_errorName(icuStatus));
     }
 
     usearch = usearch_openFromCollator(search,
@@ -2964,25 +2964,22 @@ static void TestMatchFollowedByIgnorables(void) {
                                         ubrk,
                                         &icuStatus);
     if (U_FAILURE(icuStatus)) {
-        log_err("usearch_openFromCollator error\n");
+        log_data_err("usearch_openFromCollator error - %s\n", u_errorName(icuStatus));
     }
 
     match = usearch_first(usearch,
                             &icuStatus);
     if (U_FAILURE(icuStatus)) {
-        log_err("usearch_first error\n");
-    }
+        log_data_err("usearch_first error - %s\n", u_errorName(icuStatus));
+    } else {
 
-    log_verbose("match=%d\n", match);
+        log_verbose("match=%d\n", match);
 
-    matchLength = usearch_getMatchedLength(usearch);
+        matchLength = usearch_getMatchedLength(usearch);
 
-    if (U_FAILURE(icuStatus)) {
-        log_err("usearch_getMatchedLength error\n");
-    }
-
-    if (matchLength != expectedMatchLength) {
-        log_err("Error: matchLength=%d, expected=%d\n", matchLength, expectedMatchLength);
+        if (matchLength != expectedMatchLength) {
+            log_err("Error: matchLength=%d, expected=%d\n", matchLength, expectedMatchLength);
+        }
     }
 
     usearch_close(usearch);
index 23b15ffb2e74373afaeebab25edaa035e39a5b95..096a034383f38b96a9ba11b9f59db5ce15897397 100644 (file)
@@ -3468,6 +3468,11 @@ void DateFormatTest::TestNumberAsStringParsing()
     SimpleDateFormat *formatter = new SimpleDateFormat(datePattern, Locale(""), status);
     UDate date1 = 0;
     
+    if (formatter == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
+        return;
+    }
+    
     formatter->setLenient(FALSE);
     date1 = formatter->parse(dateString, status);
     
index 9a4e762b9efffbee40f2261c536a3a9abb3163f2..ebf410dd432e819f9385dccd9999986d746508a2 100644 (file)
@@ -497,7 +497,7 @@ void MessageFormatRegressionTest::Test4116444()
                 for (int j = 0; j < count; j++) {
                     //if (array[j] != null)
                     UnicodeString dummy;
-                    err("\"" + array[j].getString(dummy) + "\"");
+                    dataerrln("\"" + array[j].getString(dummy) + "\"");
                     //else
                      //   log("null");
                     if (j < count- 1) 
index 7daeaf0d1737ec3b796541e5ad102d854340f99e..598ae7aa22be7ab76398211afdab7bba68e53fb3 100644 (file)
@@ -925,155 +925,176 @@ NumberFormatTest::TestLenientParse(void)
     DecimalFormat *format = new DecimalFormat("(#,##0)", status);
     Formattable n;
 
-    format->setLenient(TRUE);
-    for (int32_t t = 0; t < ARRAY_SIZE (lenientAffixTestCases); t += 1) {
-       UnicodeString testCase = ctou(lenientAffixTestCases[t]);
+    if (format == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create DecimalFormat (#,##0) - %s", u_errorName(status));
+    } else {
+        format->setLenient(TRUE);
+        for (int32_t t = 0; t < ARRAY_SIZE (lenientAffixTestCases); t += 1) {
+               UnicodeString testCase = ctou(lenientAffixTestCases[t]);
 
-        format->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+            format->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
 
-        if (U_FAILURE(status) || n.getType() != Formattable::kLong ||
-               n.getLong() != 1) {
-               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientAffixTestCases[t] + (UnicodeString) "\"");
-               status = U_ZERO_ERROR;
-        }
-   }
-
-    delete format;
+            if (U_FAILURE(status) || n.getType() != Formattable::kLong ||
+               n.getLong() != 1) {
+               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientAffixTestCases[t] + (UnicodeString) "\"");
+               status = U_ZERO_ERROR;
+            }
+       }
+       delete format;
+    }
 
     Locale en_US("en_US");
     Locale sv_SE("sv_SE");
     
     NumberFormat *mFormat = NumberFormat::createInstance(sv_SE, UNUM_DECIMAL, status);
     
-    mFormat->setLenient(TRUE);
-    for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
-        UnicodeString testCase = ctou(lenientMinusTestCases[t]);
-        
-        mFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
-        
-        if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
-            errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
-            status = U_ZERO_ERROR;
+    if (mFormat == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create NumberFormat (sv_SE, UNUM_DECIMAL) - %s", u_errorName(status));
+    } else {
+        mFormat->setLenient(TRUE);
+        for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
+            UnicodeString testCase = ctou(lenientMinusTestCases[t]);
+            
+            mFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+            
+            if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
+                errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
+                status = U_ZERO_ERROR;
+            }
         }
+        delete mFormat;
     }
     
-    delete mFormat;
-    
     mFormat = NumberFormat::createInstance(en_US, UNUM_DECIMAL, status);
     
-    mFormat->setLenient(TRUE);
-    for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
-        UnicodeString testCase = ctou(lenientMinusTestCases[t]);
-        
-        mFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
-        
-        if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
-            errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
-            status = U_ZERO_ERROR;
+    if (mFormat == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create NumberFormat (en_US, UNUM_DECIMAL) - %s", u_errorName(status));
+    } else {
+        mFormat->setLenient(TRUE);
+        for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
+            UnicodeString testCase = ctou(lenientMinusTestCases[t]);
+            
+            mFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+            
+            if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
+                errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
+                status = U_ZERO_ERROR;
+            }
         }
+        delete mFormat;
     }
     
-    delete mFormat;
-    
     NumberFormat *cFormat = NumberFormat::createInstance(en_US, UNUM_CURRENCY, status);
 
-    cFormat->setLenient(TRUE);
-    for (int32_t t = 0; t < ARRAY_SIZE (lenientCurrencyTestCases); t += 1) {
-       UnicodeString testCase = ctou(lenientCurrencyTestCases[t]);
+    if (cFormat == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create NumberFormat (en_US, UNUM_CURRENCY) - %s", u_errorName(status));
+    } else {
+        cFormat->setLenient(TRUE);
+        for (int32_t t = 0; t < ARRAY_SIZE (lenientCurrencyTestCases); t += 1) {
+               UnicodeString testCase = ctou(lenientCurrencyTestCases[t]);
 
-        cFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+            cFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
 
-        if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
-               n.getLong() != 1000) {
-               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientCurrencyTestCases[t] + (UnicodeString) "\"");
-               status = U_ZERO_ERROR;
+            if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
+               n.getLong() != 1000) {
+               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientCurrencyTestCases[t] + (UnicodeString) "\"");
+               status = U_ZERO_ERROR;
+            }
         }
-   }
 
-    for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativeCurrencyTestCases); t += 1) {
-       UnicodeString testCase = ctou(lenientNegativeCurrencyTestCases[t]);
+        for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativeCurrencyTestCases); t += 1) {
+               UnicodeString testCase = ctou(lenientNegativeCurrencyTestCases[t]);
 
-        cFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+            cFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
 
-        if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
-               n.getLong() != -1000) {
-               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativeCurrencyTestCases[t] + (UnicodeString) "\"");
-               status = U_ZERO_ERROR;
+            if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
+               n.getLong() != -1000) {
+               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativeCurrencyTestCases[t] + (UnicodeString) "\"");
+               status = U_ZERO_ERROR;
+            }
         }
-   }
 
-    delete cFormat;
+        delete cFormat;
+    }
 
     NumberFormat *pFormat = NumberFormat::createPercentInstance(en_US, status);
 
-    pFormat->setLenient(TRUE);
-    for (int32_t t = 0; t < ARRAY_SIZE (lenientPercentTestCases); t += 1) {
-       UnicodeString testCase = ctou(lenientPercentTestCases[t]);
+    if (pFormat == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create NumberFormat::createPercentInstance (en_US) - %s", u_errorName(status));
+    } else {
+        pFormat->setLenient(TRUE);
+        for (int32_t t = 0; t < ARRAY_SIZE (lenientPercentTestCases); t += 1) {
+               UnicodeString testCase = ctou(lenientPercentTestCases[t]);
 
-       pFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
+               pFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
 
-        if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
-               n.getDouble() != 0.25) {
-               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientPercentTestCases[t] + (UnicodeString) "\"");
-               status = U_ZERO_ERROR;
+            if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
+               n.getDouble() != 0.25) {
+               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientPercentTestCases[t] + (UnicodeString) "\"");
+               status = U_ZERO_ERROR;
+            }
         }
-   }
 
-    for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativePercentTestCases); t += 1) {
-       UnicodeString testCase = ctou(lenientNegativePercentTestCases[t]);
+        for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativePercentTestCases); t += 1) {
+               UnicodeString testCase = ctou(lenientNegativePercentTestCases[t]);
 
-       pFormat->parse(testCase, n, status);
-        logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
+               pFormat->parse(testCase, n, status);
+            logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
 
-        if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
-               n.getDouble() != -0.25) {
-               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativePercentTestCases[t] + (UnicodeString) "\"");
-               status = U_ZERO_ERROR;
+            if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
+               n.getDouble() != -0.25) {
+               errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativePercentTestCases[t] + (UnicodeString) "\"");
+               status = U_ZERO_ERROR;
+            }
         }
-   }
 
-   delete pFormat;
+        delete pFormat;
+    }
 
    // Test cases that should fail with a strict parse and pass with a
    // lenient parse.
    NumberFormat *nFormat = NumberFormat::createInstance(en_US, status);
-
-   // first, make sure that they fail with a strict parse
-   for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
-          UnicodeString testCase = ctou(strictFailureTestCases[t]);
-
-          nFormat->parse(testCase, n, status);
-          logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
-
-          if (! U_FAILURE(status)) {
-                  errln((UnicodeString)"Strict Parse succeeded for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
-          }
-
-          status = U_ZERO_ERROR;
-   }
-
-   // then, make sure that they pass with a lenient parse
-   nFormat->setLenient(TRUE);
-   for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
-          UnicodeString testCase = ctou(strictFailureTestCases[t]);
-
-          nFormat->parse(testCase, n, status);
-          logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
-
-          if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
-                       n.getLong() != 1000) {
-                  errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
-                  status = U_ZERO_ERROR;
-          }
+    
+   if (nFormat == NULL || U_FAILURE(status)) {
+       dataerrln("Unable to create NumberFormat (en_US) - %s", u_errorName(status));
+   } else { 
+       // first, make sure that they fail with a strict parse
+       for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
+              UnicodeString testCase = ctou(strictFailureTestCases[t]);
+
+              nFormat->parse(testCase, n, status);
+              logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+
+              if (! U_FAILURE(status)) {
+                      errln((UnicodeString)"Strict Parse succeeded for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
+              }
+
+              status = U_ZERO_ERROR;
+       }
+
+       // then, make sure that they pass with a lenient parse
+       nFormat->setLenient(TRUE);
+       for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
+              UnicodeString testCase = ctou(strictFailureTestCases[t]);
+
+              nFormat->parse(testCase, n, status);
+              logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
+
+              if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
+                       n.getLong() != 1000) {
+                      errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
+                      status = U_ZERO_ERROR;
+              }
+       }
+
+       delete nFormat;
    }
-
-   delete nFormat;
 }
 
 // -------------------------------------
index e1308582800b7304ed38e67e9b417fb338efe30e..b415b4e468792b668d206c2be17e7410dbff5fb7 100644 (file)
@@ -520,13 +520,13 @@ PluralFormatTest::pluralFormatExtendedTest(void) {
   UnicodeString fmtString(fmt, -1, US_INV);
   PluralFormat pf(fmtString, status);
   if (U_FAILURE(status)) {
-    errln("Failed to apply pattern - %s\n", u_errorName(status));
+    dataerrln("Failed to apply pattern - %s", u_errorName(status));
     return;
   }
   for (int i = 0; i < 7; ++i) {
     UnicodeString result = pf.format(i, status);
     if (U_FAILURE(status)) {
-      errln("Failed to format - %s\n", u_errorName(status));
+      errln("Failed to format - %s", u_errorName(status));
     }
     UnicodeString expected(targets[i], -1, US_INV);
     if (expected != result) {
index 327b0798548280db2630951c51a770cb2f332e8e..89afdb6dd7639a3a44fc350e7b43b3eb25c6470f 100644 (file)
@@ -1096,27 +1096,30 @@ void RBBIAPITest::TestCreateFromRBBIData() {
     //
     status = U_ZERO_ERROR;
     RuleBasedBreakIterator *rb = (RuleBasedBreakIterator *)BreakIterator::createWordInstance(Locale::getEnglish(), status);
-    TEST_ASSERT_SUCCESS(status);
-    uint32_t length;
-    const uint8_t *rules = rb->getBinaryRules(length);
-    RuleBasedBreakIterator *rb2 = new RuleBasedBreakIterator(rules, length, status);
-    TEST_ASSERT_SUCCESS(status);
-    TEST_ASSERT(*rb == *rb2);
-    UnicodeString words = "one two three ";
-    rb2->setText(words);
-    int wordCounter = 0;
-    while (rb2->next() != UBRK_DONE) {
-        wordCounter++;
-    }
-    TEST_ASSERT(wordCounter == 6);
+    if (rb == NULL || U_FAILURE(status)) {
+        dataerrln("Unable to create BreakIterator::createWordInstance (Locale::getEnglish) - %s", u_errorName(status));
+    } else {
+        uint32_t length;
+        const uint8_t *rules = rb->getBinaryRules(length);
+        RuleBasedBreakIterator *rb2 = new RuleBasedBreakIterator(rules, length, status);
+        TEST_ASSERT_SUCCESS(status);
+        TEST_ASSERT(*rb == *rb2);
+        UnicodeString words = "one two three ";
+        rb2->setText(words);
+        int wordCounter = 0;
+        while (rb2->next() != UBRK_DONE) {
+            wordCounter++;
+        }
+        TEST_ASSERT(wordCounter == 6);
 
-    status = U_ZERO_ERROR;
-    RuleBasedBreakIterator *rb3 = new RuleBasedBreakIterator(rules, length-1, status);
-    TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
+        status = U_ZERO_ERROR;
+        RuleBasedBreakIterator *rb3 = new RuleBasedBreakIterator(rules, length-1, status);
+        TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR);
 
-    delete rb;
-    delete rb2;
-    delete rb3;
+        delete rb;
+        delete rb2;
+        delete rb3;
+    }
 }
 
 //---------------------------------------------
index dc7f291f1b457ede4240402334433f88e19e1f43..6072cd496e81ac28708c60bd85875837cf7435ad 100644 (file)
@@ -176,7 +176,7 @@ void TestMessageFormat::testBug2()
     logln("The input pattern : " + pattern);
     MessageFormat *fmt = new MessageFormat(pattern, status);
     if (U_FAILURE(status)) {
-        errln("MessageFormat pattern creation failed.");
+        dataerrln("MessageFormat pattern creation failed. - %s", u_errorName(status));
         return;
     }
     logln("The output pattern is : " + fmt->toPattern(result));
@@ -562,7 +562,7 @@ void TestMessageFormat::testMsgFormatPlural(/* char* par */)
     UnicodeString argNameResult;
     mfAlpha->format(argName, &testArgs1, 1, argNameResult, err);
     if (U_FAILURE(err)) {
-        errln("TestMessageFormat::testMsgFormatPlural #1 - argumentName");
+        dataerrln("TestMessageFormat::testMsgFormatPlural #1 - argumentName - %s", u_errorName(err));
         logln(UnicodeString("TestMessageFormat::testMsgFormatPlural #1 with error code ")+(int32_t)err);
         delete mfNum;
         return;
@@ -1195,6 +1195,10 @@ void TestMessageFormat::testAdopt()
     err = U_ZERO_ERROR;
     MessageFormat msg( formatStr, err);
     MessageFormat msgCmp( formatStr, err);
+    if (U_FAILURE(err)) {
+        dataerrln("Unable to instantiate MessageFormat - %s", u_errorName(err));
+        return;
+    }
     int32_t count, countCmp;
     const Format** formats = msg.getFormats(count);
     const Format** formatsCmp = msgCmp.getFormats(countCmp);
@@ -1642,12 +1646,16 @@ void TestMessageFormat::TestCompatibleApostrophe() {
     pattern = "ab{0,choice,0#1'2''3'''4''''.{0,number,'#x'}}yz";
     compMsg.applyPattern(pattern, ec);
     icuMsg.applyPattern(pattern, ec);
-    assertEquals("incompatible ICU MessageFormat compatibility-apostrophe behavior",
-            "ab1234'.0xyz",
-            compMsg.format(zero0, 1, buffer1, fieldpos, ec));
-    assertEquals("unexpected ICU MessageFormat double-apostrophe-optional behavior",
-            "ab1'2'3''4''.#x0yz",
-            icuMsg.format(zero0, 1, buffer2, fieldpos, ec));
+    if (U_FAILURE(ec)) {
+        dataerrln("Unable to applyPattern - %s", u_errorName(ec));
+    } else {
+        assertEquals("incompatible ICU MessageFormat compatibility-apostrophe behavior",
+                "ab1234'.0xyz",
+                compMsg.format(zero0, 1, buffer1, fieldpos, ec));
+        assertEquals("unexpected ICU MessageFormat double-apostrophe-optional behavior",
+                "ab1'2'3''4''.#x0yz",
+                icuMsg.format(zero0, 1, buffer2, fieldpos, ec));
+    }
 
     // This part is copied over from Java tests but cannot be properly tested here
     // because we do not have a live reference implementation with JDK behavior.
@@ -1777,6 +1785,9 @@ void TestMessageFormat::TestTrimArgumentName() {
     // ICU 4.8 allows and ignores white space around argument names and numbers.
     IcuTestErrorCode errorCode(*this, "TestTrimArgumentName");
     MessageFormat m("a { 0 , number , '#,#'#.0 } z", Locale::getEnglish(), errorCode);
+    if (errorCode.logDataIfFailureAndReset("Unable to instantiate MessageFormat")) {
+        return;
+    }
     Formattable args[1] = { 2 };
     FieldPosition ignore(0);
     UnicodeString result;
index 84a64deb74fc0d723fd291c76d32eb439203efe6..8b402181d42884f213ac32296452bed19bff5b00 100644 (file)
@@ -276,7 +276,15 @@ public:
 
         StringEnumeration *tzids = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
         if (U_FAILURE(status)) {
-            log.errln("TimeZone::createTimeZoneIDEnumeration failed");
+            if (status == U_MISSING_RESOURCE_ERROR) {
+                /* This error is generally caused by data not being present. However, an infinite loop will occur
+                 * because the thread thinks that the test data is never done so we should treat the data as done.
+                 */
+                log.dataerrln("TimeZone::createTimeZoneIDEnumeration failed - %s", u_errorName(status));
+                data.numDone = data.nLocales;
+            } else {
+                log.errln("TimeZone::createTimeZoneIDEnumeration failed: %s", u_errorName(status));
+            }
             return;
         }