/*
*******************************************************************************
-* Copyright (C) 2014, International Business Machines Corporation and *
+* Copyright (C) 2014-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
UErrorCode status = U_ZERO_ERROR;
DecimalFormat *result = new DecimalFormat(
upattern, new DecimalFormatSymbols("fr", status), status);
- U_ASSERT(status == U_ZERO_ERROR);
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+
return result;
}
void NumberFormatSpecificationTest::TestNfSetters() {
LocalPointer<NumberFormat> nf(nfWithPattern("#,##0.##"));
+ if (nf == NULL) {
+ dataerrln("Error creating NumberFormat");
+ return;
+ }
nf->setMaximumIntegerDigits(5);
nf->setMinimumIntegerDigits(4);
assertEquals("", "34 567,89", format(1234567.89, *nf), TRUE);
UnicodeString result;
DecimalFormat fmt(
upattern, new DecimalFormatSymbols("fr", status), status);
- fmt.setCurrency(kJPY);
- fmt.format(433.22, result);
- assertSuccess("", status);
- assertEquals("", "JPY ****433", result, TRUE);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating DecimalFormat - %s", u_errorName(status));
+ } else {
+ fmt.setCurrency(kJPY);
+ fmt.format(433.22, result);
+ assertSuccess("", status);
+ assertEquals("", "JPY ****433", result, TRUE);
+ }
}
{
UnicodeString upattern(
upattern,
new DecimalFormatSymbols("en_US", status),
status);
- fmt.format(-433.22, result);
- assertSuccess("", status);
- assertEquals("", "USD (433.22)", result, TRUE);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating DecimalFormat - %s", u_errorName(status));
+ } else {
+ fmt.format(-433.22, result);
+ assertSuccess("", status);
+ assertEquals("", "USD (433.22)", result, TRUE);
+ }
}
const char *paddedSciPattern = "QU**00.#####E0";
assertPatternFr("QU***43,3E-1", 4.33, paddedSciPattern, TRUE);
paddedSciPattern,
sym,
status);
- UnicodeString result;
- fmt.format(4.33, result);
- assertSuccess("", status);
- assertEquals("", "QU**43,3EE-1", result, TRUE);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating DecimalFormat - %s", u_errorName(status));
+ } else {
+ UnicodeString result;
+ fmt.format(4.33, result);
+ assertSuccess("", status);
+ assertEquals("", "QU**43,3EE-1", result, TRUE);
+ }
}
// padding cannot work as intended with scientific notation.
assertPatternFr("QU**43,32E-1", 4.332, paddedSciPattern, TRUE);
UnicodeString result;
DecimalFormat fmt(
upattern, new DecimalFormatSymbols("fr_FR", status), status);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating DecimalFormatSymbols - %s", u_errorName(status));
+ return;
+ }
fmt.format(x, result);
fixNonBreakingSpace(result);
assertSuccess("", status);