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