ICU-10398 Ensure cintltst and intltest passes without data

X-SVN-Rev: 34398
This commit is contained in:
Michael Ow 2013-09-19 02:32:57 +00:00
parent 37562f403e
commit 4835d5705a
21 changed files with 112 additions and 62 deletions

View file

@ -2376,7 +2376,7 @@ void TestGetWindowsTimeZoneID() {
if (U_FAILURE(status)) {
log_data_err("FAIL: Windows ID for America/New_York, status %s\n", u_errorName(status));
} else if (len != u_strlen(winEastern) || u_strncmp(winID, winEastern, len) != 0) {
log_err("FAIL: Windows ID for America/New_York\n");
log_data_err("FAIL: Windows ID for America/New_York\n");
}
}
{
@ -2385,7 +2385,7 @@ void TestGetWindowsTimeZoneID() {
if (U_FAILURE(status)) {
log_data_err("FAIL: Windows ID for America/Toronto, status %s\n", u_errorName(status));
} else if (len != u_strlen(winEastern) || u_strncmp(winID, winEastern, len) != 0) {
log_err("FAIL: Windows ID for America/Toronto\n");
log_data_err("FAIL: Windows ID for America/Toronto\n");
}
}
{
@ -2394,7 +2394,7 @@ void TestGetWindowsTimeZoneID() {
if (U_FAILURE(status)) {
log_data_err("FAIL: Windows ID for Bogus, status %s\n", u_errorName(status));
} else if (len != 0) {
log_err("FAIL: Windows ID for Bogus\n");
log_data_err("FAIL: Windows ID for Bogus\n");
}
}
}

View file

@ -652,15 +652,24 @@ static void ctst_freeAll() {
#define VERBOSE_ASSERTIONS
U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec) {
U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError) {
U_ASSERT(ec!=NULL);
if (U_FAILURE(*ec)) {
log_err_status(*ec, "FAIL: %s (%s)\n", msg, u_errorName(*ec));
if (possibleDataError) {
log_data_err("FAIL: %s (%s)\n", msg, u_errorName(*ec));
} else {
log_err_status(*ec, "FAIL: %s (%s)\n", msg, u_errorName(*ec));
}
return FALSE;
}
return TRUE;
}
U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec) {
U_ASSERT(ec!=NULL);
return assertSuccessCheck(msg, ec, FALSE);
}
/* if 'condition' is a UBool, the compiler complains bitterly about
expressions like 'a > 0' which it evaluates as int */
U_CFUNC UBool assertTrue(const char* msg, int /*not UBool*/ condition) {

View file

@ -116,6 +116,12 @@ U_CFUNC UBool ctest_resetICU(void);
*/
U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec);
/**
* Assert that the given UErrorCode succeeds, and return TRUE if it does.
* Give data error if UErrorCode fails and possibleDataError is TRUE.
*/
U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError);
/**
* Assert that the UBool is TRUE, and return TRUE if it does.
*

View file

@ -1064,13 +1064,13 @@ static void TestDisplayNameBrackets()
status = U_ZERO_ERROR;
ulen = uloc_getDisplayCountry(itemPtr->namedLocale, itemPtr->displayLocale, getName, kDisplayNameBracketsMax, &status);
if ( U_FAILURE(status) || u_strcmp(getName, expectRegionName) != 0 ) {
log_err("uloc_getDisplayCountry for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
log_data_err("uloc_getDisplayCountry for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
}
status = U_ZERO_ERROR;
ulen = uloc_getDisplayName(itemPtr->namedLocale, itemPtr->displayLocale, getName, kDisplayNameBracketsMax, &status);
if ( U_FAILURE(status) || u_strcmp(getName, expectLocaleName) != 0 ) {
log_err("uloc_getDisplayName for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
log_data_err("uloc_getDisplayName for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
}
status = U_ZERO_ERROR;
@ -1079,13 +1079,13 @@ static void TestDisplayNameBrackets()
status = U_ZERO_ERROR;
ulen = uldn_regionDisplayName(uldn, itemPtr->namedRegion, getName, kDisplayNameBracketsMax, &status);
if ( U_FAILURE(status) || u_strcmp(getName, expectRegionName) != 0 ) {
log_err("uldn_regionDisplayName for displayLocale %s and namedRegion %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedRegion, myErrorName(status));
log_data_err("uldn_regionDisplayName for displayLocale %s and namedRegion %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedRegion, myErrorName(status));
}
status = U_ZERO_ERROR;
ulen = uldn_localeDisplayName(uldn, itemPtr->namedLocale, getName, kDisplayNameBracketsMax, &status);
if ( U_FAILURE(status) || u_strcmp(getName, expectLocaleName) != 0 ) {
log_err("uldn_localeDisplayName for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
log_data_err("uldn_localeDisplayName for displayLocale %s and namedLocale %s returns unexpected name or status %s\n", itemPtr->displayLocale, itemPtr->namedLocale, myErrorName(status));
}
uldn_close(uldn);

View file

@ -2188,7 +2188,7 @@ static void TestUFormattable(void) {
{
UErrorCode status = U_ZERO_ERROR;
UNumberFormat *unum = unum_open(UNUM_DEFAULT, NULL, -1, "en_US_POSIX", NULL, &status);
if(assertSuccess("calling ufmt_open()", &status)) {
if(assertSuccessCheck("calling ufmt_open()", &status, TRUE)) {
//! [unum_parseToUFormattable]
const UChar str[] = { 0x0031, 0x0032, 0x0033, 0x0000 }; /* 123 */
int32_t result = 0;
@ -2213,7 +2213,7 @@ static void TestUFormattable(void) {
ufmt = ufmt_open(&status);
unum = unum_open(UNUM_DEFAULT, NULL, -1, "en_US_POSIX", NULL, &status);
if(assertSuccess("calling ufmt_open()", &status)) {
if(assertSuccessCheck("calling ufmt_open()", &status, TRUE)) {
pattern = "31337";
log_verbose("-- pattern: %s\n", pattern);
@ -2261,7 +2261,7 @@ static void TestUFormattable(void) {
u_uastrcpy(buffer, pattern);
unum = unum_open(UNUM_DEFAULT, NULL, -1, "en_US_POSIX", NULL, &status);
if(assertSuccess("calling ufmt_open()", &status)) {
if(assertSuccessCheck("calling ufmt_open()", &status, TRUE)) {
ufmt = unum_parseToUFormattable(unum, NULL, /* will be unum_open()'ed for us */
buffer, -1, NULL, &status);
@ -2335,12 +2335,12 @@ static void TestUNumberingSystem(void) {
UBool isAlgorithmic = unumsys_isAlgorithmic(unumsys);
numsys = unumsys_getName(unumsys);
if ( uprv_strcmp(numsys, itemPtr->numsys) != 0 || radix != itemPtr->radix || !isAlgorithmic != !itemPtr->isAlgorithmic ) {
log_err("unumsys name/radix/isAlgorithmic for locale %s, expected %s/%d/%d, got %s/%d/%d\n",
log_data_err("unumsys name/radix/isAlgorithmic for locale %s, expected %s/%d/%d, got %s/%d/%d\n",
itemPtr->locale, itemPtr->numsys, itemPtr->radix, itemPtr->isAlgorithmic, numsys, radix, isAlgorithmic);
}
ulen = unumsys_getDescription(unumsys, ubuf, kNumSysDescripBufMax, &status);
if ( U_FAILURE(status) || u_strcmp(ubuf, itemPtr->description) != 0 ) {
log_err("unumsys description for locale %s, description unexpected and/or status %\n", myErrorName(status));
log_data_err("unumsys description for locale %s, description unexpected and/or status %\n", myErrorName(status));
}
unumsys_close(unumsys);
} else {

View file

@ -2282,7 +2282,7 @@ void CollationAPITest::TestIterNumeric() {
// and on the implementation code.
IcuTestErrorCode errorCode(*this, "TestIterNumeric");
RuleBasedCollator coll(UnicodeString("[reorder Hang Hani]"), errorCode);
if(errorCode.logIfFailureAndReset("RuleBasedCollator constructor")) {
if(errorCode.logDataIfFailureAndReset("RuleBasedCollator constructor")) {
return;
}
coll.setAttribute(UCOL_NUMERIC_COLLATION, UCOL_ON, errorCode);

View file

@ -23,8 +23,13 @@
#define mkcstr(U) u_austrcpy(calloc(8, u_strlen(U) + 1), U)
#define TEST_CHECK_STATUS {if (U_FAILURE(status)) {errln("%s:%d: Test failure. status=%s", \
__FILE__, __LINE__, u_errorName(status)); return;}}
#define TEST_CHECK_STATUS { \
if (U_FAILURE(status)) { \
if (status == U_MISSING_RESOURCE_ERROR) { \
dataerrln("%s:%d: Test failure. status=%s", __FILE__, __LINE__, u_errorName(status)); \
} else { \
errln("%s:%d: Test failure. status=%s", __FILE__, __LINE__, u_errorName(status)); \
} return;}}
#define TEST_ASSERT(expr) {if ((expr)==FALSE) {errln("%s:%d: Test failure \n", __FILE__, __LINE__);};}

View file

@ -578,7 +578,7 @@ void IntlTestDecimalFormatAPI::TestScale()
#define ASSERT_EQUAL(expect, actual) { char tmp[200]; sprintf(tmp, "(%g==%g)", (double)(expect), (double)(actual)); \
assertTrue(tmp, ((expect)==(actual)), FALSE, FALSE, __FILE__, __LINE__); }
assertTrue(tmp, ((expect)==(actual)), FALSE, TRUE, __FILE__, __LINE__); }
void IntlTestDecimalFormatAPI::TestFixedDecimal() {
UErrorCode status = U_ZERO_ERROR;
@ -786,7 +786,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
// int64_t fields to 18 digits. See ticket Ticket #10374
// ASSERT_EQUAL(223372036854775807LL, fd.intValue);
if (!(fd.intValue == 223372036854775807LL || fd.intValue == 9223372036854775807LL)) {
errln("File %s, Line %d, fd.intValue = %lld", __FILE__, __LINE__, fd.intValue);
dataerrln("File %s, Line %d, fd.intValue = %lld", __FILE__, __LINE__, fd.intValue);
}
ASSERT_EQUAL(TRUE, fd.hasIntegerValue);
ASSERT_EQUAL(FALSE, fd.isNegative);

View file

@ -4230,6 +4230,10 @@ void DateFormatTest::TestDateFormatLeniency() {
status = U_ZERO_ERROR;
ParsePosition pos(0);
SimpleDateFormat * sdmft = new SimpleDateFormat(itemPtr->pattern, locale, status);
if (U_FAILURE(status)) {
dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
continue;
}
sdmft->setLenient(itemPtr->leniency);
sdmft->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, itemPtr->leniency, status).setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, itemPtr->leniency, status);
/*UDate d = */sdmft->parse(itemPtr->parseString, pos);

View file

@ -1205,7 +1205,7 @@ void DateIntervalFormatTest::testYearFormats() {
{
LocalPointer<DateIntervalFormat> dif(DateIntervalFormat::createInstance("yyyyMd", enLocale, status));
if (U_FAILURE(status)) {
errln("Failure encountered: %s", u_errorName(status));
dataerrln("Failure encountered: %s", u_errorName(status));
return;
}
UnicodeString actual;

View file

@ -905,8 +905,12 @@ void IntlTest::dataerrln( const UnicodeString &message )
msg = UnicodeString("[DATA] " + message);
}
if (!no_err_msg && ( errCount == 1 )) {
LL_message( msg + " - (Are you missing data?)", TRUE ); // only show this message the first time
if (!no_err_msg) {
if ( errCount == 1) {
LL_message( msg + " - (Are you missing data?)", TRUE ); // only show this message the first time
} else {
LL_message( msg , TRUE );
}
}
}
@ -1894,11 +1898,18 @@ UBool IntlTest::assertEquals(const char* message,
#if !UCONFIG_NO_FORMATTING
UBool IntlTest::assertEquals(const char* message,
const Formattable& expected,
const Formattable& actual) {
const Formattable& actual,
UBool possibleDataError) {
if (expected != actual) {
errln((UnicodeString)"FAIL: " + message + "; got " +
toString(actual) +
"; expected " + toString(expected));
if (possibleDataError) {
dataerrln((UnicodeString)"FAIL: " + message + "; got " +
toString(actual) +
"; expected " + toString(expected));
} else {
errln((UnicodeString)"FAIL: " + message + "; got " +
toString(actual) +
"; expected " + toString(expected));
}
return FALSE;
}
#ifdef VERBOSE_ASSERTIONS
@ -1934,8 +1945,9 @@ UBool IntlTest::assertSuccess(const UnicodeString& message, UErrorCode ec) {
UBool IntlTest::assertEquals(const UnicodeString& message,
const UnicodeString& expected,
const UnicodeString& actual) {
return assertEquals(extractToAssertBuf(message), expected, actual);
const UnicodeString& actual,
UBool possibleDataError) {
return assertEquals(extractToAssertBuf(message), expected, actual, possibleDataError);
}
UBool IntlTest::assertEquals(const UnicodeString& message,

View file

@ -270,7 +270,7 @@ protected:
UBool assertEquals(const char* message, int64_t expected, int64_t actual);
#if !UCONFIG_NO_FORMATTING
UBool assertEquals(const char* message, const Formattable& expected,
const Formattable& actual);
const Formattable& actual, UBool possibleDataError=FALSE);
UBool assertEquals(const UnicodeString& message, const Formattable& expected,
const Formattable& actual);
#endif
@ -278,7 +278,7 @@ protected:
UBool assertFalse(const UnicodeString& message, UBool condition, UBool quiet=FALSE);
UBool assertSuccess(const UnicodeString& message, UErrorCode ec);
UBool assertEquals(const UnicodeString& message, const UnicodeString& expected,
const UnicodeString& actual);
const UnicodeString& actual, UBool possibleDataError=FALSE);
UBool assertEquals(const UnicodeString& message, const char* expected,
const char* actual);
UBool assertEquals(const UnicodeString& message, UBool expected, UBool actual);

View file

@ -7047,6 +7047,8 @@ void NumberFormatTest::TestSignificantDigits(void) {
Locale locale("en_US");
LocalPointer<DecimalFormat> numberFormat(static_cast<DecimalFormat*>(
NumberFormat::createInstance(locale, status)));
CHECK_DATA(status,"NumberFormat::createInstance")
numberFormat->setSignificantDigitsUsed(TRUE);
numberFormat->setMinimumSignificantDigits(3);
numberFormat->setMaximumSignificantDigits(5);
@ -7069,6 +7071,8 @@ void NumberFormatTest::TestShowZero() {
Locale locale("en_US");
LocalPointer<DecimalFormat> numberFormat(static_cast<DecimalFormat*>(
NumberFormat::createInstance(locale, status)));
CHECK_DATA(status, "NumberFormat::createInstance")
numberFormat->setSignificantDigitsUsed(TRUE);
numberFormat->setMaximumSignificantDigits(3);
@ -7085,7 +7089,7 @@ void NumberFormatTest::TestBug9936() {
LocalPointer<DecimalFormat> numberFormat(static_cast<DecimalFormat*>(
NumberFormat::createInstance(locale, status)));
if (U_FAILURE(status)) {
errln("File %s, Line %d: status = %s.\n", __FILE__, __LINE__, u_errorName(status));
dataerrln("File %s, Line %d: status = %s.\n", __FILE__, __LINE__, u_errorName(status));
return;
}
@ -7118,6 +7122,7 @@ void NumberFormatTest::TestBug9936() {
void NumberFormatTest::TestParseNegativeWithFaLocale() {
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *test = (DecimalFormat *) NumberFormat::createInstance("fa", status);
CHECK_DATA(status, "NumberFormat::createInstance")
test->setLenient(TRUE);
Formattable af;
ParsePosition ppos;
@ -7133,6 +7138,7 @@ void NumberFormatTest::TestParseNegativeWithFaLocale() {
void NumberFormatTest::TestParseNegativeWithAlternateMinusSign() {
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *test = (DecimalFormat *) NumberFormat::createInstance("en", status);
CHECK_DATA(status, "NumberFormat::createInstance")
test->setLenient(TRUE);
Formattable af;
ParsePosition ppos;

View file

@ -2697,11 +2697,14 @@ void NumberFormatRegressionTest::TestJ691(void) {
// Error Checking / Reporting macros
//
//---------------------------------------------------------------------------
#define TEST_CHECK_STATUS(status) \
if (U_FAILURE(status)) {\
errln("File %s, Line %d. status=%s\n", __FILE__, __LINE__, u_errorName(status));\
return;\
}
#define TEST_CHECK_STATUS(status) { \
if (U_FAILURE(status)) { \
if (status == U_MISSING_RESOURCE_ERROR) { \
dataerrln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
} else { \
errln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
} return; \
}}
#define TEST_ASSERT(expr) \
if ((expr)==FALSE) {\

View file

@ -670,15 +670,16 @@ PluralFormatTest::TestDecimals() {
IcuTestErrorCode errorCode(*this, "TestDecimals");
// Simple number replacement.
PluralFormat pf(Locale::getEnglish(), "one{one meter}other{# meters}", errorCode);
assertEquals("simple format(1)", "one meter", pf.format((int32_t)1, errorCode));
assertEquals("simple format(1.5)", "1.5 meters", pf.format(1.5, errorCode));
assertEquals("simple format(1)", "one meter", pf.format((int32_t)1, errorCode), TRUE);
assertEquals("simple format(1.5)", "1.5 meters", pf.format(1.5, errorCode), TRUE);
PluralFormat pf2(Locale::getEnglish(),
"offset:1 one{another meter}other{another # meters}", errorCode);
DecimalFormat df("0.0", new DecimalFormatSymbols(Locale::getEnglish(), errorCode), errorCode);
pf2.setNumberFormat(&df, errorCode);
assertEquals("offset-decimals format(1)", "another 0.0 meters", pf2.format((int32_t)1, errorCode));
assertEquals("offset-decimals format(2)", "another 1.0 meters", pf2.format((int32_t)2, errorCode));
assertEquals("offset-decimals format(2.5)", "another 1.5 meters", pf2.format(2.5, errorCode));
assertEquals("offset-decimals format(1)", "another 0.0 meters", pf2.format((int32_t)1, errorCode), TRUE);
assertEquals("offset-decimals format(2)", "another 1.0 meters", pf2.format((int32_t)2, errorCode), TRUE);
assertEquals("offset-decimals format(2.5)", "another 1.5 meters", pf2.format(2.5, errorCode), TRUE);
errorCode.reset();
}
void

View file

@ -849,7 +849,7 @@ void PluralRulesTest::testAvailbleLocales() {
for (;;) {
const char *locale = localesEnum->next(NULL, status);
if (U_FAILURE(status)) {
errln("file %s, line %d: Error status = %s", __FILE__, __LINE__, u_errorName(status));
dataerrln("file %s, line %d: Error status = %s", __FILE__, __LINE__, u_errorName(status));
return;
}
if (locale == NULL) {

View file

@ -3131,7 +3131,7 @@ void RegexTest::Extended() {
UnicodeString matchString; // The marked up string to be used as input
if (U_FAILURE(status)){
dataerrln("Construct RegexMatcher() error.");
dataerrln("Construct RegexMatcher() error - %s", u_errorName(status));
delete [] testData;
return;
}
@ -3594,7 +3594,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) {

View file

@ -655,7 +655,7 @@ void TestMessageFormat::internalFormat(MessageFormat* msgFmt ,
//Format with passed arguments
msgFmt->format( args , numOfArgs , result, ignore, status);
if (U_FAILURE(status)) {
dataerrln( "%serror while formatting with ErrorCode as %s" ,errMsg, u_errorName(status) );
dataerrln( "%s error while formatting with ErrorCode as %s" ,errMsg, u_errorName(status) );
}
//Compare expected with obtained result
if ( result!= expected ) {
@ -671,7 +671,7 @@ MessageFormat* TestMessageFormat::internalCreate(
//Create the MessageFormat with simple SelectFormat
MessageFormat* msgFmt = new MessageFormat(pattern, locale, status);
if (U_FAILURE(status)) {
dataerrln( "%serror while constructing with ErrorCode as %s" ,errMsg, u_errorName(status) );
dataerrln( "%s error while constructing with ErrorCode as %s" ,errMsg, u_errorName(status) );
logln(UnicodeString("TestMessageFormat::testMsgFormatSelect #1 with error code ")+(int32_t)status);
return NULL;
}
@ -753,6 +753,7 @@ void TestMessageFormat::testMsgFormatSelect(/* char* par */)
//Nested patterns with plural, number ,choice ,select format etc.
//Select Format with embedded number format
UnicodeString t4("{0} est {1, select, female {{2,number,integer} all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris.");
err = U_ZERO_ERROR;
//Create the MessageFormat with Select Format with embedded number format (nested pattern)
MessageFormat* msgFmt4 = internalCreate(t4.unescape(), Locale("fr"),err,(char*)"From TestMessageFormat::TestSelectFormat create t4");
if (!U_FAILURE(err)) {
@ -772,7 +773,6 @@ void TestMessageFormat::testMsgFormatSelect(/* char* par */)
}
delete msgFmt4;
err = U_ZERO_ERROR;
//Plural format with embedded select format
UnicodeString t5("{0} {1, plural, one {est {2, select, female {all\\u00E9e} other {all\\u00E9}}} other {sont {2, select, female {all\\u00E9es} other {all\\u00E9s}}}} \\u00E0 Paris.");
err = U_ZERO_ERROR;
@ -1903,12 +1903,12 @@ void TestMessageFormat::TestDecimals() {
FieldPosition ignore;
UnicodeString result;
assertEquals("simple format(1)", "one meter",
m.format(args, 1, result, ignore, errorCode));
m.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (double)1.5;
result.remove();
assertEquals("simple format(1.5)", "1.5 meters",
m.format(args, 1, result, ignore, errorCode));
m.format(args, 1, result, ignore, errorCode), TRUE);
// Simple but explicit.
MessageFormat m0(
@ -1917,12 +1917,12 @@ void TestMessageFormat::TestDecimals() {
args[0] = (int32_t)1;
result.remove();
assertEquals("explicit format(1)", "one meter",
m0.format(args, 1, result, ignore, errorCode));
m0.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (double)1.5;
result.remove();
assertEquals("explicit format(1.5)", "1.5 meters",
m0.format(args, 1, result, ignore, errorCode));
m0.format(args, 1, result, ignore, errorCode), TRUE);
// With offset and specific simple format with optional decimals.
MessageFormat m1(
@ -1931,17 +1931,17 @@ void TestMessageFormat::TestDecimals() {
args[0] = (int32_t)1;
result.remove();
assertEquals("offset format(1)", "01 meters",
m1.format(args, 1, result, ignore, errorCode));
m1.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (int32_t)2;
result.remove();
assertEquals("offset format(1)", "another meter",
m1.format(args, 1, result, ignore, errorCode));
m1.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (double)2.5;
result.remove();
assertEquals("offset format(1)", "02.5 meters",
m1.format(args, 1, result, ignore, errorCode));
m1.format(args, 1, result, ignore, errorCode), TRUE);
// With offset and specific simple format with forced decimals.
MessageFormat m2(
@ -1950,17 +1950,18 @@ void TestMessageFormat::TestDecimals() {
args[0] = (int32_t)1;
result.remove();
assertEquals("offset-decimals format(1)", "1.0 meters",
m2.format(args, 1, result, ignore, errorCode));
m2.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (int32_t)2;
result.remove();
assertEquals("offset-decimals format(1)", "2.0 meters",
m2.format(args, 1, result, ignore, errorCode));
m2.format(args, 1, result, ignore, errorCode), TRUE);
args[0] = (double)2.5;
result.remove();
assertEquals("offset-decimals format(1)", "2.5 meters",
m2.format(args, 1, result, ignore, errorCode));
m2.format(args, 1, result, ignore, errorCode), TRUE);
errorCode.reset();
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -217,7 +217,7 @@ void IntlTestDecimalFormatSymbols::testLastResortData() {
return;
}
DecimalFormatSymbols root(Locale::getRoot(), errorCode);
if(errorCode.logIfFailureAndReset("DecimalFormatSymbols(root) failed")) {
if(errorCode.logDataIfFailureAndReset("DecimalFormatSymbols(root) failed")) {
return;
}
// Note: It is not necessary that the last resort data matches the root locale,

View file

@ -723,6 +723,9 @@ void ThreadSafeFormat::init(UErrorCode &status) {
gFormat.adoptInstead(createFormat(status));
gYDDThing.adoptObject(new CurrencyAmount(123.456, kYDD, status));
gBBDThing.adoptObject(new CurrencyAmount(987.654, kBBD, status));
if (U_FAILURE(status)) {
return;
}
gFormat->format(gYDDThing, gYDDStr, NULL, status);
gFormat->format(gBBDThing, gBBDStr, NULL, status);
}
@ -1023,7 +1026,7 @@ void MultithreadTest::TestThreadedIntl()
UErrorCode threadSafeErr = U_ZERO_ERROR;
ThreadSafeFormat::init(threadSafeErr);
assertSuccess("initializing ThreadSafeFormat", threadSafeErr);
assertSuccess("initializing ThreadSafeFormat", threadSafeErr, TRUE);
//
// Create and start the test threads
@ -1084,7 +1087,7 @@ void MultithreadTest::TestThreadedIntl()
// All threads have finished.
//
ThreadSafeFormat::fini(threadSafeErr);
assertSuccess("finalizing ThreadSafeFormat", threadSafeErr);
assertSuccess("finalizing ThreadSafeFormat", threadSafeErr, TRUE);
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -2328,7 +2328,7 @@ void TimeZoneTest::TestGetWindowsID(void) {
TimeZone::getWindowsID(UnicodeString(TESTDATA[i].id), windowsID, sts);
assertSuccess(TESTDATA[i].id, sts);
assertEquals(TESTDATA[i].id, UnicodeString(TESTDATA[i].winid), windowsID);
assertEquals(TESTDATA[i].id, UnicodeString(TESTDATA[i].winid), windowsID, TRUE);
}
}
@ -2357,7 +2357,7 @@ void TimeZoneTest::TestGetIDForWindowsID(void) {
TimeZone::getIDForWindowsID(UnicodeString(TESTDATA[i].winid), TESTDATA[i].region,
id, sts);
assertSuccess(UnicodeString(TESTDATA[i].winid) + "/" + TESTDATA[i].region, sts);
assertEquals(UnicodeString(TESTDATA[i].winid) + "/" + TESTDATA[i].region, TESTDATA[i].id, id);
assertEquals(UnicodeString(TESTDATA[i].winid) + "/" + TESTDATA[i].region, TESTDATA[i].id, id, TRUE);
}
}