1 /********************************************************************
3 * Copyright (c) 1997-2010, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /* Modification History:
7 * Date Name Description
8 * 07/15/99 helena Ported to HPUX 10/11 CC.
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/dcfmtsym.h"
17 #include "unicode/decimfmt.h"
18 #include "unicode/ucurr.h"
19 #include "unicode/ustring.h"
20 #include "unicode/measfmt.h"
21 #include "unicode/curramt.h"
32 #include "unicode/numsys.h"
34 //#define NUMFMTST_CACHE_DEBUG 1
35 #ifdef NUMFMTST_CACHE_DEBUG
36 #include "stdio.h" /* for sprintf */
39 // #include "iostream" // for cout
41 //#define NUMFMTST_DEBUG 1
44 static const UChar EUR
[] = {69,85,82,0}; // "EUR"
45 static const UChar ISO_CURRENCY_USD
[] = {0x55, 0x53, 0x44, 0}; // "USD"
47 // *****************************************************************************
48 // class NumberFormatTest
49 // *****************************************************************************
51 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
53 #define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
54 #define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
56 void NumberFormatTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ )
58 // if (exec) logln((UnicodeString)"TestSuite DateFormatTest");
60 CASE(0,TestCurrencySign
);
63 CASE(3,TestRounding487
);
65 CASE(5,TestExponential
);
68 // Upgrade to alphaWorks - liu 5/99
70 CASE(8,TestScientific
);
72 CASE(10,TestPatterns2
);
73 CASE(11,TestSecondaryGrouping
);
74 CASE(12,TestSurrogateSupport
);
77 CASE(14,TestCurrencyObject
);
78 CASE(15,TestCurrencyPatterns
);
79 //CASE(16,TestDigitList);
80 CASE(16,TestWhiteSpaceParsing
);
81 CASE(17,TestComplexCurrency
); // This test removed because CLDR no longer uses choice formats in currency symbols.
82 CASE(18,TestRegCurrency
);
83 CASE(19,TestSymbolsWithBadLocale
);
84 CASE(20,TestAdoptDecimalFormatSymbols
);
86 CASE(21,TestScientific2
);
87 CASE(22,TestScientificGrouping
);
91 CASE(25,TestIllegalPatterns
);
94 CASE(27,TestCurrencyNames
);
95 CASE(28,TestCurrencyAmount
);
96 CASE(29,TestCurrencyUnit
);
97 CASE(30,TestCoverage
);
100 CASE(33,TestHostClone
);
101 CASE(34,TestCurrencyFormat
);
102 CASE(35,TestRounding
);
103 CASE(36,TestNonpositiveMultiplier
);
104 CASE(37,TestNumberingSystems
);
105 CASE(38,TestSpaceParsing
);
106 CASE(39,TestMultiCurrencySign
);
107 CASE(40,TestCurrencyFormatForMixParsing
);
108 CASE(41,TestDecimalFormatCurrencyParse
);
109 CASE(42,TestCurrencyIsoPluralFormat
);
110 CASE(43,TestCurrencyParsing
);
111 CASE(44,TestParseCurrencyInUCurr
);
112 CASE(45,TestFormatAttributes
);
113 CASE(46,TestFieldPositionIterator
);
114 CASE(47,TestDecimal
);
115 CASE(48,TestCurrencyFractionDigits
);
116 CASE(49,TestExponentParse
);
117 CASE(50,TestLenientParse
);
118 default: name
= ""; break;
122 // -------------------------------------
124 // Test API (increase code coverage)
126 NumberFormatTest::TestAPI(void)
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
));
135 test
->setMinimumIntegerDigits(10);
136 test
->setMaximumIntegerDigits(2);
138 test
->setMinimumFractionDigits(10);
139 test
->setMaximumFractionDigits(2);
141 UnicodeString result
;
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!");
148 status
= U_ZERO_ERROR
;
153 test
->format(ll
, result
);
154 if (result
!= "12.00"){
155 errln("format int64_t error");
159 test
->parseCurrency("",bla
,ppos
);
160 if(U_FAILURE(status
)) {
161 errln("Problems accessing the parseCurrency function for NumberFormat");
168 class StubNumberForamt
:public NumberFormat
{
170 StubNumberForamt(){};
171 virtual UnicodeString
& format(double ,UnicodeString
& appendTo
,FieldPosition
& ) const {
174 virtual UnicodeString
& format(int32_t ,UnicodeString
& appendTo
,FieldPosition
& ) const {
175 return appendTo
.append((UChar
)0x0033);
177 virtual UnicodeString
& format(int64_t number
,UnicodeString
& appendTo
,FieldPosition
& pos
) const {
178 return NumberFormat::format(number
, appendTo
, pos
);
180 virtual UnicodeString
& format(const Formattable
& , UnicodeString
& appendTo
, FieldPosition
& , UErrorCode
& ) const {
183 virtual void parse(const UnicodeString
& ,
185 ParsePosition
& ) const {}
186 virtual void parse( const UnicodeString
& ,
188 UErrorCode
& ) const {}
189 virtual UClassID
getDynamicClassID(void) const {
190 static char classID
= 0;
191 return (UClassID
)&classID
;
193 virtual Format
* clone() const {return NULL
;}
197 NumberFormatTest::TestCoverage(void){
198 StubNumberForamt stub
;
199 UnicodeString
agent("agent");
202 if (stub
.format(num
, agent
, pos
) != UnicodeString("agent3")){
203 errln("NumberFormat::format(int64, UnicodString&, FieldPosition&) should delegate to (int32, ,)");
207 // Test various patterns
209 NumberFormatTest::TestPatterns(void)
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; }
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
)
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");
229 UnicodeString s
; (*(NumberFormat
*)&fmt
).format((int32_t)0, s
);
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());
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
246 NumberFormatTest::TestDigitList(void)
248 // API coverage for DigitList
251 list1.fDecimalAt = 1;
253 list2.set((int32_t)1);
254 if (list1 != list2) {
255 errln("digitlist append, operator!= or set failed ");
257 if (!(list1 == list2)) {
258 errln("digitlist append, operator== or set failed ");
263 // -------------------------------------
265 // Test exponential pattern
267 NumberFormatTest::TestExponential(void)
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]));
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.
281 // This section may be expanded as needed.
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
[] =
289 "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
291 "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
293 "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
295 "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
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,
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]);
310 "1.234E-2", "1.2346E8", "1.23E70", "-3.1416E-71",
312 "12.340E-03", "12.346E07", "12.300E69", "-31.416E-72",
314 "12.34E-003", "123.4568E006", "12.3E069", "-31.41593E-072",
316 "1.234E-2", "1.235E8", "1.23E70", "[3.142E-71]"
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,
326 // Don't test double conversion
328 int32_t val_length
= 0;
329 char** valFormat
= 0;
330 double* valParse
= 0;
331 logln("Warning: Skipping double conversion tests");
334 int32_t lval
[] = { 0, -1, 1, 123456789 };
335 int32_t lval_length
= (int32_t)(sizeof(lval
) / sizeof(lval
[0]));
336 const char* lvalFormat
[] =
339 "0E0", "-1E0", "1E0", "1.2346E8",
341 "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
343 "0E000", "-1E000", "1E000", "123.4568E006",
345 "0E0", "[1E0]", "1E0", "1.235E8"
347 int32_t lvalParse
[] =
354 int32_t ival
= 0, ilval
= 0;
355 for (int32_t p
=0; p
<pat_length
; ++p
)
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
) + "\"");
363 for (v
=0; v
<val_length
; ++v
)
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
]);
370 ParsePosition
pos(0);
372 fmt
.parse(s
, af
, pos
);
374 UBool useEpsilon
= FALSE
;
375 if (af
.getType() == Formattable::kLong
)
377 else if (af
.getType() == Formattable::kDouble
) {
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.
391 errln((UnicodeString
)"FAIL: Non-numeric Formattable returned");
394 if (pos
.getIndex() == s
.length())
396 logln((UnicodeString
)" -parse-> " + a
);
397 // Use epsilon comparison as necessary
399 (uprv_fabs(a
- valParse
[v
+ival
]) / a
> (2*DBL_EPSILON
))) ||
400 (!useEpsilon
&& a
!= valParse
[v
+ival
]))
402 errln((UnicodeString
)"FAIL: Expected " + valParse
[v
+ival
]);
406 errln((UnicodeString
)"FAIL: Partial parse (" + pos
.getIndex() + " chars) -> " + a
);
407 errln((UnicodeString
)" should be (" + s
.length() + " chars) -> " + valParse
[v
+ival
]);
410 for (v
=0; v
<lval_length
; ++v
)
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
);
418 ParsePosition
pos(0);
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())
427 logln((UnicodeString
)" -parse-> " + a
);
428 if (a
!= lvalParse
[v
+ilval
])
429 errln((UnicodeString
)"FAIL: Expected " + lvalParse
[v
+ilval
]);
432 errln((UnicodeString
)"FAIL: Partial parse (" + pos
.getIndex() + " chars) -> " + a
);
435 errln((UnicodeString
)"FAIL: Non-long Formattable returned for " + s
436 + " Double: " + af
.getDouble()
437 + ", Long: " + af
.getLong());
440 ilval
+= lval_length
;
445 NumberFormatTest::TestScientific2() {
447 UErrorCode status
= U_ZERO_ERROR
;
448 DecimalFormat
* fmt
= (DecimalFormat
*)NumberFormat::createCurrencyInstance("en_US", status
);
449 if (U_SUCCESS(status
)) {
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");
461 NumberFormatTest::TestScientificGrouping() {
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");
475 /*static void setFromString(DigitList& dl, const char* str) {
477 UBool decimalSet = FALSE;
479 while ((c = *str++)) {
481 dl.fIsPositive = FALSE;
482 } else if (c == '+') {
483 dl.fIsPositive = TRUE;
484 } else if (c == '.') {
485 dl.fDecimalAt = dl.fCount;
492 dl.fDecimalAt = dl.fCount;
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");
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: ");
518 // test max int64 value
520 setFromString(dl, int64maxstr);
522 if (!dl.fitsIntoInt64(FALSE)) {
523 errln(fail + int64maxstr + " didn't fit");
525 int64_t int64Value = dl.getInt64();
526 if (int64Value != int64max) {
527 errln(fail + int64maxstr);
530 int64Value = dl.getInt64();
531 if (int64Value != int64max) {
532 errln(fail + int64maxstr);
535 // test negative of max int64 value (1 shy of min int64 value)
536 dl.fIsPositive = FALSE;
538 if (!dl.fitsIntoInt64(FALSE)) {
539 errln(fail + "-" + int64maxstr + " didn't fit");
541 int64_t int64Value = dl.getInt64();
542 if (int64Value != -int64max) {
543 errln(fail + "-" + int64maxstr);
546 int64Value = dl.getInt64();
547 if (int64Value != -int64max) {
548 errln(fail + "-" + int64maxstr);
551 // test min int64 value
552 setFromString(dl, int64minstr);
554 if (!dl.fitsIntoInt64(FALSE)) {
555 errln(fail + "-" + int64minstr + " didn't fit");
557 int64_t int64Value = dl.getInt64();
558 if (int64Value != int64min) {
559 errln(fail + int64minstr);
562 int64Value = dl.getInt64();
563 if (int64Value != int64min) {
564 errln(fail + int64minstr);
567 // test negative of min int 64 value (1 more than max int64 value)
568 dl.fIsPositive = TRUE; // won't fit
570 if (dl.fitsIntoInt64(FALSE)) {
571 errln(fail + "-(" + int64minstr + ") didn't fit");
576 // -------------------------------------
578 // Test the handling of quotes
580 NumberFormatTest::TestQuotes(void)
582 UErrorCode status
= U_ZERO_ERROR
;
584 DecimalFormatSymbols
*sym
= new DecimalFormatSymbols(Locale::getUS(), status
);
585 if (U_FAILURE(status
)) {
586 errcheckln(status
, "Fail to create DecimalFormatSymbols - %s", u_errorName(status
));
590 pat
= new UnicodeString("a'fo''o'b#");
591 DecimalFormat
*fmt
= new DecimalFormat(*pat
, *sym
, status
);
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");
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
));
609 errln((UnicodeString
)"FAIL: Expected a'b123");
616 * Test the handling of the currency symbol in patterns.
619 NumberFormatTest::TestCurrencySign(void)
621 UErrorCode status
= U_ZERO_ERROR
;
622 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale::getUS(), status
);
624 UChar currency
= 0x00A4;
625 if (U_FAILURE(status
)) {
626 errcheckln(status
, "Fail to create DecimalFormatSymbols - %s", u_errorName(status
));
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
);
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");
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");
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
);
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");
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");
662 if (U_FAILURE(status
)) errln((UnicodeString
)"FAIL: Status " + u_errorName(status
));
665 // -------------------------------------
667 static UChar
toHexString(int32_t i
) { return (UChar
)(i
+ (i
< 10 ? 0x30 : (0x41 - 10))); }
670 NumberFormatTest::escape(UnicodeString
& s
)
673 for (int32_t i
=0; i
<s
.length(); ++i
)
675 UChar c
= s
[(int32_t)i
];
676 if (c
<= (UChar
)0x7F) buf
+= c
;
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);
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\\u00A0BF" },
696 {"es_ES_PREEURO", "\\u20A7\\u00A01.150" },
697 {"eu_ES_PREEURO", "1.150\\u00A0\\u20A7" },
698 {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" },
699 {"it_IT_PREEURO", "IT\\u20A4\\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"}
706 * Test localized currency patterns.
709 NumberFormatTest::TestCurrency(void)
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()");
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>$");
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\\u00A0DM")))
730 errln((UnicodeString
)"FAIL: Expected 1,50<nbsp>DM");
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");
740 if (U_FAILURE(status
))
741 errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
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();
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
);
756 currencyFmt
->format(1150.50, s
);
758 errln(UnicodeString("FAIL: Expected: ")+expected
759 + UnicodeString(" Got: ") + s
760 + UnicodeString( " for locale: ")+ UnicodeString(localeID
) );
762 if (U_FAILURE(status
)){
763 errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
769 // -------------------------------------
772 * Test the Currency object handling, new as of ICU 2.2.
774 void NumberFormatTest::TestCurrencyObject() {
775 UErrorCode ec
= U_ZERO_ERROR
;
777 NumberFormat::createCurrencyInstance(Locale::getUS(), ec
);
780 dataerrln("FAIL: getCurrencyInstance(US) - %s", u_errorName(ec
));
785 Locale
null("", "", "");
787 expectCurrency(*fmt
, null
, 1234.56, "$1,234.56");
789 expectCurrency(*fmt
, Locale::getFrance(),
790 1234.56, CharsToUnicodeString("\\u20AC1,234.56")); // Euro
792 expectCurrency(*fmt
, Locale::getJapan(),
793 1234.56, CharsToUnicodeString("\\u00A51,235")); // Yen
795 expectCurrency(*fmt
, Locale("fr", "CH", ""),
796 1234.56, "CHF1,234.55"); // 0.05 rounding
798 expectCurrency(*fmt
, Locale::getUS(),
799 1234.56, "$1,234.56");
802 fmt
= NumberFormat::createCurrencyInstance(Locale::getFrance(), ec
);
805 errln("FAIL: getCurrencyInstance(FRANCE)");
810 expectCurrency(*fmt
, null
, 1234.56, CharsToUnicodeString("1 234,56 \\u20AC"));
812 expectCurrency(*fmt
, Locale::getJapan(),
813 1234.56, CharsToUnicodeString("1 235 \\u00A5JP")); // Yen
815 expectCurrency(*fmt
, Locale("fr", "CH", ""),
816 1234.56, "1 234,55 CHF"); // 0.05 rounding
818 expectCurrency(*fmt
, Locale::getUS(),
819 1234.56, "1 234,56 $US");
821 expectCurrency(*fmt
, Locale::getFrance(),
822 1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); // Euro
827 // -------------------------------------
830 * Do rudimentary testing of parsing.
833 NumberFormatTest::TestParse(void)
835 UErrorCode status
= U_ZERO_ERROR
;
836 UnicodeString
arg("0");
837 DecimalFormat
* format
= new DecimalFormat("00", status
);
841 format
->parse(arg
, n
, status
);
842 logln((UnicodeString
)"parse(" + arg
+ ") = " + n
.getLong());
843 if (n
.getType() != Formattable::kLong
||
844 n
.getLong() != 0) errln((UnicodeString
)"FAIL: Expected 0");
846 if (U_FAILURE(status
)) errcheckln(status
, (UnicodeString
)"FAIL: Status " + u_errorName(status
));
848 //catch(Exception e) {
849 // errln((UnicodeString)"Exception caught: " + e);
853 // -------------------------------------
855 static const char *lenientAffixTestCases
[] = {
862 static const char *lenientMinusTestCases
[] = {
868 static const char *lenientCurrencyTestCases
[] = {
879 static const char *lenientNegativeCurrencyTestCases
[] = {
887 "($ 1\\u00A0000.00)",
891 static const char *lenientPercentTestCases
[] = {
900 static const char *lenientNegativePercentTestCases
[] = {
912 static const char *strictFailureTestCases
[] = {
918 #define ARRAY_SIZE(array) ((int32_t) (sizeof (array) / sizeof(array[0])))
921 * Test lenient parsing.
924 NumberFormatTest::TestLenientParse(void)
926 UErrorCode status
= U_ZERO_ERROR
;
927 DecimalFormat
*format
= new DecimalFormat("(#,##0)", status
);
930 format
->setParseStrict(FALSE
);
931 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientAffixTestCases
); t
+= 1) {
932 UnicodeString testCase
= ctou(lenientAffixTestCases
[t
]);
934 format
->parse(testCase
, n
, status
);
935 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
937 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
||
939 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientAffixTestCases
[t
] + (UnicodeString
) "\"");
940 status
= U_ZERO_ERROR
;
946 Locale
en_US("en_US");
947 Locale
sv_SE("sv_SE");
949 NumberFormat
*mFormat
= NumberFormat::createInstance(sv_SE
, NumberFormat::kNumberStyle
, status
);
951 mFormat
->setParseStrict(FALSE
);
952 for (int32_t t
= 0; t
< ARRAY_SIZE(lenientMinusTestCases
); t
+= 1) {
953 UnicodeString testCase
= ctou(lenientMinusTestCases
[t
]);
955 mFormat
->parse(testCase
, n
, status
);
956 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
958 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
|| n
.getLong() != -5) {
959 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientMinusTestCases
[t
] + (UnicodeString
) "\"");
960 status
= U_ZERO_ERROR
;
966 mFormat
= NumberFormat::createInstance(en_US
, NumberFormat::kNumberStyle
, status
);
968 mFormat
->setParseStrict(FALSE
);
969 for (int32_t t
= 0; t
< ARRAY_SIZE(lenientMinusTestCases
); t
+= 1) {
970 UnicodeString testCase
= ctou(lenientMinusTestCases
[t
]);
972 mFormat
->parse(testCase
, n
, status
);
973 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
975 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
|| n
.getLong() != -5) {
976 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientMinusTestCases
[t
] + (UnicodeString
) "\"");
977 status
= U_ZERO_ERROR
;
983 NumberFormat
*cFormat
= NumberFormat::createInstance(en_US
, NumberFormat::kCurrencyStyle
, status
);
985 cFormat
->setParseStrict(FALSE
);
986 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientCurrencyTestCases
); t
+= 1) {
987 UnicodeString testCase
= ctou(lenientCurrencyTestCases
[t
]);
989 cFormat
->parse(testCase
, n
, status
);
990 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
992 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
993 n
.getLong() != 1000) {
994 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientCurrencyTestCases
[t
] + (UnicodeString
) "\"");
995 status
= U_ZERO_ERROR
;
999 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientNegativeCurrencyTestCases
); t
+= 1) {
1000 UnicodeString testCase
= ctou(lenientNegativeCurrencyTestCases
[t
]);
1002 cFormat
->parse(testCase
, n
, status
);
1003 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1005 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
1006 n
.getLong() != -1000) {
1007 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientNegativeCurrencyTestCases
[t
] + (UnicodeString
) "\"");
1008 status
= U_ZERO_ERROR
;
1014 NumberFormat
*pFormat
= NumberFormat::createPercentInstance(en_US
, status
);
1016 pFormat
->setParseStrict(FALSE
);
1017 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientPercentTestCases
); t
+= 1) {
1018 UnicodeString testCase
= ctou(lenientPercentTestCases
[t
]);
1020 pFormat
->parse(testCase
, n
, status
);
1021 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getDouble());
1023 if (U_FAILURE(status
) ||n
.getType() != Formattable::kDouble
||
1024 n
.getDouble() != 0.25) {
1025 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientPercentTestCases
[t
] + (UnicodeString
) "\"");
1026 status
= U_ZERO_ERROR
;
1030 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientNegativePercentTestCases
); t
+= 1) {
1031 UnicodeString testCase
= ctou(lenientNegativePercentTestCases
[t
]);
1033 pFormat
->parse(testCase
, n
, status
);
1034 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getDouble());
1036 if (U_FAILURE(status
) ||n
.getType() != Formattable::kDouble
||
1037 n
.getDouble() != -0.25) {
1038 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientNegativePercentTestCases
[t
] + (UnicodeString
) "\"");
1039 status
= U_ZERO_ERROR
;
1045 // Test cases that should fail with a strict parse and pass with a
1047 NumberFormat
*nFormat
= NumberFormat::createInstance(en_US
, status
);
1049 // first, make sure that they fail with a strict parse
1050 for (int32_t t
= 0; t
< ARRAY_SIZE(strictFailureTestCases
); t
+= 1) {
1051 UnicodeString testCase
= ctou(strictFailureTestCases
[t
]);
1053 nFormat
->parse(testCase
, n
, status
);
1054 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1056 if (! U_FAILURE(status
)) {
1057 errln((UnicodeString
)"Strict Parse succeeded for \"" + (UnicodeString
) strictFailureTestCases
[t
] + (UnicodeString
) "\"");
1060 status
= U_ZERO_ERROR
;
1063 // then, make sure that they pass with a lenient parse
1064 nFormat
->setParseStrict(FALSE
);
1065 for (int32_t t
= 0; t
< ARRAY_SIZE(strictFailureTestCases
); t
+= 1) {
1066 UnicodeString testCase
= ctou(strictFailureTestCases
[t
]);
1068 nFormat
->parse(testCase
, n
, status
);
1069 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1071 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
1072 n
.getLong() != 1000) {
1073 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) strictFailureTestCases
[t
] + (UnicodeString
) "\"");
1074 status
= U_ZERO_ERROR
;
1081 // -------------------------------------
1084 * Test proper rounding by the format method.
1087 NumberFormatTest::TestRounding487(void)
1089 UErrorCode status
= U_ZERO_ERROR
;
1090 NumberFormat
*nf
= NumberFormat::createInstance(status
);
1091 if (U_FAILURE(status
)) {
1092 dataerrln("Error calling NumberFormat::createInstance()");
1096 roundingTest(*nf
, 0.00159999, 4, "0.0016");
1097 roundingTest(*nf
, 0.00995, 4, "0.01");
1099 roundingTest(*nf
, 12.3995, 3, "12.4");
1101 roundingTest(*nf
, 12.4999, 0, "12");
1102 roundingTest(*nf
, - 19.5, 0, "-20");
1104 if (U_FAILURE(status
)) errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
1108 * Test the functioning of the secondary grouping value.
1110 void NumberFormatTest::TestSecondaryGrouping(void) {
1111 UErrorCode status
= U_ZERO_ERROR
;
1112 DecimalFormatSymbols
US(Locale::getUS(), status
);
1113 CHECK(status
, "DecimalFormatSymbols ct");
1115 DecimalFormat
f("#,##,###", US
, status
);
1116 CHECK(status
, "DecimalFormat ct");
1118 expect2(f
, (int32_t)123456789L, "12,34,56,789");
1119 expectPat(f
, "#,##,###");
1120 f
.applyPattern("#,###", status
);
1121 CHECK(status
, "applyPattern");
1123 f
.setSecondaryGroupingSize(4);
1124 expect2(f
, (int32_t)123456789L, "12,3456,789");
1125 expectPat(f
, "#,####,###");
1126 NumberFormat
*g
= NumberFormat::createInstance(Locale("hi", "IN"), status
);
1127 CHECK_DATA(status
, "createInstance(hi_IN)");
1130 int32_t l
= (int32_t)1876543210L;
1133 // expect "1,87,65,43,210", but with Hindi digits
1136 if (out
.length() != 14) {
1139 for (int32_t i
=0; i
<out
.length(); ++i
) {
1140 UBool expectGroup
= FALSE
;
1149 // Later -- fix this to get the actual grouping
1150 // character from the resource bundle.
1151 UBool isGroup
= (out
.charAt(i
) == 0x002C);
1152 if (isGroup
!= expectGroup
) {
1159 errln((UnicodeString
)"FAIL Expected " + l
+
1160 " x hi_IN -> \"1,87,65,43,210\" (with Hindi digits), got \"" +
1161 escape(out
) + "\"");
1163 logln((UnicodeString
)"Ok " + l
+
1165 escape(out
) + "\"");
1169 void NumberFormatTest::TestWhiteSpaceParsing(void) {
1170 UErrorCode ec
= U_ZERO_ERROR
;
1171 DecimalFormatSymbols
US(Locale::getUS(), ec
);
1172 DecimalFormat
fmt("a b#0c ", US
, ec
);
1173 if (U_FAILURE(ec
)) {
1174 errcheckln(ec
, "FAIL: Constructor - %s", u_errorName(ec
));
1178 expect(fmt
, "a b1234c ", n
);
1179 expect(fmt
, "a b1234c ", n
);
1183 * Test currencies whose display name is a ChoiceFormat.
1185 void NumberFormatTest::TestComplexCurrency() {
1187 // UErrorCode ec = U_ZERO_ERROR;
1188 // Locale loc("kn", "IN", "");
1189 // NumberFormat* fmt = NumberFormat::createCurrencyInstance(loc, ec);
1190 // if (U_SUCCESS(ec)) {
1191 // expect2(*fmt, 1.0, CharsToUnicodeString("Re.\\u00A01.00"));
1192 // Use .00392625 because that's 2^-8. Any value less than 0.005 is fine.
1193 // expect(*fmt, 1.00390625, CharsToUnicodeString("Re.\\u00A01.00")); // tricky
1194 // expect2(*fmt, 12345678.0, CharsToUnicodeString("Rs.\\u00A01,23,45,678.00"));
1195 // expect2(*fmt, 0.5, CharsToUnicodeString("Rs.\\u00A00.50"));
1196 // expect2(*fmt, -1.0, CharsToUnicodeString("-Re.\\u00A01.00"));
1197 // expect2(*fmt, -10.0, CharsToUnicodeString("-Rs.\\u00A010.00"));
1199 // errln("FAIL: getCurrencyInstance(kn_IN)");
1205 // -------------------------------------
1208 NumberFormatTest::roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
)
1210 nf
.setMaximumFractionDigits(maxFractionDigits
);
1211 UnicodeString out
; nf
.format(x
, out
);
1212 logln((UnicodeString
)"" + x
+ " formats with " + maxFractionDigits
+ " fractional digits to " + out
);
1213 if (!(out
==expected
)) errln((UnicodeString
)"FAIL: Expected " + expected
);
1217 * Upgrade to alphaWorks
1219 void NumberFormatTest::TestExponent(void) {
1220 UErrorCode status
= U_ZERO_ERROR
;
1221 DecimalFormatSymbols
US(Locale::getUS(), status
);
1222 CHECK(status
, "DecimalFormatSymbols constructor");
1223 DecimalFormat
fmt1(UnicodeString("0.###E0"), US
, status
);
1224 CHECK(status
, "DecimalFormat(0.###E0)");
1225 DecimalFormat
fmt2(UnicodeString("0.###E+0"), US
, status
);
1226 CHECK(status
, "DecimalFormat(0.###E+0)");
1228 expect2(fmt1
, n
, "1.234E3");
1229 expect2(fmt2
, n
, "1.234E+3");
1230 expect(fmt1
, "1.234E+3", n
); // Either format should parse "E+3"
1234 * Upgrade to alphaWorks
1236 void NumberFormatTest::TestScientific(void) {
1237 UErrorCode status
= U_ZERO_ERROR
;
1238 DecimalFormatSymbols
US(Locale::getUS(), status
);
1239 CHECK(status
, "DecimalFormatSymbols constructor");
1241 // Test pattern round-trip
1242 const char* PAT
[] = { "#E0", "0.####E0", "00.000E00", "##0.####E000",
1243 "0.###E0;[0.###E0]" };
1244 int32_t PAT_length
= (int32_t)(sizeof(PAT
) / sizeof(PAT
[0]));
1245 int32_t DIGITS
[] = {
1246 // min int, max int, min frac, max frac
1247 0, 1, 0, 0, // "#E0"
1248 1, 1, 0, 4, // "0.####E0"
1249 2, 2, 3, 3, // "00.000E00"
1250 1, 3, 0, 4, // "##0.####E000"
1251 1, 1, 0, 3, // "0.###E0;[0.###E0]"
1253 for (int32_t i
=0; i
<PAT_length
; ++i
) {
1254 UnicodeString
pat(PAT
[i
]);
1255 DecimalFormat
df(pat
, US
, status
);
1256 CHECK(status
, "DecimalFormat constructor");
1260 logln(UnicodeString("Ok Pattern rt \"") +
1264 errln(UnicodeString("FAIL Pattern rt \"") +
1268 // Make sure digit counts match what we expect
1269 if (df
.getMinimumIntegerDigits() != DIGITS
[4*i
] ||
1270 df
.getMaximumIntegerDigits() != DIGITS
[4*i
+1] ||
1271 df
.getMinimumFractionDigits() != DIGITS
[4*i
+2] ||
1272 df
.getMaximumFractionDigits() != DIGITS
[4*i
+3]) {
1273 errln(UnicodeString("FAIL \"" + pat
+
1274 "\" min/max int; min/max frac = ") +
1275 df
.getMinimumIntegerDigits() + "/" +
1276 df
.getMaximumIntegerDigits() + ";" +
1277 df
.getMinimumFractionDigits() + "/" +
1278 df
.getMaximumFractionDigits() + ", expect " +
1280 DIGITS
[4*i
+1] + ";" +
1281 DIGITS
[4*i
+2] + "/" +
1287 // Test the constructor for default locale. We have to
1288 // manually set the default locale, as there is no
1289 // guarantee that the default locale has the same
1290 // scientific format.
1291 Locale def
= Locale::getDefault();
1292 Locale::setDefault(Locale::getUS(), status
);
1293 expect2(NumberFormat::createScientificInstance(status
),
1295 "1.2345678901E4", status
);
1296 Locale::setDefault(def
, status
);
1298 expect2(new DecimalFormat("#E0", US
, status
),
1300 "1.2345E4", status
);
1301 expect(new DecimalFormat("0E0", US
, status
),
1304 expect2(NumberFormat::createScientificInstance(Locale::getUS(), status
),
1306 "1.2345678901E4", status
);
1307 expect(new DecimalFormat("##0.###E0", US
, status
),
1310 expect(new DecimalFormat("##0.###E0", US
, status
),
1313 expect2(new DecimalFormat("##0.####E0", US
, status
),
1315 "12.345E3", status
);
1316 expect2(NumberFormat::createScientificInstance(Locale::getFrance(), status
),
1318 "1,2345678901E4", status
);
1319 expect(new DecimalFormat("##0.####E0", US
, status
),
1321 "789.12E-9", status
);
1322 expect2(new DecimalFormat("##0.####E0", US
, status
),
1325 expect(new DecimalFormat(".###E0", US
, status
),
1328 expect2(new DecimalFormat(".###E0", US
, status
),
1332 expect(new DecimalFormat[] { new DecimalFormat("#E0", US),
1333 new DecimalFormat("##E0", US),
1334 new DecimalFormat("####E0", US),
1335 new DecimalFormat("0E0", US),
1336 new DecimalFormat("00E0", US),
1337 new DecimalFormat("000E0", US),
1340 new String[] { "4.5678E7",
1349 ! Unroll this test into individual tests below...
1352 expect2(new DecimalFormat("#E0", US
, status
),
1353 (int32_t) 45678000, "4.5678E7", status
);
1354 expect2(new DecimalFormat("##E0", US
, status
),
1355 (int32_t) 45678000, "45.678E6", status
);
1356 expect2(new DecimalFormat("####E0", US
, status
),
1357 (int32_t) 45678000, "4567.8E4", status
);
1358 expect(new DecimalFormat("0E0", US
, status
),
1359 (int32_t) 45678000, "5E7", status
);
1360 expect(new DecimalFormat("00E0", US
, status
),
1361 (int32_t) 45678000, "46E6", status
);
1362 expect(new DecimalFormat("000E0", US
, status
),
1363 (int32_t) 45678000, "457E5", status
);
1365 expect(new DecimalFormat("###E0", US, status),
1366 new Object[] { new Double(0.0000123), "12.3E-6",
1367 new Double(0.000123), "123E-6",
1368 new Double(0.00123), "1.23E-3",
1369 new Double(0.0123), "12.3E-3",
1370 new Double(0.123), "123E-3",
1371 new Double(1.23), "1.23E0",
1372 new Double(12.3), "12.3E0",
1373 new Double(123), "123E0",
1374 new Double(1230), "1.23E3",
1377 ! Unroll this test into individual tests below...
1380 expect2(new DecimalFormat("###E0", US
, status
),
1381 0.0000123, "12.3E-6", status
);
1382 expect2(new DecimalFormat("###E0", US
, status
),
1383 0.000123, "123E-6", status
);
1384 expect2(new DecimalFormat("###E0", US
, status
),
1385 0.00123, "1.23E-3", status
);
1386 expect2(new DecimalFormat("###E0", US
, status
),
1387 0.0123, "12.3E-3", status
);
1388 expect2(new DecimalFormat("###E0", US
, status
),
1389 0.123, "123E-3", status
);
1390 expect2(new DecimalFormat("###E0", US
, status
),
1391 1.23, "1.23E0", status
);
1392 expect2(new DecimalFormat("###E0", US
, status
),
1393 12.3, "12.3E0", status
);
1394 expect2(new DecimalFormat("###E0", US
, status
),
1395 123.0, "123E0", status
);
1396 expect2(new DecimalFormat("###E0", US
, status
),
1397 1230.0, "1.23E3", status
);
1399 expect(new DecimalFormat("0.#E+00", US, status),
1400 new Object[] { new Double(0.00012), "1.2E-04",
1401 new Long(12000), "1.2E+04",
1404 ! Unroll this test into individual tests below...
1407 expect2(new DecimalFormat("0.#E+00", US
, status
),
1408 0.00012, "1.2E-04", status
);
1409 expect2(new DecimalFormat("0.#E+00", US
, status
),
1410 (int32_t) 12000, "1.2E+04", status
);
1414 * Upgrade to alphaWorks
1416 void NumberFormatTest::TestPad(void) {
1417 UErrorCode status
= U_ZERO_ERROR
;
1418 DecimalFormatSymbols
US(Locale::getUS(), status
);
1419 CHECK(status
, "DecimalFormatSymbols constructor");
1421 expect2(new DecimalFormat("*^##.##", US
, status
),
1422 int32_t(0), "^^^^0", status
);
1423 expect2(new DecimalFormat("*^##.##", US
, status
),
1424 -1.3, "^-1.3", status
);
1425 expect2(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US
, status
),
1426 int32_t(0), "0.0E0______ g-m/s^2", status
);
1427 expect(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US
, status
),
1428 1.0/3, "333.333E-3_ g-m/s^2", status
);
1429 expect2(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US
, status
),
1430 int32_t(0), "0.0______ g-m/s^2", status
);
1431 expect(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US
, status
),
1432 1.0/3, "0.33333__ g-m/s^2", status
);
1434 // Test padding before a sign
1435 const char *formatStr
= "*x#,###,###,##0.0#;*x(###,###,##0.0#)";
1436 expect2(new DecimalFormat(formatStr
, US
, status
),
1437 int32_t(-10), "xxxxxxxxxx(10.0)", status
);
1438 expect2(new DecimalFormat(formatStr
, US
, status
),
1439 int32_t(-1000),"xxxxxxx(1,000.0)", status
);
1440 expect2(new DecimalFormat(formatStr
, US
, status
),
1441 int32_t(-1000000),"xxx(1,000,000.0)", status
);
1442 expect2(new DecimalFormat(formatStr
, US
, status
),
1443 -100.37, "xxxxxxxx(100.37)", status
);
1444 expect2(new DecimalFormat(formatStr
, US
, status
),
1445 -10456.37, "xxxxx(10,456.37)", status
);
1446 expect2(new DecimalFormat(formatStr
, US
, status
),
1447 -1120456.37, "xx(1,120,456.37)", status
);
1448 expect2(new DecimalFormat(formatStr
, US
, status
),
1449 -112045600.37, "(112,045,600.37)", status
);
1450 expect2(new DecimalFormat(formatStr
, US
, status
),
1451 -1252045600.37,"(1,252,045,600.37)", status
);
1453 expect2(new DecimalFormat(formatStr
, US
, status
),
1454 int32_t(10), "xxxxxxxxxxxx10.0", status
);
1455 expect2(new DecimalFormat(formatStr
, US
, status
),
1456 int32_t(1000),"xxxxxxxxx1,000.0", status
);
1457 expect2(new DecimalFormat(formatStr
, US
, status
),
1458 int32_t(1000000),"xxxxx1,000,000.0", status
);
1459 expect2(new DecimalFormat(formatStr
, US
, status
),
1460 100.37, "xxxxxxxxxx100.37", status
);
1461 expect2(new DecimalFormat(formatStr
, US
, status
),
1462 10456.37, "xxxxxxx10,456.37", status
);
1463 expect2(new DecimalFormat(formatStr
, US
, status
),
1464 1120456.37, "xxxx1,120,456.37", status
);
1465 expect2(new DecimalFormat(formatStr
, US
, status
),
1466 112045600.37, "xx112,045,600.37", status
);
1467 expect2(new DecimalFormat(formatStr
, US
, status
),
1468 10252045600.37,"10,252,045,600.37", status
);
1471 // Test padding between a sign and a number
1472 const char *formatStr2
= "#,###,###,##0.0#*x;(###,###,##0.0#*x)";
1473 expect2(new DecimalFormat(formatStr2
, US
, status
),
1474 int32_t(-10), "(10.0xxxxxxxxxx)", status
);
1475 expect2(new DecimalFormat(formatStr2
, US
, status
),
1476 int32_t(-1000),"(1,000.0xxxxxxx)", status
);
1477 expect2(new DecimalFormat(formatStr2
, US
, status
),
1478 int32_t(-1000000),"(1,000,000.0xxx)", status
);
1479 expect2(new DecimalFormat(formatStr2
, US
, status
),
1480 -100.37, "(100.37xxxxxxxx)", status
);
1481 expect2(new DecimalFormat(formatStr2
, US
, status
),
1482 -10456.37, "(10,456.37xxxxx)", status
);
1483 expect2(new DecimalFormat(formatStr2
, US
, status
),
1484 -1120456.37, "(1,120,456.37xx)", status
);
1485 expect2(new DecimalFormat(formatStr2
, US
, status
),
1486 -112045600.37, "(112,045,600.37)", status
);
1487 expect2(new DecimalFormat(formatStr2
, US
, status
),
1488 -1252045600.37,"(1,252,045,600.37)", status
);
1490 expect2(new DecimalFormat(formatStr2
, US
, status
),
1491 int32_t(10), "10.0xxxxxxxxxxxx", status
);
1492 expect2(new DecimalFormat(formatStr2
, US
, status
),
1493 int32_t(1000),"1,000.0xxxxxxxxx", status
);
1494 expect2(new DecimalFormat(formatStr2
, US
, status
),
1495 int32_t(1000000),"1,000,000.0xxxxx", status
);
1496 expect2(new DecimalFormat(formatStr2
, US
, status
),
1497 100.37, "100.37xxxxxxxxxx", status
);
1498 expect2(new DecimalFormat(formatStr2
, US
, status
),
1499 10456.37, "10,456.37xxxxxxx", status
);
1500 expect2(new DecimalFormat(formatStr2
, US
, status
),
1501 1120456.37, "1,120,456.37xxxx", status
);
1502 expect2(new DecimalFormat(formatStr2
, US
, status
),
1503 112045600.37, "112,045,600.37xx", status
);
1504 expect2(new DecimalFormat(formatStr2
, US
, status
),
1505 10252045600.37,"10,252,045,600.37", status
);
1507 //testing the setPadCharacter(UnicodeString) and getPadCharacterString()
1508 DecimalFormat
fmt("#", US
, status
);
1509 CHECK(status
, "DecimalFormat constructor");
1510 UnicodeString
padString("P");
1511 fmt
.setPadCharacter(padString
);
1512 expectPad(fmt
, "*P##.##", DecimalFormat::kPadBeforePrefix
, 5, padString
);
1513 fmt
.setPadCharacter((UnicodeString
)"^");
1514 expectPad(fmt
, "*^#", DecimalFormat::kPadBeforePrefix
, 1, (UnicodeString
)"^");
1515 //commented untill implementation is complete
1516 /* fmt.setPadCharacter((UnicodeString)"^^^");
1517 expectPad(fmt, "*^^^#", DecimalFormat::kPadBeforePrefix, 3, (UnicodeString)"^^^");
1519 padString.append((UChar)0x0061);
1520 padString.append((UChar)0x0302);
1521 fmt.setPadCharacter(padString);
1522 UChar patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000};
1523 UnicodeString pattern(patternChars);
1524 expectPad(fmt, pattern , DecimalFormat::kPadBeforePrefix, 4, padString);
1530 * Upgrade to alphaWorks
1532 void NumberFormatTest::TestPatterns2(void) {
1533 UErrorCode status
= U_ZERO_ERROR
;
1534 DecimalFormatSymbols
US(Locale::getUS(), status
);
1535 CHECK(status
, "DecimalFormatSymbols constructor");
1537 DecimalFormat
fmt("#", US
, status
);
1538 CHECK(status
, "DecimalFormat constructor");
1540 UChar hat
= 0x005E; /*^*/
1542 expectPad(fmt
, "*^#", DecimalFormat::kPadBeforePrefix
, 1, hat
);
1543 expectPad(fmt
, "$*^#", DecimalFormat::kPadAfterPrefix
, 2, hat
);
1544 expectPad(fmt
, "#*^", DecimalFormat::kPadBeforeSuffix
, 1, hat
);
1545 expectPad(fmt
, "#$*^", DecimalFormat::kPadAfterSuffix
, 2, hat
);
1546 expectPad(fmt
, "$*^$#", ILLEGAL
);
1547 expectPad(fmt
, "#$*^$", ILLEGAL
);
1548 expectPad(fmt
, "'pre'#,##0*x'post'", DecimalFormat::kPadBeforeSuffix
,
1549 12, (UChar
)0x0078 /*x*/);
1550 expectPad(fmt
, "''#0*x", DecimalFormat::kPadBeforeSuffix
,
1551 3, (UChar
)0x0078 /*x*/);
1552 expectPad(fmt
, "'I''ll'*a###.##", DecimalFormat::kPadAfterPrefix
,
1553 10, (UChar
)0x0061 /*a*/);
1555 fmt
.applyPattern("AA#,##0.00ZZ", status
);
1556 CHECK(status
, "applyPattern");
1557 fmt
.setPadCharacter(hat
);
1559 fmt
.setFormatWidth(10);
1561 fmt
.setPadPosition(DecimalFormat::kPadBeforePrefix
);
1562 expectPat(fmt
, "*^AA#,##0.00ZZ");
1564 fmt
.setPadPosition(DecimalFormat::kPadBeforeSuffix
);
1565 expectPat(fmt
, "AA#,##0.00*^ZZ");
1567 fmt
.setPadPosition(DecimalFormat::kPadAfterSuffix
);
1568 expectPat(fmt
, "AA#,##0.00ZZ*^");
1571 UnicodeString
exp("AA*^#,##0.00ZZ", "");
1572 fmt
.setFormatWidth(12);
1573 fmt
.setPadPosition(DecimalFormat::kPadAfterPrefix
);
1574 expectPat(fmt
, exp
);
1576 fmt
.setFormatWidth(13);
1578 expectPat(fmt
, "AA*^##,##0.00ZZ");
1580 fmt
.setFormatWidth(14);
1582 expectPat(fmt
, "AA*^###,##0.00ZZ");
1584 fmt
.setFormatWidth(15);
1586 expectPat(fmt
, "AA*^####,##0.00ZZ"); // This is the interesting case
1588 fmt
.setFormatWidth(16);
1589 // 12 34567890123456
1590 expectPat(fmt
, "AA*^#,###,##0.00ZZ");
1593 void NumberFormatTest::TestSurrogateSupport(void) {
1594 UErrorCode status
= U_ZERO_ERROR
;
1595 DecimalFormatSymbols
custom(Locale::getUS(), status
);
1596 CHECK(status
, "DecimalFormatSymbols constructor");
1598 custom
.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol
, "decimal");
1599 custom
.setSymbol(DecimalFormatSymbols::kPlusSignSymbol
, "plus");
1600 custom
.setSymbol(DecimalFormatSymbols::kMinusSignSymbol
, " minus ");
1601 custom
.setSymbol(DecimalFormatSymbols::kExponentialSymbol
, "exponent");
1603 UnicodeString
patternStr("*\\U00010000##.##", "");
1604 patternStr
= patternStr
.unescape();
1605 UnicodeString
expStr("\\U00010000\\U00010000\\U00010000\\U000100000", "");
1606 expStr
= expStr
.unescape();
1607 expect2(new DecimalFormat(patternStr
, custom
, status
),
1608 int32_t(0), expStr
, status
);
1610 status
= U_ZERO_ERROR
;
1611 expect2(new DecimalFormat("*^##.##", custom
, status
),
1612 int32_t(0), "^^^^0", status
);
1613 status
= U_ZERO_ERROR
;
1614 expect2(new DecimalFormat("##.##", custom
, status
),
1615 -1.3, " minus 1decimal3", status
);
1616 status
= U_ZERO_ERROR
;
1617 expect2(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom
, status
),
1618 int32_t(0), "0decimal0exponent0 g-m/s^2", status
);
1619 status
= U_ZERO_ERROR
;
1620 expect(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom
, status
),
1621 1.0/3, "333decimal333exponent minus 3 g-m/s^2", status
);
1622 status
= U_ZERO_ERROR
;
1623 expect2(new DecimalFormat("##0.0#### 'g-m/s^2'", custom
, status
),
1624 int32_t(0), "0decimal0 g-m/s^2", status
);
1625 status
= U_ZERO_ERROR
;
1626 expect(new DecimalFormat("##0.0#### 'g-m/s^2'", custom
, status
),
1627 1.0/3, "0decimal33333 g-m/s^2", status
);
1629 UnicodeString
zero((UChar32
)0x10000);
1630 UnicodeString
one((UChar32
)0x10001);
1631 UnicodeString
two((UChar32
)0x10002);
1632 UnicodeString
five((UChar32
)0x10005);
1633 custom
.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol
, zero
);
1634 custom
.setSymbol(DecimalFormatSymbols::kOneDigitSymbol
, one
);
1635 custom
.setSymbol(DecimalFormatSymbols::kTwoDigitSymbol
, two
);
1636 custom
.setSymbol(DecimalFormatSymbols::kFiveDigitSymbol
, five
);
1637 expStr
= UnicodeString("\\U00010001decimal\\U00010002\\U00010005\\U00010000", "");
1638 expStr
= expStr
.unescape();
1639 status
= U_ZERO_ERROR
;
1640 expect2(new DecimalFormat("##0.000", custom
, status
),
1641 1.25, expStr
, status
);
1643 custom
.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol
, (UChar
)0x30);
1644 custom
.setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "units of money");
1645 custom
.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol
, "money separator");
1646 patternStr
= UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'");
1647 patternStr
= patternStr
.unescape();
1648 expStr
= UnicodeString(" minus 20money separator00 units of money in your bank account", "");
1649 status
= U_ZERO_ERROR
;
1650 expect2(new DecimalFormat(patternStr
, custom
, status
),
1651 int32_t(-20), expStr
, status
);
1653 custom
.setSymbol(DecimalFormatSymbols::kPercentSymbol
, "percent");
1654 patternStr
= "'You''ve lost ' -0.00 %' of your money today'";
1655 patternStr
= patternStr
.unescape();
1656 expStr
= UnicodeString(" minus You've lost minus 2000decimal00 percent of your money today", "");
1657 status
= U_ZERO_ERROR
;
1658 expect2(new DecimalFormat(patternStr
, custom
, status
),
1659 int32_t(-20), expStr
, status
);
1662 void NumberFormatTest::TestCurrencyPatterns(void) {
1663 int32_t i
, locCount
;
1664 const Locale
* locs
= NumberFormat::getAvailableLocales(locCount
);
1665 for (i
=0; i
<locCount
; ++i
) {
1666 UErrorCode ec
= U_ZERO_ERROR
;
1667 NumberFormat
* nf
= NumberFormat::createCurrencyInstance(locs
[i
], ec
);
1668 if (U_FAILURE(ec
)) {
1669 errln("FAIL: Can't create NumberFormat(%s) - %s", locs
[i
].getName(), u_errorName(ec
));
1671 // Make sure currency formats do not have a variable number
1672 // of fraction digits
1673 int32_t min
= nf
->getMinimumFractionDigits();
1674 int32_t max
= nf
->getMaximumFractionDigits();
1678 nf
->format(1.125, b
);
1679 errln((UnicodeString
)"FAIL: " + locs
[i
].getName() +
1680 " min fraction digits != max fraction digits; "
1681 "x 1.0 => " + escape(a
) +
1682 "; x 1.125 => " + escape(b
));
1685 // Make sure EURO currency formats have exactly 2 fraction digits
1686 DecimalFormat
* df
= dynamic_cast<DecimalFormat
*>(nf
);
1688 if (u_strcmp(EUR
, df
->getCurrency()) == 0) {
1689 if (min
!= 2 || max
!= 2) {
1692 errln((UnicodeString
)"FAIL: " + locs
[i
].getName() +
1693 " is a EURO format but it does not have 2 fraction digits; "
1704 void NumberFormatTest::TestRegCurrency(void) {
1705 #if !UCONFIG_NO_SERVICE
1706 UErrorCode status
= U_ZERO_ERROR
;
1708 ucurr_forLocale("en_US", USD
, 4, &status
);
1710 ucurr_forLocale("ja_JP", YEN
, 4, &status
);
1712 static const UChar QQQ
[] = {0x51, 0x51, 0x51, 0};
1713 if(U_FAILURE(status
)) {
1714 errcheckln(status
, "Unable to get currency for locale, error %s", u_errorName(status
));
1718 UCurrRegistryKey enkey
= ucurr_register(YEN
, "en_US", &status
);
1719 UCurrRegistryKey enUSEUROkey
= ucurr_register(QQQ
, "en_US_EURO", &status
);
1721 ucurr_forLocale("en_US", TMP
, 4, &status
);
1722 if (u_strcmp(YEN
, TMP
) != 0) {
1723 errln("FAIL: didn't return YEN registered for en_US");
1726 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1727 if (u_strcmp(QQQ
, TMP
) != 0) {
1728 errln("FAIL: didn't return QQQ for en_US_EURO");
1731 int32_t fallbackLen
= ucurr_forLocale("en_XX_BAR", TMP
, 4, &status
);
1733 errln("FAIL: tried to fallback en_XX_BAR");
1735 status
= U_ZERO_ERROR
; // reset
1737 if (!ucurr_unregister(enkey
, &status
)) {
1738 errln("FAIL: couldn't unregister enkey");
1741 ucurr_forLocale("en_US", TMP
, 4, &status
);
1742 if (u_strcmp(USD
, TMP
) != 0) {
1743 errln("FAIL: didn't return USD for en_US after unregister of en_US");
1745 status
= U_ZERO_ERROR
; // reset
1747 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1748 if (u_strcmp(QQQ
, TMP
) != 0) {
1749 errln("FAIL: didn't return QQQ for en_US_EURO after unregister of en_US");
1752 ucurr_forLocale("en_US_BLAH", TMP
, 4, &status
);
1753 if (u_strcmp(USD
, TMP
) != 0) {
1754 errln("FAIL: could not find USD for en_US_BLAH after unregister of en");
1756 status
= U_ZERO_ERROR
; // reset
1758 if (!ucurr_unregister(enUSEUROkey
, &status
)) {
1759 errln("FAIL: couldn't unregister enUSEUROkey");
1762 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1763 if (u_strcmp(EUR
, TMP
) != 0) {
1764 errln("FAIL: didn't return EUR for en_US_EURO after unregister of en_US_EURO");
1766 status
= U_ZERO_ERROR
; // reset
1770 void NumberFormatTest::TestCurrencyNames(void) {
1771 // Do a basic check of getName()
1772 // USD { "US$", "US Dollar" } // 04/04/1792-
1773 UErrorCode ec
= U_ZERO_ERROR
;
1774 static const UChar USD
[] = {0x55, 0x53, 0x44, 0}; /*USD*/
1775 static const UChar USX
[] = {0x55, 0x53, 0x58, 0}; /*USX*/
1776 static const UChar CAD
[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
1777 static const UChar ITL
[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
1778 UBool isChoiceFormat
;
1780 const UBool possibleDataError
= TRUE
;
1781 // Warning: HARD-CODED LOCALE DATA in this test. If it fails, CHECK
1782 // THE LOCALE DATA before diving into the code.
1783 assertEquals("USD.getName(SYMBOL_NAME)",
1785 UnicodeString(ucurr_getName(USD
, "en",
1787 &isChoiceFormat
, &len
, &ec
)),
1789 assertEquals("USD.getName(LONG_NAME)",
1790 UnicodeString("US Dollar"),
1791 UnicodeString(ucurr_getName(USD
, "en",
1793 &isChoiceFormat
, &len
, &ec
)),
1795 assertEquals("CAD.getName(SYMBOL_NAME)",
1796 UnicodeString("CA$"),
1797 UnicodeString(ucurr_getName(CAD
, "en",
1799 &isChoiceFormat
, &len
, &ec
)),
1801 assertEquals("CAD.getName(SYMBOL_NAME)",
1803 UnicodeString(ucurr_getName(CAD
, "en_CA",
1805 &isChoiceFormat
, &len
, &ec
)),
1807 assertEquals("USD.getName(SYMBOL_NAME)",
1808 UnicodeString("US$"),
1809 UnicodeString(ucurr_getName(USD
, "en_AU",
1811 &isChoiceFormat
, &len
, &ec
)),
1813 assertEquals("CAD.getName(SYMBOL_NAME)",
1814 UnicodeString("CA$"),
1815 UnicodeString(ucurr_getName(CAD
, "en_AU",
1817 &isChoiceFormat
, &len
, &ec
)),
1819 assertEquals("USX.getName(LONG_NAME)",
1820 UnicodeString("USX"),
1821 UnicodeString(ucurr_getName(USX
, "en_US",
1823 &isChoiceFormat
, &len
, &ec
)),
1825 assertSuccess("ucurr_getName", ec
);
1829 // Test that a default or fallback warning is being returned. JB 4239.
1830 ucurr_getName(CAD
, "es_ES", UCURR_LONG_NAME
, &isChoiceFormat
,
1832 assertTrue("ucurr_getName (es_ES fallback)",
1833 U_USING_FALLBACK_WARNING
== ec
, TRUE
, possibleDataError
);
1835 ucurr_getName(CAD
, "zh_TW", UCURR_LONG_NAME
, &isChoiceFormat
,
1837 assertTrue("ucurr_getName (zh_TW fallback)",
1838 U_USING_FALLBACK_WARNING
== ec
, TRUE
, possibleDataError
);
1840 ucurr_getName(CAD
, "en_US", UCURR_LONG_NAME
, &isChoiceFormat
,
1842 assertTrue("ucurr_getName (en_US default)",
1843 U_USING_DEFAULT_WARNING
== ec
|| U_USING_FALLBACK_WARNING
== ec
, TRUE
);
1845 ucurr_getName(CAD
, "vi", UCURR_LONG_NAME
, &isChoiceFormat
,
1847 assertTrue("ucurr_getName (vi default)",
1848 U_USING_DEFAULT_WARNING
== ec
, TRUE
);
1850 // Test that a default warning is being returned when falling back to root. JB 4536.
1851 ucurr_getName(ITL
, "cy", UCURR_LONG_NAME
, &isChoiceFormat
,
1853 assertTrue("ucurr_getName (cy default to root)",
1854 U_USING_DEFAULT_WARNING
== ec
, TRUE
);
1856 // TODO add more tests later
1859 void NumberFormatTest::TestCurrencyUnit(void){
1860 UErrorCode ec
= U_ZERO_ERROR
;
1861 static const UChar USD
[] = {85, 83, 68, 0}; /*USD*/
1862 CurrencyUnit
cu(USD
, ec
);
1863 assertSuccess("CurrencyUnit", ec
);
1865 const UChar
* r
= cu
.getISOCurrency(); // who is the buffer owner ?
1866 assertEquals("getISOCurrency()", USD
, r
);
1868 CurrencyUnit
cu2(cu
);
1870 errln("CurrencyUnit copy constructed object should be same");
1873 CurrencyUnit
* cu3
= (CurrencyUnit
*)cu
.clone();
1875 errln("CurrencyUnit cloned object should be same");
1880 void NumberFormatTest::TestCurrencyAmount(void){
1881 UErrorCode ec
= U_ZERO_ERROR
;
1882 static const UChar USD
[] = {85, 83, 68, 0}; /*USD*/
1883 CurrencyAmount
ca(9, USD
, ec
);
1884 assertSuccess("CurrencyAmount", ec
);
1886 CurrencyAmount
ca2(ca
);
1888 errln("CurrencyAmount copy constructed object should be same");
1893 errln("CurrencyAmount assigned object should be same");
1896 CurrencyAmount
*ca3
= (CurrencyAmount
*)ca
.clone();
1898 errln("CurrencyAmount cloned object should be same");
1903 void NumberFormatTest::TestSymbolsWithBadLocale(void) {
1905 Locale
locBad("x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME");
1906 UErrorCode status
= U_ZERO_ERROR
;
1907 UnicodeString
intlCurrencySymbol((UChar
)0xa4);
1909 intlCurrencySymbol
.append((UChar
)0xa4);
1911 logln("Current locale is %s", Locale::getDefault().getName());
1912 Locale::setDefault(locBad
, status
);
1913 logln("Current locale is %s", Locale::getDefault().getName());
1914 DecimalFormatSymbols
mySymbols(status
);
1915 if (status
!= U_USING_FALLBACK_WARNING
) {
1916 errln("DecimalFormatSymbols should returned U_USING_FALLBACK_WARNING.");
1918 if (strcmp(mySymbols
.getLocale().getName(), locBad
.getName()) != 0) {
1919 errln("DecimalFormatSymbols does not have the right locale.");
1921 int symbolEnum
= (int)DecimalFormatSymbols::kDecimalSeparatorSymbol
;
1922 for (; symbolEnum
< (int)DecimalFormatSymbols::kFormatSymbolCount
; symbolEnum
++) {
1923 logln(UnicodeString("DecimalFormatSymbols[") + symbolEnum
+ UnicodeString("] = ")
1924 + prettify(mySymbols
.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol
)symbolEnum
)));
1926 if (mySymbols
.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol
)symbolEnum
).length() == 0
1927 && symbolEnum
!= (int)DecimalFormatSymbols::kGroupingSeparatorSymbol
1928 && symbolEnum
!= (int)DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol
)
1930 errln("DecimalFormatSymbols has an empty string at index %d.", symbolEnum
);
1933 status
= U_ZERO_ERROR
;
1934 Locale::setDefault(locDefault
, status
);
1935 logln("Current locale is %s", Locale::getDefault().getName());
1939 * Check that adoptDecimalFormatSymbols and setDecimalFormatSymbols
1940 * behave the same, except for memory ownership semantics. (No
1941 * version of this test on Java, since Java has only one method.)
1943 void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
1944 UErrorCode ec
= U_ZERO_ERROR
;
1945 DecimalFormatSymbols
*sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
1946 if (U_FAILURE(ec
)) {
1947 errcheckln(ec
, "Fail: DecimalFormatSymbols constructor - %s", u_errorName(ec
));
1951 UnicodeString
pat(" #,##0.00");
1952 pat
.insert(0, (UChar
)0x00A4);
1953 DecimalFormat
fmt(pat
, sym
, ec
);
1954 if (U_FAILURE(ec
)) {
1955 errln("Fail: DecimalFormat constructor");
1960 fmt
.format(2350.75, str
);
1961 if (str
== "$ 2,350.75") {
1964 dataerrln("Fail: " + str
+ ", expected $ 2,350.75");
1967 sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
1968 if (U_FAILURE(ec
)) {
1969 errln("Fail: DecimalFormatSymbols constructor");
1973 sym
->setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "Q");
1974 fmt
.adoptDecimalFormatSymbols(sym
);
1977 fmt
.format(2350.75, str
);
1978 if (str
== "Q 2,350.75") {
1981 dataerrln("Fail: adoptDecimalFormatSymbols -> " + str
+ ", expected Q 2,350.75");
1984 sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
1985 if (U_FAILURE(ec
)) {
1986 errln("Fail: DecimalFormatSymbols constructor");
1990 DecimalFormat
fmt2(pat
, sym
, ec
);
1991 if (U_FAILURE(ec
)) {
1992 errln("Fail: DecimalFormat constructor");
1996 DecimalFormatSymbols
sym2(Locale::getUS(), ec
);
1997 if (U_FAILURE(ec
)) {
1998 errln("Fail: DecimalFormatSymbols constructor");
2001 sym2
.setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "Q");
2002 fmt2
.setDecimalFormatSymbols(sym2
);
2005 fmt2
.format(2350.75, str
);
2006 if (str
== "Q 2,350.75") {
2009 dataerrln("Fail: setDecimalFormatSymbols -> " + str
+ ", expected Q 2,350.75");
2013 void NumberFormatTest::TestPerMill() {
2014 UErrorCode ec
= U_ZERO_ERROR
;
2016 DecimalFormat
fmt(ctou("###.###\\u2030"), ec
);
2017 if (!assertSuccess("DecimalFormat ct", ec
)) return;
2018 assertEquals("0.4857 x ###.###\\u2030",
2019 ctou("485.7\\u2030"), fmt
.format(0.4857, str
));
2021 DecimalFormatSymbols
sym(Locale::getUS(), ec
);
2022 sym
.setSymbol(DecimalFormatSymbols::kPerMillSymbol
, ctou("m"));
2023 DecimalFormat
fmt2("", sym
, ec
);
2024 fmt2
.applyLocalizedPattern("###.###m", ec
);
2025 if (!assertSuccess("setup", ec
)) return;
2027 assertEquals("0.4857 x ###.###m",
2028 "485.7m", fmt2
.format(0.4857, str
));
2032 * Generic test for patterns that should be legal/illegal.
2034 void NumberFormatTest::TestIllegalPatterns() {
2036 // Prefix with "-:" for illegal patterns
2037 // Prefix with "+:" for legal patterns
2038 const char* DATA
[] = {
2039 // Unquoted special characters in the suffix are illegal
2044 for (int32_t i
=0; DATA
[i
]; ++i
) {
2045 const char* pat
=DATA
[i
];
2046 UBool valid
= (*pat
) == '+';
2048 UErrorCode ec
= U_ZERO_ERROR
;
2049 DecimalFormat
fmt(pat
, ec
); // locale doesn't matter here
2050 if (U_SUCCESS(ec
) == valid
) {
2051 logln("Ok: pattern \"%s\": %s",
2052 pat
, u_errorName(ec
));
2054 errcheckln(ec
, "FAIL: pattern \"%s\" should have %s; got %s",
2055 pat
, (valid
?"succeeded":"failed"),
2061 //----------------------------------------------------------------------
2063 static const char* KEYWORDS
[] = {
2064 /*0*/ "ref=", // <reference pattern to parse numbers>
2065 /*1*/ "loc=", // <locale for formats>
2066 /*2*/ "f:", // <pattern or '-'> <number> <exp. string>
2067 /*3*/ "fp:", // <pattern or '-'> <number> <exp. string> <exp. number>
2068 /*4*/ "rt:", // <pattern or '-'> <(exp.) number> <(exp.) string>
2069 /*5*/ "p:", // <pattern or '-'> <string> <exp. number>
2070 /*6*/ "perr:", // <pattern or '-'> <invalid string>
2071 /*7*/ "pat:", // <pattern or '-'> <exp. toPattern or '-' or 'err'>
2072 /*8*/ "fpc:", // <pattern or '-'> <curr.amt> <exp. string> <exp. curr.amt>
2077 * Return an integer representing the next token from this
2078 * iterator. The integer will be an index into the given list, or
2079 * -1 if there are no more tokens, or -2 if the token is not on
2082 static int32_t keywordIndex(const UnicodeString
& tok
) {
2083 for (int32_t i
=0; KEYWORDS
[i
]!=0; ++i
) {
2084 if (tok
==KEYWORDS
[i
]) {
2092 * Parse a CurrencyAmount using the given NumberFormat, with
2093 * the 'delim' character separating the number and the currency.
2095 static void parseCurrencyAmount(const UnicodeString
& str
,
2096 const NumberFormat
& fmt
,
2098 Formattable
& result
,
2100 UnicodeString num
, cur
;
2101 int32_t i
= str
.indexOf(delim
);
2102 str
.extractBetween(0, i
, num
);
2103 str
.extractBetween(i
+1, INT32_MAX
, cur
);
2105 fmt
.parse(num
, n
, ec
);
2106 result
.adoptObject(new CurrencyAmount(n
, cur
.getTerminatedBuffer(), ec
));
2109 void NumberFormatTest::TestCases() {
2110 UErrorCode ec
= U_ZERO_ERROR
;
2111 TextFile
reader("NumberFormatTestCases.txt", "UTF8", ec
);
2112 if (U_FAILURE(ec
)) {
2113 dataerrln("Couldn't open NumberFormatTestCases.txt");
2116 TokenIterator
tokens(&reader
);
2118 Locale
loc("en", "US", "");
2119 DecimalFormat
*ref
= 0, *fmt
= 0;
2120 MeasureFormat
*mfmt
= 0;
2121 UnicodeString pat
, tok
, mloc
, str
, out
, where
, currAmt
;
2126 if (!tokens
.next(tok
, ec
)) {
2129 where
= UnicodeString("(") + tokens
.getLineNumber() + ") ";
2130 int32_t cmd
= keywordIndex(tok
);
2133 // ref= <reference pattern>
2134 if (!tokens
.next(tok
, ec
)) goto error
;
2136 ref
= new DecimalFormat(tok
,
2137 new DecimalFormatSymbols(Locale::getUS(), ec
), ec
);
2138 if (U_FAILURE(ec
)) {
2139 dataerrln("Error constructing DecimalFormat");
2145 if (!tokens
.next(tok
, ec
)) goto error
;
2146 loc
= Locale::createFromName(CharString().appendInvariantChars(tok
, ec
).data());
2152 if (!tokens
.next(tok
, ec
)) goto error
;
2156 fmt
= new DecimalFormat(pat
, new DecimalFormatSymbols(loc
, ec
), ec
);
2157 if (U_FAILURE(ec
)) {
2158 errln("FAIL: " + where
+ "Pattern \"" + pat
+ "\": " + u_errorName(ec
));
2160 if (!tokens
.next(tok
, ec
)) goto error
;
2161 if (!tokens
.next(tok
, ec
)) goto error
;
2163 if (!tokens
.next(tok
, ec
)) goto error
;
2168 if (cmd
== 2 || cmd
== 3 || cmd
== 4) {
2169 // f: <pattern or '-'> <number> <exp. string>
2170 // fp: <pattern or '-'> <number> <exp. string> <exp. number>
2171 // rt: <pattern or '-'> <number> <string>
2173 if (!tokens
.next(num
, ec
)) goto error
;
2174 if (!tokens
.next(str
, ec
)) goto error
;
2175 ref
->parse(num
, n
, ec
);
2176 assertSuccess("parse", ec
);
2177 assertEquals(where
+ "\"" + pat
+ "\".format(" + num
+ ")",
2178 str
, fmt
->format(n
, out
.remove(), ec
));
2179 assertSuccess("format", ec
);
2180 if (cmd
== 3) { // fp:
2181 if (!tokens
.next(num
, ec
)) goto error
;
2182 ref
->parse(num
, n
, ec
);
2183 assertSuccess("parse", ec
);
2185 if (cmd
!= 2) { // != f:
2187 fmt
->parse(str
, m
, ec
);
2188 assertSuccess("parse", ec
);
2189 assertEquals(where
+ "\"" + pat
+ "\".parse(\"" + str
+ "\")",
2193 // p: <pattern or '-'> <string to parse> <exp. number>
2195 UnicodeString expstr
;
2196 if (!tokens
.next(str
, ec
)) goto error
;
2197 if (!tokens
.next(expstr
, ec
)) goto error
;
2199 ref
->parse(expstr
, exp
, ec
);
2200 assertSuccess("parse", ec
);
2201 fmt
->parse(str
, n
, ec
);
2202 assertSuccess("parse", ec
);
2203 assertEquals(where
+ "\"" + pat
+ "\".parse(\"" + str
+ "\")",
2208 if (!tokens
.next(tok
, ec
)) goto error
;
2212 mfmt
= MeasureFormat::createCurrencyFormat(
2213 Locale::createFromName(
2214 CharString().appendInvariantChars(mloc
, ec
).data()), ec
);
2215 if (U_FAILURE(ec
)) {
2216 errln("FAIL: " + where
+ "Loc \"" + mloc
+ "\": " + u_errorName(ec
));
2218 if (!tokens
.next(tok
, ec
)) goto error
;
2219 if (!tokens
.next(tok
, ec
)) goto error
;
2220 if (!tokens
.next(tok
, ec
)) goto error
;
2224 // fpc: <loc or '-'> <curr.amt> <exp. string> <exp. curr.amt>
2225 if (!tokens
.next(currAmt
, ec
)) goto error
;
2226 if (!tokens
.next(str
, ec
)) goto error
;
2227 parseCurrencyAmount(currAmt
, *ref
, (UChar
)0x2F/*'/'*/, n
, ec
);
2228 if (assertSuccess("parseCurrencyAmount", ec
)) {
2229 assertEquals(where
+ "getCurrencyFormat(" + mloc
+ ").format(" + currAmt
+ ")",
2230 str
, mfmt
->format(n
, out
.remove(), ec
));
2231 assertSuccess("format", ec
);
2233 if (!tokens
.next(currAmt
, ec
)) goto error
;
2234 parseCurrencyAmount(currAmt
, *ref
, (UChar
)0x2F/*'/'*/, n
, ec
);
2235 if (assertSuccess("parseCurrencyAmount", ec
)) {
2238 mfmt
->parseObject(str
, m
, ec
);
2239 if (assertSuccess("parseCurrency", ec
)) {
2240 assertEquals(where
+ "getCurrencyFormat(" + mloc
+ ").parse(\"" + str
+ "\")",
2243 errln("FAIL: source " + str
);
2248 // perr: <pattern or '-'> <invalid string>
2249 errln("FAIL: Under construction");
2252 // pat: <pattern> <exp. toPattern, or '-' or 'err'>
2253 UnicodeString testpat
;
2254 UnicodeString exppat
;
2255 if (!tokens
.next(testpat
, ec
)) goto error
;
2256 if (!tokens
.next(exppat
, ec
)) goto error
;
2257 UBool err
= exppat
== "err";
2258 UBool existingPat
= FALSE
;
2259 if (testpat
== "-") {
2261 errln("FAIL: " + where
+ "Invalid command \"pat: - err\"");
2267 if (exppat
== "-") exppat
= testpat
;
2268 DecimalFormat
* f
= 0;
2269 UErrorCode ec2
= U_ZERO_ERROR
;
2273 f
= new DecimalFormat(testpat
, ec2
);
2275 if (U_SUCCESS(ec2
)) {
2277 errln("FAIL: " + where
+ "Invalid pattern \"" + testpat
+
2281 assertEquals(where
+ "\"" + testpat
+ "\".toPattern()",
2282 exppat
, f
->toPattern(pat2
));
2286 logln("Ok: " + where
+ "Invalid pattern \"" + testpat
+
2287 "\" failed: " + u_errorName(ec2
));
2289 errln("FAIL: " + where
+ "Valid pattern \"" + testpat
+
2290 "\" failed: " + u_errorName(ec2
));
2293 if (!existingPat
) delete f
;
2296 errln("FAIL: " + where
+ "Unknown command \"" + tok
+ "\"");
2303 if (U_SUCCESS(ec
)) {
2304 errln("FAIL: Unexpected EOF");
2306 errcheckln(ec
, "FAIL: " + where
+ "Unexpected " + u_errorName(ec
));
2316 //----------------------------------------------------------------------
2318 //----------------------------------------------------------------------
2320 UBool
NumberFormatTest::equalValue(const Formattable
& a
, const Formattable
& b
) {
2321 if (a
.getType() == b
.getType()) {
2325 if (a
.getType() == Formattable::kLong
) {
2326 if (b
.getType() == Formattable::kInt64
) {
2327 return a
.getLong() == b
.getLong();
2328 } else if (b
.getType() == Formattable::kDouble
) {
2329 return (double) a
.getLong() == b
.getDouble(); // TODO check use of double instead of long
2331 } else if (a
.getType() == Formattable::kDouble
) {
2332 if (b
.getType() == Formattable::kLong
) {
2333 return a
.getDouble() == (double) b
.getLong();
2334 } else if (b
.getType() == Formattable::kInt64
) {
2335 return a
.getDouble() == (double)b
.getInt64();
2337 } else if (a
.getType() == Formattable::kInt64
) {
2338 if (b
.getType() == Formattable::kLong
) {
2339 return a
.getInt64() == (int64_t)b
.getLong();
2340 } else if (b
.getType() == Formattable::kDouble
) {
2341 return a
.getInt64() == (int64_t)b
.getDouble();
2347 void NumberFormatTest::expect3(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
) {
2348 // Don't round-trip format test, since we explicitly do it
2349 expect_rbnf(fmt
, n
, str
, FALSE
);
2350 expect_rbnf(fmt
, str
, n
);
2353 void NumberFormatTest::expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
) {
2354 // Don't round-trip format test, since we explicitly do it
2355 expect(fmt
, n
, str
, FALSE
);
2356 expect(fmt
, str
, n
);
2359 void NumberFormatTest::expect2(NumberFormat
* fmt
, const Formattable
& n
,
2360 const UnicodeString
& exp
,
2361 UErrorCode status
) {
2362 if (fmt
== NULL
|| U_FAILURE(status
)) {
2363 dataerrln("FAIL: NumberFormat constructor");
2365 expect2(*fmt
, n
, exp
);
2370 void NumberFormatTest::expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
) {
2371 UErrorCode status
= U_ZERO_ERROR
;
2373 fmt
.parse(str
, num
, status
);
2374 if (U_FAILURE(status
)) {
2375 dataerrln(UnicodeString("FAIL: Parse failed for \"") + str
+ "\" - " + u_errorName(status
));
2379 ((DecimalFormat
*) &fmt
)->toPattern(pat
);
2380 if (equalValue(num
, n
)) {
2381 logln(UnicodeString("Ok \"") + str
+ "\" x " +
2385 dataerrln(UnicodeString("FAIL \"") + str
+ "\" x " +
2387 toString(num
) + ", expected " + toString(n
));
2391 void NumberFormatTest::expect_rbnf(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
) {
2392 UErrorCode status
= U_ZERO_ERROR
;
2394 fmt
.parse(str
, num
, status
);
2395 if (U_FAILURE(status
)) {
2396 errln(UnicodeString("FAIL: Parse failed for \"") + str
+ "\"");
2399 if (equalValue(num
, n
)) {
2400 logln(UnicodeString("Ok \"") + str
+ " = " +
2403 errln(UnicodeString("FAIL \"") + str
+ " = " +
2404 toString(num
) + ", expected " + toString(n
));
2408 void NumberFormatTest::expect_rbnf(NumberFormat
& fmt
, const Formattable
& n
,
2409 const UnicodeString
& exp
, UBool rt
) {
2412 UErrorCode status
= U_ZERO_ERROR
;
2413 fmt
.format(n
, saw
, pos
, status
);
2414 CHECK(status
, "NumberFormat::format");
2416 logln(UnicodeString("Ok ") + toString(n
) +
2418 escape(saw
) + "\"");
2419 // We should be able to round-trip the formatted string =>
2420 // number => string (but not the other way around: number
2421 // => string => number2, might have number2 != number):
2424 fmt
.parse(exp
, n2
, status
);
2425 if (U_FAILURE(status
)) {
2426 errln(UnicodeString("FAIL: Parse failed for \"") + exp
+ "\"");
2430 fmt
.format(n2
, saw2
, pos
, status
);
2431 CHECK(status
, "NumberFormat::format");
2433 errln((UnicodeString
)"FAIL \"" + exp
+ "\" => " + toString(n2
) +
2434 " => \"" + saw2
+ "\"");
2438 errln(UnicodeString("FAIL ") + toString(n
) +
2440 escape(saw
) + "\", expected \"" + exp
+ "\"");
2444 void NumberFormatTest::expect(NumberFormat
& fmt
, const Formattable
& n
,
2445 const UnicodeString
& exp
, UBool rt
) {
2448 UErrorCode status
= U_ZERO_ERROR
;
2449 fmt
.format(n
, saw
, pos
, status
);
2450 CHECK(status
, "NumberFormat::format");
2452 ((DecimalFormat
*) &fmt
)->toPattern(pat
);
2454 logln(UnicodeString("Ok ") + toString(n
) + " x " +
2455 escape(pat
) + " = \"" +
2456 escape(saw
) + "\"");
2457 // We should be able to round-trip the formatted string =>
2458 // number => string (but not the other way around: number
2459 // => string => number2, might have number2 != number):
2462 fmt
.parse(exp
, n2
, status
);
2463 if (U_FAILURE(status
)) {
2464 errln(UnicodeString("FAIL: Parse failed for \"") + exp
+ "\" - " + u_errorName(status
));
2468 fmt
.format(n2
, saw2
, pos
, status
);
2469 CHECK(status
, "NumberFormat::format");
2471 errln((UnicodeString
)"FAIL \"" + exp
+ "\" => " + toString(n2
) +
2472 " => \"" + saw2
+ "\"");
2476 dataerrln(UnicodeString("FAIL ") + toString(n
) + " x " +
2477 escape(pat
) + " = \"" +
2478 escape(saw
) + "\", expected \"" + exp
+ "\"");
2482 void NumberFormatTest::expect(NumberFormat
* fmt
, const Formattable
& n
,
2483 const UnicodeString
& exp
,
2484 UErrorCode status
) {
2485 if (fmt
== NULL
|| U_FAILURE(status
)) {
2486 dataerrln("FAIL: NumberFormat constructor");
2488 expect(*fmt
, n
, exp
);
2493 void NumberFormatTest::expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
2494 double value
, const UnicodeString
& string
) {
2495 UErrorCode ec
= U_ZERO_ERROR
;
2496 DecimalFormat
& fmt
= * (DecimalFormat
*) &nf
;
2497 const UChar DEFAULT_CURR
[] = {45/*-*/,0};
2499 u_strcpy(curr
, DEFAULT_CURR
);
2500 if (*locale
.getLanguage() != 0) {
2501 ucurr_forLocale(locale
.getName(), curr
, 4, &ec
);
2502 assertSuccess("ucurr_forLocale", ec
);
2503 fmt
.setCurrency(curr
, ec
);
2504 assertSuccess("DecimalFormat::setCurrency", ec
);
2505 fmt
.setCurrency(curr
); //Deprecated variant, for coverage only
2508 fmt
.format(value
, s
);
2509 s
.findAndReplace((UChar32
)0x00A0, (UChar32
)0x0020);
2511 // Default display of the number yields "1234.5599999999999"
2512 // instead of "1234.56". Use a formatter to fix this.
2514 NumberFormat::createInstance(Locale::getUS(), ec
);
2516 if (U_FAILURE(ec
)) {
2517 // Oops; bad formatter. Use default op+= display.
2518 v
= (UnicodeString
)"" + value
;
2520 f
->setMaximumFractionDigits(4);
2521 f
->setGroupingUsed(FALSE
);
2522 f
->format(value
, v
);
2527 logln((UnicodeString
)"Ok: " + v
+ " x " + curr
+ " => " + prettify(s
));
2529 errln((UnicodeString
)"FAIL: " + v
+ " x " + curr
+ " => " + prettify(s
) +
2530 ", expected " + prettify(string
));
2534 void NumberFormatTest::expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
) {
2538 logln(UnicodeString("Ok \"") + pat
+ "\"");
2540 errln(UnicodeString("FAIL \"") + pat
+ "\", expected \"" + exp
+ "\"");
2544 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2546 expectPad(fmt
, pat
, pos
, 0, (UnicodeString
)"");
2548 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2549 int32_t pos
, int32_t width
, UChar pad
) {
2550 expectPad(fmt
, pat
, pos
, width
, UnicodeString(pad
));
2552 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2553 int32_t pos
, int32_t width
, const UnicodeString
& pad
) {
2554 int32_t apos
= 0, awidth
= 0;
2555 UnicodeString apadStr
;
2556 UErrorCode status
= U_ZERO_ERROR
;
2557 fmt
.applyPattern(pat
, status
);
2558 if (U_SUCCESS(status
)) {
2559 apos
= fmt
.getPadPosition();
2560 awidth
= fmt
.getFormatWidth();
2561 apadStr
=fmt
.getPadCharacterString();
2567 if (apos
== pos
&& awidth
== width
&& apadStr
== pad
) {
2568 UnicodeString infoStr
;
2569 if (pos
== ILLEGAL
) {
2570 infoStr
= UnicodeString(" width=", "") + awidth
+ UnicodeString(" pad=", "") + apadStr
;
2572 logln(UnicodeString("Ok \"") + pat
+ "\" pos=" + apos
+ infoStr
);
2574 errln(UnicodeString("FAIL \"") + pat
+ "\" pos=" + apos
+
2575 " width=" + awidth
+ " pad=" + apadStr
+
2576 ", expected " + pos
+ " " + width
+ " " + pad
);
2579 void NumberFormatTest::TestJB3832(){
2580 const char* localeID
= "pt_PT@currency=PTE";
2581 Locale
loc(localeID
);
2582 UErrorCode status
= U_ZERO_ERROR
;
2583 UnicodeString
expected(CharsToUnicodeString("1,150$50\\u00A0Esc."));
2585 NumberFormat
* currencyFmt
= NumberFormat::createCurrencyInstance(loc
, status
);
2586 if(U_FAILURE(status
)){
2587 dataerrln("Could not create currency formatter for locale %s - %s", localeID
, u_errorName(status
));
2590 currencyFmt
->format(1150.50, s
);
2592 errln(UnicodeString("FAIL: Expected: ")+expected
2593 + UnicodeString(" Got: ") + s
2594 + UnicodeString( " for locale: ")+ UnicodeString(localeID
) );
2596 if (U_FAILURE(status
)){
2597 errln("FAIL: Status %s", u_errorName(status
));
2602 void NumberFormatTest::TestHost()
2605 Win32NumberTest::testLocales(this);
2607 for (NumberFormat::EStyles k
= NumberFormat::kNumberStyle
;
2608 k
< NumberFormat::kStyleCount
; k
= (NumberFormat::EStyles
)(k
+1)) {
2609 UErrorCode status
= U_ZERO_ERROR
;
2610 Locale
loc("en_US@compat=host");
2611 NumberFormat
*full
= NumberFormat::createInstance(loc
, status
);
2612 if (full
== NULL
|| U_FAILURE(status
)) {
2613 dataerrln("FAIL: Can't create number instance for host - %s", u_errorName(status
));
2616 UnicodeString result1
;
2617 Formattable
number(10.00);
2618 full
->format(number
, result1
, status
);
2619 if (U_FAILURE(status
)) {
2620 errln("FAIL: Can't format for host");
2623 Formattable formattable
;
2624 full
->parse(result1
, formattable
, status
);
2625 if (U_FAILURE(status
)) {
2626 errln("FAIL: Can't parse for host");
2633 void NumberFormatTest::TestHostClone()
2636 Verify that a cloned formatter gives the same results
2637 and is useable after the original has been deleted.
2639 // This is mainly important on Windows.
2640 UErrorCode status
= U_ZERO_ERROR
;
2641 Locale
loc("en_US@compat=host");
2642 UDate now
= Calendar::getNow();
2643 NumberFormat
*full
= NumberFormat::createInstance(loc
, status
);
2644 if (full
== NULL
|| U_FAILURE(status
)) {
2645 dataerrln("FAIL: Can't create Relative date instance - %s", u_errorName(status
));
2648 UnicodeString result1
;
2649 full
->format(now
, result1
, status
);
2650 Format
*fullClone
= full
->clone();
2654 UnicodeString result2
;
2655 fullClone
->format(now
, result2
, status
);
2656 if (U_FAILURE(status
)) {
2657 errln("FAIL: format failure.");
2659 if (result1
!= result2
) {
2660 errln("FAIL: Clone returned different result from non-clone.");
2665 void NumberFormatTest::TestCurrencyFormat()
2667 // This test is here to increase code coverage.
2668 UErrorCode status
= U_ZERO_ERROR
;
2669 MeasureFormat
*cloneObj
;
2671 Formattable toFormat
, result
;
2672 static const UChar ISO_CODE
[4] = {0x0047, 0x0042, 0x0050, 0};
2674 Locale saveDefaultLocale
= Locale::getDefault();
2675 Locale::setDefault( Locale::getUK(), status
);
2676 if (U_FAILURE(status
)) {
2677 errln("couldn't set default Locale!");
2681 MeasureFormat
*measureObj
= MeasureFormat::createCurrencyFormat(status
);
2682 Locale::setDefault( saveDefaultLocale
, status
);
2683 if (U_FAILURE(status
)){
2684 dataerrln("FAIL: Status %s", u_errorName(status
));
2687 cloneObj
= (MeasureFormat
*)measureObj
->clone();
2688 if (cloneObj
== NULL
) {
2689 errln("Clone doesn't work");
2692 toFormat
.adoptObject(new CurrencyAmount(1234.56, ISO_CODE
, status
));
2693 measureObj
->format(toFormat
, str
, status
);
2694 measureObj
->parseObject(str
, result
, status
);
2695 if (U_FAILURE(status
)){
2696 errln("FAIL: Status %s", u_errorName(status
));
2698 if (result
!= toFormat
) {
2699 errln("measureObj does not round trip. Formatted string was \"" + str
+ "\" Got: " + toString(result
) + " Expected: " + toString(toFormat
));
2701 status
= U_ZERO_ERROR
;
2703 cloneObj
->format(toFormat
, str
, status
);
2704 cloneObj
->parseObject(str
, result
, status
);
2705 if (U_FAILURE(status
)){
2706 errln("FAIL: Status %s", u_errorName(status
));
2708 if (result
!= toFormat
) {
2709 errln("Clone does not round trip. Formatted string was \"" + str
+ "\" Got: " + toString(result
) + " Expected: " + toString(toFormat
));
2711 if (*measureObj
!= *cloneObj
) {
2712 errln("Cloned object is not equal to the original object");
2717 status
= U_USELESS_COLLATOR_ERROR
;
2718 if (MeasureFormat::createCurrencyFormat(status
) != NULL
) {
2719 errln("createCurrencyFormat should have returned NULL.");
2723 /* Port of ICU4J rounding test. */
2724 void NumberFormatTest::TestRounding() {
2725 UErrorCode status
= U_ZERO_ERROR
;
2726 DecimalFormat
*df
= (DecimalFormat
*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status
);
2728 if (U_FAILURE(status
)) {
2729 dataerrln("Unable to create decimal formatter. - %s", u_errorName(status
));
2733 int roundingIncrements
[]={1, 2, 5, 20, 50, 100};
2734 int testValues
[]={0, 300};
2736 for (int j
=0; j
<2; j
++) {
2737 for (int mode
=DecimalFormat::kRoundUp
;mode
<DecimalFormat::kRoundHalfEven
;mode
++) {
2738 df
->setRoundingMode((DecimalFormat::ERoundingMode
)mode
);
2739 for (int increment
=0; increment
<6; increment
++) {
2740 double base
=testValues
[j
];
2741 double rInc
=roundingIncrements
[increment
];
2742 checkRounding(df
, base
, 20, rInc
);
2743 rInc
=1.000000000/rInc
;
2744 checkRounding(df
, base
, 20, rInc
);
2751 void NumberFormatTest::checkRounding(DecimalFormat
* df
, double base
, int iterations
, double increment
) {
2752 df
->setRoundingIncrement(increment
);
2753 double lastParsed
=INT32_MIN
; //Intger.MIN_VALUE
2754 for (int i
=-iterations
; i
<=iterations
;i
++) {
2755 double iValue
=base
+(increment
*(i
*0.1));
2756 double smallIncrement
=0.00000001;
2758 smallIncrement
*=iValue
;
2760 //we not only test the value, but some values in a small range around it
2761 lastParsed
=checkRound(df
, iValue
-smallIncrement
, lastParsed
);
2762 lastParsed
=checkRound(df
, iValue
, lastParsed
);
2763 lastParsed
=checkRound(df
, iValue
+smallIncrement
, lastParsed
);
2767 double NumberFormatTest::checkRound(DecimalFormat
* df
, double iValue
, double lastParsed
) {
2768 UErrorCode status
=U_ZERO_ERROR
;
2769 UnicodeString formattedDecimal
;
2772 df
->format(iValue
, formattedDecimal
, status
);
2774 if (U_FAILURE(status
)) {
2775 errln("Error formatting number.");
2778 df
->parse(formattedDecimal
, result
, status
);
2780 if (U_FAILURE(status
)) {
2781 errln("Error parsing number.");
2784 parsed
=result
.getDouble();
2786 if (lastParsed
>parsed
) {
2787 errln("Rounding wrong direction! %d > %d", lastParsed
, parsed
);
2793 void NumberFormatTest::TestNonpositiveMultiplier() {
2794 UErrorCode status
= U_ZERO_ERROR
;
2795 DecimalFormatSymbols
US(Locale::getUS(), status
);
2796 CHECK(status
, "DecimalFormatSymbols constructor");
2797 DecimalFormat
df(UnicodeString("0"), US
, status
);
2798 CHECK(status
, "DecimalFormat(0)");
2800 // test zero multiplier
2802 int32_t mult
= df
.getMultiplier();
2803 df
.setMultiplier(0);
2804 if (df
.getMultiplier() != mult
) {
2805 errln("DecimalFormat.setMultiplier(0) did not ignore its zero input");
2808 // test negative multiplier
2810 df
.setMultiplier(-1);
2811 if (df
.getMultiplier() != -1) {
2812 errln("DecimalFormat.setMultiplier(-1) ignored its negative input");
2816 expect(df
, "1122.123", -1122.123);
2817 expect(df
, "-1122.123", 1122.123);
2818 expect(df
, "1.2", -1.2);
2819 expect(df
, "-1.2", 1.2);
2821 // Note: the tests with the final parameter of FALSE will not round trip.
2822 // The initial numeric value will format correctly, after the multiplier.
2823 // Parsing the formatted text will be out-of-range for an int64, however.
2824 // The expect() function could be modified to detect this and fall back
2825 // to looking at the decimal parsed value, but it doesn't.
2826 expect(df
, U_INT64_MIN
, "9223372036854775808", FALSE
);
2827 expect(df
, U_INT64_MIN
+1, "9223372036854775807");
2828 expect(df
, (int64_t)-123, "123");
2829 expect(df
, (int64_t)123, "-123");
2830 expect(df
, U_INT64_MAX
-1, "-9223372036854775806");
2831 expect(df
, U_INT64_MAX
, "-9223372036854775807");
2833 df
.setMultiplier(-2);
2834 expect(df
, -(U_INT64_MIN
/2)-1, "-9223372036854775806");
2835 expect(df
, -(U_INT64_MIN
/2), "-9223372036854775808");
2836 expect(df
, -(U_INT64_MIN
/2)+1, "-9223372036854775810", FALSE
);
2838 df
.setMultiplier(-7);
2839 expect(df
, -(U_INT64_MAX
/7)-1, "9223372036854775814", FALSE
);
2840 expect(df
, -(U_INT64_MAX
/7), "9223372036854775807");
2841 expect(df
, -(U_INT64_MAX
/7)+1, "9223372036854775800");
2843 // TODO: uncomment (and fix up) all the following int64_t tests once BigInteger is ported
2844 // (right now the big numbers get turned into doubles and lose tons of accuracy)
2845 //expect2(df, U_INT64_MAX, Int64ToUnicodeString(-U_INT64_MAX));
2846 //expect2(df, U_INT64_MIN, UnicodeString(Int64ToUnicodeString(U_INT64_MIN), 1));
2847 //expect2(df, U_INT64_MAX / 2, Int64ToUnicodeString(-(U_INT64_MAX / 2)));
2848 //expect2(df, U_INT64_MIN / 2, Int64ToUnicodeString(-(U_INT64_MIN / 2)));
2850 // TODO: uncomment (and fix up) once BigDecimal is ported and DecimalFormat can handle it
2851 //expect2(df, BigDecimal.valueOf(Long.MAX_VALUE), BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
2852 //expect2(df, BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
2853 //expect2(df, java.math.BigDecimal.valueOf(Long.MAX_VALUE), java.math.BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
2854 //expect2(df, java.math.BigDecimal.valueOf(Long.MIN_VALUE), java.math.BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
2859 NumberFormatTest::TestSpaceParsing() {
2861 // the string to be parsed, parsed position, parsed error index
2862 const char* DATA
[][3] = {
2863 {"$124", "4", "-1"},
2864 {"$124 $124", "4", "-1"},
2865 {"$124 ", "4", "-1"},
2866 {"$ 124 ", "5", "-1"},
2867 {"$\\u00A0124 ", "5", "-1"},
2868 {" $ 124 ", "6", "-1"},
2869 //{"124$", "4", "-1"}, // TODO: need to handle trailing currency correctly
2870 {"124$", "3", "-1"},
2871 //{"124 $", "5", "-1"}, // TODO: OK or not, need currency spacing rule
2872 {"124 $", "4", "-1"},
2875 UErrorCode status
= U_ZERO_ERROR
;
2876 Locale
locale("en_US");
2877 NumberFormat
* foo
= NumberFormat::createCurrencyInstance(locale
, status
);
2879 if (U_FAILURE(status
)) {
2884 foo
->setParseStrict(FALSE
);
2885 for (uint32_t i
= 0; i
< sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
2886 ParsePosition
parsePosition(0);
2887 UnicodeString stringToBeParsed
= ctou(DATA
[i
][0]);
2888 int parsedPosition
= atoi(DATA
[i
][1]);
2889 int errorIndex
= atoi(DATA
[i
][2]);
2891 foo
->parse(stringToBeParsed
, result
, parsePosition
);
2892 if (parsePosition
.getIndex() != parsedPosition
||
2893 parsePosition
.getErrorIndex() != errorIndex
) {
2894 errln("FAILED parse " + stringToBeParsed
+ "; wrong position, expected: (" + parsedPosition
+ ", " + errorIndex
+ "); got (" + parsePosition
.getIndex() + ", " + parsePosition
.getErrorIndex() + ")");
2896 if (parsePosition
.getErrorIndex() == -1 &&
2897 result
.getType() == Formattable::kLong
&&
2898 result
.getLong() != 124) {
2899 errln("FAILED parse " + stringToBeParsed
+ "; wrong number, expect: 124, got " + result
.getLong());
2906 * Test using various numbering systems and numbering system keyword.
2908 void NumberFormatTest::TestNumberingSystems() {
2909 UErrorCode ec
= U_ZERO_ERROR
;
2911 Locale
loc1("en", "US", "", "numbers=thai");
2912 Locale
loc2("en", "US", "", "numbers=hebr");
2913 Locale
loc3("en", "US", "", "numbers=arabext");
2914 Locale
loc4("en", "US", "", "numbers=foobar");
2915 Locale
loc5("ar", "EG", "", ""); // ar_EG uses arab numbering system
2916 Locale
loc6("ar", "MA", "", ""); // ar_MA uses latn numbering system
2917 Locale
loc7("en", "US", "", "numbers=hanidec");
2919 NumberFormat
* fmt1
= NumberFormat::createInstance(loc1
, ec
);
2920 if (U_FAILURE(ec
)) {
2921 dataerrln("FAIL: getInstance(en_US@numbers=thai) - %s", u_errorName(ec
));
2923 NumberFormat
* fmt2
= NumberFormat::createInstance(loc2
, ec
);
2924 if (U_FAILURE(ec
)) {
2925 dataerrln("FAIL: getInstance(en_US@numbers=hebr) - %s", u_errorName(ec
));
2927 NumberFormat
* fmt3
= NumberFormat::createInstance(loc3
, ec
);
2928 if (U_FAILURE(ec
)) {
2929 dataerrln("FAIL: getInstance(en_US@numbers=arabext) - %s", u_errorName(ec
));
2931 NumberFormat
* fmt5
= NumberFormat::createInstance(loc5
, ec
);
2932 if (U_FAILURE(ec
)) {
2933 dataerrln("FAIL: getInstance(ar_EG) - %s", u_errorName(ec
));
2935 NumberFormat
* fmt6
= NumberFormat::createInstance(loc6
, ec
);
2936 if (U_FAILURE(ec
)) {
2937 dataerrln("FAIL: getInstance(ar_MA) - %s", u_errorName(ec
));
2940 NumberFormat
* fmt7
= NumberFormat::createInstance(loc7
, ec
);
2941 if (U_FAILURE(ec
)) {
2942 dataerrln("FAIL: getInstance(en_US@numbers=hanidec) - %s", u_errorName(ec
));
2945 if (U_SUCCESS(ec
) && fmt1
!= NULL
&& fmt2
!= NULL
&& fmt3
!= NULL
&&
2946 fmt5
!= NULL
&& fmt6
!= NULL
&& fmt7
!= NULL
) {
2947 expect2(*fmt1
, 1234.567, CharsToUnicodeString("\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57"));
2948 expect3(*fmt2
, 5678.0, CharsToUnicodeString("\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7"));
2949 expect2(*fmt3
, 1234.567, CharsToUnicodeString("\\u06F1,\\u06F2\\u06F3\\u06F4.\\u06F5\\u06F6\\u06F7"));
2950 expect2(*fmt5
, 1234.567, CharsToUnicodeString("\\u0661\\u066c\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667"));
2951 expect2(*fmt6
, 1234.567, CharsToUnicodeString("1.234,567"));
2952 expect2(*fmt7
, 1234.567, CharsToUnicodeString("\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03"));
2955 // Test bogus keyword value
2956 NumberFormat
* fmt4
= NumberFormat::createInstance(loc4
, ec
);
2957 if ( ec
!= U_UNSUPPORTED_ERROR
) {
2958 errln("FAIL: getInstance(en_US@numbers=foobar) should have returned U_UNSUPPORTED_ERROR");
2962 NumberingSystem
*ns
= NumberingSystem::createInstance(ec
);
2963 if (U_FAILURE(ec
)) {
2964 dataerrln("FAIL: NumberingSystem::createInstance(ec); - %s", u_errorName(ec
));
2968 ns
->getDynamicClassID();
2969 ns
->getStaticClassID();
2971 errln("FAIL: getInstance() returned NULL.");
2974 NumberingSystem
*ns1
= new NumberingSystem(*ns
);
2976 errln("FAIL: NumberSystem copy constructor returned NULL.");
2992 NumberFormatTest::TestMultiCurrencySign() {
2993 const char* DATA
[][6] = {
2994 // the fields in the following test are:
2996 // currency pattern (with negative pattern),
2997 // currency number to be formatted,
2998 // currency format using currency symbol name, such as "$" for USD,
2999 // currency format using currency ISO name, such as "USD",
3000 // currency format using plural name, such as "US dollars".
3002 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1234.56", "$1,234.56", "USD1,234.56", "US dollars1,234.56"},
3003 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "-1234.56", "-$1,234.56", "-USD1,234.56", "-US dollars1,234.56"},
3004 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1", "$1.00", "USD1.00", "US dollar1.00"},
3006 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1234.56", "\\uFFE51,234.56", "CNY1,234.56", "\\u4EBA\\u6C11\\u5E011,234.56"},
3007 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "-1234.56", "(\\uFFE51,234.56)", "(CNY1,234.56)", "(\\u4EBA\\u6C11\\u5E011,234.56)"},
3008 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1", "\\uFFE51.00", "CNY1.00", "\\u4EBA\\u6C11\\u5E011.00"}
3011 const UChar doubleCurrencySign
[] = {0xA4, 0xA4, 0};
3012 UnicodeString
doubleCurrencyStr(doubleCurrencySign
);
3013 const UChar tripleCurrencySign
[] = {0xA4, 0xA4, 0xA4, 0};
3014 UnicodeString
tripleCurrencyStr(tripleCurrencySign
);
3016 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3017 const char* locale
= DATA
[i
][0];
3018 UnicodeString pat
= ctou(DATA
[i
][1]);
3019 double numberToBeFormat
= atof(DATA
[i
][2]);
3020 UErrorCode status
= U_ZERO_ERROR
;
3021 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale(locale
), status
);
3022 if (U_FAILURE(status
)) {
3026 for (int j
=1; j
<=3; ++j
) {
3027 // j represents the number of currency sign in the pattern.
3029 pat
= pat
.findAndReplace(ctou("\\u00A4"), doubleCurrencyStr
);
3030 } else if (j
== 3) {
3031 pat
= pat
.findAndReplace(ctou("\\u00A4\\u00A4"), tripleCurrencyStr
);
3034 DecimalFormat
* fmt
= new DecimalFormat(pat
, new DecimalFormatSymbols(*sym
), status
);
3035 if (U_FAILURE(status
)) {
3036 errln("FAILED init DecimalFormat ");
3041 ((NumberFormat
*) fmt
)->format(numberToBeFormat
, s
);
3042 // DATA[i][3] is the currency format result using a
3043 // single currency sign.
3044 // DATA[i][4] is the currency format result using
3045 // double currency sign.
3046 // DATA[i][5] is the currency format result using
3047 // triple currency sign.
3048 // DATA[i][j+2] is the currency format result using
3049 // 'j' number of currency sign.
3050 UnicodeString currencyFormatResult
= ctou(DATA
[i
][2+j
]);
3051 if (s
.compare(currencyFormatResult
)) {
3052 errln("FAIL format: Expected " + currencyFormatResult
+ "; Got " + s
);
3054 // mix style parsing
3055 for (int k
=3; k
<=5; ++k
) {
3056 // DATA[i][3] is the currency format result using a
3057 // single currency sign.
3058 // DATA[i][4] is the currency format result using
3059 // double currency sign.
3060 // DATA[i][5] is the currency format result using
3061 // triple currency sign.
3062 UnicodeString oneCurrencyFormat
= ctou(DATA
[i
][k
]);
3063 UErrorCode status
= U_ZERO_ERROR
;
3064 Formattable parseRes
;
3065 fmt
->parse(oneCurrencyFormat
, parseRes
, status
);
3066 if (U_FAILURE(status
) ||
3067 (parseRes
.getType() == Formattable::kDouble
&&
3068 parseRes
.getDouble() != numberToBeFormat
) ||
3069 (parseRes
.getType() == Formattable::kLong
&&
3070 parseRes
.getLong() != numberToBeFormat
)) {
3071 errln("FAILED parse " + oneCurrencyFormat
+ "; (i, j, k): " +
3072 i
+ ", " + j
+ ", " + k
);
3083 NumberFormatTest::TestCurrencyFormatForMixParsing() {
3084 UErrorCode status
= U_ZERO_ERROR
;
3085 MeasureFormat
* curFmt
= MeasureFormat::createCurrencyFormat(Locale("en_US"), status
);
3086 if (U_FAILURE(status
)) {
3090 const char* formats
[] = {
3091 "$1,234.56", // string to be parsed
3093 "US dollars1,234.56",
3094 "1,234.56 US dollars"
3096 const CurrencyAmount
* curramt
= NULL
;
3097 for (uint32_t i
= 0; i
< sizeof(formats
)/sizeof(formats
[0]); ++i
) {
3098 UnicodeString stringToBeParsed
= ctou(formats
[i
]);
3099 logln(UnicodeString("stringToBeParsed: ") + stringToBeParsed
);
3101 UErrorCode status
= U_ZERO_ERROR
;
3102 curFmt
->parseObject(stringToBeParsed
, result
, status
);
3103 if (U_FAILURE(status
)) {
3104 errln("FAIL: measure format parsing: '%s' ec: %s", formats
[i
], u_errorName(status
));
3105 } else if (result
.getType() != Formattable::kObject
||
3106 (curramt
= dynamic_cast<const CurrencyAmount
*>(result
.getObject())) == NULL
||
3107 curramt
->getNumber().getDouble() != 1234.56 ||
3108 UnicodeString(curramt
->getISOCurrency()).compare(ISO_CURRENCY_USD
)
3110 errln("FAIL: getCurrencyFormat of default locale (en_US) failed roundtripping the number ");
3111 if (curramt
->getNumber().getDouble() != 1234.56) {
3112 errln((UnicodeString
)"wong number, expect: 1234.56" + ", got: " + curramt
->getNumber().getDouble());
3114 if (curramt
->getISOCurrency() != ISO_CURRENCY_USD
) {
3115 errln((UnicodeString
)"wong currency, expect: USD" + ", got: " + curramt
->getISOCurrency());
3124 NumberFormatTest::TestDecimalFormatCurrencyParse() {
3126 UErrorCode status
= U_ZERO_ERROR
;
3127 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale("en_US"), status
);
3128 if (U_FAILURE(status
)) {
3133 UChar currency
= 0x00A4;
3134 // "\xA4#,##0.00;-\xA4#,##0.00"
3135 pat
.append(currency
).append(currency
).append(currency
).append("#,##0.00;-").append(currency
).append(currency
).append(currency
).append("#,##0.00");
3136 DecimalFormat
* fmt
= new DecimalFormat(pat
, sym
, status
);
3137 if (U_FAILURE(status
)) {
3139 errln("failed to new DecimalFormat in TestDecimalFormatCurrencyParse");
3142 const char* DATA
[][2] = {
3144 // string to be parsed, the parsed result (number)
3147 {"1.00 US dollar", "1"},
3148 {"$1,234.56", "1234.56"},
3149 {"USD1,234.56", "1234.56"},
3150 {"1,234.56 US dollar", "1234.56"},
3152 for (uint32_t i
= 0; i
< sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3153 UnicodeString stringToBeParsed
= ctou(DATA
[i
][0]);
3154 double parsedResult
= atof(DATA
[i
][1]);
3155 UErrorCode status
= U_ZERO_ERROR
;
3157 fmt
->parse(stringToBeParsed
, result
, status
);
3158 if (U_FAILURE(status
) ||
3159 (result
.getType() == Formattable::kDouble
&&
3160 result
.getDouble() != parsedResult
) ||
3161 (result
.getType() == Formattable::kLong
&&
3162 result
.getLong() != parsedResult
)) {
3163 errln((UnicodeString
)"FAIL parse: Expected " + parsedResult
);
3171 NumberFormatTest::TestCurrencyIsoPluralFormat() {
3172 const char* DATA
[][6] = {
3175 // currency amount to be formatted,
3176 // currency ISO code to be formatted,
3177 // format result using CURRENCYSTYLE,
3178 // format result using ISOCURRENCYSTYLE,
3179 // format result using PLURALCURRENCYSTYLE,
3181 {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
3182 {"en_US", "1234.56", "USD", "$1,234.56", "USD1,234.56", "1,234.56 US dollars"},
3183 {"en_US", "-1234.56", "USD", "($1,234.56)", "(USD1,234.56)", "-1,234.56 US dollars"},
3184 {"zh_CN", "1", "USD", "US$1.00", "USD1.00", "1.00 \\u7F8E\\u5143"},
3185 {"zh_CN", "1234.56", "USD", "US$1,234.56", "USD1,234.56", "1,234.56 \\u7F8E\\u5143"},
3186 // wrong ISO code {"zh_CN", "1", "CHY", "CHY1.00", "CHY1.00", "1.00 CHY"},
3187 // wrong ISO code {"zh_CN", "1234.56", "CHY", "CHY1,234.56", "CHY1,234.56", "1,234.56 CHY"},
3188 {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"},
3189 {"zh_CN", "1234.56", "CNY", "\\uFFE51,234.56", "CNY1,234.56", "1,234.56 \\u4EBA\\u6C11\\u5E01"},
3190 {"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"},
3191 {"ru_RU", "2", "RUB", "2,00\\u00A0\\u0440\\u0443\\u0431.", "2,00\\u00A0RUB", "2,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u044F"},
3192 {"ru_RU", "5", "RUB", "5,00\\u00A0\\u0440\\u0443\\u0431.", "5,00\\u00A0RUB", "5,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u0435\\u0439"},
3193 // test locale without currency information
3194 {"root", "-1.23", "USD", "-US$\\u00A01.23", "-USD\\u00A01.23", "-1.23 USD"},
3195 // test choice format
3196 {"es_AR", "1", "INR", "Rs\\u00A01,00", "INR\\u00A01,00", "1,00 rupia india"},
3199 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3200 for (NumberFormat::EStyles k
= NumberFormat::kCurrencyStyle
;
3201 k
<= NumberFormat::kPluralCurrencyStyle
;
3202 k
= (NumberFormat::EStyles
)(k
+1)) {
3203 // k represents currency format style.
3204 if ( k
!= NumberFormat::kCurrencyStyle
&&
3205 k
!= NumberFormat::kIsoCurrencyStyle
&&
3206 k
!= NumberFormat::kPluralCurrencyStyle
) {
3209 const char* localeString
= DATA
[i
][0];
3210 double numberToBeFormat
= atof(DATA
[i
][1]);
3211 const char* currencyISOCode
= DATA
[i
][2];
3212 Locale
locale(localeString
);
3213 UErrorCode status
= U_ZERO_ERROR
;
3214 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, k
, status
);
3215 if (U_FAILURE(status
)) {
3217 dataerrln((UnicodeString
)"can not create instance, locale:" + localeString
+ ", style: " + k
+ " - " + u_errorName(status
));
3220 UChar currencyCode
[4];
3221 u_charsToUChars(currencyISOCode
, currencyCode
, 4);
3222 numFmt
->setCurrency(currencyCode
, status
);
3223 if (U_FAILURE(status
)) {
3225 errln((UnicodeString
)"can not set currency:" + currencyISOCode
);
3229 UnicodeString strBuf
;
3230 numFmt
->format(numberToBeFormat
, strBuf
);
3231 int resultDataIndex
= k
;
3232 if ( k
== NumberFormat::kCurrencyStyle
) {
3233 resultDataIndex
= k
+2;
3235 // DATA[i][resultDataIndex] is the currency format result
3236 // using 'k' currency style.
3237 UnicodeString formatResult
= ctou(DATA
[i
][resultDataIndex
]);
3238 if (strBuf
.compare(formatResult
)) {
3239 errln("FAIL: Expected " + formatResult
+ " actual: " + strBuf
);
3241 // test parsing, and test parsing for all currency formats.
3242 for (int j
= 3; j
< 6; ++j
) {
3243 // DATA[i][3] is the currency format result using
3244 // CURRENCYSTYLE formatter.
3245 // DATA[i][4] is the currency format result using
3246 // ISOCURRENCYSTYLE formatter.
3247 // DATA[i][5] is the currency format result using
3248 // PLURALCURRENCYSTYLE formatter.
3249 UnicodeString oneCurrencyFormatResult
= ctou(DATA
[i
][j
]);
3250 UErrorCode status
= U_ZERO_ERROR
;
3251 Formattable parseResult
;
3252 numFmt
->parse(oneCurrencyFormatResult
, parseResult
, status
);
3253 if (U_FAILURE(status
) ||
3254 (parseResult
.getType() == Formattable::kDouble
&&
3255 parseResult
.getDouble() != numberToBeFormat
) ||
3256 (parseResult
.getType() == Formattable::kLong
&&
3257 parseResult
.getLong() != numberToBeFormat
)) {
3258 errln((UnicodeString
)"FAIL: getCurrencyFormat of locale " +
3259 localeString
+ " failed roundtripping the number");
3260 if (parseResult
.getType() == Formattable::kDouble
) {
3261 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getDouble());
3263 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getLong());
3273 NumberFormatTest::TestCurrencyParsing() {
3274 const char* DATA
[][6] = {
3277 // currency amount to be formatted,
3278 // currency ISO code to be formatted,
3279 // format result using CURRENCYSTYLE,
3280 // format result using ISOCURRENCYSTYLE,
3281 // format result using PLURALCURRENCYSTYLE,
3282 {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
3283 {"pa_IN", "1", "USD", "US$\\u00a0\\u0a67.\\u0a66\\u0a66", "USD\\u00a0\\u0a67.\\u0a66\\u0a66", "\\u0a67.\\u0a66\\u0a66 USD"},
3284 {"es_AR", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 d\\u00f3lar estadounidense"},
3285 {"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"},
3286 {"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"},
3287 {"he_IL", "1", "USD", "1.00\\u00a0US$", "1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"},
3288 {"hr_HR", "1", "USD", "1,00\\u00a0$", "1,00\\u00a0USD", "1,00 Ameri\\u010dki dolar"},
3289 {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 USD"},
3290 {"it_IT", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 Dollaro Statunitense"},
3291 {"ko_KR", "1", "USD", "US$1.00", "USD1.00", "1.00 \\ubbf8\\uad6d \\ub2ec\\ub7ec"},
3292 {"ja_JP", "1", "USD", "$1.00", "USD1.00", "1.00 \\u7c73\\u30c9\\u30eb"},
3293 {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"},
3294 {"zh_TW", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4eba\\u6c11\\u5e63"},
3295 {"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"},
3298 #ifdef NUMFMTST_CACHE_DEBUG
3301 printf("loop: %d\n", deadloop
++);
3303 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3304 for (NumberFormat::EStyles k
= NumberFormat::kCurrencyStyle
;
3305 k
<= NumberFormat::kPluralCurrencyStyle
;
3306 k
= (NumberFormat::EStyles
)(k
+1)) {
3307 // k represents currency format style.
3308 if ( k
!= NumberFormat::kCurrencyStyle
&&
3309 k
!= NumberFormat::kIsoCurrencyStyle
&&
3310 k
!= NumberFormat::kPluralCurrencyStyle
) {
3313 const char* localeString
= DATA
[i
][0];
3314 double numberToBeFormat
= atof(DATA
[i
][1]);
3315 const char* currencyISOCode
= DATA
[i
][2];
3316 Locale
locale(localeString
);
3317 UErrorCode status
= U_ZERO_ERROR
;
3318 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, k
, status
);
3319 if (U_FAILURE(status
)) {
3321 dataerrln((UnicodeString
)"can not create instance, locale:" + localeString
+ ", style: " + k
+ " - " + u_errorName(status
));
3324 // TODO: need to be UChar*
3325 UChar currencyCode
[4];
3326 currencyCode
[0] = currencyISOCode
[0];
3327 currencyCode
[1] = currencyISOCode
[1];
3328 currencyCode
[2] = currencyISOCode
[2];
3329 currencyCode
[3] = currencyISOCode
[3];
3330 numFmt
->setCurrency(currencyCode
, status
);
3331 if (U_FAILURE(status
)) {
3333 errln((UnicodeString
)"can not set currency:" + currencyISOCode
);
3338 UnicodeString strBuf;
3339 numFmt->format(numberToBeFormat, strBuf);
3340 int resultDataIndex = k;
3341 if ( k == NumberFormat::kCurrencyStyle ) {
3342 resultDataIndex = k+2;
3344 // DATA[i][resultDataIndex] is the currency format result
3345 // using 'k' currency style.
3346 UnicodeString formatResult = ctou(DATA[i][resultDataIndex]);
3347 if (strBuf.compare(formatResult)) {
3348 errln("FAIL: Expected " + formatResult + " actual: " + strBuf);
3351 // test parsing, and test parsing for all currency formats.
3352 for (int j
= 3; j
< 6; ++j
) {
3353 // DATA[i][3] is the currency format result using
3354 // CURRENCYSTYLE formatter.
3355 // DATA[i][4] is the currency format result using
3356 // ISOCURRENCYSTYLE formatter.
3357 // DATA[i][5] is the currency format result using
3358 // PLURALCURRENCYSTYLE formatter.
3359 UnicodeString oneCurrencyFormatResult
= ctou(DATA
[i
][j
]);
3360 UErrorCode status
= U_ZERO_ERROR
;
3361 Formattable parseResult
;
3362 numFmt
->parse(oneCurrencyFormatResult
, parseResult
, status
);
3363 if (U_FAILURE(status
) ||
3364 (parseResult
.getType() == Formattable::kDouble
&&
3365 parseResult
.getDouble() != numberToBeFormat
) ||
3366 (parseResult
.getType() == Formattable::kLong
&&
3367 parseResult
.getLong() != numberToBeFormat
)) {
3368 errln((UnicodeString
)"FAIL: getCurrencyFormat of locale " +
3369 localeString
+ " failed roundtripping the number" +
3370 "(i,k,j): " + i
+ ", " + k
+ ", " + j
);
3371 if (parseResult
.getType() == Formattable::kDouble
) {
3372 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getDouble());
3374 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getLong());
3381 #ifdef NUMFMTST_CACHE_DEBUG
3388 NumberFormatTest::TestParseCurrencyInUCurr() {
3389 const char* DATA
[] = {
3390 "1.00 US DOLLAR", // case in-sensitive
3428 "Afghan Afghani (1927-2002)1.00",
3429 "Afghan Afghani (AFA)1.00",
3430 "Afghan Afghani1.00",
3431 "Afghan Afghani1.00",
3432 "Afghan Afghanis (AFA)1.00",
3433 "Afghan Afghanis1.00",
3437 "Albanian lek\\u00eb1.00",
3438 "Algerian Dinar1.00",
3439 "Algerian dinar1.00",
3440 "Algerian dinars1.00",
3441 "Andorran Peseta1.00",
3442 "Andorran peseta1.00",
3443 "Andorran pesetas1.00",
3444 "Angolan Kwanza (1977-1991)1.00",
3445 "Angolan Readjusted Kwanza (1995-1999)1.00",
3446 "Angolan Kwanza1.00",
3447 "Angolan New Kwanza (1990-2000)1.00",
3448 "Angolan kwanza (1977-1991)1.00",
3449 "Angolan readjusted kwanza (1995-1999)1.00",
3450 "Angolan kwanza1.00",
3451 "Angolan kwanzas (1977-1991)1.00",
3452 "Angolan readjusted kwanzas (1995-1999)1.00",
3453 "Angolan kwanzas1.00",
3454 "Angolan new kwanza (1990-2000)1.00",
3455 "Angolan new kwanzas (1990-2000)1.00",
3456 "Argentine Austral1.00",
3457 "Argentine Peso (1983-1985)1.00",
3458 "Argentine Peso1.00",
3459 "Argentine austral1.00",
3460 "Argentine australs1.00",
3461 "Argentine peso (1983-1985)1.00",
3462 "Argentine peso1.00",
3463 "Argentine pesos (1983-1985)1.00",
3464 "Argentine pesos1.00",
3465 "Armenian Dram1.00",
3466 "Armenian dram1.00",
3467 "Armenian drams1.00",
3468 "Aruban Florin1.00",
3469 "Aruban florin1.00",
3470 "Australian Dollar1.00",
3471 "Australian dollar1.00",
3472 "Australian dollars1.00",
3473 "Austrian Schilling1.00",
3474 "Austrian schilling1.00",
3475 "Austrian schillings1.00",
3476 "Azerbaijani Manat (1993-2006)1.00",
3477 "Azerbaijani Manat1.00",
3478 "Azerbaijani manat (1993-2006)1.00",
3479 "Azerbaijani manat1.00",
3480 "Azerbaijani manats (1993-2006)1.00",
3481 "Azerbaijani manats1.00",
3529 "Bahamian Dollar1.00",
3530 "Bahamian dollar1.00",
3531 "Bahamian dollars1.00",
3532 "Bahraini Dinar1.00",
3533 "Bahraini dinar1.00",
3534 "Bahraini dinars1.00",
3535 "Bangladeshi Taka1.00",
3536 "Bangladeshi taka1.00",
3537 "Bangladeshi takas1.00",
3538 "Barbadian Dollar1.00",
3539 "Barbadian dollar1.00",
3540 "Barbadian dollars1.00",
3542 "Belarusian New Ruble (1994-1999)1.00",
3543 "Belarusian Ruble1.00",
3544 "Belarusian new ruble (1994-1999)1.00",
3545 "Belarusian new rubles (1994-1999)1.00",
3546 "Belarusian ruble1.00",
3547 "Belarusian rubles1.00",
3548 "Belgian Franc (convertible)1.00",
3549 "Belgian Franc (financial)1.00",
3550 "Belgian Franc1.00",
3551 "Belgian franc (convertible)1.00",
3552 "Belgian franc (financial)1.00",
3553 "Belgian franc1.00",
3554 "Belgian francs (convertible)1.00",
3555 "Belgian francs (financial)1.00",
3556 "Belgian francs1.00",
3557 "Belize Dollar1.00",
3558 "Belize dollar1.00",
3559 "Belize dollars1.00",
3560 "Bermudan Dollar1.00",
3561 "Bermudan dollar1.00",
3562 "Bermudan dollars1.00",
3563 "Bhutanese Ngultrum1.00",
3564 "Bhutanese ngultrum1.00",
3565 "Bhutanese ngultrums1.00",
3566 "Bolivian Mvdol1.00",
3567 "Bolivian Peso1.00",
3568 "Bolivian mvdol1.00",
3569 "Bolivian mvdols1.00",
3570 "Bolivian peso1.00",
3571 "Bolivian pesos1.00",
3572 "Bolivian Boliviano1.00",
3573 "Bolivian Boliviano1.00",
3574 "Bolivian Bolivianos1.00",
3575 "Bosnia-Herzegovina Convertible Mark1.00",
3576 "Bosnia-Herzegovina Dinar (1992-1994)1.00",
3577 "Bosnia-Herzegovina convertible mark1.00",
3578 "Bosnia-Herzegovina convertible marks1.00",
3579 "Bosnia-Herzegovina dinar (1992-1994)1.00",
3580 "Bosnia-Herzegovina dinars (1992-1994)1.00",
3581 "Botswanan Pula1.00",
3582 "Botswanan pula1.00",
3583 "Botswanan pulas1.00",
3585 "Brazilian New Cruzado (1989-1990)1.00",
3586 "Brazilian Cruzado (1986-1989)1.00",
3587 "Brazilian Cruzeiro (1990-1993)1.00",
3588 "Brazilian New Cruzeiro (1967-1986)1.00",
3589 "Brazilian Cruzeiro (1993-1994)1.00",
3590 "Brazilian Real1.00",
3591 "Brazilian new cruzado (1989-1990)1.00",
3592 "Brazilian new cruzados (1989-1990)1.00",
3593 "Brazilian cruzado (1986-1989)1.00",
3594 "Brazilian cruzados (1986-1989)1.00",
3595 "Brazilian cruzeiro (1990-1993)1.00",
3596 "Brazilian new cruzeiro (1967-1986)1.00",
3597 "Brazilian cruzeiro (1993-1994)1.00",
3598 "Brazilian cruzeiros (1990-1993)1.00",
3599 "Brazilian new cruzeiros (1967-1986)1.00",
3600 "Brazilian cruzeiros (1993-1994)1.00",
3601 "Brazilian real1.00",
3602 "Brazilian reals1.00",
3603 "British Pound Sterling1.00",
3604 "British pound sterling1.00",
3605 "British pounds sterling1.00",
3606 "Brunei Dollar1.00",
3607 "Brunei dollar1.00",
3608 "Brunei dollars1.00",
3611 "Bulgarian Hard Lev1.00",
3612 "Bulgarian Lev1.00",
3613 "Bulgarian Leva1.00",
3614 "Bulgarian hard lev1.00",
3615 "Bulgarian hard leva1.00",
3616 "Bulgarian lev1.00",
3619 "Burmese kyats1.00",
3620 "Burundian Franc1.00",
3621 "Burundian franc1.00",
3622 "Burundian francs1.00",
3629 "CFA Franc BCEAO1.00",
3630 "CFA Franc BEAC1.00",
3631 "CFA franc BCEAO1.00",
3632 "CFA franc BEAC1.00",
3633 "CFA francs BCEAO1.00",
3634 "CFA francs BEAC1.00",
3663 "Cambodian Riel1.00",
3664 "Cambodian riel1.00",
3665 "Cambodian riels1.00",
3666 "Canadian Dollar1.00",
3667 "Canadian dollar1.00",
3668 "Canadian dollars1.00",
3669 "Cape Verdean Escudo1.00",
3670 "Cape Verdean escudo1.00",
3671 "Cape Verdean escudos1.00",
3672 "Cayman Islands Dollar1.00",
3673 "Cayman Islands dollar1.00",
3674 "Cayman Islands dollars1.00",
3676 "Chilean Unit of Account (UF)1.00",
3678 "Chilean pesos1.00",
3679 "Chilean unit of account (UF)1.00",
3680 "Chilean units of account (UF)1.00",
3683 "Colombian Peso1.00",
3684 "Colombian peso1.00",
3685 "Colombian pesos1.00",
3686 "Comorian Franc1.00",
3687 "Comorian franc1.00",
3688 "Comorian francs1.00",
3689 "Congolese Franc1.00",
3690 "Congolese franc1.00",
3691 "Congolese francs1.00",
3692 "Costa Rican Col\\u00f3n1.00",
3693 "Costa Rican col\\u00f3n1.00",
3694 "Costa Rican col\\u00f3ns1.00",
3695 "Croatian Dinar1.00",
3696 "Croatian Kuna1.00",
3697 "Croatian dinar1.00",
3698 "Croatian dinars1.00",
3699 "Croatian kuna1.00",
3700 "Croatian kunas1.00",
3704 "Cypriot Pound1.00",
3705 "Cypriot pound1.00",
3706 "Cypriot pounds1.00",
3707 "Czech Republic Koruna1.00",
3708 "Czech Republic koruna1.00",
3709 "Czech Republic korunas1.00",
3710 "Czechoslovak Hard Koruna1.00",
3711 "Czechoslovak hard koruna1.00",
3712 "Czechoslovak hard korunas1.00",
3724 "Danish kroner1.00",
3729 "Djiboutian Franc1.00",
3730 "Djiboutian franc1.00",
3731 "Djiboutian francs1.00",
3733 "Dominican Peso1.00",
3734 "Dominican peso1.00",
3735 "Dominican pesos1.00",
3754 "East Caribbean Dollar1.00",
3755 "East Caribbean dollar1.00",
3756 "East Caribbean dollars1.00",
3757 "East German Mark1.00",
3758 "East German mark1.00",
3759 "East German marks1.00",
3760 "Ecuadorian Sucre1.00",
3761 "Ecuadorian Unit of Constant Value1.00",
3762 "Ecuadorian sucre1.00",
3763 "Ecuadorian sucres1.00",
3764 "Ecuadorian unit of constant value1.00",
3765 "Ecuadorian units of constant value1.00",
3766 "Egyptian Pound1.00",
3767 "Egyptian pound1.00",
3768 "Egyptian pounds1.00",
3769 "Salvadoran Col\\u00f3n1.00",
3770 "Salvadoran col\\u00f3n1.00",
3771 "Salvadoran colones1.00",
3772 "Equatorial Guinean Ekwele1.00",
3773 "Equatorial Guinean ekwele1.00",
3774 "Eritrean Nakfa1.00",
3775 "Eritrean nakfa1.00",
3776 "Eritrean nakfas1.00",
3778 "Estonian Kroon1.00",
3779 "Estonian kroon1.00",
3780 "Estonian kroons1.00",
3781 "Ethiopian Birr1.00",
3782 "Ethiopian birr1.00",
3783 "Ethiopian birrs1.00",
3785 "European Composite Unit1.00",
3786 "European Currency Unit1.00",
3787 "European Monetary Unit1.00",
3788 "European Unit of Account (XBC)1.00",
3789 "European Unit of Account (XBD)1.00",
3790 "European composite unit1.00",
3791 "European composite units1.00",
3792 "European currency unit1.00",
3793 "European currency units1.00",
3794 "European monetary unit1.00",
3795 "European monetary units1.00",
3796 "European unit of account (XBC)1.00",
3797 "European unit of account (XBD)1.00",
3798 "European units of account (XBC)1.00",
3799 "European units of account (XBD)1.00",
3809 "Falkland Islands Pound1.00",
3810 "Falkland Islands pound1.00",
3811 "Falkland Islands pounds1.00",
3813 "Fijian Dollar1.00",
3814 "Fijian dollar1.00",
3815 "Fijian dollars1.00",
3816 "Finnish Markka1.00",
3817 "Finnish markka1.00",
3818 "Finnish markkas1.00",
3821 "French Gold Franc1.00",
3822 "French UIC-Franc1.00",
3823 "French UIC-franc1.00",
3824 "French UIC-francs1.00",
3826 "French francs1.00",
3827 "French gold franc1.00",
3828 "French gold francs1.00",
3856 "Gambian Dalasi1.00",
3857 "Gambian dalasi1.00",
3858 "Gambian dalasis1.00",
3859 "Georgian Kupon Larit1.00",
3860 "Georgian Lari1.00",
3861 "Georgian kupon larit1.00",
3862 "Georgian kupon larits1.00",
3863 "Georgian lari1.00",
3864 "Georgian laris1.00",
3865 "Ghanaian Cedi (1979-2007)1.00",
3866 "Ghanaian Cedi1.00",
3867 "Ghanaian cedi (1979-2007)1.00",
3868 "Ghanaian cedi1.00",
3869 "Ghanaian cedis (1979-2007)1.00",
3870 "Ghanaian cedis1.00",
3871 "Gibraltar Pound1.00",
3872 "Gibraltar pound1.00",
3873 "Gibraltar pounds1.00",
3876 "Greek Drachma1.00",
3877 "Greek drachma1.00",
3878 "Greek drachmas1.00",
3879 "Guatemalan Quetzal1.00",
3880 "Guatemalan quetzal1.00",
3881 "Guatemalan quetzals1.00",
3882 "Guinean Franc1.00",
3884 "Guinean franc1.00",
3885 "Guinean francs1.00",
3887 "Guinean sylis1.00",
3888 "Guinea-Bissau Peso1.00",
3889 "Guinea-Bissau peso1.00",
3890 "Guinea-Bissau pesos1.00",
3891 "Guyanaese Dollar1.00",
3892 "Guyanaese dollar1.00",
3893 "Guyanaese dollars1.00",
3904 "Haitian Gourde1.00",
3905 "Haitian gourde1.00",
3906 "Haitian gourdes1.00",
3907 "Honduran Lempira1.00",
3908 "Honduran lempira1.00",
3909 "Honduran lempiras1.00",
3910 "Hong Kong Dollar1.00",
3911 "Hong Kong dollar1.00",
3912 "Hong Kong dollars1.00",
3913 "Hungarian Forint1.00",
3914 "Hungarian forint1.00",
3915 "Hungarian forints1.00",
3928 "Icelandic Kr\\u00f3na1.00",
3929 "Icelandic kr\\u00f3na1.00",
3930 "Icelandic kr\\u00f3nur1.00",
3933 "Indian rupees1.00",
3934 "Indonesian Rupiah1.00",
3935 "Indonesian rupiah1.00",
3936 "Indonesian rupiahs1.00",
3939 "Iranian rials1.00",
3946 "Israeli Pound1.00",
3947 "Israeli new sheqel1.00",
3948 "Israeli pound1.00",
3949 "Israeli pounds1.00",
3952 "Italian liras1.00",
3958 "Jamaican Dollar1.00",
3959 "Jamaican dollar1.00",
3960 "Jamaican dollars1.00",
3963 "Jordanian Dinar1.00",
3964 "Jordanian dinar1.00",
3965 "Jordanian dinars1.00",
3979 "Kazakhstani Tenge1.00",
3980 "Kazakhstani tenge1.00",
3981 "Kazakhstani tenges1.00",
3982 "Kenyan Shilling1.00",
3983 "Kenyan shilling1.00",
3984 "Kenyan shillings1.00",
3985 "Kuwaiti Dinar1.00",
3986 "Kuwaiti dinar1.00",
3987 "Kuwaiti dinars1.00",
3988 "Kyrgystani Som1.00",
3989 "Kyrgystani som1.00",
3990 "Kyrgystani soms1.00",
4022 "Latvian Ruble1.00",
4025 "Latvian ruble1.00",
4026 "Latvian rubles1.00",
4027 "Lebanese Pound1.00",
4028 "Lebanese pound1.00",
4029 "Lebanese pounds1.00",
4032 "Lesotho lotis1.00",
4033 "Liberian Dollar1.00",
4034 "Liberian dollar1.00",
4035 "Liberian dollars1.00",
4038 "Libyan dinars1.00",
4039 "Lithuanian Litas1.00",
4040 "Lithuanian Talonas1.00",
4041 "Lithuanian litas1.00",
4042 "Lithuanian litai1.00",
4043 "Lithuanian talonas1.00",
4044 "Lithuanian talonases1.00",
4046 "Luxembourgian Convertible Franc1.00",
4047 "Luxembourg Financial Franc1.00",
4048 "Luxembourgian Franc1.00",
4049 "Luxembourgian convertible franc1.00",
4050 "Luxembourgian convertible francs1.00",
4051 "Luxembourg financial franc1.00",
4052 "Luxembourg financial francs1.00",
4053 "Luxembourgian franc1.00",
4054 "Luxembourgian francs1.00",
4094 "Macanese Pataca1.00",
4095 "Macanese pataca1.00",
4096 "Macanese patacas1.00",
4097 "Macedonian Denar1.00",
4098 "Macedonian denar1.00",
4099 "Macedonian denari1.00",
4100 "Malagasy Ariaries1.00",
4101 "Malagasy Ariary1.00",
4102 "Malagasy Ariary1.00",
4103 "Malagasy Franc1.00",
4104 "Malagasy franc1.00",
4105 "Malagasy francs1.00",
4106 "Malawian Kwacha1.00",
4107 "Malawian Kwacha1.00",
4108 "Malawian Kwachas1.00",
4109 "Malaysian Ringgit1.00",
4110 "Malaysian ringgit1.00",
4111 "Malaysian ringgits1.00",
4112 "Maldivian Rufiyaa1.00",
4113 "Maldivian rufiyaa1.00",
4114 "Maldivian rufiyaas1.00",
4117 "Malian francs1.00",
4119 "Maltese Pound1.00",
4122 "Maltese pound1.00",
4123 "Maltese pounds1.00",
4124 "Mauritanian Ouguiya1.00",
4125 "Mauritanian ouguiya1.00",
4126 "Mauritanian ouguiyas1.00",
4127 "Mauritian Rupee1.00",
4128 "Mauritian rupee1.00",
4129 "Mauritian rupees1.00",
4131 "Mexican Silver Peso (1861-1992)1.00",
4132 "Mexican Investment Unit1.00",
4134 "Mexican pesos1.00",
4135 "Mexican silver peso (1861-1992)1.00",
4136 "Mexican silver pesos (1861-1992)1.00",
4137 "Mexican investment unit1.00",
4138 "Mexican investment units1.00",
4142 "Mongolian Tugrik1.00",
4143 "Mongolian tugrik1.00",
4144 "Mongolian tugriks1.00",
4145 "Moroccan Dirham1.00",
4146 "Moroccan Franc1.00",
4147 "Moroccan dirham1.00",
4148 "Moroccan dirhams1.00",
4149 "Moroccan franc1.00",
4150 "Moroccan francs1.00",
4151 "Mozambican Escudo1.00",
4152 "Mozambican Metical1.00",
4153 "Mozambican escudo1.00",
4154 "Mozambican escudos1.00",
4155 "Mozambican metical1.00",
4156 "Mozambican meticals1.00",
4176 "Namibian Dollar1.00",
4177 "Namibian dollar1.00",
4178 "Namibian dollars1.00",
4179 "Nepalese Rupee1.00",
4180 "Nepalese rupee1.00",
4181 "Nepalese rupees1.00",
4182 "Netherlands Antillean Guilder1.00",
4183 "Netherlands Antillean guilder1.00",
4184 "Netherlands Antillean guilders1.00",
4185 "Dutch Guilder1.00",
4186 "Dutch guilder1.00",
4187 "Dutch guilders1.00",
4188 "Israeli New Sheqel1.00",
4189 "Israeli New Sheqels1.00",
4190 "New Zealand Dollar1.00",
4191 "New Zealand dollar1.00",
4192 "New Zealand dollars1.00",
4193 "Nicaraguan C\\u00f3rdoba1.00",
4194 "Nicaraguan C\\u00f3rdoba (1988-1991)1.00",
4195 "Nicaraguan c\\u00f3rdoba1.00",
4196 "Nicaraguan c\\u00f3rdobas1.00",
4197 "Nicaraguan c\\u00f3rdoba (1988-1991)1.00",
4198 "Nicaraguan c\\u00f3rdobas (1988-1991)1.00",
4199 "Nigerian Naira1.00",
4200 "Nigerian naira1.00",
4201 "Nigerian nairas1.00",
4202 "North Korean Won1.00",
4203 "North Korean won1.00",
4204 "North Korean won1.00",
4205 "Norwegian Krone1.00",
4206 "Norwegian krone1.00",
4207 "Norwegian kroner1.00",
4211 "Mozambican Metical (1980-2006)1.00",
4212 "Mozambican metical (1980-2006)1.00",
4213 "Mozambican meticals (1980-2006)1.00",
4214 "Romanian Lei (1952-2006)1.00",
4215 "Romanian Leu (1952-2006)1.00",
4216 "Romanian leu (1952-2006)1.00",
4217 "Serbian Dinar (2002-2006)1.00",
4218 "Serbian dinar (2002-2006)1.00",
4219 "Serbian dinars (2002-2006)1.00",
4220 "Sudanese Dinar (1992-2007)1.00",
4221 "Sudanese Pound (1957-1998)1.00",
4222 "Sudanese dinar (1992-2007)1.00",
4223 "Sudanese dinars (1992-2007)1.00",
4224 "Sudanese pound (1957-1998)1.00",
4225 "Sudanese pounds (1957-1998)1.00",
4226 "Turkish Lira (1922-2005)1.00",
4227 "Turkish Lira (1922-2005)1.00",
4249 "Pakistani Rupee1.00",
4250 "Pakistani rupee1.00",
4251 "Pakistani rupees1.00",
4254 "Panamanian Balboa1.00",
4255 "Panamanian balboa1.00",
4256 "Panamanian balboas1.00",
4257 "Papua New Guinean Kina1.00",
4258 "Papua New Guinean kina1.00",
4259 "Papua New Guinean kina1.00",
4260 "Paraguayan Guarani1.00",
4261 "Paraguayan guarani1.00",
4262 "Paraguayan guaranis1.00",
4263 "Peruvian Inti1.00",
4264 "Peruvian Nuevo Sol1.00",
4265 "Peruvian Sol (1863-1965)1.00",
4266 "Peruvian inti1.00",
4267 "Peruvian intis1.00",
4268 "Peruvian nuevo sol1.00",
4269 "Peruvian nuevos soles1.00",
4270 "Peruvian sol (1863-1965)1.00",
4271 "Peruvian soles (1863-1965)1.00",
4272 "Philippine Peso1.00",
4273 "Philippine peso1.00",
4274 "Philippine pesos1.00",
4277 "Polish Zloty (1950-1995)1.00",
4279 "Polish zlotys1.00",
4280 "Polish zloty (PLZ)1.00",
4282 "Polish zlotys (PLZ)1.00",
4283 "Portuguese Escudo1.00",
4284 "Portuguese Guinea Escudo1.00",
4285 "Portuguese Guinea escudo1.00",
4286 "Portuguese Guinea escudos1.00",
4287 "Portuguese escudo1.00",
4288 "Portuguese escudos1.00",
4317 "Rhodesian Dollar1.00",
4318 "Rhodesian dollar1.00",
4319 "Rhodesian dollars1.00",
4324 "Russian Ruble (1991-1998)1.00",
4325 "Russian Ruble1.00",
4326 "Russian ruble (1991-1998)1.00",
4327 "Russian ruble1.00",
4328 "Russian rubles (1991-1998)1.00",
4329 "Russian rubles1.00",
4330 "Rwandan Franc1.00",
4331 "Rwandan franc1.00",
4332 "Rwandan francs1.00",
4367 "Saint Helena Pound1.00",
4368 "Saint Helena pound1.00",
4369 "Saint Helena pounds1.00",
4370 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra1.00",
4371 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra1.00",
4372 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras1.00",
4376 "Serbian Dinar1.00",
4377 "Serbian dinar1.00",
4378 "Serbian dinars1.00",
4379 "Seychellois Rupee1.00",
4380 "Seychellois rupee1.00",
4381 "Seychellois rupees1.00",
4384 "Sierra Leonean Leone1.00",
4385 "Sierra Leonean leone1.00",
4386 "Sierra Leonean leones1.00",
4389 "Singapore Dollar1.00",
4390 "Singapore dollar1.00",
4391 "Singapore dollars1.00",
4393 "Slovak Koruna1.00",
4394 "Slovak koruna1.00",
4395 "Slovak korunas1.00",
4396 "Slovenian Tolar1.00",
4397 "Slovenian tolar1.00",
4398 "Slovenian tolars1.00",
4399 "Solomon Islands Dollar1.00",
4400 "Solomon Islands dollar1.00",
4401 "Solomon Islands dollars1.00",
4402 "Somali Shilling1.00",
4403 "Somali shilling1.00",
4404 "Somali shillings1.00",
4405 "South African Rand (financial)1.00",
4406 "South African Rand1.00",
4407 "South African rand (financial)1.00",
4408 "South African rand1.00",
4409 "South African rands (financial)1.00",
4410 "South African rand1.00",
4411 "South Korean Won1.00",
4412 "South Korean won1.00",
4413 "South Korean won1.00",
4414 "Soviet Rouble1.00",
4415 "Soviet rouble1.00",
4416 "Soviet roubles1.00",
4417 "Spanish Peseta (A account)1.00",
4418 "Spanish Peseta (convertible account)1.00",
4419 "Spanish Peseta1.00",
4420 "Spanish peseta (A account)1.00",
4421 "Spanish peseta (convertible account)1.00",
4422 "Spanish peseta1.00",
4423 "Spanish pesetas (A account)1.00",
4424 "Spanish pesetas (convertible account)1.00",
4425 "Spanish pesetas1.00",
4426 "Special Drawing Rights1.00",
4427 "Sri Lankan Rupee1.00",
4428 "Sri Lankan rupee1.00",
4429 "Sri Lankan rupees1.00",
4430 "Sudanese Pound1.00",
4431 "Sudanese pound1.00",
4432 "Sudanese pounds1.00",
4433 "Surinamese Dollar1.00",
4434 "Surinamese dollar1.00",
4435 "Surinamese dollars1.00",
4436 "Surinamese Guilder1.00",
4437 "Surinamese guilder1.00",
4438 "Surinamese guilders1.00",
4439 "Swazi Lilangeni1.00",
4440 "Swazi lilangeni1.00",
4441 "Swazi emalangeni1.00",
4442 "Swedish Krona1.00",
4443 "Swedish krona1.00",
4444 "Swedish kronor1.00",
4450 "Syrian pounds1.00",
4473 "New Taiwan Dollar1.00",
4474 "New Taiwan dollar1.00",
4475 "New Taiwan dollars1.00",
4476 "Tajikistani Ruble1.00",
4477 "Tajikistani Somoni1.00",
4478 "Tajikistani ruble1.00",
4479 "Tajikistani rubles1.00",
4480 "Tajikistani somoni1.00",
4481 "Tajikistani somonis1.00",
4482 "Tanzanian Shilling1.00",
4483 "Tanzanian shilling1.00",
4484 "Tanzanian shillings1.00",
4485 "Testing Currency Code1.00",
4486 "Testing Currency Code1.00",
4490 "Timorese Escudo1.00",
4491 "Timorese escudo1.00",
4492 "Timorese escudos1.00",
4494 "Tongan Pa\\u02bbanga1.00",
4495 "Tongan pa\\u02bbanga1.00",
4496 "Tongan pa\\u02bbanga1.00",
4497 "Trinidad and Tobago Dollar1.00",
4498 "Trinidad and Tobago dollar1.00",
4499 "Trinidad and Tobago dollars1.00",
4500 "Tunisian Dinar1.00",
4501 "Tunisian dinar1.00",
4502 "Tunisian dinars1.00",
4506 "Turkmenistani Manat1.00",
4507 "Turkmenistani manat1.00",
4508 "Turkmenistani manat1.00",
4519 "US Dollar (Next day)1.00",
4520 "US Dollar (Same day)1.00",
4522 "US dollar (next day)1.00",
4523 "US dollar (same day)1.00",
4525 "US dollars (next day)1.00",
4526 "US dollars (same day)1.00",
4540 "Ugandan Shilling (1966-1987)1.00",
4541 "Ugandan Shilling1.00",
4542 "Ugandan shilling (1966-1987)1.00",
4543 "Ugandan shilling1.00",
4544 "Ugandan shillings (1966-1987)1.00",
4545 "Ugandan shillings1.00",
4546 "Ukrainian Hryvnia1.00",
4547 "Ukrainian Karbovanets1.00",
4548 "Ukrainian hryvnia1.00",
4549 "Ukrainian hryvnias1.00",
4550 "Ukrainian karbovanets1.00",
4551 "Ukrainian karbovantsiv1.00",
4552 "Colombian Real Value Unit1.00",
4553 "United Arab Emirates Dirham1.00",
4554 "Unknown Currency1.00",
4556 "Uruguayan Peso (1975-1993)1.00",
4557 "Uruguayan Peso1.00",
4558 "Uruguayan Peso (Indexed Units)1.00",
4559 "Uruguayan peso (1975-1993)1.00",
4560 "Uruguayan peso (indexed units)1.00",
4561 "Uruguayan peso1.00",
4562 "Uruguayan pesos (1975-1993)1.00",
4563 "Uruguayan pesos (indexed units)1.00",
4564 "Uruguayan pesos1.00",
4565 "Uzbekistan Som1.00",
4566 "Uzbekistan som1.00",
4567 "Uzbekistan som1.00",
4575 "Vanuatu vatus1.00",
4576 "Venezuelan Bol\\u00edvar1.00",
4577 "Venezuelan Bol\\u00edvar (1871-2008)1.00",
4578 "Venezuelan bol\\u00edvar1.00",
4579 "Venezuelan bol\\u00edvars1.00",
4580 "Venezuelan bol\\u00edvar (1871-2008)1.00",
4581 "Venezuelan bol\\u00edvars (1871-2008)1.00",
4582 "Vietnamese Dong1.00",
4583 "Vietnamese dong1.00",
4584 "Vietnamese dong1.00",
4644 "Yemeni dinars1.00",
4647 "Yugoslavian Convertible Dinar (1990-1992)1.00",
4648 "Yugoslavian Hard Dinar (1966-1990)1.00",
4649 "Yugoslavian New Dinar (1994-2002)1.00",
4650 "Yugoslavian convertible dinar (1990-1992)1.00",
4651 "Yugoslavian convertible dinars (1990-1992)1.00",
4652 "Yugoslavian hard dinar (1966-1990)1.00",
4653 "Yugoslavian hard dinars (1966-1990)1.00",
4654 "Yugoslavian new dinar (1994-2002)1.00",
4655 "Yugoslavian new dinars (1994-2002)1.00",
4667 "Zairean New Zaire (1993-1998)1.00",
4668 "Zairean Zaire (1971-1993)1.00",
4669 "Zairean new zaire (1993-1998)1.00",
4670 "Zairean new zaires (1993-1998)1.00",
4671 "Zairean zaire (1971-1993)1.00",
4672 "Zairean zaires (1971-1993)1.00",
4673 "Zambian Kwacha1.00",
4674 "Zambian kwacha1.00",
4675 "Zambian kwachas1.00",
4676 "Zimbabwean Dollar (1980-2008)1.00",
4677 "Zimbabwean dollar (1980-2008)1.00",
4678 "Zimbabwean dollars (1980-2008)1.00",
4682 "Turkish lira (1922-2005)1.00",
4683 "special drawing rights1.00",
4684 "Colombian real value unit1.00",
4685 "Colombian real value units1.00",
4686 "unknown/invalid currency1.00",
4706 // Following has extra text, should be parsed correctly too
4709 "1.00 US dollar random",
4710 "1.00 US dollars random",
4711 "1.00 Afghan Afghani random",
4712 "1.00 Afghan Afghani random",
4713 "1.00 Afghan Afghanis (AFA) random",
4714 "1.00 Afghan Afghanis random",
4715 "1.00 Albanian Lek random",
4716 "1.00 Albanian lek random",
4717 "1.00 Albanian lek\\u00eb random",
4718 "1.00 Algerian Dinar random",
4719 "1.00 Algerian dinar random",
4720 "1.00 Algerian dinars random",
4721 "1.00 Andorran Peseta random",
4722 "1.00 Andorran peseta random",
4723 "1.00 Andorran pesetas random",
4724 "1.00 Angolan Kwanza (1977-1990) random",
4725 "1.00 Angolan Readjusted Kwanza (1995-1999) random",
4726 "1.00 Angolan Kwanza random",
4727 "1.00 Angolan New Kwanza (1990-2000) random",
4728 "1.00 Angolan kwanza (1977-1991) random",
4729 "1.00 Angolan readjusted kwanza (1995-1999) random",
4730 "1.00 Angolan kwanza random",
4731 "1.00 Angolan kwanzas (1977-1991) random",
4732 "1.00 Angolan readjusted kwanzas (1995-1999) random",
4733 "1.00 Angolan kwanzas random",
4734 "1.00 Angolan new kwanza (1990-2000) random",
4735 "1.00 Angolan new kwanzas (1990-2000) random",
4736 "1.00 Argentine Austral random",
4737 "1.00 Argentine Peso (1983-1985) random",
4738 "1.00 Argentine Peso random",
4739 "1.00 Argentine austral random",
4740 "1.00 Argentine australs random",
4741 "1.00 Argentine peso (1983-1985) random",
4742 "1.00 Argentine peso random",
4743 "1.00 Argentine pesos (1983-1985) random",
4744 "1.00 Argentine pesos random",
4745 "1.00 Armenian Dram random",
4746 "1.00 Armenian dram random",
4747 "1.00 Armenian drams random",
4748 "1.00 Aruban Florin random",
4749 "1.00 Aruban florin random",
4750 "1.00 Australian Dollar random",
4751 "1.00 Australian dollar random",
4752 "1.00 Australian dollars random",
4753 "1.00 Austrian Schilling random",
4754 "1.00 Austrian schilling random",
4755 "1.00 Austrian schillings random",
4756 "1.00 Azerbaijani Manat (1993-2006) random",
4757 "1.00 Azerbaijani Manat random",
4758 "1.00 Azerbaijani manat (1993-2006) random",
4759 "1.00 Azerbaijani manat random",
4760 "1.00 Azerbaijani manats (1993-2006) random",
4761 "1.00 Azerbaijani manats random",
4762 "1.00 Bahamian Dollar random",
4763 "1.00 Bahamian dollar random",
4764 "1.00 Bahamian dollars random",
4765 "1.00 Bahraini Dinar random",
4766 "1.00 Bahraini dinar random",
4767 "1.00 Bahraini dinars random",
4768 "1.00 Bangladeshi Taka random",
4769 "1.00 Bangladeshi taka random",
4770 "1.00 Bangladeshi takas random",
4771 "1.00 Barbadian Dollar random",
4772 "1.00 Barbadian dollar random",
4773 "1.00 Barbadian dollars random",
4774 "1.00 Belarusian New Ruble (1994-1999) random",
4775 "1.00 Belarusian Ruble random",
4776 "1.00 Belarusian new ruble (1994-1999) random",
4777 "1.00 Belarusian new rubles (1994-1999) random",
4778 "1.00 Belarusian ruble random",
4779 "1.00 Belarusian rubles random",
4780 "1.00 Belgian Franc (convertible) random",
4781 "1.00 Belgian Franc (financial) random",
4782 "1.00 Belgian Franc random",
4783 "1.00 Belgian franc (convertible) random",
4784 "1.00 Belgian franc (financial) random",
4785 "1.00 Belgian franc random",
4786 "1.00 Belgian francs (convertible) random",
4787 "1.00 Belgian francs (financial) random",
4788 "1.00 Belgian francs random",
4789 "1.00 Belize Dollar random",
4790 "1.00 Belize dollar random",
4791 "1.00 Belize dollars random",
4792 "1.00 Bermudan Dollar random",
4793 "1.00 Bermudan dollar random",
4794 "1.00 Bermudan dollars random",
4795 "1.00 Bhutanese Ngultrum random",
4796 "1.00 Bhutanese ngultrum random",
4797 "1.00 Bhutanese ngultrums random",
4798 "1.00 Bolivian Mvdol random",
4799 "1.00 Bolivian Peso random",
4800 "1.00 Bolivian mvdol random",
4801 "1.00 Bolivian mvdols random",
4802 "1.00 Bolivian peso random",
4803 "1.00 Bolivian pesos random",
4804 "1.00 Bolivian Boliviano random",
4805 "1.00 Bolivian Boliviano random",
4806 "1.00 Bolivian Bolivianos random",
4807 "1.00 Bosnia-Herzegovina Convertible Mark random",
4808 "1.00 Bosnia-Herzegovina Dinar (1992-1994) random",
4809 "1.00 Bosnia-Herzegovina convertible mark random",
4810 "1.00 Bosnia-Herzegovina convertible marks random",
4811 "1.00 Bosnia-Herzegovina dinar (1992-1994) random",
4812 "1.00 Bosnia-Herzegovina dinars (1992-1994) random",
4813 "1.00 Botswanan Pula random",
4814 "1.00 Botswanan pula random",
4815 "1.00 Botswanan pulas random",
4816 "1.00 Brazilian New Cruzado (1989-1990) random",
4817 "1.00 Brazilian Cruzado (1986-1989) random",
4818 "1.00 Brazilian Cruzeiro (1990-1993) random",
4819 "1.00 Brazilian New Cruzeiro (1967-1986) random",
4820 "1.00 Brazilian Cruzeiro (1993-1994) random",
4821 "1.00 Brazilian Real random",
4822 "1.00 Brazilian new cruzado (1989-1990) random",
4823 "1.00 Brazilian new cruzados (1989-1990) random",
4824 "1.00 Brazilian cruzado (1986-1989) random",
4825 "1.00 Brazilian cruzados (1986-1989) random",
4826 "1.00 Brazilian cruzeiro (1990-1993) random",
4827 "1.00 Brazilian new cruzeiro (1967-1986) random",
4828 "1.00 Brazilian cruzeiro (1993-1994) random",
4829 "1.00 Brazilian cruzeiros (1990-1993) random",
4830 "1.00 Brazilian new cruzeiros (1967-1986) random",
4831 "1.00 Brazilian cruzeiros (1993-1994) random",
4832 "1.00 Brazilian real random",
4833 "1.00 Brazilian reals random",
4834 "1.00 British Pound Sterling random",
4835 "1.00 British pound sterling random",
4836 "1.00 British pounds sterling random",
4837 "1.00 Brunei Dollar random",
4838 "1.00 Brunei dollar random",
4839 "1.00 Brunei dollars random",
4840 "1.00 Bulgarian Hard Lev random",
4841 "1.00 Bulgarian Lev random",
4842 "1.00 Bulgarian Leva random",
4843 "1.00 Bulgarian hard lev random",
4844 "1.00 Bulgarian hard leva random",
4845 "1.00 Bulgarian lev random",
4846 "1.00 Burmese Kyat random",
4847 "1.00 Burmese kyat random",
4848 "1.00 Burmese kyats random",
4849 "1.00 Burundian Franc random",
4850 "1.00 Burundian franc random",
4851 "1.00 Burundian francs random",
4852 "1.00 Cambodian Riel random",
4853 "1.00 Cambodian riel random",
4854 "1.00 Cambodian riels random",
4855 "1.00 Canadian Dollar random",
4856 "1.00 Canadian dollar random",
4857 "1.00 Canadian dollars random",
4858 "1.00 Cape Verdean Escudo random",
4859 "1.00 Cape Verdean escudo random",
4860 "1.00 Cape Verdean escudos random",
4861 "1.00 Cayman Islands Dollar random",
4862 "1.00 Cayman Islands dollar random",
4863 "1.00 Cayman Islands dollars random",
4864 "1.00 Chilean Peso random",
4865 "1.00 Chilean Unit of Account (UF) random",
4866 "1.00 Chilean peso random",
4867 "1.00 Chilean pesos random",
4868 "1.00 Chilean unit of account (UF) random",
4869 "1.00 Chilean units of account (UF) random",
4870 "1.00 Chinese Yuan random",
4871 "1.00 Chinese yuan random",
4872 "1.00 Colombian Peso random",
4873 "1.00 Colombian peso random",
4874 "1.00 Colombian pesos random",
4875 "1.00 Comorian Franc random",
4876 "1.00 Comorian franc random",
4877 "1.00 Comorian francs random",
4878 "1.00 Congolese Franc Congolais random",
4879 "1.00 Congolese franc Congolais random",
4880 "1.00 Congolese francs Congolais random",
4881 "1.00 Costa Rican Col\\u00f3n random",
4882 "1.00 Costa Rican col\\u00f3n random",
4883 "1.00 Costa Rican col\\u00f3ns random",
4884 "1.00 Croatian Dinar random",
4885 "1.00 Croatian Kuna random",
4886 "1.00 Croatian dinar random",
4887 "1.00 Croatian dinars random",
4888 "1.00 Croatian kuna random",
4889 "1.00 Croatian kunas random",
4890 "1.00 Cuban Peso random",
4891 "1.00 Cuban peso random",
4892 "1.00 Cuban pesos random",
4893 "1.00 Cypriot Pound random",
4894 "1.00 Cypriot pound random",
4895 "1.00 Cypriot pounds random",
4896 "1.00 Czech Republic Koruna random",
4897 "1.00 Czech Republic koruna random",
4898 "1.00 Czech Republic korunas random",
4899 "1.00 Czechoslovak Hard Koruna random",
4900 "1.00 Czechoslovak hard koruna random",
4901 "1.00 Czechoslovak hard korunas random",
4902 "1.00 Danish Krone random",
4903 "1.00 Danish krone random",
4904 "1.00 Danish kroner random",
4905 "1.00 German Mark random",
4906 "1.00 German mark random",
4907 "1.00 German marks random",
4908 "1.00 Djiboutian Franc random",
4909 "1.00 Djiboutian franc random",
4910 "1.00 Djiboutian francs random",
4911 "1.00 Dominican Peso random",
4912 "1.00 Dominican peso random",
4913 "1.00 Dominican pesos random",
4914 "1.00 East Caribbean Dollar random",
4915 "1.00 East Caribbean dollar random",
4916 "1.00 East Caribbean dollars random",
4917 "1.00 East German Mark random",
4918 "1.00 East German mark random",
4919 "1.00 East German marks random",
4920 "1.00 Ecuadorian Sucre random",
4921 "1.00 Ecuadorian Unit of Constant Value random",
4922 "1.00 Ecuadorian sucre random",
4923 "1.00 Ecuadorian sucres random",
4924 "1.00 Ecuadorian unit of constant value random",
4925 "1.00 Ecuadorian units of constant value random",
4926 "1.00 Egyptian Pound random",
4927 "1.00 Egyptian pound random",
4928 "1.00 Egyptian pounds random",
4929 "1.00 Salvadoran Col\\u00f3n random",
4930 "1.00 Salvadoran col\\u00f3n random",
4931 "1.00 Salvadoran colones random",
4932 "1.00 Equatorial Guinean Ekwele random",
4933 "1.00 Equatorial Guinean ekwele random",
4934 "1.00 Eritrean Nakfa random",
4935 "1.00 Eritrean nakfa random",
4936 "1.00 Eritrean nakfas random",
4937 "1.00 Estonian Kroon random",
4938 "1.00 Estonian kroon random",
4939 "1.00 Estonian kroons random",
4940 "1.00 Ethiopian Birr random",
4941 "1.00 Ethiopian birr random",
4942 "1.00 Ethiopian birrs random",
4943 "1.00 European Composite Unit random",
4944 "1.00 European Currency Unit random",
4945 "1.00 European Monetary Unit random",
4946 "1.00 European Unit of Account (XBC) random",
4947 "1.00 European Unit of Account (XBD) random",
4948 "1.00 European composite unit random",
4949 "1.00 European composite units random",
4950 "1.00 European currency unit random",
4951 "1.00 European currency units random",
4952 "1.00 European monetary unit random",
4953 "1.00 European monetary units random",
4954 "1.00 European unit of account (XBC) random",
4955 "1.00 European unit of account (XBD) random",
4956 "1.00 European units of account (XBC) random",
4957 "1.00 European units of account (XBD) random",
4958 "1.00 Falkland Islands Pound random",
4959 "1.00 Falkland Islands pound random",
4960 "1.00 Falkland Islands pounds random",
4961 "1.00 Fijian Dollar random",
4962 "1.00 Fijian dollar random",
4963 "1.00 Fijian dollars random",
4964 "1.00 Finnish Markka random",
4965 "1.00 Finnish markka random",
4966 "1.00 Finnish markkas random",
4967 "1.00 French Franc random",
4968 "1.00 French Gold Franc random",
4969 "1.00 French UIC-Franc random",
4970 "1.00 French UIC-franc random",
4971 "1.00 French UIC-francs random",
4972 "1.00 French franc random",
4973 "1.00 French francs random",
4974 "1.00 French gold franc random",
4975 "1.00 French gold francs random",
4976 "1.00 Gambian Dalasi random",
4977 "1.00 Gambian dalasi random",
4978 "1.00 Gambian dalasis random",
4979 "1.00 Georgian Kupon Larit random",
4980 "1.00 Georgian Lari random",
4981 "1.00 Georgian kupon larit random",
4982 "1.00 Georgian kupon larits random",
4983 "1.00 Georgian lari random",
4984 "1.00 Georgian laris random",
4985 "1.00 Ghanaian Cedi (1979-2007) random",
4986 "1.00 Ghanaian Cedi random",
4987 "1.00 Ghanaian cedi (1979-2007) random",
4988 "1.00 Ghanaian cedi random",
4989 "1.00 Ghanaian cedis (1979-2007) random",
4990 "1.00 Ghanaian cedis random",
4991 "1.00 Gibraltar Pound random",
4992 "1.00 Gibraltar pound random",
4993 "1.00 Gibraltar pounds random",
4996 "1.00 Greek Drachma random",
4997 "1.00 Greek drachma random",
4998 "1.00 Greek drachmas random",
4999 "1.00 Guatemalan Quetzal random",
5000 "1.00 Guatemalan quetzal random",
5001 "1.00 Guatemalan quetzals random",
5002 "1.00 Guinean Franc random",
5003 "1.00 Guinean Syli random",
5004 "1.00 Guinean franc random",
5005 "1.00 Guinean francs random",
5006 "1.00 Guinean syli random",
5007 "1.00 Guinean sylis random",
5008 "1.00 Guinea-Bissau Peso random",
5009 "1.00 Guinea-Bissau peso random",
5010 "1.00 Guinea-Bissau pesos random",
5011 "1.00 Guyanaese Dollar random",
5012 "1.00 Guyanaese dollar random",
5013 "1.00 Guyanaese dollars random",
5014 "1.00 Haitian Gourde random",
5015 "1.00 Haitian gourde random",
5016 "1.00 Haitian gourdes random",
5017 "1.00 Honduran Lempira random",
5018 "1.00 Honduran lempira random",
5019 "1.00 Honduran lempiras random",
5020 "1.00 Hong Kong Dollar random",
5021 "1.00 Hong Kong dollar random",
5022 "1.00 Hong Kong dollars random",
5023 "1.00 Hungarian Forint random",
5024 "1.00 Hungarian forint random",
5025 "1.00 Hungarian forints random",
5026 "1.00 Icelandic Kr\\u00f3na random",
5027 "1.00 Icelandic kr\\u00f3na random",
5028 "1.00 Icelandic kr\\u00f3nur random",
5029 "1.00 Indian Rupee random",
5030 "1.00 Indian rupee random",
5031 "1.00 Indian rupees random",
5032 "1.00 Indonesian Rupiah random",
5033 "1.00 Indonesian rupiah random",
5034 "1.00 Indonesian rupiahs random",
5035 "1.00 Iranian Rial random",
5036 "1.00 Iranian rial random",
5037 "1.00 Iranian rials random",
5038 "1.00 Iraqi Dinar random",
5039 "1.00 Iraqi dinar random",
5040 "1.00 Iraqi dinars random",
5041 "1.00 Irish Pound random",
5042 "1.00 Irish pound random",
5043 "1.00 Irish pounds random",
5044 "1.00 Israeli Pound random",
5045 "1.00 Israeli new sheqel random",
5046 "1.00 Israeli pound random",
5047 "1.00 Israeli pounds random",
5048 "1.00 Italian Lira random",
5049 "1.00 Italian lira random",
5050 "1.00 Italian liras random",
5051 "1.00 Jamaican Dollar random",
5052 "1.00 Jamaican dollar random",
5053 "1.00 Jamaican dollars random",
5054 "1.00 Japanese Yen random",
5055 "1.00 Japanese yen random",
5056 "1.00 Jordanian Dinar random",
5057 "1.00 Jordanian dinar random",
5058 "1.00 Jordanian dinars random",
5059 "1.00 Kazakhstani Tenge random",
5060 "1.00 Kazakhstani tenge random",
5061 "1.00 Kazakhstani tenges random",
5062 "1.00 Kenyan Shilling random",
5063 "1.00 Kenyan shilling random",
5064 "1.00 Kenyan shillings random",
5065 "1.00 Kuwaiti Dinar random",
5066 "1.00 Kuwaiti dinar random",
5067 "1.00 Kuwaiti dinars random",
5068 "1.00 Kyrgystani Som random",
5069 "1.00 Kyrgystani som random",
5070 "1.00 Kyrgystani soms random",
5071 "1.00 Laotian Kip random",
5072 "1.00 Laotian kip random",
5073 "1.00 Laotian kips random",
5074 "1.00 Latvian Lats random",
5075 "1.00 Latvian Ruble random",
5076 "1.00 Latvian lats random",
5077 "1.00 Latvian lati random",
5078 "1.00 Latvian ruble random",
5079 "1.00 Latvian rubles random",
5080 "1.00 Lebanese Pound random",
5081 "1.00 Lebanese pound random",
5082 "1.00 Lebanese pounds random",
5083 "1.00 Lesotho Loti random",
5084 "1.00 Lesotho loti random",
5085 "1.00 Lesotho lotis random",
5086 "1.00 Liberian Dollar random",
5087 "1.00 Liberian dollar random",
5088 "1.00 Liberian dollars random",
5089 "1.00 Libyan Dinar random",
5090 "1.00 Libyan dinar random",
5091 "1.00 Libyan dinars random",
5092 "1.00 Lithuanian Litas random",
5093 "1.00 Lithuanian Talonas random",
5094 "1.00 Lithuanian litas random",
5095 "1.00 Lithuanian litai random",
5096 "1.00 Lithuanian talonas random",
5097 "1.00 Lithuanian talonases random",
5098 "1.00 Luxembourgian Convertible Franc random",
5099 "1.00 Luxembourg Financial Franc random",
5100 "1.00 Luxembourgian Franc random",
5101 "1.00 Luxembourgian convertible franc random",
5102 "1.00 Luxembourgian convertible francs random",
5103 "1.00 Luxembourg financial franc random",
5104 "1.00 Luxembourg financial francs random",
5105 "1.00 Luxembourgian franc random",
5106 "1.00 Luxembourgian francs random",
5107 "1.00 Macanese Pataca random",
5108 "1.00 Macanese pataca random",
5109 "1.00 Macanese patacas random",
5110 "1.00 Macedonian Denar random",
5111 "1.00 Macedonian denar random",
5112 "1.00 Macedonian denari random",
5113 "1.00 Malagasy Ariaries random",
5114 "1.00 Malagasy Ariary random",
5115 "1.00 Malagasy Ariary random",
5116 "1.00 Malagasy Franc random",
5117 "1.00 Malagasy franc random",
5118 "1.00 Malagasy francs random",
5119 "1.00 Malawian Kwacha random",
5120 "1.00 Malawian Kwacha random",
5121 "1.00 Malawian Kwachas random",
5122 "1.00 Malaysian Ringgit random",
5123 "1.00 Malaysian ringgit random",
5124 "1.00 Malaysian ringgits random",
5125 "1.00 Maldivian Rufiyaa random",
5126 "1.00 Maldivian rufiyaa random",
5127 "1.00 Maldivian rufiyaas random",
5128 "1.00 Malian Franc random",
5129 "1.00 Malian franc random",
5130 "1.00 Malian francs random",
5131 "1.00 Maltese Lira random",
5132 "1.00 Maltese Pound random",
5133 "1.00 Maltese lira random",
5134 "1.00 Maltese liras random",
5135 "1.00 Maltese pound random",
5136 "1.00 Maltese pounds random",
5137 "1.00 Mauritanian Ouguiya random",
5138 "1.00 Mauritanian ouguiya random",
5139 "1.00 Mauritanian ouguiyas random",
5140 "1.00 Mauritian Rupee random",
5141 "1.00 Mauritian rupee random",
5142 "1.00 Mauritian rupees random",
5143 "1.00 Mexican Peso random",
5144 "1.00 Mexican Silver Peso (1861-1992) random",
5145 "1.00 Mexican Investment Unit random",
5146 "1.00 Mexican peso random",
5147 "1.00 Mexican pesos random",
5148 "1.00 Mexican silver peso (1861-1992) random",
5149 "1.00 Mexican silver pesos (1861-1992) random",
5150 "1.00 Mexican investment unit random",
5151 "1.00 Mexican investment units random",
5152 "1.00 Moldovan Leu random",
5153 "1.00 Moldovan leu random",
5154 "1.00 Moldovan lei random",
5155 "1.00 Mongolian Tugrik random",
5156 "1.00 Mongolian tugrik random",
5157 "1.00 Mongolian tugriks random",
5158 "1.00 Moroccan Dirham random",
5159 "1.00 Moroccan Franc random",
5160 "1.00 Moroccan dirham random",
5161 "1.00 Moroccan dirhams random",
5162 "1.00 Moroccan franc random",
5163 "1.00 Moroccan francs random",
5164 "1.00 Mozambican Escudo random",
5165 "1.00 Mozambican Metical random",
5166 "1.00 Mozambican escudo random",
5167 "1.00 Mozambican escudos random",
5168 "1.00 Mozambican metical random",
5169 "1.00 Mozambican meticals random",
5170 "1.00 Myanma Kyat random",
5171 "1.00 Myanma kyat random",
5172 "1.00 Myanma kyats random",
5173 "1.00 Namibian Dollar random",
5174 "1.00 Namibian dollar random",
5175 "1.00 Namibian dollars random",
5176 "1.00 Nepalese Rupee random",
5177 "1.00 Nepalese rupee random",
5178 "1.00 Nepalese rupees random",
5179 "1.00 Netherlands Antillean Guilder random",
5180 "1.00 Netherlands Antillean guilder random",
5181 "1.00 Netherlands Antillean guilders random",
5182 "1.00 Dutch Guilder random",
5183 "1.00 Dutch guilder random",
5184 "1.00 Dutch guilders random",
5185 "1.00 Israeli New Sheqel random",
5186 "1.00 Israeli new sheqels random",
5187 "1.00 New Zealand Dollar random",
5188 "1.00 New Zealand dollar random",
5189 "1.00 New Zealand dollars random",
5190 "1.00 Nicaraguan C\\u00f3rdoba random",
5191 "1.00 Nicaraguan C\\u00f3rdoba (1988-1991) random",
5192 "1.00 Nicaraguan c\\u00f3rdoba random",
5193 "1.00 Nicaraguan c\\u00f3rdoba random",
5194 "1.00 Nicaraguan c\\u00f3rdoba (1988-1991) random",
5195 "1.00 Nicaraguan c\\u00f3rdobas (1988-1991) random",
5196 "1.00 Nigerian Naira random",
5197 "1.00 Nigerian naira random",
5198 "1.00 Nigerian nairas random",
5199 "1.00 North Korean Won random",
5200 "1.00 North Korean won random",
5201 "1.00 North Korean won random",
5202 "1.00 Norwegian Krone random",
5203 "1.00 Norwegian krone random",
5204 "1.00 Norwegian kroner random",
5205 "1.00 Mozambican Metical (1980-2006) random",
5206 "1.00 Mozambican metical (1980-2006) random",
5207 "1.00 Mozambican meticals (1980-2006) random",
5208 "1.00 Romanian Lei (1952-2006) random",
5209 "1.00 Romanian Leu (1952-2006) random",
5210 "1.00 Romanian leu (1952-2006) random",
5211 "1.00 Serbian Dinar (2002-2006) random",
5212 "1.00 Serbian dinar (2002-2006) random",
5213 "1.00 Serbian dinars (2002-2006) random",
5214 "1.00 Sudanese Dinar (1992-2007) random",
5215 "1.00 Sudanese Pound (1957-1998) random",
5216 "1.00 Sudanese dinar (1992-2007) random",
5217 "1.00 Sudanese dinars (1992-2007) random",
5218 "1.00 Sudanese pound (1957-1998) random",
5219 "1.00 Sudanese pounds (1957-1998) random",
5220 "1.00 Turkish Lira (1922-2005) random",
5221 "1.00 Turkish Lira (1922-2005) random",
5222 "1.00 Omani Rial random",
5223 "1.00 Omani rial random",
5224 "1.00 Omani rials random",
5225 "1.00 Pakistani Rupee random",
5226 "1.00 Pakistani rupee random",
5227 "1.00 Pakistani rupees random",
5228 "1.00 Palladium random",
5229 "1.00 Palladium random",
5230 "1.00 Panamanian Balboa random",
5231 "1.00 Panamanian balboa random",
5232 "1.00 Panamanian balboas random",
5233 "1.00 Papua New Guinean Kina random",
5234 "1.00 Papua New Guinean kina random",
5235 "1.00 Papua New Guinean kina random",
5236 "1.00 Paraguayan Guarani random",
5237 "1.00 Paraguayan guarani random",
5238 "1.00 Paraguayan guaranis random",
5239 "1.00 Peruvian Inti random",
5240 "1.00 Peruvian Nuevo Sol random",
5241 "1.00 Peruvian Sol (1863-1965) random",
5242 "1.00 Peruvian inti random",
5243 "1.00 Peruvian intis random",
5244 "1.00 Peruvian nuevo sol random",
5245 "1.00 Peruvian nuevos soles random",
5246 "1.00 Peruvian sol (1863-1965) random",
5247 "1.00 Peruvian soles (1863-1965) random",
5248 "1.00 Philippine Peso random",
5249 "1.00 Philippine peso random",
5250 "1.00 Philippine pesos random",
5251 "1.00 Platinum random",
5252 "1.00 Platinum random",
5253 "1.00 Polish Zloty (1950-1995) random",
5254 "1.00 Polish Zloty random",
5255 "1.00 Polish zlotys random",
5256 "1.00 Polish zloty (PLZ) random",
5257 "1.00 Polish zloty random",
5258 "1.00 Polish zlotys (PLZ) random",
5259 "1.00 Portuguese Escudo random",
5260 "1.00 Portuguese Guinea Escudo random",
5261 "1.00 Portuguese Guinea escudo random",
5262 "1.00 Portuguese Guinea escudos random",
5263 "1.00 Portuguese escudo random",
5264 "1.00 Portuguese escudos random",
5265 "1.00 Qatari Rial random",
5266 "1.00 Qatari rial random",
5267 "1.00 Qatari rials random",
5268 "1.00 RINET Funds random",
5269 "1.00 RINET Funds random",
5270 "1.00 Rhodesian Dollar random",
5271 "1.00 Rhodesian dollar random",
5272 "1.00 Rhodesian dollars random",
5273 "1.00 Romanian Leu random",
5274 "1.00 Romanian lei random",
5275 "1.00 Romanian leu random",
5276 "1.00 Russian Ruble (1991-1998) random",
5277 "1.00 Russian Ruble random",
5278 "1.00 Russian ruble (1991-1998) random",
5279 "1.00 Russian ruble random",
5280 "1.00 Russian rubles (1991-1998) random",
5281 "1.00 Russian rubles random",
5282 "1.00 Rwandan Franc random",
5283 "1.00 Rwandan franc random",
5284 "1.00 Rwandan francs random",
5285 "1.00 Saint Helena Pound random",
5286 "1.00 Saint Helena pound random",
5287 "1.00 Saint Helena pounds random",
5288 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra random",
5289 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra random",
5290 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras random",
5291 "1.00 Saudi Riyal random",
5292 "1.00 Saudi riyal random",
5293 "1.00 Saudi riyals random",
5294 "1.00 Serbian Dinar random",
5295 "1.00 Serbian dinar random",
5296 "1.00 Serbian dinars random",
5297 "1.00 Seychellois Rupee random",
5298 "1.00 Seychellois rupee random",
5299 "1.00 Seychellois rupees random",
5300 "1.00 Sierra Leonean Leone random",
5301 "1.00 Sierra Leonean leone random",
5302 "1.00 Sierra Leonean leones random",
5303 "1.00 Singapore Dollar random",
5304 "1.00 Singapore dollar random",
5305 "1.00 Singapore dollars random",
5306 "1.00 Slovak Koruna random",
5307 "1.00 Slovak koruna random",
5308 "1.00 Slovak korunas random",
5309 "1.00 Slovenian Tolar random",
5310 "1.00 Slovenian tolar random",
5311 "1.00 Slovenian tolars random",
5312 "1.00 Solomon Islands Dollar random",
5313 "1.00 Solomon Islands dollar random",
5314 "1.00 Solomon Islands dollars random",
5315 "1.00 Somali Shilling random",
5316 "1.00 Somali shilling random",
5317 "1.00 Somali shillings random",
5318 "1.00 South African Rand (financial) random",
5319 "1.00 South African Rand random",
5320 "1.00 South African rand (financial) random",
5321 "1.00 South African rand random",
5322 "1.00 South African rands (financial) random",
5323 "1.00 South African rand random",
5324 "1.00 South Korean Won random",
5325 "1.00 South Korean won random",
5326 "1.00 South Korean won random",
5327 "1.00 Soviet Rouble random",
5328 "1.00 Soviet rouble random",
5329 "1.00 Soviet roubles random",
5330 "1.00 Spanish Peseta (A account) random",
5331 "1.00 Spanish Peseta (convertible account) random",
5332 "1.00 Spanish Peseta random",
5333 "1.00 Spanish peseta (A account) random",
5334 "1.00 Spanish peseta (convertible account) random",
5335 "1.00 Spanish peseta random",
5336 "1.00 Spanish pesetas (A account) random",
5337 "1.00 Spanish pesetas (convertible account) random",
5338 "1.00 Spanish pesetas random",
5339 "1.00 Special Drawing Rights random",
5340 "1.00 Sri Lankan Rupee random",
5341 "1.00 Sri Lankan rupee random",
5342 "1.00 Sri Lankan rupees random",
5343 "1.00 Sudanese Pound random",
5344 "1.00 Sudanese pound random",
5345 "1.00 Sudanese pounds random",
5346 "1.00 Surinamese Dollar random",
5347 "1.00 Surinamese dollar random",
5348 "1.00 Surinamese dollars random",
5349 "1.00 Surinamese Guilder random",
5350 "1.00 Surinamese guilder random",
5351 "1.00 Surinamese guilders random",
5352 "1.00 Swazi Lilangeni random",
5353 "1.00 Swazi lilangeni random",
5354 "1.00 Swazi emalangeni random",
5355 "1.00 Swedish Krona random",
5356 "1.00 Swedish krona random",
5357 "1.00 Swedish kronor random",
5358 "1.00 Swiss Franc random",
5359 "1.00 Swiss franc random",
5360 "1.00 Swiss francs random",
5361 "1.00 Syrian Pound random",
5362 "1.00 Syrian pound random",
5363 "1.00 Syrian pounds random",
5364 "1.00 New Taiwan Dollar random",
5365 "1.00 New Taiwan dollar random",
5366 "1.00 New Taiwan dollars random",
5367 "1.00 Tajikistani Ruble random",
5368 "1.00 Tajikistani Somoni random",
5369 "1.00 Tajikistani ruble random",
5370 "1.00 Tajikistani rubles random",
5371 "1.00 Tajikistani somoni random",
5372 "1.00 Tajikistani somonis random",
5373 "1.00 Tanzanian Shilling random",
5374 "1.00 Tanzanian shilling random",
5375 "1.00 Tanzanian shillings random",
5376 "1.00 Testing Currency Code random",
5377 "1.00 Testing Currency Code random",
5378 "1.00 Thai Baht random",
5379 "1.00 Thai baht random",
5380 "1.00 Thai baht random",
5381 "1.00 Timorese Escudo random",
5382 "1.00 Timorese escudo random",
5383 "1.00 Timorese escudos random",
5384 "1.00 Trinidad and Tobago Dollar random",
5385 "1.00 Trinidad and Tobago dollar random",
5386 "1.00 Trinidad and Tobago dollars random",
5387 "1.00 Tunisian Dinar random",
5388 "1.00 Tunisian dinar random",
5389 "1.00 Tunisian dinars random",
5390 "1.00 Turkish Lira random",
5391 "1.00 Turkish Lira random",
5392 "1.00 Turkish lira random",
5393 "1.00 Turkmenistani Manat random",
5394 "1.00 Turkmenistani manat random",
5395 "1.00 Turkmenistani manat random",
5396 "1.00 US Dollar (Next day) random",
5397 "1.00 US Dollar (Same day) random",
5398 "1.00 US Dollar random",
5399 "1.00 US dollar (next day) random",
5400 "1.00 US dollar (same day) random",
5401 "1.00 US dollar random",
5402 "1.00 US dollars (next day) random",
5403 "1.00 US dollars (same day) random",
5404 "1.00 US dollars random",
5405 "1.00 Ugandan Shilling (1966-1987) random",
5406 "1.00 Ugandan Shilling random",
5407 "1.00 Ugandan shilling (1966-1987) random",
5408 "1.00 Ugandan shilling random",
5409 "1.00 Ugandan shillings (1966-1987) random",
5410 "1.00 Ugandan shillings random",
5411 "1.00 Ukrainian Hryvnia random",
5412 "1.00 Ukrainian Karbovanets random",
5413 "1.00 Ukrainian hryvnia random",
5414 "1.00 Ukrainian hryvnias random",
5415 "1.00 Ukrainian karbovanets random",
5416 "1.00 Ukrainian karbovantsiv random",
5417 "1.00 Colombian Real Value Unit random",
5418 "1.00 United Arab Emirates Dirham random",
5419 "1.00 Unknown Currency random",
5420 "1.00 Uruguayan Peso (1975-1993) random",
5421 "1.00 Uruguayan Peso random",
5422 "1.00 Uruguayan Peso (Indexed Units) random",
5423 "1.00 Uruguayan peso (1975-1993) random",
5424 "1.00 Uruguayan peso (indexed units) random",
5425 "1.00 Uruguayan peso random",
5426 "1.00 Uruguayan pesos (1975-1993) random",
5427 "1.00 Uruguayan pesos (indexed units) random",
5428 "1.00 Uzbekistan Som random",
5429 "1.00 Uzbekistan som random",
5430 "1.00 Uzbekistan som random",
5431 "1.00 Vanuatu Vatu random",
5432 "1.00 Vanuatu vatu random",
5433 "1.00 Vanuatu vatus random",
5434 "1.00 Venezuelan Bol\\u00edvar random",
5435 "1.00 Venezuelan Bol\\u00edvar (1871-2008) random",
5436 "1.00 Venezuelan bol\\u00edvar random",
5437 "1.00 Venezuelan bol\\u00edvars random",
5438 "1.00 Venezuelan bol\\u00edvar (1871-2008) random",
5439 "1.00 Venezuelan bol\\u00edvars (1871-2008) random",
5440 "1.00 Vietnamese Dong random",
5441 "1.00 Vietnamese dong random",
5442 "1.00 Vietnamese dong random",
5443 "1.00 WIR Euro random",
5444 "1.00 WIR Franc random",
5445 "1.00 WIR euro random",
5446 "1.00 WIR euros random",
5447 "1.00 WIR franc random",
5448 "1.00 WIR francs random",
5449 "1.00 Samoan Tala random",
5450 "1.00 Samoan tala random",
5451 "1.00 Samoan tala random",
5452 "1.00 Yemeni Dinar random",
5453 "1.00 Yemeni Rial random",
5454 "1.00 Yemeni dinar random",
5455 "1.00 Yemeni dinars random",
5456 "1.00 Yemeni rial random",
5457 "1.00 Yemeni rials random",
5458 "1.00 Yugoslavian Convertible Dinar (1990-1992) random",
5459 "1.00 Yugoslavian Hard Dinar (1966-1990) random",
5460 "1.00 Yugoslavian New Dinar (1994-2002) random",
5461 "1.00 Yugoslavian convertible dinar (1990-1992) random",
5462 "1.00 Yugoslavian convertible dinars (1990-1992) random",
5463 "1.00 Yugoslavian hard dinar (1966-1990) random",
5464 "1.00 Yugoslavian hard dinars (1966-1990) random",
5465 "1.00 Yugoslavian new dinar (1994-2002) random",
5466 "1.00 Yugoslavian new dinars (1994-2002) random",
5467 "1.00 Zairean New Zaire (1993-1998) random",
5468 "1.00 Zairean Zaire (1971-1993) random",
5469 "1.00 Zairean new zaire (1993-1998) random",
5470 "1.00 Zairean new zaires (1993-1998) random",
5471 "1.00 Zairean zaire (1971-1993) random",
5472 "1.00 Zairean zaires (1971-1993) random",
5473 "1.00 Zambian Kwacha random",
5474 "1.00 Zambian kwacha random",
5475 "1.00 Zambian kwachas random",
5476 "1.00 Zimbabwean Dollar (1980-2008) random",
5477 "1.00 Zimbabwean dollar (1980-2008) random",
5478 "1.00 Zimbabwean dollars (1980-2008) random",
5480 "1.00 euros random",
5481 "1.00 Turkish lira (1922-2005) random",
5482 "1.00 special drawing rights random",
5483 "1.00 Colombian real value unit random",
5484 "1.00 Colombian real value units random",
5485 "1.00 unknown/invalid currency random",
5488 const char* WRONG_DATA
[] = {
5489 // Following are missing one last char in the currency name
5490 "usd1.00", // case sensitive
5491 "1.00 Nicaraguan Cordob",
5492 "1.00 Namibian Dolla",
5493 "1.00 Namibian dolla",
5494 "1.00 Nepalese Rupe",
5495 "1.00 Nepalese rupe",
5496 "1.00 Netherlands Antillean Guilde",
5497 "1.00 Netherlands Antillean guilde",
5498 "1.00 Dutch Guilde",
5499 "1.00 Dutch guilde",
5500 "1.00 Israeli New Sheqe",
5501 "1.00 New Zealand Dolla",
5502 "1.00 New Zealand dolla",
5503 "1.00 Nicaraguan cordob",
5504 "1.00 Nigerian Nair",
5505 "1.00 Nigerian nair",
5506 "1.00 North Korean Wo",
5507 "1.00 North Korean wo",
5508 "1.00 Norwegian Kron",
5509 "1.00 Norwegian kron",
5525 "Afghan Afghan1.00",
5526 "Afghan Afghani (1927-20021.00",
5529 "Algerian Dina1.00",
5530 "Andorran Peset1.00",
5531 "Angolan Kwanz1.00",
5532 "Angolan Kwanza (1977-19901.00",
5533 "Angolan Readjusted Kwanza (1995-19991.00",
5534 "Angolan New Kwanza (1990-20001.00",
5535 "Argentine Austra1.00",
5536 "Argentine Pes1.00",
5537 "Argentine Peso (1983-19851.00",
5540 "Australian Dolla1.00",
5541 "Austrian Schillin1.00",
5542 "Azerbaijani Mana1.00",
5543 "Azerbaijani Manat (1993-20061.00",
5561 "Bahamian Dolla1.00",
5562 "Bahraini Dina1.00",
5563 "Bangladeshi Tak1.00",
5564 "Barbadian Dolla1.00",
5566 "Belarusian New Ruble (1994-19991.00",
5567 "Belarusian Rubl1.00",
5569 "Belgian Franc (convertible1.00",
5570 "Belgian Franc (financial1.00",
5572 "Bermudan Dolla1.00",
5573 "Bhutanese Ngultru1.00",
5574 "Bolivian Mvdo1.00",
5576 "Bolivian Bolivian1.00",
5577 "Bosnia-Herzegovina Convertible Mar1.00",
5578 "Bosnia-Herzegovina Dina1.00",
5579 "Botswanan Pul1.00",
5580 "Brazilian Cruzad1.00",
5581 "Brazilian Cruzado Nov1.00",
5582 "Brazilian Cruzeir1.00",
5583 "Brazilian Cruzeiro (1990-19931.00",
5584 "Brazilian New Cruzeiro (1967-19861.00",
5585 "Brazilian Rea1.00",
5586 "British Pound Sterlin1.00",
5588 "Bulgarian Hard Le1.00",
5591 "Burundian Fran1.00",
5595 "CFA Franc BCEA1.00",
5596 "CFA Franc BEA1.00",
5608 "Cambodian Rie1.00",
5609 "Canadian Dolla1.00",
5610 "Cape Verdean Escud1.00",
5611 "Cayman Islands Dolla1.00",
5613 "Chilean Unit of Accoun1.00",
5615 "Colombian Pes1.00",
5617 "Congolese Fran1.00",
5618 "Costa Rican Col\\u00f31.00",
5619 "Croatian Dina1.00",
5623 "Czech Republic Korun1.00",
5624 "Czechoslovak Hard Korun1.00",
5634 "Djiboutian Fran1.00",
5636 "Dominican Pes1.00",
5645 "East Caribbean Dolla1.00",
5646 "East German Ostmar1.00",
5647 "Ecuadorian Sucr1.00",
5648 "Ecuadorian Unit of Constant Valu1.00",
5649 "Egyptian Poun1.00",
5651 "Salvadoran Col\\u00f31.00",
5652 "Equatorial Guinean Ekwel1.00",
5653 "Eritrean Nakf1.00",
5655 "Estonian Kroo1.00",
5656 "Ethiopian Bir1.00",
5658 "European Composite Uni1.00",
5659 "European Currency Uni1.00",
5660 "European Monetary Uni1.00",
5661 "European Unit of Account (XBC1.00",
5662 "European Unit of Account (XBD1.00",
5669 "Falkland Islands Poun1.00",
5672 "Finnish Markk1.00",
5675 "French Gold Fran1.00",
5676 "French UIC-Fran1.00",
5689 "Gambian Dalas1.00",
5690 "Georgian Kupon Lari1.00",
5693 "Ghanaian Cedi (1979-20071.00",
5694 "Gibraltar Poun1.00",
5697 "Guatemalan Quetza1.00",
5700 "Guinea-Bissau Pes1.00",
5701 "Guyanaese Dolla1.00",
5707 "Haitian Gourd1.00",
5708 "Honduran Lempir1.00",
5709 "Hong Kong Dolla1.00",
5710 "Hungarian Forin1.00",
5719 "Icelandic Kron1.00",
5721 "Indonesian Rupia1.00",
5731 "Jamaican Dolla1.00",
5733 "Jordanian Dina1.00",
5744 "Kazakhstani Teng1.00",
5745 "Kenyan Shillin1.00",
5747 "Kyrgystani So1.00",
5759 "Lebanese Poun1.00",
5761 "Liberian Dolla1.00",
5763 "Lithuanian Lit1.00",
5764 "Lithuanian Talona1.00",
5765 "Luxembourgian Convertible Fran1.00",
5766 "Luxembourg Financial Fran1.00",
5767 "Luxembourgian Fran1.00",
5785 "Macanese Patac1.00",
5786 "Macedonian Dena1.00",
5787 "Malagasy Ariar1.00",
5788 "Malagasy Fran1.00",
5789 "Malawian Kwach1.00",
5790 "Malaysian Ringgi1.00",
5791 "Maldivian Rufiya1.00",
5796 "Mauritanian Ouguiy1.00",
5797 "Mauritian Rupe1.00",
5799 "Mexican Silver Peso (1861-19921.00",
5800 "Mexican Investment Uni1.00",
5802 "Mongolian Tugri1.00",
5803 "Moroccan Dirha1.00",
5804 "Moroccan Fran1.00",
5805 "Mozambican Escud1.00",
5806 "Mozambican Metica1.00",
5818 "Namibian Dolla1.00",
5819 "Nepalese Rupe1.00",
5820 "Netherlands Antillean Guilde1.00",
5822 "Israeli New Sheqe1.00",
5823 "New Zealand Dolla1.00",
5824 "Nicaraguan C\\u00f3rdoba (1988-19911.00",
5825 "Nicaraguan C\\u00f3rdob1.00",
5826 "Nigerian Nair1.00",
5827 "North Korean Wo1.00",
5828 "Norwegian Kron1.00",
5831 "Old Mozambican Metica1.00",
5832 "Romanian Leu (1952-20061.00",
5833 "Serbian Dinar (2002-20061.00",
5834 "Sudanese Dinar (1992-20071.00",
5835 "Sudanese Pound (1957-19981.00",
5836 "Turkish Lira (1922-20051.00",
5846 "Pakistani Rupe1.00",
5848 "Panamanian Balbo1.00",
5849 "Papua New Guinean Kin1.00",
5850 "Paraguayan Guaran1.00",
5852 "Peruvian Sol (1863-19651.00",
5853 "Peruvian Sol Nuev1.00",
5854 "Philippine Pes1.00",
5857 "Polish Zloty (1950-19951.00",
5858 "Portuguese Escud1.00",
5859 "Portuguese Guinea Escud1.00",
5870 "Rhodesian Dolla1.00",
5873 "Russian Ruble (1991-19981.00",
5893 "Saint Helena Poun1.00",
5894 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobr1.00",
5897 "Seychellois Rupe1.00",
5899 "Sierra Leonean Leon1.00",
5901 "Singapore Dolla1.00",
5903 "Slovenian Tola1.00",
5904 "Solomon Islands Dolla1.00",
5905 "Somali Shillin1.00",
5906 "South African Ran1.00",
5907 "South African Rand (financial1.00",
5908 "South Korean Wo1.00",
5910 "Spanish Peset1.00",
5911 "Spanish Peseta (A account1.00",
5912 "Spanish Peseta (convertible account1.00",
5913 "Special Drawing Right1.00",
5914 "Sri Lankan Rupe1.00",
5915 "Sudanese Poun1.00",
5916 "Surinamese Dolla1.00",
5917 "Surinamese Guilde1.00",
5918 "Swazi Lilangen1.00",
5933 "New Taiwan Dolla1.00",
5934 "Tajikistani Rubl1.00",
5935 "Tajikistani Somon1.00",
5936 "Tanzanian Shillin1.00",
5937 "Testing Currency Cod1.00",
5939 "Timorese Escud1.00",
5940 "Tongan Pa\\u20bbang1.00",
5941 "Trinidad and Tobago Dolla1.00",
5942 "Tunisian Dina1.00",
5944 "Turkmenistani Mana1.00",
5950 "US Dollar (Next day1.00",
5951 "US Dollar (Same day1.00",
5955 "Ugandan Shillin1.00",
5956 "Ugandan Shilling (1966-19871.00",
5957 "Ukrainian Hryvni1.00",
5958 "Ukrainian Karbovanet1.00",
5959 "Colombian Real Value Uni1.00",
5960 "United Arab Emirates Dirha1.00",
5961 "Unknown Currenc1.00",
5963 "Uruguay Peso (1975-19931.00",
5964 "Uruguay Peso Uruguay1.00",
5965 "Uruguay Peso (Indexed Units1.00",
5966 "Uzbekistan So1.00",
5972 "Venezuelan Bol\\u00edva1.00",
5973 "Venezuelan Bol\\u00edvar Fuert1.00",
5974 "Vietnamese Don1.00",
5995 "Yugoslavian Convertible Dina1.00",
5996 "Yugoslavian Hard Dinar (1966-19901.00",
5997 "Yugoslavian New Dina1.00",
6003 "Zairean New Zaire (1993-19981.00",
6005 "Zambian Kwach1.00",
6006 "Zimbabwean Dollar (1980-20081.00",
6014 Locale
locale("en_US");
6015 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
6016 UnicodeString formatted
= ctou(DATA
[i
]);
6017 UErrorCode status
= U_ZERO_ERROR
;
6018 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, NumberFormat::kCurrencyStyle
, status
);
6019 Formattable parseResult
;
6020 ParsePosition
parsePos(0);
6021 if (numFmt
!= NULL
&& U_SUCCESS(status
)) {
6022 numFmt
->parseCurrency(formatted
, parseResult
, parsePos
);
6023 if ( parseResult
.getDouble(status
) != 1.0 || U_FAILURE(status
) || parsePos
.getErrorIndex() != -1 ) {
6024 errln("wrong parsing, " + formatted
);
6025 errln("data: " + formatted
);
6028 dataerrln("Unable to create NumberFormat. - %s", u_errorName(status
));
6035 for (uint32_t i
=0; i
<sizeof(WRONG_DATA
)/sizeof(WRONG_DATA
[0]); ++i
) {
6036 UnicodeString formatted
= ctou(WRONG_DATA
[i
]);
6037 UErrorCode status
= U_ZERO_ERROR
;
6038 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, NumberFormat::kCurrencyStyle
, status
);
6039 Formattable parseResult
;
6040 if (numFmt
!= NULL
&& U_SUCCESS(status
)) {
6041 numFmt
->parse(formatted
, parseResult
, status
);
6042 if (!U_FAILURE(status
) ||
6043 (parseResult
.getType() == Formattable::kDouble
&&
6044 parseResult
.getDouble() == 1.0)) {
6045 errln("parsed but should not be: " + formatted
);
6046 errln("data: " + formatted
);
6049 dataerrln("Unable to create NumberFormat. - %s", u_errorName(status
));
6057 const char* attrString(int32_t);
6061 // std::cout << s.toUTF8String(ss)
6062 void NumberFormatTest::expectPositions(FieldPositionIterator
& iter
, int32_t *values
, int32_t tupleCount
,
6063 const UnicodeString
& str
) {
6067 if (tupleCount
> 10) {
6068 assertTrue("internal error, tupleCount too large", FALSE
);
6070 for (int i
= 0; i
< tupleCount
; ++i
) {
6076 while (iter
.next(fp
)) {
6078 int32_t id
= fp
.getField();
6079 int32_t start
= fp
.getBeginIndex();
6080 int32_t limit
= fp
.getEndIndex();
6082 // is there a logln using printf?
6084 sprintf(buf
, "%24s %3d %3d %3d", attrString(id
), id
, start
, limit
);
6087 for (int i
= 0; i
< tupleCount
; ++i
) {
6091 if (values
[i
*3] == id
&&
6092 values
[i
*3+1] == start
&&
6093 values
[i
*3+2] == limit
) {
6094 found
[i
] = ok
= TRUE
;
6099 assertTrue((UnicodeString
)"found [" + id
+ "," + start
+ "," + limit
+ "]", ok
);
6102 // check that all were found
6104 for (int i
= 0; i
< tupleCount
; ++i
) {
6107 assertTrue((UnicodeString
) "missing [" + values
[i
*3] + "," + values
[i
*3+1] + "," + values
[i
*3+2] + "]", found
[i
]);
6110 assertTrue("no expected values were missing", ok
);
6113 void NumberFormatTest::expectPosition(FieldPosition
& pos
, int32_t id
, int32_t start
, int32_t limit
,
6114 const UnicodeString
& str
) {
6116 assertTrue((UnicodeString
)"id " + id
+ " == " + pos
.getField(), id
== pos
.getField());
6117 assertTrue((UnicodeString
)"begin " + start
+ " == " + pos
.getBeginIndex(), start
== pos
.getBeginIndex());
6118 assertTrue((UnicodeString
)"end " + limit
+ " == " + pos
.getEndIndex(), limit
== pos
.getEndIndex());
6121 void NumberFormatTest::TestFieldPositionIterator() {
6123 UErrorCode status
= U_ZERO_ERROR
;
6124 FieldPositionIterator iter1
;
6125 FieldPositionIterator iter2
;
6128 DecimalFormat
*decFmt
= (DecimalFormat
*) NumberFormat::createInstance(status
);
6129 if (failure(status
, "NumberFormat::createInstance", TRUE
)) return;
6131 double num
= 1234.56;
6135 assertTrue((UnicodeString
)"self==", iter1
== iter1
);
6136 assertTrue((UnicodeString
)"iter1==iter2", iter1
== iter2
);
6138 decFmt
->format(num
, str1
, &iter1
, status
);
6139 assertTrue((UnicodeString
)"iter1 != iter2", iter1
!= iter2
);
6140 decFmt
->format(num
, str2
, &iter2
, status
);
6141 assertTrue((UnicodeString
)"iter1 == iter2 (2)", iter1
== iter2
);
6143 assertTrue((UnicodeString
)"iter1 != iter2 (2)", iter1
!= iter2
);
6145 assertTrue((UnicodeString
)"iter1 == iter2 (3)", iter1
== iter2
);
6147 // should format ok with no iterator
6149 decFmt
->format(num
, str2
, NULL
, status
);
6150 assertEquals("null fpiter", str1
, str2
);
6155 void NumberFormatTest::TestFormatAttributes() {
6156 Locale
locale("en_US");
6157 UErrorCode status
= U_ZERO_ERROR
;
6158 DecimalFormat
*decFmt
= (DecimalFormat
*) NumberFormat::createInstance(locale
, NumberFormat::kCurrencyStyle
, status
);
6159 if (failure(status
, "NumberFormat::createInstance", TRUE
)) return;
6160 double val
= 12345.67;
6163 int32_t expected
[] = {
6164 NumberFormat::kCurrencyField
, 0, 1,
6165 NumberFormat::kGroupingSeparatorField
, 3, 4,
6166 NumberFormat::kIntegerField
, 1, 7,
6167 NumberFormat::kDecimalSeparatorField
, 7, 8,
6168 NumberFormat::kFractionField
, 8, 10,
6170 int32_t tupleCount
= sizeof(expected
)/(3 * sizeof(*expected
));
6172 FieldPositionIterator posIter
;
6173 UnicodeString result
;
6174 decFmt
->format(val
, result
, &posIter
, status
);
6175 expectPositions(posIter
, expected
, tupleCount
, result
);
6178 FieldPosition
fp(NumberFormat::kIntegerField
);
6179 UnicodeString result
;
6180 decFmt
->format(val
, result
, fp
);
6181 expectPosition(fp
, NumberFormat::kIntegerField
, 1, 7, result
);
6184 FieldPosition
fp(NumberFormat::kFractionField
);
6185 UnicodeString result
;
6186 decFmt
->format(val
, result
, fp
);
6187 expectPosition(fp
, NumberFormat::kFractionField
, 8, 10, result
);
6191 decFmt
= (DecimalFormat
*) NumberFormat::createInstance(locale
, NumberFormat::kScientificStyle
, status
);
6194 int32_t expected
[] = {
6195 NumberFormat::kSignField
, 0, 1,
6196 NumberFormat::kIntegerField
, 1, 2,
6197 NumberFormat::kDecimalSeparatorField
, 2, 3,
6198 NumberFormat::kFractionField
, 3, 5,
6199 NumberFormat::kExponentSymbolField
, 5, 6,
6200 NumberFormat::kExponentSignField
, 6, 7,
6201 NumberFormat::kExponentField
, 7, 8
6203 int32_t tupleCount
= sizeof(expected
)/(3 * sizeof(*expected
));
6205 FieldPositionIterator posIter
;
6206 UnicodeString result
;
6207 decFmt
->format(val
, result
, &posIter
, status
);
6208 expectPositions(posIter
, expected
, tupleCount
, result
);
6211 FieldPosition
fp(NumberFormat::kIntegerField
);
6212 UnicodeString result
;
6213 decFmt
->format(val
, result
, fp
);
6214 expectPosition(fp
, NumberFormat::kIntegerField
, 1, 2, result
);
6217 FieldPosition
fp(NumberFormat::kFractionField
);
6218 UnicodeString result
;
6219 decFmt
->format(val
, result
, fp
);
6220 expectPosition(fp
, NumberFormat::kFractionField
, 3, 5, result
);
6227 const char* attrString(int32_t attrId
) {
6229 case NumberFormat::kIntegerField
: return "integer";
6230 case NumberFormat::kFractionField
: return "fraction";
6231 case NumberFormat::kDecimalSeparatorField
: return "decimal separator";
6232 case NumberFormat::kExponentSymbolField
: return "exponent symbol";
6233 case NumberFormat::kExponentSignField
: return "exponent sign";
6234 case NumberFormat::kExponentField
: return "exponent";
6235 case NumberFormat::kGroupingSeparatorField
: return "grouping separator";
6236 case NumberFormat::kCurrencyField
: return "currency";
6237 case NumberFormat::kPercentField
: return "percent";
6238 case NumberFormat::kPermillField
: return "permille";
6239 case NumberFormat::kSignField
: return "sign";
6245 // Test formatting & parsing of big decimals.
6246 // API test, not a comprehensive test.
6247 // See DecimalFormatTest/DataDrivenTests
6249 #define ASSERT_SUCCESS(status) {if (U_FAILURE(status)) errln("file %s, line %d: status: %s", \
6250 __FILE__, __LINE__, u_errorName(status));}
6251 #define ASSERT_EQUALS(expected, actual) {if ((expected) != (actual)) \
6252 errln("file %s, line %d: %s != %s", __FILE__, __LINE__, #expected, #actual);}
6254 static UBool
operator != (const char *s1
, UnicodeString
&s2
) {
6255 // This function lets ASSERT_EQUALS("literal", UnicodeString) work.
6256 UnicodeString
us1(s1
);
6260 void NumberFormatTest::TestDecimal() {
6262 UErrorCode status
= U_ZERO_ERROR
;
6263 Formattable
f("12.345678999987654321E666", status
);
6264 ASSERT_SUCCESS(status
);
6265 StringPiece s
= f
.getDecimalNumber(status
);
6266 ASSERT_SUCCESS(status
);
6267 ASSERT_EQUALS("1.2345678999987654321E+667", s
);
6268 //printf("%s\n", s.data());
6272 UErrorCode status
= U_ZERO_ERROR
;
6273 Formattable
f1("this is not a number", status
);
6274 ASSERT_EQUALS(U_DECIMAL_NUMBER_SYNTAX_ERROR
, status
);
6278 UErrorCode status
= U_ZERO_ERROR
;
6280 f
.setDecimalNumber("123.45", status
);
6281 ASSERT_SUCCESS(status
);
6282 ASSERT_EQUALS( Formattable::kDouble
, f
.getType());
6283 ASSERT_EQUALS(123.45, f
.getDouble());
6284 ASSERT_EQUALS(123.45, f
.getDouble(status
));
6285 ASSERT_SUCCESS(status
);
6286 ASSERT_EQUALS("123.45", f
.getDecimalNumber(status
));
6287 ASSERT_SUCCESS(status
);
6289 f
.setDecimalNumber("4.5678E7", status
);
6292 ASSERT_EQUALS(45678000, n
);
6294 status
= U_ZERO_ERROR
;
6295 f
.setDecimalNumber("-123", status
);
6296 ASSERT_SUCCESS(status
);
6297 ASSERT_EQUALS( Formattable::kLong
, f
.getType());
6298 ASSERT_EQUALS(-123, f
.getLong());
6299 ASSERT_EQUALS(-123, f
.getLong(status
));
6300 ASSERT_SUCCESS(status
);
6301 ASSERT_EQUALS("-123", f
.getDecimalNumber(status
));
6302 ASSERT_SUCCESS(status
);
6304 status
= U_ZERO_ERROR
;
6305 f
.setDecimalNumber("1234567890123", status
); // Number too big for 32 bits
6306 ASSERT_SUCCESS(status
);
6307 ASSERT_EQUALS( Formattable::kInt64
, f
.getType());
6308 ASSERT_EQUALS(1234567890123LL, f
.getInt64());
6309 ASSERT_EQUALS(1234567890123LL, f
.getInt64(status
));
6310 ASSERT_SUCCESS(status
);
6311 ASSERT_EQUALS("1234567890123", f
.getDecimalNumber(status
));
6312 ASSERT_SUCCESS(status
);
6316 UErrorCode status
= U_ZERO_ERROR
;
6317 NumberFormat
*fmtr
= NumberFormat::createInstance(
6318 Locale::getUS(), NumberFormat::kNumberStyle
, status
);
6319 if (U_FAILURE(status
) || fmtr
== NULL
) {
6320 dataerrln("Unable to create NumberFormat");
6322 UnicodeString formattedResult
;
6323 StringPiece
num("244444444444444444444444444444444444446.4");
6324 fmtr
->format(num
, formattedResult
, NULL
, status
);
6325 ASSERT_SUCCESS(status
);
6326 ASSERT_EQUALS("244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult
);
6327 //std::string ss; std::cout << formattedResult.toUTF8String(ss);
6333 // Check formatting a DigitList. DigitList is internal, but this is
6334 // a critical interface that must work.
6335 UErrorCode status
= U_ZERO_ERROR
;
6336 NumberFormat
*fmtr
= NumberFormat::createInstance(
6337 Locale::getUS(), NumberFormat::kNumberStyle
, status
);
6338 if (U_FAILURE(status
) || fmtr
== NULL
) {
6339 dataerrln("Unable to create NumberFormat");
6341 UnicodeString formattedResult
;
6343 StringPiece
num("123.4566666666666666666666666666666666621E+40");
6344 dl
.set(num
, status
);
6345 ASSERT_SUCCESS(status
);
6346 fmtr
->format(dl
, formattedResult
, NULL
, status
);
6347 ASSERT_SUCCESS(status
);
6348 ASSERT_EQUALS("1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult
);
6350 status
= U_ZERO_ERROR
;
6352 dl
.set(num
, status
);
6353 FieldPosition
pos(NumberFormat::FRACTION_FIELD
);
6354 ASSERT_SUCCESS(status
);
6355 formattedResult
.remove();
6356 fmtr
->format(dl
, formattedResult
, pos
, status
);
6357 ASSERT_SUCCESS(status
);
6358 ASSERT_EQUALS("666.666", formattedResult
);
6359 ASSERT_EQUALS(4, pos
.getBeginIndex());
6360 ASSERT_EQUALS(7, pos
.getEndIndex());
6366 // Check a parse with a formatter with a multiplier.
6367 UErrorCode status
= U_ZERO_ERROR
;
6368 NumberFormat
*fmtr
= NumberFormat::createInstance(
6369 Locale::getUS(), NumberFormat::kPercentStyle
, status
);
6370 if (U_FAILURE(status
) || fmtr
== NULL
) {
6371 dataerrln("Unable to create NumberFormat");
6373 UnicodeString input
= "1.84%";
6375 fmtr
->parse(input
, result
, status
);
6376 ASSERT_SUCCESS(status
);
6377 ASSERT_EQUALS(0, strcmp("0.0184", result
.getDecimalNumber(status
).data()));
6378 //std::cout << result.getDecimalNumber(status).data();
6384 // Check that a parse returns a decimal number with full accuracy
6385 UErrorCode status
= U_ZERO_ERROR
;
6386 NumberFormat
*fmtr
= NumberFormat::createInstance(
6387 Locale::getUS(), NumberFormat::kNumberStyle
, status
);
6388 if (U_FAILURE(status
) || fmtr
== NULL
) {
6389 dataerrln("Unable to create NumberFormat");
6391 UnicodeString input
= "1.002200044400088880000070000";
6393 fmtr
->parse(input
, result
, status
);
6394 ASSERT_SUCCESS(status
);
6395 ASSERT_EQUALS(0, strcmp("1.00220004440008888000007", result
.getDecimalNumber(status
).data()));
6396 ASSERT_EQUALS(1.00220004440008888, result
.getDouble());
6397 //std::cout << result.getDecimalNumber(status).data();
6404 void NumberFormatTest::TestCurrencyFractionDigits() {
6405 UErrorCode status
= U_ZERO_ERROR
;
6406 UnicodeString text1
, text2
;
6407 double value
= 99.12345;
6409 // Create currenct instance
6410 NumberFormat
* fmt
= NumberFormat::createCurrencyInstance("ja_JP", status
);
6411 if (U_FAILURE(status
) || fmt
== NULL
) {
6412 dataerrln("Unable to create NumberFormat");
6414 fmt
->format(value
, text1
);
6416 // Reset the same currency and format the test value again
6417 fmt
->setCurrency(fmt
->getCurrency(), status
);
6418 ASSERT_SUCCESS(status
);
6419 fmt
->format(value
, text2
);
6421 if (text1
!= text2
) {
6422 errln((UnicodeString
)"NumberFormat::format() should return the same result - text1="
6423 + text1
+ " text2=" + text2
);
6429 void NumberFormatTest::TestExponentParse() {
6431 UErrorCode status
= U_ZERO_ERROR
;
6433 ParsePosition
parsePos(0);
6435 // set the exponent symbol
6436 status
= U_ZERO_ERROR
;
6437 DecimalFormatSymbols
*symbols
= new DecimalFormatSymbols(Locale::getDefault(), status
);
6438 if(U_FAILURE(status
)) {
6439 dataerrln((UnicodeString
)"ERROR: Could not create DecimalFormatSymbols (Default)");
6444 symbols
->setSymbol(DecimalFormatSymbols::kExponentialSymbol
,"e");
6446 // create format instance
6447 status
= U_ZERO_ERROR
;
6448 DecimalFormat
fmt("#####", symbols
, status
);
6449 if(U_FAILURE(status
)) {
6450 errln((UnicodeString
)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
6454 fmt
.parse("123E4", result
, parsePos
);
6455 if(result
.getType() != Formattable::kDouble
&&
6456 result
.getDouble() != (double)123 &&
6457 parsePos
.getIndex() != 3
6460 errln("ERROR: parse failed - expected 123.0, 3 - returned %d, %i",
6461 result
.getDouble(), parsePos
.getIndex());
6464 // create format instance
6465 status
= U_ZERO_ERROR
;
6466 DecimalFormat
fmt("#####", symbols
, status
);
6467 if(U_FAILURE(status
)) {
6468 errln((UnicodeString
)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
6472 fmt
.parse("5.06e-27", result
, parsePos
);
6473 if(result
.getType() != Formattable::kDouble
&&
6474 result
.getDouble() != 5.06E-27 &&
6475 parsePos
.getIndex() != 8
6478 errln("ERROR: parse failed - expected 5.06E-27, 8 - returned %d, %i",
6479 result
.getDouble(), parsePos
.getIndex());
6484 #endif /* #if !UCONFIG_NO_FORMATTING */