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