| Index: source/test/intltest/dcfmapts.cpp
|
| diff --git a/source/test/intltest/dcfmapts.cpp b/source/test/intltest/dcfmapts.cpp
|
| index 17f7f8fc43f894b88c2064cda5a5b82337d88359..2f7dd3f5a06c4a5da763f454c7b4f1cd1608c88d 100644
|
| --- a/source/test/intltest/dcfmapts.cpp
|
| +++ b/source/test/intltest/dcfmapts.cpp
|
| @@ -1,6 +1,6 @@
|
| /********************************************************************
|
| * COPYRIGHT:
|
| - * Copyright (c) 1997-2014, International Business Machines Corporation and
|
| + * Copyright (c) 1997-2015, International Business Machines Corporation and
|
| * others. All Rights Reserved.
|
| ********************************************************************/
|
|
|
| @@ -113,6 +113,10 @@ void IntlTestDecimalFormatAPI::testAPI(/*char *par*/)
|
| if (noGrouping.getGroupingSize() != 0) {
|
| errln("Grouping size should be 0 for no grouping.");
|
| }
|
| + noGrouping.setGroupingUsed(TRUE);
|
| + if (noGrouping.getGroupingSize() != 0) {
|
| + errln("Grouping size should still be 0.");
|
| + }
|
| // end bug 10864
|
|
|
| status = U_ZERO_ERROR;
|
| @@ -443,6 +447,7 @@ void IntlTestDecimalFormatAPI::TestCurrencyPluralInfo(){
|
| DecimalFormat *df = new DecimalFormat(status);
|
| if(U_FAILURE(status)) {
|
| errcheckln(status, "ERROR: Could not create DecimalFormat - %s", u_errorName(status));
|
| + return;
|
| }
|
|
|
| df->adoptCurrencyPluralInfo(cpi);
|
| @@ -601,25 +606,115 @@ void IntlTestDecimalFormatAPI::TestScale()
|
| void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| UErrorCode status = U_ZERO_ERROR;
|
|
|
| - LocalPointer<DecimalFormat> df(new DecimalFormat("###", status));
|
| + LocalPointer<DecimalFormat> df(new DecimalFormat("###", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| + if (status == U_MISSING_RESOURCE_ERROR) {
|
| + return;
|
| + }
|
| FixedDecimal fd = df->getFixedDecimal(44, status);
|
| TEST_ASSERT_STATUS(status);
|
| ASSERT_EQUAL(44, fd.source);
|
| ASSERT_EQUAL(0, fd.visibleDecimalDigitCount);
|
| + ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("###.00##", status));
|
| + fd = df->getFixedDecimal(-44, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(44, fd.source);
|
| + ASSERT_EQUAL(0, fd.visibleDecimalDigitCount);
|
| + ASSERT_EQUAL(TRUE, fd.isNegative);
|
| +
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.00##", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(123.456, status);
|
| TEST_ASSERT_STATUS(status);
|
| - ASSERT_EQUAL(3, fd.visibleDecimalDigitCount);
|
| - ASSERT_EQUAL(456, fd.decimalDigits);
|
| - ASSERT_EQUAL(456, fd.decimalDigitsWithoutTrailingZeros);
|
| - ASSERT_EQUAL(123, fd.intValue);
|
| + ASSERT_EQUAL(3, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(456, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(456, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(123, fd.intValue); // i
|
| + ASSERT_EQUAL(123.456, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(FALSE, fd.isNegative);
|
| +
|
| + fd = df->getFixedDecimal(-123.456, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(3, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(456, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(456, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(123, fd.intValue); // i
|
| + ASSERT_EQUAL(123.456, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(TRUE, fd.isNegative);
|
| +
|
| + // test max int digits
|
| + df->setMaximumIntegerDigits(2);
|
| + fd = df->getFixedDecimal(123.456, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(3, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(456, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(456, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(23, fd.intValue); // i
|
| + ASSERT_EQUAL(23.456, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(FALSE, fd.isNegative);
|
| +
|
| + fd = df->getFixedDecimal(-123.456, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(3, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(456, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(456, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(23, fd.intValue); // i
|
| + ASSERT_EQUAL(23.456, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(TRUE, fd.isNegative);
|
| +
|
| + // test max fraction digits
|
| + df->setMaximumIntegerDigits(2000000000);
|
| + df->setMaximumFractionDigits(2);
|
| + fd = df->getFixedDecimal(123.456, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(2, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(46, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(46, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(123, fd.intValue); // i
|
| + ASSERT_EQUAL(123.46, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(FALSE, fd.isNegative);
|
| +
|
| + fd = df->getFixedDecimal(-123.456, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(2, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(46, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(46, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(123, fd.intValue); // i
|
| + ASSERT_EQUAL(123.46, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(TRUE, fd.isNegative);
|
| +
|
| + // test esoteric rounding
|
| + df->setMaximumFractionDigits(6);
|
| + df->setRoundingIncrement(7.3);
|
| +
|
| + fd = df->getFixedDecimal(30.0, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(2, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(20, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(2, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(29, fd.intValue); // i
|
| + ASSERT_EQUAL(29.2, fd.source); // n
|
| ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("###", status));
|
| + fd = df->getFixedDecimal(-30.0, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(2, fd.visibleDecimalDigitCount); // v
|
| + ASSERT_EQUAL(20, fd.decimalDigits); // f
|
| + ASSERT_EQUAL(2, fd.decimalDigitsWithoutTrailingZeros); // t
|
| + ASSERT_EQUAL(29, fd.intValue); // i
|
| + ASSERT_EQUAL(29.2, fd.source); // n
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(TRUE, fd.isNegative);
|
| +
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(123.456, status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -630,7 +725,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| ASSERT_EQUAL(TRUE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("###.0", status));
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.0", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(123.01, status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -641,7 +736,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| ASSERT_EQUAL(TRUE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("###.0", status));
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.0", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(123.06, status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -652,7 +747,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("@@@@@", status)); // Significant Digits
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("@@@@@", status), status); // Significant Digits
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(123, status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -663,7 +758,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| ASSERT_EQUAL(TRUE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| - df.adoptInstead(new DecimalFormat("@@@@@", status)); // Significant Digits
|
| + df.adoptInsteadAndCheckErrorCode(new DecimalFormat("@@@@@", status), status); // Significant Digits
|
| TEST_ASSERT_STATUS(status);
|
| fd = df->getFixedDecimal(1.23, status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -686,7 +781,8 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| // Test Big Decimal input.
|
| // 22 digits before and after decimal, will exceed the precision of a double
|
| // and force DecimalFormat::getFixedDecimal() to work with a digit list.
|
| - df.adoptInstead(new DecimalFormat("#####################0.00####################", status));
|
| + df.adoptInsteadAndCheckErrorCode(
|
| + new DecimalFormat("#####################0.00####################", status), status);
|
| TEST_ASSERT_STATUS(status);
|
| Formattable fable("12.34", status);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -770,6 +866,17 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| ASSERT_EQUAL(FALSE, fd.isNegative);
|
|
|
| + fable.setDecimalNumber("1000000000000000050000.3", status);
|
| + TEST_ASSERT_STATUS(status);
|
| + fd = df->getFixedDecimal(fable, status);
|
| + TEST_ASSERT_STATUS(status);
|
| + ASSERT_EQUAL(2, fd.visibleDecimalDigitCount);
|
| + ASSERT_EQUAL(30, fd.decimalDigits);
|
| + ASSERT_EQUAL(3, fd.decimalDigitsWithoutTrailingZeros);
|
| + ASSERT_EQUAL(50000LL, fd.intValue);
|
| + ASSERT_EQUAL(FALSE, fd.hasIntegerValue);
|
| + ASSERT_EQUAL(FALSE, fd.isNegative);
|
| +
|
| // Test some int64_t values that are out of the range of a double
|
| fable.setInt64(4503599627370496LL);
|
| TEST_ASSERT_STATUS(status);
|
| @@ -814,7 +921,7 @@ void IntlTestDecimalFormatAPI::TestFixedDecimal() {
|
| void IntlTestDecimalFormatAPI::TestBadFastpath() {
|
| UErrorCode status = U_ZERO_ERROR;
|
|
|
| - LocalPointer<DecimalFormat> df(new DecimalFormat("###", status));
|
| + LocalPointer<DecimalFormat> df(new DecimalFormat("###", status), status);
|
| if (U_FAILURE(status)) {
|
| dataerrln("Error creating new DecimalFormat - %s", u_errorName(status));
|
| return;
|
| @@ -827,6 +934,7 @@ void IntlTestDecimalFormatAPI::TestBadFastpath() {
|
| fmt.remove();
|
| assertEquals("Format 1234", "1234", df->format(1234, fmt));
|
| df->setGroupingUsed(TRUE);
|
| + df->setGroupingSize(3);
|
| fmt.remove();
|
| assertEquals("Format 1234 w/ grouping", "1,234", df->format(1234, fmt));
|
| }
|
| @@ -838,7 +946,7 @@ void IntlTestDecimalFormatAPI::TestRequiredDecimalPoint() {
|
| UnicodeString pat1("##.0000");
|
| UnicodeString pat2("00.0");
|
|
|
| - LocalPointer<DecimalFormat> df(new DecimalFormat(pat1, status));
|
| + LocalPointer<DecimalFormat> df(new DecimalFormat(pat1, status), status);
|
| if (U_FAILURE(status)) {
|
| dataerrln("Error creating new DecimalFormat - %s", u_errorName(status));
|
| return;
|
|
|