Home | History | Annotate | Download | only in intltest
      1 /********************************************************************
      2  * COPYRIGHT:
      3  * Copyright (c) 1997-2012, International Business Machines Corporation and
      4  * others. All Rights Reserved.
      5  ********************************************************************/
      6 /* Modification History:
      7 *   Date        Name        Description
      8 *   07/15/99    helena      Ported to HPUX 10/11 CC.
      9 */
     10 
     11 #include "unicode/utypes.h"
     12 
     13 #if !UCONFIG_NO_FORMATTING
     14 
     15 #include "numfmtst.h"
     16 #include "unicode/dcfmtsym.h"
     17 #include "unicode/decimfmt.h"
     18 #include "unicode/localpointer.h"
     19 #include "unicode/ucurr.h"
     20 #include "unicode/ustring.h"
     21 #include "unicode/measfmt.h"
     22 #include "unicode/curramt.h"
     23 #include "digitlst.h"
     24 #include "textfile.h"
     25 #include "tokiter.h"
     26 #include "charstr.h"
     27 #include "putilimp.h"
     28 #include "winnmtst.h"
     29 #include <float.h>
     30 #include <string.h>
     31 #include <stdlib.h>
     32 #include "cstring.h"
     33 #include "unicode/numsys.h"
     34 #include "fmtableimp.h"
     35 
     36 //#define NUMFMTST_CACHE_DEBUG 1
     37 #include "stdio.h" /* for sprintf */
     38 // #include "iostream"   // for cout
     39 
     40 //#define NUMFMTST_DEBUG 1
     41 
     42 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
     43 
     44 static const UChar EUR[] = {69,85,82,0}; // "EUR"
     45 static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
     46 
     47 // *****************************************************************************
     48 // class NumberFormatTest
     49 // *****************************************************************************
     50 
     51 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
     52 
     53 #define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
     54 #define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
     55 
     56 void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
     57 {
     58     // if (exec) logln((UnicodeString)"TestSuite DateFormatTest");
     59     switch (index) {
     60         CASE(0,TestCurrencySign);
     61         CASE(1,TestCurrency);
     62         CASE(2,TestParse);
     63         CASE(3,TestRounding487);
     64         CASE(4,TestQuotes);
     65         CASE(5,TestExponential);
     66         CASE(6,TestPatterns);
     67 
     68         // Upgrade to alphaWorks - liu 5/99
     69         CASE(7,TestExponent);
     70         CASE(8,TestScientific);
     71         CASE(9,TestPad);
     72         CASE(10,TestPatterns2);
     73         CASE(11,TestSecondaryGrouping);
     74         CASE(12,TestSurrogateSupport);
     75         CASE(13,TestAPI);
     76 
     77         CASE(14,TestCurrencyObject);
     78         CASE(15,TestCurrencyPatterns);
     79         //CASE(16,TestDigitList);
     80         CASE(16,TestWhiteSpaceParsing);
     81         CASE(17,TestComplexCurrency);  // This test removed because CLDR no longer uses choice formats in currency symbols.
     82         CASE(18,TestRegCurrency);
     83         CASE(19,TestSymbolsWithBadLocale);
     84         CASE(20,TestAdoptDecimalFormatSymbols);
     85 
     86         CASE(21,TestScientific2);
     87         CASE(22,TestScientificGrouping);
     88         CASE(23,TestInt64);
     89 
     90         CASE(24,TestPerMill);
     91         CASE(25,TestIllegalPatterns);
     92         CASE(26,TestCases);
     93 
     94         CASE(27,TestCurrencyNames);
     95         CASE(28,TestCurrencyAmount);
     96         CASE(29,TestCurrencyUnit);
     97         CASE(30,TestCoverage);
     98         CASE(31,TestJB3832);
     99         CASE(32,TestHost);
    100         CASE(33,TestHostClone);
    101         CASE(34,TestCurrencyFormat);
    102         CASE(35,TestRounding);
    103         CASE(36,TestNonpositiveMultiplier);
    104         CASE(37,TestNumberingSystems);
    105         CASE(38,TestSpaceParsing);
    106         CASE(39,TestMultiCurrencySign);
    107         CASE(40,TestCurrencyFormatForMixParsing);
    108         CASE(41,TestDecimalFormatCurrencyParse);
    109         CASE(42,TestCurrencyIsoPluralFormat);
    110         CASE(43,TestCurrencyParsing);
    111         CASE(44,TestParseCurrencyInUCurr);
    112         CASE(45,TestFormatAttributes);
    113         CASE(46,TestFieldPositionIterator);
    114         CASE(47,TestDecimal);
    115         CASE(48,TestCurrencyFractionDigits);
    116         CASE(49,TestExponentParse);
    117         CASE(50,TestExplicitParents);
    118         CASE(51,TestLenientParse);
    119         CASE(52,TestAvailableNumberingSystems);
    120         CASE(53,TestRoundingPattern);
    121         CASE(54,Test9087);
    122         CASE(55,TestFormatFastpaths);
    123         CASE(56,TestEnumSet);
    124         CASE(57,TestFormattableSize);
    125         default: name = ""; break;
    126     }
    127 }
    128 
    129 // -------------------------------------
    130 
    131 // Test API (increase code coverage)
    132 void
    133 NumberFormatTest::TestAPI(void)
    134 {
    135   logln("Test API");
    136   UErrorCode status = U_ZERO_ERROR;
    137   NumberFormat *test = NumberFormat::createInstance("root", status);
    138   if(U_FAILURE(status)) {
    139     dataerrln("unable to create format object - %s", u_errorName(status));
    140   }
    141   if(test != NULL) {
    142     test->setMinimumIntegerDigits(10);
    143     test->setMaximumIntegerDigits(2);
    144 
    145     test->setMinimumFractionDigits(10);
    146     test->setMaximumFractionDigits(2);
    147 
    148     UnicodeString result;
    149     FieldPosition pos;
    150     Formattable bla("Paja Patak"); // Donald Duck for non Serbian speakers
    151     test->format(bla, result, pos, status);
    152     if(U_SUCCESS(status)) {
    153       errln("Yuck... Formatted a duck... As a number!");
    154     } else {
    155       status = U_ZERO_ERROR;
    156     }
    157 
    158     result.remove();
    159     int64_t ll = 12;
    160     test->format(ll, result);
    161     if (result != "12.00"){
    162         errln("format int64_t error");
    163     }
    164 
    165     ParsePosition ppos;
    166     LocalPointer<CurrencyAmount> currAmt(test->parseCurrency("",ppos));
    167     // old test for (U_FAILURE(status)) was bogus here, method does not set status!
    168     if (ppos.getIndex()) {
    169         errln("Parsed empty string as currency");
    170     }
    171 
    172     delete test;
    173   }
    174 }
    175 
    176 class StubNumberForamt :public NumberFormat{
    177 public:
    178     StubNumberForamt(){};
    179     virtual UnicodeString& format(double ,UnicodeString& appendTo,FieldPosition& ) const {
    180         return appendTo;
    181     }
    182     virtual UnicodeString& format(int32_t ,UnicodeString& appendTo,FieldPosition& ) const {
    183         return appendTo.append((UChar)0x0033);
    184     }
    185     virtual UnicodeString& format(int64_t number,UnicodeString& appendTo,FieldPosition& pos) const {
    186         return NumberFormat::format(number, appendTo, pos);
    187     }
    188     virtual UnicodeString& format(const Formattable& , UnicodeString& appendTo, FieldPosition& , UErrorCode& ) const {
    189         return appendTo;
    190     }
    191     virtual void parse(const UnicodeString& ,
    192                     Formattable& ,
    193                     ParsePosition& ) const {}
    194     virtual void parse( const UnicodeString& ,
    195                         Formattable& ,
    196                         UErrorCode& ) const {}
    197     virtual UClassID getDynamicClassID(void) const {
    198         static char classID = 0;
    199         return (UClassID)&classID;
    200     }
    201     virtual Format* clone() const {return NULL;}
    202 };
    203 
    204 void
    205 NumberFormatTest::TestCoverage(void){
    206     StubNumberForamt stub;
    207     UnicodeString agent("agent");
    208     FieldPosition pos;
    209     int64_t num = 4;
    210     if (stub.format(num, agent, pos) != UnicodeString("agent3")){
    211         errln("NumberFormat::format(int64, UnicodString&, FieldPosition&) should delegate to (int32, ,)");
    212     };
    213 }
    214 
    215 // Test various patterns
    216 void
    217 NumberFormatTest::TestPatterns(void)
    218 {
    219     UErrorCode status = U_ZERO_ERROR;
    220     DecimalFormatSymbols sym(Locale::getUS(), status);
    221     if (U_FAILURE(status)) { errcheckln(status, "FAIL: Could not construct DecimalFormatSymbols - %s", u_errorName(status)); return; }
    222 
    223     const char* pat[]    = { "#.#", "#.", ".#", "#" };
    224     int32_t pat_length = (int32_t)(sizeof(pat) / sizeof(pat[0]));
    225     const char* newpat[] = { "#0.#", "#0.", "#.0", "#" };
    226     const char* num[]    = { "0",   "0.", ".0", "0" };
    227     for (int32_t i=0; i<pat_length; ++i)
    228     {
    229         status = U_ZERO_ERROR;
    230         DecimalFormat fmt(pat[i], sym, status);
    231         if (U_FAILURE(status)) { errln((UnicodeString)"FAIL: DecimalFormat constructor failed for " + pat[i]); continue; }
    232         UnicodeString newp; fmt.toPattern(newp);
    233         if (!(newp == newpat[i]))
    234             errln((UnicodeString)"FAIL: Pattern " + pat[i] + " should transmute to " + newpat[i] +
    235                   "; " + newp + " seen instead");
    236 
    237         UnicodeString s; (*(NumberFormat*)&fmt).format((int32_t)0, s);
    238         if (!(s == num[i]))
    239         {
    240             errln((UnicodeString)"FAIL: Pattern " + pat[i] + " should format zero as " + num[i] +
    241                   "; " + s + " seen instead");
    242             logln((UnicodeString)"Min integer digits = " + fmt.getMinimumIntegerDigits());
    243         }
    244     }
    245 }
    246 
    247 /*
    248 icu_2_4::DigitList::operator== 0 0 2 icuuc24d.dll digitlst.cpp Doug
    249 icu_2_4::DigitList::append 0 0 4 icuin24d.dll digitlst.h Doug
    250 icu_2_4::DigitList::operator!= 0 0 1 icuuc24d.dll digitlst.h Doug
    251 */
    252 /*
    253 void
    254 NumberFormatTest::TestDigitList(void)
    255 {
    256   // API coverage for DigitList
    257   DigitList list1;
    258   list1.append('1');
    259   list1.fDecimalAt = 1;
    260   DigitList list2;
    261   list2.set((int32_t)1);
    262   if (list1 != list2) {
    263     errln("digitlist append, operator!= or set failed ");
    264   }
    265   if (!(list1 == list2)) {
    266     errln("digitlist append, operator== or set failed ");
    267   }
    268 }
    269 */
    270 
    271 // -------------------------------------
    272 
    273 // Test exponential pattern
    274 void
    275 NumberFormatTest::TestExponential(void)
    276 {
    277     UErrorCode status = U_ZERO_ERROR;
    278     DecimalFormatSymbols sym(Locale::getUS(), status);
    279     if (U_FAILURE(status)) { errcheckln(status, "FAIL: Bad status returned by DecimalFormatSymbols ct - %s", u_errorName(status)); return; }
    280     const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]"  };
    281     int32_t pat_length = (int32_t)(sizeof(pat) / sizeof(pat[0]));
    282 
    283 // The following #if statements allow this test to be built and run on
    284 // platforms that do not have standard IEEE numerics.  For example,
    285 // S/390 doubles have an exponent range of -78 to +75.  For the
    286 // following #if statements to work, float.h must define
    287 // DBL_MAX_10_EXP to be a compile-time constant.
    288 
    289 // This section may be expanded as needed.
    290 
    291 #if DBL_MAX_10_EXP > 300
    292     double val[] = { 0.01234, 123456789, 1.23e300, -3.141592653e-271 };
    293     int32_t val_length = (int32_t)(sizeof(val) / sizeof(val[0]));
    294     const char* valFormat[] =
    295     {
    296         // 0.####E0
    297         "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
    298         // 00.000E00
    299         "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
    300         // ##0.######E000
    301         "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
    302         // 0.###E0;[0.###E0]
    303         "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
    304     };
    305     double valParse[] =
    306     {
    307         0.01234, 123460000, 1.23E300, -3.1416E-271,
    308         0.01234, 123460000, 1.23E300, -3.1416E-271,
    309         0.01234, 123456800, 1.23E300, -3.141593E-271,
    310         0.01234, 123500000, 1.23E300, -3.142E-271,
    311     };
    312 #elif DBL_MAX_10_EXP > 70
    313     double val[] = { 0.01234, 123456789, 1.23e70, -3.141592653e-71 };
    314     int32_t val_length = sizeof(val) / sizeof(val[0]);
    315     char* valFormat[] =
    316     {
    317         // 0.####E0
    318         "1.234E-2", "1.2346E8", "1.23E70", "-3.1416E-71",
    319         // 00.000E00
    320         "12.340E-03", "12.346E07", "12.300E69", "-31.416E-72",
    321         // ##0.######E000
    322         "12.34E-003", "123.4568E006", "12.3E069", "-31.41593E-072",
    323         // 0.###E0;[0.###E0]
    324         "1.234E-2", "1.235E8", "1.23E70", "[3.142E-71]"
    325     };
    326     double valParse[] =
    327     {
    328         0.01234, 123460000, 1.23E70, -3.1416E-71,
    329         0.01234, 123460000, 1.23E70, -3.1416E-71,
    330         0.01234, 123456800, 1.23E70, -3.141593E-71,
    331         0.01234, 123500000, 1.23E70, -3.142E-71,
    332     };
    333 #else
    334     // Don't test double conversion
    335     double* val = 0;
    336     int32_t val_length = 0;
    337     char** valFormat = 0;
    338     double* valParse = 0;
    339     logln("Warning: Skipping double conversion tests");
    340 #endif
    341 
    342     int32_t lval[] = { 0, -1, 1, 123456789 };
    343     int32_t lval_length = (int32_t)(sizeof(lval) / sizeof(lval[0]));
    344     const char* lvalFormat[] =
    345     {
    346         // 0.####E0
    347         "0E0", "-1E0", "1E0", "1.2346E8",
    348         // 00.000E00
    349         "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
    350         // ##0.######E000
    351         "0E000", "-1E000", "1E000", "123.4568E006",
    352         // 0.###E0;[0.###E0]
    353         "0E0", "[1E0]", "1E0", "1.235E8"
    354     };
    355     int32_t lvalParse[] =
    356     {
    357         0, -1, 1, 123460000,
    358         0, -1, 1, 123460000,
    359         0, -1, 1, 123456800,
    360         0, -1, 1, 123500000,
    361     };
    362     int32_t ival = 0, ilval = 0;
    363     for (int32_t p=0; p<pat_length; ++p)
    364     {
    365         DecimalFormat fmt(pat[p], sym, status);
    366         if (U_FAILURE(status)) { errln("FAIL: Bad status returned by DecimalFormat ct"); continue; }
    367         UnicodeString pattern;
    368         logln((UnicodeString)"Pattern \"" + pat[p] + "\" -toPattern-> \"" +
    369           fmt.toPattern(pattern) + "\"");
    370         int32_t v;
    371         for (v=0; v<val_length; ++v)
    372         {
    373             UnicodeString s; (*(NumberFormat*)&fmt).format(val[v], s);
    374             logln((UnicodeString)" " + val[v] + " -format-> " + s);
    375             if (s != valFormat[v+ival])
    376                 errln((UnicodeString)"FAIL: Expected " + valFormat[v+ival]);
    377 
    378             ParsePosition pos(0);
    379             Formattable af;
    380             fmt.parse(s, af, pos);
    381             double a;
    382             UBool useEpsilon = FALSE;
    383             if (af.getType() == Formattable::kLong)
    384                 a = af.getLong();
    385             else if (af.getType() == Formattable::kDouble) {
    386                 a = af.getDouble();
    387 #if U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400
    388                 // S/390 will show a failure like this:
    389                 //| -3.141592652999999e-271 -format-> -3.1416E-271
    390                 //|                          -parse-> -3.1416e-271
    391                 //| FAIL: Expected -3.141599999999999e-271
    392                 // To compensate, we use an epsilon-based equality
    393                 // test on S/390 only.  We don't want to do this in
    394                 // general because it's less exacting.
    395                 useEpsilon = TRUE;
    396 #endif
    397             }
    398             else {
    399                 errln((UnicodeString)"FAIL: Non-numeric Formattable returned");
    400                 continue;
    401             }
    402             if (pos.getIndex() == s.length())
    403             {
    404                 logln((UnicodeString)"  -parse-> " + a);
    405                 // Use epsilon comparison as necessary
    406                 if ((useEpsilon &&
    407                     (uprv_fabs(a - valParse[v+ival]) / a > (2*DBL_EPSILON))) ||
    408                     (!useEpsilon && a != valParse[v+ival]))
    409                 {
    410                     errln((UnicodeString)"FAIL: Expected " + valParse[v+ival]);
    411                 }
    412             }
    413             else {
    414                 errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a);
    415                 errln((UnicodeString)"  should be (" + s.length() + " chars) -> " + valParse[v+ival]);
    416             }
    417         }
    418         for (v=0; v<lval_length; ++v)
    419         {
    420             UnicodeString s;
    421             (*(NumberFormat*)&fmt).format(lval[v], s);
    422             logln((UnicodeString)" " + lval[v] + "L -format-> " + s);
    423             if (s != lvalFormat[v+ilval])
    424                 errln((UnicodeString)"ERROR: Expected " + lvalFormat[v+ilval] + " Got: " + s);
    425 
    426             ParsePosition pos(0);
    427             Formattable af;
    428             fmt.parse(s, af, pos);
    429             if (af.getType() == Formattable::kLong ||
    430                 af.getType() == Formattable::kInt64) {
    431                 UErrorCode status = U_ZERO_ERROR;
    432                 int32_t a = af.getLong(status);
    433                 if (pos.getIndex() == s.length())
    434                 {
    435                     logln((UnicodeString)"  -parse-> " + a);
    436                     if (a != lvalParse[v+ilval])
    437                         errln((UnicodeString)"FAIL: Expected " + lvalParse[v+ilval]);
    438                 }
    439                 else
    440                     errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a);
    441             }
    442             else
    443                 errln((UnicodeString)"FAIL: Non-long Formattable returned for " + s
    444                     + " Double: " + af.getDouble()
    445                     + ", Long: " + af.getLong());
    446         }
    447         ival += val_length;
    448         ilval += lval_length;
    449     }
    450 }
    451 
    452 void
    453 NumberFormatTest::TestScientific2() {
    454     // jb 2552
    455     UErrorCode status = U_ZERO_ERROR;
    456     DecimalFormat* fmt = (DecimalFormat*)NumberFormat::createCurrencyInstance("en_US", status);
    457     if (U_SUCCESS(status)) {
    458         double num = 12.34;
    459         expect(*fmt, num, "$12.34");
    460         fmt->setScientificNotation(TRUE);
    461         expect(*fmt, num, "$1.23E1");
    462         fmt->setScientificNotation(FALSE);
    463         expect(*fmt, num, "$12.34");
    464     }
    465     delete fmt;
    466 }
    467 
    468 void
    469 NumberFormatTest::TestScientificGrouping() {
    470     // jb 2552
    471     UErrorCode status = U_ZERO_ERROR;
    472     DecimalFormat fmt("##0.00E0",status);
    473     if (U_SUCCESS(status)) {
    474         expect(fmt, .01234, "12.3E-3");
    475         expect(fmt, .1234, "123E-3");
    476         expect(fmt, 1.234, "1.23E0");
    477         expect(fmt, 12.34, "12.3E0");
    478         expect(fmt, 123.4, "123E0");
    479         expect(fmt, 1234., "1.23E3");
    480     }
    481 }
    482 
    483 /*static void setFromString(DigitList& dl, const char* str) {
    484     char c;
    485     UBool decimalSet = FALSE;
    486     dl.clear();
    487     while ((c = *str++)) {
    488         if (c == '-') {
    489             dl.fIsPositive = FALSE;
    490         } else if (c == '+') {
    491             dl.fIsPositive = TRUE;
    492         } else if (c == '.') {
    493             dl.fDecimalAt = dl.fCount;
    494             decimalSet = TRUE;
    495         } else {
    496             dl.append(c);
    497         }
    498     }
    499     if (!decimalSet) {
    500         dl.fDecimalAt = dl.fCount;
    501     }
    502 }*/
    503 
    504 void
    505 NumberFormatTest::TestInt64() {
    506     UErrorCode status = U_ZERO_ERROR;
    507     DecimalFormat fmt("#.#E0",status);
    508     fmt.setMaximumFractionDigits(20);
    509     if (U_SUCCESS(status)) {
    510         expect(fmt, (Formattable)(int64_t)0, "0E0");
    511         expect(fmt, (Formattable)(int64_t)-1, "-1E0");
    512         expect(fmt, (Formattable)(int64_t)1, "1E0");
    513         expect(fmt, (Formattable)(int64_t)2147483647, "2.147483647E9");
    514         expect(fmt, (Formattable)((int64_t)-2147483647-1), "-2.147483648E9");
    515         expect(fmt, (Formattable)(int64_t)U_INT64_MAX, "9.223372036854775807E18");
    516         expect(fmt, (Formattable)(int64_t)U_INT64_MIN, "-9.223372036854775808E18");
    517     }
    518 
    519     // also test digitlist
    520 /*    int64_t int64max = U_INT64_MAX;
    521     int64_t int64min = U_INT64_MIN;
    522     const char* int64maxstr = "9223372036854775807";
    523     const char* int64minstr = "-9223372036854775808";
    524     UnicodeString fail("fail: ");
    525 
    526     // test max int64 value
    527     DigitList dl;
    528     setFromString(dl, int64maxstr);
    529     {
    530         if (!dl.fitsIntoInt64(FALSE)) {
    531             errln(fail + int64maxstr + " didn't fit");
    532         }
    533         int64_t int64Value = dl.getInt64();
    534         if (int64Value != int64max) {
    535             errln(fail + int64maxstr);
    536         }
    537         dl.set(int64Value);
    538         int64Value = dl.getInt64();
    539         if (int64Value != int64max) {
    540             errln(fail + int64maxstr);
    541         }
    542     }
    543     // test negative of max int64 value (1 shy of min int64 value)
    544     dl.fIsPositive = FALSE;
    545     {
    546         if (!dl.fitsIntoInt64(FALSE)) {
    547             errln(fail + "-" + int64maxstr + " didn't fit");
    548         }
    549         int64_t int64Value = dl.getInt64();
    550         if (int64Value != -int64max) {
    551             errln(fail + "-" + int64maxstr);
    552         }
    553         dl.set(int64Value);
    554         int64Value = dl.getInt64();
    555         if (int64Value != -int64max) {
    556             errln(fail + "-" + int64maxstr);
    557         }
    558     }
    559     // test min int64 value
    560     setFromString(dl, int64minstr);
    561     {
    562         if (!dl.fitsIntoInt64(FALSE)) {
    563             errln(fail + "-" + int64minstr + " didn't fit");
    564         }
    565         int64_t int64Value = dl.getInt64();
    566         if (int64Value != int64min) {
    567             errln(fail + int64minstr);
    568         }
    569         dl.set(int64Value);
    570         int64Value = dl.getInt64();
    571         if (int64Value != int64min) {
    572             errln(fail + int64minstr);
    573         }
    574     }
    575     // test negative of min int 64 value (1 more than max int64 value)
    576     dl.fIsPositive = TRUE; // won't fit
    577     {
    578         if (dl.fitsIntoInt64(FALSE)) {
    579             errln(fail + "-(" + int64minstr + ") didn't fit");
    580         }
    581     }*/
    582 }
    583 
    584 // -------------------------------------
    585 
    586 // Test the handling of quotes
    587 void
    588 NumberFormatTest::TestQuotes(void)
    589 {
    590     UErrorCode status = U_ZERO_ERROR;
    591     UnicodeString *pat;
    592     DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), status);
    593     if (U_FAILURE(status)) {
    594         errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status));
    595         delete sym;
    596         return;
    597     }
    598     pat = new UnicodeString("a'fo''o'b#");
    599     DecimalFormat *fmt = new DecimalFormat(*pat, *sym, status);
    600     UnicodeString s;
    601     ((NumberFormat*)fmt)->format((int32_t)123, s);
    602     logln((UnicodeString)"Pattern \"" + *pat + "\"");
    603     logln((UnicodeString)" Format 123 -> " + escape(s));
    604     if (!(s=="afo'ob123"))
    605         errln((UnicodeString)"FAIL: Expected afo'ob123");
    606 
    607     s.truncate(0);
    608     delete fmt;
    609     delete pat;
    610 
    611     pat = new UnicodeString("a''b#");
    612     fmt = new DecimalFormat(*pat, *sym, status);
    613     ((NumberFormat*)fmt)->format((int32_t)123, s);
    614     logln((UnicodeString)"Pattern \"" + *pat + "\"");
    615     logln((UnicodeString)" Format 123 -> " + escape(s));
    616     if (!(s=="a'b123"))
    617         errln((UnicodeString)"FAIL: Expected a'b123");
    618     delete fmt;
    619     delete pat;
    620     delete sym;
    621 }
    622 
    623 /**
    624  * Test the handling of the currency symbol in patterns.
    625  */
    626 void
    627 NumberFormatTest::TestCurrencySign(void)
    628 {
    629     UErrorCode status = U_ZERO_ERROR;
    630     DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale::getUS(), status);
    631     UnicodeString pat;
    632     UChar currency = 0x00A4;
    633     if (U_FAILURE(status)) {
    634         errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status));
    635         delete sym;
    636         return;
    637     }
    638     // "\xA4#,##0.00;-\xA4#,##0.00"
    639     pat.append(currency).append("#,##0.00;-").
    640         append(currency).append("#,##0.00");
    641     DecimalFormat *fmt = new DecimalFormat(pat, *sym, status);
    642     UnicodeString s; ((NumberFormat*)fmt)->format(1234.56, s);
    643     pat.truncate(0);
    644     logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
    645     logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
    646     if (s != "$1,234.56") dataerrln((UnicodeString)"FAIL: Expected $1,234.56");
    647     s.truncate(0);
    648     ((NumberFormat*)fmt)->format(- 1234.56, s);
    649     logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
    650     if (s != "-$1,234.56") dataerrln((UnicodeString)"FAIL: Expected -$1,234.56");
    651     delete fmt;
    652     pat.truncate(0);
    653     // "\xA4\xA4 #,##0.00;\xA4\xA4 -#,##0.00"
    654     pat.append(currency).append(currency).
    655         append(" #,##0.00;").
    656         append(currency).append(currency).
    657         append(" -#,##0.00");
    658     fmt = new DecimalFormat(pat, *sym, status);
    659     s.truncate(0);
    660     ((NumberFormat*)fmt)->format(1234.56, s);
    661     logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
    662     logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
    663     if (s != "USD 1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD 1,234.56");
    664     s.truncate(0);
    665     ((NumberFormat*)fmt)->format(-1234.56, s);
    666     logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
    667     if (s != "USD -1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD -1,234.56");
    668     delete fmt;
    669     delete sym;
    670     if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + u_errorName(status));
    671 }
    672 
    673 // -------------------------------------
    674 
    675 static UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
    676 
    677 UnicodeString&
    678 NumberFormatTest::escape(UnicodeString& s)
    679 {
    680     UnicodeString buf;
    681     for (int32_t i=0; i<s.length(); ++i)
    682     {
    683         UChar c = s[(int32_t)i];
    684         if (c <= (UChar)0x7F) buf += c;
    685         else {
    686             buf += (UChar)0x5c; buf += (UChar)0x55;
    687             buf += toHexString((c & 0xF000) >> 12);
    688             buf += toHexString((c & 0x0F00) >> 8);
    689             buf += toHexString((c & 0x00F0) >> 4);
    690             buf += toHexString(c & 0x000F);
    691         }
    692     }
    693     return (s = buf);
    694 }
    695 
    696 
    697 // -------------------------------------
    698 static const char* testCases[][2]= {
    699      /* locale ID */  /* expected */
    700     {"ca_ES_PREEURO", "\\u20A7\\u00A01.150" },
    701     {"de_LU_PREEURO", "1,150\\u00A0F" },
    702     {"el_GR_PREEURO", "1.150,50\\u00A0\\u0394\\u03C1\\u03C7" },
    703     {"en_BE_PREEURO", "1.150,50\\u00A0BEF" },
    704     {"es_ES_PREEURO", "1.150\\u00A0\\u20A7" },
    705     {"eu_ES_PREEURO", "\\u20A7\\u00A01.150" },
    706     {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" },
    707     {"it_IT_PREEURO", "ITL\\u00A01.150" },
    708     {"pt_PT_PREEURO", "1,150$50\\u00A0Esc."},
    709     {"en_US@currency=JPY", "\\u00A51,150"},
    710     {"en_US@currency=jpy", "\\u00A51,150"},
    711     {"en-US-u-cu-jpy", "\\u00A51,150"}
    712 };
    713 /**
    714  * Test localized currency patterns.
    715  */
    716 void
    717 NumberFormatTest::TestCurrency(void)
    718 {
    719     UErrorCode status = U_ZERO_ERROR;
    720     NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(Locale::getCanadaFrench(), status);
    721     if (U_FAILURE(status)) {
    722         dataerrln("Error calling NumberFormat::createCurrencyInstance()");
    723         return;
    724     }
    725 
    726     UnicodeString s; currencyFmt->format(1.50, s);
    727     logln((UnicodeString)"Un pauvre ici a..........." + s);
    728     if (!(s==CharsToUnicodeString("1,50\\u00A0$")))
    729         errln((UnicodeString)"FAIL: Expected 1,50<nbsp>$");
    730     delete currencyFmt;
    731     s.truncate(0);
    732     char loc[256]={0};
    733     int len = uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
    734     currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc),status);
    735     currencyFmt->format(1.50, s);
    736     logln((UnicodeString)"Un pauvre en Allemagne a.." + s);
    737     if (!(s==CharsToUnicodeString("1,50\\u00A0DEM")))
    738         errln((UnicodeString)"FAIL: Expected 1,50<nbsp>DEM");
    739     delete currencyFmt;
    740     s.truncate(0);
    741     len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
    742     currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status);
    743     currencyFmt->format(1.50, s);
    744     logln((UnicodeString)"Un pauvre en France a....." + s);
    745     if (!(s==CharsToUnicodeString("1,50\\u00A0F")))
    746         errln((UnicodeString)"FAIL: Expected 1,50<nbsp>F");
    747     delete currencyFmt;
    748     if (U_FAILURE(status))
    749         errln((UnicodeString)"FAIL: Status " + (int32_t)status);
    750 
    751     for(int i=0; i < (int)(sizeof(testCases)/sizeof(testCases[i])); i++){
    752         status = U_ZERO_ERROR;
    753         const char *localeID = testCases[i][0];
    754         UnicodeString expected(testCases[i][1], -1, US_INV);
    755         expected = expected.unescape();
    756         s.truncate(0);
    757         char loc[256]={0};
    758         uloc_canonicalize(localeID, loc, 256, &status);
    759         currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status);
    760         if(U_FAILURE(status)){
    761             errln("Could not create currency formatter for locale %s",localeID);
    762             continue;
    763         }
    764         currencyFmt->format(1150.50, s);
    765         if(s!=expected){
    766             errln(UnicodeString("FAIL: Expected: ")+expected
    767                     + UnicodeString(" Got: ") + s
    768                     + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
    769         }
    770         if (U_FAILURE(status)){
    771             errln((UnicodeString)"FAIL: Status " + (int32_t)status);
    772         }
    773         delete currencyFmt;
    774     }
    775 }
    776 
    777 // -------------------------------------
    778 
    779 /**
    780  * Test the Currency object handling, new as of ICU 2.2.
    781  */
    782 void NumberFormatTest::TestCurrencyObject() {
    783     UErrorCode ec = U_ZERO_ERROR;
    784     NumberFormat* fmt =
    785         NumberFormat::createCurrencyInstance(Locale::getUS(), ec);
    786 
    787     if (U_FAILURE(ec)) {
    788         dataerrln("FAIL: getCurrencyInstance(US) - %s", u_errorName(ec));
    789         delete fmt;
    790         return;
    791     }
    792 
    793     Locale null("", "", "");
    794 
    795     expectCurrency(*fmt, null, 1234.56, "$1,234.56");
    796 
    797     expectCurrency(*fmt, Locale::getFrance(),
    798                    1234.56, CharsToUnicodeString("\\u20AC1,234.56")); // Euro
    799 
    800     expectCurrency(*fmt, Locale::getJapan(),
    801                    1234.56, CharsToUnicodeString("\\u00A51,235")); // Yen
    802 
    803     expectCurrency(*fmt, Locale("fr", "CH", ""),
    804                    1234.56, "CHF1,234.55"); // 0.05 rounding
    805 
    806     expectCurrency(*fmt, Locale::getUS(),
    807                    1234.56, "$1,234.56");
    808 
    809     delete fmt;
    810     fmt = NumberFormat::createCurrencyInstance(Locale::getFrance(), ec);
    811 
    812     if (U_FAILURE(ec)) {
    813         errln("FAIL: getCurrencyInstance(FRANCE)");
    814         delete fmt;
    815         return;
    816     }
    817 
    818     expectCurrency(*fmt, null, 1234.56, CharsToUnicodeString("1 234,56 \\u20AC"));
    819 
    820     expectCurrency(*fmt, Locale::getJapan(),
    821                    1234.56, CharsToUnicodeString("1 235 \\u00A5JP")); // Yen
    822 
    823     expectCurrency(*fmt, Locale("fr", "CH", ""),
    824                    1234.56, "1 234,55 CHF"); // 0.05 rounding
    825 
    826     expectCurrency(*fmt, Locale::getUS(),
    827                    1234.56, "1 234,56 $US");
    828 
    829     expectCurrency(*fmt, Locale::getFrance(),
    830                    1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); // Euro
    831 
    832     delete fmt;
    833 }
    834 
    835 // -------------------------------------
    836 
    837 /**
    838  * Do rudimentary testing of parsing.
    839  */
    840 void
    841 NumberFormatTest::TestParse(void)
    842 {
    843     UErrorCode status = U_ZERO_ERROR;
    844     UnicodeString arg("0");
    845     DecimalFormat* format = new DecimalFormat("00", status);
    846     //try {
    847         Formattable n; format->parse(arg, n, status);
    848         logln((UnicodeString)"parse(" + arg + ") = " + n.getLong());
    849         if (n.getType() != Formattable::kLong ||
    850             n.getLong() != 0) errln((UnicodeString)"FAIL: Expected 0");
    851     delete format;
    852     if (U_FAILURE(status)) errcheckln(status, (UnicodeString)"FAIL: Status " + u_errorName(status));
    853     //}
    854     //catch(Exception e) {
    855     //    errln((UnicodeString)"Exception caught: " + e);
    856     //}
    857 }
    858 
    859 // -------------------------------------
    860 
    861 static const char *lenientAffixTestCases[] = {
    862         "(1)",
    863         "( 1)",
    864         "(1 )",
    865         "( 1 )"
    866 };
    867 
    868 static const char *lenientMinusTestCases[] = {
    869     "-5",
    870     "\\u22125",
    871     "\\u20105"
    872 };
    873 
    874 static const char *lenientCurrencyTestCases[] = {
    875         "$1,000",
    876         "$ 1,000",
    877         "$1000",
    878         "$ 1000",
    879         "$1 000.00",
    880         "$ 1 000.00",
    881         "$ 1\\u00A0000.00",
    882         "1000.00"
    883 };
    884 
    885 static const char *lenientNegativeCurrencyTestCases[] = {
    886         "($1,000)",
    887         "($ 1,000)",
    888         "($1000)",
    889         "($ 1000)",
    890         "($1 000.00)",
    891         "($ 1 000.00)",
    892         "( $ 1,000.00 )",
    893         "($ 1\\u00A0000.00)",
    894         "(1000.00)"
    895 };
    896 
    897 static const char *lenientPercentTestCases[] = {
    898         "25%",
    899         " 25%",
    900         " 25 %",
    901     	"25 %",
    902 		"25\\u00A0%",
    903 		"25"
    904 };
    905 
    906 static const char *lenientNegativePercentTestCases[] = {
    907 		"-25%",
    908 		" -25%",
    909 		" - 25%",
    910 		"- 25 %",
    911 		" - 25 %",
    912 		"-25 %",
    913 		"-25\\u00A0%",
    914 		"-25",
    915 		"- 25"
    916 };
    917 
    918 static const char *strictFailureTestCases[] = {
    919 		" 1000",
    920 		"10,00",
    921 		"1,000,.0"
    922 };
    923 
    924 #define ARRAY_SIZE(array) ((int32_t) (sizeof (array) / sizeof(array[0])))
    925 
    926 /**
    927  * Test lenient parsing.
    928  */
    929 void
    930 NumberFormatTest::TestLenientParse(void)
    931 {
    932     UErrorCode status = U_ZERO_ERROR;
    933     DecimalFormat *format = new DecimalFormat("(#,##0)", status);
    934     Formattable n;
    935 
    936     if (format == NULL || U_FAILURE(status)) {
    937         dataerrln("Unable to create DecimalFormat (#,##0) - %s", u_errorName(status));
    938     } else {
    939         format->setLenient(TRUE);
    940         for (int32_t t = 0; t < ARRAY_SIZE (lenientAffixTestCases); t += 1) {
    941         	UnicodeString testCase = ctou(lenientAffixTestCases[t]);
    942 
    943             format->parse(testCase, n, status);
    944             logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
    945 
    946             if (U_FAILURE(status) || n.getType() != Formattable::kLong ||
    947             	n.getLong() != 1) {
    948             	errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientAffixTestCases[t] + (UnicodeString) "\"");
    949             	status = U_ZERO_ERROR;
    950             }
    951        }
    952        delete format;
    953     }
    954 
    955     Locale en_US("en_US");
    956     Locale sv_SE("sv_SE");
    957 
    958     NumberFormat *mFormat = NumberFormat::createInstance(sv_SE, UNUM_DECIMAL, status);
    959 
    960     if (mFormat == NULL || U_FAILURE(status)) {
    961         dataerrln("Unable to create NumberFormat (sv_SE, UNUM_DECIMAL) - %s", u_errorName(status));
    962     } else {
    963         mFormat->setLenient(TRUE);
    964         for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
    965             UnicodeString testCase = ctou(lenientMinusTestCases[t]);
    966 
    967             mFormat->parse(testCase, n, status);
    968             logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
    969 
    970             if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
    971                 errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
    972                 status = U_ZERO_ERROR;
    973             }
    974         }
    975         delete mFormat;
    976     }
    977 
    978     mFormat = NumberFormat::createInstance(en_US, UNUM_DECIMAL, status);
    979 
    980     if (mFormat == NULL || U_FAILURE(status)) {
    981         dataerrln("Unable to create NumberFormat (en_US, UNUM_DECIMAL) - %s", u_errorName(status));
    982     } else {
    983         mFormat->setLenient(TRUE);
    984         for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
    985             UnicodeString testCase = ctou(lenientMinusTestCases[t]);
    986 
    987             mFormat->parse(testCase, n, status);
    988             logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
    989 
    990             if (U_FAILURE(status) || n.getType() != Formattable::kLong || n.getLong() != -5) {
    991                 errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientMinusTestCases[t] + (UnicodeString) "\"");
    992                 status = U_ZERO_ERROR;
    993             }
    994         }
    995         delete mFormat;
    996     }
    997 
    998     NumberFormat *cFormat = NumberFormat::createInstance(en_US, UNUM_CURRENCY, status);
    999 
   1000     if (cFormat == NULL || U_FAILURE(status)) {
   1001         dataerrln("Unable to create NumberFormat (en_US, UNUM_CURRENCY) - %s", u_errorName(status));
   1002     } else {
   1003         cFormat->setLenient(TRUE);
   1004         for (int32_t t = 0; t < ARRAY_SIZE (lenientCurrencyTestCases); t += 1) {
   1005         	UnicodeString testCase = ctou(lenientCurrencyTestCases[t]);
   1006 
   1007             cFormat->parse(testCase, n, status);
   1008             logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
   1009 
   1010             if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
   1011             	n.getLong() != 1000) {
   1012             	errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientCurrencyTestCases[t] + (UnicodeString) "\"");
   1013             	status = U_ZERO_ERROR;
   1014             }
   1015         }
   1016 
   1017         for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativeCurrencyTestCases); t += 1) {
   1018         	UnicodeString testCase = ctou(lenientNegativeCurrencyTestCases[t]);
   1019 
   1020             cFormat->parse(testCase, n, status);
   1021             logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
   1022 
   1023             if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
   1024             	n.getLong() != -1000) {
   1025             	errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativeCurrencyTestCases[t] + (UnicodeString) "\"");
   1026             	status = U_ZERO_ERROR;
   1027             }
   1028         }
   1029 
   1030         delete cFormat;
   1031     }
   1032 
   1033     NumberFormat *pFormat = NumberFormat::createPercentInstance(en_US, status);
   1034 
   1035     if (pFormat == NULL || U_FAILURE(status)) {
   1036         dataerrln("Unable to create NumberFormat::createPercentInstance (en_US) - %s", u_errorName(status));
   1037     } else {
   1038         pFormat->setLenient(TRUE);
   1039         for (int32_t t = 0; t < ARRAY_SIZE (lenientPercentTestCases); t += 1) {
   1040         	UnicodeString testCase = ctou(lenientPercentTestCases[t]);
   1041 
   1042         	pFormat->parse(testCase, n, status);
   1043             logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
   1044 
   1045             if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
   1046             	n.getDouble() != 0.25) {
   1047             	errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientPercentTestCases[t] + (UnicodeString) "\"");
   1048             	status = U_ZERO_ERROR;
   1049             }
   1050         }
   1051 
   1052         for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativePercentTestCases); t += 1) {
   1053         	UnicodeString testCase = ctou(lenientNegativePercentTestCases[t]);
   1054 
   1055         	pFormat->parse(testCase, n, status);
   1056             logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
   1057 
   1058             if (U_FAILURE(status) ||n.getType() != Formattable::kDouble ||
   1059             	n.getDouble() != -0.25) {
   1060             	errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientNegativePercentTestCases[t] + (UnicodeString) "\"");
   1061             	status = U_ZERO_ERROR;
   1062             }
   1063         }
   1064 
   1065         delete pFormat;
   1066     }
   1067 
   1068    // Test cases that should fail with a strict parse and pass with a
   1069    // lenient parse.
   1070    NumberFormat *nFormat = NumberFormat::createInstance(en_US, status);
   1071 
   1072    if (nFormat == NULL || U_FAILURE(status)) {
   1073        dataerrln("Unable to create NumberFormat (en_US) - %s", u_errorName(status));
   1074    } else {
   1075        // first, make sure that they fail with a strict parse
   1076        for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
   1077 	       UnicodeString testCase = ctou(strictFailureTestCases[t]);
   1078 
   1079 	       nFormat->parse(testCase, n, status);
   1080 	       logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
   1081 
   1082 	       if (! U_FAILURE(status)) {
   1083 		       errln((UnicodeString)"Strict Parse succeeded for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
   1084 	       }
   1085 
   1086 	       status = U_ZERO_ERROR;
   1087        }
   1088 
   1089        // then, make sure that they pass with a lenient parse
   1090        nFormat->setLenient(TRUE);
   1091        for (int32_t t = 0; t < ARRAY_SIZE(strictFailureTestCases); t += 1) {
   1092 	       UnicodeString testCase = ctou(strictFailureTestCases[t]);
   1093 
   1094 	       nFormat->parse(testCase, n, status);
   1095 	       logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
   1096 
   1097 	       if (U_FAILURE(status) ||n.getType() != Formattable::kLong ||
   1098 	            	n.getLong() != 1000) {
   1099 		       errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
   1100 		       status = U_ZERO_ERROR;
   1101 	       }
   1102        }
   1103 
   1104        delete nFormat;
   1105    }
   1106 }
   1107 
   1108 // -------------------------------------
   1109 
   1110 /**
   1111  * Test proper rounding by the format method.
   1112  */
   1113 void
   1114 NumberFormatTest::TestRounding487(void)
   1115 {
   1116     UErrorCode status = U_ZERO_ERROR;
   1117     NumberFormat *nf = NumberFormat::createInstance(status);
   1118     if (U_FAILURE(status)) {
   1119         dataerrln("Error calling NumberFormat::createInstance()");
   1120         return;
   1121     }
   1122 
   1123     roundingTest(*nf, 0.00159999, 4, "0.0016");
   1124     roundingTest(*nf, 0.00995, 4, "0.01");
   1125 
   1126     roundingTest(*nf, 12.3995, 3, "12.4");
   1127 
   1128     roundingTest(*nf, 12.4999, 0, "12");
   1129     roundingTest(*nf, - 19.5, 0, "-20");
   1130     delete nf;
   1131     if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + (int32_t)status);
   1132 }
   1133 
   1134 /**
   1135  * Test the functioning of the secondary grouping value.
   1136  */
   1137 void NumberFormatTest::TestSecondaryGrouping(void) {
   1138     UErrorCode status = U_ZERO_ERROR;
   1139     DecimalFormatSymbols US(Locale::getUS(), status);
   1140     CHECK(status, "DecimalFormatSymbols ct");
   1141 
   1142     DecimalFormat f("#,##,###", US, status);
   1143     CHECK(status, "DecimalFormat ct");
   1144 
   1145     expect2(f, (int32_t)123456789L, "12,34,56,789");
   1146     expectPat(f, "#,##,###");
   1147     f.applyPattern("#,###", status);
   1148     CHECK(status, "applyPattern");
   1149 
   1150     f.setSecondaryGroupingSize(4);
   1151     expect2(f, (int32_t)123456789L, "12,3456,789");
   1152     expectPat(f, "#,####,###");
   1153     NumberFormat *g = NumberFormat::createInstance(Locale("hi", "IN"), status);
   1154     CHECK_DATA(status, "createInstance(hi_IN)");
   1155 
   1156     UnicodeString out;
   1157     int32_t l = (int32_t)1876543210L;
   1158     g->format(l, out);
   1159     delete g;
   1160     // expect "1,87,65,43,210", but with Hindi digits
   1161     //         01234567890123
   1162     UBool ok = TRUE;
   1163     if (out.length() != 14) {
   1164         ok = FALSE;
   1165     } else {
   1166         for (int32_t i=0; i<out.length(); ++i) {
   1167             UBool expectGroup = FALSE;
   1168             switch (i) {
   1169             case 1:
   1170             case 4:
   1171             case 7:
   1172             case 10:
   1173                 expectGroup = TRUE;
   1174                 break;
   1175             }
   1176             // Later -- fix this to get the actual grouping
   1177             // character from the resource bundle.
   1178             UBool isGroup = (out.charAt(i) == 0x002C);
   1179             if (isGroup != expectGroup) {
   1180                 ok = FALSE;
   1181                 break;
   1182             }
   1183         }
   1184     }
   1185     if (!ok) {
   1186         errln((UnicodeString)"FAIL  Expected " + l +
   1187               " x hi_IN -> \"1,87,65,43,210\" (with Hindi digits), got \"" +
   1188               escape(out) + "\"");
   1189     } else {
   1190         logln((UnicodeString)"Ok    " + l +
   1191               " x hi_IN -> \"" +
   1192               escape(out) + "\"");
   1193     }
   1194 }
   1195 
   1196 void NumberFormatTest::TestWhiteSpaceParsing(void) {
   1197     UErrorCode ec = U_ZERO_ERROR;
   1198     DecimalFormatSymbols US(Locale::getUS(), ec);
   1199     DecimalFormat fmt("a  b#0c  ", US, ec);
   1200     if (U_FAILURE(ec)) {
   1201         errcheckln(ec, "FAIL: Constructor - %s", u_errorName(ec));
   1202         return;
   1203     }
   1204     int32_t n = 1234;
   1205     expect(fmt, "a b1234c ", n);
   1206     expect(fmt, "a   b1234c   ", n);
   1207 }
   1208 
   1209 /**
   1210  * Test currencies whose display name is a ChoiceFormat.
   1211  */
   1212 void NumberFormatTest::TestComplexCurrency() {
   1213 
   1214 //    UErrorCode ec = U_ZERO_ERROR;
   1215 //    Locale loc("kn", "IN", "");
   1216 //    NumberFormat* fmt = NumberFormat::createCurrencyInstance(loc, ec);
   1217 //    if (U_SUCCESS(ec)) {
   1218 //        expect2(*fmt, 1.0, CharsToUnicodeString("Re.\\u00A01.00"));
   1219 //        Use .00392625 because that's 2^-8.  Any value less than 0.005 is fine.
   1220 //        expect(*fmt, 1.00390625, CharsToUnicodeString("Re.\\u00A01.00")); // tricky
   1221 //        expect2(*fmt, 12345678.0, CharsToUnicodeString("Rs.\\u00A01,23,45,678.00"));
   1222 //        expect2(*fmt, 0.5, CharsToUnicodeString("Rs.\\u00A00.50"));
   1223 //        expect2(*fmt, -1.0, CharsToUnicodeString("-Re.\\u00A01.00"));
   1224 //        expect2(*fmt, -10.0, CharsToUnicodeString("-Rs.\\u00A010.00"));
   1225 //    } else {
   1226 //        errln("FAIL: getCurrencyInstance(kn_IN)");
   1227 //    }
   1228 //    delete fmt;
   1229 
   1230 }
   1231 
   1232 // -------------------------------------
   1233 
   1234 void
   1235 NumberFormatTest::roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected)
   1236 {
   1237     nf.setMaximumFractionDigits(maxFractionDigits);
   1238     UnicodeString out; nf.format(x, out);
   1239     logln((UnicodeString)"" + x + " formats with " + maxFractionDigits + " fractional digits to " + out);
   1240     if (!(out==expected)) errln((UnicodeString)"FAIL: Expected " + expected);
   1241 }
   1242 
   1243 /**
   1244  * Upgrade to alphaWorks
   1245  */
   1246 void NumberFormatTest::TestExponent(void) {
   1247     UErrorCode status = U_ZERO_ERROR;
   1248     DecimalFormatSymbols US(Locale::getUS(), status);
   1249     CHECK(status, "DecimalFormatSymbols constructor");
   1250     DecimalFormat fmt1(UnicodeString("0.###E0"), US, status);
   1251     CHECK(status, "DecimalFormat(0.###E0)");
   1252     DecimalFormat fmt2(UnicodeString("0.###E+0"), US, status);
   1253     CHECK(status, "DecimalFormat(0.###E+0)");
   1254     int32_t n = 1234;
   1255     expect2(fmt1, n, "1.234E3");
   1256     expect2(fmt2, n, "1.234E+3");
   1257     expect(fmt1, "1.234E+3", n); // Either format should parse "E+3"
   1258 }
   1259 
   1260 /**
   1261  * Upgrade to alphaWorks
   1262  */
   1263 void NumberFormatTest::TestScientific(void) {
   1264     UErrorCode status = U_ZERO_ERROR;
   1265     DecimalFormatSymbols US(Locale::getUS(), status);
   1266     CHECK(status, "DecimalFormatSymbols constructor");
   1267 
   1268     // Test pattern round-trip
   1269     const char* PAT[] = { "#E0", "0.####E0", "00.000E00", "##0.####E000",
   1270                           "0.###E0;[0.###E0]" };
   1271     int32_t PAT_length = (int32_t)(sizeof(PAT) / sizeof(PAT[0]));
   1272     int32_t DIGITS[] = {
   1273         // min int, max int, min frac, max frac
   1274         0, 1, 0, 0, // "#E0"
   1275         1, 1, 0, 4, // "0.####E0"
   1276         2, 2, 3, 3, // "00.000E00"
   1277         1, 3, 0, 4, // "##0.####E000"
   1278         1, 1, 0, 3, // "0.###E0;[0.###E0]"
   1279     };
   1280     for (int32_t i=0; i<PAT_length; ++i) {
   1281         UnicodeString pat(PAT[i]);
   1282         DecimalFormat df(pat, US, status);
   1283         CHECK(status, "DecimalFormat constructor");
   1284         UnicodeString pat2;
   1285         df.toPattern(pat2);
   1286         if (pat == pat2) {
   1287             logln(UnicodeString("Ok   Pattern rt \"") +
   1288                   pat + "\" -> \"" +
   1289                   pat2 + "\"");
   1290         } else {
   1291             errln(UnicodeString("FAIL Pattern rt \"") +
   1292                   pat + "\" -> \"" +
   1293                   pat2 + "\"");
   1294         }
   1295         // Make sure digit counts match what we expect
   1296         if (df.getMinimumIntegerDigits() != DIGITS[4*i] ||
   1297             df.getMaximumIntegerDigits() != DIGITS[4*i+1] ||
   1298             df.getMinimumFractionDigits() != DIGITS[4*i+2] ||
   1299             df.getMaximumFractionDigits() != DIGITS[4*i+3]) {
   1300             errln(UnicodeString("FAIL \"" + pat +
   1301                                 "\" min/max int; min/max frac = ") +
   1302                   df.getMinimumIntegerDigits() + "/" +
   1303                   df.getMaximumIntegerDigits() + ";" +
   1304                   df.getMinimumFractionDigits() + "/" +
   1305                   df.getMaximumFractionDigits() + ", expect " +
   1306                   DIGITS[4*i] + "/" +
   1307                   DIGITS[4*i+1] + ";" +
   1308                   DIGITS[4*i+2] + "/" +
   1309                   DIGITS[4*i+3]);
   1310         }
   1311     }
   1312 
   1313 
   1314     // Test the constructor for default locale. We have to
   1315     // manually set the default locale, as there is no
   1316     // guarantee that the default locale has the same
   1317     // scientific format.
   1318     Locale def = Locale::getDefault();
   1319     Locale::setDefault(Locale::getUS(), status);
   1320     expect2(NumberFormat::createScientificInstance(status),
   1321            12345.678901,
   1322            "1.2345678901E4", status);
   1323     Locale::setDefault(def, status);
   1324 
   1325     expect2(new DecimalFormat("#E0", US, status),
   1326            12345.0,
   1327            "1.2345E4", status);
   1328     expect(new DecimalFormat("0E0", US, status),
   1329            12345.0,
   1330            "1E4", status);
   1331     expect2(NumberFormat::createScientificInstance(Locale::getUS(), status),
   1332            12345.678901,
   1333            "1.2345678901E4", status);
   1334     expect(new DecimalFormat("##0.###E0", US, status),
   1335            12345.0,
   1336            "12.34E3", status);
   1337     expect(new DecimalFormat("##0.###E0", US, status),
   1338            12345.00001,
   1339            "12.35E3", status);
   1340     expect2(new DecimalFormat("##0.####E0", US, status),
   1341            (int32_t) 12345,
   1342            "12.345E3", status);
   1343     expect2(NumberFormat::createScientificInstance(Locale::getFrance(), status),
   1344            12345.678901,
   1345            "1,2345678901E4", status);
   1346     expect(new DecimalFormat("##0.####E0", US, status),
   1347            789.12345e-9,
   1348            "789.12E-9", status);
   1349     expect2(new DecimalFormat("##0.####E0", US, status),
   1350            780.e-9,
   1351            "780E-9", status);
   1352     expect(new DecimalFormat(".###E0", US, status),
   1353            45678.0,
   1354            ".457E5", status);
   1355     expect2(new DecimalFormat(".###E0", US, status),
   1356            (int32_t) 0,
   1357            ".0E0", status);
   1358     /*
   1359     expect(new DecimalFormat[] { new DecimalFormat("#E0", US),
   1360                                  new DecimalFormat("##E0", US),
   1361                                  new DecimalFormat("####E0", US),
   1362                                  new DecimalFormat("0E0", US),
   1363                                  new DecimalFormat("00E0", US),
   1364                                  new DecimalFormat("000E0", US),
   1365                                },
   1366            new Long(45678000),
   1367            new String[] { "4.5678E7",
   1368                           "45.678E6",
   1369                           "4567.8E4",
   1370                           "5E7",
   1371                           "46E6",
   1372                           "457E5",
   1373                         }
   1374            );
   1375     !
   1376     ! Unroll this test into individual tests below...
   1377     !
   1378     */
   1379     expect2(new DecimalFormat("#E0", US, status),
   1380            (int32_t) 45678000, "4.5678E7", status);
   1381     expect2(new DecimalFormat("##E0", US, status),
   1382            (int32_t) 45678000, "45.678E6", status);
   1383     expect2(new DecimalFormat("####E0", US, status),
   1384            (int32_t) 45678000, "4567.8E4", status);
   1385     expect(new DecimalFormat("0E0", US, status),
   1386            (int32_t) 45678000, "5E7", status);
   1387     expect(new DecimalFormat("00E0", US, status),
   1388            (int32_t) 45678000, "46E6", status);
   1389     expect(new DecimalFormat("000E0", US, status),
   1390            (int32_t) 45678000, "457E5", status);
   1391     /*
   1392     expect(new DecimalFormat("###E0", US, status),
   1393            new Object[] { new Double(0.0000123), "12.3E-6",
   1394                           new Double(0.000123), "123E-6",
   1395                           new Double(0.00123), "1.23E-3",
   1396                           new Double(0.0123), "12.3E-3",
   1397                           new Double(0.123), "123E-3",
   1398                           new Double(1.23), "1.23E0",
   1399                           new Double(12.3), "12.3E0",
   1400                           new Double(123), "123E0",
   1401                           new Double(1230), "1.23E3",
   1402                          });
   1403     !
   1404     ! Unroll this test into individual tests below...
   1405     !
   1406     */
   1407     expect2(new DecimalFormat("###E0", US, status),
   1408            0.0000123, "12.3E-6", status);
   1409     expect2(new DecimalFormat("###E0", US, status),
   1410            0.000123, "123E-6", status);
   1411     expect2(new DecimalFormat("###E0", US, status),
   1412            0.00123, "1.23E-3", status);
   1413     expect2(new DecimalFormat("###E0", US, status),
   1414            0.0123, "12.3E-3", status);
   1415     expect2(new DecimalFormat("###E0", US, status),
   1416            0.123, "123E-3", status);
   1417     expect2(new DecimalFormat("###E0", US, status),
   1418            1.23, "1.23E0", status);
   1419     expect2(new DecimalFormat("###E0", US, status),
   1420            12.3, "12.3E0", status);
   1421     expect2(new DecimalFormat("###E0", US, status),
   1422            123.0, "123E0", status);
   1423     expect2(new DecimalFormat("###E0", US, status),
   1424            1230.0, "1.23E3", status);
   1425     /*
   1426     expect(new DecimalFormat("0.#E+00", US, status),
   1427            new Object[] { new Double(0.00012), "1.2E-04",
   1428                           new Long(12000),     "1.2E+04",
   1429                          });
   1430     !
   1431     ! Unroll this test into individual tests below...
   1432     !
   1433     */
   1434     expect2(new DecimalFormat("0.#E+00", US, status),
   1435            0.00012, "1.2E-04", status);
   1436     expect2(new DecimalFormat("0.#E+00", US, status),
   1437            (int32_t) 12000, "1.2E+04", status);
   1438 }
   1439 
   1440 /**
   1441  * Upgrade to alphaWorks
   1442  */
   1443 void NumberFormatTest::TestPad(void) {
   1444     UErrorCode status = U_ZERO_ERROR;
   1445     DecimalFormatSymbols US(Locale::getUS(), status);
   1446     CHECK(status, "DecimalFormatSymbols constructor");
   1447 
   1448     expect2(new DecimalFormat("*^##.##", US, status),
   1449            int32_t(0), "^^^^0", status);
   1450     expect2(new DecimalFormat("*^##.##", US, status),
   1451            -1.3, "^-1.3", status);
   1452     expect2(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status),
   1453            int32_t(0), "0.0E0______ g-m/s^2", status);
   1454     expect(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status),
   1455            1.0/3, "333.333E-3_ g-m/s^2", status);
   1456     expect2(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status),
   1457            int32_t(0), "0.0______ g-m/s^2", status);
   1458     expect(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status),
   1459            1.0/3, "0.33333__ g-m/s^2", status);
   1460 
   1461     // Test padding before a sign
   1462     const char *formatStr = "*x#,###,###,##0.0#;*x(###,###,##0.0#)";
   1463     expect2(new DecimalFormat(formatStr, US, status),
   1464            int32_t(-10),  "xxxxxxxxxx(10.0)", status);
   1465     expect2(new DecimalFormat(formatStr, US, status),
   1466            int32_t(-1000),"xxxxxxx(1,000.0)", status);
   1467     expect2(new DecimalFormat(formatStr, US, status),
   1468            int32_t(-1000000),"xxx(1,000,000.0)", status);
   1469     expect2(new DecimalFormat(formatStr, US, status),
   1470            -100.37,       "xxxxxxxx(100.37)", status);
   1471     expect2(new DecimalFormat(formatStr, US, status),
   1472            -10456.37,     "xxxxx(10,456.37)", status);
   1473     expect2(new DecimalFormat(formatStr, US, status),
   1474            -1120456.37,   "xx(1,120,456.37)", status);
   1475     expect2(new DecimalFormat(formatStr, US, status),
   1476            -112045600.37, "(112,045,600.37)", status);
   1477     expect2(new DecimalFormat(formatStr, US, status),
   1478            -1252045600.37,"(1,252,045,600.37)", status);
   1479 
   1480     expect2(new DecimalFormat(formatStr, US, status),
   1481            int32_t(10),  "xxxxxxxxxxxx10.0", status);
   1482     expect2(new DecimalFormat(formatStr, US, status),
   1483            int32_t(1000),"xxxxxxxxx1,000.0", status);
   1484     expect2(new DecimalFormat(formatStr, US, status),
   1485            int32_t(1000000),"xxxxx1,000,000.0", status);
   1486     expect2(new DecimalFormat(formatStr, US, status),
   1487            100.37,       "xxxxxxxxxx100.37", status);
   1488     expect2(new DecimalFormat(formatStr, US, status),
   1489            10456.37,     "xxxxxxx10,456.37", status);
   1490     expect2(new DecimalFormat(formatStr, US, status),
   1491            1120456.37,   "xxxx1,120,456.37", status);
   1492     expect2(new DecimalFormat(formatStr, US, status),
   1493            112045600.37, "xx112,045,600.37", status);
   1494     expect2(new DecimalFormat(formatStr, US, status),
   1495            10252045600.37,"10,252,045,600.37", status);
   1496 
   1497 
   1498     // Test padding between a sign and a number
   1499     const char *formatStr2 = "#,###,###,##0.0#*x;(###,###,##0.0#*x)";
   1500     expect2(new DecimalFormat(formatStr2, US, status),
   1501            int32_t(-10),  "(10.0xxxxxxxxxx)", status);
   1502     expect2(new DecimalFormat(formatStr2, US, status),
   1503            int32_t(-1000),"(1,000.0xxxxxxx)", status);
   1504     expect2(new DecimalFormat(formatStr2, US, status),
   1505            int32_t(-1000000),"(1,000,000.0xxx)", status);
   1506     expect2(new DecimalFormat(formatStr2, US, status),
   1507            -100.37,       "(100.37xxxxxxxx)", status);
   1508     expect2(new DecimalFormat(formatStr2, US, status),
   1509            -10456.37,     "(10,456.37xxxxx)", status);
   1510     expect2(new DecimalFormat(formatStr2, US, status),
   1511            -1120456.37,   "(1,120,456.37xx)", status);
   1512     expect2(new DecimalFormat(formatStr2, US, status),
   1513            -112045600.37, "(112,045,600.37)", status);
   1514     expect2(new DecimalFormat(formatStr2, US, status),
   1515            -1252045600.37,"(1,252,045,600.37)", status);
   1516 
   1517     expect2(new DecimalFormat(formatStr2, US, status),
   1518            int32_t(10),  "10.0xxxxxxxxxxxx", status);
   1519     expect2(new DecimalFormat(formatStr2, US, status),
   1520            int32_t(1000),"1,000.0xxxxxxxxx", status);
   1521     expect2(new DecimalFormat(formatStr2, US, status),
   1522            int32_t(1000000),"1,000,000.0xxxxx", status);
   1523     expect2(new DecimalFormat(formatStr2, US, status),
   1524            100.37,       "100.37xxxxxxxxxx", status);
   1525     expect2(new DecimalFormat(formatStr2, US, status),
   1526            10456.37,     "10,456.37xxxxxxx", status);
   1527     expect2(new DecimalFormat(formatStr2, US, status),
   1528            1120456.37,   "1,120,456.37xxxx", status);
   1529     expect2(new DecimalFormat(formatStr2, US, status),
   1530            112045600.37, "112,045,600.37xx", status);
   1531     expect2(new DecimalFormat(formatStr2, US, status),
   1532            10252045600.37,"10,252,045,600.37", status);
   1533 
   1534     //testing the setPadCharacter(UnicodeString) and getPadCharacterString()
   1535     DecimalFormat fmt("#", US, status);
   1536     CHECK(status, "DecimalFormat constructor");
   1537     UnicodeString padString("P");
   1538     fmt.setPadCharacter(padString);
   1539     expectPad(fmt, "*P##.##", DecimalFormat::kPadBeforePrefix, 5, padString);
   1540     fmt.setPadCharacter((UnicodeString)"^");
   1541     expectPad(fmt, "*^#", DecimalFormat::kPadBeforePrefix, 1, (UnicodeString)"^");
   1542     //commented untill implementation is complete
   1543   /*  fmt.setPadCharacter((UnicodeString)"^^^");
   1544     expectPad(fmt, "*^^^#", DecimalFormat::kPadBeforePrefix, 3, (UnicodeString)"^^^");
   1545     padString.remove();
   1546     padString.append((UChar)0x0061);
   1547     padString.append((UChar)0x0302);
   1548     fmt.setPadCharacter(padString);
   1549     UChar patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000};
   1550     UnicodeString pattern(patternChars);
   1551     expectPad(fmt, pattern , DecimalFormat::kPadBeforePrefix, 4, padString);
   1552  */
   1553 
   1554 }
   1555 
   1556 /**
   1557  * Upgrade to alphaWorks
   1558  */
   1559 void NumberFormatTest::TestPatterns2(void) {
   1560     UErrorCode status = U_ZERO_ERROR;
   1561     DecimalFormatSymbols US(Locale::getUS(), status);
   1562     CHECK(status, "DecimalFormatSymbols constructor");
   1563 
   1564     DecimalFormat fmt("#", US, status);
   1565     CHECK(status, "DecimalFormat constructor");
   1566 
   1567     UChar hat = 0x005E; /*^*/
   1568 
   1569     expectPad(fmt, "*^#", DecimalFormat::kPadBeforePrefix, 1, hat);
   1570     expectPad(fmt, "$*^#", DecimalFormat::kPadAfterPrefix, 2, hat);
   1571     expectPad(fmt, "#*^", DecimalFormat::kPadBeforeSuffix, 1, hat);
   1572     expectPad(fmt, "#$*^", DecimalFormat::kPadAfterSuffix, 2, hat);
   1573     expectPad(fmt, "$*^$#", ILLEGAL);
   1574     expectPad(fmt, "#$*^$", ILLEGAL);
   1575     expectPad(fmt, "'pre'#,##0*x'post'", DecimalFormat::kPadBeforeSuffix,
   1576               12, (UChar)0x0078 /*x*/);
   1577     expectPad(fmt, "''#0*x", DecimalFormat::kPadBeforeSuffix,
   1578               3, (UChar)0x0078 /*x*/);
   1579     expectPad(fmt, "'I''ll'*a###.##", DecimalFormat::kPadAfterPrefix,
   1580               10, (UChar)0x0061 /*a*/);
   1581 
   1582     fmt.applyPattern("AA#,##0.00ZZ", status);
   1583     CHECK(status, "applyPattern");
   1584     fmt.setPadCharacter(hat);
   1585 
   1586     fmt.setFormatWidth(10);
   1587 
   1588     fmt.setPadPosition(DecimalFormat::kPadBeforePrefix);
   1589     expectPat(fmt, "*^AA#,##0.00ZZ");
   1590 
   1591     fmt.setPadPosition(DecimalFormat::kPadBeforeSuffix);
   1592     expectPat(fmt, "AA#,##0.00*^ZZ");
   1593 
   1594     fmt.setPadPosition(DecimalFormat::kPadAfterSuffix);
   1595     expectPat(fmt, "AA#,##0.00ZZ*^");
   1596 
   1597     //            12  3456789012
   1598     UnicodeString exp("AA*^#,##0.00ZZ", "");
   1599     fmt.setFormatWidth(12);
   1600     fmt.setPadPosition(DecimalFormat::kPadAfterPrefix);
   1601     expectPat(fmt, exp);
   1602 
   1603     fmt.setFormatWidth(13);
   1604     //              12  34567890123
   1605     expectPat(fmt, "AA*^##,##0.00ZZ");
   1606 
   1607     fmt.setFormatWidth(14);
   1608     //              12  345678901234
   1609     expectPat(fmt, "AA*^###,##0.00ZZ");
   1610 
   1611     fmt.setFormatWidth(15);
   1612     //              12  3456789012345
   1613     expectPat(fmt, "AA*^####,##0.00ZZ"); // This is the interesting case
   1614 
   1615     fmt.setFormatWidth(16);
   1616     //              12  34567890123456
   1617     expectPat(fmt, "AA*^#,###,##0.00ZZ");
   1618 }
   1619 
   1620 void NumberFormatTest::TestSurrogateSupport(void) {
   1621     UErrorCode status = U_ZERO_ERROR;
   1622     DecimalFormatSymbols custom(Locale::getUS(), status);
   1623     CHECK(status, "DecimalFormatSymbols constructor");
   1624 
   1625     custom.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, "decimal");
   1626     custom.setSymbol(DecimalFormatSymbols::kPlusSignSymbol, "plus");
   1627     custom.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, " minus ");
   1628     custom.setSymbol(DecimalFormatSymbols::kExponentialSymbol, "exponent");
   1629 
   1630     UnicodeString patternStr("*\\U00010000##.##", "");
   1631     patternStr = patternStr.unescape();
   1632     UnicodeString expStr("\\U00010000\\U00010000\\U00010000\\U000100000", "");
   1633     expStr = expStr.unescape();
   1634     expect2(new DecimalFormat(patternStr, custom, status),
   1635            int32_t(0), expStr, status);
   1636 
   1637     status = U_ZERO_ERROR;
   1638     expect2(new DecimalFormat("*^##.##", custom, status),
   1639            int32_t(0), "^^^^0", status);
   1640     status = U_ZERO_ERROR;
   1641     expect2(new DecimalFormat("##.##", custom, status),
   1642            -1.3, " minus 1decimal3", status);
   1643     status = U_ZERO_ERROR;
   1644     expect2(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status),
   1645            int32_t(0), "0decimal0exponent0 g-m/s^2", status);
   1646     status = U_ZERO_ERROR;
   1647     expect(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status),
   1648            1.0/3, "333decimal333exponent minus 3 g-m/s^2", status);
   1649     status = U_ZERO_ERROR;
   1650     expect2(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status),
   1651            int32_t(0), "0decimal0 g-m/s^2", status);
   1652     status = U_ZERO_ERROR;
   1653     expect(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status),
   1654            1.0/3, "0decimal33333 g-m/s^2", status);
   1655 
   1656     UnicodeString zero((UChar32)0x10000);
   1657     UnicodeString one((UChar32)0x10001);
   1658     UnicodeString two((UChar32)0x10002);
   1659     UnicodeString five((UChar32)0x10005);
   1660     custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, zero);
   1661     custom.setSymbol(DecimalFormatSymbols::kOneDigitSymbol, one);
   1662     custom.setSymbol(DecimalFormatSymbols::kTwoDigitSymbol, two);
   1663     custom.setSymbol(DecimalFormatSymbols::kFiveDigitSymbol, five);
   1664     expStr = UnicodeString("\\U00010001decimal\\U00010002\\U00010005\\U00010000", "");
   1665     expStr = expStr.unescape();
   1666     status = U_ZERO_ERROR;
   1667     expect2(new DecimalFormat("##0.000", custom, status),
   1668            1.25, expStr, status);
   1669 
   1670     custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, (UChar)0x30);
   1671     custom.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "units of money");
   1672     custom.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, "money separator");
   1673     patternStr = UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'");
   1674     patternStr = patternStr.unescape();
   1675     expStr = UnicodeString(" minus 20money separator00 units of money in your bank account", "");
   1676     status = U_ZERO_ERROR;
   1677     expect2(new DecimalFormat(patternStr, custom, status),
   1678            int32_t(-20), expStr, status);
   1679 
   1680     custom.setSymbol(DecimalFormatSymbols::kPercentSymbol, "percent");
   1681     patternStr = "'You''ve lost ' -0.00 %' of your money today'";
   1682     patternStr = patternStr.unescape();
   1683     expStr = UnicodeString(" minus You've lost   minus 2000decimal00 percent of your money today", "");
   1684     status = U_ZERO_ERROR;
   1685     expect2(new DecimalFormat(patternStr, custom, status),
   1686            int32_t(-20), expStr, status);
   1687 }
   1688 
   1689 void NumberFormatTest::TestCurrencyPatterns(void) {
   1690     int32_t i, locCount;
   1691     const Locale* locs = NumberFormat::getAvailableLocales(locCount);
   1692     for (i=0; i<locCount; ++i) {
   1693         UErrorCode ec = U_ZERO_ERROR;
   1694         NumberFormat* nf = NumberFormat::createCurrencyInstance(locs[i], ec);
   1695         if (U_FAILURE(ec)) {
   1696             errln("FAIL: Can't create NumberFormat(%s) - %s", locs[i].getName(), u_errorName(ec));
   1697         } else {
   1698             // Make sure currency formats do not have a variable number
   1699             // of fraction digits
   1700             int32_t min = nf->getMinimumFractionDigits();
   1701             int32_t max = nf->getMaximumFractionDigits();
   1702             if (min != max) {
   1703                 UnicodeString a, b;
   1704                 nf->format(1.0, a);
   1705                 nf->format(1.125, b);
   1706                 errln((UnicodeString)"FAIL: " + locs[i].getName() +
   1707                       " min fraction digits != max fraction digits; "
   1708                       "x 1.0 => " + escape(a) +
   1709                       "; x 1.125 => " + escape(b));
   1710             }
   1711 
   1712             // Make sure EURO currency formats have exactly 2 fraction digits
   1713             DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
   1714             if (df != NULL) {
   1715                 if (u_strcmp(EUR, df->getCurrency()) == 0) {
   1716                     if (min != 2 || max != 2) {
   1717                         UnicodeString a;
   1718                         nf->format(1.0, a);
   1719                         errln((UnicodeString)"FAIL: " + locs[i].getName() +
   1720                               " is a EURO format but it does not have 2 fraction digits; "
   1721                               "x 1.0 => " +
   1722                               escape(a));
   1723                     }
   1724                 }
   1725             }
   1726         }
   1727         delete nf;
   1728     }
   1729 }
   1730 
   1731 void NumberFormatTest::TestRegCurrency(void) {
   1732 #if !UCONFIG_NO_SERVICE
   1733     UErrorCode status = U_ZERO_ERROR;
   1734     UChar USD[4];
   1735     ucurr_forLocale("en_US", USD, 4, &status);
   1736     UChar YEN[4];
   1737     ucurr_forLocale("ja_JP", YEN, 4, &status);
   1738     UChar TMP[4];
   1739     static const UChar QQQ[] = {0x51, 0x51, 0x51, 0};
   1740     if(U_FAILURE(status)) {
   1741         errcheckln(status, "Unable to get currency for locale, error %s", u_errorName(status));
   1742         return;
   1743     }
   1744 
   1745     UCurrRegistryKey enkey = ucurr_register(YEN, "en_US", &status);
   1746     UCurrRegistryKey enUSEUROkey = ucurr_register(QQQ, "en_US_EURO", &status);
   1747 
   1748     ucurr_forLocale("en_US", TMP, 4, &status);
   1749     if (u_strcmp(YEN, TMP) != 0) {
   1750         errln("FAIL: didn't return YEN registered for en_US");
   1751     }
   1752 
   1753     ucurr_forLocale("en_US_EURO", TMP, 4, &status);
   1754     if (u_strcmp(QQQ, TMP) != 0) {
   1755         errln("FAIL: didn't return QQQ for en_US_EURO");
   1756     }
   1757 
   1758     int32_t fallbackLen = ucurr_forLocale("en_XX_BAR", TMP, 4, &status);
   1759     if (fallbackLen) {
   1760         errln("FAIL: tried to fallback en_XX_BAR");
   1761     }
   1762     status = U_ZERO_ERROR; // reset
   1763 
   1764     if (!ucurr_unregister(enkey, &status)) {
   1765         errln("FAIL: couldn't unregister enkey");
   1766     }
   1767 
   1768     ucurr_forLocale("en_US", TMP, 4, &status);
   1769     if (u_strcmp(USD, TMP) != 0) {
   1770         errln("FAIL: didn't return USD for en_US after unregister of en_US");
   1771     }
   1772     status = U_ZERO_ERROR; // reset
   1773 
   1774     ucurr_forLocale("en_US_EURO", TMP, 4, &status);
   1775     if (u_strcmp(QQQ, TMP) != 0) {
   1776         errln("FAIL: didn't return QQQ for en_US_EURO after unregister of en_US");
   1777     }
   1778 
   1779     ucurr_forLocale("en_US_BLAH", TMP, 4, &status);
   1780     if (u_strcmp(USD, TMP) != 0) {
   1781         errln("FAIL: could not find USD for en_US_BLAH after unregister of en");
   1782     }
   1783     status = U_ZERO_ERROR; // reset
   1784 
   1785     if (!ucurr_unregister(enUSEUROkey, &status)) {
   1786         errln("FAIL: couldn't unregister enUSEUROkey");
   1787     }
   1788 
   1789     ucurr_forLocale("en_US_EURO", TMP, 4, &status);
   1790     if (u_strcmp(EUR, TMP) != 0) {
   1791         errln("FAIL: didn't return EUR for en_US_EURO after unregister of en_US_EURO");
   1792     }
   1793     status = U_ZERO_ERROR; // reset
   1794 #endif
   1795 }
   1796 
   1797 void NumberFormatTest::TestCurrencyNames(void) {
   1798     // Do a basic check of getName()
   1799     // USD { "US$", "US Dollar"            } // 04/04/1792-
   1800     UErrorCode ec = U_ZERO_ERROR;
   1801     static const UChar USD[] = {0x55, 0x53, 0x44, 0}; /*USD*/
   1802     static const UChar USX[] = {0x55, 0x53, 0x58, 0}; /*USX*/
   1803     static const UChar CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
   1804     static const UChar ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
   1805     UBool isChoiceFormat;
   1806     int32_t len;
   1807     const UBool possibleDataError = TRUE;
   1808     // Warning: HARD-CODED LOCALE DATA in this test.  If it fails, CHECK
   1809     // THE LOCALE DATA before diving into the code.
   1810     assertEquals("USD.getName(SYMBOL_NAME)",
   1811                  UnicodeString("$"),
   1812                  UnicodeString(ucurr_getName(USD, "en",
   1813                                              UCURR_SYMBOL_NAME,
   1814                                              &isChoiceFormat, &len, &ec)),
   1815                                              possibleDataError);
   1816     assertEquals("USD.getName(LONG_NAME)",
   1817                  UnicodeString("US Dollar"),
   1818                  UnicodeString(ucurr_getName(USD, "en",
   1819                                              UCURR_LONG_NAME,
   1820                                              &isChoiceFormat, &len, &ec)),
   1821                                              possibleDataError);
   1822     assertEquals("CAD.getName(SYMBOL_NAME)",
   1823                  UnicodeString("CA$"),
   1824                  UnicodeString(ucurr_getName(CAD, "en",
   1825                                              UCURR_SYMBOL_NAME,
   1826                                              &isChoiceFormat, &len, &ec)),
   1827                                              possibleDataError);
   1828     assertEquals("CAD.getName(SYMBOL_NAME)",
   1829                  UnicodeString("$"),
   1830                  UnicodeString(ucurr_getName(CAD, "en_CA",
   1831                                              UCURR_SYMBOL_NAME,
   1832                                              &isChoiceFormat, &len, &ec)),
   1833                                              possibleDataError);
   1834     assertEquals("USD.getName(SYMBOL_NAME) in en_AU",
   1835                  UnicodeString("US$"),
   1836                  UnicodeString(ucurr_getName(USD, "en_AU",
   1837                                              UCURR_SYMBOL_NAME,
   1838                                              &isChoiceFormat, &len, &ec)),
   1839                                              possibleDataError);
   1840     assertEquals("CAD.getName(SYMBOL_NAME)",
   1841                  UnicodeString("CA$"),
   1842                  UnicodeString(ucurr_getName(CAD, "en_AU",
   1843                                              UCURR_SYMBOL_NAME,
   1844                                              &isChoiceFormat, &len, &ec)),
   1845                                              possibleDataError);
   1846     assertEquals("USX.getName(LONG_NAME)",
   1847                  UnicodeString("USX"),
   1848                  UnicodeString(ucurr_getName(USX, "en_US",
   1849                                              UCURR_LONG_NAME,
   1850                                              &isChoiceFormat, &len, &ec)),
   1851                                              possibleDataError);
   1852     assertSuccess("ucurr_getName", ec);
   1853 
   1854     ec = U_ZERO_ERROR;
   1855 
   1856     // Test that a default or fallback warning is being returned. JB 4239.
   1857     ucurr_getName(CAD, "es_ES", UCURR_LONG_NAME, &isChoiceFormat,
   1858                             &len, &ec);
   1859     assertTrue("ucurr_getName (es_ES fallback)",
   1860                     U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError);
   1861 
   1862     ucurr_getName(CAD, "zh_TW", UCURR_LONG_NAME, &isChoiceFormat,
   1863                             &len, &ec);
   1864     assertTrue("ucurr_getName (zh_TW fallback)",
   1865                     U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError);
   1866 
   1867     ucurr_getName(CAD, "en_US", UCURR_LONG_NAME, &isChoiceFormat,
   1868                             &len, &ec);
   1869     assertTrue("ucurr_getName (en_US default)",
   1870                     U_USING_DEFAULT_WARNING == ec || U_USING_FALLBACK_WARNING == ec, TRUE);
   1871 
   1872     ucurr_getName(CAD, "ti", UCURR_LONG_NAME, &isChoiceFormat,
   1873                             &len, &ec);
   1874     assertTrue("ucurr_getName (ti default)",
   1875                     U_USING_DEFAULT_WARNING == ec, TRUE);
   1876 
   1877     // Test that a default warning is being returned when falling back to root. JB 4536.
   1878     ucurr_getName(ITL, "cy", UCURR_LONG_NAME, &isChoiceFormat,
   1879                             &len, &ec);
   1880     assertTrue("ucurr_getName (cy default to root)",
   1881                     U_USING_DEFAULT_WARNING == ec, TRUE);
   1882 
   1883     // TODO add more tests later
   1884 }
   1885 
   1886 void NumberFormatTest::TestCurrencyUnit(void){
   1887     UErrorCode ec = U_ZERO_ERROR;
   1888     static const UChar USD[] = {85, 83, 68, 0}; /*USD*/
   1889     CurrencyUnit cu(USD, ec);
   1890     assertSuccess("CurrencyUnit", ec);
   1891 
   1892     const UChar * r = cu.getISOCurrency(); // who is the buffer owner ?
   1893     assertEquals("getISOCurrency()", USD, r);
   1894 
   1895     CurrencyUnit cu2(cu);
   1896     if (!(cu2 == cu)){
   1897         errln("CurrencyUnit copy constructed object should be same");
   1898     }
   1899 
   1900     CurrencyUnit * cu3 = (CurrencyUnit *)cu.clone();
   1901     if (!(*cu3 == cu)){
   1902         errln("CurrencyUnit cloned object should be same");
   1903     }
   1904     delete cu3;
   1905 }
   1906 
   1907 void NumberFormatTest::TestCurrencyAmount(void){
   1908     UErrorCode ec = U_ZERO_ERROR;
   1909     static const UChar USD[] = {85, 83, 68, 0}; /*USD*/
   1910     CurrencyAmount ca(9, USD, ec);
   1911     assertSuccess("CurrencyAmount", ec);
   1912 
   1913     CurrencyAmount ca2(ca);
   1914     if (!(ca2 == ca)){
   1915         errln("CurrencyAmount copy constructed object should be same");
   1916     }
   1917 
   1918     ca2=ca;
   1919     if (!(ca2 == ca)){
   1920         errln("CurrencyAmount assigned object should be same");
   1921     }
   1922 
   1923     CurrencyAmount *ca3 = (CurrencyAmount *)ca.clone();
   1924     if (!(*ca3 == ca)){
   1925         errln("CurrencyAmount cloned object should be same");
   1926     }
   1927     delete ca3;
   1928 }
   1929 
   1930 void NumberFormatTest::TestSymbolsWithBadLocale(void) {
   1931     Locale locDefault;
   1932     static const char *badLocales[] = {
   1933         // length < ULOC_FULLNAME_CAPACITY
   1934         "x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME",
   1935 
   1936         // length > ULOC_FULLNAME_CAPACITY
   1937         "x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME"
   1938     }; // expect U_USING_DEFAULT_WARNING for both
   1939 
   1940     unsigned int i;
   1941     for (i = 0; i < sizeof(badLocales) / sizeof(char*); i++) {
   1942         const char *localeName = badLocales[i];
   1943         Locale locBad(localeName);
   1944         UErrorCode status = U_ZERO_ERROR;
   1945         UnicodeString intlCurrencySymbol((UChar)0xa4);
   1946 
   1947         intlCurrencySymbol.append((UChar)0xa4);
   1948 
   1949         logln("Current locale is %s", Locale::getDefault().getName());
   1950         Locale::setDefault(locBad, status);
   1951         logln("Current locale is %s", Locale::getDefault().getName());
   1952         DecimalFormatSymbols mySymbols(status);
   1953         if (status != U_USING_DEFAULT_WARNING) {
   1954             errln("DecimalFormatSymbols should return U_USING_DEFAULT_WARNING.");
   1955         }
   1956         if (strcmp(mySymbols.getLocale().getName(), locBad.getName()) != 0) {
   1957             errln("DecimalFormatSymbols does not have the right locale.", locBad.getName());
   1958         }
   1959         int symbolEnum = (int)DecimalFormatSymbols::kDecimalSeparatorSymbol;
   1960         for (; symbolEnum < (int)DecimalFormatSymbols::kFormatSymbolCount; symbolEnum++) {
   1961             UnicodeString symbolString = mySymbols.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbolEnum);
   1962             logln(UnicodeString("DecimalFormatSymbols[") + symbolEnum + UnicodeString("] = ") + prettify(symbolString));
   1963             if (symbolString.length() == 0
   1964                 && symbolEnum != (int)DecimalFormatSymbols::kGroupingSeparatorSymbol
   1965                 && symbolEnum != (int)DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol)
   1966             {
   1967                 errln("DecimalFormatSymbols has an empty string at index %d.", symbolEnum);
   1968             }
   1969         }
   1970 
   1971         status = U_ZERO_ERROR;
   1972         Locale::setDefault(locDefault, status);
   1973         logln("Current locale is %s", Locale::getDefault().getName());
   1974     }
   1975 }
   1976 
   1977 /**
   1978  * Check that adoptDecimalFormatSymbols and setDecimalFormatSymbols
   1979  * behave the same, except for memory ownership semantics. (No
   1980  * version of this test on Java, since Java has only one method.)
   1981  */
   1982 void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
   1983     UErrorCode ec = U_ZERO_ERROR;
   1984     DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), ec);
   1985     if (U_FAILURE(ec)) {
   1986         errcheckln(ec, "Fail: DecimalFormatSymbols constructor - %s", u_errorName(ec));
   1987         delete sym;
   1988         return;
   1989     }
   1990     UnicodeString pat(" #,##0.00");
   1991     pat.insert(0, (UChar)0x00A4);
   1992     DecimalFormat fmt(pat, sym, ec);
   1993     if (U_FAILURE(ec)) {
   1994         errln("Fail: DecimalFormat constructor");
   1995         return;
   1996     }
   1997 
   1998     UnicodeString str;
   1999     fmt.format(2350.75, str);
   2000     if (str == "$ 2,350.75") {
   2001         logln(str);
   2002     } else {
   2003         dataerrln("Fail: " + str + ", expected $ 2,350.75");
   2004     }
   2005 
   2006     sym = new DecimalFormatSymbols(Locale::getUS(), ec);
   2007     if (U_FAILURE(ec)) {
   2008         errln("Fail: DecimalFormatSymbols constructor");
   2009         delete sym;
   2010         return;
   2011     }
   2012     sym->setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q");
   2013     fmt.adoptDecimalFormatSymbols(sym);
   2014 
   2015     str.truncate(0);
   2016     fmt.format(2350.75, str);
   2017     if (str == "Q 2,350.75") {
   2018         logln(str);
   2019     } else {
   2020         dataerrln("Fail: adoptDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
   2021     }
   2022 
   2023     sym = new DecimalFormatSymbols(Locale::getUS(), ec);
   2024     if (U_FAILURE(ec)) {
   2025         errln("Fail: DecimalFormatSymbols constructor");
   2026         delete sym;
   2027         return;
   2028     }
   2029     DecimalFormat fmt2(pat, sym, ec);
   2030     if (U_FAILURE(ec)) {
   2031         errln("Fail: DecimalFormat constructor");
   2032         return;
   2033     }
   2034 
   2035     DecimalFormatSymbols sym2(Locale::getUS(), ec);
   2036     if (U_FAILURE(ec)) {
   2037         errln("Fail: DecimalFormatSymbols constructor");
   2038         return;
   2039     }
   2040     sym2.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q");
   2041     fmt2.setDecimalFormatSymbols(sym2);
   2042 
   2043     str.truncate(0);
   2044     fmt2.format(2350.75, str);
   2045     if (str == "Q 2,350.75") {
   2046         logln(str);
   2047     } else {
   2048         dataerrln("Fail: setDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
   2049     }
   2050 }
   2051 
   2052 void NumberFormatTest::TestPerMill() {
   2053     UErrorCode ec = U_ZERO_ERROR;
   2054     UnicodeString str;
   2055     DecimalFormat fmt(ctou("###.###\\u2030"), ec);
   2056     if (!assertSuccess("DecimalFormat ct", ec)) return;
   2057     assertEquals("0.4857 x ###.###\\u2030",
   2058                  ctou("485.7\\u2030"), fmt.format(0.4857, str));
   2059 
   2060     DecimalFormatSymbols sym(Locale::getUS(), ec);
   2061     sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, ctou("m"));
   2062     DecimalFormat fmt2("", sym, ec);
   2063     fmt2.applyLocalizedPattern("###.###m", ec);
   2064     if (!assertSuccess("setup", ec)) return;
   2065     str.truncate(0);
   2066     assertEquals("0.4857 x ###.###m",
   2067                  "485.7m", fmt2.format(0.4857, str));
   2068 }
   2069 
   2070 /**
   2071  * Generic test for patterns that should be legal/illegal.
   2072  */
   2073 void NumberFormatTest::TestIllegalPatterns() {
   2074     // Test cases:
   2075     // Prefix with "-:" for illegal patterns
   2076     // Prefix with "+:" for legal patterns
   2077     const char* DATA[] = {
   2078         // Unquoted special characters in the suffix are illegal
   2079         "-:000.000|###",
   2080         "+:000.000'|###'",
   2081         0
   2082     };
   2083     for (int32_t i=0; DATA[i]; ++i) {
   2084         const char* pat=DATA[i];
   2085         UBool valid = (*pat) == '+';
   2086         pat += 2;
   2087         UErrorCode ec = U_ZERO_ERROR;
   2088         DecimalFormat fmt(pat, ec); // locale doesn't matter here
   2089         if (U_SUCCESS(ec) == valid) {
   2090             logln("Ok: pattern \"%s\": %s",
   2091                   pat, u_errorName(ec));
   2092         } else {
   2093             errcheckln(ec, "FAIL: pattern \"%s\" should have %s; got %s",
   2094                   pat, (valid?"succeeded":"failed"),
   2095                   u_errorName(ec));
   2096         }
   2097     }
   2098 }
   2099 
   2100 //----------------------------------------------------------------------
   2101 
   2102 static const char* KEYWORDS[] = {
   2103     /*0*/ "ref=", // <reference pattern to parse numbers>
   2104     /*1*/ "loc=", // <locale for formats>
   2105     /*2*/ "f:",   // <pattern or '-'> <number> <exp. string>
   2106     /*3*/ "fp:",  // <pattern or '-'> <number> <exp. string> <exp. number>
   2107     /*4*/ "rt:",  // <pattern or '-'> <(exp.) number> <(exp.) string>
   2108     /*5*/ "p:",   // <pattern or '-'> <string> <exp. number>
   2109     /*6*/ "perr:", // <pattern or '-'> <invalid string>
   2110     /*7*/ "pat:", // <pattern or '-'> <exp. toPattern or '-' or 'err'>
   2111     /*8*/ "fpc:", // <pattern or '-'> <curr.amt> <exp. string> <exp. curr.amt>
   2112     0
   2113 };
   2114 
   2115 /**
   2116  * Return an integer representing the next token from this
   2117  * iterator.  The integer will be an index into the given list, or
   2118  * -1 if there are no more tokens, or -2 if the token is not on
   2119  * the list.
   2120  */
   2121 static int32_t keywordIndex(const UnicodeString& tok) {
   2122     for (int32_t i=0; KEYWORDS[i]!=0; ++i) {
   2123         if (tok==KEYWORDS[i]) {
   2124             return i;
   2125         }
   2126     }
   2127     return -1;
   2128 }
   2129 
   2130 /**
   2131  * Parse a CurrencyAmount using the given NumberFormat, with
   2132  * the 'delim' character separating the number and the currency.
   2133  */
   2134 static void parseCurrencyAmount(const UnicodeString& str,
   2135                                 const NumberFormat& fmt,
   2136                                 UChar delim,
   2137                                 Formattable& result,
   2138                                 UErrorCode& ec) {
   2139     UnicodeString num, cur;
   2140     int32_t i = str.indexOf(delim);
   2141     str.extractBetween(0, i, num);
   2142     str.extractBetween(i+1, INT32_MAX, cur);
   2143     Formattable n;
   2144     fmt.parse(num, n, ec);
   2145     result.adoptObject(new CurrencyAmount(n, cur.getTerminatedBuffer(), ec));
   2146 }
   2147 
   2148 void NumberFormatTest::TestCases() {
   2149     UErrorCode ec = U_ZERO_ERROR;
   2150     TextFile reader("NumberFormatTestCases.txt", "UTF8", ec);
   2151     if (U_FAILURE(ec)) {
   2152         dataerrln("Couldn't open NumberFormatTestCases.txt");
   2153         return;
   2154     }
   2155     TokenIterator tokens(&reader);
   2156 
   2157     Locale loc("en", "US", "");
   2158     DecimalFormat *ref = 0, *fmt = 0;
   2159     MeasureFormat *mfmt = 0;
   2160     UnicodeString pat, tok, mloc, str, out, where, currAmt;
   2161     Formattable n;
   2162 
   2163     for (;;) {
   2164         ec = U_ZERO_ERROR;
   2165         if (!tokens.next(tok, ec)) {
   2166             break;
   2167         }
   2168         where = UnicodeString("(") + tokens.getLineNumber() + ") ";
   2169         int32_t cmd = keywordIndex(tok);
   2170         switch (cmd) {
   2171         case 0:
   2172             // ref= <reference pattern>
   2173             if (!tokens.next(tok, ec)) goto error;
   2174             delete ref;
   2175             ref = new DecimalFormat(tok,
   2176                       new DecimalFormatSymbols(Locale::getUS(), ec), ec);
   2177             if (U_FAILURE(ec)) {
   2178                 dataerrln("Error constructing DecimalFormat");
   2179                 goto error;
   2180             }
   2181             break;
   2182         case 1:
   2183             // loc= <locale>
   2184             if (!tokens.next(tok, ec)) goto error;
   2185             loc = Locale::createFromName(CharString().appendInvariantChars(tok, ec).data());
   2186             break;
   2187         case 2: // f:
   2188         case 3: // fp:
   2189         case 4: // rt:
   2190         case 5: // p:
   2191             if (!tokens.next(tok, ec)) goto error;
   2192             if (tok != "-") {
   2193                 pat = tok;
   2194                 delete fmt;
   2195                 fmt = new DecimalFormat(pat, new DecimalFormatSymbols(loc, ec), ec);
   2196                 if (U_FAILURE(ec)) {
   2197                     errln("FAIL: " + where + "Pattern \"" + pat + "\": " + u_errorName(ec));
   2198                     ec = U_ZERO_ERROR;
   2199                     if (!tokens.next(tok, ec)) goto error;
   2200                     if (!tokens.next(tok, ec)) goto error;
   2201                     if (cmd == 3) {
   2202                         if (!tokens.next(tok, ec)) goto error;
   2203                     }
   2204                     continue;
   2205                 }
   2206             }
   2207             if (cmd == 2 || cmd == 3 || cmd == 4) {
   2208                 // f: <pattern or '-'> <number> <exp. string>
   2209                 // fp: <pattern or '-'> <number> <exp. string> <exp. number>
   2210                 // rt: <pattern or '-'> <number> <string>
   2211                 UnicodeString num;
   2212                 if (!tokens.next(num, ec)) goto error;
   2213                 if (!tokens.next(str, ec)) goto error;
   2214                 ref->parse(num, n, ec);
   2215                 assertSuccess("parse", ec);
   2216                 assertEquals(where + "\"" + pat + "\".format(" + num + ")",
   2217                              str, fmt->format(n, out.remove(), ec));
   2218                 assertSuccess("format", ec);
   2219                 if (cmd == 3) { // fp:
   2220                     if (!tokens.next(num, ec)) goto error;
   2221                     ref->parse(num, n, ec);
   2222                     assertSuccess("parse", ec);
   2223                 }
   2224                 if (cmd != 2) { // != f:
   2225                     Formattable m;
   2226                     fmt->parse(str, m, ec);
   2227                     assertSuccess("parse", ec);
   2228                     assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")",
   2229                                  n, m);
   2230                 }
   2231             }
   2232             // p: <pattern or '-'> <string to parse> <exp. number>
   2233             else {
   2234                 UnicodeString expstr;
   2235                 if (!tokens.next(str, ec)) goto error;
   2236                 if (!tokens.next(expstr, ec)) goto error;
   2237                 Formattable exp, n;
   2238                 ref->parse(expstr, exp, ec);
   2239                 assertSuccess("parse", ec);
   2240                 fmt->parse(str, n, ec);
   2241                 assertSuccess("parse", ec);
   2242                 assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")",
   2243                              exp, n);
   2244             }
   2245             break;
   2246         case 8: // fpc:
   2247             if (!tokens.next(tok, ec)) goto error;
   2248             if (tok != "-") {
   2249                 mloc = tok;
   2250                 delete mfmt;
   2251                 mfmt = MeasureFormat::createCurrencyFormat(
   2252                     Locale::createFromName(
   2253                         CharString().appendInvariantChars(mloc, ec).data()), ec);
   2254                 if (U_FAILURE(ec)) {
   2255                     errln("FAIL: " + where + "Loc \"" + mloc + "\": " + u_errorName(ec));
   2256                     ec = U_ZERO_ERROR;
   2257                     if (!tokens.next(tok, ec)) goto error;
   2258                     if (!tokens.next(tok, ec)) goto error;
   2259                     if (!tokens.next(tok, ec)) goto error;
   2260                     continue;
   2261                 }
   2262             }
   2263             // fpc: <loc or '-'> <curr.amt> <exp. string> <exp. curr.amt>
   2264             if (!tokens.next(currAmt, ec)) goto error;
   2265             if (!tokens.next(str, ec)) goto error;
   2266             parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec);
   2267             if (assertSuccess("parseCurrencyAmount", ec)) {
   2268                 assertEquals(where + "getCurrencyFormat(" + mloc + ").format(" + currAmt + ")",
   2269                              str, mfmt->format(n, out.remove(), ec));
   2270                 assertSuccess("format", ec);
   2271             }
   2272             if (!tokens.next(currAmt, ec)) goto error;
   2273             parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec);
   2274             if (assertSuccess("parseCurrencyAmount", ec)) {
   2275                 Formattable m;
   2276 
   2277                 mfmt->parseObject(str, m, ec);
   2278                 if (assertSuccess("parseCurrency", ec)) {
   2279                     assertEquals(where + "getCurrencyFormat(" + mloc + ").parse(\"" + str + "\")",
   2280                                  n, m);
   2281                 } else {
   2282                     errln("FAIL: source " + str);
   2283                 }
   2284             }
   2285             break;
   2286         case 6:
   2287             // perr: <pattern or '-'> <invalid string>
   2288             errln("FAIL: Under construction");
   2289             goto done;
   2290         case 7: {
   2291             // pat: <pattern> <exp. toPattern, or '-' or 'err'>
   2292             UnicodeString testpat;
   2293             UnicodeString exppat;
   2294             if (!tokens.next(testpat, ec)) goto error;
   2295             if (!tokens.next(exppat, ec)) goto error;
   2296             UBool err = exppat == "err";
   2297             UBool existingPat = FALSE;
   2298             if (testpat == "-") {
   2299                 if (err) {
   2300                     errln("FAIL: " + where + "Invalid command \"pat: - err\"");
   2301                     continue;
   2302                 }
   2303                 existingPat = TRUE;
   2304                 testpat = pat;
   2305             }
   2306             if (exppat == "-") exppat = testpat;
   2307             DecimalFormat* f = 0;
   2308             UErrorCode ec2 = U_ZERO_ERROR;
   2309             if (existingPat) {
   2310                 f = fmt;
   2311             } else {
   2312                 f = new DecimalFormat(testpat, ec2);
   2313             }
   2314             if (U_SUCCESS(ec2)) {
   2315                 if (err) {
   2316                     errln("FAIL: " + where + "Invalid pattern \"" + testpat +
   2317                           "\" was accepted");
   2318                 } else {
   2319                     UnicodeString pat2;
   2320                     assertEquals(where + "\"" + testpat + "\".toPattern()",
   2321                                  exppat, f->toPattern(pat2));
   2322                 }
   2323             } else {
   2324                 if (err) {
   2325                     logln("Ok: " + where + "Invalid pattern \"" + testpat +
   2326                           "\" failed: " + u_errorName(ec2));
   2327                 } else {
   2328                     errln("FAIL: " + where + "Valid pattern \"" + testpat +
   2329                           "\" failed: " + u_errorName(ec2));
   2330                 }
   2331             }
   2332             if (!existingPat) delete f;
   2333             } break;
   2334         case -1:
   2335             errln("FAIL: " + where + "Unknown command \"" + tok + "\"");
   2336             goto done;
   2337         }
   2338     }
   2339     goto done;
   2340 
   2341  error:
   2342     if (U_SUCCESS(ec)) {
   2343         errln("FAIL: Unexpected EOF");
   2344     } else {
   2345         errcheckln(ec, "FAIL: " + where + "Unexpected " + u_errorName(ec));
   2346     }
   2347 
   2348  done:
   2349     delete mfmt;
   2350     delete fmt;
   2351     delete ref;
   2352 }
   2353 
   2354 
   2355 //----------------------------------------------------------------------
   2356 // Support methods
   2357 //----------------------------------------------------------------------
   2358 
   2359 UBool NumberFormatTest::equalValue(const Formattable& a, const Formattable& b) {
   2360     if (a.getType() == b.getType()) {
   2361         return a == b;
   2362     }
   2363 
   2364     if (a.getType() == Formattable::kLong) {
   2365         if (b.getType() == Formattable::kInt64) {
   2366             return a.getLong() == b.getLong();
   2367         } else if (b.getType() == Formattable::kDouble) {
   2368             return (double) a.getLong() == b.getDouble(); // TODO check use of double instead of long
   2369         }
   2370     } else if (a.getType() == Formattable::kDouble) {
   2371         if (b.getType() == Formattable::kLong) {
   2372             return a.getDouble() == (double) b.getLong();
   2373         } else if (b.getType() == Formattable::kInt64) {
   2374             return a.getDouble() == (double)b.getInt64();
   2375         }
   2376     } else if (a.getType() == Formattable::kInt64) {
   2377         if (b.getType() == Formattable::kLong) {
   2378                 return a.getInt64() == (int64_t)b.getLong();
   2379         } else if (b.getType() == Formattable::kDouble) {
   2380             return a.getInt64() == (int64_t)b.getDouble();
   2381         }
   2382     }
   2383     return FALSE;
   2384 }
   2385 
   2386 void NumberFormatTest::expect3(NumberFormat& fmt, const Formattable& n, const UnicodeString& str) {
   2387     // Don't round-trip format test, since we explicitly do it
   2388     expect_rbnf(fmt, n, str, FALSE);
   2389     expect_rbnf(fmt, str, n);
   2390 }
   2391 
   2392 void NumberFormatTest::expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str) {
   2393     // Don't round-trip format test, since we explicitly do it
   2394     expect(fmt, n, str, FALSE);
   2395     expect(fmt, str, n);
   2396 }
   2397 
   2398 void NumberFormatTest::expect2(NumberFormat* fmt, const Formattable& n,
   2399                                const UnicodeString& exp,
   2400                                UErrorCode status) {
   2401     if (fmt == NULL || U_FAILURE(status)) {
   2402         dataerrln("FAIL: NumberFormat constructor");
   2403     } else {
   2404         expect2(*fmt, n, exp);
   2405     }
   2406     delete fmt;
   2407 }
   2408 
   2409 void NumberFormatTest::expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) {
   2410     UErrorCode status = U_ZERO_ERROR;
   2411     Formattable num;
   2412     fmt.parse(str, num, status);
   2413     if (U_FAILURE(status)) {
   2414         dataerrln(UnicodeString("FAIL: Parse failed for \"") + str + "\" - " + u_errorName(status));
   2415         return;
   2416     }
   2417     UnicodeString pat;
   2418     ((DecimalFormat*) &fmt)->toPattern(pat);
   2419     if (equalValue(num, n)) {
   2420         logln(UnicodeString("Ok   \"") + str + "\" x " +
   2421               pat + " = " +
   2422               toString(num));
   2423     } else {
   2424         dataerrln(UnicodeString("FAIL \"") + str + "\" x " +
   2425               pat + " = " +
   2426               toString(num) + ", expected " + toString(n));
   2427     }
   2428 }
   2429 
   2430 void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) {
   2431     UErrorCode status = U_ZERO_ERROR;
   2432     Formattable num;
   2433     fmt.parse(str, num, status);
   2434     if (U_FAILURE(status)) {
   2435         errln(UnicodeString("FAIL: Parse failed for \"") + str + "\"");
   2436         return;
   2437     }
   2438     if (equalValue(num, n)) {
   2439         logln(UnicodeString("Ok   \"") + str + " = " +
   2440               toString(num));
   2441     } else {
   2442         errln(UnicodeString("FAIL \"") + str + " = " +
   2443               toString(num) + ", expected " + toString(n));
   2444     }
   2445 }
   2446 
   2447 void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const Formattable& n,
   2448                               const UnicodeString& exp, UBool rt) {
   2449     UnicodeString saw;
   2450     FieldPosition pos;
   2451     UErrorCode status = U_ZERO_ERROR;
   2452     fmt.format(n, saw, pos, status);
   2453     CHECK(status, "NumberFormat::format");
   2454     if (saw == exp) {
   2455         logln(UnicodeString("Ok   ") + toString(n) +
   2456               " = \"" +
   2457               escape(saw) + "\"");
   2458         // We should be able to round-trip the formatted string =>
   2459         // number => string (but not the other way around: number
   2460         // => string => number2, might have number2 != number):
   2461         if (rt) {
   2462             Formattable n2;
   2463             fmt.parse(exp, n2, status);
   2464             if (U_FAILURE(status)) {
   2465                 errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\"");
   2466                 return;
   2467             }
   2468             UnicodeString saw2;
   2469             fmt.format(n2, saw2, pos, status);
   2470             CHECK(status, "NumberFormat::format");
   2471             if (saw2 != exp) {
   2472                 errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) +
   2473                       " => \"" + saw2 + "\"");
   2474             }
   2475         }
   2476     } else {
   2477         errln(UnicodeString("FAIL ") + toString(n) +
   2478               " = \"" +
   2479               escape(saw) + "\", expected \"" + exp + "\"");
   2480     }
   2481 }
   2482 
   2483 void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n,
   2484                               const UnicodeString& exp, UBool rt) {
   2485     UnicodeString saw;
   2486     FieldPosition pos;
   2487     UErrorCode status = U_ZERO_ERROR;
   2488     fmt.format(n, saw, pos, status);
   2489     CHECK(status, "NumberFormat::format");
   2490     UnicodeString pat;
   2491     ((DecimalFormat*) &fmt)->toPattern(pat);
   2492     if (saw == exp) {
   2493         logln(UnicodeString("Ok   ") + toString(n) + " x " +
   2494               escape(pat) + " = \"" +
   2495               escape(saw) + "\"");
   2496         // We should be able to round-trip the formatted string =>
   2497         // number => string (but not the other way around: number
   2498         // => string => number2, might have number2 != number):
   2499         if (rt) {
   2500             Formattable n2;
   2501             fmt.parse(exp, n2, status);
   2502             if (U_FAILURE(status)) {
   2503                 errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\" - " + u_errorName(status));
   2504                 return;
   2505             }
   2506             UnicodeString saw2;
   2507             fmt.format(n2, saw2, pos, status);
   2508             CHECK(status, "NumberFormat::format");
   2509             if (saw2 != exp) {
   2510                 errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) +
   2511                       " => \"" + saw2 + "\"");
   2512             }
   2513         }
   2514     } else {
   2515         dataerrln(UnicodeString("FAIL ") + toString(n) + " x " +
   2516               escape(pat) + " = \"" +
   2517               escape(saw) + "\", expected \"" + exp + "\"");
   2518     }
   2519 }
   2520 
   2521 void NumberFormatTest::expect(NumberFormat* fmt, const Formattable& n,
   2522                               const UnicodeString& exp,
   2523                               UErrorCode status) {
   2524     if (fmt == NULL || U_FAILURE(status)) {
   2525         dataerrln("FAIL: NumberFormat constructor");
   2526     } else {
   2527         expect(*fmt, n, exp);
   2528     }
   2529     delete fmt;
   2530 }
   2531 
   2532 void NumberFormatTest::expectCurrency(NumberFormat& nf, const Locale& locale,
   2533                                       double value, const UnicodeString& string) {
   2534     UErrorCode ec = U_ZERO_ERROR;
   2535     DecimalFormat& fmt = * (DecimalFormat*) &nf;
   2536     const UChar DEFAULT_CURR[] = {45/*-*/,0};
   2537     UChar curr[4];
   2538     u_strcpy(curr, DEFAULT_CURR);
   2539     if (*locale.getLanguage() != 0) {
   2540         ucurr_forLocale(locale.getName(), curr, 4, &ec);
   2541         assertSuccess("ucurr_forLocale", ec);
   2542         fmt.setCurrency(curr, ec);
   2543         assertSuccess("DecimalFormat::setCurrency", ec);
   2544         fmt.setCurrency(curr); //Deprecated variant, for coverage only
   2545     }
   2546     UnicodeString s;
   2547     fmt.format(value, s);
   2548     s.findAndReplace((UChar32)0x00A0, (UChar32)0x0020);
   2549 
   2550     // Default display of the number yields "1234.5599999999999"
   2551     // instead of "1234.56".  Use a formatter to fix this.
   2552     NumberFormat* f =
   2553         NumberFormat::createInstance(Locale::getUS(), ec);
   2554     UnicodeString v;
   2555     if (U_FAILURE(ec)) {
   2556         // Oops; bad formatter.  Use default op+= display.
   2557         v = (UnicodeString)"" + value;
   2558     } else {
   2559         f->setMaximumFractionDigits(4);
   2560         f->setGroupingUsed(FALSE);
   2561         f->format(value, v);
   2562     }
   2563     delete f;
   2564 
   2565     if (s == string) {
   2566         logln((UnicodeString)"Ok: " + v + " x " + curr + " => " + prettify(s));
   2567     } else {
   2568         errln((UnicodeString)"FAIL: " + v + " x " + curr + " => " + prettify(s) +
   2569               ", expected " + prettify(string));
   2570     }
   2571 }
   2572 
   2573 void NumberFormatTest::expectPat(DecimalFormat& fmt, const UnicodeString& exp) {
   2574     UnicodeString pat;
   2575     fmt.toPattern(pat);
   2576     if (pat == exp) {
   2577         logln(UnicodeString("Ok   \"") + pat + "\"");
   2578     } else {
   2579         errln(UnicodeString("FAIL \"") + pat + "\", expected \"" + exp + "\"");
   2580     }
   2581 }
   2582 
   2583 void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
   2584                                  int32_t pos) {
   2585     expectPad(fmt, pat, pos, 0, (UnicodeString)"");
   2586 }
   2587 void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
   2588                                  int32_t pos, int32_t width, UChar pad) {
   2589     expectPad(fmt, pat, pos, width, UnicodeString(pad));
   2590 }
   2591 void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
   2592                                  int32_t pos, int32_t width, const UnicodeString& pad) {
   2593     int32_t apos = 0, awidth = 0;
   2594     UnicodeString apadStr;
   2595     UErrorCode status = U_ZERO_ERROR;
   2596     fmt.applyPattern(pat, status);
   2597     if (U_SUCCESS(status)) {
   2598         apos = fmt.getPadPosition();
   2599         awidth = fmt.getFormatWidth();
   2600         apadStr=fmt.getPadCharacterString();
   2601     } else {
   2602         apos = -1;
   2603         awidth = width;
   2604         apadStr = pad;
   2605     }
   2606     if (apos == pos && awidth == width && apadStr == pad) {
   2607         UnicodeString infoStr;
   2608         if (pos == ILLEGAL) {
   2609             infoStr = UnicodeString(" width=", "") + awidth + UnicodeString(" pad=", "") + apadStr;
   2610         }
   2611         logln(UnicodeString("Ok   \"") + pat + "\" pos=" + apos + infoStr);
   2612     } else {
   2613         errln(UnicodeString("FAIL \"") + pat + "\" pos=" + apos +
   2614               " width=" + awidth + " pad=" + apadStr +
   2615               ", expected " + pos + " " + width + " " + pad);
   2616     }
   2617 }
   2618 void NumberFormatTest::TestJB3832(){
   2619     const char* localeID = "pt_PT@currency=PTE";
   2620     Locale loc(localeID);
   2621     UErrorCode status = U_ZERO_ERROR;
   2622     UnicodeString expected(CharsToUnicodeString("1,150$50\\u00A0Esc."));
   2623     UnicodeString s;
   2624     NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(loc, status);
   2625     if(U_FAILURE(status)){
   2626         dataerrln("Could not create currency formatter for locale %s - %s", localeID, u_errorName(status));
   2627         return;
   2628     }
   2629     currencyFmt->format(1150.50, s);
   2630     if(s!=expected){
   2631         errln(UnicodeString("FAIL: Expected: ")+expected
   2632                 + UnicodeString(" Got: ") + s
   2633                 + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
   2634     }
   2635     if (U_FAILURE(status)){
   2636         errln("FAIL: Status %s", u_errorName(status));
   2637     }
   2638     delete currencyFmt;
   2639 }
   2640 
   2641 void NumberFormatTest::TestHost()
   2642 {
   2643 #if U_PLATFORM_USES_ONLY_WIN32_API
   2644     Win32NumberTest::testLocales(this);
   2645 #endif
   2646     Locale loc("en_US@compat=host");
   2647     for (UNumberFormatStyle k = UNUM_DECIMAL;
   2648          k < UNUM_FORMAT_STYLE_COUNT; k = (UNumberFormatStyle)(k+1)) {
   2649         UErrorCode status = U_ZERO_ERROR;
   2650         LocalPointer<NumberFormat> full(NumberFormat::createInstance(loc, k, status));
   2651         if (!NumberFormat::isStyleSupported(k)) {
   2652             if (status != U_UNSUPPORTED_ERROR) {
   2653                 errln("FAIL: expected style %d to be unsupported - %s",
   2654                       k, u_errorName(status));
   2655             }
   2656             continue;
   2657         }
   2658         if (full.isNull() || U_FAILURE(status)) {
   2659             dataerrln("FAIL: Can't create number instance of style %d for host - %s",
   2660                       k, u_errorName(status));
   2661             return;
   2662         }
   2663         UnicodeString result1;
   2664         Formattable number(10.00);
   2665         full->format(number, result1, status);
   2666         if (U_FAILURE(status)) {
   2667             errln("FAIL: Can't format for host");
   2668             return;
   2669         }
   2670         Formattable formattable;
   2671         full->parse(result1, formattable, status);
   2672         if (U_FAILURE(status)) {
   2673             errln("FAIL: Can't parse for host");
   2674             return;
   2675         }
   2676     }
   2677 }
   2678 
   2679 void NumberFormatTest::TestHostClone()
   2680 {
   2681     /*
   2682     Verify that a cloned formatter gives the same results
   2683     and is useable after the original has been deleted.
   2684     */
   2685     // This is mainly important on Windows.
   2686     UErrorCode status = U_ZERO_ERROR;
   2687     Locale loc("en_US@compat=host");
   2688     UDate now = Calendar::getNow();
   2689     NumberFormat *full = NumberFormat::createInstance(loc, status);
   2690     if (full == NULL || U_FAILURE(status)) {
   2691         dataerrln("FAIL: Can't create Relative date instance - %s", u_errorName(status));
   2692         return;
   2693     }
   2694     UnicodeString result1;
   2695     full->format(now, result1, status);
   2696     Format *fullClone = full->clone();
   2697     delete full;
   2698     full = NULL;
   2699 
   2700     UnicodeString result2;
   2701     fullClone->format(now, result2, status);
   2702     if (U_FAILURE(status)) {
   2703         errln("FAIL: format failure.");
   2704     }
   2705     if (result1 != result2) {
   2706         errln("FAIL: Clone returned different result from non-clone.");
   2707     }
   2708     delete fullClone;
   2709 }
   2710 
   2711 void NumberFormatTest::TestCurrencyFormat()
   2712 {
   2713     // This test is here to increase code coverage.
   2714     UErrorCode status = U_ZERO_ERROR;
   2715     MeasureFormat *cloneObj;
   2716     UnicodeString str;
   2717     Formattable toFormat, result;
   2718     static const UChar ISO_CODE[4] = {0x0047, 0x0042, 0x0050, 0};
   2719 
   2720     Locale  saveDefaultLocale = Locale::getDefault();
   2721     Locale::setDefault( Locale::getUK(), status );
   2722     if (U_FAILURE(status)) {
   2723         errln("couldn't set default Locale!");
   2724         return;
   2725     }
   2726 
   2727     MeasureFormat *measureObj = MeasureFormat::createCurrencyFormat(status);
   2728     Locale::setDefault( saveDefaultLocale, status );
   2729     if (U_FAILURE(status)){
   2730         dataerrln("FAIL: Status %s", u_errorName(status));
   2731         return;
   2732     }
   2733     cloneObj = (MeasureFormat *)measureObj->clone();
   2734     if (cloneObj == NULL) {
   2735         errln("Clone doesn't work");
   2736         return;
   2737     }
   2738     toFormat.adoptObject(new CurrencyAmount(1234.56, ISO_CODE, status));
   2739     measureObj->format(toFormat, str, status);
   2740     measureObj->parseObject(str, result, status);
   2741     if (U_FAILURE(status)){
   2742         errln("FAIL: Status %s", u_errorName(status));
   2743     }
   2744     if (result != toFormat) {
   2745         errln("measureObj does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat));
   2746     }
   2747     status = U_ZERO_ERROR;
   2748     str.truncate(0);
   2749     cloneObj->format(toFormat, str, status);
   2750     cloneObj->parseObject(str, result, status);
   2751     if (U_FAILURE(status)){
   2752         errln("FAIL: Status %s", u_errorName(status));
   2753     }
   2754     if (result != toFormat) {
   2755         errln("Clone does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat));
   2756     }
   2757     if (*measureObj != *cloneObj) {
   2758         errln("Cloned object is not equal to the original object");
   2759     }
   2760     delete measureObj;
   2761     delete cloneObj;
   2762 
   2763     status = U_USELESS_COLLATOR_ERROR;
   2764     if (MeasureFormat::createCurrencyFormat(status) != NULL) {
   2765         errln("createCurrencyFormat should have returned NULL.");
   2766     }
   2767 }
   2768 
   2769 /* Port of ICU4J rounding test. */
   2770 void NumberFormatTest::TestRounding() {
   2771     UErrorCode status = U_ZERO_ERROR;
   2772     DecimalFormat *df = (DecimalFormat*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status);
   2773 
   2774     if (U_FAILURE(status)) {
   2775         dataerrln("Unable to create decimal formatter. - %s", u_errorName(status));
   2776         return;
   2777     }
   2778 
   2779     int roundingIncrements[]={1, 2, 5, 20, 50, 100};
   2780     int testValues[]={0, 300};
   2781 
   2782     for (int j=0; j<2; j++) {
   2783         for (int mode=DecimalFormat::kRoundUp;mode<DecimalFormat::kRoundHalfEven;mode++) {
   2784             df->setRoundingMode((DecimalFormat::ERoundingMode)mode);
   2785             for (int increment=0; increment<6; increment++) {
   2786                 double base=testValues[j];
   2787                 double rInc=roundingIncrements[increment];
   2788                 checkRounding(df, base, 20, rInc);
   2789                 rInc=1.000000000/rInc;
   2790                 checkRounding(df, base, 20, rInc);
   2791             }
   2792         }
   2793     }
   2794     delete df;
   2795 }
   2796 
   2797 void NumberFormatTest::TestRoundingPattern() {
   2798     UErrorCode status = U_ZERO_ERROR;
   2799     struct {
   2800         UnicodeString  pattern;
   2801         double        testCase;
   2802         UnicodeString expected;
   2803     } tests[] = {
   2804             { (UnicodeString)"##0.65", 1.234, (UnicodeString)"1.30" },
   2805             { (UnicodeString)"#50",    1230,  (UnicodeString)"1250" }
   2806     };
   2807     int32_t numOfTests = (sizeof(tests)/sizeof(tests[0]));
   2808     UnicodeString result;
   2809 
   2810     DecimalFormat *df = (DecimalFormat*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status);
   2811     if (U_FAILURE(status)) {
   2812         dataerrln("Unable to create decimal formatter. - %s", u_errorName(status));
   2813         return;
   2814     }
   2815 
   2816     for (int32_t i = 0; i < numOfTests; i++) {
   2817         result.remove();
   2818 
   2819         df->applyPattern(tests[i].pattern, status);
   2820         if (U_FAILURE(status)) {
   2821             errln("Unable to apply pattern to decimal formatter. - %s", u_errorName(status));
   2822         }
   2823 
   2824         df->format(tests[i].testCase, result);
   2825 
   2826         if (result != tests[i].expected) {
   2827             errln("String Pattern Rounding Test Failed: Pattern: \"" + tests[i].pattern + "\" Number: " + tests[i].testCase + " - Got: " + result + " Expected: " + tests[i].expected);
   2828         }
   2829     }
   2830 
   2831     delete df;
   2832 }
   2833 
   2834 void NumberFormatTest::checkRounding(DecimalFormat* df, double base, int iterations, double increment) {
   2835     df->setRoundingIncrement(increment);
   2836     double lastParsed=INT32_MIN; //Intger.MIN_VALUE
   2837     for (int i=-iterations; i<=iterations;i++) {
   2838         double iValue=base+(increment*(i*0.1));
   2839         double smallIncrement=0.00000001;
   2840         if (iValue!=0) {
   2841             smallIncrement*=iValue;
   2842         }
   2843         //we not only test the value, but some values in a small range around it
   2844         lastParsed=checkRound(df, iValue-smallIncrement, lastParsed);
   2845         lastParsed=checkRound(df, iValue, lastParsed);
   2846         lastParsed=checkRound(df, iValue+smallIncrement, lastParsed);
   2847     }
   2848 }
   2849 
   2850 double NumberFormatTest::checkRound(DecimalFormat* df, double iValue, double lastParsed) {
   2851     UErrorCode status=U_ZERO_ERROR;
   2852     UnicodeString formattedDecimal;
   2853     double parsed;
   2854     Formattable result;
   2855     df->format(iValue, formattedDecimal, status);
   2856 
   2857     if (U_FAILURE(status)) {
   2858         errln("Error formatting number.");
   2859     }
   2860 
   2861     df->parse(formattedDecimal, result, status);
   2862 
   2863     if (U_FAILURE(status)) {
   2864         errln("Error parsing number.");
   2865     }
   2866 
   2867     parsed=result.getDouble();
   2868 
   2869     if (lastParsed>parsed) {
   2870         errln("Rounding wrong direction! %d > %d", lastParsed, parsed);
   2871     }
   2872 
   2873     return lastParsed;
   2874 }
   2875 
   2876 void NumberFormatTest::TestNonpositiveMultiplier() {
   2877     UErrorCode status = U_ZERO_ERROR;
   2878     DecimalFormatSymbols US(Locale::getUS(), status);
   2879     CHECK(status, "DecimalFormatSymbols constructor");
   2880     DecimalFormat df(UnicodeString("0"), US, status);
   2881     CHECK(status, "DecimalFormat(0)");
   2882 
   2883     // test zero multiplier
   2884 
   2885     int32_t mult = df.getMultiplier();
   2886     df.setMultiplier(0);
   2887     if (df.getMultiplier() != mult) {
   2888         errln("DecimalFormat.setMultiplier(0) did not ignore its zero input");
   2889     }
   2890 
   2891     // test negative multiplier
   2892 
   2893     df.setMultiplier(-1);
   2894     if (df.getMultiplier() != -1) {
   2895         errln("DecimalFormat.setMultiplier(-1) ignored its negative input");
   2896         return;
   2897     }
   2898 
   2899     expect(df, "1122.123", -1122.123);
   2900     expect(df, "-1122.123", 1122.123);
   2901     expect(df, "1.2", -1.2);
   2902     expect(df, "-1.2", 1.2);
   2903 
   2904     // Note:  the tests with the final parameter of FALSE will not round trip.
   2905     //        The initial numeric value will format correctly, after the multiplier.
   2906     //        Parsing the formatted text will be out-of-range for an int64, however.
   2907     //        The expect() function could be modified to detect this and fall back
   2908     //        to looking at the decimal parsed value, but it doesn't.
   2909     expect(df, U_INT64_MIN,    "9223372036854775808", FALSE);
   2910     expect(df, U_INT64_MIN+1,  "9223372036854775807");
   2911     expect(df, (int64_t)-123,                  "123");
   2912     expect(df, (int64_t)123,                  "-123");
   2913     expect(df, U_INT64_MAX-1, "-9223372036854775806");
   2914     expect(df, U_INT64_MAX,   "-9223372036854775807");
   2915 
   2916     df.setMultiplier(-2);
   2917     expect(df, -(U_INT64_MIN/2)-1, "-9223372036854775806");
   2918     expect(df, -(U_INT64_MIN/2),   "-9223372036854775808");
   2919     expect(df, -(U_INT64_MIN/2)+1, "-9223372036854775810", FALSE);
   2920 
   2921     df.setMultiplier(-7);
   2922     expect(df, -(U_INT64_MAX/7)-1, "9223372036854775814", FALSE);
   2923     expect(df, -(U_INT64_MAX/7),   "9223372036854775807");
   2924     expect(df, -(U_INT64_MAX/7)+1, "9223372036854775800");
   2925 
   2926     // TODO: uncomment (and fix up) all the following int64_t tests once BigInteger is ported
   2927     // (right now the big numbers get turned into doubles and lose tons of accuracy)
   2928     //expect2(df, U_INT64_MAX, Int64ToUnicodeString(-U_INT64_MAX));
   2929     //expect2(df, U_INT64_MIN, UnicodeString(Int64ToUnicodeString(U_INT64_MIN), 1));
   2930     //expect2(df, U_INT64_MAX / 2, Int64ToUnicodeString(-(U_INT64_MAX / 2)));
   2931     //expect2(df, U_INT64_MIN / 2, Int64ToUnicodeString(-(U_INT64_MIN / 2)));
   2932 
   2933     // TODO: uncomment (and fix up) once BigDecimal is ported and DecimalFormat can handle it
   2934     //expect2(df, BigDecimal.valueOf(Long.MAX_VALUE), BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
   2935     //expect2(df, BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
   2936     //expect2(df, java.math.BigDecimal.valueOf(Long.MAX_VALUE), java.math.BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
   2937     //expect2(df, java.math.BigDecimal.valueOf(Long.MIN_VALUE), java.math.BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
   2938 }
   2939 
   2940 typedef struct {
   2941     const char * stringToParse;
   2942     int          parsedPos;
   2943     int          errorIndex;
   2944     UBool        lenient;
   2945 } TestSpaceParsingItem;
   2946 
   2947 void
   2948 NumberFormatTest::TestSpaceParsing() {
   2949     // the data are:
   2950     // the string to be parsed, parsed position, parsed error index
   2951     const TestSpaceParsingItem DATA[] = {
   2952         // TOTO: Update the following TODOs, some may be handled now
   2953         {"$124",           4, -1, FALSE},
   2954         {"$124 $124",      4, -1, FALSE},
   2955         {"$124 ",          4, -1, FALSE},
   2956         //{"$ 124 ",       5, -1, FALSE}, // TODO: need to handle space correctly
   2957         //{"$\\u00A0124 ", 5, -1, FALSE}, // TODO: need to handle space correctly
   2958         {"$ 124 ",         0,  1, FALSE}, // errorIndex used to be 0, now 1 (better)
   2959         {"$\\u00A0124 ",   0,  1, FALSE}, // errorIndex used to be 0, now 1 (better)
   2960         {" $ 124 ",        0,  0, FALSE}, // TODO: need to handle space correctly
   2961         {"124$",           0,  3, FALSE}, // TODO: need to handle space correctly
   2962         // {"124 $",       5, -1, FALSE}, // TODO: OK or not, need currency spacing rule
   2963         {"124 $",          0,  3, FALSE},
   2964         {"$124",           4, -1, TRUE},
   2965         {"$124 $124",      4, -1, TRUE},
   2966         {"$124 ",          4, -1, TRUE},
   2967         {"$ 124 ",         5, -1, TRUE},
   2968         {"$\\u00A0124 ",   5, -1, TRUE},
   2969         {" $ 124 ",        6, -1, TRUE},
   2970         //{"124$",         4, -1, TRUE}, // TODO: need to handle trailing currency correctly
   2971         {"124$",           3, -1, TRUE},
   2972         //{"124 $",        5, -1, TRUE}, // TODO: OK or not, need currency spacing rule
   2973         {"124 $",          4, -1, TRUE},
   2974     };
   2975     UErrorCode status = U_ZERO_ERROR;
   2976     Locale locale("en_US");
   2977     NumberFormat* foo = NumberFormat::createCurrencyInstance(locale, status);
   2978 
   2979     if (U_FAILURE(status)) {
   2980         delete foo;
   2981         return;
   2982     }
   2983     for (uint32_t i = 0; i < sizeof(DATA)/sizeof(DATA[0]); ++i) {
   2984         ParsePosition parsePosition(0);
   2985         UnicodeString stringToBeParsed = ctou(DATA[i].stringToParse);
   2986         int parsedPosition = DATA[i].parsedPos;
   2987         int errorIndex = DATA[i].errorIndex;
   2988         foo->setLenient(DATA[i].lenient);
   2989         Formattable result;
   2990         foo->parse(stringToBeParsed, result, parsePosition);
   2991         if (parsePosition.getIndex() != parsedPosition ||
   2992             parsePosition.getErrorIndex() != errorIndex) {
   2993             errln("FAILED parse " + stringToBeParsed + "; lenient: " + DATA[i].lenient + "; wrong position, expected: (" + parsedPosition + ", " + errorIndex + "); got (" + parsePosition.getIndex() + ", " + parsePosition.getErrorIndex() + ")");
   2994         }
   2995         if (parsePosition.getErrorIndex() == -1 &&
   2996             result.getType() == Formattable::kLong &&
   2997             result.getLong() != 124) {
   2998             errln("FAILED parse " + stringToBeParsed + "; wrong number, expect: 124, got " + result.getLong());
   2999         }
   3000     }
   3001     delete foo;
   3002 }
   3003 
   3004 /**
   3005  * Test using various numbering systems and numbering system keyword.
   3006  */
   3007 typedef struct {
   3008     const char *localeName;
   3009     double      value;
   3010     UBool        isRBNF;
   3011     const char *expectedResult;
   3012 } TestNumberingSystemItem;
   3013 
   3014 void NumberFormatTest::TestNumberingSystems() {
   3015 
   3016     const TestNumberingSystemItem DATA[] = {
   3017         { "en_US@numbers=thai", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" },
   3018         { "en_US@numbers=hebr", 5678.0, TRUE, "\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7" },
   3019         { "en_US@numbers=arabext", 1234.567, FALSE, "\\u06F1\\u066c\\u06F2\\u06F3\\u06F4\\u066b\\u06F5\\u06F6\\u06F7" },
   3020         { "ar_EG", 1234.567, FALSE, "\\u0661\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
   3021         { "th_TH@numbers=traditional", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" }, // fall back to native per TR35
   3022         { "ar_MA", 1234.567, FALSE, "1.234,567" },
   3023         { "en_US@numbers=hanidec", 1234.567, FALSE, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },
   3024         { "ta_IN@numbers=native", 1234.567, FALSE, "\\u0BE7,\\u0BE8\\u0BE9\\u0BEA.\\u0BEB\\u0BEC\\u0BED" },
   3025         { "ta_IN@numbers=traditional", 1235.0, TRUE, "\\u0BF2\\u0BE8\\u0BF1\\u0BE9\\u0BF0\\u0BEB" },
   3026         { "ta_IN@numbers=finance", 1234.567, FALSE, "1,234.567" }, // fall back to default per TR35
   3027         { "zh_TW@numbers=native", 1234.567, FALSE, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },
   3028         { "zh_TW@numbers=traditional", 1234.567, TRUE, "\\u4E00\\u5343\\u4E8C\\u767E\\u4E09\\u5341\\u56DB\\u9EDE\\u4E94\\u516D\\u4E03" },
   3029         { "zh_TW@numbers=finance", 1234.567, TRUE, "\\u58F9\\u4EDF\\u8CB3\\u4F70\\u53C3\\u62FE\\u8086\\u9EDE\\u4F0D\\u9678\\u67D2" },
   3030         { NULL, 0, FALSE, NULL }
   3031     };
   3032 
   3033     UErrorCode ec;
   3034 
   3035     const TestNumberingSystemItem *item;
   3036     for (item = DATA; item->localeName != NULL; item++) {
   3037         ec = U_ZERO_ERROR;
   3038         Locale loc = Locale::createFromName(item->localeName);
   3039         NumberFormat *fmt = NumberFormat::createInstance(loc,ec);
   3040 
   3041         if (U_FAILURE(ec)) {
   3042             dataerrln("FAIL: getInstance(%s) - %s", item->localeName, u_errorName(ec));
   3043             continue;
   3044         }
   3045 
   3046         if (item->isRBNF) {
   3047             expect3(*fmt,item->value,CharsToUnicodeString(item->expectedResult));
   3048         } else {
   3049             expect2(*fmt,item->value,CharsToUnicodeString(item->expectedResult));
   3050         }
   3051         delete fmt;
   3052     }
   3053 
   3054 
   3055     // Test bogus keyword value
   3056     ec = U_ZERO_ERROR;
   3057     Locale loc4 = Locale::createFromName("en_US@numbers=foobar");
   3058     NumberFormat* fmt4= NumberFormat::createInstance(loc4, ec);
   3059     if ( ec != U_UNSUPPORTED_ERROR ) {
   3060         errln("FAIL: getInstance(en_US@numbers=foobar) should have returned U_UNSUPPORTED_ERROR");
   3061         delete fmt4;
   3062     }
   3063 
   3064     ec = U_ZERO_ERROR;
   3065     NumberingSystem *ns = NumberingSystem::createInstance(ec);
   3066     if (U_FAILURE(ec)) {
   3067         dataerrln("FAIL: NumberingSystem::createInstance(ec); - %s", u_errorName(ec));
   3068     }
   3069 
   3070     if ( ns != NULL ) {
   3071         ns->getDynamicClassID();
   3072         ns->getStaticClassID();
   3073     } else {
   3074         errln("FAIL: getInstance() returned NULL.");
   3075     }
   3076 
   3077     NumberingSystem *ns1 = new NumberingSystem(*ns);
   3078     if (ns1 == NULL) {
   3079         errln("FAIL: NumberSystem copy constructor returned NULL.");
   3080     }
   3081 
   3082     delete ns1;
   3083     delete ns;
   3084 
   3085 }
   3086 
   3087 
   3088 void
   3089 NumberFormatTest::TestMultiCurrencySign() {
   3090     const char* DATA[][6] = {
   3091         // the fields in the following test are:
   3092         // locale,
   3093         // currency pattern (with negative pattern),
   3094         // currency number to be formatted,
   3095         // currency format using currency symbol name, such as "$" for USD,
   3096         // currency format using currency ISO name, such as "USD",
   3097         // currency format using plural name, such as "US dollars".
   3098         // for US locale
   3099         {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1234.56", "$1,234.56", "USD1,234.56", "US dollars1,234.56"},
   3100         {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "-1234.56", "-$1,234.56", "-USD1,234.56", "-US dollars1,234.56"},
   3101         {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1", "$1.00", "USD1.00", "US dollar1.00"},
   3102         // for CHINA locale
   3103         {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1234.56", "\\uFFE51,234.56", "CNY1,234.56", "\\u4EBA\\u6C11\\u5E011,234.56"},
   3104         {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "-1234.56", "(\\uFFE51,234.56)", "(CNY1,234.56)", "(\\u4EBA\\u6C11\\u5E011,234.56)"},
   3105         {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1", "\\uFFE51.00", "CNY1.00", "\\u4EBA\\u6C11\\u5E011.00"}
   3106     };
   3107 
   3108     const UChar doubleCurrencySign[] = {0xA4, 0xA4, 0};
   3109     UnicodeString doubleCurrencyStr(doubleCurrencySign);
   3110     const UChar tripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
   3111     UnicodeString tripleCurrencyStr(tripleCurrencySign);
   3112 
   3113     for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) {
   3114         const char* locale = DATA[i][0];
   3115         UnicodeString pat = ctou(DATA[i][1]);
   3116         double numberToBeFormat = atof(DATA[i][2]);
   3117         UErrorCode status = U_ZERO_ERROR;
   3118         DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale(locale), status);
   3119         if (U_FAILURE(status)) {
   3120             delete sym;
   3121             continue;
   3122         }
   3123         for (int j=1; j<=3; ++j) {
   3124             // j represents the number of currency sign in the pattern.
   3125             if (j == 2) {
   3126                 pat = pat.findAndReplace(ctou("\\u00A4"), doubleCurrencyStr);
   3127             } else if (j == 3) {
   3128                 pat = pat.findAndReplace(ctou("\\u00A4\\u00A4"), tripleCurrencyStr);
   3129             }
   3130 
   3131             DecimalFormat* fmt = new DecimalFormat(pat, new DecimalFormatSymbols(*sym), status);
   3132             if (U_FAILURE(status)) {
   3133                 errln("FAILED init DecimalFormat ");
   3134                 delete fmt;
   3135                 continue;
   3136             }
   3137             UnicodeString s;
   3138             ((NumberFormat*) fmt)->format(numberToBeFormat, s);
   3139             // DATA[i][3] is the currency format result using a
   3140             // single currency sign.
   3141             // DATA[i][4] is the currency format result using
   3142             // double currency sign.
   3143             // DATA[i][5] is the currency format result using
   3144             // triple currency sign.
   3145             // DATA[i][j+2] is the currency format result using
   3146             // 'j' number of currency sign.
   3147             UnicodeString currencyFormatResult = ctou(DATA[i][2+j]);
   3148             if (s.compare(currencyFormatResult)) {
   3149                 errln("FAIL format: Expected " + currencyFormatResult + "; Got " + s);
   3150             }
   3151             // mix style parsing
   3152             for (int k=3; k<=5; ++k) {
   3153               // DATA[i][3] is the currency format result using a
   3154               // single currency sign.
   3155               // DATA[i][4] is the currency format result using
   3156               // double currency sign.
   3157               // DATA[i][5] is the currency format result using
   3158               // triple currency sign.
   3159               UnicodeString oneCurrencyFormat = ctou(DATA[i][k]);
   3160               UErrorCode status = U_ZERO_ERROR;
   3161               Formattable parseRes;
   3162               fmt->parse(oneCurrencyFormat, parseRes, status);
   3163               if (U_FAILURE(status) ||
   3164                   (parseRes.getType() == Formattable::kDouble &&
   3165                    parseRes.getDouble() != numberToBeFormat) ||
   3166                   (parseRes.getType() == Formattable::kLong &&
   3167                    parseRes.getLong() != numberToBeFormat)) {
   3168                   errln("FAILED parse " + oneCurrencyFormat + "; (i, j, k): " +
   3169                         i + ", " + j + ", " + k);
   3170               }
   3171             }
   3172             delete fmt;
   3173         }
   3174         delete sym;
   3175     }
   3176 }
   3177 
   3178 
   3179 void
   3180 NumberFormatTest::TestCurrencyFormatForMixParsing() {
   3181     UErrorCode status = U_ZERO_ERROR;
   3182     MeasureFormat* curFmt = MeasureFormat::createCurrencyFormat(Locale("en_US"), status);
   3183     if (U_FAILURE(status)) {
   3184         delete curFmt;
   3185         return;
   3186     }
   3187     const char* formats[] = {
   3188         "$1,234.56",  // string to be parsed
   3189         "USD1,234.56",
   3190         "US dollars1,234.56",
   3191         "1,234.56 US dollars"
   3192     };
   3193     const CurrencyAmount* curramt = NULL;
   3194     for (uint32_t i = 0; i < sizeof(formats)/sizeof(formats[0]); ++i) {
   3195         UnicodeString stringToBeParsed = ctou(formats[i]);
   3196         logln(UnicodeString("stringToBeParsed: ") + stringToBeParsed);
   3197         Formattable result;
   3198         UErrorCode status = U_ZERO_ERROR;
   3199         curFmt->parseObject(stringToBeParsed, result, status);
   3200         if (U_FAILURE(status)) {
   3201           errln("FAIL: measure format parsing: '%s' ec: %s", formats[i], u_errorName(status));
   3202         } else if (result.getType() != Formattable::kObject ||
   3203             (curramt = dynamic_cast<const CurrencyAmount*>(result.getObject())) == NULL ||
   3204             curramt->getNumber().getDouble() != 1234.56 ||
   3205             UnicodeString(curramt->getISOCurrency()).compare(ISO_CURRENCY_USD)
   3206         ) {
   3207             errln("FAIL: getCurrencyFormat of default locale (en_US) failed roundtripping the number ");
   3208             if (curramt->getNumber().getDouble() != 1234.56) {
   3209                 errln((UnicodeString)"wong number, expect: 1234.56" + ", got: " + curramt->getNumber().getDouble());
   3210             }
   3211             if (curramt->getISOCurrency() != ISO_CURRENCY_USD) {
   3212                 errln((UnicodeString)"wong currency, expect: USD" + ", got: " + curramt->getISOCurrency());
   3213             }
   3214         }
   3215     }
   3216     delete curFmt;
   3217 }
   3218 
   3219 
   3220 void
   3221 NumberFormatTest::TestDecimalFormatCurrencyParse() {
   3222     // Locale.US
   3223     UErrorCode status = U_ZERO_ERROR;
   3224     DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale("en_US"), status);
   3225     if (U_FAILURE(status)) {
   3226         delete sym;
   3227         return;
   3228     }
   3229     UnicodeString pat;
   3230     UChar currency = 0x00A4;
   3231     // "\xA4#,##0.00;-\xA4#,##0.00"
   3232     pat.append(currency).append(currency).append(currency).append("#,##0.00;-").append(currency).append(currency).append(currency).append("#,##0.00");
   3233     DecimalFormat* fmt = new DecimalFormat(pat, sym, status);
   3234     if (U_FAILURE(status)) {
   3235         delete fmt;
   3236         errln("failed to new DecimalFormat in TestDecimalFormatCurrencyParse");
   3237         return;
   3238     }
   3239     const char* DATA[][2] = {
   3240         // the data are:
   3241         // string to be parsed, the parsed result (number)
   3242         {"$1.00", "1"},
   3243         {"USD1.00", "1"},
   3244         {"1.00 US dollar", "1"},
   3245         {"$1,234.56", "1234.56"},
   3246         {"USD1,234.56", "1234.56"},
   3247         {"1,234.56 US dollar", "1234.56"},
   3248     };
   3249     for (uint32_t i = 0; i < sizeof(DATA)/sizeof(DATA[0]); ++i) {
   3250         UnicodeString stringToBeParsed = ctou(DATA[i][0]);
   3251         double parsedResult = atof(DATA[i][1]);
   3252         UErrorCode status = U_ZERO_ERROR;
   3253         Formattable result;
   3254         fmt->parse(stringToBeParsed, result, status);
   3255         if (U_FAILURE(status) ||
   3256             (result.getType() == Formattable::kDouble &&
   3257             result.getDouble() != parsedResult) ||
   3258             (result.getType() == Formattable::kLong &&
   3259             result.getLong() != parsedResult)) {
   3260             errln((UnicodeString)"FAIL parse: Expected " + parsedResult);
   3261         }
   3262     }
   3263     delete fmt;
   3264 }
   3265 
   3266 
   3267 void
   3268 NumberFormatTest::TestCurrencyIsoPluralFormat() {
   3269     static const char* DATA[][6] = {
   3270         // the data are:
   3271         // locale,
   3272         // currency amount to be formatted,
   3273         // currency ISO code to be formatted,
   3274         // format result using CURRENCYSTYLE,
   3275         // format result using ISOCURRENCYSTYLE,
   3276         // format result using PLURALCURRENCYSTYLE,
   3277 
   3278         {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
   3279         {"en_US", "1234.56", "USD", "$1,234.56", "USD1,234.56", "1,234.56 US dollars"},
   3280         {"en_US", "-1234.56", "USD", "($1,234.56)", "(USD1,234.56)", "-1,234.56 US dollars"},
   3281         {"zh_CN", "1", "USD", "US$1.00", "USD1.00", "1.00\\u7F8E\\u5143"},
   3282         {"zh_CN", "1234.56", "USD", "US$1,234.56", "USD1,234.56", "1,234.56\\u7F8E\\u5143"},
   3283         // wrong ISO code {"zh_CN", "1", "CHY", "CHY1.00", "CHY1.00", "1.00 CHY"},
   3284         // wrong ISO code {"zh_CN", "1234.56", "CHY", "CHY1,234.56", "CHY1,234.56", "1,234.56 CHY"},
   3285         {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00\\u4EBA\\u6C11\\u5E01"},
   3286         {"zh_CN", "1234.56", "CNY", "\\uFFE51,234.56", "CNY1,234.56", "1,234.56\\u4EBA\\u6C11\\u5E01"},
   3287         {"ru_RU", "1", "RUB", "1,00\\u00A0\\u0440\\u0443\\u0431.", "1,00\\u00A0RUB", "1,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0439 \\u0440\\u0443\\u0431\\u043B\\u044C"},
   3288         {"ru_RU", "2", "RUB", "2,00\\u00A0\\u0440\\u0443\\u0431.", "2,00\\u00A0RUB", "2,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u044F"},
   3289         {"ru_RU", "5", "RUB", "5,00\\u00A0\\u0440\\u0443\\u0431.", "5,00\\u00A0RUB", "5,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u0435\\u0439"},
   3290         // test locale without currency information
   3291         {"root", "-1.23", "USD", "-US$\\u00A01.23", "-USD\\u00A01.23", "-1.23 USD"},
   3292         // test choice format
   3293         {"es_AR", "1", "INR", "\\u20B91,00", "INR1,00", "1,00 rupia india"},
   3294     };
   3295     static const UNumberFormatStyle currencyStyles[] = {
   3296         UNUM_CURRENCY,
   3297         UNUM_CURRENCY_ISO,
   3298         UNUM_CURRENCY_PLURAL
   3299     };
   3300 
   3301     for (int32_t i=0; i<LENGTHOF(DATA); ++i) {
   3302       for (int32_t kIndex = 0; kIndex < LENGTHOF(currencyStyles); ++kIndex) {
   3303         UNumberFormatStyle k = currencyStyles[kIndex];
   3304         const char* localeString = DATA[i][0];
   3305         double numberToBeFormat = atof(DATA[i][1]);
   3306         const char* currencyISOCode = DATA[i][2];
   3307         Locale locale(localeString);
   3308         UErrorCode status = U_ZERO_ERROR;
   3309         NumberFormat* numFmt = NumberFormat::createInstance(locale, k, status);
   3310         if (U_FAILURE(status)) {
   3311             delete numFmt;
   3312             dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
   3313             continue;
   3314         }
   3315         UChar currencyCode[4];
   3316         u_charsToUChars(currencyISOCode, currencyCode, 4);
   3317         numFmt->setCurrency(currencyCode, status);
   3318         if (U_FAILURE(status)) {
   3319             delete numFmt;
   3320             errln((UnicodeString)"can not set currency:" + currencyISOCode);
   3321             continue;
   3322         }
   3323 
   3324         UnicodeString strBuf;
   3325         numFmt->format(numberToBeFormat, strBuf);
   3326         int resultDataIndex = 3 + kIndex;
   3327         // DATA[i][resultDataIndex] is the currency format result
   3328         // using 'k' currency style.
   3329         UnicodeString formatResult = ctou(DATA[i][resultDataIndex]);
   3330         if (strBuf.compare(formatResult)) {
   3331             errln("FAIL: Expected " + formatResult + " actual: " + strBuf);
   3332         }
   3333         // test parsing, and test parsing for all currency formats.
   3334         for (int j = 3; j < 6; ++j) {
   3335             // DATA[i][3] is the currency format result using
   3336             // CURRENCYSTYLE formatter.
   3337             // DATA[i][4] is the currency format result using
   3338             // ISOCURRENCYSTYLE formatter.
   3339             // DATA[i][5] is the currency format result using
   3340             // PLURALCURRENCYSTYLE formatter.
   3341             UnicodeString oneCurrencyFormatResult = ctou(DATA[i][j]);
   3342             UErrorCode status = U_ZERO_ERROR;
   3343             Formattable parseResult;
   3344             numFmt->parse(oneCurrencyFormatResult, parseResult, status);
   3345             if (U_FAILURE(status) ||
   3346                 (parseResult.getType() == Formattable::kDouble &&
   3347                  parseResult.getDouble() != numberToBeFormat) ||
   3348                 (parseResult.getType() == Formattable::kLong &&
   3349                  parseResult.getLong() != numberToBeFormat)) {
   3350                 errln((UnicodeString)"FAIL: getCurrencyFormat of locale " +
   3351                       localeString + " failed roundtripping the number");
   3352                 if (parseResult.getType() == Formattable::kDouble) {
   3353                     errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getDouble());
   3354                 } else {
   3355                     errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong());
   3356                 }
   3357             }
   3358         }
   3359         delete numFmt;
   3360       }
   3361     }
   3362 }
   3363 
   3364 void
   3365 NumberFormatTest::TestCurrencyParsing() {
   3366     static const char* DATA[][6] = {
   3367         // the data are:
   3368         // locale,
   3369         // currency amount to be formatted,
   3370         // currency ISO code to be formatted,
   3371         // format result using CURRENCYSTYLE,
   3372         // format result using ISOCURRENCYSTYLE,
   3373         // format result using PLURALCURRENCYSTYLE,
   3374         {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
   3375         {"pa_IN", "1", "USD", "US$\\u00a0\\u0a67.\\u0a66\\u0a66", "USD\\u00a0\\u0a67.\\u0a66\\u0a66", "\\u0a67.\\u0a66\\u0a66 USD"},
   3376         {"es_AR", "1", "USD", "US$1,00", "USD1,00", "1,00 d\\u00f3lar estadounidense"},
   3377         {"ar_EG", "1", "USD", "US$\\u00a0\\u0661\\u066b\\u0660\\u0660", "USD\\u00a0\\u0661\\u066b\\u0660\\u0660", "\\u0661\\u066b\\u0660\\u0660 \\u062f\\u0648\\u0644\\u0627\\u0631 \\u0623\\u0645\\u0631\\u064a\\u0643\\u064a"},
   3378         {"fa_CA", "1", "USD", "\\u200eUS$\\u06f1\\u066b\\u06f0\\u06f0", "\\u200eUSD\\u06f1\\u066b\\u06f0\\u06f0", "\\u200e\\u062f\\u0644\\u0627\\u0631 \\u0627\\u0645\\u0631\\u06cc\\u06a9\\u0627\\u06f1\\u066b\\u06f0\\u06f0"},
   3379         {"he_IL", "1", "USD", "1.00\\u00a0US$", "1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"},
   3380         {"hr_HR", "1", "USD", "1,00\\u00a0$", "1,00\\u00a0USD", "1,00 Ameri\\u010dki dolar"},
   3381         {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 Dolar Amerika Serikat"},
   3382         {"it_IT", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 Dollaro Statunitense"},
   3383         {"ko_KR", "1", "USD", "US$1.00", "USD1.00", "1.00 \\ubbf8\\uad6d \\ub2ec\\ub7ec"},
   3384         {"ja_JP", "1", "USD", "$1.00", "USD1.00", "1.00 \\u7c73\\u30c9\\u30eb"},
   3385         {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00\\u4EBA\\u6C11\\u5E01"},
   3386         {"zh_TW", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4eba\\u6c11\\u5e63"},
   3387         {"ru_RU", "1", "RUB", "1,00\\u00A0\\u0440\\u0443\\u0431.", "1,00\\u00A0RUB", "1,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0439 \\u0440\\u0443\\u0431\\u043B\\u044C"},
   3388     };
   3389     static const UNumberFormatStyle currencyStyles[] = {
   3390         UNUM_CURRENCY,
   3391         UNUM_CURRENCY_ISO,
   3392         UNUM_CURRENCY_PLURAL
   3393     };
   3394 
   3395 #ifdef NUMFMTST_CACHE_DEBUG
   3396 int deadloop = 0;
   3397 for (;;) {
   3398     printf("loop: %d\n", deadloop++);
   3399 #endif
   3400     for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) {
   3401       for (int32_t kIndex = 0; kIndex < LENGTHOF(currencyStyles); ++kIndex) {
   3402         UNumberFormatStyle k = currencyStyles[kIndex];
   3403         const char* localeString = DATA[i][0];
   3404         double numberToBeFormat = atof(DATA[i][1]);
   3405         const char* currencyISOCode = DATA[i][2];
   3406         Locale locale(localeString);
   3407         UErrorCode status = U_ZERO_ERROR;
   3408         NumberFormat* numFmt = NumberFormat::createInstance(locale, k, status);
   3409         if (U_FAILURE(status)) {
   3410             delete numFmt;
   3411             dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
   3412             continue;
   3413         }
   3414         UChar currencyCode[4];
   3415         u_charsToUChars(currencyISOCode, currencyCode, 4);
   3416         numFmt->setCurrency(currencyCode, status);
   3417         if (U_FAILURE(status)) {
   3418             delete numFmt;
   3419             errln((UnicodeString)"can not set currency:" + currencyISOCode);
   3420             continue;
   3421         }
   3422 
   3423         /*
   3424         UnicodeString strBuf;
   3425         numFmt->format(numberToBeFormat, strBuf);
   3426         int resultDataIndex = 3 + kIndex;
   3427         // DATA[i][resultDataIndex] is the currency format result
   3428         // using 'k' currency style.
   3429         UnicodeString formatResult = ctou(DATA[i][resultDataIndex]);
   3430         if (strBuf.compare(formatResult)) {
   3431             errln("FAIL: Expected " + formatResult + " actual: " + strBuf);
   3432         }
   3433         */
   3434         // test parsing, and test parsing for all currency formats.
   3435         for (int j = 3; j < 6; ++j) {
   3436             // DATA[i][3] is the currency format result using
   3437             // CURRENCYSTYLE formatter.
   3438             // DATA[i][4] is the currency format result using
   3439             // ISOCURRENCYSTYLE formatter.
   3440             // DATA[i][5] is the currency format result using
   3441             // PLURALCURRENCYSTYLE formatter.
   3442             UnicodeString oneCurrencyFormatResult = ctou(DATA[i][j]);
   3443             UErrorCode status = U_ZERO_ERROR;
   3444             Formattable parseResult;
   3445             numFmt->parse(oneCurrencyFormatResult, parseResult, status);
   3446             if (U_FAILURE(status) ||
   3447                 (parseResult.getType() == Formattable::kDouble &&
   3448                  parseResult.getDouble() != numberToBeFormat) ||
   3449                 (parseResult.getType() == Formattable::kLong &&
   3450                  parseResult.getLong() != numberToBeFormat)) {
   3451                 errln((UnicodeString)"FAIL: getCurrencyFormat of locale " +
   3452                       localeString + " failed roundtripping the number" +
   3453                       "(i,k,j): " + i + ", " + k + ", " + j);
   3454                 if (parseResult.getType() == Formattable::kDouble) {
   3455                     errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getDouble());
   3456                 } else {
   3457                     errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong());
   3458                 }
   3459             }
   3460         }
   3461         delete numFmt;
   3462       }
   3463     }
   3464 #ifdef NUMFMTST_CACHE_DEBUG
   3465 }
   3466 #endif
   3467 }
   3468 
   3469 
   3470 void
   3471 NumberFormatTest::TestParseCurrencyInUCurr() {
   3472     const char* DATA[] = {
   3473         "1.00 US DOLLAR",  // case in-sensitive
   3474         "$1.00",
   3475         "USD1.00",
   3476         "US dollar1.00",
   3477         "US dollars1.00",
   3478         "$1.00",
   3479         "A$1.00",
   3480         "ADP1.00",
   3481         "ADP1.00",
   3482         "AED1.00",
   3483         "AED1.00",
   3484         "AFA1.00",
   3485         "AFA1.00",
   3486         "AFN1.00",
   3487         "ALL1.00",
   3488         "AMD1.00",
   3489         "ANG1.00",
   3490         "AOA1.00",
   3491         "AOK1.00",
   3492         "AOK1.00",
   3493         "AON1.00",
   3494         "AON1.00",
   3495         "AOR1.00",
   3496         "AOR1.00",
   3497         "ARS1.00",
   3498         "ARA1.00",
   3499         "ARA1.00",
   3500         "ARP1.00",
   3501         "ARP1.00",
   3502         "ARS1.00",
   3503         "ATS1.00",
   3504         "ATS1.00",
   3505         "AUD1.00",
   3506         "AWG1.00",
   3507         "AZM1.00",
   3508         "AZM1.00",
   3509         "AZN1.00",
   3510         "Afghan Afghani (1927-2002)1.00",
   3511         "Afghan afghani (1927-2002)1.00",
   3512         "Afghan Afghani1.00",
   3513         "Afghan Afghanis1.00",
   3514         "Albanian Lek1.00",
   3515         "Albanian lek1.00",
   3516         "Albanian lek\\u00eb1.00",
   3517         "Algerian Dinar1.00",
   3518         "Algerian dinar1.00",
   3519         "Algerian dinars1.00",
   3520         "Andorran Peseta1.00",
   3521         "Andorran peseta1.00",
   3522         "Andorran pesetas1.00",
   3523         "Angolan Kwanza (1977-1991)1.00",
   3524         "Angolan Readjusted Kwanza (1995-1999)1.00",
   3525         "Angolan Kwanza1.00",
   3526         "Angolan New Kwanza (1990-2000)1.00",
   3527         "Angolan kwanza (1977-1991)1.00",
   3528         "Angolan readjusted kwanza (1995-1999)1.00",
   3529         "Angolan kwanza1.00",
   3530         "Angolan kwanzas (1977-1991)1.00",
   3531         "Angolan readjusted kwanzas (1995-1999)1.00",
   3532         "Angolan kwanzas1.00",
   3533         "Angolan new kwanza (1990-2000)1.00",
   3534         "Angolan new kwanzas (1990-2000)1.00",
   3535         "Argentine Austral1.00",
   3536         "Argentine Peso (1983-1985)1.00",
   3537         "Argentine Peso1.00",
   3538         "Argentine austral1.00",
   3539         "Argentine australs1.00",
   3540         "Argentine peso (1983-1985)1.00",
   3541         "Argentine peso1.00",
   3542         "Argentine pesos (1983-1985)1.00",
   3543         "Argentine pesos1.00",
   3544         "Armenian Dram1.00",
   3545         "Armenian dram1.00",
   3546         "Armenian drams1.00",
   3547         "Aruban Florin1.00",
   3548         "Aruban florin1.00",
   3549         "Australian Dollar1.00",
   3550         "Australian dollar1.00",
   3551         "Australian dollars1.00",
   3552         "Austrian Schilling1.00",
   3553         "Austrian schilling1.00",
   3554         "Austrian schillings1.00",
   3555         "Azerbaijani Manat (1993-2006)1.00",
   3556         "Azerbaijani Manat1.00",
   3557         "Azerbaijani manat (1993-2006)1.00",
   3558         "Azerbaijani manat1.00",
   3559         "Azerbaijani manats (1993-2006)1.00",
   3560         "Azerbaijani manats1.00",
   3561         "BAD1.00",
   3562         "BAD1.00",
   3563         "BAM1.00",
   3564         "BBD1.00",
   3565         "BDT1.00",
   3566         "BEC1.00",
   3567         "BEC1.00",
   3568         "BEF1.00",
   3569         "BEL1.00",
   3570         "BEL1.00",
   3571         "BGL1.00",
   3572         "BGN1.00",
   3573         "BGN1.00",
   3574         "BHD1.00",
   3575         "BIF1.00",
   3576         "BMD1.00",
   3577         "BND1.00",
   3578         "BOB1.00",
   3579         "BOP1.00",
   3580         "BOP1.00",
   3581         "BOV1.00",
   3582         "BOV1.00",
   3583         "BRB1.00",
   3584         "BRB1.00",
   3585         "BRC1.00",
   3586         "BRC1.00",
   3587         "BRE1.00",
   3588         "BRE1.00",
   3589         "BRL1.00",
   3590         "BRN1.00",
   3591         "BRN1.00",
   3592         "BRR1.00",
   3593         "BRR1.00",
   3594         "BSD1.00",
   3595         "BSD1.00",
   3596         "BTN1.00",
   3597         "BUK1.00",
   3598         "BUK1.00",
   3599         "BWP1.00",
   3600         "BYB1.00",
   3601         "BYB1.00",
   3602         "BYR1.00",
   3603         "BZD1.00",
   3604         "Bahamian Dollar1.00",
   3605         "Bahamian dollar1.00",
   3606         "Bahamian dollars1.00",
   3607         "Bahraini Dinar1.00",
   3608         "Bahraini dinar1.00",
   3609         "Bahraini dinars1.00",
   3610         "Bangladeshi Taka1.00",
   3611         "Bangladeshi taka1.00",
   3612         "Bangladeshi takas1.00",
   3613         "Barbadian Dollar1.00",
   3614         "Barbadian dollar1.00",
   3615         "Barbadian dollars1.00",
   3616         "Belarusian New Ruble (1994-1999)1.00",
   3617         "Belarusian Ruble1.00",
   3618         "Belarusian new ruble (1994-1999)1.00",
   3619         "Belarusian new rubles (1994-1999)1.00",
   3620         "Belarusian ruble1.00",
   3621         "Belarusian rubles1.00",
   3622         "Belgian Franc (convertible)1.00",
   3623         "Belgian Franc (financial)1.00",
   3624         "Belgian Franc1.00",
   3625         "Belgian franc (convertible)1.00",
   3626         "Belgian franc (financial)1.00",
   3627         "Belgian franc1.00",
   3628         "Belgian francs (convertible)1.00",
   3629         "Belgian francs (financial)1.00",
   3630         "Belgian francs1.00",
   3631         "Belize Dollar1.00",
   3632         "Belize dollar1.00",
   3633         "Belize dollars1.00",
   3634         "Bermudan Dollar1.00",
   3635         "Bermudan dollar1.00",
   3636         "Bermudan dollars1.00",
   3637         "Bhutanese Ngultrum1.00",
   3638         "Bhutanese ngultrum1.00",
   3639         "Bhutanese ngultrums1.00",
   3640         "Bolivian Mvdol1.00",
   3641         "Bolivian Peso1.00",
   3642         "Bolivian mvdol1.00",
   3643         "Bolivian mvdols1.00",
   3644         "Bolivian peso1.00",
   3645         "Bolivian pesos1.00",
   3646         "Bolivian Boliviano1.00",
   3647         "Bolivian Boliviano1.00",
   3648         "Bolivian Bolivianos1.00",
   3649         "Bosnia-Herzegovina Convertible Mark1.00",
   3650         "Bosnia-Herzegovina Dinar (1992-1994)1.00",
   3651         "Bosnia-Herzegovina convertible mark1.00",
   3652         "Bosnia-Herzegovina convertible marks1.00",
   3653         "Bosnia-Herzegovina dinar (1992-1994)1.00",
   3654         "Bosnia-Herzegovina dinars (1992-1994)1.00",
   3655         "Botswanan Pula1.00",
   3656         "Botswanan pula1.00",
   3657         "Botswanan pulas1.00",
   3658         "Brazilian New Cruzado (1989-1990)1.00",
   3659         "Brazilian Cruzado (1986-1989)1.00",
   3660         "Brazilian Cruzeiro (1990-1993)1.00",
   3661         "Brazilian New Cruzeiro (1967-1986)1.00",
   3662         "Brazilian Cruzeiro (1993-1994)1.00",
   3663         "Brazilian Real1.00",
   3664         "Brazilian new cruzado (1989-1990)1.00",
   3665         "Brazilian new cruzados (1989-1990)1.00",
   3666         "Brazilian cruzado (1986-1989)1.00",
   3667         "Brazilian cruzados (1986-1989)1.00",
   3668         "Brazilian cruzeiro (1990-1993)1.00",
   3669         "Brazilian new cruzeiro (1967-1986)1.00",
   3670         "Brazilian cruzeiro (1993-1994)1.00",
   3671         "Brazilian cruzeiros (1990-1993)1.00",
   3672         "Brazilian new cruzeiros (1967-1986)1.00",
   3673         "Brazilian cruzeiros (1993-1994)1.00",
   3674         "Brazilian real1.00",
   3675         "Brazilian reals1.00",
   3676         "British Pound Sterling1.00",
   3677         "British pound sterling1.00",
   3678         "British pounds sterling1.00",
   3679         "Brunei Dollar1.00",
   3680         "Brunei dollar1.00",
   3681         "Brunei dollars1.00",
   3682         "Bulgarian Hard Lev1.00",
   3683         "Bulgarian Lev1.00",
   3684         "Bulgarian Leva1.00",
   3685         "Bulgarian hard lev1.00",
   3686         "Bulgarian hard leva1.00",
   3687         "Bulgarian lev1.00",
   3688         "Burmese Kyat1.00",
   3689         "Burmese kyat1.00",
   3690         "Burmese kyats1.00",
   3691         "Burundian Franc1.00",
   3692         "Burundian franc1.00",
   3693         "Burundian francs1.00",
   3694         "CA$1.00",
   3695         "CAD1.00",
   3696         "CDF1.00",
   3697         "CDF1.00",
   3698         "CFA Franc BCEAO1.00",
   3699         "CFA Franc BEAC1.00",
   3700         "CFA franc BCEAO1.00",
   3701         "CFA franc BEAC1.00",
   3702         "CFA francs BCEAO1.00",
   3703         "CFA francs BEAC1.00",
   3704         "CFP Franc1.00",
   3705         "CFP franc1.00",
   3706         "CFP francs1.00",
   3707         "CFPF1.00",
   3708         "CHE1.00",
   3709         "CHE1.00",
   3710         "CHF1.00",
   3711         "CHW1.00",
   3712         "CHW1.00",
   3713         "CLF1.00",
   3714         "CLF1.00",
   3715         "CLP1.00",
   3716         "CNY1.00",
   3717         "COP1.00",
   3718         "COU1.00",
   3719         "COU1.00",
   3720         "CRC1.00",
   3721         "CSD1.00",
   3722         "CSD1.00",
   3723         "CSK1.00",
   3724         "CSK1.00",
   3725         "CUP1.00",
   3726         "CUP1.00",
   3727         "CVE1.00",
   3728         "CYP1.00",
   3729         "CZK1.00",
   3730         "Cambodian Riel1.00",
   3731         "Cambodian riel1.00",
   3732         "Cambodian riels1.00",
   3733         "Canadian Dollar1.00",
   3734         "Canadian dollar1.00",
   3735         "Canadian dollars1.00",
   3736         "Cape Verdean Escudo1.00",
   3737         "Cape Verdean escudo1.00",
   3738         "Cape Verdean escudos1.00",
   3739         "Cayman Islands Dollar1.00",
   3740         "Cayman Islands dollar1.00",
   3741         "Cayman Islands dollars1.00",
   3742         "Chilean Peso1.00",
   3743         "Chilean Unit of Account (UF)1.00",
   3744         "Chilean peso1.00",
   3745         "Chilean pesos1.00",
   3746         "Chilean unit of account (UF)1.00",
   3747         "Chilean units of account (UF)1.00",
   3748         "Chinese Yuan1.00",
   3749         "Chinese yuan1.00",
   3750         "Colombian Peso1.00",
   3751         "Colombian peso1.00",
   3752         "Colombian pesos1.00",
   3753         "Comorian Franc1.00",
   3754         "Comorian franc1.00",
   3755         "Comorian francs1.00",
   3756         "Congolese Franc1.00",
   3757         "Congolese franc1.00",
   3758         "Congolese francs1.00",
   3759         "Costa Rican Col\\u00f3n1.00",
   3760         "Costa Rican col\\u00f3n1.00",
   3761         "Costa Rican col\\u00f3ns1.00",
   3762         "Croatian Dinar1.00",
   3763         "Croatian Kuna1.00",
   3764         "Croatian dinar1.00",
   3765         "Croatian dinars1.00",
   3766         "Croatian kuna1.00",
   3767         "Croatian kunas1.00",
   3768         "Cuban Peso1.00",
   3769         "Cuban peso1.00",
   3770         "Cuban pesos1.00",
   3771         "Cypriot Pound1.00",
   3772         "Cypriot pound1.00",
   3773         "Cypriot pounds1.00",
   3774         "Czech Republic Koruna1.00",
   3775         "Czech Republic koruna1.00",
   3776         "Czech Republic korunas1.00",
   3777         "Czechoslovak Hard Koruna1.00",
   3778         "Czechoslovak hard koruna1.00",
   3779         "Czechoslovak hard korunas1.00",
   3780         "DDM1.00",
   3781         "DDM1.00",
   3782         "DEM1.00",
   3783         "DEM1.00",
   3784         "DJF1.00",
   3785         "DKK1.00",
   3786         "DOP1.00",
   3787         "DZD1.00",
   3788         "Danish Krone1.00",
   3789         "Danish krone1.00",
   3790         "Danish kroner1.00",
   3791         "German Mark1.00",
   3792         "German mark1.00",
   3793         "German marks1.00",
   3794         "Djiboutian Franc1.00",
   3795         "Djiboutian franc1.00",
   3796         "Djiboutian francs1.00",
   3797         "Dominican Peso1.00",
   3798         "Dominican peso1.00",
   3799         "Dominican pesos1.00",
   3800         "EC$1.00",
   3801         "ECS1.00",
   3802         "ECS1.00",
   3803         "ECV1.00",
   3804         "ECV1.00",
   3805         "EEK1.00",
   3806         "EEK1.00",
   3807         "EGP1.00",
   3808         "EGP1.00",
   3809         "ERN1.00",
   3810         "ERN1.00",
   3811         "ESA1.00",
   3812         "ESA1.00",
   3813         "ESB1.00",
   3814         "ESB1.00",
   3815         "ESP1.00",
   3816         "ETB1.00",
   3817         "EUR1.00",
   3818         "East Caribbean Dollar1.00",
   3819         "East Caribbean dollar1.00",
   3820         "East Caribbean dollars1.00",
   3821         "East German Mark1.00",
   3822         "East German mark1.00",
   3823         "East German marks1.00",
   3824         "Ecuadorian Sucre1.00",
   3825         "Ecuadorian Unit of Constant Value1.00",
   3826         "Ecuadorian sucre1.00",
   3827         "Ecuadorian sucres1.00",
   3828         "Ecuadorian unit of constant value1.00",
   3829         "Ecuadorian units of constant value1.00",
   3830         "Egyptian Pound1.00",
   3831         "Egyptian pound1.00",
   3832         "Egyptian pounds1.00",
   3833         "Salvadoran Col\\u00f3n1.00",
   3834         "Salvadoran col\\u00f3n1.00",
   3835         "Salvadoran colones1.00",
   3836         "Equatorial Guinean Ekwele1.00",
   3837         "Equatorial Guinean ekwele1.00",
   3838         "Eritrean Nakfa1.00",
   3839         "Eritrean nakfa1.00",
   3840         "Eritrean nakfas1.00",
   3841         "Estonian Kroon1.00",
   3842         "Estonian kroon1.00",
   3843         "Estonian kroons1.00",
   3844         "Ethiopian Birr1.00",
   3845         "Ethiopian birr1.00",
   3846         "Ethiopian birrs1.00",
   3847         "Euro1.00",
   3848         "European Composite Unit1.00",
   3849         "European Currency Unit1.00",
   3850         "European Monetary Unit1.00",
   3851         "European Unit of Account (XBC)1.00",
   3852         "European Unit of Account (XBD)1.00",
   3853         "European composite unit1.00",
   3854         "European composite units1.00",
   3855         "European currency unit1.00",
   3856         "European currency units1.00",
   3857         "European monetary unit1.00",
   3858         "European monetary units1.00",
   3859         "European unit of account (XBC)1.00",
   3860         "European unit of account (XBD)1.00",
   3861         "European units of account (XBC)1.00",
   3862         "European units of account (XBD)1.00",
   3863         "FIM1.00",
   3864         "FIM1.00",
   3865         "FJD1.00",
   3866         "FKP1.00",
   3867         "FKP1.00",
   3868         "FRF1.00",
   3869         "FRF1.00",
   3870         "Falkland Islands Pound1.00",
   3871         "Falkland Islands pound1.00",
   3872         "Falkland Islands pounds1.00",
   3873         "Fijian Dollar1.00",
   3874         "Fijian dollar1.00",
   3875         "Fijian dollars1.00",
   3876         "Finnish Markka1.00",
   3877         "Finnish markka1.00",
   3878         "Finnish markkas1.00",
   3879         "CHF1.00",
   3880         "French Franc1.00",
   3881         "French Gold Franc1.00",
   3882         "French UIC-Franc1.00",
   3883         "French UIC-franc1.00",
   3884         "French UIC-francs1.00",
   3885         "French franc1.00",
   3886         "French francs1.00",
   3887         "French gold franc1.00",
   3888         "French gold francs1.00",
   3889         "GBP1.00",
   3890         "GEK1.00",
   3891         "GEK1.00",
   3892         "GEL1.00",
   3893         "GHC1.00",
   3894         "GHC1.00",
   3895         "GHS1.00",
   3896         "GIP1.00",
   3897         "GIP1.00",
   3898         "GMD1.00",
   3899         "GMD1.00",
   3900         "GNF1.00",
   3901         "GNS1.00",
   3902         "GNS1.00",
   3903         "GQE1.00",
   3904         "GQE1.00",
   3905         "GRD1.00",
   3906         "GRD1.00",
   3907         "GTQ1.00",
   3908         "GWE1.00",
   3909         "GWE1.00",
   3910         "GWP1.00",
   3911         "GWP1.00",
   3912         "GYD1.00",
   3913         "Gambian Dalasi1.00",
   3914         "Gambian dalasi1.00",
   3915         "Gambian dalasis1.00",
   3916         "Georgian Kupon Larit1.00",
   3917         "Georgian Lari1.00",
   3918         "Georgian kupon larit1.00",
   3919         "Georgian kupon larits1.00",
   3920         "Georgian lari1.00",
   3921         "Georgian laris1.00",
   3922         "Ghanaian Cedi (1979-2007)1.00",
   3923         "Ghanaian Cedi1.00",
   3924         "Ghanaian cedi (1979-2007)1.00",
   3925         "Ghanaian cedi1.00",
   3926         "Ghanaian cedis (1979-2007)1.00",
   3927         "Ghanaian cedis1.00",
   3928         "Gibraltar Pound1.00",
   3929         "Gibraltar pound1.00",
   3930         "Gibraltar pounds1.00",
   3931         "Gold1.00",
   3932         "Gold1.00",
   3933         "Greek Drachma1.00",
   3934         "Greek drachma1.00",
   3935         "Greek drachmas1.00",
   3936         "Guatemalan Quetzal1.00",
   3937         "Guatemalan quetzal1.00",
   3938         "Guatemalan quetzals1.00",
   3939         "Guinean Franc1.00",
   3940         "Guinean Syli1.00",
   3941         "Guinean franc1.00",
   3942         "Guinean francs1.00",
   3943         "Guinean syli1.00",
   3944         "Guinean sylis1.00",
   3945         "Guinea-Bissau Peso1.00",
   3946         "Guinea-Bissau peso1.00",
   3947         "Guinea-Bissau pesos1.00",
   3948         "Guyanaese Dollar1.00",
   3949         "Guyanaese dollar1.00",
   3950         "Guyanaese dollars1.00",
   3951         "HK$1.00",
   3952         "HKD1.00",
   3953         "HNL1.00",
   3954         "HRD1.00",
   3955         "HRD1.00",
   3956         "HRK1.00",
   3957         "HRK1.00",
   3958         "HTG1.00",
   3959         "HTG1.00",
   3960         "HUF1.00",
   3961         "Haitian Gourde1.00",
   3962         "Haitian gourde1.00",
   3963         "Haitian gourdes1.00",
   3964         "Honduran Lempira1.00",
   3965         "Honduran lempira1.00",
   3966         "Honduran lempiras1.00",
   3967         "Hong Kong Dollar1.00",
   3968         "Hong Kong dollar1.00",
   3969         "Hong Kong dollars1.00",
   3970         "Hungarian Forint1.00",
   3971         "Hungarian forint1.00",
   3972         "Hungarian forints1.00",
   3973         "IDR1.00",
   3974         "IEP1.00",
   3975         "ILP1.00",
   3976         "ILP1.00",
   3977         "ILS1.00",
   3978         "INR1.00",
   3979         "IQD1.00",
   3980         "IRR1.00",
   3981         "ISK1.00",
   3982         "ISK1.00",
   3983         "ITL1.00",
   3984         "Icelandic Kr\\u00f3na1.00",
   3985         "Icelandic kr\\u00f3na1.00",
   3986         "Icelandic kr\\u00f3nur1.00",
   3987         "Indian Rupee1.00",
   3988         "Indian rupee1.00",
   3989         "Indian rupees1.00",
   3990         "Indonesian Rupiah1.00",
   3991         "Indonesian rupiah1.00",
   3992         "Indonesian rupiahs1.00",
   3993         "Iranian Rial1.00",
   3994         "Iranian rial1.00",
   3995         "Iranian rials1.00",
   3996         "Iraqi Dinar1.00",
   3997         "Iraqi dinar1.00",
   3998         "Iraqi dinars1.00",
   3999         "Irish Pound1.00",
   4000         "Irish pound1.00",
   4001         "Irish pounds1.00",
   4002         "Israeli Pound1.00",
   4003         "Israeli new sheqel1.00",
   4004         "Israeli pound1.00",
   4005         "Israeli pounds1.00",
   4006         "Italian Lira1.00",
   4007         "Italian lira1.00",
   4008         "Italian liras1.00",
   4009         "JMD1.00",
   4010         "JOD1.00",
   4011         "JPY1.00",
   4012         "Jamaican Dollar1.00",
   4013         "Jamaican dollar1.00",
   4014         "Jamaican dollars1.00",
   4015         "Japanese Yen1.00",
   4016         "Japanese yen1.00",
   4017         "Jordanian Dinar1.00",
   4018         "Jordanian dinar1.00",
   4019         "Jordanian dinars1.00",
   4020         "KES1.00",
   4021         "KGS1.00",
   4022         "KHR1.00",
   4023         "KMF1.00",
   4024         "KPW1.00",
   4025         "KPW1.00",
   4026         "KRW1.00",
   4027         "KWD1.00",
   4028         "KYD1.00",
   4029         "KYD1.00",
   4030         "KZT1.00",
   4031         "Kazakhstani Tenge1.00",
   4032         "Kazakhstani tenge1.00",
   4033         "Kazakhstani tenges1.00",
   4034         "Kenyan Shilling1.00",
   4035         "Kenyan shilling1.00",
   4036         "Kenyan shillings1.00",
   4037         "Kuwaiti Dinar1.00",
   4038         "Kuwaiti dinar1.00",
   4039         "Kuwaiti dinars1.00",
   4040         "Kyrgystani Som1.00",
   4041         "Kyrgystani som1.00",
   4042         "Kyrgystani soms1.00",
   4043         "HNL1.00",
   4044         "LAK1.00",
   4045         "LAK1.00",
   4046         "LBP1.00",
   4047         "LKR1.00",
   4048         "LRD1.00",
   4049         "LRD1.00",
   4050         "LSL1.00",
   4051         "LTL1.00",
   4052         "LTL1.00",
   4053         "LTT1.00",
   4054         "LTT1.00",
   4055         "LUC1.00",
   4056         "LUC1.00",
   4057         "LUF1.00",
   4058         "LUF1.00",
   4059         "LUL1.00",
   4060         "LUL1.00",
   4061         "LVL1.00",
   4062         "LVL1.00",
   4063         "LVR1.00",
   4064         "LVR1.00",
   4065         "LYD1.00",
   4066         "Laotian Kip1.00",
   4067         "Laotian kip1.00",
   4068         "Laotian kips1.00",
   4069         "Latvian Lats1.00",
   4070         "Latvian Ruble1.00",
   4071         "Latvian lats1.00",
   4072         "Latvian lati1.00",
   4073         "Latvian ruble1.00",
   4074         "Latvian rubles1.00",
   4075         "Lebanese Pound1.00",
   4076         "Lebanese pound1.00",
   4077         "Lebanese pounds1.00",
   4078         "Lesotho Loti1.00",
   4079         "Lesotho loti1.00",
   4080         "Lesotho lotis1.00",
   4081         "Liberian Dollar1.00",
   4082         "Liberian dollar1.00",
   4083         "Liberian dollars1.00",
   4084         "Libyan Dinar1.00",
   4085         "Libyan dinar1.00",
   4086         "Libyan dinars1.00",
   4087         "Lithuanian Litas1.00",
   4088         "Lithuanian Talonas1.00",
   4089         "Lithuanian litas1.00",
   4090         "Lithuanian litai1.00",
   4091         "Lithuanian talonas1.00",
   4092         "Lithuanian talonases1.00",
   4093         "Luxembourgian Convertible Franc1.00",
   4094         "Luxembourg Financial Franc1.00",
   4095         "Luxembourgian Franc1.00",
   4096         "Luxembourgian convertible franc1.00",
   4097         "Luxembourgian convertible francs1.00",
   4098         "Luxembourg financial franc1.00",
   4099         "Luxembourg financial francs1.00",
   4100         "Luxembourgian franc1.00",
   4101         "Luxembourgian francs1.00",
   4102         "MAD1.00",
   4103         "MAD1.00",
   4104         "MAF1.00",
   4105         "MAF1.00",
   4106         "MDL1.00",
   4107         "MDL1.00",
   4108         "MX$1.00",
   4109         "MGA1.00",
   4110         "MGA1.00",
   4111         "MGF1.00",
   4112         "MGF1.00",
   4113         "MKD1.00",
   4114         "MLF1.00",
   4115         "MLF1.00",
   4116         "MMK1.00",
   4117         "MMK1.00",
   4118         "MNT1.00",
   4119         "MOP1.00",
   4120         "MOP1.00",
   4121         "MRO1.00",
   4122         "MTL1.00",
   4123         "MTP1.00",
   4124         "MTP1.00",
   4125         "MUR1.00",
   4126         "MUR1.00",
   4127         "MVR1.00",
   4128         "MVR1.00",
   4129         "MWK1.00",
   4130         "MXN1.00",
   4131         "MXP1.00",
   4132         "MXP1.00",
   4133         "MXV1.00",
   4134         "MXV1.00",
   4135         "MYR1.00",
   4136         "MZE1.00",
   4137         "MZE1.00",
   4138         "MZM1.00",
   4139         "MZN1.00",
   4140         "Macanese Pataca1.00",
   4141         "Macanese pataca1.00",
   4142         "Macanese patacas1.00",
   4143         "Macedonian Denar1.00",
   4144         "Macedonian denar1.00",
   4145         "Macedonian denari1.00",
   4146         "Malagasy Ariaries1.00",
   4147         "Malagasy Ariary1.00",
   4148         "Malagasy Ariary1.00",
   4149         "Malagasy Franc1.00",
   4150         "Malagasy franc1.00",
   4151         "Malagasy francs1.00",
   4152         "Malawian Kwacha1.00",
   4153         "Malawian Kwacha1.00",
   4154         "Malawian Kwachas1.00",
   4155         "Malaysian Ringgit1.00",
   4156         "Malaysian ringgit1.00",
   4157         "Malaysian ringgits1.00",
   4158         "Maldivian Rufiyaa1.00",
   4159         "Maldivian rufiyaa1.00",
   4160         "Maldivian rufiyaas1.00",
   4161         "Malian Franc1.00",
   4162         "Malian franc1.00",
   4163         "Malian francs1.00",
   4164         "Maltese Lira1.00",
   4165         "Maltese Pound1.00",
   4166         "Maltese lira1.00",
   4167         "Maltese lira1.00",
   4168         "Maltese pound1.00",
   4169         "Maltese pounds1.00",
   4170         "Mauritanian Ouguiya1.00",
   4171         "Mauritanian ouguiya1.00",
   4172         "Mauritanian ouguiyas1.00",
   4173         "Mauritian Rupee1.00",
   4174         "Mauritian rupee1.00",
   4175         "Mauritian rupees1.00",
   4176         "Mexican Peso1.00",
   4177         "Mexican Silver Peso (1861-1992)1.00",
   4178         "Mexican Investment Unit1.00",
   4179         "Mexican peso1.00",
   4180         "Mexican pesos1.00",
   4181         "Mexican silver peso (1861-1992)1.00",
   4182         "Mexican silver pesos (1861-1992)1.00",
   4183         "Mexican investment unit1.00",
   4184         "Mexican investment units1.00",
   4185         "Moldovan Leu1.00",
   4186         "Moldovan leu1.00",
   4187         "Moldovan lei1.00",
   4188         "Mongolian Tugrik1.00",
   4189         "Mongolian tugrik1.00",
   4190         "Mongolian tugriks1.00",
   4191         "Moroccan Dirham1.00",
   4192         "Moroccan Franc1.00",
   4193         "Moroccan dirham1.00",
   4194         "Moroccan dirhams1.00",
   4195         "Moroccan franc1.00",
   4196         "Moroccan francs1.00",
   4197         "Mozambican Escudo1.00",
   4198         "Mozambican Metical1.00",
   4199         "Mozambican escudo1.00",
   4200         "Mozambican escudos1.00",
   4201         "Mozambican metical1.00",
   4202         "Mozambican meticals1.00",
   4203         "Myanma Kyat1.00",
   4204         "Myanma kyat1.00",
   4205         "Myanma kyats1.00",
   4206         "NAD1.00",
   4207         "NGN1.00",
   4208         "NIC1.00",
   4209         "NIO1.00",
   4210         "NIO1.00",
   4211         "NLG1.00",
   4212         "NLG1.00",
   4213         "NOK1.00",
   4214         "NPR1.00",
   4215         "NT$1.00",
   4216         "NZ$1.00",
   4217         "NZD1.00",
   4218         "Namibian Dollar1.00",
   4219         "Namibian dollar1.00",
   4220         "Namibian dollars1.00",
   4221         "Nepalese Rupee1.00",
   4222         "Nepalese rupee1.00",
   4223         "Nepalese rupees1.00",
   4224         "Netherlands Antillean Guilder1.00",
   4225         "Netherlands Antillean guilder1.00",
   4226         "Netherlands Antillean guilders1.00",
   4227         "Dutch Guilder1.00",
   4228         "Dutch guilder1.00",
   4229         "Dutch guilders1.00",
   4230         "Israeli New Sheqel1.00",
   4231         "Israeli New Sheqels1.00",
   4232         "New Zealand Dollar1.00",
   4233         "New Zealand dollar1.00",
   4234         "New Zealand dollars1.00",
   4235         "Nicaraguan C\\u00f3rdoba1.00",
   4236         "Nicaraguan C\\u00f3rdoba (1988-1991)1.00",
   4237         "Nicaraguan c\\u00f3rdoba1.00",
   4238         "Nicaraguan c\\u00f3rdobas1.00",
   4239         "Nicaraguan c\\u00f3rdoba (1988-1991)1.00",
   4240         "Nicaraguan c\\u00f3rdobas (1988-1991)1.00",
   4241         "Nigerian Naira1.00",
   4242         "Nigerian naira1.00",
   4243         "Nigerian nairas1.00",
   4244         "North Korean Won1.00",
   4245         "North Korean won1.00",
   4246         "North Korean won1.00",
   4247         "Norwegian Krone1.00",
   4248         "Norwegian krone1.00",
   4249         "Norwegian kroner1.00",
   4250         "OMR1.00",
   4251         "Mozambican Metical (1980-2006)1.00",
   4252         "Mozambican metical (1980-2006)1.00",
   4253         "Mozambican meticals (1980-2006)1.00",
   4254         "Romanian Lei (1952-2006)1.00",
   4255         "Romanian Leu (1952-2006)1.00",
   4256         "Romanian leu (1952-2006)1.00",
   4257         "Serbian Dinar (2002-2006)1.00",
   4258         "Serbian dinar (2002-2006)1.00",
   4259         "Serbian dinars (2002-2006)1.00",
   4260         "Sudanese Dinar (1992-2007)1.00",
   4261         "Sudanese Pound (1957-1998)1.00",
   4262         "Sudanese dinar (1992-2007)1.00",
   4263         "Sudanese dinars (1992-2007)1.00",
   4264         "Sudanese pound (1957-1998)1.00",
   4265         "Sudanese pounds (1957-1998)1.00",
   4266         "Turkish Lira (1922-2005)1.00",
   4267         "Turkish Lira (1922-2005)1.00",
   4268         "Omani Rial1.00",
   4269         "Omani rial1.00",
   4270         "Omani rials1.00",
   4271         "PAB1.00",
   4272         "PAB1.00",
   4273         "PEI1.00",
   4274         "PEI1.00",
   4275         "PEN1.00",
   4276         "PEN1.00",
   4277         "PES1.00",
   4278         "PES1.00",
   4279         "PGK1.00",
   4280         "PGK1.00",
   4281         "PHP1.00",
   4282         "PKR1.00",
   4283         "PLN1.00",
   4284         "PLZ1.00",
   4285         "PLZ1.00",
   4286         "PTE1.00",
   4287         "PTE1.00",
   4288         "PYG1.00",
   4289         "Pakistani Rupee1.00",
   4290         "Pakistani rupee1.00",
   4291         "Pakistani rupees1.00",
   4292         "Palladium1.00",
   4293         "Palladium1.00",
   4294         "Panamanian Balboa1.00",
   4295         "Panamanian balboa1.00",
   4296         "Panamanian balboas1.00",
   4297         "Papua New Guinean Kina1.00",
   4298         "Papua New Guinean kina1.00",
   4299         "Papua New Guinean kina1.00",
   4300         "Paraguayan Guarani1.00",
   4301         "Paraguayan guarani1.00",
   4302         "Paraguayan guaranis1.00",
   4303         "Peruvian Inti1.00",
   4304         "Peruvian Nuevo Sol1.00",
   4305         "Peruvian Sol (1863-1965)1.00",
   4306         "Peruvian inti1.00",
   4307         "Peruvian intis1.00",
   4308         "Peruvian nuevo sol1.00",
   4309         "Peruvian nuevos soles1.00",
   4310         "Peruvian sol (1863-1965)1.00",
   4311         "Peruvian soles (1863-1965)1.00",
   4312         "Philippine Peso1.00",
   4313         "Philippine peso1.00",
   4314         "Philippine pesos1.00",
   4315         "Platinum1.00",
   4316         "Platinum1.00",
   4317         "Polish Zloty (1950-1995)1.00",
   4318         "Polish Zloty1.00",
   4319         "Polish zlotys1.00",
   4320         "Polish zloty (PLZ)1.00",
   4321         "Polish zloty1.00",
   4322         "Polish zlotys (PLZ)1.00",
   4323         "Portuguese Escudo1.00",
   4324         "Portuguese Guinea Escudo1.00",
   4325         "Portuguese Guinea escudo1.00",
   4326         "Portuguese Guinea escudos1.00",
   4327         "Portuguese escudo1.00",
   4328         "Portuguese escudos1.00",
   4329         "GTQ1.00",
   4330         "QAR1.00",
   4331         "Qatari Rial1.00",
   4332         "Qatari rial1.00",
   4333         "Qatari rials1.00",
   4334         "RHD1.00",
   4335         "RHD1.00",
   4336         "RINET Funds1.00",
   4337         "RINET Funds1.00",
   4338         "CN\\u00a51.00",
   4339         "ROL1.00",
   4340         "ROL1.00",
   4341         "RON1.00",
   4342         "RON1.00",
   4343         "RSD1.00",
   4344         "RSD1.00",
   4345         "RUB1.00",
   4346         "RUB1.00",
   4347         "RUR1.00",
   4348         "RUR1.00",
   4349         "RWF1.00",
   4350         "RWF1.00",
   4351         "Rhodesian Dollar1.00",
   4352         "Rhodesian dollar1.00",
   4353         "Rhodesian dollars1.00",
   4354         "Romanian Leu1.00",
   4355         "Romanian lei1.00",
   4356         "Romanian leu1.00",
   4357         "Russian Ruble (1991-1998)1.00",
   4358         "Russian Ruble1.00",
   4359         "Russian ruble (1991-1998)1.00",
   4360         "Russian ruble1.00",
   4361         "Russian rubles (1991-1998)1.00",
   4362         "Russian rubles1.00",
   4363         "Rwandan Franc1.00",
   4364         "Rwandan franc1.00",
   4365         "Rwandan francs1.00",
   4366         "SAR1.00",
   4367         "SBD1.00",
   4368         "SCR1.00",
   4369         "SDD1.00",
   4370         "SDD1.00",
   4371         "SDG1.00",
   4372         "SDG1.00",
   4373         "SDP1.00",
   4374         "SDP1.00",
   4375         "SEK1.00",
   4376         "SGD1.00",
   4377         "SHP1.00",
   4378         "SHP1.00",
   4379         "SIT1.00",
   4380         "SIT1.00",
   4381         "SKK1.00",
   4382         "SLL1.00",
   4383         "SLL1.00",
   4384         "SOS1.00",
   4385         "SRD1.00",
   4386         "SRD1.00",
   4387         "SRG1.00",
   4388         "STD1.00",
   4389         "SUR1.00",
   4390         "SUR1.00",
   4391         "SVC1.00",
   4392         "SVC1.00",
   4393         "SYP1.00",
   4394         "SZL1.00",
   4395         "Saint Helena Pound1.00",
   4396         "Saint Helena pound1.00",
   4397         "Saint Helena pounds1.00",
   4398         "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra1.00",
   4399         "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra1.00",
   4400         "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras1.00",
   4401         "Saudi Riyal1.00",
   4402         "Saudi riyal1.00",
   4403         "Saudi riyals1.00",
   4404         "Serbian Dinar1.00",
   4405         "Serbian dinar1.00",
   4406         "Serbian dinars1.00",
   4407         "Seychellois Rupee1.00",
   4408         "Seychellois rupee1.00",
   4409         "Seychellois rupees1.00",
   4410         "Sierra Leonean Leone1.00",
   4411         "Sierra Leonean leone1.00",
   4412         "Sierra Leonean leones1.00",
   4413         "Silver1.00",
   4414         "Silver1.00",
   4415         "Singapore Dollar1.00",
   4416         "Singapore dollar1.00",
   4417         "Singapore dollars1.00",
   4418         "Slovak Koruna1.00",
   4419         "Slovak koruna1.00",
   4420         "Slovak korunas1.00",
   4421         "Slovenian Tolar1.00",
   4422         "Slovenian tolar1.00",
   4423         "Slovenian tolars1.00",
   4424         "Solomon Islands Dollar1.00",
   4425         "Solomon Islands dollar1.00",
   4426         "Solomon Islands dollars1.00",
   4427         "Somali Shilling1.00",
   4428         "Somali shilling1.00",
   4429         "Somali shillings1.00",
   4430         "South African Rand (financial)1.00",
   4431         "South African Rand1.00",
   4432         "South African rand (financial)1.00",
   4433         "South African rand1.00",
   4434         "South African rands (financial)1.00",
   4435         "South African rand1.00",
   4436         "South Korean Won1.00",
   4437         "South Korean won1.00",
   4438         "South Korean won1.00",
   4439         "Soviet Rouble1.00",
   4440         "Soviet rouble1.00",
   4441         "Soviet roubles1.00",
   4442         "Spanish Peseta (A account)1.00",
   4443         "Spanish Peseta (convertible account)1.00",
   4444         "Spanish Peseta1.00",
   4445         "Spanish peseta (A account)1.00",
   4446         "Spanish peseta (convertible account)1.00",
   4447         "Spanish peseta1.00",
   4448         "Spanish pesetas (A account)1.00",
   4449         "Spanish pesetas (convertible account)1.00",
   4450         "Spanish pesetas1.00",
   4451         "Special Drawing Rights1.00",
   4452         "Sri Lankan Rupee1.00",
   4453         "Sri Lankan rupee1.00",
   4454         "Sri Lankan rupees1.00",
   4455         "Sudanese Pound1.00",
   4456         "Sudanese pound1.00",
   4457         "Sudanese pounds1.00",
   4458         "Surinamese Dollar1.00",
   4459         "Surinamese dollar1.00",
   4460         "Surinamese dollars1.00",
   4461         "Surinamese Guilder1.00",
   4462         "Surinamese guilder1.00",
   4463         "Surinamese guilders1.00",
   4464         "Swazi Lilangeni1.00",
   4465         "Swazi lilangeni1.00",
   4466         "Swazi emalangeni1.00",
   4467         "Swedish Krona1.00",
   4468         "Swedish krona1.00",
   4469         "Swedish kronor1.00",
   4470         "Swiss Franc1.00",
   4471         "Swiss franc1.00",
   4472         "Swiss francs1.00",
   4473         "Syrian Pound1.00",
   4474         "Syrian pound1.00",
   4475         "Syrian pounds1.00",
   4476         "THB1.00",
   4477         "TJR1.00",
   4478         "TJR1.00",
   4479         "TJS1.00",
   4480         "TJS1.00",
   4481         "TMM1.00",
   4482         "TMM1.00",
   4483         "TND1.00",
   4484         "TND1.00",
   4485         "TOP1.00",
   4486         "TPE1.00",
   4487         "TPE1.00",
   4488         "TRL1.00",
   4489         "TRY1.00",
   4490         "TRY1.00",
   4491         "TTD1.00",
   4492         "TWD1.00",
   4493         "TZS1.00",
   4494         "New Taiwan Dollar1.00",
   4495         "New Taiwan dollar1.00",
   4496         "New Taiwan dollars1.00",
   4497         "Tajikistani Ruble1.00",
   4498         "Tajikistani Somoni1.00",
   4499         "Tajikistani ruble1.00",
   4500         "Tajikistani rubles1.00",
   4501         "Tajikistani somoni1.00",
   4502         "Tajikistani somonis1.00",
   4503         "Tanzanian Shilling1.00",
   4504         "Tanzanian shilling1.00",
   4505         "Tanzanian shillings1.00",
   4506         "Testing Currency Code1.00",
   4507         "Testing Currency Code1.00",
   4508         "Thai Baht1.00",
   4509         "Thai baht1.00",
   4510         "Thai baht1.00",
   4511         "Timorese Escudo1.00",
   4512         "Timorese escudo1.00",
   4513         "Timorese escudos1.00",
   4514         "Tongan Pa\\u02bbanga1.00",
   4515         "Tongan pa\\u02bbanga1.00",
   4516         "Tongan pa\\u02bbanga1.00",
   4517         "Trinidad and Tobago Dollar1.00",
   4518         "Trinidad and Tobago dollar1.00",
   4519         "Trinidad and Tobago dollars1.00",
   4520         "Tunisian Dinar1.00",
   4521         "Tunisian dinar1.00",
   4522         "Tunisian dinars1.00",
   4523         "Turkish Lira1.00",
   4524         "Turkish Lira1.00",
   4525         "Turkish lira1.00",
   4526         "Turkmenistani Manat1.00",
   4527         "Turkmenistani manat1.00",
   4528         "Turkmenistani manat1.00",
   4529         "UAE dirham1.00",
   4530         "UAE dirhams1.00",
   4531         "UAH1.00",
   4532         "UAK1.00",
   4533         "UAK1.00",
   4534         "UGS1.00",
   4535         "UGS1.00",
   4536         "UGX1.00",
   4537         "US Dollar (Next day)1.00",
   4538         "US Dollar (Same day)1.00",
   4539         "US Dollar1.00",
   4540         "US dollar (next day)1.00",
   4541         "US dollar (same day)1.00",
   4542         "US dollar1.00",
   4543         "US dollars (next day)1.00",
   4544         "US dollars (same day)1.00",
   4545         "US dollars1.00",
   4546         "USD1.00",
   4547         "USN1.00",
   4548         "USN1.00",
   4549         "USS1.00",
   4550         "USS1.00",
   4551         "UYI1.00",
   4552         "UYI1.00",
   4553         "UYP1.00",
   4554         "UYP1.00",
   4555         "UYU1.00",
   4556         "UZS1.00",
   4557         "UZS1.00",
   4558         "Ugandan Shilling (1966-1987)1.00",
   4559         "Ugandan Shilling1.00",
   4560         "Ugandan shilling (1966-1987)1.00",
   4561         "Ugandan shilling1.00",
   4562         "Ugandan shillings (1966-1987)1.00",
   4563         "Ugandan shillings1.00",
   4564         "Ukrainian Hryvnia1.00",
   4565         "Ukrainian Karbovanets1.00",
   4566         "Ukrainian hryvnia1.00",
   4567         "Ukrainian hryvnias1.00",
   4568         "Ukrainian karbovanets1.00",
   4569         "Ukrainian karbovantsiv1.00",
   4570         "Colombian Real Value Unit1.00",
   4571         "United Arab Emirates Dirham1.00",
   4572         "Unknown Currency1.00",
   4573         "Uruguayan Peso (1975-1993)1.00",
   4574         "Uruguayan Peso1.00",
   4575         "Uruguayan Peso (Indexed Units)1.00",
   4576         "Uruguayan peso (1975-1993)1.00",
   4577         "Uruguayan peso (indexed units)1.00",
   4578         "Uruguayan peso1.00",
   4579         "Uruguayan pesos (1975-1993)1.00",
   4580         "Uruguayan pesos (indexed units)1.00",
   4581         "Uruguayan pesos1.00",
   4582         "Uzbekistan Som1.00",
   4583         "Uzbekistan som1.00",
   4584         "Uzbekistan som1.00",
   4585         "VEB1.00",
   4586         "VEF1.00",
   4587         "VND1.00",
   4588         "VUV1.00",
   4589         "Vanuatu Vatu1.00",
   4590         "Vanuatu vatu1.00",
   4591         "Vanuatu vatus1.00",
   4592         "Venezuelan Bol\\u00edvar1.00",
   4593         "Venezuelan Bol\\u00edvar (1871-2008)1.00",
   4594         "Venezuelan bol\\u00edvar1.00",
   4595         "Venezuelan bol\\u00edvars1.00",
   4596         "Venezuelan bol\\u00edvar (1871-2008)1.00",
   4597         "Venezuelan bol\\u00edvars (1871-2008)1.00",
   4598         "Vietnamese Dong1.00",
   4599         "Vietnamese dong1.00",
   4600         "Vietnamese dong1.00",
   4601         "WIR Euro1.00",
   4602         "WIR Franc1.00",
   4603         "WIR euro1.00",
   4604         "WIR euros1.00",
   4605         "WIR franc1.00",
   4606         "WIR francs1.00",
   4607         "WST1.00",
   4608         "WST1.00",
   4609         "Samoan Tala1.00",
   4610         "Samoan tala1.00",
   4611         "Samoan tala1.00",
   4612         "XAF1.00",
   4613         "XAF1.00",
   4614         "XAG1.00",
   4615         "XAG1.00",
   4616         "XAU1.00",
   4617         "XAU1.00",
   4618         "XBA1.00",
   4619         "XBA1.00",
   4620         "XBB1.00",
   4621         "XBB1.00",
   4622         "XBC1.00",
   4623         "XBC1.00",
   4624         "XBD1.00",
   4625         "XBD1.00",
   4626         "XCD1.00",
   4627         "XDR1.00",
   4628         "XDR1.00",
   4629         "XEU1.00",
   4630         "XEU1.00",
   4631         "XFO1.00",
   4632         "XFO1.00",
   4633         "XFU1.00",
   4634         "XFU1.00",
   4635         "XOF1.00",
   4636         "XOF1.00",
   4637         "XPD1.00",
   4638         "XPD1.00",
   4639         "XPF1.00",
   4640         "XPT1.00",
   4641         "XPT1.00",
   4642         "XRE1.00",
   4643         "XRE1.00",
   4644         "XTS1.00",
   4645         "XTS1.00",
   4646         "XXX1.00",
   4647         "XXX1.00",
   4648         "YDD1.00",
   4649         "YDD1.00",
   4650         "YER1.00",
   4651         "YUD1.00",
   4652         "YUD1.00",
   4653         "YUM1.00",
   4654         "YUM1.00",
   4655         "YUN1.00",
   4656         "YUN1.00",
   4657         "Yemeni Dinar1.00",
   4658         "Yemeni Rial1.00",
   4659         "Yemeni dinar1.00",
   4660         "Yemeni dinars1.00",
   4661         "Yemeni rial1.00",
   4662         "Yemeni rials1.00",
   4663         "Yugoslavian Convertible Dinar (1990-1992)1.00",
   4664         "Yugoslavian Hard Dinar (1966-1990)1.00",
   4665         "Yugoslavian New Dinar (1994-2002)1.00",
   4666         "Yugoslavian convertible dinar (1990-1992)1.00",
   4667         "Yugoslavian convertible dinars (1990-1992)1.00",
   4668         "Yugoslavian hard dinar (1966-1990)1.00",
   4669         "Yugoslavian hard dinars (1966-1990)1.00",
   4670         "Yugoslavian new dinar (1994-2002)1.00",
   4671         "Yugoslavian new dinars (1994-2002)1.00",
   4672         "ZAL1.00",
   4673         "ZAL1.00",
   4674         "ZAR1.00",
   4675         "ZMK1.00",
   4676         "ZMK1.00",
   4677         "ZRN1.00",
   4678         "ZRN1.00",
   4679         "ZRZ1.00",
   4680         "ZRZ1.00",
   4681         "ZWD1.00",
   4682         "Zairean New Zaire (1993-1998)1.00",
   4683         "Zairean Zaire (1971-1993)1.00",
   4684         "Zairean new zaire (1993-1998)1.00",
   4685         "Zairean new zaires (1993-1998)1.00",
   4686         "Zairean zaire (1971-1993)1.00",
   4687         "Zairean zaires (1971-1993)1.00",
   4688         "Zambian Kwacha1.00",
   4689         "Zambian kwacha1.00",
   4690         "Zambian kwachas1.00",
   4691         "Zimbabwean Dollar (1980-2008)1.00",
   4692         "Zimbabwean dollar (1980-2008)1.00",
   4693         "Zimbabwean dollars (1980-2008)1.00",
   4694         "euro1.00",
   4695         "euros1.00",
   4696         "Turkish lira (1922-2005)1.00",
   4697         "special drawing rights1.00",
   4698         "Colombian real value unit1.00",
   4699         "Colombian real value units1.00",
   4700         "unknown currency1.00",
   4701         "\\u00a31.00",
   4702         "\\u00a51.00",
   4703         "\\u0e3f1.00",
   4704         "\\u20ab1.00",
   4705         "\\u20aa1.00",
   4706         "\\u20ac1.00",
   4707         "\\u20b91.00",
   4708         //
   4709         // Following has extra text, should be parsed correctly too
   4710         "$1.00 random",
   4711         "USD1.00 random",
   4712         "1.00 US dollar random",
   4713         "1.00 US dollars random",
   4714         "1.00 Afghan Afghani random",
   4715         "1.00 Afghan Afghani random",
   4716         "1.00 Afghan Afghanis (1927-1992) random",
   4717         "1.00 Afghan Afghanis random",
   4718         "1.00 Albanian Lek random",
   4719         "1.00 Albanian lek random",
   4720         "1.00 Albanian lek\\u00eb random",
   4721         "1.00 Algerian Dinar random",
   4722         "1.00 Algerian dinar random",
   4723         "1.00 Algerian dinars random",
   4724         "1.00 Andorran Peseta random",
   4725         "1.00 Andorran peseta random",
   4726         "1.00 Andorran pesetas random",
   4727         "1.00 Angolan Kwanza (1977-1990) random",
   4728         "1.00 Angolan Readjusted Kwanza (1995-1999) random",
   4729         "1.00 Angolan Kwanza random",
   4730         "1.00 Angolan New Kwanza (1990-2000) random",
   4731         "1.00 Angolan kwanza (1977-1991) random",
   4732         "1.00 Angolan readjusted kwanza (1995-1999) random",
   4733         "1.00 Angolan kwanza random",
   4734         "1.00 Angolan kwanzas (1977-1991) random",
   4735         "1.00 Angolan readjusted kwanzas (1995-1999) random",
   4736         "1.00 Angolan kwanzas random",
   4737         "1.00 Angolan new kwanza (1990-2000) random",
   4738         "1.00 Angolan new kwanzas (1990-2000) random",
   4739         "1.00 Argentine Austral random",
   4740         "1.00 Argentine Peso (1983-1985) random",
   4741         "1.00 Argentine Peso random",
   4742         "1.00 Argentine austral random",
   4743         "1.00 Argentine australs random",
   4744         "1.00 Argentine peso (1983-1985) random",
   4745         "1.00 Argentine peso random",
   4746         "1.00 Argentine pesos (1983-1985) random",
   4747         "1.00 Argentine pesos random",
   4748         "1.00 Armenian Dram random",
   4749         "1.00 Armenian dram random",
   4750         "1.00 Armenian drams random",
   4751         "1.00 Aruban Florin random",
   4752         "1.00 Aruban florin random",
   4753         "1.00 Australian Dollar random",
   4754         "1.00 Australian dollar random",
   4755         "1.00 Australian dollars random",
   4756         "1.00 Austrian Schilling random",
   4757         "1.00 Austrian schilling random",
   4758         "1.00 Austrian schillings random",
   4759         "1.00 Azerbaijani Manat (1993-2006) random",
   4760         "1.00 Azerbaijani Manat random",
   4761         "1.00 Azerbaijani manat (1993-2006) random",
   4762         "1.00 Azerbaijani manat random",
   4763         "1.00 Azerbaijani manats (1993-2006) random",
   4764         "1.00 Azerbaijani manats random",
   4765         "1.00 Bahamian Dollar random",
   4766         "1.00 Bahamian dollar random",
   4767         "1.00 Bahamian dollars random",
   4768         "1.00 Bahraini Dinar random",
   4769         "1.00 Bahraini dinar random",
   4770         "1.00 Bahraini dinars random",
   4771         "1.00 Bangladeshi Taka random",
   4772         "1.00 Bangladeshi taka random",
   4773         "1.00 Bangladeshi takas random",
   4774         "1.00 Barbadian Dollar random",
   4775         "1.00 Barbadian dollar random",
   4776         "1.00 Barbadian dollars random",
   4777         "1.00 Belarusian New Ruble (1994-1999) random",
   4778         "1.00 Belarusian Ruble random",
   4779         "1.00 Belarusian new ruble (1994-1999) random",
   4780         "1.00 Belarusian new rubles (1994-1999) random",
   4781         "1.00 Belarusian ruble random",
   4782         "1.00 Belarusian rubles random",
   4783         "1.00 Belgian Franc (convertible) random",
   4784         "1.00 Belgian Franc (financial) random",
   4785         "1.00 Belgian Franc random",
   4786         "1.00 Belgian franc (convertible) random",
   4787         "1.00 Belgian franc (financial) random",
   4788         "1.00 Belgian franc random",
   4789         "1.00 Belgian francs (convertible) random",
   4790         "1.00 Belgian francs (financial) random",
   4791         "1.00 Belgian francs random",
   4792         "1.00 Belize Dollar random",
   4793         "1.00 Belize dollar random",
   4794         "1.00 Belize dollars random",
   4795         "1.00 Bermudan Dollar random",
   4796         "1.00 Bermudan dollar random",
   4797         "1.00 Bermudan dollars random",
   4798         "1.00 Bhutanese Ngultrum random",
   4799         "1.00 Bhutanese ngultrum random",
   4800         "1.00 Bhutanese ngultrums random",
   4801         "1.00 Bolivian Mvdol random",
   4802         "1.00 Bolivian Peso random",
   4803         "1.00 Bolivian mvdol random",
   4804         "1.00 Bolivian mvdols random",
   4805         "1.00 Bolivian peso random",
   4806         "1.00 Bolivian pesos random",
   4807         "1.00 Bolivian Boliviano random",
   4808         "1.00 Bolivian Boliviano random",
   4809         "1.00 Bolivian Bolivianos random",
   4810         "1.00 Bosnia-Herzegovina Convertible Mark random",
   4811         "1.00 Bosnia-Herzegovina Dinar (1992-1994) random",
   4812         "1.00 Bosnia-Herzegovina convertible mark random",
   4813         "1.00 Bosnia-Herzegovina convertible marks random",
   4814         "1.00 Bosnia-Herzegovina dinar (1992-1994) random",
   4815         "1.00 Bosnia-Herzegovina dinars (1992-1994) random",
   4816         "1.00 Botswanan Pula random",
   4817         "1.00 Botswanan pula random",
   4818         "1.00 Botswanan pulas random",
   4819         "1.00 Brazilian New Cruzado (1989-1990) random",
   4820         "1.00 Brazilian Cruzado (1986-1989) random",
   4821         "1.00 Brazilian Cruzeiro (1990-1993) random",
   4822         "1.00 Brazilian New Cruzeiro (1967-1986) random",
   4823         "1.00 Brazilian Cruzeiro (1993-1994) random",
   4824         "1.00 Brazilian Real random",
   4825         "1.00 Brazilian new cruzado (1989-1990) random",
   4826         "1.00 Brazilian new cruzados (1989-1990) random",
   4827         "1.00 Brazilian cruzado (1986-1989) random",
   4828         "1.00 Brazilian cruzados (1986-1989) random",
   4829         "1.00 Brazilian cruzeiro (1990-1993) random",
   4830         "1.00 Brazilian new cruzeiro (1967-1986) random",
   4831         "1.00 Brazilian cruzeiro (1993-1994) random",
   4832         "1.00 Brazilian cruzeiros (1990-1993) random",
   4833         "1.00 Brazilian new cruzeiros (1967-1986) random",
   4834         "1.00 Brazilian cruzeiros (1993-1994) random",
   4835         "1.00 Brazilian real random",
   4836         "1.00 Brazilian reals random",
   4837         "1.00 British Pound Sterling random",
   4838         "1.00 British pound sterling random",
   4839         "1.00 British pounds sterling random",
   4840         "1.00 Brunei Dollar random",
   4841         "1.00 Brunei dollar random",
   4842         "1.00 Brunei dollars random",
   4843         "1.00 Bulgarian Hard Lev random",
   4844         "1.00 Bulgarian Lev random",
   4845         "1.00 Bulgarian Leva random",
   4846         "1.00 Bulgarian hard lev random",
   4847         "1.00 Bulgarian hard leva random",
   4848         "1.00 Bulgarian lev random",
   4849         "1.00 Burmese Kyat random",
   4850         "1.00 Burmese kyat random",
   4851         "1.00 Burmese kyats random",
   4852         "1.00 Burundian Franc random",
   4853         "1.00 Burundian franc random",
   4854         "1.00 Burundian francs random",
   4855         "1.00 Cambodian Riel random",
   4856         "1.00 Cambodian riel random",
   4857         "1.00 Cambodian riels random",
   4858         "1.00 Canadian Dollar random",
   4859         "1.00 Canadian dollar random",
   4860         "1.00 Canadian dollars random",
   4861         "1.00 Cape Verdean Escudo random",
   4862         "1.00 Cape Verdean escudo random",
   4863         "1.00 Cape Verdean escudos random",
   4864         "1.00 Cayman Islands Dollar random",
   4865         "1.00 Cayman Islands dollar random",
   4866         "1.00 Cayman Islands dollars random",
   4867         "1.00 Chilean Peso random",
   4868         "1.00 Chilean Unit of Account (UF) random",
   4869         "1.00 Chilean peso random",
   4870         "1.00 Chilean pesos random",
   4871         "1.00 Chilean unit of account (UF) random",
   4872         "1.00 Chilean units of account (UF) random",
   4873         "1.00 Chinese Yuan random",
   4874         "1.00 Chinese yuan random",
   4875         "1.00 Colombian Peso random",
   4876         "1.00 Colombian peso random",
   4877         "1.00 Colombian pesos random",
   4878         "1.00 Comorian Franc random",
   4879         "1.00 Comorian franc random",
   4880         "1.00 Comorian francs random",
   4881         "1.00 Congolese Franc Congolais random",
   4882         "1.00 Congolese franc Congolais random",
   4883         "1.00 Congolese francs Congolais random",
   4884         "1.00 Costa Rican Col\\u00f3n random",
   4885         "1.00 Costa Rican col\\u00f3n random",
   4886         "1.00 Costa Rican col\\u00f3ns random",
   4887         "1.00 Croatian Dinar random",
   4888         "1.00 Croatian Kuna random",
   4889         "1.00 Croatian dinar random",
   4890         "1.00 Croatian dinars random",
   4891         "1.00 Croatian kuna random",
   4892         "1.00 Croatian kunas random",
   4893         "1.00 Cuban Peso random",
   4894         "1.00 Cuban peso random",
   4895         "1.00 Cuban pesos random",
   4896         "1.00 Cypriot Pound random",
   4897         "1.00 Cypriot pound random",
   4898         "1.00 Cypriot pounds random",
   4899         "1.00 Czech Republic Koruna random",
   4900         "1.00 Czech Republic koruna random",
   4901         "1.00 Czech Republic korunas random",
   4902         "1.00 Czechoslovak Hard Koruna random",
   4903         "1.00 Czechoslovak hard koruna random",
   4904         "1.00 Czechoslovak hard korunas random",
   4905         "1.00 Danish Krone random",
   4906         "1.00 Danish krone random",
   4907         "1.00 Danish kroner random",
   4908         "1.00 German Mark random",
   4909         "1.00 German mark random",
   4910         "1.00 German marks random",
   4911         "1.00 Djiboutian Franc random",
   4912         "1.00 Djiboutian franc random",
   4913         "1.00 Djiboutian francs random",
   4914         "1.00 Dominican Peso random",
   4915         "1.00 Dominican peso random",
   4916         "1.00 Dominican pesos random",
   4917         "1.00 East Caribbean Dollar random",
   4918         "1.00 East Caribbean dollar random",
   4919         "1.00 East Caribbean dollars random",
   4920         "1.00 East German Mark random",
   4921         "1.00 East German mark random",
   4922         "1.00 East German marks random",
   4923         "1.00 Ecuadorian Sucre random",
   4924         "1.00 Ecuadorian Unit of Constant Value random",
   4925         "1.00 Ecuadorian sucre random",
   4926         "1.00 Ecuadorian sucres random",
   4927         "1.00 Ecuadorian unit of constant value random",
   4928         "1.00 Ecuadorian units of constant value random",
   4929         "1.00 Egyptian Pound random",
   4930         "1.00 Egyptian pound random",
   4931         "1.00 Egyptian pounds random",
   4932         "1.00 Salvadoran Col\\u00f3n random",
   4933         "1.00 Salvadoran col\\u00f3n random",
   4934         "1.00 Salvadoran colones random",
   4935         "1.00 Equatorial Guinean Ekwele random",
   4936         "1.00 Equatorial Guinean ekwele random",
   4937         "1.00 Eritrean Nakfa random",
   4938         "1.00 Eritrean nakfa random",
   4939         "1.00 Eritrean nakfas random",
   4940         "1.00 Estonian Kroon random",
   4941         "1.00 Estonian kroon random",
   4942         "1.00 Estonian kroons random",
   4943         "1.00 Ethiopian Birr random",
   4944         "1.00 Ethiopian birr random",
   4945         "1.00 Ethiopian birrs random",
   4946         "1.00 European Composite Unit random",
   4947         "1.00 European Currency Unit random",
   4948         "1.00 European Monetary Unit random",
   4949         "1.00 European Unit of Account (XBC) random",
   4950         "1.00 European Unit of Account (XBD) random",
   4951         "1.00 European composite unit random",
   4952         "1.00 European composite units random",
   4953         "1.00 European currency unit random",
   4954         "1.00 European currency units random",
   4955         "1.00 European monetary unit random",
   4956         "1.00 European monetary units random",
   4957         "1.00 European unit of account (XBC) random",
   4958         "1.00 European unit of account (XBD) random",
   4959         "1.00 European units of account (XBC) random",
   4960         "1.00 European units of account (XBD) random",
   4961         "1.00 Falkland Islands Pound random",
   4962         "1.00 Falkland Islands pound random",
   4963         "1.00 Falkland Islands pounds random",
   4964         "1.00 Fijian Dollar random",
   4965         "1.00 Fijian dollar random",
   4966         "1.00 Fijian dollars random",
   4967         "1.00 Finnish Markka random",
   4968         "1.00 Finnish markka random",
   4969         "1.00 Finnish markkas random",
   4970         "1.00 French Franc random",
   4971         "1.00 French Gold Franc random",
   4972         "1.00 French UIC-Franc random",
   4973         "1.00 French UIC-franc random",
   4974         "1.00 French UIC-francs random",
   4975         "1.00 French franc random",
   4976         "1.00 French francs random",
   4977         "1.00 French gold franc random",
   4978         "1.00 French gold francs random",
   4979         "1.00 Gambian Dalasi random",
   4980         "1.00 Gambian dalasi random",
   4981         "1.00 Gambian dalasis random",
   4982         "1.00 Georgian Kupon Larit random",
   4983         "1.00 Georgian Lari random",
   4984         "1.00 Georgian kupon larit random",
   4985         "1.00 Georgian kupon larits random",
   4986         "1.00 Georgian lari random",
   4987         "1.00 Georgian laris random",
   4988         "1.00 Ghanaian Cedi (1979-2007) random",
   4989         "1.00 Ghanaian Cedi random",
   4990         "1.00 Ghanaian cedi (1979-2007) random",
   4991         "1.00 Ghanaian cedi random",
   4992         "1.00 Ghanaian cedis (1979-2007) random",
   4993         "1.00 Ghanaian cedis random",
   4994         "1.00 Gibraltar Pound random",
   4995         "1.00 Gibraltar pound random",
   4996         "1.00 Gibraltar pounds random",
   4997         "1.00 Gold random",
   4998         "1.00 Gold random",
   4999         "1.00 Greek Drachma random",
   5000         "1.00 Greek drachma random",
   5001         "1.00 Greek drachmas random",
   5002         "1.00 Guatemalan Quetzal random",
   5003         "1.00 Guatemalan quetzal random",
   5004         "1.00 Guatemalan quetzals random",
   5005         "1.00 Guinean Franc random",
   5006         "1.00 Guinean Syli random",
   5007         "1.00 Guinean franc random",
   5008         "1.00 Guinean francs random",
   5009         "1.00 Guinean syli random",
   5010         "1.00 Guinean sylis random",
   5011         "1.00 Guinea-Bissau Peso random",
   5012         "1.00 Guinea-Bissau peso random",
   5013         "1.00 Guinea-Bissau pesos random",
   5014         "1.00 Guyanaese Dollar random",
   5015         "1.00 Guyanaese dollar random",
   5016         "1.00 Guyanaese dollars random",
   5017         "1.00 Haitian Gourde random",
   5018         "1.00 Haitian gourde random",
   5019         "1.00 Haitian gourdes random",
   5020         "1.00 Honduran Lempira random",
   5021         "1.00 Honduran lempira random",
   5022         "1.00 Honduran lempiras random",
   5023         "1.00 Hong Kong Dollar random",
   5024         "1.00 Hong Kong dollar random",
   5025         "1.00 Hong Kong dollars random",
   5026         "1.00 Hungarian Forint random",
   5027         "1.00 Hungarian forint random",
   5028         "1.00 Hungarian forints random",
   5029         "1.00 Icelandic Kr\\u00f3na random",
   5030         "1.00 Icelandic kr\\u00f3na random",
   5031         "1.00 Icelandic kr\\u00f3nur random",
   5032         "1.00 Indian Rupee random",
   5033         "1.00 Indian rupee random",
   5034         "1.00 Indian rupees random",
   5035         "1.00 Indonesian Rupiah random",
   5036         "1.00 Indonesian rupiah random",
   5037         "1.00 Indonesian rupiahs random",
   5038         "1.00 Iranian Rial random",
   5039         "1.00 Iranian rial random",
   5040         "1.00 Iranian rials random",
   5041         "1.00 Iraqi Dinar random",
   5042         "1.00 Iraqi dinar random",
   5043         "1.00 Iraqi dinars random",
   5044         "1.00 Irish Pound random",
   5045         "1.00 Irish pound random",
   5046         "1.00 Irish pounds random",
   5047         "1.00 Israeli Pound random",
   5048         "1.00 Israeli new sheqel random",
   5049         "1.00 Israeli pound random",
   5050         "1.00 Israeli pounds random",
   5051         "1.00 Italian Lira random",
   5052         "1.00 Italian lira random",
   5053         "1.00 Italian liras random",
   5054         "1.00 Jamaican Dollar random",
   5055         "1.00 Jamaican dollar random",
   5056         "1.00 Jamaican dollars random",
   5057         "1.00 Japanese Yen random",
   5058         "1.00 Japanese yen random",
   5059         "1.00 Jordanian Dinar random",
   5060         "1.00 Jordanian dinar random",
   5061         "1.00 Jordanian dinars random",
   5062         "1.00 Kazakhstani Tenge random",
   5063         "1.00 Kazakhstani tenge random",
   5064         "1.00 Kazakhstani tenges random",
   5065         "1.00 Kenyan Shilling random",
   5066         "1.00 Kenyan shilling random",
   5067         "1.00 Kenyan shillings random",
   5068         "1.00 Kuwaiti Dinar random",
   5069         "1.00 Kuwaiti dinar random",
   5070         "1.00 Kuwaiti dinars random",
   5071         "1.00 Kyrgystani Som random",
   5072         "1.00 Kyrgystani som random",
   5073         "1.00 Kyrgystani soms random",
   5074         "1.00 Laotian Kip random",
   5075         "1.00 Laotian kip random",
   5076         "1.00 Laotian kips random",
   5077         "1.00 Latvian Lats random",
   5078         "1.00 Latvian Ruble random",
   5079         "1.00 Latvian lats random",
   5080         "1.00 Latvian lati random",
   5081         "1.00 Latvian ruble random",
   5082         "1.00 Latvian rubles random",
   5083         "1.00 Lebanese Pound random",
   5084         "1.00 Lebanese pound random",
   5085         "1.00 Lebanese pounds random",
   5086         "1.00 Lesotho Loti random",
   5087         "1.00 Lesotho loti random",
   5088         "1.00 Lesotho lotis random",
   5089         "1.00 Liberian Dollar random",
   5090         "1.00 Liberian dollar random",
   5091         "1.00 Liberian dollars random",
   5092         "1.00 Libyan Dinar random",
   5093         "1.00 Libyan dinar random",
   5094         "1.00 Libyan dinars random",
   5095         "1.00 Lithuanian Litas random",
   5096         "1.00 Lithuanian Talonas random",
   5097         "1.00 Lithuanian litas random",
   5098         "1.00 Lithuanian litai random",
   5099         "1.00 Lithuanian talonas random",
   5100         "1.00 Lithuanian talonases random",
   5101         "1.00 Luxembourgian Convertible Franc random",
   5102         "1.00 Luxembourg Financial Franc random",
   5103         "1.00 Luxembourgian Franc random",
   5104         "1.00 Luxembourgian convertible franc random",
   5105         "1.00 Luxembourgian convertible francs random",
   5106         "1.00 Luxembourg financial franc random",
   5107         "1.00 Luxembourg financial francs random",
   5108         "1.00 Luxembourgian franc random",
   5109         "1.00 Luxembourgian francs random",
   5110         "1.00 Macanese Pataca random",
   5111         "1.00 Macanese pataca random",
   5112         "1.00 Macanese patacas random",
   5113         "1.00 Macedonian Denar random",
   5114         "1.00 Macedonian denar random",
   5115         "1.00 Macedonian denari random",
   5116         "1.00 Malagasy Ariaries random",
   5117         "1.00 Malagasy Ariary random",
   5118         "1.00 Malagasy Ariary random",
   5119         "1.00 Malagasy Franc random",
   5120         "1.00 Malagasy franc random",
   5121         "1.00 Malagasy francs random",
   5122         "1.00 Malawian Kwacha random",
   5123         "1.00 Malawian Kwacha random",
   5124         "1.00 Malawian Kwachas random",
   5125         "1.00 Malaysian Ringgit random",
   5126         "1.00 Malaysian ringgit random",
   5127         "1.00 Malaysian ringgits random",
   5128         "1.00 Maldivian Rufiyaa random",
   5129         "1.00 Maldivian rufiyaa random",
   5130         "1.00 Maldivian rufiyaas random",
   5131         "1.00 Malian Franc random",
   5132         "1.00 Malian franc random",
   5133         "1.00 Malian francs random",
   5134         "1.00 Maltese Lira random",
   5135         "1.00 Maltese Pound random",
   5136         "1.00 Maltese lira random",
   5137         "1.00 Maltese liras random",
   5138         "1.00 Maltese pound random",
   5139         "1.00 Maltese pounds random",
   5140         "1.00 Mauritanian Ouguiya random",
   5141         "1.00 Mauritanian ouguiya random",
   5142         "1.00 Mauritanian ouguiyas random",
   5143         "1.00 Mauritian Rupee random",
   5144         "1.00 Mauritian rupee random",
   5145         "1.00 Mauritian rupees random",
   5146         "1.00 Mexican Peso random",
   5147         "1.00 Mexican Silver Peso (1861-1992) random",
   5148         "1.00 Mexican Investment Unit random",
   5149         "1.00 Mexican peso random",
   5150         "1.00 Mexican pesos random",
   5151         "1.00 Mexican silver peso (1861-1992) random",
   5152         "1.00 Mexican silver pesos (1861-1992) random",
   5153         "1.00 Mexican investment unit random",
   5154         "1.00 Mexican investment units random",
   5155         "1.00 Moldovan Leu random",
   5156         "1.00 Moldovan leu random",
   5157         "1.00 Moldovan lei random",
   5158         "1.00 Mongolian Tugrik random",
   5159         "1.00 Mongolian tugrik random",
   5160         "1.00 Mongolian tugriks random",
   5161         "1.00 Moroccan Dirham random",
   5162         "1.00 Moroccan Franc random",
   5163         "1.00 Moroccan dirham random",
   5164         "1.00 Moroccan dirhams random",
   5165         "1.00 Moroccan franc random",
   5166         "1.00 Moroccan francs random",
   5167         "1.00 Mozambican Escudo random",
   5168         "1.00 Mozambican Metical random",
   5169         "1.00 Mozambican escudo random",
   5170         "1.00 Mozambican escudos random",
   5171         "1.00 Mozambican metical random",
   5172         "1.00 Mozambican meticals random",
   5173         "1.00 Myanma Kyat random",
   5174         "1.00 Myanma kyat random",
   5175         "1.00 Myanma kyats random",
   5176         "1.00 Namibian Dollar random",
   5177         "1.00 Namibian dollar random",
   5178         "1.00 Namibian dollars random",
   5179         "1.00 Nepalese Rupee random",
   5180         "1.00 Nepalese rupee random",
   5181         "1.00 Nepalese rupees random",
   5182         "1.00 Netherlands Antillean Guilder random",
   5183         "1.00 Netherlands Antillean guilder random",
   5184         "1.00 Netherlands Antillean guilders random",
   5185         "1.00 Dutch Guilder random",
   5186         "1.00 Dutch guilder random",
   5187         "1.00 Dutch guilders random",
   5188         "1.00 Israeli New Sheqel random",
   5189         "1.00 Israeli new sheqels random",
   5190         "1.00 New Zealand Dollar random",
   5191         "1.00 New Zealand dollar random",
   5192         "1.00 New Zealand dollars random",
   5193         "1.00 Nicaraguan C\\u00f3rdoba random",
   5194         "1.00 Nicaraguan C\\u00f3rdoba (1988-1991) random",
   5195         "1.00 Nicaraguan c\\u00f3rdoba random",
   5196         "1.00 Nicaraguan c\\u00f3rdoba random",
   5197         "1.00 Nicaraguan c\\u00f3rdoba (1988-1991) random",
   5198         "1.00 Nicaraguan c\\u00f3rdobas (1988-1991) random",
   5199         "1.00 Nigerian Naira random",
   5200         "1.00 Nigerian naira random",
   5201         "1.00 Nigerian nairas random",
   5202         "1.00 North Korean Won random",
   5203         "1.00 North Korean won random",
   5204         "1.00 North Korean won random",
   5205         "1.00 Norwegian Krone random",
   5206         "1.00 Norwegian krone random",
   5207         "1.00 Norwegian kroner random",
   5208         "1.00 Mozambican Metical (1980-2006) random",
   5209         "1.00 Mozambican metical (1980-2006) random",
   5210         "1.00 Mozambican meticals (1980-2006) random",
   5211         "1.00 Romanian Lei (1952-2006) random",
   5212         "1.00 Romanian Leu (1952-2006) random",
   5213         "1.00 Romanian leu (1952-2006) random",
   5214         "1.00 Serbian Dinar (2002-2006) random",
   5215         "1.00 Serbian dinar (2002-2006) random",
   5216         "1.00 Serbian dinars (2002-2006) random",
   5217         "1.00 Sudanese Dinar (1992-2007) random",
   5218         "1.00 Sudanese Pound (1957-1998) random",
   5219         "1.00 Sudanese dinar (1992-2007) random",
   5220         "1.00 Sudanese dinars (1992-2007) random",
   5221         "1.00 Sudanese pound (1957-1998) random",
   5222         "1.00 Sudanese pounds (1957-1998) random",
   5223         "1.00 Turkish Lira (1922-2005) random",
   5224         "1.00 Turkish Lira (1922-2005) random",
   5225         "1.00 Omani Rial random",
   5226         "1.00 Omani rial random",
   5227         "1.00 Omani rials random",
   5228         "1.00 Pakistani Rupee random",
   5229         "1.00 Pakistani rupee random",
   5230         "1.00 Pakistani rupees random",
   5231         "1.00 Palladium random",
   5232         "1.00 Palladium random",
   5233         "1.00 Panamanian Balboa random",
   5234         "1.00 Panamanian balboa random",
   5235         "1.00 Panamanian balboas random",
   5236         "1.00 Papua New Guinean Kina random",
   5237         "1.00 Papua New Guinean kina random",
   5238         "1.00 Papua New Guinean kina random",
   5239         "1.00 Paraguayan Guarani random",
   5240         "1.00 Paraguayan guarani random",
   5241         "1.00 Paraguayan guaranis random",
   5242         "1.00 Peruvian Inti random",
   5243         "1.00 Peruvian Nuevo Sol random",
   5244         "1.00 Peruvian Sol (1863-1965) random",
   5245         "1.00 Peruvian inti random",
   5246         "1.00 Peruvian intis random",
   5247         "1.00 Peruvian nuevo sol random",
   5248         "1.00 Peruvian nuevos soles random",
   5249         "1.00 Peruvian sol (1863-1965) random",
   5250         "1.00 Peruvian soles (1863-1965) random",
   5251         "1.00 Philippine Peso random",
   5252         "1.00 Philippine peso random",
   5253         "1.00 Philippine pesos random",
   5254         "1.00 Platinum random",
   5255         "1.00 Platinum random",
   5256         "1.00 Polish Zloty (1950-1995) random",
   5257         "1.00 Polish Zloty random",
   5258         "1.00 Polish zlotys random",
   5259         "1.00 Polish zloty (PLZ) random",
   5260         "1.00 Polish zloty random",
   5261         "1.00 Polish zlotys (PLZ) random",
   5262         "1.00 Portuguese Escudo random",
   5263         "1.00 Portuguese Guinea Escudo random",
   5264         "1.00 Portuguese Guinea escudo random",
   5265         "1.00 Portuguese Guinea escudos random",
   5266         "1.00 Portuguese escudo random",
   5267         "1.00 Portuguese escudos random",
   5268         "1.00 Qatari Rial random",
   5269         "1.00 Qatari rial random",
   5270         "1.00 Qatari rials random",
   5271         "1.00 RINET Funds random",
   5272         "1.00 RINET Funds random",
   5273         "1.00 Rhodesian Dollar random",
   5274         "1.00 Rhodesian dollar random",
   5275         "1.00 Rhodesian dollars random",
   5276         "1.00 Romanian Leu random",
   5277         "1.00 Romanian lei random",
   5278         "1.00 Romanian leu random",
   5279         "1.00 Russian Ruble (1991-1998) random",
   5280         "1.00 Russian Ruble random",
   5281         "1.00 Russian ruble (1991-1998) random",
   5282         "1.00 Russian ruble random",
   5283         "1.00 Russian rubles (1991-1998) random",
   5284         "1.00 Russian rubles random",
   5285         "1.00 Rwandan Franc random",
   5286         "1.00 Rwandan franc random",
   5287         "1.00 Rwandan francs random",
   5288         "1.00 Saint Helena Pound random",
   5289         "1.00 Saint Helena pound random",
   5290         "1.00 Saint Helena pounds random",
   5291         "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra random",
   5292         "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra random",
   5293         "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras random",
   5294         "1.00 Saudi Riyal random",
   5295         "1.00 Saudi riyal random",
   5296         "1.00 Saudi riyals random",
   5297         "1.00 Serbian Dinar random",
   5298         "1.00 Serbian dinar random",
   5299         "1.00 Serbian dinars random",
   5300         "1.00 Seychellois Rupee random",
   5301         "1.00 Seychellois rupee random",
   5302         "1.00 Seychellois rupees random",
   5303         "1.00 Sierra Leonean Leone random",
   5304         "1.00 Sierra Leonean leone random",
   5305         "1.00 Sierra Leonean leones random",
   5306         "1.00 Singapore Dollar random",
   5307         "1.00 Singapore dollar random",
   5308         "1.00 Singapore dollars random",
   5309         "1.00 Slovak Koruna random",
   5310         "1.00 Slovak koruna random",
   5311         "1.00 Slovak korunas random",
   5312         "1.00 Slovenian Tolar random",
   5313         "1.00 Slovenian tolar random",
   5314         "1.00 Slovenian tolars random",
   5315         "1.00 Solomon Islands Dollar random",
   5316         "1.00 Solomon Islands dollar random",
   5317         "1.00 Solomon Islands dollars random",
   5318         "1.00 Somali Shilling random",
   5319         "1.00 Somali shilling random",
   5320         "1.00 Somali shillings random",
   5321         "1.00 South African Rand (financial) random",
   5322         "1.00 South African Rand random",
   5323         "1.00 South African rand (financial) random",
   5324         "1.00 South African rand random",
   5325         "1.00 South African rands (financial) random",
   5326         "1.00 South African rand random",
   5327         "1.00 South Korean Won random",
   5328         "1.00 South Korean won random",
   5329         "1.00 South Korean won random",
   5330         "1.00 Soviet Rouble random",
   5331         "1.00 Soviet rouble random",
   5332         "1.00 Soviet roubles random",
   5333         "1.00 Spanish Peseta (A account) random",
   5334         "1.00 Spanish Peseta (convertible account) random",
   5335         "1.00 Spanish Peseta random",
   5336         "1.00 Spanish peseta (A account) random",
   5337         "1.00 Spanish peseta (convertible account) random",
   5338         "1.00 Spanish peseta random",
   5339         "1.00 Spanish pesetas (A account) random",
   5340         "1.00 Spanish pesetas (convertible account) random",
   5341         "1.00 Spanish pesetas random",
   5342         "1.00 Special Drawing Rights random",
   5343         "1.00 Sri Lankan Rupee random",
   5344         "1.00 Sri Lankan rupee random",
   5345         "1.00 Sri Lankan rupees random",
   5346         "1.00 Sudanese Pound random",
   5347         "1.00 Sudanese pound random",
   5348         "1.00 Sudanese pounds random",
   5349         "1.00 Surinamese Dollar random",
   5350         "1.00 Surinamese dollar random",
   5351         "1.00 Surinamese dollars random",
   5352         "1.00 Surinamese Guilder random",
   5353         "1.00 Surinamese guilder random",
   5354         "1.00 Surinamese guilders random",
   5355         "1.00 Swazi Lilangeni random",
   5356         "1.00 Swazi lilangeni random",
   5357         "1.00 Swazi emalangeni random",
   5358         "1.00 Swedish Krona random",
   5359         "1.00 Swedish krona random",
   5360         "1.00 Swedish kronor random",
   5361         "1.00 Swiss Franc random",
   5362         "1.00 Swiss franc random",
   5363         "1.00 Swiss francs random",
   5364         "1.00 Syrian Pound random",
   5365         "1.00 Syrian pound random",
   5366         "1.00 Syrian pounds random",
   5367         "1.00 New Taiwan Dollar random",
   5368         "1.00 New Taiwan dollar random",
   5369         "1.00 New Taiwan dollars random",
   5370         "1.00 Tajikistani Ruble random",
   5371         "1.00 Tajikistani Somoni random",
   5372         "1.00 Tajikistani ruble random",
   5373         "1.00 Tajikistani rubles random",
   5374         "1.00 Tajikistani somoni random",
   5375         "1.00 Tajikistani somonis random",
   5376         "1.00 Tanzanian Shilling random",
   5377         "1.00 Tanzanian shilling random",
   5378         "1.00 Tanzanian shillings random",
   5379         "1.00 Testing Currency Code random",
   5380         "1.00 Testing Currency Code random",
   5381         "1.00 Thai Baht random",
   5382         "1.00 Thai baht random",
   5383         "1.00 Thai baht random",
   5384         "1.00 Timorese Escudo random",
   5385         "1.00 Timorese escudo random",
   5386         "1.00 Timorese escudos random",
   5387         "1.00 Trinidad and Tobago Dollar random",
   5388         "1.00 Trinidad and Tobago dollar random",
   5389         "1.00 Trinidad and Tobago dollars random",
   5390         "1.00 Tunisian Dinar random",
   5391         "1.00 Tunisian dinar random",
   5392         "1.00 Tunisian dinars random",
   5393         "1.00 Turkish Lira random",
   5394         "1.00 Turkish Lira random",
   5395         "1.00 Turkish lira random",
   5396         "1.00 Turkmenistani Manat random",
   5397         "1.00 Turkmenistani manat random",
   5398         "1.00 Turkmenistani manat random",
   5399         "1.00 US Dollar (Next day) random",
   5400         "1.00 US Dollar (Same day) random",
   5401         "1.00 US Dollar random",
   5402         "1.00 US dollar (next day) random",
   5403         "1.00 US dollar (same day) random",
   5404         "1.00 US dollar random",
   5405         "1.00 US dollars (next day) random",
   5406         "1.00 US dollars (same day) random",
   5407         "1.00 US dollars random",
   5408         "1.00 Ugandan Shilling (1966-1987) random",
   5409         "1.00 Ugandan Shilling random",
   5410         "1.00 Ugandan shilling (1966-1987) random",
   5411         "1.00 Ugandan shilling random",
   5412         "1.00 Ugandan shillings (1966-1987) random",
   5413         "1.00 Ugandan shillings random",
   5414         "1.00 Ukrainian Hryvnia random",
   5415         "1.00 Ukrainian Karbovanets random",
   5416         "1.00 Ukrainian hryvnia random",
   5417         "1.00 Ukrainian hryvnias random",
   5418         "1.00 Ukrainian karbovanets random",
   5419         "1.00 Ukrainian karbovantsiv random",
   5420         "1.00 Colombian Real Value Unit random",
   5421         "1.00 United Arab Emirates Dirham random",
   5422         "1.00 Unknown Currency random",
   5423         "1.00 Uruguayan Peso (1975-1993) random",
   5424         "1.00 Uruguayan Peso random",
   5425         "1.00 Uruguayan Peso (Indexed Units) random",
   5426         "1.00 Uruguayan peso (1975-1993) random",
   5427         "1.00 Uruguayan peso (indexed units) random",
   5428         "1.00 Uruguayan peso random",
   5429         "1.00 Uruguayan pesos (1975-1993) random",
   5430         "1.00 Uruguayan pesos (indexed units) random",
   5431         "1.00 Uzbekistan Som random",
   5432         "1.00 Uzbekistan som random",
   5433         "1.00 Uzbekistan som random",
   5434         "1.00 Vanuatu Vatu random",
   5435         "1.00 Vanuatu vatu random",
   5436         "1.00 Vanuatu vatus random",
   5437         "1.00 Venezuelan Bol\\u00edvar random",
   5438         "1.00 Venezuelan Bol\\u00edvar (1871-2008) random",
   5439         "1.00 Venezuelan bol\\u00edvar random",
   5440         "1.00 Venezuelan bol\\u00edvars random",
   5441         "1.00 Venezuelan bol\\u00edvar (1871-2008) random",
   5442         "1.00 Venezuelan bol\\u00edvars (1871-2008) random",
   5443         "1.00 Vietnamese Dong random",
   5444         "1.00 Vietnamese dong random",
   5445         "1.00 Vietnamese dong random",
   5446         "1.00 WIR Euro random",
   5447         "1.00 WIR Franc random",
   5448         "1.00 WIR euro random",
   5449         "1.00 WIR euros random",
   5450         "1.00 WIR franc random",
   5451         "1.00 WIR francs random",
   5452         "1.00 Samoan Tala random",
   5453         "1.00 Samoan tala random",
   5454         "1.00 Samoan tala random",
   5455         "1.00 Yemeni Dinar random",
   5456         "1.00 Yemeni Rial random",
   5457         "1.00 Yemeni dinar random",
   5458         "1.00 Yemeni dinars random",
   5459         "1.00 Yemeni rial random",
   5460         "1.00 Yemeni rials random",
   5461         "1.00 Yugoslavian Convertible Dinar (1990-1992) random",
   5462         "1.00 Yugoslavian Hard Dinar (1966-1990) random",
   5463         "1.00 Yugoslavian New Dinar (1994-2002) random",
   5464         "1.00 Yugoslavian convertible dinar (1990-1992) random",
   5465         "1.00 Yugoslavian convertible dinars (1990-1992) random",
   5466         "1.00 Yugoslavian hard dinar (1966-1990) random",
   5467         "1.00 Yugoslavian hard dinars (1966-1990) random",
   5468         "1.00 Yugoslavian new dinar (1994-2002) random",
   5469         "1.00 Yugoslavian new dinars (1994-2002) random",
   5470         "1.00 Zairean New Zaire (1993-1998) random",
   5471         "1.00 Zairean Zaire (1971-1993) random",
   5472         "1.00 Zairean new zaire (1993-1998) random",
   5473         "1.00 Zairean new zaires (1993-1998) random",
   5474         "1.00 Zairean zaire (1971-1993) random",
   5475         "1.00 Zairean zaires (1971-1993) random",
   5476         "1.00 Zambian Kwacha random",
   5477         "1.00 Zambian kwacha random",
   5478         "1.00 Zambian kwachas random",
   5479         "1.00 Zimbabwean Dollar (1980-2008) random",
   5480         "1.00 Zimbabwean dollar (1980-2008) random",
   5481         "1.00 Zimbabwean dollars (1980-2008) random",
   5482         "1.00 euro random",
   5483         "1.00 euros random",
   5484         "1.00 Turkish lira (1922-2005) random",
   5485         "1.00 special drawing rights random",
   5486         "1.00 Colombian real value unit random",
   5487         "1.00 Colombian real value units random",
   5488         "1.00 unknown currency random",
   5489     };
   5490 
   5491     const char* WRONG_DATA[] = {
   5492         // Following are missing one last char in the currency name
   5493         "usd1.00", // case sensitive
   5494         "1.00 Nicaraguan Cordob",
   5495         "1.00 Namibian Dolla",
   5496         "1.00 Namibian dolla",
   5497         "1.00 Nepalese Rupe",
   5498         "1.00 Nepalese rupe",
   5499         "1.00 Netherlands Antillean Guilde",
   5500         "1.00 Netherlands Antillean guilde",
   5501         "1.00 Dutch Guilde",
   5502         "1.00 Dutch guilde",
   5503         "1.00 Israeli New Sheqe",
   5504         "1.00 New Zealand Dolla",
   5505         "1.00 New Zealand dolla",
   5506         "1.00 Nicaraguan cordob",
   5507         "1.00 Nigerian Nair",
   5508         "1.00 Nigerian nair",
   5509         "1.00 North Korean Wo",
   5510         "1.00 North Korean wo",
   5511         "1.00 Norwegian Kron",
   5512         "1.00 Norwegian kron",
   5513         "1.00 US dolla",
   5514         "1.00",
   5515         "A1.00",
   5516         "AD1.00",
   5517         "AE1.00",
   5518         "AF1.00",
   5519         "AL1.00",
   5520         "AM1.00",
   5521         "AN1.00",
   5522         "AO1.00",
   5523         "AR1.00",
   5524         "AT1.00",
   5525         "AU1.00",
   5526         "AW1.00",
   5527         "AZ1.00",
   5528         "Afghan Afghan1.00",
   5529         "Afghan Afghani (1927-20021.00",
   5530         "Afl1.00",
   5531         "Albanian Le1.00",
   5532         "Algerian Dina1.00",
   5533         "Andorran Peset1.00",
   5534         "Angolan Kwanz1.00",
   5535         "Angolan Kwanza (1977-19901.00",
   5536         "Angolan Readjusted Kwanza (1995-19991.00",
   5537         "Angolan New Kwanza (1990-20001.00",
   5538         "Argentine Austra1.00",
   5539         "Argentine Pes1.00",
   5540         "Argentine Peso (1983-19851.00",
   5541         "Armenian Dra1.00",
   5542         "Aruban Flori1.00",
   5543         "Australian Dolla1.00",
   5544         "Austrian Schillin1.00",
   5545         "Azerbaijani Mana1.00",
   5546         "Azerbaijani Manat (1993-20061.00",
   5547         "B1.00",
   5548         "BA1.00",
   5549         "BB1.00",
   5550         "BE1.00",
   5551         "BG1.00",
   5552         "BH1.00",
   5553         "BI1.00",
   5554         "BM1.00",
   5555         "BN1.00",
   5556         "BO1.00",
   5557         "BR1.00",
   5558         "BS1.00",
   5559         "BT1.00",
   5560         "BU1.00",
   5561         "BW1.00",
   5562         "BY1.00",
   5563         "BZ1.00",
   5564         "Bahamian Dolla1.00",
   5565         "Bahraini Dina1.00",
   5566         "Bangladeshi Tak1.00",
   5567         "Barbadian Dolla1.00",
   5568         "Bds1.00",
   5569         "Belarusian New Ruble (1994-19991.00",
   5570         "Belarusian Rubl1.00",
   5571         "Belgian Fran1.00",
   5572         "Belgian Franc (convertible1.00",
   5573         "Belgian Franc (financial1.00",
   5574         "Belize Dolla1.00",
   5575         "Bermudan Dolla1.00",
   5576         "Bhutanese Ngultru1.00",
   5577         "Bolivian Mvdo1.00",
   5578         "Bolivian Pes1.00",
   5579         "Bolivian Bolivian1.00",
   5580         "Bosnia-Herzegovina Convertible Mar1.00",
   5581         "Bosnia-Herzegovina Dina1.00",
   5582         "Botswanan Pul1.00",
   5583         "Brazilian Cruzad1.00",
   5584         "Brazilian Cruzado Nov1.00",
   5585         "Brazilian Cruzeir1.00",
   5586         "Brazilian Cruzeiro (1990-19931.00",
   5587         "Brazilian New Cruzeiro (1967-19861.00",
   5588         "Brazilian Rea1.00",
   5589         "British Pound Sterlin1.00",
   5590         "Brunei Dolla1.00",
   5591         "Bulgarian Hard Le1.00",
   5592         "Bulgarian Le1.00",
   5593         "Burmese Kya1.00",
   5594         "Burundian Fran1.00",
   5595         "C1.00",
   5596         "CA1.00",
   5597         "CD1.00",
   5598         "CFA Franc BCEA1.00",
   5599         "CFA Franc BEA1.00",
   5600         "CFP Fran1.00",
   5601         "CFP1.00",
   5602         "CH1.00",
   5603         "CL1.00",
   5604         "CN1.00",
   5605         "CO1.00",
   5606         "CS1.00",
   5607         "CU1.00",
   5608         "CV1.00",
   5609         "CY1.00",
   5610         "CZ1.00",
   5611         "Cambodian Rie1.00",
   5612         "Canadian Dolla1.00",
   5613         "Cape Verdean Escud1.00",
   5614         "Cayman Islands Dolla1.00",
   5615         "Chilean Pes1.00",
   5616         "Chilean Unit of Accoun1.00",
   5617         "Chinese Yua1.00",
   5618         "Colombian Pes1.00",
   5619         "Comoro Fran1.00",
   5620         "Congolese Fran1.00",
   5621         "Costa Rican Col\\u00f31.00",
   5622         "Croatian Dina1.00",
   5623         "Croatian Kun1.00",
   5624         "Cuban Pes1.00",
   5625         "Cypriot Poun1.00",
   5626         "Czech Republic Korun1.00",
   5627         "Czechoslovak Hard Korun1.00",
   5628         "D1.00",
   5629         "DD1.00",
   5630         "DE1.00",
   5631         "DJ1.00",
   5632         "DK1.00",
   5633         "DO1.00",
   5634         "DZ1.00",
   5635         "Danish Kron1.00",
   5636         "German Mar1.00",
   5637         "Djiboutian Fran1.00",
   5638         "Dk1.00",
   5639         "Dominican Pes1.00",
   5640         "EC1.00",
   5641         "EE1.00",
   5642         "EG1.00",
   5643         "EQ1.00",
   5644         "ER1.00",
   5645         "ES1.00",
   5646         "ET1.00",
   5647         "EU1.00",
   5648         "East Caribbean Dolla1.00",
   5649         "East German Ostmar1.00",
   5650         "Ecuadorian Sucr1.00",
   5651         "Ecuadorian Unit of Constant Valu1.00",
   5652         "Egyptian Poun1.00",
   5653         "Ekwel1.00",
   5654         "Salvadoran Col\\u00f31.00",
   5655         "Equatorial Guinean Ekwel1.00",
   5656         "Eritrean Nakf1.00",
   5657         "Es1.00",
   5658         "Estonian Kroo1.00",
   5659         "Ethiopian Bir1.00",
   5660         "Eur1.00",
   5661         "European Composite Uni1.00",
   5662         "European Currency Uni1.00",
   5663         "European Monetary Uni1.00",
   5664         "European Unit of Account (XBC1.00",
   5665         "European Unit of Account (XBD1.00",
   5666         "F1.00",
   5667         "FB1.00",
   5668         "FI1.00",
   5669         "FJ1.00",
   5670         "FK1.00",
   5671         "FR1.00",
   5672         "Falkland Islands Poun1.00",
   5673         "Fd1.00",
   5674         "Fijian Dolla1.00",
   5675         "Finnish Markk1.00",
   5676         "Fr1.00",
   5677         "French Fran1.00",
   5678         "French Gold Fran1.00",
   5679         "French UIC-Fran1.00",
   5680         "G1.00",
   5681         "GB1.00",
   5682         "GE1.00",
   5683         "GH1.00",
   5684         "GI1.00",
   5685         "GM1.00",
   5686         "GN1.00",
   5687         "GQ1.00",
   5688         "GR1.00",
   5689         "GT1.00",
   5690         "GW1.00",
   5691         "GY1.00",
   5692         "Gambian Dalas1.00",
   5693         "Georgian Kupon Lari1.00",
   5694         "Georgian Lar1.00",
   5695         "Ghanaian Ced1.00",
   5696         "Ghanaian Cedi (1979-20071.00",
   5697         "Gibraltar Poun1.00",
   5698         "Gol1.00",
   5699         "Greek Drachm1.00",
   5700         "Guatemalan Quetza1.00",
   5701         "Guinean Fran1.00",
   5702         "Guinean Syl1.00",
   5703         "Guinea-Bissau Pes1.00",
   5704         "Guyanaese Dolla1.00",
   5705         "HK1.00",
   5706         "HN1.00",
   5707         "HR1.00",
   5708         "HT1.00",
   5709         "HU1.00",
   5710         "Haitian Gourd1.00",
   5711         "Honduran Lempir1.00",
   5712         "Hong Kong Dolla1.00",
   5713         "Hungarian Forin1.00",
   5714         "I1.00",
   5715         "IE1.00",
   5716         "IL1.00",
   5717         "IN1.00",
   5718         "IQ1.00",
   5719         "IR1.00",
   5720         "IS1.00",
   5721         "IT1.00",
   5722         "Icelandic Kron1.00",
   5723         "Indian Rupe1.00",
   5724         "Indonesian Rupia1.00",
   5725         "Iranian Ria1.00",
   5726         "Iraqi Dina1.00",
   5727         "Irish Poun1.00",
   5728         "Israeli Poun1.00",
   5729         "Italian Lir1.00",
   5730         "J1.00",
   5731         "JM1.00",
   5732         "JO1.00",
   5733         "JP1.00",
   5734         "Jamaican Dolla1.00",
   5735         "Japanese Ye1.00",
   5736         "Jordanian Dina1.00",
   5737         "K S1.00",
   5738         "K1.00",
   5739         "KE1.00",
   5740         "KG1.00",
   5741         "KH1.00",
   5742         "KP1.00",
   5743         "KR1.00",
   5744         "KW1.00",
   5745         "KY1.00",
   5746         "KZ1.00",
   5747         "Kazakhstani Teng1.00",
   5748         "Kenyan Shillin1.00",
   5749         "Kuwaiti Dina1.00",
   5750         "Kyrgystani So1.00",
   5751         "LA1.00",
   5752         "LB1.00",
   5753         "LK1.00",
   5754         "LR1.00",
   5755         "LT1.00",
   5756         "LU1.00",
   5757         "LV1.00",
   5758         "LY1.00",
   5759         "Laotian Ki1.00",
   5760         "Latvian Lat1.00",
   5761         "Latvian Rubl1.00",
   5762         "Lebanese Poun1.00",
   5763         "Lesotho Lot1.00",
   5764         "Liberian Dolla1.00",
   5765         "Libyan Dina1.00",
   5766         "Lithuanian Lit1.00",
   5767         "Lithuanian Talona1.00",
   5768         "Luxembourgian Convertible Fran1.00",
   5769         "Luxembourg Financial Fran1.00",
   5770         "Luxembourgian Fran1.00",
   5771         "MA1.00",
   5772         "MD1.00",
   5773         "MDe1.00",
   5774         "MEX1.00",
   5775         "MG1.00",
   5776         "ML1.00",
   5777         "MM1.00",
   5778         "MN1.00",
   5779         "MO1.00",
   5780         "MR1.00",
   5781         "MT1.00",
   5782         "MU1.00",
   5783         "MV1.00",
   5784         "MW1.00",
   5785         "MX1.00",
   5786         "MY1.00",
   5787         "MZ1.00",
   5788         "Macanese Patac1.00",
   5789         "Macedonian Dena1.00",
   5790         "Malagasy Ariar1.00",
   5791         "Malagasy Fran1.00",
   5792         "Malawian Kwach1.00",
   5793         "Malaysian Ringgi1.00",
   5794         "Maldivian Rufiya1.00",
   5795         "Malian Fran1.00",
   5796         "Malot1.00",
   5797         "Maltese Lir1.00",
   5798         "Maltese Poun1.00",
   5799         "Mauritanian Ouguiy1.00",
   5800         "Mauritian Rupe1.00",
   5801         "Mexican Pes1.00",
   5802         "Mexican Silver Peso (1861-19921.00",
   5803         "Mexican Investment Uni1.00",
   5804         "Moldovan Le1.00",
   5805         "Mongolian Tugri1.00",
   5806         "Moroccan Dirha1.00",
   5807         "Moroccan Fran1.00",
   5808         "Mozambican Escud1.00",
   5809         "Mozambican Metica1.00",
   5810         "Myanma Kya1.00",
   5811         "N1.00",
   5812         "NA1.00",
   5813         "NAf1.00",
   5814         "NG1.00",
   5815         "NI1.00",
   5816         "NK1.00",
   5817         "NL1.00",
   5818         "NO1.00",
   5819         "NP1.00",
   5820         "NT1.00",
   5821         "Namibian Dolla1.00",
   5822         "Nepalese Rupe1.00",
   5823         "Netherlands Antillean Guilde1.00",
   5824         "Dutch Guilde1.00",
   5825         "Israeli New Sheqe1.00",
   5826         "New Zealand Dolla1.00",
   5827         "Nicaraguan C\\u00f3rdoba (1988-19911.00",
   5828         "Nicaraguan C\\u00f3rdob1.00",
   5829         "Nigerian Nair1.00",
   5830         "North Korean Wo1.00",
   5831         "Norwegian Kron1.00",
   5832         "Nr1.00",
   5833         "OM1.00",
   5834         "Old Mozambican Metica1.00",
   5835         "Romanian Leu (1952-20061.00",
   5836         "Serbian Dinar (2002-20061.00",
   5837         "Sudanese Dinar (1992-20071.00",
   5838         "Sudanese Pound (1957-19981.00",
   5839         "Turkish Lira (1922-20051.00",
   5840         "Omani Ria1.00",
   5841         "PA1.00",
   5842         "PE1.00",
   5843         "PG1.00",
   5844         "PH1.00",
   5845         "PK1.00",
   5846         "PL1.00",
   5847         "PT1.00",
   5848         "PY1.00",
   5849         "Pakistani Rupe1.00",
   5850         "Palladiu1.00",
   5851         "Panamanian Balbo1.00",
   5852         "Papua New Guinean Kin1.00",
   5853         "Paraguayan Guaran1.00",
   5854         "Peruvian Int1.00",
   5855         "Peruvian Sol (1863-19651.00",
   5856         "Peruvian Sol Nuev1.00",
   5857         "Philippine Pes1.00",
   5858         "Platinu1.00",
   5859         "Polish Zlot1.00",
   5860         "Polish Zloty (1950-19951.00",
   5861         "Portuguese Escud1.00",
   5862         "Portuguese Guinea Escud1.00",
   5863         "Pr1.00",
   5864         "QA1.00",
   5865         "Qatari Ria1.00",
   5866         "RD1.00",
   5867         "RH1.00",
   5868         "RINET Fund1.00",
   5869         "RS1.00",
   5870         "RU1.00",
   5871         "RW1.00",
   5872         "Rb1.00",
   5873         "Rhodesian Dolla1.00",
   5874         "Romanian Le1.00",
   5875         "Russian Rubl1.00",
   5876         "Russian Ruble (1991-19981.00",
   5877         "Rwandan Fran1.00",
   5878         "S1.00",
   5879         "SA1.00",
   5880         "SB1.00",
   5881         "SC1.00",
   5882         "SD1.00",
   5883         "SE1.00",
   5884         "SG1.00",
   5885         "SH1.00",
   5886         "SI1.00",
   5887         "SK1.00",
   5888         "SL R1.00",
   5889         "SL1.00",
   5890         "SO1.00",
   5891         "ST1.00",
   5892         "SU1.00",
   5893         "SV1.00",
   5894         "SY1.00",
   5895         "SZ1.00",
   5896         "Saint Helena Poun1.00",
   5897         "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobr1.00",
   5898         "Saudi Riya1.00",
   5899         "Serbian Dina1.00",
   5900         "Seychellois Rupe1.00",
   5901         "Sh1.00",
   5902         "Sierra Leonean Leon1.00",
   5903         "Silve1.00",
   5904         "Singapore Dolla1.00",
   5905         "Slovak Korun1.00",
   5906         "Slovenian Tola1.00",
   5907         "Solomon Islands Dolla1.00",
   5908         "Somali Shillin1.00",
   5909         "South African Ran1.00",
   5910         "South African Rand (financial1.00",
   5911         "South Korean Wo1.00",
   5912         "Soviet Roubl1.00",
   5913         "Spanish Peset1.00",
   5914         "Spanish Peseta (A account1.00",
   5915         "Spanish Peseta (convertible account1.00",
   5916         "Special Drawing Right1.00",
   5917         "Sri Lankan Rupe1.00",
   5918         "Sudanese Poun1.00",
   5919         "Surinamese Dolla1.00",
   5920         "Surinamese Guilde1.00",
   5921         "Swazi Lilangen1.00",
   5922         "Swedish Kron1.00",
   5923         "Swiss Fran1.00",
   5924         "Syrian Poun1.00",
   5925         "T S1.00",
   5926         "TH1.00",
   5927         "TJ1.00",
   5928         "TM1.00",
   5929         "TN1.00",
   5930         "TO1.00",
   5931         "TP1.00",
   5932         "TR1.00",
   5933         "TT1.00",
   5934         "TW1.00",
   5935         "TZ1.00",
   5936         "New Taiwan Dolla1.00",
   5937         "Tajikistani Rubl1.00",
   5938         "Tajikistani Somon1.00",
   5939         "Tanzanian Shillin1.00",
   5940         "Testing Currency Cod1.00",
   5941         "Thai Bah1.00",
   5942         "Timorese Escud1.00",
   5943         "Tongan Pa\\u20bbang1.00",
   5944         "Trinidad and Tobago Dolla1.00",
   5945         "Tunisian Dina1.00",
   5946         "Turkish Lir1.00",
   5947         "Turkmenistani Mana1.00",
   5948         "U S1.00",
   5949         "U1.00",
   5950         "UA1.00",
   5951         "UG1.00",
   5952         "US Dolla1.00",
   5953         "US Dollar (Next day1.00",
   5954         "US Dollar (Same day1.00",
   5955         "US1.00",
   5956         "UY1.00",
   5957         "UZ1.00",
   5958         "Ugandan Shillin1.00",
   5959         "Ugandan Shilling (1966-19871.00",
   5960         "Ukrainian Hryvni1.00",
   5961         "Ukrainian Karbovanet1.00",
   5962         "Colombian Real Value Uni1.00",
   5963         "United Arab Emirates Dirha1.00",
   5964         "Unknown Currenc1.00",
   5965         "Ur1.00",
   5966         "Uruguay Peso (1975-19931.00",
   5967         "Uruguay Peso Uruguay1.00",
   5968         "Uruguay Peso (Indexed Units1.00",
   5969         "Uzbekistan So1.00",
   5970         "V1.00",
   5971         "VE1.00",
   5972         "VN1.00",
   5973         "VU1.00",
   5974         "Vanuatu Vat1.00",
   5975         "Venezuelan Bol\\u00edva1.00",
   5976         "Venezuelan Bol\\u00edvar Fuert1.00",
   5977         "Vietnamese Don1.00",
   5978         "WIR Eur1.00",
   5979         "WIR Fran1.00",
   5980         "WS1.00",
   5981         "Samoa Tal1.00",
   5982         "XA1.00",
   5983         "XB1.00",
   5984         "XC1.00",
   5985         "XD1.00",
   5986         "XE1.00",
   5987         "XF1.00",
   5988         "XO1.00",
   5989         "XP1.00",
   5990         "XR1.00",
   5991         "XT1.00",
   5992         "XX1.00",
   5993         "YD1.00",
   5994         "YE1.00",
   5995         "YU1.00",
   5996         "Yemeni Dina1.00",
   5997         "Yemeni Ria1.00",
   5998         "Yugoslavian Convertible Dina1.00",
   5999         "Yugoslavian Hard Dinar (1966-19901.00",
   6000         "Yugoslavian New Dina1.00",
   6001         "Z1.00",
   6002         "ZA1.00",
   6003         "ZM1.00",
   6004         "ZR1.00",
   6005         "ZW1.00",
   6006         "Zairean New Zaire (1993-19981.00",
   6007         "Zairean Zair1.00",
   6008         "Zambian Kwach1.00",
   6009         "Zimbabwean Dollar (1980-20081.00",
   6010         "dra1.00",
   6011         "lar1.00",
   6012         "le1.00",
   6013         "man1.00",
   6014         "so1.00",
   6015     };
   6016 
   6017     Locale locale("en_US");
   6018     for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) {
   6019       UnicodeString formatted = ctou(DATA[i]);
   6020       UErrorCode status = U_ZERO_ERROR;
   6021       NumberFormat* numFmt = NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
   6022       if (numFmt != NULL && U_SUCCESS(status)) {
   6023           ParsePosition parsePos;
   6024           LocalPointer<CurrencyAmount> currAmt(numFmt->parseCurrency(formatted, parsePos));
   6025           if (parsePos.getIndex() > 0) {
   6026               double doubleVal = currAmt->getNumber().getDouble(status);
   6027               if ( doubleVal != 1.0 ) {
   6028                   errln("Parsed as currency value other than 1.0: " + formatted + " -> " + doubleVal);
   6029               }
   6030           } else {
   6031               errln("Failed to parse as currency: " + formatted);
   6032           }
   6033       } else {
   6034           dataerrln("Unable to create NumberFormat. - %s", u_errorName(status));
   6035           delete numFmt;
   6036           break;
   6037       }
   6038       delete numFmt;
   6039     }
   6040 
   6041     for (uint32_t i=0; i<sizeof(WRONG_DATA)/sizeof(WRONG_DATA[0]); ++i) {
   6042       UnicodeString formatted = ctou(WRONG_DATA[i]);
   6043       UErrorCode status = U_ZERO_ERROR;
   6044       NumberFormat* numFmt = NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
   6045       if (numFmt != NULL && U_SUCCESS(status)) {
   6046           ParsePosition parsePos;
   6047           LocalPointer<CurrencyAmount> currAmt(numFmt->parseCurrency(formatted, parsePos));
   6048           if (parsePos.getIndex() > 0) {
   6049               double doubleVal = currAmt->getNumber().getDouble(status);
   6050               errln("Parsed as currency, should not have: " + formatted + " -> " + doubleVal);
   6051           }
   6052       } else {
   6053           dataerrln("Unable to create NumberFormat. - %s", u_errorName(status));
   6054           delete numFmt;
   6055           break;
   6056       }
   6057       delete numFmt;
   6058     }
   6059 }
   6060 
   6061 const char* attrString(int32_t);
   6062 
   6063 // UnicodeString s;
   6064 //  std::string ss;
   6065 //  std::cout << s.toUTF8String(ss)
   6066 void NumberFormatTest::expectPositions(FieldPositionIterator& iter, int32_t *values, int32_t tupleCount,
   6067                                        const UnicodeString& str)  {
   6068   UBool found[10];
   6069   FieldPosition fp;
   6070 
   6071   if (tupleCount > 10) {
   6072     assertTrue("internal error, tupleCount too large", FALSE);
   6073   } else {
   6074     for (int i = 0; i < tupleCount; ++i) {
   6075       found[i] = FALSE;
   6076     }
   6077   }
   6078 
   6079   logln(str);
   6080   while (iter.next(fp)) {
   6081     UBool ok = FALSE;
   6082     int32_t id = fp.getField();
   6083     int32_t start = fp.getBeginIndex();
   6084     int32_t limit = fp.getEndIndex();
   6085 
   6086     // is there a logln using printf?
   6087     char buf[128];
   6088     sprintf(buf, "%24s %3d %3d %3d", attrString(id), id, start, limit);
   6089     logln(buf);
   6090 
   6091     for (int i = 0; i < tupleCount; ++i) {
   6092       if (found[i]) {
   6093         continue;
   6094       }
   6095       if (values[i*3] == id &&
   6096           values[i*3+1] == start &&
   6097           values[i*3+2] == limit) {
   6098         found[i] = ok = TRUE;
   6099         break;
   6100       }
   6101     }
   6102 
   6103     assertTrue((UnicodeString)"found [" + id + "," + start + "," + limit + "]", ok);
   6104   }
   6105 
   6106   // check that all were found
   6107   UBool ok = TRUE;
   6108   for (int i = 0; i < tupleCount; ++i) {
   6109     if (!found[i]) {
   6110       ok = FALSE;
   6111       assertTrue((UnicodeString) "missing [" + values[i*3] + "," + values[i*3+1] + "," + values[i*3+2] + "]", found[i]);
   6112     }
   6113   }
   6114   assertTrue("no expected values were missing", ok);
   6115 }
   6116 
   6117 void NumberFormatTest::expectPosition(FieldPosition& pos, int32_t id, int32_t start, int32_t limit,
   6118                                        const UnicodeString& str)  {
   6119   logln(str);
   6120   assertTrue((UnicodeString)"id " + id + " == " + pos.getField(), id == pos.getField());
   6121   assertTrue((UnicodeString)"begin " + start + " == " + pos.getBeginIndex(), start == pos.getBeginIndex());
   6122   assertTrue((UnicodeString)"end " + limit + " == " + pos.getEndIndex(), limit == pos.getEndIndex());
   6123 }
   6124 
   6125 void NumberFormatTest::TestFieldPositionIterator() {
   6126   // bug 7372
   6127   UErrorCode status = U_ZERO_ERROR;
   6128   FieldPositionIterator iter1;
   6129   FieldPositionIterator iter2;
   6130   FieldPosition pos;
   6131 
   6132   DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(status);
   6133   if (failure(status, "NumberFormat::createInstance", TRUE)) return;
   6134 
   6135   double num = 1234.56;
   6136   UnicodeString str1;
   6137   UnicodeString str2;
   6138 
   6139   assertTrue((UnicodeString)"self==", iter1 == iter1);
   6140   assertTrue((UnicodeString)"iter1==iter2", iter1 == iter2);
   6141 
   6142   decFmt->format(num, str1, &iter1, status);
   6143   assertTrue((UnicodeString)"iter1 != iter2", iter1 != iter2);
   6144   decFmt->format(num, str2, &iter2, status);
   6145   assertTrue((UnicodeString)"iter1 == iter2 (2)", iter1 == iter2);
   6146   iter1.next(pos);
   6147   assertTrue((UnicodeString)"iter1 != iter2 (2)", iter1 != iter2);
   6148   iter2.next(pos);
   6149   assertTrue((UnicodeString)"iter1 == iter2 (3)", iter1 == iter2);
   6150 
   6151   // should format ok with no iterator
   6152   str2.remove();
   6153   decFmt->format(num, str2, NULL, status);
   6154   assertEquals("null fpiter", str1, str2);
   6155 
   6156   delete decFmt;
   6157 }
   6158 
   6159 void NumberFormatTest::TestFormatAttributes() {
   6160   Locale locale("en_US");
   6161   UErrorCode status = U_ZERO_ERROR;
   6162   DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
   6163     if (failure(status, "NumberFormat::createInstance", TRUE)) return;
   6164   double val = 12345.67;
   6165 
   6166   {
   6167     int32_t expected[] = {
   6168       UNUM_CURRENCY_FIELD, 0, 1,
   6169       UNUM_GROUPING_SEPARATOR_FIELD, 3, 4,
   6170       UNUM_INTEGER_FIELD, 1, 7,
   6171       UNUM_DECIMAL_SEPARATOR_FIELD, 7, 8,
   6172       UNUM_FRACTION_FIELD, 8, 10,
   6173     };
   6174     int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
   6175 
   6176     FieldPositionIterator posIter;
   6177     UnicodeString result;
   6178     decFmt->format(val, result, &posIter, status);
   6179     expectPositions(posIter, expected, tupleCount, result);
   6180   }
   6181   {
   6182     FieldPosition fp(UNUM_INTEGER_FIELD);
   6183     UnicodeString result;
   6184     decFmt->format(val, result, fp);
   6185     expectPosition(fp, UNUM_INTEGER_FIELD, 1, 7, result);
   6186   }
   6187   {
   6188     FieldPosition fp(UNUM_FRACTION_FIELD);
   6189     UnicodeString result;
   6190     decFmt->format(val, result, fp);
   6191     expectPosition(fp, UNUM_FRACTION_FIELD, 8, 10, result);
   6192   }
   6193   delete decFmt;
   6194 
   6195   decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, UNUM_SCIENTIFIC, status);
   6196   val = -0.0000123;
   6197   {
   6198     int32_t expected[] = {
   6199       UNUM_SIGN_FIELD, 0, 1,
   6200       UNUM_INTEGER_FIELD, 1, 2,
   6201       UNUM_DECIMAL_SEPARATOR_FIELD, 2, 3,
   6202       UNUM_FRACTION_FIELD, 3, 5,
   6203       UNUM_EXPONENT_SYMBOL_FIELD, 5, 6,
   6204       UNUM_EXPONENT_SIGN_FIELD, 6, 7,
   6205       UNUM_EXPONENT_FIELD, 7, 8
   6206     };
   6207     int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
   6208 
   6209     FieldPositionIterator posIter;
   6210     UnicodeString result;
   6211     decFmt->format(val, result, &posIter, status);
   6212     expectPositions(posIter, expected, tupleCount, result);
   6213   }
   6214   {
   6215     FieldPosition fp(UNUM_INTEGER_FIELD);
   6216     UnicodeString result;
   6217     decFmt->format(val, result, fp);
   6218     expectPosition(fp, UNUM_INTEGER_FIELD, 1, 2, result);
   6219   }
   6220   {
   6221     FieldPosition fp(UNUM_FRACTION_FIELD);
   6222     UnicodeString result;
   6223     decFmt->format(val, result, fp);
   6224     expectPosition(fp, UNUM_FRACTION_FIELD, 3, 5, result);
   6225   }
   6226   delete decFmt;
   6227 
   6228   fflush(stderr);
   6229 }
   6230 
   6231 const char* attrString(int32_t attrId) {
   6232   switch (attrId) {
   6233     case UNUM_INTEGER_FIELD: return "integer";
   6234     case UNUM_FRACTION_FIELD: return "fraction";
   6235     case UNUM_DECIMAL_SEPARATOR_FIELD: return "decimal separator";
   6236     case UNUM_EXPONENT_SYMBOL_FIELD: return "exponent symbol";
   6237     case UNUM_EXPONENT_SIGN_FIELD: return "exponent sign";
   6238     case UNUM_EXPONENT_FIELD: return "exponent";
   6239     case UNUM_GROUPING_SEPARATOR_FIELD: return "grouping separator";
   6240     case UNUM_CURRENCY_FIELD: return "currency";
   6241     case UNUM_PERCENT_FIELD: return "percent";
   6242     case UNUM_PERMILL_FIELD: return "permille";
   6243     case UNUM_SIGN_FIELD: return "sign";
   6244     default: return "";
   6245   }
   6246 }
   6247 
   6248 //
   6249 //   Test formatting & parsing of big decimals.
   6250 //      API test, not a comprehensive test.
   6251 //      See DecimalFormatTest/DataDrivenTests
   6252 //
   6253 #define ASSERT_SUCCESS(status) {if (U_FAILURE(status)) errln("file %s, line %d: status: %s", \
   6254                                                 __FILE__, __LINE__, u_errorName(status));}
   6255 #define ASSERT_EQUALS(expected, actual) {if ((expected) != (actual)) \
   6256                   errln("file %s, line %d: %s != %s", __FILE__, __LINE__, #expected, #actual);}
   6257 
   6258 static UBool operator != (const char *s1, UnicodeString &s2) {
   6259     // This function lets ASSERT_EQUALS("literal", UnicodeString) work.
   6260     UnicodeString us1(s1);
   6261     return us1 != s2;
   6262 }
   6263 
   6264 void NumberFormatTest::TestDecimal() {
   6265     {
   6266         UErrorCode  status = U_ZERO_ERROR;
   6267         Formattable f("12.345678999987654321E666", status);
   6268         ASSERT_SUCCESS(status);
   6269         StringPiece s = f.getDecimalNumber(status);
   6270         ASSERT_SUCCESS(status);
   6271         ASSERT_EQUALS("1.2345678999987654321E+667", s);
   6272         //printf("%s\n", s.data());
   6273     }
   6274 
   6275     {
   6276         UErrorCode status = U_ZERO_ERROR;
   6277         Formattable f1("this is not a number", status);
   6278         ASSERT_EQUALS(U_DECIMAL_NUMBER_SYNTAX_ERROR, status);
   6279     }
   6280 
   6281     {
   6282         UErrorCode status = U_ZERO_ERROR;
   6283         Formattable f;
   6284         f.setDecimalNumber("123.45", status);
   6285         ASSERT_SUCCESS(status);
   6286         ASSERT_EQUALS( Formattable::kDouble, f.getType());
   6287         ASSERT_EQUALS(123.45, f.getDouble());
   6288         ASSERT_EQUALS(123.45, f.getDouble(status));
   6289         ASSERT_SUCCESS(status);
   6290         ASSERT_EQUALS("123.45", f.getDecimalNumber(status));
   6291         ASSERT_SUCCESS(status);
   6292 
   6293         f.setDecimalNumber("4.5678E7", status);
   6294         int32_t n;
   6295         n = f.getLong();
   6296         ASSERT_EQUALS(45678000, n);
   6297 
   6298         status = U_ZERO_ERROR;
   6299         f.setDecimalNumber("-123", status);
   6300         ASSERT_SUCCESS(status);
   6301         ASSERT_EQUALS( Formattable::kLong, f.getType());
   6302         ASSERT_EQUALS(-123, f.getLong());
   6303         ASSERT_EQUALS(-123, f.getLong(status));
   6304         ASSERT_SUCCESS(status);
   6305         ASSERT_EQUALS("-123", f.getDecimalNumber(status));
   6306         ASSERT_SUCCESS(status);
   6307 
   6308         status = U_ZERO_ERROR;
   6309         f.setDecimalNumber("1234567890123", status);  // Number too big for 32 bits
   6310         ASSERT_SUCCESS(status);
   6311         ASSERT_EQUALS( Formattable::kInt64, f.getType());
   6312         ASSERT_EQUALS(1234567890123LL, f.getInt64());
   6313         ASSERT_EQUALS(1234567890123LL, f.getInt64(status));
   6314         ASSERT_SUCCESS(status);
   6315         ASSERT_EQUALS("1234567890123", f.getDecimalNumber(status));
   6316         ASSERT_SUCCESS(status);
   6317     }
   6318 
   6319     {
   6320         UErrorCode status = U_ZERO_ERROR;
   6321         NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
   6322         if (U_FAILURE(status) || fmtr == NULL) {
   6323             dataerrln("Unable to create NumberFormat");
   6324         } else {
   6325             UnicodeString formattedResult;
   6326             StringPiece num("244444444444444444444444444444444444446.4");
   6327             fmtr->format(num, formattedResult, NULL, status);
   6328             ASSERT_SUCCESS(status);
   6329             ASSERT_EQUALS("244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult);
   6330             //std::string ss; std::cout << formattedResult.toUTF8String(ss);
   6331             delete fmtr;
   6332         }
   6333     }
   6334 
   6335     {
   6336         // Check formatting a DigitList.  DigitList is internal, but this is
   6337         // a critical interface that must work.
   6338         UErrorCode status = U_ZERO_ERROR;
   6339         NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
   6340         if (U_FAILURE(status) || fmtr == NULL) {
   6341             dataerrln("Unable to create NumberFormat");
   6342         } else {
   6343             UnicodeString formattedResult;
   6344             DigitList dl;
   6345             StringPiece num("123.4566666666666666666666666666666666621E+40");
   6346             dl.set(num, status);
   6347             ASSERT_SUCCESS(status);
   6348             fmtr->format(dl, formattedResult, NULL, status);
   6349             ASSERT_SUCCESS(status);
   6350             ASSERT_EQUALS("1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult);
   6351 
   6352             status = U_ZERO_ERROR;
   6353             num.set("666.666");
   6354             dl.set(num, status);
   6355             FieldPosition pos(NumberFormat::FRACTION_FIELD);
   6356             ASSERT_SUCCESS(status);
   6357             formattedResult.remove();
   6358             fmtr->format(dl, formattedResult, pos, status);
   6359             ASSERT_SUCCESS(status);
   6360             ASSERT_EQUALS("666.666", formattedResult);
   6361             ASSERT_EQUALS(4, pos.getBeginIndex());
   6362             ASSERT_EQUALS(7, pos.getEndIndex());
   6363             delete fmtr;
   6364         }
   6365     }
   6366 
   6367     {
   6368         // Check a parse with a formatter with a multiplier.
   6369         UErrorCode status = U_ZERO_ERROR;
   6370         NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_PERCENT, status);
   6371         if (U_FAILURE(status) || fmtr == NULL) {
   6372             dataerrln("Unable to create NumberFormat");
   6373         } else {
   6374             UnicodeString input = "1.84%";
   6375             Formattable result;
   6376             fmtr->parse(input, result, status);
   6377             ASSERT_SUCCESS(status);
   6378             ASSERT_EQUALS(0, strcmp("0.0184", result.getDecimalNumber(status).data()));
   6379             //std::cout << result.getDecimalNumber(status).data();
   6380             delete fmtr;
   6381         }
   6382     }
   6383 
   6384 #if U_PLATFORM != U_PF_CYGWIN || defined(CYGWINMSVC)
   6385     /*
   6386      * This test fails on Cygwin (1.7.16) using GCC because of a rounding issue with strtod().
   6387      * See #9463
   6388      */
   6389     {
   6390         // Check that a parse returns a decimal number with full accuracy
   6391         UErrorCode status = U_ZERO_ERROR;
   6392         NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
   6393         if (U_FAILURE(status) || fmtr == NULL) {
   6394             dataerrln("Unable to create NumberFormat");
   6395         } else {
   6396             UnicodeString input = "1.002200044400088880000070000";
   6397             Formattable result;
   6398             fmtr->parse(input, result, status);
   6399             ASSERT_SUCCESS(status);
   6400             ASSERT_EQUALS(0, strcmp("1.00220004440008888000007", result.getDecimalNumber(status).data()));
   6401             ASSERT_EQUALS(1.00220004440008888,   result.getDouble());
   6402             //std::cout << result.getDecimalNumber(status).data();
   6403             delete fmtr;
   6404         }
   6405     }
   6406 #endif
   6407 
   6408 }
   6409 
   6410 void NumberFormatTest::TestCurrencyFractionDigits() {
   6411     UErrorCode status = U_ZERO_ERROR;
   6412     UnicodeString text1, text2;
   6413     double value = 99.12345;
   6414 
   6415     // Create currenct instance
   6416     NumberFormat* fmt = NumberFormat::createCurrencyInstance("ja_JP", status);
   6417     if (U_FAILURE(status) || fmt == NULL) {
   6418         dataerrln("Unable to create NumberFormat");
   6419     } else {
   6420         fmt->format(value, text1);
   6421 
   6422         // Reset the same currency and format the test value again
   6423         fmt->setCurrency(fmt->getCurrency(), status);
   6424         ASSERT_SUCCESS(status);
   6425         fmt->format(value, text2);
   6426 
   6427         if (text1 != text2) {
   6428             errln((UnicodeString)"NumberFormat::format() should return the same result - text1="
   6429                 + text1 + " text2=" + text2);
   6430         }
   6431         delete fmt;
   6432     }
   6433 }
   6434 
   6435 void NumberFormatTest::TestExponentParse() {
   6436 
   6437     UErrorCode status = U_ZERO_ERROR;
   6438     Formattable result;
   6439     ParsePosition parsePos(0);
   6440 
   6441     // set the exponent symbol
   6442     status = U_ZERO_ERROR;
   6443     DecimalFormatSymbols *symbols = new DecimalFormatSymbols(Locale::getDefault(), status);
   6444     if(U_FAILURE(status)) {
   6445         dataerrln((UnicodeString)"ERROR: Could not create DecimalFormatSymbols (Default)");
   6446         return;
   6447     }
   6448 
   6449     // create format instance
   6450     status = U_ZERO_ERROR;
   6451     DecimalFormat fmt("#####", symbols, status);
   6452     if(U_FAILURE(status)) {
   6453         errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
   6454     }
   6455 
   6456     // parse the text
   6457     fmt.parse("5.06e-27", result, parsePos);
   6458     if(result.getType() != Formattable::kDouble &&
   6459        result.getDouble() != 5.06E-27 &&
   6460        parsePos.getIndex() != 8
   6461        )
   6462     {
   6463         errln("ERROR: parse failed - expected 5.06E-27, 8  - returned %d, %i",
   6464               result.getDouble(), parsePos.getIndex());
   6465     }
   6466 }
   6467 
   6468 void NumberFormatTest::TestExplicitParents() {
   6469 
   6470     /* Test that number formats are properly inherited from es_419 */
   6471     /* These could be subject to change if the CLDR data changes */
   6472     static const char* parentLocaleTests[][2]= {
   6473     /* locale ID */  /* expected */
   6474     {"es_CO", "1.250,75" },
   6475     {"es_CR", "1.250,75" },
   6476     {"es_ES", "1.250,75" },
   6477     {"es_GQ", "1.250,75" },
   6478     {"es_MX", "1,250.75" },
   6479     {"es_US", "1,250.75" },
   6480     {"es_VE", "1.250,75" },
   6481     };
   6482 
   6483     UnicodeString s;
   6484 
   6485     for(int i=0; i < (int)(sizeof(parentLocaleTests)/sizeof(parentLocaleTests[i])); i++){
   6486         UErrorCode status = U_ZERO_ERROR;
   6487         const char *localeID = parentLocaleTests[i][0];
   6488         UnicodeString expected(parentLocaleTests[i][1], -1, US_INV);
   6489         expected = expected.unescape();
   6490         char loc[256]={0};
   6491         uloc_canonicalize(localeID, loc, 256, &status);
   6492         NumberFormat *fmt= NumberFormat::createInstance(Locale(loc), status);
   6493         if(U_FAILURE(status)){
   6494             dataerrln("Could not create number formatter for locale %s - %s",localeID, u_errorName(status));
   6495             continue;
   6496         }
   6497         s.remove();
   6498         fmt->format(1250.75, s);
   6499         if(s!=expected){
   6500             errln(UnicodeString("FAIL: Expected: ")+expected
   6501                     + UnicodeString(" Got: ") + s
   6502                     + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
   6503         }
   6504         if (U_FAILURE(status)){
   6505             errln((UnicodeString)"FAIL: Status " + (int32_t)status);
   6506         }
   6507         delete fmt;
   6508     }
   6509 
   6510 }
   6511 
   6512 /**
   6513  * Test available numbering systems API.
   6514  */
   6515 void NumberFormatTest::TestAvailableNumberingSystems() {
   6516     UErrorCode status = U_ZERO_ERROR;
   6517     StringEnumeration *availableNumberingSystems = NumberingSystem::getAvailableNames(status);
   6518     CHECK_DATA(status, "NumberingSystem::getAvailableNames()")
   6519 
   6520     int32_t nsCount = availableNumberingSystems->count(status);
   6521     if ( nsCount < 36 ) {
   6522         errln("FAIL: Didn't get as many numbering systems as we had hoped for. Need at least 36, got %d",nsCount);
   6523     }
   6524 
   6525     /* A relatively simple test of the API.  We call getAvailableNames() and cycle through */
   6526     /* each name returned, attempting to create a numbering system based on that name and  */
   6527     /* verifying that the name returned from the resulting numbering system is the same    */
   6528     /* one that we initially thought.                                                      */
   6529 
   6530     int32_t len;
   6531     for ( int32_t i = 0 ; i < nsCount ; i++ ) {
   6532         const char *nsname = availableNumberingSystems->next(&len,status);
   6533         NumberingSystem* ns = NumberingSystem::createInstanceByName(nsname,status);
   6534         if ( uprv_strcmp(nsname,ns->getName()) ) {
   6535             errln("FAIL: Numbering system name didn't match for name = %s\n",nsname);
   6536         }
   6537 
   6538         delete ns;
   6539     }
   6540 
   6541     delete availableNumberingSystems;
   6542 }
   6543 
   6544 void
   6545 NumberFormatTest::Test9087(void)
   6546 {
   6547     U_STRING_DECL(pattern,"#",1);
   6548     U_STRING_INIT(pattern,"#",1);
   6549 
   6550     U_STRING_DECL(infstr,"INF",3);
   6551     U_STRING_INIT(infstr,"INF",3);
   6552 
   6553     U_STRING_DECL(nanstr,"NAN",3);
   6554     U_STRING_INIT(nanstr,"NAN",3);
   6555 
   6556     UChar outputbuf[50] = {0};
   6557     UErrorCode status = U_ZERO_ERROR;
   6558     UNumberFormat* fmt = unum_open(UNUM_PATTERN_DECIMAL,pattern,1,NULL,NULL,&status);
   6559     if ( U_FAILURE(status) ) {
   6560         dataerrln("FAIL: error in unum_open() - %s", u_errorName(status));
   6561         return;
   6562     }
   6563 
   6564     unum_setSymbol(fmt,UNUM_INFINITY_SYMBOL,infstr,3,&status);
   6565     unum_setSymbol(fmt,UNUM_NAN_SYMBOL,nanstr,3,&status);
   6566     if ( U_FAILURE(status) ) {
   6567         errln("FAIL: error setting symbols");
   6568     }
   6569 
   6570     double inf = uprv_getInfinity();
   6571 
   6572     unum_setAttribute(fmt,UNUM_ROUNDING_MODE,UNUM_ROUND_HALFEVEN);
   6573     unum_setDoubleAttribute(fmt,UNUM_ROUNDING_INCREMENT,0);
   6574 
   6575     UFieldPosition position = { 0, 0, 0};
   6576     unum_formatDouble(fmt,inf,outputbuf,50,&position,&status);
   6577 
   6578     if ( u_strcmp(infstr, outputbuf)) {
   6579         errln((UnicodeString)"FAIL: unexpected result for infinity - expected " + infstr + " got " + outputbuf);
   6580     }
   6581 
   6582     unum_close(fmt);
   6583 }
   6584 
   6585 #include "dcfmtimp.h"
   6586 
   6587 void NumberFormatTest::TestFormatFastpaths() {
   6588 #if UCONFIG_FORMAT_FASTPATHS_49
   6589     logln("Sizeof DecimalFormat = %d, Sizeof DecimalFormatInternal=%d, UNUM_DECIMALFORMAT_INTERNAL_SIZE=%d\n",
   6590         sizeof(DecimalFormat), sizeof(DecimalFormatInternal), UNUM_DECIMALFORMAT_INTERNAL_SIZE);
   6591     if(UNUM_DECIMALFORMAT_INTERNAL_SIZE < sizeof(DecimalFormatInternal)) {
   6592         errln("Error: sizeof(DecimalFormatInternal)=%d but UNUM_DECIMALFORMAT_INTERNAL_SIZE is only %d. Increase the #define?\n", sizeof(DecimalFormatInternal), UNUM_DECIMALFORMAT_INTERNAL_SIZE);
   6593     } else if(UNUM_DECIMALFORMAT_INTERNAL_SIZE > (sizeof(DecimalFormatInternal)+16)) {
   6594         infoln("Note: sizeof(DecimalFormatInternal)=%d but UNUM_DECIMALFORMAT_INTERNAL_SIZE is %d. Decrease the #define? sizeof(DecimalFormat)=%d\n", sizeof(DecimalFormatInternal), UNUM_DECIMALFORMAT_INTERNAL_SIZE, sizeof(DecimalFormat));
   6595     }
   6596 #else
   6597     infoln("NOTE: UCONFIG_FORMAT_FASTPATHS not set, test skipped.");
   6598 #endif
   6599 
   6600     // get some additional case
   6601     {
   6602         UErrorCode status=U_ZERO_ERROR;
   6603         DecimalFormat df(UnicodeString("0000",""),status);
   6604         int64_t long_number = 1;
   6605         UnicodeString expect = "0001";
   6606         UnicodeString result;
   6607         FieldPosition pos;
   6608         df.format(long_number, result, pos);
   6609         if(U_FAILURE(status)||expect!=result) {
   6610             errcheckln(status, "FAIL: expected '"+expect+"' got '"+result+"' status "+UnicodeString(u_errorName(status),""));
   6611         } else {
   6612             logln("OK:  got expected '"+result+"' status "+UnicodeString(u_errorName(status),""));
   6613         }
   6614     }
   6615     {
   6616         UErrorCode status=U_ZERO_ERROR;
   6617         DecimalFormat df(UnicodeString("0000000000000000000",""),status);
   6618         int64_t long_number = U_INT64_MIN; // -9223372036854775808L;
   6619         // uint8_t bits[8];
   6620         // memcpy(bits,&long_number,8);
   6621         // for(int i=0;i<8;i++) {
   6622         //   logln("bits: %02X", (unsigned int)bits[i]);
   6623         // }
   6624         UnicodeString expect = "-9223372036854775808";
   6625         UnicodeString result;
   6626         FieldPosition pos;
   6627         df.format(long_number, result, pos);
   6628         if(U_FAILURE(status)||expect!=result) {
   6629             errcheckln(status, "FAIL: expected '"+expect+"' got '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on -9223372036854775808");
   6630         } else {
   6631             logln("OK:  got expected '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on -9223372036854775808");
   6632         }
   6633     }
   6634     {
   6635         UErrorCode status=U_ZERO_ERROR;
   6636         DecimalFormat df(UnicodeString("0000000000000000000",""),status);
   6637         int64_t long_number = U_INT64_MAX; // -9223372036854775808L;
   6638         // uint8_t bits[8];
   6639         // memcpy(bits,&long_number,8);
   6640         // for(int i=0;i<8;i++) {
   6641         //   logln("bits: %02X", (unsigned int)bits[i]);
   6642         // }
   6643         UnicodeString expect = "9223372036854775807";
   6644         UnicodeString result;
   6645         FieldPosition pos;
   6646         df.format(long_number, result, pos);
   6647         if(U_FAILURE(status)||expect!=result) {
   6648             errcheckln(status, "FAIL: expected '"+expect+"' got '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on U_INT64_MAX");
   6649         } else {
   6650             logln("OK:  got expected '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on U_INT64_MAX");
   6651         }
   6652     }
   6653     {
   6654         UErrorCode status=U_ZERO_ERROR;
   6655         DecimalFormat df(UnicodeString("0000000000000000000",""),status);
   6656         int64_t long_number = 0;
   6657         // uint8_t bits[8];
   6658         // memcpy(bits,&long_number,8);
   6659         // for(int i=0;i<8;i++) {
   6660         //   logln("bits: %02X", (unsigned int)bits[i]);
   6661         // }
   6662         UnicodeString expect = "0000000000000000000";
   6663         UnicodeString result;
   6664         FieldPosition pos;
   6665         df.format(long_number, result, pos);
   6666         if(U_FAILURE(status)||expect!=result) {
   6667             errcheckln(status, "FAIL: expected '"+expect+"' got '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on 0");
   6668         } else {
   6669             logln("OK:  got expected '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on 0");
   6670         }
   6671     }
   6672     {
   6673         UErrorCode status=U_ZERO_ERROR;
   6674         DecimalFormat df(UnicodeString("0000000000000000000",""),status);
   6675         int64_t long_number = U_INT64_MIN + 1;
   6676         UnicodeString expect = "-9223372036854775807";
   6677         UnicodeString result;
   6678         FieldPosition pos;
   6679         df.format(long_number, result, pos);
   6680         if(U_FAILURE(status)||expect!=result) {
   6681             errcheckln(status, "FAIL: expected '"+expect+"' got '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on -9223372036854775807");
   6682         } else {
   6683             logln("OK:  got expected '"+result+"' status "+UnicodeString(u_errorName(status),"")+" on -9223372036854775807");
   6684         }
   6685     }
   6686 }
   6687 
   6688 enum myEnum {
   6689     MAX_NONBOOLEAN=-1,
   6690     THING1,
   6691     THING2,
   6692     THING3,
   6693     LIMIT_BOOLEAN
   6694 };
   6695 
   6696 void NumberFormatTest::TestEnumSet(void) {
   6697     EnumSet<myEnum,
   6698             MAX_NONBOOLEAN+1,
   6699             LIMIT_BOOLEAN>
   6700                             flags;
   6701     infoln("TODO!! This test doesn't fail on error. Convert printf into error assert.\n");
   6702 
   6703     logln("Enum is from [%d..%d]\n", MAX_NONBOOLEAN+1,
   6704           LIMIT_BOOLEAN);
   6705 
   6706     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6707     logln("Value now: %d\n", flags.getAll());
   6708     flags.clear();
   6709     logln("clear -Value now: %d\n", flags.getAll());
   6710     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6711     flags.add(THING1);
   6712     logln("set THING1 -Value now: %d\n", flags.getAll());
   6713     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6714     flags.add(THING3);
   6715     logln("set THING3 -Value now: %d\n", flags.getAll());
   6716     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6717     flags.remove(THING2);
   6718     logln("remove THING2 -Value now: %d\n", flags.getAll());
   6719     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6720     flags.remove(THING1);
   6721     logln("remove THING1 -Value now: %d\n", flags.getAll());
   6722     logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
   6723 
   6724 }
   6725 
   6726 void NumberFormatTest::TestFormattableSize(void) {
   6727   if(sizeof(FmtStackData) > UNUM_INTERNAL_STACKARRAY_SIZE) {
   6728     errln("Error: sizeof(FmtStackData)=%d, UNUM_INTERNAL_STACKARRAY_SIZE=%d\n",
   6729           sizeof(FmtStackData), UNUM_INTERNAL_STACKARRAY_SIZE);
   6730   } else if(sizeof(FmtStackData) < UNUM_INTERNAL_STACKARRAY_SIZE) {
   6731     logln("Warning: sizeof(FmtStackData)=%d, UNUM_INTERNAL_STACKARRAY_SIZE=%d\n",
   6732         sizeof(FmtStackData), UNUM_INTERNAL_STACKARRAY_SIZE);
   6733   } else {
   6734     logln("sizeof(FmtStackData)=%d, UNUM_INTERNAL_STACKARRAY_SIZE=%d\n",
   6735         sizeof(FmtStackData), UNUM_INTERNAL_STACKARRAY_SIZE);
   6736   }
   6737 }
   6738 
   6739 #endif /* #if !UCONFIG_NO_FORMATTING */
   6740