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);
}
}
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) );
}
}
/* 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);
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) {
}
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) {
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);
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",
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);
}
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);
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);
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 {
&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;
}
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,
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,
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);
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);
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)
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;
}
// -------------------------------------
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) {
//
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;
+ }
}
//---------------------------------------------
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));
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;
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);
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.
// 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;
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;
}