12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
32e5b6d6dSopenharmony_ci/********************************************************************
42e5b6d6dSopenharmony_ci * COPYRIGHT:
52e5b6d6dSopenharmony_ci * Copyright (c) 1997-2015, International Business Machines Corporation and
62e5b6d6dSopenharmony_ci * others. All Rights Reserved.
72e5b6d6dSopenharmony_ci ********************************************************************/
82e5b6d6dSopenharmony_ci
92e5b6d6dSopenharmony_ci#include "unicode/utypes.h"
102e5b6d6dSopenharmony_ci
112e5b6d6dSopenharmony_ci#if !UCONFIG_NO_FORMATTING
122e5b6d6dSopenharmony_ci
132e5b6d6dSopenharmony_ci#include "dcfmapts.h"
142e5b6d6dSopenharmony_ci
152e5b6d6dSopenharmony_ci#include "unicode/currpinf.h"
162e5b6d6dSopenharmony_ci#include "unicode/dcfmtsym.h"
172e5b6d6dSopenharmony_ci#include "unicode/decimfmt.h"
182e5b6d6dSopenharmony_ci#include "unicode/fmtable.h"
192e5b6d6dSopenharmony_ci#include "unicode/localpointer.h"
202e5b6d6dSopenharmony_ci#include "unicode/parseerr.h"
212e5b6d6dSopenharmony_ci#include "unicode/stringpiece.h"
222e5b6d6dSopenharmony_ci
232e5b6d6dSopenharmony_ci#include "putilimp.h"
242e5b6d6dSopenharmony_ci#include "plurrule_impl.h"
252e5b6d6dSopenharmony_ci#include "number_decimalquantity.h"
262e5b6d6dSopenharmony_ci
272e5b6d6dSopenharmony_ci#include <stdio.h>
282e5b6d6dSopenharmony_ci
292e5b6d6dSopenharmony_ci// This is an API test, not a unit test.  It doesn't test very many cases, and doesn't
302e5b6d6dSopenharmony_ci// try to test the full functionality.  It just calls each function in the class and
312e5b6d6dSopenharmony_ci// verifies that it works on a basic level.
322e5b6d6dSopenharmony_ci
332e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
342e5b6d6dSopenharmony_ci{
352e5b6d6dSopenharmony_ci    if (exec) logln((UnicodeString)"TestSuite DecimalFormatAPI");
362e5b6d6dSopenharmony_ci    switch (index) {
372e5b6d6dSopenharmony_ci        case 0: name = "DecimalFormat API test";
382e5b6d6dSopenharmony_ci                if (exec) {
392e5b6d6dSopenharmony_ci                    logln((UnicodeString)"DecimalFormat API test---"); logln((UnicodeString)"");
402e5b6d6dSopenharmony_ci                    UErrorCode status = U_ZERO_ERROR;
412e5b6d6dSopenharmony_ci                    Locale saveLocale;
422e5b6d6dSopenharmony_ci                    Locale::setDefault(Locale::getEnglish(), status);
432e5b6d6dSopenharmony_ci                    if(U_FAILURE(status)) {
442e5b6d6dSopenharmony_ci                        errln((UnicodeString)"ERROR: Could not set default locale, test may not give correct results");
452e5b6d6dSopenharmony_ci                    }
462e5b6d6dSopenharmony_ci                    testAPI(/*par*/);
472e5b6d6dSopenharmony_ci                    Locale::setDefault(saveLocale, status);
482e5b6d6dSopenharmony_ci                }
492e5b6d6dSopenharmony_ci                break;
502e5b6d6dSopenharmony_ci        case 1: name = "Rounding test";
512e5b6d6dSopenharmony_ci            if(exec) {
522e5b6d6dSopenharmony_ci               logln((UnicodeString)"DecimalFormat Rounding test---");
532e5b6d6dSopenharmony_ci               testRounding(/*par*/);
542e5b6d6dSopenharmony_ci            }
552e5b6d6dSopenharmony_ci            break;
562e5b6d6dSopenharmony_ci        case 2: name = "Test6354";
572e5b6d6dSopenharmony_ci            if(exec) {
582e5b6d6dSopenharmony_ci               logln((UnicodeString)"DecimalFormat Rounding Increment test---");
592e5b6d6dSopenharmony_ci               testRoundingInc(/*par*/);
602e5b6d6dSopenharmony_ci            }
612e5b6d6dSopenharmony_ci            break;
622e5b6d6dSopenharmony_ci        case 3: name = "TestCurrencyPluralInfo";
632e5b6d6dSopenharmony_ci            if(exec) {
642e5b6d6dSopenharmony_ci               logln((UnicodeString)"CurrencyPluralInfo API test---");
652e5b6d6dSopenharmony_ci               TestCurrencyPluralInfo();
662e5b6d6dSopenharmony_ci            }
672e5b6d6dSopenharmony_ci            break;
682e5b6d6dSopenharmony_ci        case 4: name = "TestScale";
692e5b6d6dSopenharmony_ci            if(exec) {
702e5b6d6dSopenharmony_ci               logln((UnicodeString)"Scale test---");
712e5b6d6dSopenharmony_ci               TestScale();
722e5b6d6dSopenharmony_ci            }
732e5b6d6dSopenharmony_ci            break;
742e5b6d6dSopenharmony_ci         case 5: name = "TestFixedDecimal";
752e5b6d6dSopenharmony_ci            if(exec) {
762e5b6d6dSopenharmony_ci               logln((UnicodeString)"TestFixedDecimal ---");
772e5b6d6dSopenharmony_ci               TestFixedDecimal();
782e5b6d6dSopenharmony_ci            }
792e5b6d6dSopenharmony_ci            break;
802e5b6d6dSopenharmony_ci         case 6: name = "TestBadFastpath";
812e5b6d6dSopenharmony_ci            if(exec) {
822e5b6d6dSopenharmony_ci               logln((UnicodeString)"TestBadFastpath ---");
832e5b6d6dSopenharmony_ci               TestBadFastpath();
842e5b6d6dSopenharmony_ci            }
852e5b6d6dSopenharmony_ci            break;
862e5b6d6dSopenharmony_ci         case 7: name = "TestRequiredDecimalPoint";
872e5b6d6dSopenharmony_ci            if(exec) {
882e5b6d6dSopenharmony_ci               logln((UnicodeString)"TestRequiredDecimalPoint ---");
892e5b6d6dSopenharmony_ci               TestRequiredDecimalPoint();
902e5b6d6dSopenharmony_ci            }
912e5b6d6dSopenharmony_ci            break;
922e5b6d6dSopenharmony_ci         case 8: name = "testErrorCode";
932e5b6d6dSopenharmony_ci            if(exec) {
942e5b6d6dSopenharmony_ci               logln((UnicodeString)"testErrorCode ---");
952e5b6d6dSopenharmony_ci               testErrorCode();
962e5b6d6dSopenharmony_ci            }
972e5b6d6dSopenharmony_ci            break;
982e5b6d6dSopenharmony_ci         case 9: name = "testInvalidObject";
992e5b6d6dSopenharmony_ci            if(exec) {
1002e5b6d6dSopenharmony_ci                logln((UnicodeString) "testInvalidObject ---");
1012e5b6d6dSopenharmony_ci                testInvalidObject();
1022e5b6d6dSopenharmony_ci            }
1032e5b6d6dSopenharmony_ci            break;
1042e5b6d6dSopenharmony_ci       default: name = ""; break;
1052e5b6d6dSopenharmony_ci    }
1062e5b6d6dSopenharmony_ci}
1072e5b6d6dSopenharmony_ci
1082e5b6d6dSopenharmony_ci/**
1092e5b6d6dSopenharmony_ci * This test checks various generic API methods in DecimalFormat to achieve 100%
1102e5b6d6dSopenharmony_ci * API coverage.
1112e5b6d6dSopenharmony_ci */
1122e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::testAPI(/*char *par*/)
1132e5b6d6dSopenharmony_ci{
1142e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
1152e5b6d6dSopenharmony_ci
1162e5b6d6dSopenharmony_ci// ======= Test constructors
1172e5b6d6dSopenharmony_ci
1182e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing DecimalFormat constructors");
1192e5b6d6dSopenharmony_ci
1202e5b6d6dSopenharmony_ci    DecimalFormat def(status);
1212e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
1222e5b6d6dSopenharmony_ci        errcheckln(status, "ERROR: Could not create DecimalFormat (default) - %s", u_errorName(status));
1232e5b6d6dSopenharmony_ci        return;
1242e5b6d6dSopenharmony_ci    }
1252e5b6d6dSopenharmony_ci
1262e5b6d6dSopenharmony_ci    // bug 10864
1272e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1282e5b6d6dSopenharmony_ci    DecimalFormat noGrouping("###0.##", status);
1292e5b6d6dSopenharmony_ci    assertEquals("Grouping size should be 0 for no grouping.", 0, noGrouping.getGroupingSize());
1302e5b6d6dSopenharmony_ci    noGrouping.setGroupingUsed(true);
1312e5b6d6dSopenharmony_ci    assertEquals("Grouping size should still be 0.", 0, noGrouping.getGroupingSize());
1322e5b6d6dSopenharmony_ci    // end bug 10864
1332e5b6d6dSopenharmony_ci
1342e5b6d6dSopenharmony_ci    // bug 13442 comment 14
1352e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1362e5b6d6dSopenharmony_ci    {
1372e5b6d6dSopenharmony_ci        DecimalFormat df("0", {"en", status}, status);
1382e5b6d6dSopenharmony_ci        UnicodeString result;
1392e5b6d6dSopenharmony_ci        assertEquals("pat 0: ", 0, df.getGroupingSize());
1402e5b6d6dSopenharmony_ci        assertEquals("pat 0: ", (UBool) false, (UBool) df.isGroupingUsed());
1412e5b6d6dSopenharmony_ci        df.setGroupingUsed(false);
1422e5b6d6dSopenharmony_ci        assertEquals("pat 0 then disabled: ", 0, df.getGroupingSize());
1432e5b6d6dSopenharmony_ci        assertEquals("pat 0 then disabled: ", u"1111", df.format(1111, result.remove()));
1442e5b6d6dSopenharmony_ci        df.setGroupingUsed(true);
1452e5b6d6dSopenharmony_ci        assertEquals("pat 0 then enabled: ", 0, df.getGroupingSize());
1462e5b6d6dSopenharmony_ci        assertEquals("pat 0 then enabled: ", u"1111", df.format(1111, result.remove()));
1472e5b6d6dSopenharmony_ci    }
1482e5b6d6dSopenharmony_ci    {
1492e5b6d6dSopenharmony_ci        DecimalFormat df("#,##0", {"en", status}, status);
1502e5b6d6dSopenharmony_ci        UnicodeString result;
1512e5b6d6dSopenharmony_ci        assertEquals("pat #,##0: ", 3, df.getGroupingSize());
1522e5b6d6dSopenharmony_ci        assertEquals("pat #,##0: ", (UBool) true, (UBool) df.isGroupingUsed());
1532e5b6d6dSopenharmony_ci        df.setGroupingUsed(false);
1542e5b6d6dSopenharmony_ci        assertEquals("pat #,##0 then disabled: ", 3, df.getGroupingSize());
1552e5b6d6dSopenharmony_ci        assertEquals("pat #,##0 then disabled: ", u"1111", df.format(1111, result.remove()));
1562e5b6d6dSopenharmony_ci        df.setGroupingUsed(true);
1572e5b6d6dSopenharmony_ci        assertEquals("pat #,##0 then enabled: ", 3, df.getGroupingSize());
1582e5b6d6dSopenharmony_ci        assertEquals("pat #,##0 then enabled: ", u"1,111", df.format(1111, result.remove()));
1592e5b6d6dSopenharmony_ci    }
1602e5b6d6dSopenharmony_ci    // end bug 13442 comment 14
1612e5b6d6dSopenharmony_ci
1622e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1632e5b6d6dSopenharmony_ci    const UnicodeString pattern("#,##0.# FF");
1642e5b6d6dSopenharmony_ci    DecimalFormat pat(pattern, status);
1652e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
1662e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern)");
1672e5b6d6dSopenharmony_ci        return;
1682e5b6d6dSopenharmony_ci    }
1692e5b6d6dSopenharmony_ci
1702e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1712e5b6d6dSopenharmony_ci    DecimalFormatSymbols *symbols = new DecimalFormatSymbols(Locale::getFrench(), status);
1722e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
1732e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Could not create DecimalFormatSymbols (French)");
1742e5b6d6dSopenharmony_ci        return;
1752e5b6d6dSopenharmony_ci    }
1762e5b6d6dSopenharmony_ci
1772e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1782e5b6d6dSopenharmony_ci    DecimalFormat cust1(pattern, *symbols, status);
1792e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
1802e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols)");
1812e5b6d6dSopenharmony_ci    }
1822e5b6d6dSopenharmony_ci
1832e5b6d6dSopenharmony_ci    // NOTE: The test where you pass "symbols" as a pointer has to come second-- the DecimalFormat
1842e5b6d6dSopenharmony_ci    // object is _adopting_ this object, meaning it's unavailable for use by this test (e.g.,
1852e5b6d6dSopenharmony_ci    // to pass to another DecimalFormat) after the call to the DecimalFormat constructor.
1862e5b6d6dSopenharmony_ci    // The call above, where we're passing it by reference, doesn't take ownership of the
1872e5b6d6dSopenharmony_ci    // symbols object, so we can reuse it here.
1882e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
1892e5b6d6dSopenharmony_ci    DecimalFormat cust2(pattern, symbols, status);
1902e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
1912e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
1922e5b6d6dSopenharmony_ci    }
1932e5b6d6dSopenharmony_ci
1942e5b6d6dSopenharmony_ci    DecimalFormat copy(pat);
1952e5b6d6dSopenharmony_ci
1962e5b6d6dSopenharmony_ci// ======= Test clone(), assignment, and equality
1972e5b6d6dSopenharmony_ci
1982e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing clone(), assignment and equality operators");
1992e5b6d6dSopenharmony_ci
2002e5b6d6dSopenharmony_ci    if( ! (copy == pat) || copy != pat) {
2012e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Copy constructor or == failed");
2022e5b6d6dSopenharmony_ci    }
2032e5b6d6dSopenharmony_ci
2042e5b6d6dSopenharmony_ci    copy = cust1;
2052e5b6d6dSopenharmony_ci    if(copy != cust1) {
2062e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Assignment (or !=) failed");
2072e5b6d6dSopenharmony_ci    }
2082e5b6d6dSopenharmony_ci
2092e5b6d6dSopenharmony_ci    Format *clone = def.clone();
2102e5b6d6dSopenharmony_ci    if( ! (*clone == def) ) {
2112e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Clone() failed");
2122e5b6d6dSopenharmony_ci    }
2132e5b6d6dSopenharmony_ci    delete clone;
2142e5b6d6dSopenharmony_ci
2152e5b6d6dSopenharmony_ci// ======= Test various format() methods
2162e5b6d6dSopenharmony_ci
2172e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing various format() methods");
2182e5b6d6dSopenharmony_ci
2192e5b6d6dSopenharmony_ci    double d = -10456.0037;
2202e5b6d6dSopenharmony_ci    int32_t l = 100000000;
2212e5b6d6dSopenharmony_ci    Formattable fD(d);
2222e5b6d6dSopenharmony_ci    Formattable fL(l);
2232e5b6d6dSopenharmony_ci
2242e5b6d6dSopenharmony_ci    UnicodeString res1, res2, res3, res4;
2252e5b6d6dSopenharmony_ci    FieldPosition pos1(FieldPosition::DONT_CARE), pos2(FieldPosition::DONT_CARE), pos3(FieldPosition::DONT_CARE), pos4(FieldPosition::DONT_CARE);
2262e5b6d6dSopenharmony_ci
2272e5b6d6dSopenharmony_ci    res1 = def.format(d, res1, pos1);
2282e5b6d6dSopenharmony_ci    logln( (UnicodeString) "" + (int32_t) d + " formatted to " + res1);
2292e5b6d6dSopenharmony_ci
2302e5b6d6dSopenharmony_ci    res2 = pat.format(l, res2, pos2);
2312e5b6d6dSopenharmony_ci    logln((UnicodeString) "" + (int32_t) l + " formatted to " + res2);
2322e5b6d6dSopenharmony_ci
2332e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
2342e5b6d6dSopenharmony_ci    res3 = cust1.format(fD, res3, pos3, status);
2352e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
2362e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: format(Formattable [double]) failed");
2372e5b6d6dSopenharmony_ci    }
2382e5b6d6dSopenharmony_ci    logln((UnicodeString) "" + (int32_t) fD.getDouble() + " formatted to " + res3);
2392e5b6d6dSopenharmony_ci
2402e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
2412e5b6d6dSopenharmony_ci    res4 = cust2.format(fL, res4, pos4, status);
2422e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
2432e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: format(Formattable [long]) failed");
2442e5b6d6dSopenharmony_ci    }
2452e5b6d6dSopenharmony_ci    logln((UnicodeString) "" + fL.getLong() + " formatted to " + res4);
2462e5b6d6dSopenharmony_ci
2472e5b6d6dSopenharmony_ci// ======= Test parse()
2482e5b6d6dSopenharmony_ci
2492e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing parse()");
2502e5b6d6dSopenharmony_ci
2512e5b6d6dSopenharmony_ci    UnicodeString text("-10,456.0037");
2522e5b6d6dSopenharmony_ci    Formattable result1, result2;
2532e5b6d6dSopenharmony_ci    ParsePosition pos(0);
2542e5b6d6dSopenharmony_ci    UnicodeString patt("#,##0.#");
2552e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
2562e5b6d6dSopenharmony_ci    pat.applyPattern(patt, status);
2572e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
2582e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern() failed");
2592e5b6d6dSopenharmony_ci    }
2602e5b6d6dSopenharmony_ci    pat.parse(text, result1, pos);
2612e5b6d6dSopenharmony_ci    if(result1.getType() != Formattable::kDouble && result1.getDouble() != d) {
2622e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Roundtrip failed (via parse()) for " + text);
2632e5b6d6dSopenharmony_ci    }
2642e5b6d6dSopenharmony_ci    logln(text + " parsed into " + (int32_t) result1.getDouble());
2652e5b6d6dSopenharmony_ci
2662e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
2672e5b6d6dSopenharmony_ci    pat.parse(text, result2, status);
2682e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
2692e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: parse() failed");
2702e5b6d6dSopenharmony_ci    }
2712e5b6d6dSopenharmony_ci    if(result2.getType() != Formattable::kDouble && result2.getDouble() != d) {
2722e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Roundtrip failed (via parse()) for " + text);
2732e5b6d6dSopenharmony_ci    }
2742e5b6d6dSopenharmony_ci    logln(text + " parsed into " + (int32_t) result2.getDouble());
2752e5b6d6dSopenharmony_ci
2762e5b6d6dSopenharmony_ci// ======= Test getters and setters
2772e5b6d6dSopenharmony_ci
2782e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing getters and setters");
2792e5b6d6dSopenharmony_ci
2802e5b6d6dSopenharmony_ci    const DecimalFormatSymbols *syms = pat.getDecimalFormatSymbols();
2812e5b6d6dSopenharmony_ci    DecimalFormatSymbols *newSyms = new DecimalFormatSymbols(*syms);
2822e5b6d6dSopenharmony_ci    def.setDecimalFormatSymbols(*newSyms);
2832e5b6d6dSopenharmony_ci    def.adoptDecimalFormatSymbols(newSyms); // don't use newSyms after this
2842e5b6d6dSopenharmony_ci    if( *(pat.getDecimalFormatSymbols()) != *(def.getDecimalFormatSymbols())) {
2852e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: adopt or set DecimalFormatSymbols() failed");
2862e5b6d6dSopenharmony_ci    }
2872e5b6d6dSopenharmony_ci
2882e5b6d6dSopenharmony_ci    UnicodeString posPrefix;
2892e5b6d6dSopenharmony_ci    pat.setPositivePrefix("+");
2902e5b6d6dSopenharmony_ci    posPrefix = pat.getPositivePrefix(posPrefix);
2912e5b6d6dSopenharmony_ci    logln((UnicodeString)"Positive prefix (should be +): " + posPrefix);
2922e5b6d6dSopenharmony_ci    if(posPrefix != "+") {
2932e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setPositivePrefix() failed");
2942e5b6d6dSopenharmony_ci    }
2952e5b6d6dSopenharmony_ci
2962e5b6d6dSopenharmony_ci    UnicodeString negPrefix;
2972e5b6d6dSopenharmony_ci    pat.setNegativePrefix("-");
2982e5b6d6dSopenharmony_ci    negPrefix = pat.getNegativePrefix(negPrefix);
2992e5b6d6dSopenharmony_ci    logln((UnicodeString)"Negative prefix (should be -): " + negPrefix);
3002e5b6d6dSopenharmony_ci    if(negPrefix != "-") {
3012e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setNegativePrefix() failed");
3022e5b6d6dSopenharmony_ci    }
3032e5b6d6dSopenharmony_ci
3042e5b6d6dSopenharmony_ci    UnicodeString posSuffix;
3052e5b6d6dSopenharmony_ci    pat.setPositiveSuffix("_");
3062e5b6d6dSopenharmony_ci    posSuffix = pat.getPositiveSuffix(posSuffix);
3072e5b6d6dSopenharmony_ci    logln((UnicodeString)"Positive suffix (should be _): " + posSuffix);
3082e5b6d6dSopenharmony_ci    if(posSuffix != "_") {
3092e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setPositiveSuffix() failed");
3102e5b6d6dSopenharmony_ci    }
3112e5b6d6dSopenharmony_ci
3122e5b6d6dSopenharmony_ci    UnicodeString negSuffix;
3132e5b6d6dSopenharmony_ci    pat.setNegativeSuffix("~");
3142e5b6d6dSopenharmony_ci    negSuffix = pat.getNegativeSuffix(negSuffix);
3152e5b6d6dSopenharmony_ci    logln((UnicodeString)"Negative suffix (should be ~): " + negSuffix);
3162e5b6d6dSopenharmony_ci    if(negSuffix != "~") {
3172e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setNegativeSuffix() failed");
3182e5b6d6dSopenharmony_ci    }
3192e5b6d6dSopenharmony_ci
3202e5b6d6dSopenharmony_ci    int32_t multiplier = 0;
3212e5b6d6dSopenharmony_ci    pat.setMultiplier(8);
3222e5b6d6dSopenharmony_ci    multiplier = pat.getMultiplier();
3232e5b6d6dSopenharmony_ci    logln((UnicodeString)"Multiplier (should be 8): " + multiplier);
3242e5b6d6dSopenharmony_ci    if(multiplier != 8) {
3252e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setMultiplier() failed");
3262e5b6d6dSopenharmony_ci    }
3272e5b6d6dSopenharmony_ci
3282e5b6d6dSopenharmony_ci    int32_t groupingSize = 0;
3292e5b6d6dSopenharmony_ci    pat.setGroupingSize(2);
3302e5b6d6dSopenharmony_ci    groupingSize = pat.getGroupingSize();
3312e5b6d6dSopenharmony_ci    logln((UnicodeString)"Grouping size (should be 2): " + (int32_t) groupingSize);
3322e5b6d6dSopenharmony_ci    if(groupingSize != 2) {
3332e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setGroupingSize() failed");
3342e5b6d6dSopenharmony_ci    }
3352e5b6d6dSopenharmony_ci
3362e5b6d6dSopenharmony_ci    pat.setDecimalSeparatorAlwaysShown(true);
3372e5b6d6dSopenharmony_ci    UBool tf = pat.isDecimalSeparatorAlwaysShown();
3382e5b6d6dSopenharmony_ci    logln((UnicodeString)"DecimalSeparatorIsAlwaysShown (should be true) is " + (UnicodeString) (tf ? "true" : "false"));
3392e5b6d6dSopenharmony_ci    if(tf != true) {
3402e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setDecimalSeparatorAlwaysShown() failed");
3412e5b6d6dSopenharmony_ci    }
3422e5b6d6dSopenharmony_ci    // Added by Ken Liu testing set/isExponentSignAlwaysShown
3432e5b6d6dSopenharmony_ci    pat.setExponentSignAlwaysShown(true);
3442e5b6d6dSopenharmony_ci    UBool esas = pat.isExponentSignAlwaysShown();
3452e5b6d6dSopenharmony_ci    logln((UnicodeString)"ExponentSignAlwaysShown (should be true) is " + (UnicodeString) (esas ? "true" : "false"));
3462e5b6d6dSopenharmony_ci    if(esas != true) {
3472e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: ExponentSignAlwaysShown() failed");
3482e5b6d6dSopenharmony_ci    }
3492e5b6d6dSopenharmony_ci
3502e5b6d6dSopenharmony_ci    // Added by Ken Liu testing set/isScientificNotation
3512e5b6d6dSopenharmony_ci    pat.setScientificNotation(true);
3522e5b6d6dSopenharmony_ci    UBool sn = pat.isScientificNotation();
3532e5b6d6dSopenharmony_ci    logln((UnicodeString)"isScientificNotation (should be true) is " + (UnicodeString) (sn ? "true" : "false"));
3542e5b6d6dSopenharmony_ci    if(sn != true) {
3552e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setScientificNotation() failed");
3562e5b6d6dSopenharmony_ci    }
3572e5b6d6dSopenharmony_ci
3582e5b6d6dSopenharmony_ci    // Added by Ken Liu testing set/getMinimumExponentDigits
3592e5b6d6dSopenharmony_ci    int8_t MinimumExponentDigits = 0;
3602e5b6d6dSopenharmony_ci    pat.setMinimumExponentDigits(2);
3612e5b6d6dSopenharmony_ci    MinimumExponentDigits = pat.getMinimumExponentDigits();
3622e5b6d6dSopenharmony_ci    logln((UnicodeString)"MinimumExponentDigits (should be 2) is " + (int8_t) MinimumExponentDigits);
3632e5b6d6dSopenharmony_ci    if(MinimumExponentDigits != 2) {
3642e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setMinimumExponentDigits() failed");
3652e5b6d6dSopenharmony_ci    }
3662e5b6d6dSopenharmony_ci
3672e5b6d6dSopenharmony_ci    // Added by Ken Liu testing set/getRoundingIncrement
3682e5b6d6dSopenharmony_ci    double RoundingIncrement = 0.0;
3692e5b6d6dSopenharmony_ci    pat.setRoundingIncrement(2.0);
3702e5b6d6dSopenharmony_ci    RoundingIncrement = pat.getRoundingIncrement();
3712e5b6d6dSopenharmony_ci    logln((UnicodeString)"RoundingIncrement (should be 2.0) is " + (double) RoundingIncrement);
3722e5b6d6dSopenharmony_ci    if(RoundingIncrement != 2.0) {
3732e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: setRoundingIncrement() failed");
3742e5b6d6dSopenharmony_ci    }
3752e5b6d6dSopenharmony_ci    //end of Ken's Adding
3762e5b6d6dSopenharmony_ci
3772e5b6d6dSopenharmony_ci    UnicodeString funkyPat;
3782e5b6d6dSopenharmony_ci    funkyPat = pat.toPattern(funkyPat);
3792e5b6d6dSopenharmony_ci    logln((UnicodeString)"Pattern is " + funkyPat);
3802e5b6d6dSopenharmony_ci
3812e5b6d6dSopenharmony_ci    UnicodeString locPat;
3822e5b6d6dSopenharmony_ci    locPat = pat.toLocalizedPattern(locPat);
3832e5b6d6dSopenharmony_ci    logln((UnicodeString)"Localized pattern is " + locPat);
3842e5b6d6dSopenharmony_ci
3852e5b6d6dSopenharmony_ci// ======= Test applyPattern()
3862e5b6d6dSopenharmony_ci
3872e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing applyPattern()");
3882e5b6d6dSopenharmony_ci    pat = DecimalFormat(status); // reset
3892e5b6d6dSopenharmony_ci
3902e5b6d6dSopenharmony_ci    UnicodeString p1("#,##0.0#;(#,##0.0#)");
3912e5b6d6dSopenharmony_ci    logln((UnicodeString)"Applying pattern " + p1);
3922e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
3932e5b6d6dSopenharmony_ci    pat.applyPattern(p1, status);
3942e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
3952e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
3962e5b6d6dSopenharmony_ci    }
3972e5b6d6dSopenharmony_ci    UnicodeString s2;
3982e5b6d6dSopenharmony_ci    s2 = pat.toPattern(s2);
3992e5b6d6dSopenharmony_ci    logln((UnicodeString)"Extracted pattern is " + s2);
4002e5b6d6dSopenharmony_ci    assertEquals("toPattern() result did not match pattern applied", p1, s2);
4012e5b6d6dSopenharmony_ci
4022e5b6d6dSopenharmony_ci    if(pat.getSecondaryGroupingSize() != 0) {
4032e5b6d6dSopenharmony_ci        errln("FAIL: Secondary Grouping Size should be 0, not %d\n", pat.getSecondaryGroupingSize());
4042e5b6d6dSopenharmony_ci    }
4052e5b6d6dSopenharmony_ci
4062e5b6d6dSopenharmony_ci    if(pat.getGroupingSize() != 3) {
4072e5b6d6dSopenharmony_ci        errln("FAIL: Primary Grouping Size should be 3, not %d\n", pat.getGroupingSize());
4082e5b6d6dSopenharmony_ci    }
4092e5b6d6dSopenharmony_ci
4102e5b6d6dSopenharmony_ci    UnicodeString p2("#,##,##0.0# FF;(#,##,##0.0# FF)");
4112e5b6d6dSopenharmony_ci    logln((UnicodeString)"Applying pattern " + p2);
4122e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
4132e5b6d6dSopenharmony_ci    pat.applyLocalizedPattern(p2, status);
4142e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4152e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
4162e5b6d6dSopenharmony_ci    }
4172e5b6d6dSopenharmony_ci    UnicodeString s3;
4182e5b6d6dSopenharmony_ci    s3 = pat.toLocalizedPattern(s3);
4192e5b6d6dSopenharmony_ci    logln((UnicodeString)"Extracted pattern is " + s3);
4202e5b6d6dSopenharmony_ci    assertEquals("toLocalizedPattern() result did not match pattern applied", p2, s3);
4212e5b6d6dSopenharmony_ci
4222e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
4232e5b6d6dSopenharmony_ci    UParseError pe;
4242e5b6d6dSopenharmony_ci    pat.applyLocalizedPattern(p2, pe, status);
4252e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4262e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern((with ParseError)) failed with " + (int32_t) status);
4272e5b6d6dSopenharmony_ci    }
4282e5b6d6dSopenharmony_ci    UnicodeString s4;
4292e5b6d6dSopenharmony_ci    s4 = pat.toLocalizedPattern(s3);
4302e5b6d6dSopenharmony_ci    logln((UnicodeString)"Extracted pattern is " + s4);
4312e5b6d6dSopenharmony_ci    assertEquals("toLocalizedPattern(with ParseErr) result did not match pattern applied", p2, s4);
4322e5b6d6dSopenharmony_ci
4332e5b6d6dSopenharmony_ci    if(pat.getSecondaryGroupingSize() != 2) {
4342e5b6d6dSopenharmony_ci        errln("FAIL: Secondary Grouping Size should be 2, not %d\n", pat.getSecondaryGroupingSize());
4352e5b6d6dSopenharmony_ci    }
4362e5b6d6dSopenharmony_ci
4372e5b6d6dSopenharmony_ci    if(pat.getGroupingSize() != 3) {
4382e5b6d6dSopenharmony_ci        errln("FAIL: Primary Grouping Size should be 3, not %d\n", pat.getGroupingSize());
4392e5b6d6dSopenharmony_ci    }
4402e5b6d6dSopenharmony_ci
4412e5b6d6dSopenharmony_ci// ======= Test getStaticClassID()
4422e5b6d6dSopenharmony_ci
4432e5b6d6dSopenharmony_ci    logln((UnicodeString)"Testing getStaticClassID()");
4442e5b6d6dSopenharmony_ci
4452e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
4462e5b6d6dSopenharmony_ci    NumberFormat *test = new DecimalFormat(status);
4472e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4482e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: Couldn't create a DecimalFormat");
4492e5b6d6dSopenharmony_ci    }
4502e5b6d6dSopenharmony_ci
4512e5b6d6dSopenharmony_ci    if(test->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
4522e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: getDynamicClassID() didn't return the expected value");
4532e5b6d6dSopenharmony_ci    }
4542e5b6d6dSopenharmony_ci
4552e5b6d6dSopenharmony_ci    delete test;
4562e5b6d6dSopenharmony_ci}
4572e5b6d6dSopenharmony_ci
4582e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::TestCurrencyPluralInfo(){
4592e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
4602e5b6d6dSopenharmony_ci
4612e5b6d6dSopenharmony_ci    LocalPointer<CurrencyPluralInfo>cpi(new CurrencyPluralInfo(status), status);
4622e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4632e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: CurrencyPluralInfo(UErrorCode) could not be created");
4642e5b6d6dSopenharmony_ci        return;
4652e5b6d6dSopenharmony_ci    }
4662e5b6d6dSopenharmony_ci
4672e5b6d6dSopenharmony_ci    CurrencyPluralInfo cpi1 = *cpi;
4682e5b6d6dSopenharmony_ci
4692e5b6d6dSopenharmony_ci    if(cpi->getDynamicClassID() != CurrencyPluralInfo::getStaticClassID()){
4702e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: CurrencyPluralInfo::getDynamicClassID() didn't return the expected value");
4712e5b6d6dSopenharmony_ci    }
4722e5b6d6dSopenharmony_ci
4732e5b6d6dSopenharmony_ci    cpi->setCurrencyPluralPattern("","",status);
4742e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4752e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: CurrencyPluralInfo::setCurrencyPluralPattern");
4762e5b6d6dSopenharmony_ci    }
4772e5b6d6dSopenharmony_ci
4782e5b6d6dSopenharmony_ci    cpi->setLocale(Locale::getCanada(), status);
4792e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4802e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: CurrencyPluralInfo::setLocale");
4812e5b6d6dSopenharmony_ci    }
4822e5b6d6dSopenharmony_ci
4832e5b6d6dSopenharmony_ci    cpi->setPluralRules("",status);
4842e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4852e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: CurrencyPluralInfo::setPluralRules");
4862e5b6d6dSopenharmony_ci    }
4872e5b6d6dSopenharmony_ci
4882e5b6d6dSopenharmony_ci    LocalPointer<DecimalFormat>df(new DecimalFormat(status));
4892e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
4902e5b6d6dSopenharmony_ci        errcheckln(status, "ERROR: Could not create DecimalFormat - %s", u_errorName(status));
4912e5b6d6dSopenharmony_ci        return;
4922e5b6d6dSopenharmony_ci    }
4932e5b6d6dSopenharmony_ci
4942e5b6d6dSopenharmony_ci    df->adoptCurrencyPluralInfo(cpi.orphan());
4952e5b6d6dSopenharmony_ci
4962e5b6d6dSopenharmony_ci    df->getCurrencyPluralInfo();
4972e5b6d6dSopenharmony_ci
4982e5b6d6dSopenharmony_ci    df->setCurrencyPluralInfo(cpi1);
4992e5b6d6dSopenharmony_ci
5002e5b6d6dSopenharmony_ci}
5012e5b6d6dSopenharmony_ci
5022e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::testRounding(/*char *par*/)
5032e5b6d6dSopenharmony_ci{
5042e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
5052e5b6d6dSopenharmony_ci    double Roundingnumber = 2.55;
5062e5b6d6dSopenharmony_ci    double Roundingnumber1 = -2.55;
5072e5b6d6dSopenharmony_ci                      //+2.55 results   -2.55 results
5082e5b6d6dSopenharmony_ci    double result[]={   3.0,            -2.0,    //  kRoundCeiling  0,
5092e5b6d6dSopenharmony_ci                        2.0,            -3.0,    //  kRoundFloor    1,
5102e5b6d6dSopenharmony_ci                        2.0,            -2.0,    //  kRoundDown     2,
5112e5b6d6dSopenharmony_ci                        3.0,            -3.0,    //  kRoundUp       3,
5122e5b6d6dSopenharmony_ci                        3.0,            -3.0,    //  kRoundHalfEven 4,
5132e5b6d6dSopenharmony_ci                        3.0,            -3.0,    //  kRoundHalfDown 5,
5142e5b6d6dSopenharmony_ci                        3.0,            -3.0     //  kRoundHalfUp   6
5152e5b6d6dSopenharmony_ci    };
5162e5b6d6dSopenharmony_ci    DecimalFormat pat(status);
5172e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
5182e5b6d6dSopenharmony_ci      errcheckln(status, "ERROR: Could not create DecimalFormat (default) - %s", u_errorName(status));
5192e5b6d6dSopenharmony_ci      return;
5202e5b6d6dSopenharmony_ci    }
5212e5b6d6dSopenharmony_ci    uint16_t mode;
5222e5b6d6dSopenharmony_ci    uint16_t i=0;
5232e5b6d6dSopenharmony_ci    UnicodeString message;
5242e5b6d6dSopenharmony_ci    UnicodeString resultStr;
5252e5b6d6dSopenharmony_ci    for(mode=0;mode < 7;mode++){
5262e5b6d6dSopenharmony_ci        pat.setRoundingMode((DecimalFormat::ERoundingMode)mode);
5272e5b6d6dSopenharmony_ci        if(pat.getRoundingMode() != (DecimalFormat::ERoundingMode)mode){
5282e5b6d6dSopenharmony_ci            errln((UnicodeString)"SetRoundingMode or GetRoundingMode failed for mode=" + mode);
5292e5b6d6dSopenharmony_ci        }
5302e5b6d6dSopenharmony_ci
5312e5b6d6dSopenharmony_ci
5322e5b6d6dSopenharmony_ci        //for +2.55 with RoundingIncrement=1.0
5332e5b6d6dSopenharmony_ci        pat.setRoundingIncrement(1.0);
5342e5b6d6dSopenharmony_ci        pat.format(Roundingnumber, resultStr);
5352e5b6d6dSopenharmony_ci        message= (UnicodeString)"round(" + (double)Roundingnumber + UnicodeString(",") + mode + UnicodeString(",false) with RoundingIncrement=1.0==>");
5362e5b6d6dSopenharmony_ci        verify(message, resultStr, result[i++]);
5372e5b6d6dSopenharmony_ci        message.remove();
5382e5b6d6dSopenharmony_ci        resultStr.remove();
5392e5b6d6dSopenharmony_ci
5402e5b6d6dSopenharmony_ci        //for -2.55 with RoundingIncrement=1.0
5412e5b6d6dSopenharmony_ci        pat.format(Roundingnumber1, resultStr);
5422e5b6d6dSopenharmony_ci        message= (UnicodeString)"round(" + (double)Roundingnumber1 + UnicodeString(",") + mode + UnicodeString(",false) with RoundingIncrement=1.0==>");
5432e5b6d6dSopenharmony_ci        verify(message, resultStr, result[i++]);
5442e5b6d6dSopenharmony_ci        message.remove();
5452e5b6d6dSopenharmony_ci        resultStr.remove();
5462e5b6d6dSopenharmony_ci    }
5472e5b6d6dSopenharmony_ci
5482e5b6d6dSopenharmony_ci}
5492e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::verify(const UnicodeString& message, const UnicodeString& got, double expected){
5502e5b6d6dSopenharmony_ci    logln((UnicodeString)message + got + (UnicodeString)" Expected : " + expected);
5512e5b6d6dSopenharmony_ci    UnicodeString expectedStr("");
5522e5b6d6dSopenharmony_ci    expectedStr=expectedStr + expected;
5532e5b6d6dSopenharmony_ci    if(got != expectedStr ) {
5542e5b6d6dSopenharmony_ci            errln((UnicodeString)"ERROR: " + message + got + (UnicodeString)"  Expected : " + expectedStr);
5552e5b6d6dSopenharmony_ci        }
5562e5b6d6dSopenharmony_ci}
5572e5b6d6dSopenharmony_ci
5582e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::verifyString(const UnicodeString& message, const UnicodeString& got, UnicodeString& expected){
5592e5b6d6dSopenharmony_ci    logln((UnicodeString)message + got + (UnicodeString)" Expected : " + expected);
5602e5b6d6dSopenharmony_ci    if(got != expected ) {
5612e5b6d6dSopenharmony_ci            errln((UnicodeString)"ERROR: " + message + got + (UnicodeString)"  Expected : " + expected);
5622e5b6d6dSopenharmony_ci        }
5632e5b6d6dSopenharmony_ci}
5642e5b6d6dSopenharmony_ci
5652e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::testRoundingInc(/*char *par*/)
5662e5b6d6dSopenharmony_ci{
5672e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
5682e5b6d6dSopenharmony_ci    DecimalFormat pat(UnicodeString("#,##0.00"),status);
5692e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
5702e5b6d6dSopenharmony_ci      errcheckln(status, "ERROR: Could not create DecimalFormat (default) - %s", u_errorName(status));
5712e5b6d6dSopenharmony_ci      return;
5722e5b6d6dSopenharmony_ci    }
5732e5b6d6dSopenharmony_ci
5742e5b6d6dSopenharmony_ci    // get default rounding increment
5752e5b6d6dSopenharmony_ci    double roundingInc = pat.getRoundingIncrement();
5762e5b6d6dSopenharmony_ci    if (roundingInc != 0.0) {
5772e5b6d6dSopenharmony_ci      errln((UnicodeString)"ERROR: Rounding increment not zero");
5782e5b6d6dSopenharmony_ci      return;
5792e5b6d6dSopenharmony_ci    }
5802e5b6d6dSopenharmony_ci
5812e5b6d6dSopenharmony_ci    // With rounding now being handled by decNumber, we no longer
5822e5b6d6dSopenharmony_ci    // set a rounding increment to enable non-default mode rounding,
5832e5b6d6dSopenharmony_ci    // checking of which was the original point of this test.
5842e5b6d6dSopenharmony_ci
5852e5b6d6dSopenharmony_ci    // set rounding mode with zero increment.  Rounding
5862e5b6d6dSopenharmony_ci    // increment should not be set by this operation
5872e5b6d6dSopenharmony_ci    pat.setRoundingMode((DecimalFormat::ERoundingMode)0);
5882e5b6d6dSopenharmony_ci    roundingInc = pat.getRoundingIncrement();
5892e5b6d6dSopenharmony_ci    if (roundingInc != 0.0) {
5902e5b6d6dSopenharmony_ci      errln((UnicodeString)"ERROR: Rounding increment not zero after setRoundingMode");
5912e5b6d6dSopenharmony_ci      return;
5922e5b6d6dSopenharmony_ci    }
5932e5b6d6dSopenharmony_ci}
5942e5b6d6dSopenharmony_ci
5952e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::TestScale()
5962e5b6d6dSopenharmony_ci{
5972e5b6d6dSopenharmony_ci    typedef struct TestData {
5982e5b6d6dSopenharmony_ci        double inputValue;
5992e5b6d6dSopenharmony_ci        int inputScale;
6002e5b6d6dSopenharmony_ci        const char *expectedOutput;
6012e5b6d6dSopenharmony_ci    } TestData;
6022e5b6d6dSopenharmony_ci
6032e5b6d6dSopenharmony_ci    static TestData testData[] = {
6042e5b6d6dSopenharmony_ci        { 100.0, 3,  "100,000" },
6052e5b6d6dSopenharmony_ci        { 10034.0, -2, "100.34" },
6062e5b6d6dSopenharmony_ci        { 0.86, -3, "0.0009" },
6072e5b6d6dSopenharmony_ci        { -0.000455, 1, "-0%" },
6082e5b6d6dSopenharmony_ci        { -0.000555, 1, "-1%" },
6092e5b6d6dSopenharmony_ci        { 0.000455, 1, "0%" },
6102e5b6d6dSopenharmony_ci        { 0.000555, 1, "1%" },
6112e5b6d6dSopenharmony_ci    };
6122e5b6d6dSopenharmony_ci
6132e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
6142e5b6d6dSopenharmony_ci    DecimalFormat pat(status);
6152e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
6162e5b6d6dSopenharmony_ci      errcheckln(status, "ERROR: Could not create DecimalFormat (default) - %s", u_errorName(status));
6172e5b6d6dSopenharmony_ci      return;
6182e5b6d6dSopenharmony_ci    }
6192e5b6d6dSopenharmony_ci
6202e5b6d6dSopenharmony_ci    UnicodeString message;
6212e5b6d6dSopenharmony_ci    UnicodeString resultStr;
6222e5b6d6dSopenharmony_ci    UnicodeString exp;
6232e5b6d6dSopenharmony_ci    UnicodeString percentPattern("#,##0%");
6242e5b6d6dSopenharmony_ci    pat.setMaximumFractionDigits(4);
6252e5b6d6dSopenharmony_ci
6262e5b6d6dSopenharmony_ci    for(int32_t i=0; i < UPRV_LENGTHOF(testData); i++) {
6272e5b6d6dSopenharmony_ci        if ( i > 2 ) {
6282e5b6d6dSopenharmony_ci            pat.applyPattern(percentPattern,status);
6292e5b6d6dSopenharmony_ci        }
6302e5b6d6dSopenharmony_ci        // Test both the attribute and the setter
6312e5b6d6dSopenharmony_ci        if (i % 2 == 0) {
6322e5b6d6dSopenharmony_ci            pat.setAttribute(UNUM_SCALE, testData[i].inputScale,status);
6332e5b6d6dSopenharmony_ci            assertEquals("", testData[i].inputScale, pat.getMultiplierScale());
6342e5b6d6dSopenharmony_ci        } else {
6352e5b6d6dSopenharmony_ci            pat.setMultiplierScale(testData[i].inputScale);
6362e5b6d6dSopenharmony_ci            assertEquals("", testData[i].inputScale, pat.getAttribute(UNUM_SCALE, status));
6372e5b6d6dSopenharmony_ci        }
6382e5b6d6dSopenharmony_ci        pat.format(testData[i].inputValue, resultStr);
6392e5b6d6dSopenharmony_ci        message = UnicodeString("Unexpected output for ") + testData[i].inputValue + UnicodeString(" and scale ") +
6402e5b6d6dSopenharmony_ci                  testData[i].inputScale + UnicodeString(". Got: ");
6412e5b6d6dSopenharmony_ci        exp = testData[i].expectedOutput;
6422e5b6d6dSopenharmony_ci        verifyString(message, resultStr, exp);
6432e5b6d6dSopenharmony_ci        message.remove();
6442e5b6d6dSopenharmony_ci        resultStr.remove();
6452e5b6d6dSopenharmony_ci        exp.remove();
6462e5b6d6dSopenharmony_ci    }
6472e5b6d6dSopenharmony_ci}
6482e5b6d6dSopenharmony_ci
6492e5b6d6dSopenharmony_ci
6502e5b6d6dSopenharmony_ci#define ASSERT_EQUAL(expect, actual) UPRV_BLOCK_MACRO_BEGIN { \
6512e5b6d6dSopenharmony_ci    /* ICU-20080: Use temporary variables to avoid strange compiler behaviour \
6522e5b6d6dSopenharmony_ci       (with the nice side-effect of avoiding repeated function calls too). */ \
6532e5b6d6dSopenharmony_ci    auto lhs = (expect); \
6542e5b6d6dSopenharmony_ci    auto rhs = (actual); \
6552e5b6d6dSopenharmony_ci    char tmp[200]; \
6562e5b6d6dSopenharmony_ci    sprintf(tmp, "(%g==%g)", (double)lhs, (double)rhs); \
6572e5b6d6dSopenharmony_ci    assertTrue(tmp, (lhs==rhs), false, true, __FILE__, __LINE__); \
6582e5b6d6dSopenharmony_ci} UPRV_BLOCK_MACRO_END
6592e5b6d6dSopenharmony_ci
6602e5b6d6dSopenharmony_ci#if defined(_MSC_VER)
6612e5b6d6dSopenharmony_ci// Ignore the noisy warning 4805 (comparisons between int and bool) in the function below as we use the ICU true/false macros
6622e5b6d6dSopenharmony_ci// which are int values, whereas some of the DecimalQuantity methods return C++ bools.
6632e5b6d6dSopenharmony_ci#pragma warning(push)
6642e5b6d6dSopenharmony_ci#pragma warning(disable: 4805)
6652e5b6d6dSopenharmony_ci#endif
6662e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::TestFixedDecimal() {
6672e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
6682e5b6d6dSopenharmony_ci
6692e5b6d6dSopenharmony_ci    LocalPointer<DecimalFormat> df(new DecimalFormat("###", status), status);
6702e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
6712e5b6d6dSopenharmony_ci    if (status == U_MISSING_RESOURCE_ERROR) {
6722e5b6d6dSopenharmony_ci        return;
6732e5b6d6dSopenharmony_ci    }
6742e5b6d6dSopenharmony_ci    number::impl::DecimalQuantity fd;
6752e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(44, fd, status);
6762e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
6772e5b6d6dSopenharmony_ci    ASSERT_EQUAL(44, fd.getPluralOperand(PLURAL_OPERAND_N));
6782e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_V));
6792e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
6802e5b6d6dSopenharmony_ci
6812e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(-44, fd, status);
6822e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
6832e5b6d6dSopenharmony_ci    ASSERT_EQUAL(44, fd.getPluralOperand(PLURAL_OPERAND_N));
6842e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_V));
6852e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
6862e5b6d6dSopenharmony_ci
6872e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.00##", status), status);
6882e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
6892e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.456, fd, status);
6902e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
6912e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
6922e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
6932e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
6942e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
6952e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123.456, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
6962e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
6972e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
6982e5b6d6dSopenharmony_ci
6992e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(-123.456, fd, status);
7002e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7012e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7022e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7032e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7042e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7052e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123.456, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7062e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7072e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
7082e5b6d6dSopenharmony_ci
7092e5b6d6dSopenharmony_ci    // test max int digits
7102e5b6d6dSopenharmony_ci    df->setMaximumIntegerDigits(2);
7112e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.456, fd, status);
7122e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7132e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7142e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7152e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7162e5b6d6dSopenharmony_ci    ASSERT_EQUAL(23, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7172e5b6d6dSopenharmony_ci    ASSERT_EQUAL(23.456, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7182e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7192e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
7202e5b6d6dSopenharmony_ci
7212e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(-123.456, fd, status);
7222e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7232e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7242e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7252e5b6d6dSopenharmony_ci    ASSERT_EQUAL(456, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7262e5b6d6dSopenharmony_ci    ASSERT_EQUAL(23, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7272e5b6d6dSopenharmony_ci    ASSERT_EQUAL(23.456, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7282e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7292e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
7302e5b6d6dSopenharmony_ci
7312e5b6d6dSopenharmony_ci    // test max fraction digits
7322e5b6d6dSopenharmony_ci    df->setMaximumIntegerDigits(2000000000);
7332e5b6d6dSopenharmony_ci    df->setMaximumFractionDigits(2);
7342e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.456, fd, status);
7352e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7362e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7372e5b6d6dSopenharmony_ci    ASSERT_EQUAL(46, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7382e5b6d6dSopenharmony_ci    ASSERT_EQUAL(46, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7392e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7402e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123.46, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7412e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7422e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
7432e5b6d6dSopenharmony_ci
7442e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(-123.456, fd, status);
7452e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7462e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7472e5b6d6dSopenharmony_ci    ASSERT_EQUAL(46, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7482e5b6d6dSopenharmony_ci    ASSERT_EQUAL(46, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7492e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7502e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123.46, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7512e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7522e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
7532e5b6d6dSopenharmony_ci
7542e5b6d6dSopenharmony_ci    // test esoteric rounding
7552e5b6d6dSopenharmony_ci    df->setMaximumFractionDigits(6);
7562e5b6d6dSopenharmony_ci    df->setRoundingIncrement(7.3);
7572e5b6d6dSopenharmony_ci
7582e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(30.0, fd, status);
7592e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7602e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7612e5b6d6dSopenharmony_ci    ASSERT_EQUAL(20, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7622e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7632e5b6d6dSopenharmony_ci    ASSERT_EQUAL(29, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7642e5b6d6dSopenharmony_ci    ASSERT_EQUAL(29.2, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7652e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7662e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
7672e5b6d6dSopenharmony_ci
7682e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(-30.0, fd, status);
7692e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7702e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V)); // v
7712e5b6d6dSopenharmony_ci    ASSERT_EQUAL(20, fd.getPluralOperand(PLURAL_OPERAND_F)); // f
7722e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_T)); // t
7732e5b6d6dSopenharmony_ci    ASSERT_EQUAL(29, fd.getPluralOperand(PLURAL_OPERAND_I)); // i
7742e5b6d6dSopenharmony_ci    ASSERT_EQUAL(29.2, fd.getPluralOperand(PLURAL_OPERAND_N)); // n
7752e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
7762e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
7772e5b6d6dSopenharmony_ci
7782e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###", status), status);
7792e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7802e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.456, fd, status);
7812e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7822e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_V));
7832e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
7842e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
7852e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I));
7862e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
7872e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
7882e5b6d6dSopenharmony_ci
7892e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.0", status), status);
7902e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7912e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.01, fd, status);
7922e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
7932e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_V));
7942e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
7952e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
7962e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I));
7972e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
7982e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
7992e5b6d6dSopenharmony_ci
8002e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("###.0", status), status);
8012e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8022e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123.06, fd, status);
8032e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8042e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_V));
8052e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_F));
8062e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_T));
8072e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I));
8082e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8092e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8102e5b6d6dSopenharmony_ci
8112e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("@@@@@", status), status);  // Significant Digits
8122e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8132e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(123, fd, status);
8142e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8152e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
8162e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
8172e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
8182e5b6d6dSopenharmony_ci    ASSERT_EQUAL(123, fd.getPluralOperand(PLURAL_OPERAND_I));
8192e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
8202e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8212e5b6d6dSopenharmony_ci
8222e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(new DecimalFormat("@@@@@", status), status);  // Significant Digits
8232e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8242e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(1.23, fd, status);
8252e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8262e5b6d6dSopenharmony_ci    ASSERT_EQUAL(4, fd.getPluralOperand(PLURAL_OPERAND_V));
8272e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2300, fd.getPluralOperand(PLURAL_OPERAND_F));
8282e5b6d6dSopenharmony_ci    ASSERT_EQUAL(23, fd.getPluralOperand(PLURAL_OPERAND_T));
8292e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_I));
8302e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8312e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8322e5b6d6dSopenharmony_ci
8332e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(uprv_getInfinity(), fd, status);
8342e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8352e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNaN() || fd.isInfinite());
8362e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(0.0, fd, status);
8372e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNaN() || fd.isInfinite());
8382e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(uprv_getNaN(), fd, status);
8392e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNaN() || fd.isInfinite());
8402e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8412e5b6d6dSopenharmony_ci
8422e5b6d6dSopenharmony_ci    // Test Big Decimal input.
8432e5b6d6dSopenharmony_ci    // 22 digits before and after decimal, will exceed the precision of a double
8442e5b6d6dSopenharmony_ci    //    and force DecimalFormat::getFixedDecimal() to work with a digit list.
8452e5b6d6dSopenharmony_ci    df.adoptInsteadAndCheckErrorCode(
8462e5b6d6dSopenharmony_ci        new DecimalFormat("#####################0.00####################", status), status);
8472e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8482e5b6d6dSopenharmony_ci    Formattable fable("12.34", status);
8492e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8502e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
8512e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8522e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
8532e5b6d6dSopenharmony_ci    ASSERT_EQUAL(34, fd.getPluralOperand(PLURAL_OPERAND_F));
8542e5b6d6dSopenharmony_ci    ASSERT_EQUAL(34, fd.getPluralOperand(PLURAL_OPERAND_T));
8552e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_I));
8562e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8572e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8582e5b6d6dSopenharmony_ci
8592e5b6d6dSopenharmony_ci    fable.setDecimalNumber("12.3456789012345678900123456789", status);
8602e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8612e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
8622e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8632e5b6d6dSopenharmony_ci    ASSERT_EQUAL(22, fd.getPluralOperand(PLURAL_OPERAND_V));
8642e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3456789012345678900LL, fd.getPluralOperand(PLURAL_OPERAND_F));
8652e5b6d6dSopenharmony_ci    ASSERT_EQUAL(34567890123456789LL, fd.getPluralOperand(PLURAL_OPERAND_T));
8662e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_I));
8672e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8682e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8692e5b6d6dSopenharmony_ci
8702e5b6d6dSopenharmony_ci    // On field overflow, Integer part is truncated on the left, fraction part on the right.
8712e5b6d6dSopenharmony_ci    fable.setDecimalNumber("123456789012345678901234567890.123456789012345678901234567890", status);
8722e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8732e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
8742e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8752e5b6d6dSopenharmony_ci    ASSERT_EQUAL(22, fd.getPluralOperand(PLURAL_OPERAND_V));
8762e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1234567890123456789LL, fd.getPluralOperand(PLURAL_OPERAND_F));
8772e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1234567890123456789LL, fd.getPluralOperand(PLURAL_OPERAND_T));
8782e5b6d6dSopenharmony_ci    ASSERT_EQUAL(345678901234567890LL, fd.getPluralOperand(PLURAL_OPERAND_I));
8792e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8802e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8812e5b6d6dSopenharmony_ci
8822e5b6d6dSopenharmony_ci    // Digits way to the right of the decimal but within the format's precision aren't truncated
8832e5b6d6dSopenharmony_ci    fable.setDecimalNumber("1.0000000000000000000012", status);
8842e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8852e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
8862e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8872e5b6d6dSopenharmony_ci    ASSERT_EQUAL(22, fd.getPluralOperand(PLURAL_OPERAND_V));
8882e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_F));
8892e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_T));
8902e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_I));
8912e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
8922e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
8932e5b6d6dSopenharmony_ci
8942e5b6d6dSopenharmony_ci    // Digits beyond the precision of the format are rounded away
8952e5b6d6dSopenharmony_ci    fable.setDecimalNumber("1.000000000000000000000012", status);
8962e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8972e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
8982e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
8992e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9002e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
9012e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
9022e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_I));
9032e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
9042e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9052e5b6d6dSopenharmony_ci
9062e5b6d6dSopenharmony_ci    // Negative numbers come through
9072e5b6d6dSopenharmony_ci    fable.setDecimalNumber("-1.0000000000000000000012", status);
9082e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9092e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9102e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9112e5b6d6dSopenharmony_ci    ASSERT_EQUAL(22, fd.getPluralOperand(PLURAL_OPERAND_V));
9122e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_F));
9132e5b6d6dSopenharmony_ci    ASSERT_EQUAL(12, fd.getPluralOperand(PLURAL_OPERAND_T));
9142e5b6d6dSopenharmony_ci    ASSERT_EQUAL(1, fd.getPluralOperand(PLURAL_OPERAND_I));
9152e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
9162e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.isNegative());
9172e5b6d6dSopenharmony_ci
9182e5b6d6dSopenharmony_ci    // MinFractionDigits from format larger than from number.
9192e5b6d6dSopenharmony_ci    fable.setDecimalNumber("1000000000000000000000.3", status);
9202e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9212e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9222e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9232e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9242e5b6d6dSopenharmony_ci    ASSERT_EQUAL(30, fd.getPluralOperand(PLURAL_OPERAND_F));
9252e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_T));
9262e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_I));
9272e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
9282e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9292e5b6d6dSopenharmony_ci
9302e5b6d6dSopenharmony_ci    fable.setDecimalNumber("1000000000000000050000.3", status);
9312e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9322e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9332e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9342e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9352e5b6d6dSopenharmony_ci    ASSERT_EQUAL(30, fd.getPluralOperand(PLURAL_OPERAND_F));
9362e5b6d6dSopenharmony_ci    ASSERT_EQUAL(3, fd.getPluralOperand(PLURAL_OPERAND_T));
9372e5b6d6dSopenharmony_ci    ASSERT_EQUAL(50000LL, fd.getPluralOperand(PLURAL_OPERAND_I));
9382e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.hasIntegerValue());
9392e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9402e5b6d6dSopenharmony_ci
9412e5b6d6dSopenharmony_ci    // Test some int64_t values that are out of the range of a double
9422e5b6d6dSopenharmony_ci    fable.setInt64(4503599627370496LL);
9432e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9442e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9452e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9462e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9472e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
9482e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
9492e5b6d6dSopenharmony_ci    ASSERT_EQUAL(4503599627370496LL, fd.getPluralOperand(PLURAL_OPERAND_I));
9502e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
9512e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9522e5b6d6dSopenharmony_ci
9532e5b6d6dSopenharmony_ci    fable.setInt64(4503599627370497LL);
9542e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9552e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9562e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9572e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9582e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
9592e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
9602e5b6d6dSopenharmony_ci    ASSERT_EQUAL(4503599627370497LL, fd.getPluralOperand(PLURAL_OPERAND_I));
9612e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
9622e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9632e5b6d6dSopenharmony_ci
9642e5b6d6dSopenharmony_ci    fable.setInt64(9223372036854775807LL);
9652e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9662e5b6d6dSopenharmony_ci    df->formatToDecimalQuantity(fable, fd, status);
9672e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
9682e5b6d6dSopenharmony_ci    ASSERT_EQUAL(2, fd.getPluralOperand(PLURAL_OPERAND_V));
9692e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_F));
9702e5b6d6dSopenharmony_ci    ASSERT_EQUAL(0, fd.getPluralOperand(PLURAL_OPERAND_T));
9712e5b6d6dSopenharmony_ci    // note: going through DigitList path to FixedDecimal, which is trimming
9722e5b6d6dSopenharmony_ci    //       int64_t fields to 18 digits. See ticket Ticket #10374
9732e5b6d6dSopenharmony_ci    ASSERT_EQUAL(223372036854775807LL, fd.getPluralOperand(PLURAL_OPERAND_I));
9742e5b6d6dSopenharmony_ci    ASSERT_EQUAL(true, fd.hasIntegerValue());
9752e5b6d6dSopenharmony_ci    ASSERT_EQUAL(false, fd.isNegative());
9762e5b6d6dSopenharmony_ci
9772e5b6d6dSopenharmony_ci}
9782e5b6d6dSopenharmony_ci#if defined(_MSC_VER)
9792e5b6d6dSopenharmony_ci// Re-enable 4805 warnings (comparisons between int and bool).
9802e5b6d6dSopenharmony_ci#pragma warning(pop)
9812e5b6d6dSopenharmony_ci#endif
9822e5b6d6dSopenharmony_ci
9832e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::TestBadFastpath() {
9842e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
9852e5b6d6dSopenharmony_ci
9862e5b6d6dSopenharmony_ci    LocalPointer<DecimalFormat> df(new DecimalFormat("###", status), status);
9872e5b6d6dSopenharmony_ci    if (U_FAILURE(status)) {
9882e5b6d6dSopenharmony_ci        dataerrln("Error creating new DecimalFormat - %s", u_errorName(status));
9892e5b6d6dSopenharmony_ci        return;
9902e5b6d6dSopenharmony_ci    }
9912e5b6d6dSopenharmony_ci
9922e5b6d6dSopenharmony_ci    UnicodeString fmt;
9932e5b6d6dSopenharmony_ci    fmt.remove();
9942e5b6d6dSopenharmony_ci    assertEquals("Format 1234", "1234", df->format((int32_t)1234, fmt));
9952e5b6d6dSopenharmony_ci    df->setGroupingUsed(false);
9962e5b6d6dSopenharmony_ci    fmt.remove();
9972e5b6d6dSopenharmony_ci    assertEquals("Format 1234", "1234", df->format((int32_t)1234, fmt));
9982e5b6d6dSopenharmony_ci    df->setGroupingUsed(true);
9992e5b6d6dSopenharmony_ci    df->setGroupingSize(3);
10002e5b6d6dSopenharmony_ci    fmt.remove();
10012e5b6d6dSopenharmony_ci    assertEquals("Format 1234 w/ grouping", "1,234", df->format((int32_t)1234, fmt));
10022e5b6d6dSopenharmony_ci}
10032e5b6d6dSopenharmony_ci
10042e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::TestRequiredDecimalPoint() {
10052e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
10062e5b6d6dSopenharmony_ci    UnicodeString text("99");
10072e5b6d6dSopenharmony_ci    Formattable result1;
10082e5b6d6dSopenharmony_ci    UnicodeString pat1("##.0000");
10092e5b6d6dSopenharmony_ci    UnicodeString pat2("00.0");
10102e5b6d6dSopenharmony_ci
10112e5b6d6dSopenharmony_ci    LocalPointer<DecimalFormat> df(new DecimalFormat(pat1, status), status);
10122e5b6d6dSopenharmony_ci    if (U_FAILURE(status)) {
10132e5b6d6dSopenharmony_ci        dataerrln("Error creating new DecimalFormat - %s", u_errorName(status));
10142e5b6d6dSopenharmony_ci        return;
10152e5b6d6dSopenharmony_ci    }
10162e5b6d6dSopenharmony_ci
10172e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
10182e5b6d6dSopenharmony_ci    df->applyPattern(pat1, status);
10192e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
10202e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern() failed");
10212e5b6d6dSopenharmony_ci    }
10222e5b6d6dSopenharmony_ci    df->parse(text, result1, status);
10232e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
10242e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: parse() failed");
10252e5b6d6dSopenharmony_ci    }
10262e5b6d6dSopenharmony_ci    df->setDecimalPatternMatchRequired(true);
10272e5b6d6dSopenharmony_ci    df->parse(text, result1, status);
10282e5b6d6dSopenharmony_ci    if(U_SUCCESS(status)) {
10292e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: unexpected parse()");
10302e5b6d6dSopenharmony_ci    }
10312e5b6d6dSopenharmony_ci
10322e5b6d6dSopenharmony_ci
10332e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
10342e5b6d6dSopenharmony_ci    df->applyPattern(pat2, status);
10352e5b6d6dSopenharmony_ci    df->setDecimalPatternMatchRequired(false);
10362e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
10372e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: applyPattern(2) failed");
10382e5b6d6dSopenharmony_ci    }
10392e5b6d6dSopenharmony_ci    df->parse(text, result1, status);
10402e5b6d6dSopenharmony_ci    if(U_FAILURE(status)) {
10412e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: parse(2) failed - " + u_errorName(status));
10422e5b6d6dSopenharmony_ci    }
10432e5b6d6dSopenharmony_ci    df->setDecimalPatternMatchRequired(true);
10442e5b6d6dSopenharmony_ci    df->parse(text, result1, status);
10452e5b6d6dSopenharmony_ci    if(U_SUCCESS(status)) {
10462e5b6d6dSopenharmony_ci        errln((UnicodeString)"ERROR: unexpected parse(2)");
10472e5b6d6dSopenharmony_ci    }
10482e5b6d6dSopenharmony_ci}
10492e5b6d6dSopenharmony_ci
10502e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::testErrorCode() {
10512e5b6d6dSopenharmony_ci    // Try each DecimalFormat constructor with an errorCode set on input,
10522e5b6d6dSopenharmony_ci    // Verify no crashes or leaks, and that the errorCode is not altered.
10532e5b6d6dSopenharmony_ci
10542e5b6d6dSopenharmony_ci    UErrorCode status = U_ZERO_ERROR;
10552e5b6d6dSopenharmony_ci    const UnicodeString pattern(u"0.###E0");
10562e5b6d6dSopenharmony_ci    UParseError pe;
10572e5b6d6dSopenharmony_ci    DecimalFormatSymbols symbols(Locale::getUS(), status);
10582e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
10592e5b6d6dSopenharmony_ci
10602e5b6d6dSopenharmony_ci    {
10612e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10622e5b6d6dSopenharmony_ci        DecimalFormat df(status);
10632e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10642e5b6d6dSopenharmony_ci    }
10652e5b6d6dSopenharmony_ci    {
10662e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10672e5b6d6dSopenharmony_ci        DecimalFormat df(pattern, status);
10682e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10692e5b6d6dSopenharmony_ci    }
10702e5b6d6dSopenharmony_ci    {
10712e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10722e5b6d6dSopenharmony_ci        DecimalFormat df(pattern, new DecimalFormatSymbols(symbols), status);
10732e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10742e5b6d6dSopenharmony_ci    }
10752e5b6d6dSopenharmony_ci    {
10762e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10772e5b6d6dSopenharmony_ci        DecimalFormat df(pattern, new DecimalFormatSymbols(symbols), UNUM_DECIMAL_COMPACT_LONG, status);
10782e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10792e5b6d6dSopenharmony_ci    }
10802e5b6d6dSopenharmony_ci    {
10812e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10822e5b6d6dSopenharmony_ci        DecimalFormat df(pattern, new DecimalFormatSymbols(symbols), pe, status);
10832e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10842e5b6d6dSopenharmony_ci    }
10852e5b6d6dSopenharmony_ci    {
10862e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
10872e5b6d6dSopenharmony_ci        DecimalFormat df(pattern, symbols ,status);
10882e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10892e5b6d6dSopenharmony_ci    }
10902e5b6d6dSopenharmony_ci
10912e5b6d6dSopenharmony_ci    // Try each DecimalFormat method with an error code parameter, verifying that
10922e5b6d6dSopenharmony_ci    //  an input error is not altered, and that no segmentation faults occur.
10932e5b6d6dSopenharmony_ci
10942e5b6d6dSopenharmony_ci    status = U_INTERNAL_PROGRAM_ERROR;
10952e5b6d6dSopenharmony_ci    DecimalFormat dfBogus(status);
10962e5b6d6dSopenharmony_ci    assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
10972e5b6d6dSopenharmony_ci
10982e5b6d6dSopenharmony_ci    status = U_ZERO_ERROR;
10992e5b6d6dSopenharmony_ci    DecimalFormat dfGood(pattern, new DecimalFormatSymbols(symbols), status);
11002e5b6d6dSopenharmony_ci    assertSuccess(WHERE, status);
11012e5b6d6dSopenharmony_ci
11022e5b6d6dSopenharmony_ci    for (DecimalFormat *df: {&dfBogus, &dfGood}) {
11032e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11042e5b6d6dSopenharmony_ci        df->setAttribute(UNUM_PARSE_INT_ONLY, 0, status);
11052e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11062e5b6d6dSopenharmony_ci
11072e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11082e5b6d6dSopenharmony_ci        df->getAttribute(UNUM_MAX_FRACTION_DIGITS, status);
11092e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11102e5b6d6dSopenharmony_ci
11112e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11122e5b6d6dSopenharmony_ci        UnicodeString dest;
11132e5b6d6dSopenharmony_ci        FieldPosition fp;
11142e5b6d6dSopenharmony_ci        df->format(1.2, dest, fp, status);
11152e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11162e5b6d6dSopenharmony_ci
11172e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11182e5b6d6dSopenharmony_ci        df->format(1.2, dest, nullptr, status);
11192e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11202e5b6d6dSopenharmony_ci
11212e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11222e5b6d6dSopenharmony_ci        df->format((int32_t)666, dest, nullptr, status);
11232e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11242e5b6d6dSopenharmony_ci
11252e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11262e5b6d6dSopenharmony_ci        df->format((int64_t)666, dest, nullptr, status);
11272e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11282e5b6d6dSopenharmony_ci
11292e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11302e5b6d6dSopenharmony_ci        df->format(StringPiece("3.1415926535897932384626"), dest, nullptr, status);
11312e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11322e5b6d6dSopenharmony_ci
11332e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11342e5b6d6dSopenharmony_ci        df->applyPattern(pattern, status);
11352e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11362e5b6d6dSopenharmony_ci
11372e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11382e5b6d6dSopenharmony_ci        df->applyLocalizedPattern(pattern, pe, status);
11392e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11402e5b6d6dSopenharmony_ci
11412e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11422e5b6d6dSopenharmony_ci        df->applyLocalizedPattern(pattern, status);
11432e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11442e5b6d6dSopenharmony_ci
11452e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11462e5b6d6dSopenharmony_ci        df->setCurrency(u"USD", status);
11472e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11482e5b6d6dSopenharmony_ci
11492e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11502e5b6d6dSopenharmony_ci        df->setCurrencyUsage(UCURR_USAGE_CASH, &status);
11512e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11522e5b6d6dSopenharmony_ci    }
11532e5b6d6dSopenharmony_ci}
11542e5b6d6dSopenharmony_ci
11552e5b6d6dSopenharmony_civoid IntlTestDecimalFormatAPI::testInvalidObject() {
11562e5b6d6dSopenharmony_ci    {
11572e5b6d6dSopenharmony_ci        UErrorCode status = U_INTERNAL_PROGRAM_ERROR;
11582e5b6d6dSopenharmony_ci        DecimalFormat dfBogus(status);
11592e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
11602e5b6d6dSopenharmony_ci
11612e5b6d6dSopenharmony_ci        status = U_ZERO_ERROR;
11622e5b6d6dSopenharmony_ci        DecimalFormat dfGood(status);
11632e5b6d6dSopenharmony_ci        assertSuccess(WHERE, status);
11642e5b6d6dSopenharmony_ci
11652e5b6d6dSopenharmony_ci        // An invalid object should not be equal to a valid object.
11662e5b6d6dSopenharmony_ci        // This also tests that no segmentation fault occurs in the comparison operator due
11672e5b6d6dSopenharmony_ci        // to any dangling/nullptr pointers. (ICU-20381).
11682e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfGood != dfBogus);
11692e5b6d6dSopenharmony_ci
11702e5b6d6dSopenharmony_ci        status = U_MEMORY_ALLOCATION_ERROR;
11712e5b6d6dSopenharmony_ci        DecimalFormat dfBogus2(status);
11722e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_MEMORY_ALLOCATION_ERROR, status);
11732e5b6d6dSopenharmony_ci
11742e5b6d6dSopenharmony_ci        // Two invalid objects should not be equal.
11752e5b6d6dSopenharmony_ci        // (Also verify that nullptr isn't t dereferenced in the comparison operator.)
11762e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfBogus != dfBogus2);
11772e5b6d6dSopenharmony_ci
11782e5b6d6dSopenharmony_ci        // Verify the comparison operator works for two valid objects.
11792e5b6d6dSopenharmony_ci        status = U_ZERO_ERROR;
11802e5b6d6dSopenharmony_ci        DecimalFormat dfGood2(status);
11812e5b6d6dSopenharmony_ci        assertSuccess(WHERE, status);
11822e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfGood == dfGood2);
11832e5b6d6dSopenharmony_ci
11842e5b6d6dSopenharmony_ci        // Verify that the assignment operator sets the object to an invalid state, and
11852e5b6d6dSopenharmony_ci        // that no segmentation fault occurs due to any dangling/nullptr pointers.
11862e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
11872e5b6d6dSopenharmony_ci        DecimalFormat dfAssignmentBogus = DecimalFormat(status);
11882e5b6d6dSopenharmony_ci        // Verify comparison for the assigned object.
11892e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfAssignmentBogus != dfGood);
11902e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfAssignmentBogus != dfGood2);
11912e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfAssignmentBogus != dfBogus);
11922e5b6d6dSopenharmony_ci
11932e5b6d6dSopenharmony_ci        // Verify that cloning our original invalid object gives nullptr.
11942e5b6d6dSopenharmony_ci        auto dfBogusClone = dfBogus.clone();
11952e5b6d6dSopenharmony_ci        assertTrue(WHERE,  dfBogusClone == nullptr);
11962e5b6d6dSopenharmony_ci        // Verify that cloning our assigned invalid object gives nullptr.
11972e5b6d6dSopenharmony_ci        auto dfBogusClone2 = dfAssignmentBogus.clone();
11982e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfBogusClone2 == nullptr);
11992e5b6d6dSopenharmony_ci
12002e5b6d6dSopenharmony_ci        // Verify copy constructing from an invalid object is also invalid.
12012e5b6d6dSopenharmony_ci        DecimalFormat dfCopy(dfBogus);
12022e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopy != dfGood);
12032e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopy != dfGood2);
12042e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopy != dfBogus);
12052e5b6d6dSopenharmony_ci        DecimalFormat dfCopyAssign = dfBogus;
12062e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopyAssign != dfGood);
12072e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopyAssign != dfGood2);
12082e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfCopyAssign != dfBogus);
12092e5b6d6dSopenharmony_ci        auto dfBogusCopyClone1 = dfCopy.clone();
12102e5b6d6dSopenharmony_ci        auto dfBogusCopyClone2 = dfCopyAssign.clone();
12112e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfBogusCopyClone1 == nullptr);
12122e5b6d6dSopenharmony_ci        assertTrue(WHERE, dfBogusCopyClone2 == nullptr);
12132e5b6d6dSopenharmony_ci    }
12142e5b6d6dSopenharmony_ci
12152e5b6d6dSopenharmony_ci    {
12162e5b6d6dSopenharmony_ci        // Try each DecimalFormat class method that lacks an error code parameter, verifying
12172e5b6d6dSopenharmony_ci        // we don't crash (segmentation fault) on invalid objects.
12182e5b6d6dSopenharmony_ci
12192e5b6d6dSopenharmony_ci        UErrorCode status = U_ZERO_ERROR;
12202e5b6d6dSopenharmony_ci        const UnicodeString pattern(u"0.###E0");
12212e5b6d6dSopenharmony_ci        UParseError pe;
12222e5b6d6dSopenharmony_ci        DecimalFormatSymbols symbols(Locale::getUS(), status);
12232e5b6d6dSopenharmony_ci        assertSuccess(WHERE, status);
12242e5b6d6dSopenharmony_ci        CurrencyPluralInfo currencyPI(status);
12252e5b6d6dSopenharmony_ci        assertSuccess(WHERE, status);
12262e5b6d6dSopenharmony_ci
12272e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
12282e5b6d6dSopenharmony_ci        DecimalFormat dfBogus1(status);
12292e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
12302e5b6d6dSopenharmony_ci
12312e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
12322e5b6d6dSopenharmony_ci        DecimalFormat dfBogus2(pattern, status);
12332e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
12342e5b6d6dSopenharmony_ci
12352e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
12362e5b6d6dSopenharmony_ci        DecimalFormat dfBogus3(pattern, new DecimalFormatSymbols(symbols), status);
12372e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
12382e5b6d6dSopenharmony_ci
12392e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
12402e5b6d6dSopenharmony_ci        DecimalFormat dfBogus4(pattern, new DecimalFormatSymbols(symbols), UNumberFormatStyle::UNUM_CURRENCY, status);
12412e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
12422e5b6d6dSopenharmony_ci
12432e5b6d6dSopenharmony_ci        status = U_INTERNAL_PROGRAM_ERROR;
12442e5b6d6dSopenharmony_ci        DecimalFormat dfBogus5(pattern, new DecimalFormatSymbols(symbols), pe, status);
12452e5b6d6dSopenharmony_ci        assertEquals(WHERE, U_INTERNAL_PROGRAM_ERROR, status);
12462e5b6d6dSopenharmony_ci
12472e5b6d6dSopenharmony_ci        for (DecimalFormat *df : {&dfBogus1, &dfBogus2, &dfBogus3, &dfBogus4, &dfBogus5})
12482e5b6d6dSopenharmony_ci        {
12492e5b6d6dSopenharmony_ci            df->setGroupingUsed(true);
12502e5b6d6dSopenharmony_ci
12512e5b6d6dSopenharmony_ci            df->setParseIntegerOnly(false);
12522e5b6d6dSopenharmony_ci
12532e5b6d6dSopenharmony_ci            df->setLenient(true);
12542e5b6d6dSopenharmony_ci
12552e5b6d6dSopenharmony_ci            auto dfClone = df->clone();
12562e5b6d6dSopenharmony_ci            assertTrue(WHERE, dfClone == nullptr);
12572e5b6d6dSopenharmony_ci
12582e5b6d6dSopenharmony_ci            UnicodeString dest;
12592e5b6d6dSopenharmony_ci            FieldPosition fp;
12602e5b6d6dSopenharmony_ci            df->format(1.2, dest, fp);
12612e5b6d6dSopenharmony_ci            df->format(static_cast<int32_t>(1234), dest, fp);
12622e5b6d6dSopenharmony_ci            df->format(static_cast<int64_t>(1234), dest, fp);
12632e5b6d6dSopenharmony_ci
12642e5b6d6dSopenharmony_ci            UnicodeString text("-1,234.00");
12652e5b6d6dSopenharmony_ci            Formattable result;
12662e5b6d6dSopenharmony_ci            ParsePosition pos(0);
12672e5b6d6dSopenharmony_ci            df->parse(text, result, pos);
12682e5b6d6dSopenharmony_ci
12692e5b6d6dSopenharmony_ci            CurrencyAmount* ca = df->parseCurrency(text, pos);
12702e5b6d6dSopenharmony_ci            assertTrue(WHERE, ca == nullptr);
12712e5b6d6dSopenharmony_ci
12722e5b6d6dSopenharmony_ci            const DecimalFormatSymbols* dfs = df->getDecimalFormatSymbols();
12732e5b6d6dSopenharmony_ci            assertTrue(WHERE, dfs == nullptr);
12742e5b6d6dSopenharmony_ci
12752e5b6d6dSopenharmony_ci            df->adoptDecimalFormatSymbols(nullptr);
12762e5b6d6dSopenharmony_ci
12772e5b6d6dSopenharmony_ci            df->setDecimalFormatSymbols(symbols);
12782e5b6d6dSopenharmony_ci
12792e5b6d6dSopenharmony_ci            const CurrencyPluralInfo* cpi = df->getCurrencyPluralInfo();
12802e5b6d6dSopenharmony_ci            assertTrue(WHERE, cpi == nullptr);
12812e5b6d6dSopenharmony_ci
12822e5b6d6dSopenharmony_ci            df->adoptCurrencyPluralInfo(nullptr);
12832e5b6d6dSopenharmony_ci
12842e5b6d6dSopenharmony_ci            df->setCurrencyPluralInfo(currencyPI);
12852e5b6d6dSopenharmony_ci
12862e5b6d6dSopenharmony_ci            UnicodeString prefix("-123");
12872e5b6d6dSopenharmony_ci            df->getPositivePrefix(dest);
12882e5b6d6dSopenharmony_ci            df->setPositivePrefix(prefix);
12892e5b6d6dSopenharmony_ci            df->getNegativePrefix(dest);
12902e5b6d6dSopenharmony_ci            df->setNegativePrefix(prefix);
12912e5b6d6dSopenharmony_ci            df->getPositiveSuffix(dest);
12922e5b6d6dSopenharmony_ci            df->setPositiveSuffix(prefix);
12932e5b6d6dSopenharmony_ci            df->getNegativeSuffix(dest);
12942e5b6d6dSopenharmony_ci            df->setNegativeSuffix(prefix);
12952e5b6d6dSopenharmony_ci
12962e5b6d6dSopenharmony_ci            df->isSignAlwaysShown();
12972e5b6d6dSopenharmony_ci
12982e5b6d6dSopenharmony_ci            df->setSignAlwaysShown(true);
12992e5b6d6dSopenharmony_ci
13002e5b6d6dSopenharmony_ci            df->getMultiplier();
13012e5b6d6dSopenharmony_ci            df->setMultiplier(10);
13022e5b6d6dSopenharmony_ci
13032e5b6d6dSopenharmony_ci            df->getMultiplierScale();
13042e5b6d6dSopenharmony_ci            df->setMultiplierScale(2);
13052e5b6d6dSopenharmony_ci
13062e5b6d6dSopenharmony_ci            df->getRoundingIncrement();
13072e5b6d6dSopenharmony_ci            df->setRoundingIncrement(1.2);
13082e5b6d6dSopenharmony_ci
13092e5b6d6dSopenharmony_ci            df->getRoundingMode();
13102e5b6d6dSopenharmony_ci            df->setRoundingMode(DecimalFormat::ERoundingMode::kRoundDown);
13112e5b6d6dSopenharmony_ci
13122e5b6d6dSopenharmony_ci            df->getFormatWidth();
13132e5b6d6dSopenharmony_ci            df->setFormatWidth(0);
13142e5b6d6dSopenharmony_ci
13152e5b6d6dSopenharmony_ci            UnicodeString pad(" ");
13162e5b6d6dSopenharmony_ci            df->getPadCharacterString();
13172e5b6d6dSopenharmony_ci            df->setPadCharacter(pad);
13182e5b6d6dSopenharmony_ci
13192e5b6d6dSopenharmony_ci            df->getPadPosition();
13202e5b6d6dSopenharmony_ci            df->setPadPosition(DecimalFormat::EPadPosition::kPadBeforePrefix);
13212e5b6d6dSopenharmony_ci
13222e5b6d6dSopenharmony_ci            df->isScientificNotation();
13232e5b6d6dSopenharmony_ci            df->setScientificNotation(false);
13242e5b6d6dSopenharmony_ci
13252e5b6d6dSopenharmony_ci            df->getMinimumExponentDigits();
13262e5b6d6dSopenharmony_ci            df->setMinimumExponentDigits(1);
13272e5b6d6dSopenharmony_ci
13282e5b6d6dSopenharmony_ci            df->isExponentSignAlwaysShown();
13292e5b6d6dSopenharmony_ci            df->setExponentSignAlwaysShown(true);
13302e5b6d6dSopenharmony_ci
13312e5b6d6dSopenharmony_ci            df->getGroupingSize();
13322e5b6d6dSopenharmony_ci            df->setGroupingSize(3);
13332e5b6d6dSopenharmony_ci
13342e5b6d6dSopenharmony_ci            df->getSecondaryGroupingSize();
13352e5b6d6dSopenharmony_ci            df->setSecondaryGroupingSize(-1);
13362e5b6d6dSopenharmony_ci
13372e5b6d6dSopenharmony_ci            df->getMinimumGroupingDigits();
13382e5b6d6dSopenharmony_ci            df->setMinimumGroupingDigits(-1);
13392e5b6d6dSopenharmony_ci
13402e5b6d6dSopenharmony_ci            df->isDecimalSeparatorAlwaysShown();
13412e5b6d6dSopenharmony_ci            df->setDecimalSeparatorAlwaysShown(true);
13422e5b6d6dSopenharmony_ci
13432e5b6d6dSopenharmony_ci            df->isDecimalPatternMatchRequired();
13442e5b6d6dSopenharmony_ci            df->setDecimalPatternMatchRequired(false);
13452e5b6d6dSopenharmony_ci
13462e5b6d6dSopenharmony_ci            df->isParseNoExponent();
13472e5b6d6dSopenharmony_ci            df->setParseNoExponent(true);
13482e5b6d6dSopenharmony_ci
13492e5b6d6dSopenharmony_ci            df->isParseCaseSensitive();
13502e5b6d6dSopenharmony_ci            df->setParseCaseSensitive(false);
13512e5b6d6dSopenharmony_ci
13522e5b6d6dSopenharmony_ci            df->isFormatFailIfMoreThanMaxDigits();
13532e5b6d6dSopenharmony_ci            df->setFormatFailIfMoreThanMaxDigits(true);
13542e5b6d6dSopenharmony_ci
13552e5b6d6dSopenharmony_ci            df->toPattern(dest);
13562e5b6d6dSopenharmony_ci            df->toLocalizedPattern(dest);
13572e5b6d6dSopenharmony_ci
13582e5b6d6dSopenharmony_ci            df->setMaximumIntegerDigits(10);
13592e5b6d6dSopenharmony_ci            df->setMinimumIntegerDigits(0);
13602e5b6d6dSopenharmony_ci
13612e5b6d6dSopenharmony_ci            df->setMaximumFractionDigits(2);
13622e5b6d6dSopenharmony_ci            df->setMinimumFractionDigits(0);
13632e5b6d6dSopenharmony_ci
13642e5b6d6dSopenharmony_ci            df->getMinimumSignificantDigits();
13652e5b6d6dSopenharmony_ci            df->setMinimumSignificantDigits(0);
13662e5b6d6dSopenharmony_ci
13672e5b6d6dSopenharmony_ci            df->getMaximumSignificantDigits();
13682e5b6d6dSopenharmony_ci            df->setMaximumSignificantDigits(5);
13692e5b6d6dSopenharmony_ci
13702e5b6d6dSopenharmony_ci            df->areSignificantDigitsUsed();
13712e5b6d6dSopenharmony_ci            df->setSignificantDigitsUsed(true);
13722e5b6d6dSopenharmony_ci
13732e5b6d6dSopenharmony_ci            df->setCurrency(u"USD");
13742e5b6d6dSopenharmony_ci
13752e5b6d6dSopenharmony_ci            df->getCurrencyUsage();
13762e5b6d6dSopenharmony_ci
13772e5b6d6dSopenharmony_ci            const number::LocalizedNumberFormatter* lnf = df->toNumberFormatter(status);
13782e5b6d6dSopenharmony_ci            assertEquals("toNumberFormatter should return nullptr",
13792e5b6d6dSopenharmony_ci                (int64_t) nullptr, (int64_t) lnf);
13802e5b6d6dSopenharmony_ci
13812e5b6d6dSopenharmony_ci            // Should not crash when chaining to error code enabled methods on the LNF
13822e5b6d6dSopenharmony_ci            lnf->formatInt(1, status);
13832e5b6d6dSopenharmony_ci            lnf->formatDouble(1.0, status);
13842e5b6d6dSopenharmony_ci            lnf->formatDecimal("1", status);
13852e5b6d6dSopenharmony_ci            lnf->toFormat(status);
13862e5b6d6dSopenharmony_ci            lnf->toSkeleton(status);
13872e5b6d6dSopenharmony_ci            lnf->copyErrorTo(status);
13882e5b6d6dSopenharmony_ci        }
13892e5b6d6dSopenharmony_ci
13902e5b6d6dSopenharmony_ci    }
13912e5b6d6dSopenharmony_ci}
13922e5b6d6dSopenharmony_ci
13932e5b6d6dSopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */
1394