1 /********************************************************************
3 * Copyright (c) 1997-2012, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /* Modification History:
7 * Date Name Description
8 * 07/15/99 helena Ported to HPUX 10/11 CC.
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/dcfmtsym.h"
17 #include "unicode/decimfmt.h"
18 #include "unicode/localpointer.h"
19 #include "unicode/ucurr.h"
20 #include "unicode/ustring.h"
21 #include "unicode/measfmt.h"
22 #include "unicode/curramt.h"
33 #include "unicode/numsys.h"
35 //#define NUMFMTST_CACHE_DEBUG 1
36 #include "stdio.h" /* for sprintf */
37 // #include "iostream" // for cout
39 //#define NUMFMTST_DEBUG 1
41 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
43 static const UChar EUR
[] = {69,85,82,0}; // "EUR"
44 static const UChar ISO_CURRENCY_USD
[] = {0x55, 0x53, 0x44, 0}; // "USD"
46 // *****************************************************************************
47 // class NumberFormatTest
48 // *****************************************************************************
50 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
52 #define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
53 #define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
55 void NumberFormatTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ )
57 // if (exec) logln((UnicodeString)"TestSuite DateFormatTest");
59 CASE(0,TestCurrencySign
);
62 CASE(3,TestRounding487
);
64 CASE(5,TestExponential
);
67 // Upgrade to alphaWorks - liu 5/99
69 CASE(8,TestScientific
);
71 CASE(10,TestPatterns2
);
72 CASE(11,TestSecondaryGrouping
);
73 CASE(12,TestSurrogateSupport
);
76 CASE(14,TestCurrencyObject
);
77 CASE(15,TestCurrencyPatterns
);
78 //CASE(16,TestDigitList);
79 CASE(16,TestWhiteSpaceParsing
);
80 CASE(17,TestComplexCurrency
); // This test removed because CLDR no longer uses choice formats in currency symbols.
81 CASE(18,TestRegCurrency
);
82 CASE(19,TestSymbolsWithBadLocale
);
83 CASE(20,TestAdoptDecimalFormatSymbols
);
85 CASE(21,TestScientific2
);
86 CASE(22,TestScientificGrouping
);
90 CASE(25,TestIllegalPatterns
);
93 CASE(27,TestCurrencyNames
);
94 CASE(28,TestCurrencyAmount
);
95 CASE(29,TestCurrencyUnit
);
96 CASE(30,TestCoverage
);
99 CASE(33,TestHostClone
);
100 CASE(34,TestCurrencyFormat
);
101 CASE(35,TestRounding
);
102 CASE(36,TestNonpositiveMultiplier
);
103 CASE(37,TestNumberingSystems
);
104 CASE(38,TestSpaceParsing
);
105 CASE(39,TestMultiCurrencySign
);
106 CASE(40,TestCurrencyFormatForMixParsing
);
107 CASE(41,TestDecimalFormatCurrencyParse
);
108 CASE(42,TestCurrencyIsoPluralFormat
);
109 CASE(43,TestCurrencyParsing
);
110 CASE(44,TestParseCurrencyInUCurr
);
111 CASE(45,TestFormatAttributes
);
112 CASE(46,TestFieldPositionIterator
);
113 CASE(47,TestDecimal
);
114 CASE(48,TestCurrencyFractionDigits
);
115 CASE(49,TestExponentParse
);
116 CASE(50,TestExplicitParents
);
117 CASE(51,TestLenientParse
);
118 CASE(52,TestAvailableNumberingSystems
);
119 CASE(53,TestRoundingPattern
);
121 default: name
= ""; break;
125 // -------------------------------------
127 // Test API (increase code coverage)
129 NumberFormatTest::TestAPI(void)
132 UErrorCode status
= U_ZERO_ERROR
;
133 NumberFormat
*test
= NumberFormat::createInstance("root", status
);
134 if(U_FAILURE(status
)) {
135 dataerrln("unable to create format object - %s", u_errorName(status
));
138 test
->setMinimumIntegerDigits(10);
139 test
->setMaximumIntegerDigits(2);
141 test
->setMinimumFractionDigits(10);
142 test
->setMaximumFractionDigits(2);
144 UnicodeString result
;
146 Formattable
bla("Paja Patak"); // Donald Duck for non Serbian speakers
147 test
->format(bla
, result
, pos
, status
);
148 if(U_SUCCESS(status
)) {
149 errln("Yuck... Formatted a duck... As a number!");
151 status
= U_ZERO_ERROR
;
156 test
->format(ll
, result
);
157 if (result
!= "12.00"){
158 errln("format int64_t error");
162 LocalPointer
<CurrencyAmount
> currAmt(test
->parseCurrency("",ppos
));
163 // old test for (U_FAILURE(status)) was bogus here, method does not set status!
164 if (ppos
.getIndex()) {
165 errln("Parsed empty string as currency");
172 class StubNumberForamt
:public NumberFormat
{
174 StubNumberForamt(){};
175 virtual UnicodeString
& format(double ,UnicodeString
& appendTo
,FieldPosition
& ) const {
178 virtual UnicodeString
& format(int32_t ,UnicodeString
& appendTo
,FieldPosition
& ) const {
179 return appendTo
.append((UChar
)0x0033);
181 virtual UnicodeString
& format(int64_t number
,UnicodeString
& appendTo
,FieldPosition
& pos
) const {
182 return NumberFormat::format(number
, appendTo
, pos
);
184 virtual UnicodeString
& format(const Formattable
& , UnicodeString
& appendTo
, FieldPosition
& , UErrorCode
& ) const {
187 virtual void parse(const UnicodeString
& ,
189 ParsePosition
& ) const {}
190 virtual void parse( const UnicodeString
& ,
192 UErrorCode
& ) const {}
193 virtual UClassID
getDynamicClassID(void) const {
194 static char classID
= 0;
195 return (UClassID
)&classID
;
197 virtual Format
* clone() const {return NULL
;}
201 NumberFormatTest::TestCoverage(void){
202 StubNumberForamt stub
;
203 UnicodeString
agent("agent");
206 if (stub
.format(num
, agent
, pos
) != UnicodeString("agent3")){
207 errln("NumberFormat::format(int64, UnicodString&, FieldPosition&) should delegate to (int32, ,)");
211 // Test various patterns
213 NumberFormatTest::TestPatterns(void)
215 UErrorCode status
= U_ZERO_ERROR
;
216 DecimalFormatSymbols
sym(Locale::getUS(), status
);
217 if (U_FAILURE(status
)) { errcheckln(status
, "FAIL: Could not construct DecimalFormatSymbols - %s", u_errorName(status
)); return; }
219 const char* pat
[] = { "#.#", "#.", ".#", "#" };
220 int32_t pat_length
= (int32_t)(sizeof(pat
) / sizeof(pat
[0]));
221 const char* newpat
[] = { "#0.#", "#0.", "#.0", "#" };
222 const char* num
[] = { "0", "0.", ".0", "0" };
223 for (int32_t i
=0; i
<pat_length
; ++i
)
225 status
= U_ZERO_ERROR
;
226 DecimalFormat
fmt(pat
[i
], sym
, status
);
227 if (U_FAILURE(status
)) { errln((UnicodeString
)"FAIL: DecimalFormat constructor failed for " + pat
[i
]); continue; }
228 UnicodeString newp
; fmt
.toPattern(newp
);
229 if (!(newp
== newpat
[i
]))
230 errln((UnicodeString
)"FAIL: Pattern " + pat
[i
] + " should transmute to " + newpat
[i
] +
231 "; " + newp
+ " seen instead");
233 UnicodeString s
; (*(NumberFormat
*)&fmt
).format((int32_t)0, s
);
236 errln((UnicodeString
)"FAIL: Pattern " + pat
[i
] + " should format zero as " + num
[i
] +
237 "; " + s
+ " seen instead");
238 logln((UnicodeString
)"Min integer digits = " + fmt
.getMinimumIntegerDigits());
244 icu_2_4::DigitList::operator== 0 0 2 icuuc24d.dll digitlst.cpp Doug
245 icu_2_4::DigitList::append 0 0 4 icuin24d.dll digitlst.h Doug
246 icu_2_4::DigitList::operator!= 0 0 1 icuuc24d.dll digitlst.h Doug
250 NumberFormatTest::TestDigitList(void)
252 // API coverage for DigitList
255 list1.fDecimalAt = 1;
257 list2.set((int32_t)1);
258 if (list1 != list2) {
259 errln("digitlist append, operator!= or set failed ");
261 if (!(list1 == list2)) {
262 errln("digitlist append, operator== or set failed ");
267 // -------------------------------------
269 // Test exponential pattern
271 NumberFormatTest::TestExponential(void)
273 UErrorCode status
= U_ZERO_ERROR
;
274 DecimalFormatSymbols
sym(Locale::getUS(), status
);
275 if (U_FAILURE(status
)) { errcheckln(status
, "FAIL: Bad status returned by DecimalFormatSymbols ct - %s", u_errorName(status
)); return; }
276 const char* pat
[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" };
277 int32_t pat_length
= (int32_t)(sizeof(pat
) / sizeof(pat
[0]));
279 // The following #if statements allow this test to be built and run on
280 // platforms that do not have standard IEEE numerics. For example,
281 // S/390 doubles have an exponent range of -78 to +75. For the
282 // following #if statements to work, float.h must define
283 // DBL_MAX_10_EXP to be a compile-time constant.
285 // This section may be expanded as needed.
287 #if DBL_MAX_10_EXP > 300
288 double val
[] = { 0.01234, 123456789, 1.23e300
, -3.141592653e-271 };
289 int32_t val_length
= (int32_t)(sizeof(val
) / sizeof(val
[0]));
290 const char* valFormat
[] =
293 "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
295 "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
297 "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
299 "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
303 0.01234, 123460000, 1.23E300
, -3.1416E-271,
304 0.01234, 123460000, 1.23E300
, -3.1416E-271,
305 0.01234, 123456800, 1.23E300
, -3.141593E-271,
306 0.01234, 123500000, 1.23E300
, -3.142E-271,
308 #elif DBL_MAX_10_EXP > 70
309 double val
[] = { 0.01234, 123456789, 1.23e70
, -3.141592653e-71 };
310 int32_t val_length
= sizeof(val
) / sizeof(val
[0]);
314 "1.234E-2", "1.2346E8", "1.23E70", "-3.1416E-71",
316 "12.340E-03", "12.346E07", "12.300E69", "-31.416E-72",
318 "12.34E-003", "123.4568E006", "12.3E069", "-31.41593E-072",
320 "1.234E-2", "1.235E8", "1.23E70", "[3.142E-71]"
324 0.01234, 123460000, 1.23E70
, -3.1416E-71,
325 0.01234, 123460000, 1.23E70
, -3.1416E-71,
326 0.01234, 123456800, 1.23E70
, -3.141593E-71,
327 0.01234, 123500000, 1.23E70
, -3.142E-71,
330 // Don't test double conversion
332 int32_t val_length
= 0;
333 char** valFormat
= 0;
334 double* valParse
= 0;
335 logln("Warning: Skipping double conversion tests");
338 int32_t lval
[] = { 0, -1, 1, 123456789 };
339 int32_t lval_length
= (int32_t)(sizeof(lval
) / sizeof(lval
[0]));
340 const char* lvalFormat
[] =
343 "0E0", "-1E0", "1E0", "1.2346E8",
345 "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
347 "0E000", "-1E000", "1E000", "123.4568E006",
349 "0E0", "[1E0]", "1E0", "1.235E8"
351 int32_t lvalParse
[] =
358 int32_t ival
= 0, ilval
= 0;
359 for (int32_t p
=0; p
<pat_length
; ++p
)
361 DecimalFormat
fmt(pat
[p
], sym
, status
);
362 if (U_FAILURE(status
)) { errln("FAIL: Bad status returned by DecimalFormat ct"); continue; }
363 UnicodeString pattern
;
364 logln((UnicodeString
)"Pattern \"" + pat
[p
] + "\" -toPattern-> \"" +
365 fmt
.toPattern(pattern
) + "\"");
367 for (v
=0; v
<val_length
; ++v
)
369 UnicodeString s
; (*(NumberFormat
*)&fmt
).format(val
[v
], s
);
370 logln((UnicodeString
)" " + val
[v
] + " -format-> " + s
);
371 if (s
!= valFormat
[v
+ival
])
372 errln((UnicodeString
)"FAIL: Expected " + valFormat
[v
+ival
]);
374 ParsePosition
pos(0);
376 fmt
.parse(s
, af
, pos
);
378 UBool useEpsilon
= FALSE
;
379 if (af
.getType() == Formattable::kLong
)
381 else if (af
.getType() == Formattable::kDouble
) {
383 #if U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400
384 // S/390 will show a failure like this:
385 //| -3.141592652999999e-271 -format-> -3.1416E-271
386 //| -parse-> -3.1416e-271
387 //| FAIL: Expected -3.141599999999999e-271
388 // To compensate, we use an epsilon-based equality
389 // test on S/390 only. We don't want to do this in
390 // general because it's less exacting.
395 errln((UnicodeString
)"FAIL: Non-numeric Formattable returned");
398 if (pos
.getIndex() == s
.length())
400 logln((UnicodeString
)" -parse-> " + a
);
401 // Use epsilon comparison as necessary
403 (uprv_fabs(a
- valParse
[v
+ival
]) / a
> (2*DBL_EPSILON
))) ||
404 (!useEpsilon
&& a
!= valParse
[v
+ival
]))
406 errln((UnicodeString
)"FAIL: Expected " + valParse
[v
+ival
]);
410 errln((UnicodeString
)"FAIL: Partial parse (" + pos
.getIndex() + " chars) -> " + a
);
411 errln((UnicodeString
)" should be (" + s
.length() + " chars) -> " + valParse
[v
+ival
]);
414 for (v
=0; v
<lval_length
; ++v
)
417 (*(NumberFormat
*)&fmt
).format(lval
[v
], s
);
418 logln((UnicodeString
)" " + lval
[v
] + "L -format-> " + s
);
419 if (s
!= lvalFormat
[v
+ilval
])
420 errln((UnicodeString
)"ERROR: Expected " + lvalFormat
[v
+ilval
] + " Got: " + s
);
422 ParsePosition
pos(0);
424 fmt
.parse(s
, af
, pos
);
425 if (af
.getType() == Formattable::kLong
||
426 af
.getType() == Formattable::kInt64
) {
427 UErrorCode status
= U_ZERO_ERROR
;
428 int32_t a
= af
.getLong(status
);
429 if (pos
.getIndex() == s
.length())
431 logln((UnicodeString
)" -parse-> " + a
);
432 if (a
!= lvalParse
[v
+ilval
])
433 errln((UnicodeString
)"FAIL: Expected " + lvalParse
[v
+ilval
]);
436 errln((UnicodeString
)"FAIL: Partial parse (" + pos
.getIndex() + " chars) -> " + a
);
439 errln((UnicodeString
)"FAIL: Non-long Formattable returned for " + s
440 + " Double: " + af
.getDouble()
441 + ", Long: " + af
.getLong());
444 ilval
+= lval_length
;
449 NumberFormatTest::TestScientific2() {
451 UErrorCode status
= U_ZERO_ERROR
;
452 DecimalFormat
* fmt
= (DecimalFormat
*)NumberFormat::createCurrencyInstance("en_US", status
);
453 if (U_SUCCESS(status
)) {
455 expect(*fmt
, num
, "$12.34");
456 fmt
->setScientificNotation(TRUE
);
457 expect(*fmt
, num
, "$1.23E1");
458 fmt
->setScientificNotation(FALSE
);
459 expect(*fmt
, num
, "$12.34");
465 NumberFormatTest::TestScientificGrouping() {
467 UErrorCode status
= U_ZERO_ERROR
;
468 DecimalFormat
fmt("##0.00E0",status
);
469 if (U_SUCCESS(status
)) {
470 expect(fmt
, .01234, "12.3E-3");
471 expect(fmt
, .1234, "123E-3");
472 expect(fmt
, 1.234, "1.23E0");
473 expect(fmt
, 12.34, "12.3E0");
474 expect(fmt
, 123.4, "123E0");
475 expect(fmt
, 1234., "1.23E3");
479 /*static void setFromString(DigitList& dl, const char* str) {
481 UBool decimalSet = FALSE;
483 while ((c = *str++)) {
485 dl.fIsPositive = FALSE;
486 } else if (c == '+') {
487 dl.fIsPositive = TRUE;
488 } else if (c == '.') {
489 dl.fDecimalAt = dl.fCount;
496 dl.fDecimalAt = dl.fCount;
501 NumberFormatTest::TestInt64() {
502 UErrorCode status
= U_ZERO_ERROR
;
503 DecimalFormat
fmt("#.#E0",status
);
504 fmt
.setMaximumFractionDigits(20);
505 if (U_SUCCESS(status
)) {
506 expect(fmt
, (Formattable
)(int64_t)0, "0E0");
507 expect(fmt
, (Formattable
)(int64_t)-1, "-1E0");
508 expect(fmt
, (Formattable
)(int64_t)1, "1E0");
509 expect(fmt
, (Formattable
)(int64_t)2147483647, "2.147483647E9");
510 expect(fmt
, (Formattable
)((int64_t)-2147483647-1), "-2.147483648E9");
511 expect(fmt
, (Formattable
)(int64_t)U_INT64_MAX
, "9.223372036854775807E18");
512 expect(fmt
, (Formattable
)(int64_t)U_INT64_MIN
, "-9.223372036854775808E18");
515 // also test digitlist
516 /* int64_t int64max = U_INT64_MAX;
517 int64_t int64min = U_INT64_MIN;
518 const char* int64maxstr = "9223372036854775807";
519 const char* int64minstr = "-9223372036854775808";
520 UnicodeString fail("fail: ");
522 // test max int64 value
524 setFromString(dl, int64maxstr);
526 if (!dl.fitsIntoInt64(FALSE)) {
527 errln(fail + int64maxstr + " didn't fit");
529 int64_t int64Value = dl.getInt64();
530 if (int64Value != int64max) {
531 errln(fail + int64maxstr);
534 int64Value = dl.getInt64();
535 if (int64Value != int64max) {
536 errln(fail + int64maxstr);
539 // test negative of max int64 value (1 shy of min int64 value)
540 dl.fIsPositive = FALSE;
542 if (!dl.fitsIntoInt64(FALSE)) {
543 errln(fail + "-" + int64maxstr + " didn't fit");
545 int64_t int64Value = dl.getInt64();
546 if (int64Value != -int64max) {
547 errln(fail + "-" + int64maxstr);
550 int64Value = dl.getInt64();
551 if (int64Value != -int64max) {
552 errln(fail + "-" + int64maxstr);
555 // test min int64 value
556 setFromString(dl, int64minstr);
558 if (!dl.fitsIntoInt64(FALSE)) {
559 errln(fail + "-" + int64minstr + " didn't fit");
561 int64_t int64Value = dl.getInt64();
562 if (int64Value != int64min) {
563 errln(fail + int64minstr);
566 int64Value = dl.getInt64();
567 if (int64Value != int64min) {
568 errln(fail + int64minstr);
571 // test negative of min int 64 value (1 more than max int64 value)
572 dl.fIsPositive = TRUE; // won't fit
574 if (dl.fitsIntoInt64(FALSE)) {
575 errln(fail + "-(" + int64minstr + ") didn't fit");
580 // -------------------------------------
582 // Test the handling of quotes
584 NumberFormatTest::TestQuotes(void)
586 UErrorCode status
= U_ZERO_ERROR
;
588 DecimalFormatSymbols
*sym
= new DecimalFormatSymbols(Locale::getUS(), status
);
589 if (U_FAILURE(status
)) {
590 errcheckln(status
, "Fail to create DecimalFormatSymbols - %s", u_errorName(status
));
594 pat
= new UnicodeString("a'fo''o'b#");
595 DecimalFormat
*fmt
= new DecimalFormat(*pat
, *sym
, status
);
597 ((NumberFormat
*)fmt
)->format((int32_t)123, s
);
598 logln((UnicodeString
)"Pattern \"" + *pat
+ "\"");
599 logln((UnicodeString
)" Format 123 -> " + escape(s
));
600 if (!(s
=="afo'ob123"))
601 errln((UnicodeString
)"FAIL: Expected afo'ob123");
607 pat
= new UnicodeString("a''b#");
608 fmt
= new DecimalFormat(*pat
, *sym
, status
);
609 ((NumberFormat
*)fmt
)->format((int32_t)123, s
);
610 logln((UnicodeString
)"Pattern \"" + *pat
+ "\"");
611 logln((UnicodeString
)" Format 123 -> " + escape(s
));
613 errln((UnicodeString
)"FAIL: Expected a'b123");
620 * Test the handling of the currency symbol in patterns.
623 NumberFormatTest::TestCurrencySign(void)
625 UErrorCode status
= U_ZERO_ERROR
;
626 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale::getUS(), status
);
628 UChar currency
= 0x00A4;
629 if (U_FAILURE(status
)) {
630 errcheckln(status
, "Fail to create DecimalFormatSymbols - %s", u_errorName(status
));
634 // "\xA4#,##0.00;-\xA4#,##0.00"
635 pat
.append(currency
).append("#,##0.00;-").
636 append(currency
).append("#,##0.00");
637 DecimalFormat
*fmt
= new DecimalFormat(pat
, *sym
, status
);
638 UnicodeString s
; ((NumberFormat
*)fmt
)->format(1234.56, s
);
640 logln((UnicodeString
)"Pattern \"" + fmt
->toPattern(pat
) + "\"");
641 logln((UnicodeString
)" Format " + 1234.56 + " -> " + escape(s
));
642 if (s
!= "$1,234.56") dataerrln((UnicodeString
)"FAIL: Expected $1,234.56");
644 ((NumberFormat
*)fmt
)->format(- 1234.56, s
);
645 logln((UnicodeString
)" Format " + (-1234.56) + " -> " + escape(s
));
646 if (s
!= "-$1,234.56") dataerrln((UnicodeString
)"FAIL: Expected -$1,234.56");
649 // "\xA4\xA4 #,##0.00;\xA4\xA4 -#,##0.00"
650 pat
.append(currency
).append(currency
).
651 append(" #,##0.00;").
652 append(currency
).append(currency
).
653 append(" -#,##0.00");
654 fmt
= new DecimalFormat(pat
, *sym
, status
);
656 ((NumberFormat
*)fmt
)->format(1234.56, s
);
657 logln((UnicodeString
)"Pattern \"" + fmt
->toPattern(pat
) + "\"");
658 logln((UnicodeString
)" Format " + 1234.56 + " -> " + escape(s
));
659 if (s
!= "USD 1,234.56") dataerrln((UnicodeString
)"FAIL: Expected USD 1,234.56");
661 ((NumberFormat
*)fmt
)->format(-1234.56, s
);
662 logln((UnicodeString
)" Format " + (-1234.56) + " -> " + escape(s
));
663 if (s
!= "USD -1,234.56") dataerrln((UnicodeString
)"FAIL: Expected USD -1,234.56");
666 if (U_FAILURE(status
)) errln((UnicodeString
)"FAIL: Status " + u_errorName(status
));
669 // -------------------------------------
671 static UChar
toHexString(int32_t i
) { return (UChar
)(i
+ (i
< 10 ? 0x30 : (0x41 - 10))); }
674 NumberFormatTest::escape(UnicodeString
& s
)
677 for (int32_t i
=0; i
<s
.length(); ++i
)
679 UChar c
= s
[(int32_t)i
];
680 if (c
<= (UChar
)0x7F) buf
+= c
;
682 buf
+= (UChar
)0x5c; buf
+= (UChar
)0x55;
683 buf
+= toHexString((c
& 0xF000) >> 12);
684 buf
+= toHexString((c
& 0x0F00) >> 8);
685 buf
+= toHexString((c
& 0x00F0) >> 4);
686 buf
+= toHexString(c
& 0x000F);
693 // -------------------------------------
694 static const char* testCases
[][2]= {
695 /* locale ID */ /* expected */
696 {"ca_ES_PREEURO", "1.150\\u00A0\\u20A7" },
697 {"de_LU_PREEURO", "1,150\\u00A0F" },
698 {"el_GR_PREEURO", "1.150,50\\u00A0\\u0394\\u03C1\\u03C7" },
699 {"en_BE_PREEURO", "1.150,50\\u00A0BEF" },
700 {"es_ES_PREEURO", "1.150\\u00A0\\u20A7" },
701 {"eu_ES_PREEURO", "1.150\\u00A0\\u20A7" },
702 {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" },
703 {"it_IT_PREEURO", "ITL\\u00A01.150" },
704 {"pt_PT_PREEURO", "1,150$50\\u00A0Esc."},
705 {"en_US@currency=JPY", "\\u00A51,150"},
706 {"en_US@currency=jpy", "\\u00A51,150"},
707 {"en-US-u-cu-jpy", "\\u00A51,150"}
710 * Test localized currency patterns.
713 NumberFormatTest::TestCurrency(void)
715 UErrorCode status
= U_ZERO_ERROR
;
716 NumberFormat
* currencyFmt
= NumberFormat::createCurrencyInstance(Locale::getCanadaFrench(), status
);
717 if (U_FAILURE(status
)) {
718 dataerrln("Error calling NumberFormat::createCurrencyInstance()");
722 UnicodeString s
; currencyFmt
->format(1.50, s
);
723 logln((UnicodeString
)"Un pauvre ici a..........." + s
);
724 if (!(s
==CharsToUnicodeString("1,50\\u00A0$")))
725 errln((UnicodeString
)"FAIL: Expected 1,50<nbsp>$");
729 int len
= uloc_canonicalize("de_DE_PREEURO", loc
, 256, &status
);
730 currencyFmt
= NumberFormat::createCurrencyInstance(Locale(loc
),status
);
731 currencyFmt
->format(1.50, s
);
732 logln((UnicodeString
)"Un pauvre en Allemagne a.." + s
);
733 if (!(s
==CharsToUnicodeString("1,50\\u00A0DEM")))
734 errln((UnicodeString
)"FAIL: Expected 1,50<nbsp>DEM");
737 len
= uloc_canonicalize("fr_FR_PREEURO", loc
, 256, &status
);
738 currencyFmt
= NumberFormat::createCurrencyInstance(Locale(loc
), status
);
739 currencyFmt
->format(1.50, s
);
740 logln((UnicodeString
)"Un pauvre en France a....." + s
);
741 if (!(s
==CharsToUnicodeString("1,50\\u00A0F")))
742 errln((UnicodeString
)"FAIL: Expected 1,50<nbsp>F");
744 if (U_FAILURE(status
))
745 errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
747 for(int i
=0; i
< (int)(sizeof(testCases
)/sizeof(testCases
[i
])); i
++){
748 status
= U_ZERO_ERROR
;
749 const char *localeID
= testCases
[i
][0];
750 UnicodeString
expected(testCases
[i
][1], -1, US_INV
);
751 expected
= expected
.unescape();
754 uloc_canonicalize(localeID
, loc
, 256, &status
);
755 currencyFmt
= NumberFormat::createCurrencyInstance(Locale(loc
), status
);
756 if(U_FAILURE(status
)){
757 errln("Could not create currency formatter for locale %s",localeID
);
760 currencyFmt
->format(1150.50, s
);
762 errln(UnicodeString("FAIL: Expected: ")+expected
763 + UnicodeString(" Got: ") + s
764 + UnicodeString( " for locale: ")+ UnicodeString(localeID
) );
766 if (U_FAILURE(status
)){
767 errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
773 // -------------------------------------
776 * Test the Currency object handling, new as of ICU 2.2.
778 void NumberFormatTest::TestCurrencyObject() {
779 UErrorCode ec
= U_ZERO_ERROR
;
781 NumberFormat::createCurrencyInstance(Locale::getUS(), ec
);
784 dataerrln("FAIL: getCurrencyInstance(US) - %s", u_errorName(ec
));
789 Locale
null("", "", "");
791 expectCurrency(*fmt
, null
, 1234.56, "$1,234.56");
793 expectCurrency(*fmt
, Locale::getFrance(),
794 1234.56, CharsToUnicodeString("\\u20AC1,234.56")); // Euro
796 expectCurrency(*fmt
, Locale::getJapan(),
797 1234.56, CharsToUnicodeString("\\u00A51,235")); // Yen
799 expectCurrency(*fmt
, Locale("fr", "CH", ""),
800 1234.56, "CHF1,234.55"); // 0.05 rounding
802 expectCurrency(*fmt
, Locale::getUS(),
803 1234.56, "$1,234.56");
806 fmt
= NumberFormat::createCurrencyInstance(Locale::getFrance(), ec
);
809 errln("FAIL: getCurrencyInstance(FRANCE)");
814 expectCurrency(*fmt
, null
, 1234.56, CharsToUnicodeString("1 234,56 \\u20AC"));
816 expectCurrency(*fmt
, Locale::getJapan(),
817 1234.56, CharsToUnicodeString("1 235 \\u00A5JP")); // Yen
819 expectCurrency(*fmt
, Locale("fr", "CH", ""),
820 1234.56, "1 234,55 CHF"); // 0.05 rounding
822 expectCurrency(*fmt
, Locale::getUS(),
823 1234.56, "1 234,56 $US");
825 expectCurrency(*fmt
, Locale::getFrance(),
826 1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); // Euro
831 // -------------------------------------
834 * Do rudimentary testing of parsing.
837 NumberFormatTest::TestParse(void)
839 UErrorCode status
= U_ZERO_ERROR
;
840 UnicodeString
arg("0");
841 DecimalFormat
* format
= new DecimalFormat("00", status
);
843 Formattable n
; format
->parse(arg
, n
, status
);
844 logln((UnicodeString
)"parse(" + arg
+ ") = " + n
.getLong());
845 if (n
.getType() != Formattable::kLong
||
846 n
.getLong() != 0) errln((UnicodeString
)"FAIL: Expected 0");
848 if (U_FAILURE(status
)) errcheckln(status
, (UnicodeString
)"FAIL: Status " + u_errorName(status
));
850 //catch(Exception e) {
851 // errln((UnicodeString)"Exception caught: " + e);
855 // -------------------------------------
857 static const char *lenientAffixTestCases
[] = {
864 static const char *lenientMinusTestCases
[] = {
870 static const char *lenientCurrencyTestCases
[] = {
881 static const char *lenientNegativeCurrencyTestCases
[] = {
889 "($ 1\\u00A0000.00)",
893 static const char *lenientPercentTestCases
[] = {
902 static const char *lenientNegativePercentTestCases
[] = {
914 static const char *strictFailureTestCases
[] = {
920 #define ARRAY_SIZE(array) ((int32_t) (sizeof (array) / sizeof(array[0])))
923 * Test lenient parsing.
926 NumberFormatTest::TestLenientParse(void)
928 UErrorCode status
= U_ZERO_ERROR
;
929 DecimalFormat
*format
= new DecimalFormat("(#,##0)", status
);
932 if (format
== NULL
|| U_FAILURE(status
)) {
933 dataerrln("Unable to create DecimalFormat (#,##0) - %s", u_errorName(status
));
935 format
->setLenient(TRUE
);
936 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientAffixTestCases
); t
+= 1) {
937 UnicodeString testCase
= ctou(lenientAffixTestCases
[t
]);
939 format
->parse(testCase
, n
, status
);
940 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
942 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
||
944 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientAffixTestCases
[t
] + (UnicodeString
) "\"");
945 status
= U_ZERO_ERROR
;
951 Locale
en_US("en_US");
952 Locale
sv_SE("sv_SE");
954 NumberFormat
*mFormat
= NumberFormat::createInstance(sv_SE
, UNUM_DECIMAL
, status
);
956 if (mFormat
== NULL
|| U_FAILURE(status
)) {
957 dataerrln("Unable to create NumberFormat (sv_SE, UNUM_DECIMAL) - %s", u_errorName(status
));
959 mFormat
->setLenient(TRUE
);
960 for (int32_t t
= 0; t
< ARRAY_SIZE(lenientMinusTestCases
); t
+= 1) {
961 UnicodeString testCase
= ctou(lenientMinusTestCases
[t
]);
963 mFormat
->parse(testCase
, n
, status
);
964 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
966 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
|| n
.getLong() != -5) {
967 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientMinusTestCases
[t
] + (UnicodeString
) "\"");
968 status
= U_ZERO_ERROR
;
974 mFormat
= NumberFormat::createInstance(en_US
, UNUM_DECIMAL
, status
);
976 if (mFormat
== NULL
|| U_FAILURE(status
)) {
977 dataerrln("Unable to create NumberFormat (en_US, UNUM_DECIMAL) - %s", u_errorName(status
));
979 mFormat
->setLenient(TRUE
);
980 for (int32_t t
= 0; t
< ARRAY_SIZE(lenientMinusTestCases
); t
+= 1) {
981 UnicodeString testCase
= ctou(lenientMinusTestCases
[t
]);
983 mFormat
->parse(testCase
, n
, status
);
984 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
986 if (U_FAILURE(status
) || n
.getType() != Formattable::kLong
|| n
.getLong() != -5) {
987 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientMinusTestCases
[t
] + (UnicodeString
) "\"");
988 status
= U_ZERO_ERROR
;
994 NumberFormat
*cFormat
= NumberFormat::createInstance(en_US
, UNUM_CURRENCY
, status
);
996 if (cFormat
== NULL
|| U_FAILURE(status
)) {
997 dataerrln("Unable to create NumberFormat (en_US, UNUM_CURRENCY) - %s", u_errorName(status
));
999 cFormat
->setLenient(TRUE
);
1000 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientCurrencyTestCases
); t
+= 1) {
1001 UnicodeString testCase
= ctou(lenientCurrencyTestCases
[t
]);
1003 cFormat
->parse(testCase
, n
, status
);
1004 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1006 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
1007 n
.getLong() != 1000) {
1008 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientCurrencyTestCases
[t
] + (UnicodeString
) "\"");
1009 status
= U_ZERO_ERROR
;
1013 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientNegativeCurrencyTestCases
); t
+= 1) {
1014 UnicodeString testCase
= ctou(lenientNegativeCurrencyTestCases
[t
]);
1016 cFormat
->parse(testCase
, n
, status
);
1017 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1019 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
1020 n
.getLong() != -1000) {
1021 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientNegativeCurrencyTestCases
[t
] + (UnicodeString
) "\"");
1022 status
= U_ZERO_ERROR
;
1029 NumberFormat
*pFormat
= NumberFormat::createPercentInstance(en_US
, status
);
1031 if (pFormat
== NULL
|| U_FAILURE(status
)) {
1032 dataerrln("Unable to create NumberFormat::createPercentInstance (en_US) - %s", u_errorName(status
));
1034 pFormat
->setLenient(TRUE
);
1035 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientPercentTestCases
); t
+= 1) {
1036 UnicodeString testCase
= ctou(lenientPercentTestCases
[t
]);
1038 pFormat
->parse(testCase
, n
, status
);
1039 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getDouble());
1041 if (U_FAILURE(status
) ||n
.getType() != Formattable::kDouble
||
1042 n
.getDouble() != 0.25) {
1043 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientPercentTestCases
[t
] + (UnicodeString
) "\"");
1044 status
= U_ZERO_ERROR
;
1048 for (int32_t t
= 0; t
< ARRAY_SIZE (lenientNegativePercentTestCases
); t
+= 1) {
1049 UnicodeString testCase
= ctou(lenientNegativePercentTestCases
[t
]);
1051 pFormat
->parse(testCase
, n
, status
);
1052 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getDouble());
1054 if (U_FAILURE(status
) ||n
.getType() != Formattable::kDouble
||
1055 n
.getDouble() != -0.25) {
1056 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) lenientNegativePercentTestCases
[t
] + (UnicodeString
) "\"");
1057 status
= U_ZERO_ERROR
;
1064 // Test cases that should fail with a strict parse and pass with a
1066 NumberFormat
*nFormat
= NumberFormat::createInstance(en_US
, status
);
1068 if (nFormat
== NULL
|| U_FAILURE(status
)) {
1069 dataerrln("Unable to create NumberFormat (en_US) - %s", u_errorName(status
));
1071 // first, make sure that they fail with a strict parse
1072 for (int32_t t
= 0; t
< ARRAY_SIZE(strictFailureTestCases
); t
+= 1) {
1073 UnicodeString testCase
= ctou(strictFailureTestCases
[t
]);
1075 nFormat
->parse(testCase
, n
, status
);
1076 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1078 if (! U_FAILURE(status
)) {
1079 errln((UnicodeString
)"Strict Parse succeeded for \"" + (UnicodeString
) strictFailureTestCases
[t
] + (UnicodeString
) "\"");
1082 status
= U_ZERO_ERROR
;
1085 // then, make sure that they pass with a lenient parse
1086 nFormat
->setLenient(TRUE
);
1087 for (int32_t t
= 0; t
< ARRAY_SIZE(strictFailureTestCases
); t
+= 1) {
1088 UnicodeString testCase
= ctou(strictFailureTestCases
[t
]);
1090 nFormat
->parse(testCase
, n
, status
);
1091 logln((UnicodeString
)"parse(" + testCase
+ ") = " + n
.getLong());
1093 if (U_FAILURE(status
) ||n
.getType() != Formattable::kLong
||
1094 n
.getLong() != 1000) {
1095 errln((UnicodeString
)"Lenient parse failed for \"" + (UnicodeString
) strictFailureTestCases
[t
] + (UnicodeString
) "\"");
1096 status
= U_ZERO_ERROR
;
1104 // -------------------------------------
1107 * Test proper rounding by the format method.
1110 NumberFormatTest::TestRounding487(void)
1112 UErrorCode status
= U_ZERO_ERROR
;
1113 NumberFormat
*nf
= NumberFormat::createInstance(status
);
1114 if (U_FAILURE(status
)) {
1115 dataerrln("Error calling NumberFormat::createInstance()");
1119 roundingTest(*nf
, 0.00159999, 4, "0.0016");
1120 roundingTest(*nf
, 0.00995, 4, "0.01");
1122 roundingTest(*nf
, 12.3995, 3, "12.4");
1124 roundingTest(*nf
, 12.4999, 0, "12");
1125 roundingTest(*nf
, - 19.5, 0, "-20");
1127 if (U_FAILURE(status
)) errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
1131 * Test the functioning of the secondary grouping value.
1133 void NumberFormatTest::TestSecondaryGrouping(void) {
1134 UErrorCode status
= U_ZERO_ERROR
;
1135 DecimalFormatSymbols
US(Locale::getUS(), status
);
1136 CHECK(status
, "DecimalFormatSymbols ct");
1138 DecimalFormat
f("#,##,###", US
, status
);
1139 CHECK(status
, "DecimalFormat ct");
1141 expect2(f
, (int32_t)123456789L, "12,34,56,789");
1142 expectPat(f
, "#,##,###");
1143 f
.applyPattern("#,###", status
);
1144 CHECK(status
, "applyPattern");
1146 f
.setSecondaryGroupingSize(4);
1147 expect2(f
, (int32_t)123456789L, "12,3456,789");
1148 expectPat(f
, "#,####,###");
1149 NumberFormat
*g
= NumberFormat::createInstance(Locale("hi", "IN"), status
);
1150 CHECK_DATA(status
, "createInstance(hi_IN)");
1153 int32_t l
= (int32_t)1876543210L;
1156 // expect "1,87,65,43,210", but with Hindi digits
1159 if (out
.length() != 14) {
1162 for (int32_t i
=0; i
<out
.length(); ++i
) {
1163 UBool expectGroup
= FALSE
;
1172 // Later -- fix this to get the actual grouping
1173 // character from the resource bundle.
1174 UBool isGroup
= (out
.charAt(i
) == 0x002C);
1175 if (isGroup
!= expectGroup
) {
1182 errln((UnicodeString
)"FAIL Expected " + l
+
1183 " x hi_IN -> \"1,87,65,43,210\" (with Hindi digits), got \"" +
1184 escape(out
) + "\"");
1186 logln((UnicodeString
)"Ok " + l
+
1188 escape(out
) + "\"");
1192 void NumberFormatTest::TestWhiteSpaceParsing(void) {
1193 UErrorCode ec
= U_ZERO_ERROR
;
1194 DecimalFormatSymbols
US(Locale::getUS(), ec
);
1195 DecimalFormat
fmt("a b#0c ", US
, ec
);
1196 if (U_FAILURE(ec
)) {
1197 errcheckln(ec
, "FAIL: Constructor - %s", u_errorName(ec
));
1201 expect(fmt
, "a b1234c ", n
);
1202 expect(fmt
, "a b1234c ", n
);
1206 * Test currencies whose display name is a ChoiceFormat.
1208 void NumberFormatTest::TestComplexCurrency() {
1210 // UErrorCode ec = U_ZERO_ERROR;
1211 // Locale loc("kn", "IN", "");
1212 // NumberFormat* fmt = NumberFormat::createCurrencyInstance(loc, ec);
1213 // if (U_SUCCESS(ec)) {
1214 // expect2(*fmt, 1.0, CharsToUnicodeString("Re.\\u00A01.00"));
1215 // Use .00392625 because that's 2^-8. Any value less than 0.005 is fine.
1216 // expect(*fmt, 1.00390625, CharsToUnicodeString("Re.\\u00A01.00")); // tricky
1217 // expect2(*fmt, 12345678.0, CharsToUnicodeString("Rs.\\u00A01,23,45,678.00"));
1218 // expect2(*fmt, 0.5, CharsToUnicodeString("Rs.\\u00A00.50"));
1219 // expect2(*fmt, -1.0, CharsToUnicodeString("-Re.\\u00A01.00"));
1220 // expect2(*fmt, -10.0, CharsToUnicodeString("-Rs.\\u00A010.00"));
1222 // errln("FAIL: getCurrencyInstance(kn_IN)");
1228 // -------------------------------------
1231 NumberFormatTest::roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
)
1233 nf
.setMaximumFractionDigits(maxFractionDigits
);
1234 UnicodeString out
; nf
.format(x
, out
);
1235 logln((UnicodeString
)"" + x
+ " formats with " + maxFractionDigits
+ " fractional digits to " + out
);
1236 if (!(out
==expected
)) errln((UnicodeString
)"FAIL: Expected " + expected
);
1240 * Upgrade to alphaWorks
1242 void NumberFormatTest::TestExponent(void) {
1243 UErrorCode status
= U_ZERO_ERROR
;
1244 DecimalFormatSymbols
US(Locale::getUS(), status
);
1245 CHECK(status
, "DecimalFormatSymbols constructor");
1246 DecimalFormat
fmt1(UnicodeString("0.###E0"), US
, status
);
1247 CHECK(status
, "DecimalFormat(0.###E0)");
1248 DecimalFormat
fmt2(UnicodeString("0.###E+0"), US
, status
);
1249 CHECK(status
, "DecimalFormat(0.###E+0)");
1251 expect2(fmt1
, n
, "1.234E3");
1252 expect2(fmt2
, n
, "1.234E+3");
1253 expect(fmt1
, "1.234E+3", n
); // Either format should parse "E+3"
1257 * Upgrade to alphaWorks
1259 void NumberFormatTest::TestScientific(void) {
1260 UErrorCode status
= U_ZERO_ERROR
;
1261 DecimalFormatSymbols
US(Locale::getUS(), status
);
1262 CHECK(status
, "DecimalFormatSymbols constructor");
1264 // Test pattern round-trip
1265 const char* PAT
[] = { "#E0", "0.####E0", "00.000E00", "##0.####E000",
1266 "0.###E0;[0.###E0]" };
1267 int32_t PAT_length
= (int32_t)(sizeof(PAT
) / sizeof(PAT
[0]));
1268 int32_t DIGITS
[] = {
1269 // min int, max int, min frac, max frac
1270 0, 1, 0, 0, // "#E0"
1271 1, 1, 0, 4, // "0.####E0"
1272 2, 2, 3, 3, // "00.000E00"
1273 1, 3, 0, 4, // "##0.####E000"
1274 1, 1, 0, 3, // "0.###E0;[0.###E0]"
1276 for (int32_t i
=0; i
<PAT_length
; ++i
) {
1277 UnicodeString
pat(PAT
[i
]);
1278 DecimalFormat
df(pat
, US
, status
);
1279 CHECK(status
, "DecimalFormat constructor");
1283 logln(UnicodeString("Ok Pattern rt \"") +
1287 errln(UnicodeString("FAIL Pattern rt \"") +
1291 // Make sure digit counts match what we expect
1292 if (df
.getMinimumIntegerDigits() != DIGITS
[4*i
] ||
1293 df
.getMaximumIntegerDigits() != DIGITS
[4*i
+1] ||
1294 df
.getMinimumFractionDigits() != DIGITS
[4*i
+2] ||
1295 df
.getMaximumFractionDigits() != DIGITS
[4*i
+3]) {
1296 errln(UnicodeString("FAIL \"" + pat
+
1297 "\" min/max int; min/max frac = ") +
1298 df
.getMinimumIntegerDigits() + "/" +
1299 df
.getMaximumIntegerDigits() + ";" +
1300 df
.getMinimumFractionDigits() + "/" +
1301 df
.getMaximumFractionDigits() + ", expect " +
1303 DIGITS
[4*i
+1] + ";" +
1304 DIGITS
[4*i
+2] + "/" +
1310 // Test the constructor for default locale. We have to
1311 // manually set the default locale, as there is no
1312 // guarantee that the default locale has the same
1313 // scientific format.
1314 Locale def
= Locale::getDefault();
1315 Locale::setDefault(Locale::getUS(), status
);
1316 expect2(NumberFormat::createScientificInstance(status
),
1318 "1.2345678901E4", status
);
1319 Locale::setDefault(def
, status
);
1321 expect2(new DecimalFormat("#E0", US
, status
),
1323 "1.2345E4", status
);
1324 expect(new DecimalFormat("0E0", US
, status
),
1327 expect2(NumberFormat::createScientificInstance(Locale::getUS(), status
),
1329 "1.2345678901E4", status
);
1330 expect(new DecimalFormat("##0.###E0", US
, status
),
1333 expect(new DecimalFormat("##0.###E0", US
, status
),
1336 expect2(new DecimalFormat("##0.####E0", US
, status
),
1338 "12.345E3", status
);
1339 expect2(NumberFormat::createScientificInstance(Locale::getFrance(), status
),
1341 "1,2345678901E4", status
);
1342 expect(new DecimalFormat("##0.####E0", US
, status
),
1344 "789.12E-9", status
);
1345 expect2(new DecimalFormat("##0.####E0", US
, status
),
1348 expect(new DecimalFormat(".###E0", US
, status
),
1351 expect2(new DecimalFormat(".###E0", US
, status
),
1355 expect(new DecimalFormat[] { new DecimalFormat("#E0", US),
1356 new DecimalFormat("##E0", US),
1357 new DecimalFormat("####E0", US),
1358 new DecimalFormat("0E0", US),
1359 new DecimalFormat("00E0", US),
1360 new DecimalFormat("000E0", US),
1363 new String[] { "4.5678E7",
1372 ! Unroll this test into individual tests below...
1375 expect2(new DecimalFormat("#E0", US
, status
),
1376 (int32_t) 45678000, "4.5678E7", status
);
1377 expect2(new DecimalFormat("##E0", US
, status
),
1378 (int32_t) 45678000, "45.678E6", status
);
1379 expect2(new DecimalFormat("####E0", US
, status
),
1380 (int32_t) 45678000, "4567.8E4", status
);
1381 expect(new DecimalFormat("0E0", US
, status
),
1382 (int32_t) 45678000, "5E7", status
);
1383 expect(new DecimalFormat("00E0", US
, status
),
1384 (int32_t) 45678000, "46E6", status
);
1385 expect(new DecimalFormat("000E0", US
, status
),
1386 (int32_t) 45678000, "457E5", status
);
1388 expect(new DecimalFormat("###E0", US, status),
1389 new Object[] { new Double(0.0000123), "12.3E-6",
1390 new Double(0.000123), "123E-6",
1391 new Double(0.00123), "1.23E-3",
1392 new Double(0.0123), "12.3E-3",
1393 new Double(0.123), "123E-3",
1394 new Double(1.23), "1.23E0",
1395 new Double(12.3), "12.3E0",
1396 new Double(123), "123E0",
1397 new Double(1230), "1.23E3",
1400 ! Unroll this test into individual tests below...
1403 expect2(new DecimalFormat("###E0", US
, status
),
1404 0.0000123, "12.3E-6", status
);
1405 expect2(new DecimalFormat("###E0", US
, status
),
1406 0.000123, "123E-6", status
);
1407 expect2(new DecimalFormat("###E0", US
, status
),
1408 0.00123, "1.23E-3", status
);
1409 expect2(new DecimalFormat("###E0", US
, status
),
1410 0.0123, "12.3E-3", status
);
1411 expect2(new DecimalFormat("###E0", US
, status
),
1412 0.123, "123E-3", status
);
1413 expect2(new DecimalFormat("###E0", US
, status
),
1414 1.23, "1.23E0", status
);
1415 expect2(new DecimalFormat("###E0", US
, status
),
1416 12.3, "12.3E0", status
);
1417 expect2(new DecimalFormat("###E0", US
, status
),
1418 123.0, "123E0", status
);
1419 expect2(new DecimalFormat("###E0", US
, status
),
1420 1230.0, "1.23E3", status
);
1422 expect(new DecimalFormat("0.#E+00", US, status),
1423 new Object[] { new Double(0.00012), "1.2E-04",
1424 new Long(12000), "1.2E+04",
1427 ! Unroll this test into individual tests below...
1430 expect2(new DecimalFormat("0.#E+00", US
, status
),
1431 0.00012, "1.2E-04", status
);
1432 expect2(new DecimalFormat("0.#E+00", US
, status
),
1433 (int32_t) 12000, "1.2E+04", status
);
1437 * Upgrade to alphaWorks
1439 void NumberFormatTest::TestPad(void) {
1440 UErrorCode status
= U_ZERO_ERROR
;
1441 DecimalFormatSymbols
US(Locale::getUS(), status
);
1442 CHECK(status
, "DecimalFormatSymbols constructor");
1444 expect2(new DecimalFormat("*^##.##", US
, status
),
1445 int32_t(0), "^^^^0", status
);
1446 expect2(new DecimalFormat("*^##.##", US
, status
),
1447 -1.3, "^-1.3", status
);
1448 expect2(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US
, status
),
1449 int32_t(0), "0.0E0______ g-m/s^2", status
);
1450 expect(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US
, status
),
1451 1.0/3, "333.333E-3_ g-m/s^2", status
);
1452 expect2(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US
, status
),
1453 int32_t(0), "0.0______ g-m/s^2", status
);
1454 expect(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US
, status
),
1455 1.0/3, "0.33333__ g-m/s^2", status
);
1457 // Test padding before a sign
1458 const char *formatStr
= "*x#,###,###,##0.0#;*x(###,###,##0.0#)";
1459 expect2(new DecimalFormat(formatStr
, US
, status
),
1460 int32_t(-10), "xxxxxxxxxx(10.0)", status
);
1461 expect2(new DecimalFormat(formatStr
, US
, status
),
1462 int32_t(-1000),"xxxxxxx(1,000.0)", status
);
1463 expect2(new DecimalFormat(formatStr
, US
, status
),
1464 int32_t(-1000000),"xxx(1,000,000.0)", status
);
1465 expect2(new DecimalFormat(formatStr
, US
, status
),
1466 -100.37, "xxxxxxxx(100.37)", status
);
1467 expect2(new DecimalFormat(formatStr
, US
, status
),
1468 -10456.37, "xxxxx(10,456.37)", status
);
1469 expect2(new DecimalFormat(formatStr
, US
, status
),
1470 -1120456.37, "xx(1,120,456.37)", status
);
1471 expect2(new DecimalFormat(formatStr
, US
, status
),
1472 -112045600.37, "(112,045,600.37)", status
);
1473 expect2(new DecimalFormat(formatStr
, US
, status
),
1474 -1252045600.37,"(1,252,045,600.37)", status
);
1476 expect2(new DecimalFormat(formatStr
, US
, status
),
1477 int32_t(10), "xxxxxxxxxxxx10.0", status
);
1478 expect2(new DecimalFormat(formatStr
, US
, status
),
1479 int32_t(1000),"xxxxxxxxx1,000.0", status
);
1480 expect2(new DecimalFormat(formatStr
, US
, status
),
1481 int32_t(1000000),"xxxxx1,000,000.0", status
);
1482 expect2(new DecimalFormat(formatStr
, US
, status
),
1483 100.37, "xxxxxxxxxx100.37", status
);
1484 expect2(new DecimalFormat(formatStr
, US
, status
),
1485 10456.37, "xxxxxxx10,456.37", status
);
1486 expect2(new DecimalFormat(formatStr
, US
, status
),
1487 1120456.37, "xxxx1,120,456.37", status
);
1488 expect2(new DecimalFormat(formatStr
, US
, status
),
1489 112045600.37, "xx112,045,600.37", status
);
1490 expect2(new DecimalFormat(formatStr
, US
, status
),
1491 10252045600.37,"10,252,045,600.37", status
);
1494 // Test padding between a sign and a number
1495 const char *formatStr2
= "#,###,###,##0.0#*x;(###,###,##0.0#*x)";
1496 expect2(new DecimalFormat(formatStr2
, US
, status
),
1497 int32_t(-10), "(10.0xxxxxxxxxx)", status
);
1498 expect2(new DecimalFormat(formatStr2
, US
, status
),
1499 int32_t(-1000),"(1,000.0xxxxxxx)", status
);
1500 expect2(new DecimalFormat(formatStr2
, US
, status
),
1501 int32_t(-1000000),"(1,000,000.0xxx)", status
);
1502 expect2(new DecimalFormat(formatStr2
, US
, status
),
1503 -100.37, "(100.37xxxxxxxx)", status
);
1504 expect2(new DecimalFormat(formatStr2
, US
, status
),
1505 -10456.37, "(10,456.37xxxxx)", status
);
1506 expect2(new DecimalFormat(formatStr2
, US
, status
),
1507 -1120456.37, "(1,120,456.37xx)", status
);
1508 expect2(new DecimalFormat(formatStr2
, US
, status
),
1509 -112045600.37, "(112,045,600.37)", status
);
1510 expect2(new DecimalFormat(formatStr2
, US
, status
),
1511 -1252045600.37,"(1,252,045,600.37)", status
);
1513 expect2(new DecimalFormat(formatStr2
, US
, status
),
1514 int32_t(10), "10.0xxxxxxxxxxxx", status
);
1515 expect2(new DecimalFormat(formatStr2
, US
, status
),
1516 int32_t(1000),"1,000.0xxxxxxxxx", status
);
1517 expect2(new DecimalFormat(formatStr2
, US
, status
),
1518 int32_t(1000000),"1,000,000.0xxxxx", status
);
1519 expect2(new DecimalFormat(formatStr2
, US
, status
),
1520 100.37, "100.37xxxxxxxxxx", status
);
1521 expect2(new DecimalFormat(formatStr2
, US
, status
),
1522 10456.37, "10,456.37xxxxxxx", status
);
1523 expect2(new DecimalFormat(formatStr2
, US
, status
),
1524 1120456.37, "1,120,456.37xxxx", status
);
1525 expect2(new DecimalFormat(formatStr2
, US
, status
),
1526 112045600.37, "112,045,600.37xx", status
);
1527 expect2(new DecimalFormat(formatStr2
, US
, status
),
1528 10252045600.37,"10,252,045,600.37", status
);
1530 //testing the setPadCharacter(UnicodeString) and getPadCharacterString()
1531 DecimalFormat
fmt("#", US
, status
);
1532 CHECK(status
, "DecimalFormat constructor");
1533 UnicodeString
padString("P");
1534 fmt
.setPadCharacter(padString
);
1535 expectPad(fmt
, "*P##.##", DecimalFormat::kPadBeforePrefix
, 5, padString
);
1536 fmt
.setPadCharacter((UnicodeString
)"^");
1537 expectPad(fmt
, "*^#", DecimalFormat::kPadBeforePrefix
, 1, (UnicodeString
)"^");
1538 //commented untill implementation is complete
1539 /* fmt.setPadCharacter((UnicodeString)"^^^");
1540 expectPad(fmt, "*^^^#", DecimalFormat::kPadBeforePrefix, 3, (UnicodeString)"^^^");
1542 padString.append((UChar)0x0061);
1543 padString.append((UChar)0x0302);
1544 fmt.setPadCharacter(padString);
1545 UChar patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000};
1546 UnicodeString pattern(patternChars);
1547 expectPad(fmt, pattern , DecimalFormat::kPadBeforePrefix, 4, padString);
1553 * Upgrade to alphaWorks
1555 void NumberFormatTest::TestPatterns2(void) {
1556 UErrorCode status
= U_ZERO_ERROR
;
1557 DecimalFormatSymbols
US(Locale::getUS(), status
);
1558 CHECK(status
, "DecimalFormatSymbols constructor");
1560 DecimalFormat
fmt("#", US
, status
);
1561 CHECK(status
, "DecimalFormat constructor");
1563 UChar hat
= 0x005E; /*^*/
1565 expectPad(fmt
, "*^#", DecimalFormat::kPadBeforePrefix
, 1, hat
);
1566 expectPad(fmt
, "$*^#", DecimalFormat::kPadAfterPrefix
, 2, hat
);
1567 expectPad(fmt
, "#*^", DecimalFormat::kPadBeforeSuffix
, 1, hat
);
1568 expectPad(fmt
, "#$*^", DecimalFormat::kPadAfterSuffix
, 2, hat
);
1569 expectPad(fmt
, "$*^$#", ILLEGAL
);
1570 expectPad(fmt
, "#$*^$", ILLEGAL
);
1571 expectPad(fmt
, "'pre'#,##0*x'post'", DecimalFormat::kPadBeforeSuffix
,
1572 12, (UChar
)0x0078 /*x*/);
1573 expectPad(fmt
, "''#0*x", DecimalFormat::kPadBeforeSuffix
,
1574 3, (UChar
)0x0078 /*x*/);
1575 expectPad(fmt
, "'I''ll'*a###.##", DecimalFormat::kPadAfterPrefix
,
1576 10, (UChar
)0x0061 /*a*/);
1578 fmt
.applyPattern("AA#,##0.00ZZ", status
);
1579 CHECK(status
, "applyPattern");
1580 fmt
.setPadCharacter(hat
);
1582 fmt
.setFormatWidth(10);
1584 fmt
.setPadPosition(DecimalFormat::kPadBeforePrefix
);
1585 expectPat(fmt
, "*^AA#,##0.00ZZ");
1587 fmt
.setPadPosition(DecimalFormat::kPadBeforeSuffix
);
1588 expectPat(fmt
, "AA#,##0.00*^ZZ");
1590 fmt
.setPadPosition(DecimalFormat::kPadAfterSuffix
);
1591 expectPat(fmt
, "AA#,##0.00ZZ*^");
1594 UnicodeString
exp("AA*^#,##0.00ZZ", "");
1595 fmt
.setFormatWidth(12);
1596 fmt
.setPadPosition(DecimalFormat::kPadAfterPrefix
);
1597 expectPat(fmt
, exp
);
1599 fmt
.setFormatWidth(13);
1601 expectPat(fmt
, "AA*^##,##0.00ZZ");
1603 fmt
.setFormatWidth(14);
1605 expectPat(fmt
, "AA*^###,##0.00ZZ");
1607 fmt
.setFormatWidth(15);
1609 expectPat(fmt
, "AA*^####,##0.00ZZ"); // This is the interesting case
1611 fmt
.setFormatWidth(16);
1612 // 12 34567890123456
1613 expectPat(fmt
, "AA*^#,###,##0.00ZZ");
1616 void NumberFormatTest::TestSurrogateSupport(void) {
1617 UErrorCode status
= U_ZERO_ERROR
;
1618 DecimalFormatSymbols
custom(Locale::getUS(), status
);
1619 CHECK(status
, "DecimalFormatSymbols constructor");
1621 custom
.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol
, "decimal");
1622 custom
.setSymbol(DecimalFormatSymbols::kPlusSignSymbol
, "plus");
1623 custom
.setSymbol(DecimalFormatSymbols::kMinusSignSymbol
, " minus ");
1624 custom
.setSymbol(DecimalFormatSymbols::kExponentialSymbol
, "exponent");
1626 UnicodeString
patternStr("*\\U00010000##.##", "");
1627 patternStr
= patternStr
.unescape();
1628 UnicodeString
expStr("\\U00010000\\U00010000\\U00010000\\U000100000", "");
1629 expStr
= expStr
.unescape();
1630 expect2(new DecimalFormat(patternStr
, custom
, status
),
1631 int32_t(0), expStr
, status
);
1633 status
= U_ZERO_ERROR
;
1634 expect2(new DecimalFormat("*^##.##", custom
, status
),
1635 int32_t(0), "^^^^0", status
);
1636 status
= U_ZERO_ERROR
;
1637 expect2(new DecimalFormat("##.##", custom
, status
),
1638 -1.3, " minus 1decimal3", status
);
1639 status
= U_ZERO_ERROR
;
1640 expect2(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom
, status
),
1641 int32_t(0), "0decimal0exponent0 g-m/s^2", status
);
1642 status
= U_ZERO_ERROR
;
1643 expect(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom
, status
),
1644 1.0/3, "333decimal333exponent minus 3 g-m/s^2", status
);
1645 status
= U_ZERO_ERROR
;
1646 expect2(new DecimalFormat("##0.0#### 'g-m/s^2'", custom
, status
),
1647 int32_t(0), "0decimal0 g-m/s^2", status
);
1648 status
= U_ZERO_ERROR
;
1649 expect(new DecimalFormat("##0.0#### 'g-m/s^2'", custom
, status
),
1650 1.0/3, "0decimal33333 g-m/s^2", status
);
1652 UnicodeString
zero((UChar32
)0x10000);
1653 UnicodeString
one((UChar32
)0x10001);
1654 UnicodeString
two((UChar32
)0x10002);
1655 UnicodeString
five((UChar32
)0x10005);
1656 custom
.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol
, zero
);
1657 custom
.setSymbol(DecimalFormatSymbols::kOneDigitSymbol
, one
);
1658 custom
.setSymbol(DecimalFormatSymbols::kTwoDigitSymbol
, two
);
1659 custom
.setSymbol(DecimalFormatSymbols::kFiveDigitSymbol
, five
);
1660 expStr
= UnicodeString("\\U00010001decimal\\U00010002\\U00010005\\U00010000", "");
1661 expStr
= expStr
.unescape();
1662 status
= U_ZERO_ERROR
;
1663 expect2(new DecimalFormat("##0.000", custom
, status
),
1664 1.25, expStr
, status
);
1666 custom
.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol
, (UChar
)0x30);
1667 custom
.setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "units of money");
1668 custom
.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol
, "money separator");
1669 patternStr
= UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'");
1670 patternStr
= patternStr
.unescape();
1671 expStr
= UnicodeString(" minus 20money separator00 units of money in your bank account", "");
1672 status
= U_ZERO_ERROR
;
1673 expect2(new DecimalFormat(patternStr
, custom
, status
),
1674 int32_t(-20), expStr
, status
);
1676 custom
.setSymbol(DecimalFormatSymbols::kPercentSymbol
, "percent");
1677 patternStr
= "'You''ve lost ' -0.00 %' of your money today'";
1678 patternStr
= patternStr
.unescape();
1679 expStr
= UnicodeString(" minus You've lost minus 2000decimal00 percent of your money today", "");
1680 status
= U_ZERO_ERROR
;
1681 expect2(new DecimalFormat(patternStr
, custom
, status
),
1682 int32_t(-20), expStr
, status
);
1685 void NumberFormatTest::TestCurrencyPatterns(void) {
1686 int32_t i
, locCount
;
1687 const Locale
* locs
= NumberFormat::getAvailableLocales(locCount
);
1688 for (i
=0; i
<locCount
; ++i
) {
1689 UErrorCode ec
= U_ZERO_ERROR
;
1690 NumberFormat
* nf
= NumberFormat::createCurrencyInstance(locs
[i
], ec
);
1691 if (U_FAILURE(ec
)) {
1692 errln("FAIL: Can't create NumberFormat(%s) - %s", locs
[i
].getName(), u_errorName(ec
));
1694 // Make sure currency formats do not have a variable number
1695 // of fraction digits
1696 int32_t min
= nf
->getMinimumFractionDigits();
1697 int32_t max
= nf
->getMaximumFractionDigits();
1701 nf
->format(1.125, b
);
1702 errln((UnicodeString
)"FAIL: " + locs
[i
].getName() +
1703 " min fraction digits != max fraction digits; "
1704 "x 1.0 => " + escape(a
) +
1705 "; x 1.125 => " + escape(b
));
1708 // Make sure EURO currency formats have exactly 2 fraction digits
1709 DecimalFormat
* df
= dynamic_cast<DecimalFormat
*>(nf
);
1711 if (u_strcmp(EUR
, df
->getCurrency()) == 0) {
1712 if (min
!= 2 || max
!= 2) {
1715 errln((UnicodeString
)"FAIL: " + locs
[i
].getName() +
1716 " is a EURO format but it does not have 2 fraction digits; "
1727 void NumberFormatTest::TestRegCurrency(void) {
1728 #if !UCONFIG_NO_SERVICE
1729 UErrorCode status
= U_ZERO_ERROR
;
1731 ucurr_forLocale("en_US", USD
, 4, &status
);
1733 ucurr_forLocale("ja_JP", YEN
, 4, &status
);
1735 static const UChar QQQ
[] = {0x51, 0x51, 0x51, 0};
1736 if(U_FAILURE(status
)) {
1737 errcheckln(status
, "Unable to get currency for locale, error %s", u_errorName(status
));
1741 UCurrRegistryKey enkey
= ucurr_register(YEN
, "en_US", &status
);
1742 UCurrRegistryKey enUSEUROkey
= ucurr_register(QQQ
, "en_US_EURO", &status
);
1744 ucurr_forLocale("en_US", TMP
, 4, &status
);
1745 if (u_strcmp(YEN
, TMP
) != 0) {
1746 errln("FAIL: didn't return YEN registered for en_US");
1749 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1750 if (u_strcmp(QQQ
, TMP
) != 0) {
1751 errln("FAIL: didn't return QQQ for en_US_EURO");
1754 int32_t fallbackLen
= ucurr_forLocale("en_XX_BAR", TMP
, 4, &status
);
1756 errln("FAIL: tried to fallback en_XX_BAR");
1758 status
= U_ZERO_ERROR
; // reset
1760 if (!ucurr_unregister(enkey
, &status
)) {
1761 errln("FAIL: couldn't unregister enkey");
1764 ucurr_forLocale("en_US", TMP
, 4, &status
);
1765 if (u_strcmp(USD
, TMP
) != 0) {
1766 errln("FAIL: didn't return USD for en_US after unregister of en_US");
1768 status
= U_ZERO_ERROR
; // reset
1770 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1771 if (u_strcmp(QQQ
, TMP
) != 0) {
1772 errln("FAIL: didn't return QQQ for en_US_EURO after unregister of en_US");
1775 ucurr_forLocale("en_US_BLAH", TMP
, 4, &status
);
1776 if (u_strcmp(USD
, TMP
) != 0) {
1777 errln("FAIL: could not find USD for en_US_BLAH after unregister of en");
1779 status
= U_ZERO_ERROR
; // reset
1781 if (!ucurr_unregister(enUSEUROkey
, &status
)) {
1782 errln("FAIL: couldn't unregister enUSEUROkey");
1785 ucurr_forLocale("en_US_EURO", TMP
, 4, &status
);
1786 if (u_strcmp(EUR
, TMP
) != 0) {
1787 errln("FAIL: didn't return EUR for en_US_EURO after unregister of en_US_EURO");
1789 status
= U_ZERO_ERROR
; // reset
1793 void NumberFormatTest::TestCurrencyNames(void) {
1794 // Do a basic check of getName()
1795 // USD { "US$", "US Dollar" } // 04/04/1792-
1796 UErrorCode ec
= U_ZERO_ERROR
;
1797 static const UChar USD
[] = {0x55, 0x53, 0x44, 0}; /*USD*/
1798 static const UChar USX
[] = {0x55, 0x53, 0x58, 0}; /*USX*/
1799 static const UChar CAD
[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
1800 static const UChar ITL
[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
1801 UBool isChoiceFormat
;
1803 const UBool possibleDataError
= TRUE
;
1804 // Warning: HARD-CODED LOCALE DATA in this test. If it fails, CHECK
1805 // THE LOCALE DATA before diving into the code.
1806 assertEquals("USD.getName(SYMBOL_NAME)",
1808 UnicodeString(ucurr_getName(USD
, "en",
1810 &isChoiceFormat
, &len
, &ec
)),
1812 assertEquals("USD.getName(LONG_NAME)",
1813 UnicodeString("US Dollar"),
1814 UnicodeString(ucurr_getName(USD
, "en",
1816 &isChoiceFormat
, &len
, &ec
)),
1818 assertEquals("CAD.getName(SYMBOL_NAME)",
1819 UnicodeString("CA$"),
1820 UnicodeString(ucurr_getName(CAD
, "en",
1822 &isChoiceFormat
, &len
, &ec
)),
1824 assertEquals("CAD.getName(SYMBOL_NAME)",
1826 UnicodeString(ucurr_getName(CAD
, "en_CA",
1828 &isChoiceFormat
, &len
, &ec
)),
1830 assertEquals("USD.getName(SYMBOL_NAME) in en_AU",
1831 UnicodeString("US$"),
1832 UnicodeString(ucurr_getName(USD
, "en_AU",
1834 &isChoiceFormat
, &len
, &ec
)),
1836 assertEquals("CAD.getName(SYMBOL_NAME)",
1837 UnicodeString("CA$"),
1838 UnicodeString(ucurr_getName(CAD
, "en_AU",
1840 &isChoiceFormat
, &len
, &ec
)),
1842 assertEquals("USX.getName(LONG_NAME)",
1843 UnicodeString("USX"),
1844 UnicodeString(ucurr_getName(USX
, "en_US",
1846 &isChoiceFormat
, &len
, &ec
)),
1848 assertSuccess("ucurr_getName", ec
);
1852 // Test that a default or fallback warning is being returned. JB 4239.
1853 ucurr_getName(CAD
, "es_ES", UCURR_LONG_NAME
, &isChoiceFormat
,
1855 assertTrue("ucurr_getName (es_ES fallback)",
1856 U_USING_FALLBACK_WARNING
== ec
, TRUE
, possibleDataError
);
1858 ucurr_getName(CAD
, "zh_TW", UCURR_LONG_NAME
, &isChoiceFormat
,
1860 assertTrue("ucurr_getName (zh_TW fallback)",
1861 U_USING_FALLBACK_WARNING
== ec
, TRUE
, possibleDataError
);
1863 ucurr_getName(CAD
, "en_US", UCURR_LONG_NAME
, &isChoiceFormat
,
1865 assertTrue("ucurr_getName (en_US default)",
1866 U_USING_DEFAULT_WARNING
== ec
|| U_USING_FALLBACK_WARNING
== ec
, TRUE
);
1868 ucurr_getName(CAD
, "ti", UCURR_LONG_NAME
, &isChoiceFormat
,
1870 assertTrue("ucurr_getName (ti default)",
1871 U_USING_DEFAULT_WARNING
== ec
, TRUE
);
1873 // Test that a default warning is being returned when falling back to root. JB 4536.
1874 ucurr_getName(ITL
, "cy", UCURR_LONG_NAME
, &isChoiceFormat
,
1876 assertTrue("ucurr_getName (cy default to root)",
1877 U_USING_DEFAULT_WARNING
== ec
, TRUE
);
1879 // TODO add more tests later
1882 void NumberFormatTest::TestCurrencyUnit(void){
1883 UErrorCode ec
= U_ZERO_ERROR
;
1884 static const UChar USD
[] = {85, 83, 68, 0}; /*USD*/
1885 CurrencyUnit
cu(USD
, ec
);
1886 assertSuccess("CurrencyUnit", ec
);
1888 const UChar
* r
= cu
.getISOCurrency(); // who is the buffer owner ?
1889 assertEquals("getISOCurrency()", USD
, r
);
1891 CurrencyUnit
cu2(cu
);
1893 errln("CurrencyUnit copy constructed object should be same");
1896 CurrencyUnit
* cu3
= (CurrencyUnit
*)cu
.clone();
1898 errln("CurrencyUnit cloned object should be same");
1903 void NumberFormatTest::TestCurrencyAmount(void){
1904 UErrorCode ec
= U_ZERO_ERROR
;
1905 static const UChar USD
[] = {85, 83, 68, 0}; /*USD*/
1906 CurrencyAmount
ca(9, USD
, ec
);
1907 assertSuccess("CurrencyAmount", ec
);
1909 CurrencyAmount
ca2(ca
);
1911 errln("CurrencyAmount copy constructed object should be same");
1916 errln("CurrencyAmount assigned object should be same");
1919 CurrencyAmount
*ca3
= (CurrencyAmount
*)ca
.clone();
1921 errln("CurrencyAmount cloned object should be same");
1926 void NumberFormatTest::TestSymbolsWithBadLocale(void) {
1928 static const char *badLocales
[] = {
1929 // length < ULOC_FULLNAME_CAPACITY
1930 "x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME",
1932 // length > ULOC_FULLNAME_CAPACITY
1933 "x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME"
1934 }; // expect U_USING_DEFAULT_WARNING for both
1937 for (i
= 0; i
< sizeof(badLocales
) / sizeof(char*); i
++) {
1938 const char *localeName
= badLocales
[i
];
1939 Locale
locBad(localeName
);
1940 UErrorCode status
= U_ZERO_ERROR
;
1941 UnicodeString
intlCurrencySymbol((UChar
)0xa4);
1943 intlCurrencySymbol
.append((UChar
)0xa4);
1945 logln("Current locale is %s", Locale::getDefault().getName());
1946 Locale::setDefault(locBad
, status
);
1947 logln("Current locale is %s", Locale::getDefault().getName());
1948 DecimalFormatSymbols
mySymbols(status
);
1949 if (status
!= U_USING_DEFAULT_WARNING
) {
1950 errln("DecimalFormatSymbols should return U_USING_DEFAULT_WARNING.");
1952 if (strcmp(mySymbols
.getLocale().getName(), locBad
.getName()) != 0) {
1953 errln("DecimalFormatSymbols does not have the right locale.", locBad
.getName());
1955 int symbolEnum
= (int)DecimalFormatSymbols::kDecimalSeparatorSymbol
;
1956 for (; symbolEnum
< (int)DecimalFormatSymbols::kFormatSymbolCount
; symbolEnum
++) {
1957 UnicodeString symbolString
= mySymbols
.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol
)symbolEnum
);
1958 logln(UnicodeString("DecimalFormatSymbols[") + symbolEnum
+ UnicodeString("] = ") + prettify(symbolString
));
1959 if (symbolString
.length() == 0
1960 && symbolEnum
!= (int)DecimalFormatSymbols::kGroupingSeparatorSymbol
1961 && symbolEnum
!= (int)DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol
)
1963 errln("DecimalFormatSymbols has an empty string at index %d.", symbolEnum
);
1967 status
= U_ZERO_ERROR
;
1968 Locale::setDefault(locDefault
, status
);
1969 logln("Current locale is %s", Locale::getDefault().getName());
1974 * Check that adoptDecimalFormatSymbols and setDecimalFormatSymbols
1975 * behave the same, except for memory ownership semantics. (No
1976 * version of this test on Java, since Java has only one method.)
1978 void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
1979 UErrorCode ec
= U_ZERO_ERROR
;
1980 DecimalFormatSymbols
*sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
1981 if (U_FAILURE(ec
)) {
1982 errcheckln(ec
, "Fail: DecimalFormatSymbols constructor - %s", u_errorName(ec
));
1986 UnicodeString
pat(" #,##0.00");
1987 pat
.insert(0, (UChar
)0x00A4);
1988 DecimalFormat
fmt(pat
, sym
, ec
);
1989 if (U_FAILURE(ec
)) {
1990 errln("Fail: DecimalFormat constructor");
1995 fmt
.format(2350.75, str
);
1996 if (str
== "$ 2,350.75") {
1999 dataerrln("Fail: " + str
+ ", expected $ 2,350.75");
2002 sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
2003 if (U_FAILURE(ec
)) {
2004 errln("Fail: DecimalFormatSymbols constructor");
2008 sym
->setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "Q");
2009 fmt
.adoptDecimalFormatSymbols(sym
);
2012 fmt
.format(2350.75, str
);
2013 if (str
== "Q 2,350.75") {
2016 dataerrln("Fail: adoptDecimalFormatSymbols -> " + str
+ ", expected Q 2,350.75");
2019 sym
= new DecimalFormatSymbols(Locale::getUS(), ec
);
2020 if (U_FAILURE(ec
)) {
2021 errln("Fail: DecimalFormatSymbols constructor");
2025 DecimalFormat
fmt2(pat
, sym
, ec
);
2026 if (U_FAILURE(ec
)) {
2027 errln("Fail: DecimalFormat constructor");
2031 DecimalFormatSymbols
sym2(Locale::getUS(), ec
);
2032 if (U_FAILURE(ec
)) {
2033 errln("Fail: DecimalFormatSymbols constructor");
2036 sym2
.setSymbol(DecimalFormatSymbols::kCurrencySymbol
, "Q");
2037 fmt2
.setDecimalFormatSymbols(sym2
);
2040 fmt2
.format(2350.75, str
);
2041 if (str
== "Q 2,350.75") {
2044 dataerrln("Fail: setDecimalFormatSymbols -> " + str
+ ", expected Q 2,350.75");
2048 void NumberFormatTest::TestPerMill() {
2049 UErrorCode ec
= U_ZERO_ERROR
;
2051 DecimalFormat
fmt(ctou("###.###\\u2030"), ec
);
2052 if (!assertSuccess("DecimalFormat ct", ec
)) return;
2053 assertEquals("0.4857 x ###.###\\u2030",
2054 ctou("485.7\\u2030"), fmt
.format(0.4857, str
));
2056 DecimalFormatSymbols
sym(Locale::getUS(), ec
);
2057 sym
.setSymbol(DecimalFormatSymbols::kPerMillSymbol
, ctou("m"));
2058 DecimalFormat
fmt2("", sym
, ec
);
2059 fmt2
.applyLocalizedPattern("###.###m", ec
);
2060 if (!assertSuccess("setup", ec
)) return;
2062 assertEquals("0.4857 x ###.###m",
2063 "485.7m", fmt2
.format(0.4857, str
));
2067 * Generic test for patterns that should be legal/illegal.
2069 void NumberFormatTest::TestIllegalPatterns() {
2071 // Prefix with "-:" for illegal patterns
2072 // Prefix with "+:" for legal patterns
2073 const char* DATA
[] = {
2074 // Unquoted special characters in the suffix are illegal
2079 for (int32_t i
=0; DATA
[i
]; ++i
) {
2080 const char* pat
=DATA
[i
];
2081 UBool valid
= (*pat
) == '+';
2083 UErrorCode ec
= U_ZERO_ERROR
;
2084 DecimalFormat
fmt(pat
, ec
); // locale doesn't matter here
2085 if (U_SUCCESS(ec
) == valid
) {
2086 logln("Ok: pattern \"%s\": %s",
2087 pat
, u_errorName(ec
));
2089 errcheckln(ec
, "FAIL: pattern \"%s\" should have %s; got %s",
2090 pat
, (valid
?"succeeded":"failed"),
2096 //----------------------------------------------------------------------
2098 static const char* KEYWORDS
[] = {
2099 /*0*/ "ref=", // <reference pattern to parse numbers>
2100 /*1*/ "loc=", // <locale for formats>
2101 /*2*/ "f:", // <pattern or '-'> <number> <exp. string>
2102 /*3*/ "fp:", // <pattern or '-'> <number> <exp. string> <exp. number>
2103 /*4*/ "rt:", // <pattern or '-'> <(exp.) number> <(exp.) string>
2104 /*5*/ "p:", // <pattern or '-'> <string> <exp. number>
2105 /*6*/ "perr:", // <pattern or '-'> <invalid string>
2106 /*7*/ "pat:", // <pattern or '-'> <exp. toPattern or '-' or 'err'>
2107 /*8*/ "fpc:", // <pattern or '-'> <curr.amt> <exp. string> <exp. curr.amt>
2112 * Return an integer representing the next token from this
2113 * iterator. The integer will be an index into the given list, or
2114 * -1 if there are no more tokens, or -2 if the token is not on
2117 static int32_t keywordIndex(const UnicodeString
& tok
) {
2118 for (int32_t i
=0; KEYWORDS
[i
]!=0; ++i
) {
2119 if (tok
==KEYWORDS
[i
]) {
2127 * Parse a CurrencyAmount using the given NumberFormat, with
2128 * the 'delim' character separating the number and the currency.
2130 static void parseCurrencyAmount(const UnicodeString
& str
,
2131 const NumberFormat
& fmt
,
2133 Formattable
& result
,
2135 UnicodeString num
, cur
;
2136 int32_t i
= str
.indexOf(delim
);
2137 str
.extractBetween(0, i
, num
);
2138 str
.extractBetween(i
+1, INT32_MAX
, cur
);
2140 fmt
.parse(num
, n
, ec
);
2141 result
.adoptObject(new CurrencyAmount(n
, cur
.getTerminatedBuffer(), ec
));
2144 void NumberFormatTest::TestCases() {
2145 UErrorCode ec
= U_ZERO_ERROR
;
2146 TextFile
reader("NumberFormatTestCases.txt", "UTF8", ec
);
2147 if (U_FAILURE(ec
)) {
2148 dataerrln("Couldn't open NumberFormatTestCases.txt");
2151 TokenIterator
tokens(&reader
);
2153 Locale
loc("en", "US", "");
2154 DecimalFormat
*ref
= 0, *fmt
= 0;
2155 MeasureFormat
*mfmt
= 0;
2156 UnicodeString pat
, tok
, mloc
, str
, out
, where
, currAmt
;
2161 if (!tokens
.next(tok
, ec
)) {
2164 where
= UnicodeString("(") + tokens
.getLineNumber() + ") ";
2165 int32_t cmd
= keywordIndex(tok
);
2168 // ref= <reference pattern>
2169 if (!tokens
.next(tok
, ec
)) goto error
;
2171 ref
= new DecimalFormat(tok
,
2172 new DecimalFormatSymbols(Locale::getUS(), ec
), ec
);
2173 if (U_FAILURE(ec
)) {
2174 dataerrln("Error constructing DecimalFormat");
2180 if (!tokens
.next(tok
, ec
)) goto error
;
2181 loc
= Locale::createFromName(CharString().appendInvariantChars(tok
, ec
).data());
2187 if (!tokens
.next(tok
, ec
)) goto error
;
2191 fmt
= new DecimalFormat(pat
, new DecimalFormatSymbols(loc
, ec
), ec
);
2192 if (U_FAILURE(ec
)) {
2193 errln("FAIL: " + where
+ "Pattern \"" + pat
+ "\": " + u_errorName(ec
));
2195 if (!tokens
.next(tok
, ec
)) goto error
;
2196 if (!tokens
.next(tok
, ec
)) goto error
;
2198 if (!tokens
.next(tok
, ec
)) goto error
;
2203 if (cmd
== 2 || cmd
== 3 || cmd
== 4) {
2204 // f: <pattern or '-'> <number> <exp. string>
2205 // fp: <pattern or '-'> <number> <exp. string> <exp. number>
2206 // rt: <pattern or '-'> <number> <string>
2208 if (!tokens
.next(num
, ec
)) goto error
;
2209 if (!tokens
.next(str
, ec
)) goto error
;
2210 ref
->parse(num
, n
, ec
);
2211 assertSuccess("parse", ec
);
2212 assertEquals(where
+ "\"" + pat
+ "\".format(" + num
+ ")",
2213 str
, fmt
->format(n
, out
.remove(), ec
));
2214 assertSuccess("format", ec
);
2215 if (cmd
== 3) { // fp:
2216 if (!tokens
.next(num
, ec
)) goto error
;
2217 ref
->parse(num
, n
, ec
);
2218 assertSuccess("parse", ec
);
2220 if (cmd
!= 2) { // != f:
2222 fmt
->parse(str
, m
, ec
);
2223 assertSuccess("parse", ec
);
2224 assertEquals(where
+ "\"" + pat
+ "\".parse(\"" + str
+ "\")",
2228 // p: <pattern or '-'> <string to parse> <exp. number>
2230 UnicodeString expstr
;
2231 if (!tokens
.next(str
, ec
)) goto error
;
2232 if (!tokens
.next(expstr
, ec
)) goto error
;
2234 ref
->parse(expstr
, exp
, ec
);
2235 assertSuccess("parse", ec
);
2236 fmt
->parse(str
, n
, ec
);
2237 assertSuccess("parse", ec
);
2238 assertEquals(where
+ "\"" + pat
+ "\".parse(\"" + str
+ "\")",
2243 if (!tokens
.next(tok
, ec
)) goto error
;
2247 mfmt
= MeasureFormat::createCurrencyFormat(
2248 Locale::createFromName(
2249 CharString().appendInvariantChars(mloc
, ec
).data()), ec
);
2250 if (U_FAILURE(ec
)) {
2251 errln("FAIL: " + where
+ "Loc \"" + mloc
+ "\": " + u_errorName(ec
));
2253 if (!tokens
.next(tok
, ec
)) goto error
;
2254 if (!tokens
.next(tok
, ec
)) goto error
;
2255 if (!tokens
.next(tok
, ec
)) goto error
;
2259 // fpc: <loc or '-'> <curr.amt> <exp. string> <exp. curr.amt>
2260 if (!tokens
.next(currAmt
, ec
)) goto error
;
2261 if (!tokens
.next(str
, ec
)) goto error
;
2262 parseCurrencyAmount(currAmt
, *ref
, (UChar
)0x2F/*'/'*/, n
, ec
);
2263 if (assertSuccess("parseCurrencyAmount", ec
)) {
2264 assertEquals(where
+ "getCurrencyFormat(" + mloc
+ ").format(" + currAmt
+ ")",
2265 str
, mfmt
->format(n
, out
.remove(), ec
));
2266 assertSuccess("format", ec
);
2268 if (!tokens
.next(currAmt
, ec
)) goto error
;
2269 parseCurrencyAmount(currAmt
, *ref
, (UChar
)0x2F/*'/'*/, n
, ec
);
2270 if (assertSuccess("parseCurrencyAmount", ec
)) {
2273 mfmt
->parseObject(str
, m
, ec
);
2274 if (assertSuccess("parseCurrency", ec
)) {
2275 assertEquals(where
+ "getCurrencyFormat(" + mloc
+ ").parse(\"" + str
+ "\")",
2278 errln("FAIL: source " + str
);
2283 // perr: <pattern or '-'> <invalid string>
2284 errln("FAIL: Under construction");
2287 // pat: <pattern> <exp. toPattern, or '-' or 'err'>
2288 UnicodeString testpat
;
2289 UnicodeString exppat
;
2290 if (!tokens
.next(testpat
, ec
)) goto error
;
2291 if (!tokens
.next(exppat
, ec
)) goto error
;
2292 UBool err
= exppat
== "err";
2293 UBool existingPat
= FALSE
;
2294 if (testpat
== "-") {
2296 errln("FAIL: " + where
+ "Invalid command \"pat: - err\"");
2302 if (exppat
== "-") exppat
= testpat
;
2303 DecimalFormat
* f
= 0;
2304 UErrorCode ec2
= U_ZERO_ERROR
;
2308 f
= new DecimalFormat(testpat
, ec2
);
2310 if (U_SUCCESS(ec2
)) {
2312 errln("FAIL: " + where
+ "Invalid pattern \"" + testpat
+
2316 assertEquals(where
+ "\"" + testpat
+ "\".toPattern()",
2317 exppat
, f
->toPattern(pat2
));
2321 logln("Ok: " + where
+ "Invalid pattern \"" + testpat
+
2322 "\" failed: " + u_errorName(ec2
));
2324 errln("FAIL: " + where
+ "Valid pattern \"" + testpat
+
2325 "\" failed: " + u_errorName(ec2
));
2328 if (!existingPat
) delete f
;
2331 errln("FAIL: " + where
+ "Unknown command \"" + tok
+ "\"");
2338 if (U_SUCCESS(ec
)) {
2339 errln("FAIL: Unexpected EOF");
2341 errcheckln(ec
, "FAIL: " + where
+ "Unexpected " + u_errorName(ec
));
2351 //----------------------------------------------------------------------
2353 //----------------------------------------------------------------------
2355 UBool
NumberFormatTest::equalValue(const Formattable
& a
, const Formattable
& b
) {
2356 if (a
.getType() == b
.getType()) {
2360 if (a
.getType() == Formattable::kLong
) {
2361 if (b
.getType() == Formattable::kInt64
) {
2362 return a
.getLong() == b
.getLong();
2363 } else if (b
.getType() == Formattable::kDouble
) {
2364 return (double) a
.getLong() == b
.getDouble(); // TODO check use of double instead of long
2366 } else if (a
.getType() == Formattable::kDouble
) {
2367 if (b
.getType() == Formattable::kLong
) {
2368 return a
.getDouble() == (double) b
.getLong();
2369 } else if (b
.getType() == Formattable::kInt64
) {
2370 return a
.getDouble() == (double)b
.getInt64();
2372 } else if (a
.getType() == Formattable::kInt64
) {
2373 if (b
.getType() == Formattable::kLong
) {
2374 return a
.getInt64() == (int64_t)b
.getLong();
2375 } else if (b
.getType() == Formattable::kDouble
) {
2376 return a
.getInt64() == (int64_t)b
.getDouble();
2382 void NumberFormatTest::expect3(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
) {
2383 // Don't round-trip format test, since we explicitly do it
2384 expect_rbnf(fmt
, n
, str
, FALSE
);
2385 expect_rbnf(fmt
, str
, n
);
2388 void NumberFormatTest::expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
) {
2389 // Don't round-trip format test, since we explicitly do it
2390 expect(fmt
, n
, str
, FALSE
);
2391 expect(fmt
, str
, n
);
2394 void NumberFormatTest::expect2(NumberFormat
* fmt
, const Formattable
& n
,
2395 const UnicodeString
& exp
,
2396 UErrorCode status
) {
2397 if (fmt
== NULL
|| U_FAILURE(status
)) {
2398 dataerrln("FAIL: NumberFormat constructor");
2400 expect2(*fmt
, n
, exp
);
2405 void NumberFormatTest::expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
) {
2406 UErrorCode status
= U_ZERO_ERROR
;
2408 fmt
.parse(str
, num
, status
);
2409 if (U_FAILURE(status
)) {
2410 dataerrln(UnicodeString("FAIL: Parse failed for \"") + str
+ "\" - " + u_errorName(status
));
2414 ((DecimalFormat
*) &fmt
)->toPattern(pat
);
2415 if (equalValue(num
, n
)) {
2416 logln(UnicodeString("Ok \"") + str
+ "\" x " +
2420 dataerrln(UnicodeString("FAIL \"") + str
+ "\" x " +
2422 toString(num
) + ", expected " + toString(n
));
2426 void NumberFormatTest::expect_rbnf(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
) {
2427 UErrorCode status
= U_ZERO_ERROR
;
2429 fmt
.parse(str
, num
, status
);
2430 if (U_FAILURE(status
)) {
2431 errln(UnicodeString("FAIL: Parse failed for \"") + str
+ "\"");
2434 if (equalValue(num
, n
)) {
2435 logln(UnicodeString("Ok \"") + str
+ " = " +
2438 errln(UnicodeString("FAIL \"") + str
+ " = " +
2439 toString(num
) + ", expected " + toString(n
));
2443 void NumberFormatTest::expect_rbnf(NumberFormat
& fmt
, const Formattable
& n
,
2444 const UnicodeString
& exp
, UBool rt
) {
2447 UErrorCode status
= U_ZERO_ERROR
;
2448 fmt
.format(n
, saw
, pos
, status
);
2449 CHECK(status
, "NumberFormat::format");
2451 logln(UnicodeString("Ok ") + toString(n
) +
2453 escape(saw
) + "\"");
2454 // We should be able to round-trip the formatted string =>
2455 // number => string (but not the other way around: number
2456 // => string => number2, might have number2 != number):
2459 fmt
.parse(exp
, n2
, status
);
2460 if (U_FAILURE(status
)) {
2461 errln(UnicodeString("FAIL: Parse failed for \"") + exp
+ "\"");
2465 fmt
.format(n2
, saw2
, pos
, status
);
2466 CHECK(status
, "NumberFormat::format");
2468 errln((UnicodeString
)"FAIL \"" + exp
+ "\" => " + toString(n2
) +
2469 " => \"" + saw2
+ "\"");
2473 errln(UnicodeString("FAIL ") + toString(n
) +
2475 escape(saw
) + "\", expected \"" + exp
+ "\"");
2479 void NumberFormatTest::expect(NumberFormat
& fmt
, const Formattable
& n
,
2480 const UnicodeString
& exp
, UBool rt
) {
2483 UErrorCode status
= U_ZERO_ERROR
;
2484 fmt
.format(n
, saw
, pos
, status
);
2485 CHECK(status
, "NumberFormat::format");
2487 ((DecimalFormat
*) &fmt
)->toPattern(pat
);
2489 logln(UnicodeString("Ok ") + toString(n
) + " x " +
2490 escape(pat
) + " = \"" +
2491 escape(saw
) + "\"");
2492 // We should be able to round-trip the formatted string =>
2493 // number => string (but not the other way around: number
2494 // => string => number2, might have number2 != number):
2497 fmt
.parse(exp
, n2
, status
);
2498 if (U_FAILURE(status
)) {
2499 errln(UnicodeString("FAIL: Parse failed for \"") + exp
+ "\" - " + u_errorName(status
));
2503 fmt
.format(n2
, saw2
, pos
, status
);
2504 CHECK(status
, "NumberFormat::format");
2506 errln((UnicodeString
)"FAIL \"" + exp
+ "\" => " + toString(n2
) +
2507 " => \"" + saw2
+ "\"");
2511 dataerrln(UnicodeString("FAIL ") + toString(n
) + " x " +
2512 escape(pat
) + " = \"" +
2513 escape(saw
) + "\", expected \"" + exp
+ "\"");
2517 void NumberFormatTest::expect(NumberFormat
* fmt
, const Formattable
& n
,
2518 const UnicodeString
& exp
,
2519 UErrorCode status
) {
2520 if (fmt
== NULL
|| U_FAILURE(status
)) {
2521 dataerrln("FAIL: NumberFormat constructor");
2523 expect(*fmt
, n
, exp
);
2528 void NumberFormatTest::expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
2529 double value
, const UnicodeString
& string
) {
2530 UErrorCode ec
= U_ZERO_ERROR
;
2531 DecimalFormat
& fmt
= * (DecimalFormat
*) &nf
;
2532 const UChar DEFAULT_CURR
[] = {45/*-*/,0};
2534 u_strcpy(curr
, DEFAULT_CURR
);
2535 if (*locale
.getLanguage() != 0) {
2536 ucurr_forLocale(locale
.getName(), curr
, 4, &ec
);
2537 assertSuccess("ucurr_forLocale", ec
);
2538 fmt
.setCurrency(curr
, ec
);
2539 assertSuccess("DecimalFormat::setCurrency", ec
);
2540 fmt
.setCurrency(curr
); //Deprecated variant, for coverage only
2543 fmt
.format(value
, s
);
2544 s
.findAndReplace((UChar32
)0x00A0, (UChar32
)0x0020);
2546 // Default display of the number yields "1234.5599999999999"
2547 // instead of "1234.56". Use a formatter to fix this.
2549 NumberFormat::createInstance(Locale::getUS(), ec
);
2551 if (U_FAILURE(ec
)) {
2552 // Oops; bad formatter. Use default op+= display.
2553 v
= (UnicodeString
)"" + value
;
2555 f
->setMaximumFractionDigits(4);
2556 f
->setGroupingUsed(FALSE
);
2557 f
->format(value
, v
);
2562 logln((UnicodeString
)"Ok: " + v
+ " x " + curr
+ " => " + prettify(s
));
2564 errln((UnicodeString
)"FAIL: " + v
+ " x " + curr
+ " => " + prettify(s
) +
2565 ", expected " + prettify(string
));
2569 void NumberFormatTest::expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
) {
2573 logln(UnicodeString("Ok \"") + pat
+ "\"");
2575 errln(UnicodeString("FAIL \"") + pat
+ "\", expected \"" + exp
+ "\"");
2579 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2581 expectPad(fmt
, pat
, pos
, 0, (UnicodeString
)"");
2583 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2584 int32_t pos
, int32_t width
, UChar pad
) {
2585 expectPad(fmt
, pat
, pos
, width
, UnicodeString(pad
));
2587 void NumberFormatTest::expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
2588 int32_t pos
, int32_t width
, const UnicodeString
& pad
) {
2589 int32_t apos
= 0, awidth
= 0;
2590 UnicodeString apadStr
;
2591 UErrorCode status
= U_ZERO_ERROR
;
2592 fmt
.applyPattern(pat
, status
);
2593 if (U_SUCCESS(status
)) {
2594 apos
= fmt
.getPadPosition();
2595 awidth
= fmt
.getFormatWidth();
2596 apadStr
=fmt
.getPadCharacterString();
2602 if (apos
== pos
&& awidth
== width
&& apadStr
== pad
) {
2603 UnicodeString infoStr
;
2604 if (pos
== ILLEGAL
) {
2605 infoStr
= UnicodeString(" width=", "") + awidth
+ UnicodeString(" pad=", "") + apadStr
;
2607 logln(UnicodeString("Ok \"") + pat
+ "\" pos=" + apos
+ infoStr
);
2609 errln(UnicodeString("FAIL \"") + pat
+ "\" pos=" + apos
+
2610 " width=" + awidth
+ " pad=" + apadStr
+
2611 ", expected " + pos
+ " " + width
+ " " + pad
);
2614 void NumberFormatTest::TestJB3832(){
2615 const char* localeID
= "pt_PT@currency=PTE";
2616 Locale
loc(localeID
);
2617 UErrorCode status
= U_ZERO_ERROR
;
2618 UnicodeString
expected(CharsToUnicodeString("1,150$50\\u00A0Esc."));
2620 NumberFormat
* currencyFmt
= NumberFormat::createCurrencyInstance(loc
, status
);
2621 if(U_FAILURE(status
)){
2622 dataerrln("Could not create currency formatter for locale %s - %s", localeID
, u_errorName(status
));
2625 currencyFmt
->format(1150.50, s
);
2627 errln(UnicodeString("FAIL: Expected: ")+expected
2628 + UnicodeString(" Got: ") + s
2629 + UnicodeString( " for locale: ")+ UnicodeString(localeID
) );
2631 if (U_FAILURE(status
)){
2632 errln("FAIL: Status %s", u_errorName(status
));
2637 void NumberFormatTest::TestHost()
2639 #if U_PLATFORM_USES_ONLY_WIN32_API
2640 Win32NumberTest::testLocales(this);
2642 Locale
loc("en_US@compat=host");
2643 for (UNumberFormatStyle k
= UNUM_DECIMAL
;
2644 k
< UNUM_FORMAT_STYLE_COUNT
; k
= (UNumberFormatStyle
)(k
+1)) {
2645 UErrorCode status
= U_ZERO_ERROR
;
2646 LocalPointer
<NumberFormat
> full(NumberFormat::createInstance(loc
, k
, status
));
2647 if (!NumberFormat::isStyleSupported(k
)) {
2648 if (status
!= U_UNSUPPORTED_ERROR
) {
2649 errln("FAIL: expected style %d to be unsupported - %s",
2650 k
, u_errorName(status
));
2654 if (full
.isNull() || U_FAILURE(status
)) {
2655 dataerrln("FAIL: Can't create number instance of style %d for host - %s",
2656 k
, u_errorName(status
));
2659 UnicodeString result1
;
2660 Formattable
number(10.00);
2661 full
->format(number
, result1
, status
);
2662 if (U_FAILURE(status
)) {
2663 errln("FAIL: Can't format for host");
2666 Formattable formattable
;
2667 full
->parse(result1
, formattable
, status
);
2668 if (U_FAILURE(status
)) {
2669 errln("FAIL: Can't parse for host");
2675 void NumberFormatTest::TestHostClone()
2678 Verify that a cloned formatter gives the same results
2679 and is useable after the original has been deleted.
2681 // This is mainly important on Windows.
2682 UErrorCode status
= U_ZERO_ERROR
;
2683 Locale
loc("en_US@compat=host");
2684 UDate now
= Calendar::getNow();
2685 NumberFormat
*full
= NumberFormat::createInstance(loc
, status
);
2686 if (full
== NULL
|| U_FAILURE(status
)) {
2687 dataerrln("FAIL: Can't create Relative date instance - %s", u_errorName(status
));
2690 UnicodeString result1
;
2691 full
->format(now
, result1
, status
);
2692 Format
*fullClone
= full
->clone();
2696 UnicodeString result2
;
2697 fullClone
->format(now
, result2
, status
);
2698 if (U_FAILURE(status
)) {
2699 errln("FAIL: format failure.");
2701 if (result1
!= result2
) {
2702 errln("FAIL: Clone returned different result from non-clone.");
2707 void NumberFormatTest::TestCurrencyFormat()
2709 // This test is here to increase code coverage.
2710 UErrorCode status
= U_ZERO_ERROR
;
2711 MeasureFormat
*cloneObj
;
2713 Formattable toFormat
, result
;
2714 static const UChar ISO_CODE
[4] = {0x0047, 0x0042, 0x0050, 0};
2716 Locale saveDefaultLocale
= Locale::getDefault();
2717 Locale::setDefault( Locale::getUK(), status
);
2718 if (U_FAILURE(status
)) {
2719 errln("couldn't set default Locale!");
2723 MeasureFormat
*measureObj
= MeasureFormat::createCurrencyFormat(status
);
2724 Locale::setDefault( saveDefaultLocale
, status
);
2725 if (U_FAILURE(status
)){
2726 dataerrln("FAIL: Status %s", u_errorName(status
));
2729 cloneObj
= (MeasureFormat
*)measureObj
->clone();
2730 if (cloneObj
== NULL
) {
2731 errln("Clone doesn't work");
2734 toFormat
.adoptObject(new CurrencyAmount(1234.56, ISO_CODE
, status
));
2735 measureObj
->format(toFormat
, str
, status
);
2736 measureObj
->parseObject(str
, result
, status
);
2737 if (U_FAILURE(status
)){
2738 errln("FAIL: Status %s", u_errorName(status
));
2740 if (result
!= toFormat
) {
2741 errln("measureObj does not round trip. Formatted string was \"" + str
+ "\" Got: " + toString(result
) + " Expected: " + toString(toFormat
));
2743 status
= U_ZERO_ERROR
;
2745 cloneObj
->format(toFormat
, str
, status
);
2746 cloneObj
->parseObject(str
, result
, status
);
2747 if (U_FAILURE(status
)){
2748 errln("FAIL: Status %s", u_errorName(status
));
2750 if (result
!= toFormat
) {
2751 errln("Clone does not round trip. Formatted string was \"" + str
+ "\" Got: " + toString(result
) + " Expected: " + toString(toFormat
));
2753 if (*measureObj
!= *cloneObj
) {
2754 errln("Cloned object is not equal to the original object");
2759 status
= U_USELESS_COLLATOR_ERROR
;
2760 if (MeasureFormat::createCurrencyFormat(status
) != NULL
) {
2761 errln("createCurrencyFormat should have returned NULL.");
2765 /* Port of ICU4J rounding test. */
2766 void NumberFormatTest::TestRounding() {
2767 UErrorCode status
= U_ZERO_ERROR
;
2768 DecimalFormat
*df
= (DecimalFormat
*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status
);
2770 if (U_FAILURE(status
)) {
2771 dataerrln("Unable to create decimal formatter. - %s", u_errorName(status
));
2775 int roundingIncrements
[]={1, 2, 5, 20, 50, 100};
2776 int testValues
[]={0, 300};
2778 for (int j
=0; j
<2; j
++) {
2779 for (int mode
=DecimalFormat::kRoundUp
;mode
<DecimalFormat::kRoundHalfEven
;mode
++) {
2780 df
->setRoundingMode((DecimalFormat::ERoundingMode
)mode
);
2781 for (int increment
=0; increment
<6; increment
++) {
2782 double base
=testValues
[j
];
2783 double rInc
=roundingIncrements
[increment
];
2784 checkRounding(df
, base
, 20, rInc
);
2785 rInc
=1.000000000/rInc
;
2786 checkRounding(df
, base
, 20, rInc
);
2793 void NumberFormatTest::TestRoundingPattern() {
2794 UErrorCode status
= U_ZERO_ERROR
;
2796 UnicodeString pattern
;
2798 UnicodeString expected
;
2800 { (UnicodeString
)"##0.65", 1.234, (UnicodeString
)"1.30" },
2801 { (UnicodeString
)"#50", 1230, (UnicodeString
)"1250" }
2803 int32_t numOfTests
= (sizeof(tests
)/sizeof(tests
[0]));
2804 UnicodeString result
;
2806 DecimalFormat
*df
= (DecimalFormat
*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status
);
2807 if (U_FAILURE(status
)) {
2808 dataerrln("Unable to create decimal formatter. - %s", u_errorName(status
));
2812 for (int32_t i
= 0; i
< numOfTests
; i
++) {
2815 df
->applyPattern(tests
[i
].pattern
, status
);
2816 if (U_FAILURE(status
)) {
2817 errln("Unable to apply pattern to decimal formatter. - %s", u_errorName(status
));
2820 df
->format(tests
[i
].testCase
, result
);
2822 if (result
!= tests
[i
].expected
) {
2823 errln("String Pattern Rounding Test Failed: Pattern: \"" + tests
[i
].pattern
+ "\" Number: " + tests
[i
].testCase
+ " - Got: " + result
+ " Expected: " + tests
[i
].expected
);
2830 void NumberFormatTest::checkRounding(DecimalFormat
* df
, double base
, int iterations
, double increment
) {
2831 df
->setRoundingIncrement(increment
);
2832 double lastParsed
=INT32_MIN
; //Intger.MIN_VALUE
2833 for (int i
=-iterations
; i
<=iterations
;i
++) {
2834 double iValue
=base
+(increment
*(i
*0.1));
2835 double smallIncrement
=0.00000001;
2837 smallIncrement
*=iValue
;
2839 //we not only test the value, but some values in a small range around it
2840 lastParsed
=checkRound(df
, iValue
-smallIncrement
, lastParsed
);
2841 lastParsed
=checkRound(df
, iValue
, lastParsed
);
2842 lastParsed
=checkRound(df
, iValue
+smallIncrement
, lastParsed
);
2846 double NumberFormatTest::checkRound(DecimalFormat
* df
, double iValue
, double lastParsed
) {
2847 UErrorCode status
=U_ZERO_ERROR
;
2848 UnicodeString formattedDecimal
;
2851 df
->format(iValue
, formattedDecimal
, status
);
2853 if (U_FAILURE(status
)) {
2854 errln("Error formatting number.");
2857 df
->parse(formattedDecimal
, result
, status
);
2859 if (U_FAILURE(status
)) {
2860 errln("Error parsing number.");
2863 parsed
=result
.getDouble();
2865 if (lastParsed
>parsed
) {
2866 errln("Rounding wrong direction! %d > %d", lastParsed
, parsed
);
2872 void NumberFormatTest::TestNonpositiveMultiplier() {
2873 UErrorCode status
= U_ZERO_ERROR
;
2874 DecimalFormatSymbols
US(Locale::getUS(), status
);
2875 CHECK(status
, "DecimalFormatSymbols constructor");
2876 DecimalFormat
df(UnicodeString("0"), US
, status
);
2877 CHECK(status
, "DecimalFormat(0)");
2879 // test zero multiplier
2881 int32_t mult
= df
.getMultiplier();
2882 df
.setMultiplier(0);
2883 if (df
.getMultiplier() != mult
) {
2884 errln("DecimalFormat.setMultiplier(0) did not ignore its zero input");
2887 // test negative multiplier
2889 df
.setMultiplier(-1);
2890 if (df
.getMultiplier() != -1) {
2891 errln("DecimalFormat.setMultiplier(-1) ignored its negative input");
2895 expect(df
, "1122.123", -1122.123);
2896 expect(df
, "-1122.123", 1122.123);
2897 expect(df
, "1.2", -1.2);
2898 expect(df
, "-1.2", 1.2);
2900 // Note: the tests with the final parameter of FALSE will not round trip.
2901 // The initial numeric value will format correctly, after the multiplier.
2902 // Parsing the formatted text will be out-of-range for an int64, however.
2903 // The expect() function could be modified to detect this and fall back
2904 // to looking at the decimal parsed value, but it doesn't.
2905 expect(df
, U_INT64_MIN
, "9223372036854775808", FALSE
);
2906 expect(df
, U_INT64_MIN
+1, "9223372036854775807");
2907 expect(df
, (int64_t)-123, "123");
2908 expect(df
, (int64_t)123, "-123");
2909 expect(df
, U_INT64_MAX
-1, "-9223372036854775806");
2910 expect(df
, U_INT64_MAX
, "-9223372036854775807");
2912 df
.setMultiplier(-2);
2913 expect(df
, -(U_INT64_MIN
/2)-1, "-9223372036854775806");
2914 expect(df
, -(U_INT64_MIN
/2), "-9223372036854775808");
2915 expect(df
, -(U_INT64_MIN
/2)+1, "-9223372036854775810", FALSE
);
2917 df
.setMultiplier(-7);
2918 expect(df
, -(U_INT64_MAX
/7)-1, "9223372036854775814", FALSE
);
2919 expect(df
, -(U_INT64_MAX
/7), "9223372036854775807");
2920 expect(df
, -(U_INT64_MAX
/7)+1, "9223372036854775800");
2922 // TODO: uncomment (and fix up) all the following int64_t tests once BigInteger is ported
2923 // (right now the big numbers get turned into doubles and lose tons of accuracy)
2924 //expect2(df, U_INT64_MAX, Int64ToUnicodeString(-U_INT64_MAX));
2925 //expect2(df, U_INT64_MIN, UnicodeString(Int64ToUnicodeString(U_INT64_MIN), 1));
2926 //expect2(df, U_INT64_MAX / 2, Int64ToUnicodeString(-(U_INT64_MAX / 2)));
2927 //expect2(df, U_INT64_MIN / 2, Int64ToUnicodeString(-(U_INT64_MIN / 2)));
2929 // TODO: uncomment (and fix up) once BigDecimal is ported and DecimalFormat can handle it
2930 //expect2(df, BigDecimal.valueOf(Long.MAX_VALUE), BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
2931 //expect2(df, BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
2932 //expect2(df, java.math.BigDecimal.valueOf(Long.MAX_VALUE), java.math.BigDecimal.valueOf(Long.MAX_VALUE).negate().toString());
2933 //expect2(df, java.math.BigDecimal.valueOf(Long.MIN_VALUE), java.math.BigDecimal.valueOf(Long.MIN_VALUE).negate().toString());
2937 const char * stringToParse
;
2941 } TestSpaceParsingItem
;
2944 NumberFormatTest::TestSpaceParsing() {
2946 // the string to be parsed, parsed position, parsed error index
2947 const TestSpaceParsingItem DATA
[] = {
2948 // TOTO: Update the following TODOs, some may be handled now
2949 {"$124", 4, -1, FALSE
},
2950 {"$124 $124", 4, -1, FALSE
},
2951 {"$124 ", 4, -1, FALSE
},
2952 //{"$ 124 ", 5, -1, FALSE}, // TODO: need to handle space correctly
2953 //{"$\\u00A0124 ", 5, -1, FALSE}, // TODO: need to handle space correctly
2954 {"$ 124 ", 0, 1, FALSE
}, // errorIndex used to be 0, now 1 (better)
2955 {"$\\u00A0124 ", 5, -1, FALSE
}, // errorIndex used to be 0, now 1 (better) *Apple change from open source*
2956 {" $ 124 ", 0, 0, FALSE
}, // TODO: need to handle space correctly
2957 {"124$", 0, 3, FALSE
}, // TODO: need to handle space correctly
2958 // {"124 $", 5, -1, FALSE}, // TODO: OK or not, need currency spacing rule
2959 {"124 $", 0, 3, FALSE
},
2960 {"$124", 4, -1, TRUE
},
2961 {"$124 $124", 4, -1, TRUE
},
2962 {"$124 ", 4, -1, TRUE
},
2963 {"$ 124 ", 5, -1, TRUE
},
2964 {"$\\u00A0124 ", 5, -1, TRUE
},
2965 {" $ 124 ", 6, -1, TRUE
},
2966 //{"124$", 4, -1, TRUE}, // TODO: need to handle trailing currency correctly
2967 {"124$", 3, -1, TRUE
},
2968 //{"124 $", 5, -1, TRUE}, // TODO: OK or not, need currency spacing rule
2969 {"124 $", 4, -1, TRUE
},
2971 UErrorCode status
= U_ZERO_ERROR
;
2972 Locale
locale("en_US");
2973 NumberFormat
* foo
= NumberFormat::createCurrencyInstance(locale
, status
);
2975 if (U_FAILURE(status
)) {
2979 for (uint32_t i
= 0; i
< sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
2980 ParsePosition
parsePosition(0);
2981 UnicodeString stringToBeParsed
= ctou(DATA
[i
].stringToParse
);
2982 int parsedPosition
= DATA
[i
].parsedPos
;
2983 int errorIndex
= DATA
[i
].errorIndex
;
2984 foo
->setLenient(DATA
[i
].lenient
);
2986 foo
->parse(stringToBeParsed
, result
, parsePosition
);
2987 if (parsePosition
.getIndex() != parsedPosition
||
2988 parsePosition
.getErrorIndex() != errorIndex
) {
2989 errln("FAILED parse " + stringToBeParsed
+ "; lenient: " + DATA
[i
].lenient
+ "; wrong position, expected: (" + parsedPosition
+ ", " + errorIndex
+ "); got (" + parsePosition
.getIndex() + ", " + parsePosition
.getErrorIndex() + ")");
2991 if (parsePosition
.getErrorIndex() == -1 &&
2992 result
.getType() == Formattable::kLong
&&
2993 result
.getLong() != 124) {
2994 errln("FAILED parse " + stringToBeParsed
+ "; wrong number, expect: 124, got " + result
.getLong());
3001 * Test using various numbering systems and numbering system keyword.
3004 const char *localeName
;
3007 const char *expectedResult
;
3008 } TestNumberingSystemItem
;
3010 void NumberFormatTest::TestNumberingSystems() {
3012 const TestNumberingSystemItem DATA
[] = {
3013 { "en_US@numbers=thai", 1234.567, FALSE
, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" },
3014 { "en_US@numbers=hebr", 5678.0, TRUE
, "\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7" },
3015 { "en_US@numbers=arabext", 1234.567, FALSE
, "\\u06F1\\u066c\\u06F2\\u06F3\\u06F4\\u066b\\u06F5\\u06F6\\u06F7" },
3016 { "ar_EG", 1234.567, FALSE
, "\\u0661\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
3017 { "th_TH@numbers=traditional", 1234.567, FALSE
, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" }, // fall back to native per TR35
3018 { "ar_MA", 1234.567, FALSE
, "1.234,567" },
3019 { "en_US@numbers=hanidec", 1234.567, FALSE
, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },
3020 { "ta_IN@numbers=native", 1234.567, FALSE
, "\\u0BE7,\\u0BE8\\u0BE9\\u0BEA.\\u0BEB\\u0BEC\\u0BED" },
3021 { "ta_IN@numbers=traditional", 1235.0, TRUE
, "\\u0BF2\\u0BE8\\u0BF1\\u0BE9\\u0BF0\\u0BEB" },
3022 { "ta_IN@numbers=finance", 1234.567, FALSE
, "1,234.567" }, // fall back to default per TR35
3023 { "zh_TW@numbers=native", 1234.567, FALSE
, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },
3024 { "zh_TW@numbers=traditional", 1234.567, TRUE
, "\\u4E00\\u5343\\u4E8C\\u767E\\u4E09\\u5341\\u56DB\\u9EDE\\u4E94\\u516D\\u4E03" },
3025 { "zh_TW@numbers=finance", 1234.567, TRUE
, "\\u58F9\\u4EDF\\u8CB3\\u4F70\\u53C4\\u62FE\\u8086\\u9EDE\\u4F0D\\u9678\\u67D2" },
3026 { NULL
, 0, FALSE
, NULL
}
3031 const TestNumberingSystemItem
*item
;
3032 for (item
= DATA
; item
->localeName
!= NULL
; item
++) {
3034 Locale loc
= Locale::createFromName(item
->localeName
);
3035 NumberFormat
*fmt
= NumberFormat::createInstance(loc
,ec
);
3037 if (U_FAILURE(ec
)) {
3038 dataerrln("FAIL: getInstance(%s) - %s", item
->localeName
, u_errorName(ec
));
3043 expect3(*fmt
,item
->value
,CharsToUnicodeString(item
->expectedResult
));
3045 expect2(*fmt
,item
->value
,CharsToUnicodeString(item
->expectedResult
));
3051 // Test bogus keyword value
3053 Locale loc4
= Locale::createFromName("en_US@numbers=foobar");
3054 NumberFormat
* fmt4
= NumberFormat::createInstance(loc4
, ec
);
3055 if ( ec
!= U_UNSUPPORTED_ERROR
) {
3056 errln("FAIL: getInstance(en_US@numbers=foobar) should have returned U_UNSUPPORTED_ERROR");
3061 NumberingSystem
*ns
= NumberingSystem::createInstance(ec
);
3062 if (U_FAILURE(ec
)) {
3063 dataerrln("FAIL: NumberingSystem::createInstance(ec); - %s", u_errorName(ec
));
3067 ns
->getDynamicClassID();
3068 ns
->getStaticClassID();
3070 errln("FAIL: getInstance() returned NULL.");
3073 NumberingSystem
*ns1
= new NumberingSystem(*ns
);
3075 errln("FAIL: NumberSystem copy constructor returned NULL.");
3085 NumberFormatTest::TestMultiCurrencySign() {
3086 const char* DATA
[][6] = {
3087 // the fields in the following test are:
3089 // currency pattern (with negative pattern),
3090 // currency number to be formatted,
3091 // currency format using currency symbol name, such as "$" for USD,
3092 // currency format using currency ISO name, such as "USD",
3093 // currency format using plural name, such as "US dollars".
3095 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1234.56", "$1,234.56", "USD1,234.56", "US dollars1,234.56"},
3096 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "-1234.56", "-$1,234.56", "-USD1,234.56", "-US dollars1,234.56"},
3097 {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1", "$1.00", "USD1.00", "US dollar1.00"},
3099 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1234.56", "\\uFFE51,234.56", "CNY1,234.56", "\\u4EBA\\u6C11\\u5E011,234.56"},
3100 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "-1234.56", "(\\uFFE51,234.56)", "(CNY1,234.56)", "(\\u4EBA\\u6C11\\u5E011,234.56)"},
3101 {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1", "\\uFFE51.00", "CNY1.00", "\\u4EBA\\u6C11\\u5E011.00"}
3104 const UChar doubleCurrencySign
[] = {0xA4, 0xA4, 0};
3105 UnicodeString
doubleCurrencyStr(doubleCurrencySign
);
3106 const UChar tripleCurrencySign
[] = {0xA4, 0xA4, 0xA4, 0};
3107 UnicodeString
tripleCurrencyStr(tripleCurrencySign
);
3109 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3110 const char* locale
= DATA
[i
][0];
3111 UnicodeString pat
= ctou(DATA
[i
][1]);
3112 double numberToBeFormat
= atof(DATA
[i
][2]);
3113 UErrorCode status
= U_ZERO_ERROR
;
3114 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale(locale
), status
);
3115 if (U_FAILURE(status
)) {
3119 for (int j
=1; j
<=3; ++j
) {
3120 // j represents the number of currency sign in the pattern.
3122 pat
= pat
.findAndReplace(ctou("\\u00A4"), doubleCurrencyStr
);
3123 } else if (j
== 3) {
3124 pat
= pat
.findAndReplace(ctou("\\u00A4\\u00A4"), tripleCurrencyStr
);
3127 DecimalFormat
* fmt
= new DecimalFormat(pat
, new DecimalFormatSymbols(*sym
), status
);
3128 if (U_FAILURE(status
)) {
3129 errln("FAILED init DecimalFormat ");
3134 ((NumberFormat
*) fmt
)->format(numberToBeFormat
, s
);
3135 // DATA[i][3] is the currency format result using a
3136 // single currency sign.
3137 // DATA[i][4] is the currency format result using
3138 // double currency sign.
3139 // DATA[i][5] is the currency format result using
3140 // triple currency sign.
3141 // DATA[i][j+2] is the currency format result using
3142 // 'j' number of currency sign.
3143 UnicodeString currencyFormatResult
= ctou(DATA
[i
][2+j
]);
3144 if (s
.compare(currencyFormatResult
)) {
3145 errln("FAIL format: Expected " + currencyFormatResult
+ "; Got " + s
);
3147 // mix style parsing
3148 for (int k
=3; k
<=5; ++k
) {
3149 // DATA[i][3] is the currency format result using a
3150 // single currency sign.
3151 // DATA[i][4] is the currency format result using
3152 // double currency sign.
3153 // DATA[i][5] is the currency format result using
3154 // triple currency sign.
3155 UnicodeString oneCurrencyFormat
= ctou(DATA
[i
][k
]);
3156 UErrorCode status
= U_ZERO_ERROR
;
3157 Formattable parseRes
;
3158 fmt
->parse(oneCurrencyFormat
, parseRes
, status
);
3159 if (U_FAILURE(status
) ||
3160 (parseRes
.getType() == Formattable::kDouble
&&
3161 parseRes
.getDouble() != numberToBeFormat
) ||
3162 (parseRes
.getType() == Formattable::kLong
&&
3163 parseRes
.getLong() != numberToBeFormat
)) {
3164 errln("FAILED parse " + oneCurrencyFormat
+ "; (i, j, k): " +
3165 i
+ ", " + j
+ ", " + k
);
3176 NumberFormatTest::TestCurrencyFormatForMixParsing() {
3177 UErrorCode status
= U_ZERO_ERROR
;
3178 MeasureFormat
* curFmt
= MeasureFormat::createCurrencyFormat(Locale("en_US"), status
);
3179 if (U_FAILURE(status
)) {
3183 const char* formats
[] = {
3184 "$1,234.56", // string to be parsed
3186 "US dollars1,234.56",
3187 "1,234.56 US dollars"
3189 const CurrencyAmount
* curramt
= NULL
;
3190 for (uint32_t i
= 0; i
< sizeof(formats
)/sizeof(formats
[0]); ++i
) {
3191 UnicodeString stringToBeParsed
= ctou(formats
[i
]);
3192 logln(UnicodeString("stringToBeParsed: ") + stringToBeParsed
);
3194 UErrorCode status
= U_ZERO_ERROR
;
3195 curFmt
->parseObject(stringToBeParsed
, result
, status
);
3196 if (U_FAILURE(status
)) {
3197 errln("FAIL: measure format parsing: '%s' ec: %s", formats
[i
], u_errorName(status
));
3198 } else if (result
.getType() != Formattable::kObject
||
3199 (curramt
= dynamic_cast<const CurrencyAmount
*>(result
.getObject())) == NULL
||
3200 curramt
->getNumber().getDouble() != 1234.56 ||
3201 UnicodeString(curramt
->getISOCurrency()).compare(ISO_CURRENCY_USD
)
3203 errln("FAIL: getCurrencyFormat of default locale (en_US) failed roundtripping the number ");
3204 if (curramt
->getNumber().getDouble() != 1234.56) {
3205 errln((UnicodeString
)"wong number, expect: 1234.56" + ", got: " + curramt
->getNumber().getDouble());
3207 if (curramt
->getISOCurrency() != ISO_CURRENCY_USD
) {
3208 errln((UnicodeString
)"wong currency, expect: USD" + ", got: " + curramt
->getISOCurrency());
3217 NumberFormatTest::TestDecimalFormatCurrencyParse() {
3219 UErrorCode status
= U_ZERO_ERROR
;
3220 DecimalFormatSymbols
* sym
= new DecimalFormatSymbols(Locale("en_US"), status
);
3221 if (U_FAILURE(status
)) {
3226 UChar currency
= 0x00A4;
3227 // "\xA4#,##0.00;-\xA4#,##0.00"
3228 pat
.append(currency
).append(currency
).append(currency
).append("#,##0.00;-").append(currency
).append(currency
).append(currency
).append("#,##0.00");
3229 DecimalFormat
* fmt
= new DecimalFormat(pat
, sym
, status
);
3230 if (U_FAILURE(status
)) {
3232 errln("failed to new DecimalFormat in TestDecimalFormatCurrencyParse");
3235 const char* DATA
[][2] = {
3237 // string to be parsed, the parsed result (number)
3240 {"1.00 US dollar", "1"},
3241 {"$1,234.56", "1234.56"},
3242 {"USD1,234.56", "1234.56"},
3243 {"1,234.56 US dollar", "1234.56"},
3245 for (uint32_t i
= 0; i
< sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3246 UnicodeString stringToBeParsed
= ctou(DATA
[i
][0]);
3247 double parsedResult
= atof(DATA
[i
][1]);
3248 UErrorCode status
= U_ZERO_ERROR
;
3250 fmt
->parse(stringToBeParsed
, result
, status
);
3251 if (U_FAILURE(status
) ||
3252 (result
.getType() == Formattable::kDouble
&&
3253 result
.getDouble() != parsedResult
) ||
3254 (result
.getType() == Formattable::kLong
&&
3255 result
.getLong() != parsedResult
)) {
3256 errln((UnicodeString
)"FAIL parse: Expected " + parsedResult
);
3264 NumberFormatTest::TestCurrencyIsoPluralFormat() {
3265 static const char* DATA
[][6] = {
3268 // currency amount to be formatted,
3269 // currency ISO code to be formatted,
3270 // format result using CURRENCYSTYLE,
3271 // format result using ISOCURRENCYSTYLE,
3272 // format result using PLURALCURRENCYSTYLE,
3274 {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
3275 {"en_US", "1234.56", "USD", "$1,234.56", "USD1,234.56", "1,234.56 US dollars"},
3276 {"en_US", "-1234.56", "USD", "($1,234.56)", "(USD1,234.56)", "-1,234.56 US dollars"},
3277 {"zh_CN", "1", "USD", "US$1.00", "USD1.00", "1.00 \\u7F8E\\u5143"},
3278 {"zh_CN", "1234.56", "USD", "US$1,234.56", "USD1,234.56", "1,234.56 \\u7F8E\\u5143"},
3279 // wrong ISO code {"zh_CN", "1", "CHY", "CHY1.00", "CHY1.00", "1.00 CHY"},
3280 // wrong ISO code {"zh_CN", "1234.56", "CHY", "CHY1,234.56", "CHY1,234.56", "1,234.56 CHY"},
3281 {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"},
3282 {"zh_CN", "1234.56", "CNY", "\\uFFE51,234.56", "CNY1,234.56", "1,234.56 \\u4EBA\\u6C11\\u5E01"},
3283 {"ru_RU", "1", "RUB", "1,00\\u00A0\\u0440\\u0443\\u0431.", "1,00\\u00A0RUB", "1,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0439 \\u0440\\u0443\\u0431\\u043B\\u044C"},
3284 {"ru_RU", "2", "RUB", "2,00\\u00A0\\u0440\\u0443\\u0431.", "2,00\\u00A0RUB", "2,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u044F"},
3285 {"ru_RU", "5", "RUB", "5,00\\u00A0\\u0440\\u0443\\u0431.", "5,00\\u00A0RUB", "5,00 \\u0440\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u0435\\u0439"},
3286 // test locale without currency information
3287 {"root", "-1.23", "USD", "-US$\\u00A01.23", "-USD\\u00A01.23", "-1.23 USD"},
3288 // test choice format
3289 {"es_AR", "1", "INR", "\\u20B91,00", "INR1,00", "1,00 rupia india"},
3291 static const UNumberFormatStyle currencyStyles
[] = {
3294 UNUM_CURRENCY_PLURAL
3297 for (int32_t i
=0; i
<LENGTHOF(DATA
); ++i
) {
3298 for (int32_t kIndex
= 0; kIndex
< LENGTHOF(currencyStyles
); ++kIndex
) {
3299 UNumberFormatStyle k
= currencyStyles
[kIndex
];
3300 const char* localeString
= DATA
[i
][0];
3301 double numberToBeFormat
= atof(DATA
[i
][1]);
3302 const char* currencyISOCode
= DATA
[i
][2];
3303 Locale
locale(localeString
);
3304 UErrorCode status
= U_ZERO_ERROR
;
3305 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, k
, status
);
3306 if (U_FAILURE(status
)) {
3308 dataerrln((UnicodeString
)"can not create instance, locale:" + localeString
+ ", style: " + k
+ " - " + u_errorName(status
));
3311 UChar currencyCode
[4];
3312 u_charsToUChars(currencyISOCode
, currencyCode
, 4);
3313 numFmt
->setCurrency(currencyCode
, status
);
3314 if (U_FAILURE(status
)) {
3316 errln((UnicodeString
)"can not set currency:" + currencyISOCode
);
3320 UnicodeString strBuf
;
3321 numFmt
->format(numberToBeFormat
, strBuf
);
3322 int resultDataIndex
= 3 + kIndex
;
3323 // DATA[i][resultDataIndex] is the currency format result
3324 // using 'k' currency style.
3325 UnicodeString formatResult
= ctou(DATA
[i
][resultDataIndex
]);
3326 if (strBuf
.compare(formatResult
)) {
3327 errln("FAIL: Expected " + formatResult
+ " actual: " + strBuf
);
3329 // test parsing, and test parsing for all currency formats.
3330 for (int j
= 3; j
< 6; ++j
) {
3331 // DATA[i][3] is the currency format result using
3332 // CURRENCYSTYLE formatter.
3333 // DATA[i][4] is the currency format result using
3334 // ISOCURRENCYSTYLE formatter.
3335 // DATA[i][5] is the currency format result using
3336 // PLURALCURRENCYSTYLE formatter.
3337 UnicodeString oneCurrencyFormatResult
= ctou(DATA
[i
][j
]);
3338 UErrorCode status
= U_ZERO_ERROR
;
3339 Formattable parseResult
;
3340 numFmt
->parse(oneCurrencyFormatResult
, parseResult
, status
);
3341 if (U_FAILURE(status
) ||
3342 (parseResult
.getType() == Formattable::kDouble
&&
3343 parseResult
.getDouble() != numberToBeFormat
) ||
3344 (parseResult
.getType() == Formattable::kLong
&&
3345 parseResult
.getLong() != numberToBeFormat
)) {
3346 errln((UnicodeString
)"FAIL: getCurrencyFormat of locale " +
3347 localeString
+ " failed roundtripping the number");
3348 if (parseResult
.getType() == Formattable::kDouble
) {
3349 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getDouble());
3351 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getLong());
3361 NumberFormatTest::TestCurrencyParsing() {
3362 static const char* DATA
[][6] = {
3365 // currency amount to be formatted,
3366 // currency ISO code to be formatted,
3367 // format result using CURRENCYSTYLE,
3368 // format result using ISOCURRENCYSTYLE,
3369 // format result using PLURALCURRENCYSTYLE,
3370 {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
3371 {"pa_IN", "1", "USD", "US$\\u00a0\\u0a67.\\u0a66\\u0a66", "USD\\u00a0\\u0a67.\\u0a66\\u0a66", "\\u0a67.\\u0a66\\u0a66 USD"},
3372 {"es_AR", "1", "USD", "US$1,00", "USD1,00", "1,00 d\\u00f3lar estadounidense"},
3373 {"ar_EG", "1", "USD", "\\u0661\\u066b\\u0660\\u0660\\u00a0US$", "\\u0661\\u066b\\u0660\\u0660\\u00a0USD", "\\u0661\\u066b\\u0660\\u0660 \\u062f\\u0648\\u0644\\u0627\\u0631 \\u0623\\u0645\\u0631\\u064a\\u0643\\u064a"},
3374 {"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"},
3375 {"he_IL", "1", "USD", "1.00\\u00a0US$", "1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"},
3376 {"hr_HR", "1", "USD", "1,00\\u00a0$", "1,00\\u00a0USD", "1,00 Ameri\\u010dki dolar"},
3377 {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 Dolar Amerika Serikat"},
3378 {"it_IT", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 Dollaro Statunitense"},
3379 {"ko_KR", "1", "USD", "US$1.00", "USD1.00", "1.00 \\ubbf8\\uad6d \\ub2ec\\ub7ec"},
3380 {"ja_JP", "1", "USD", "$1.00", "USD1.00", "1.00 \\u7c73\\u30c9\\u30eb"},
3381 {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"},
3382 {"zh_TW", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4eba\\u6c11\\u5e63"},
3383 {"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"},
3385 static const UNumberFormatStyle currencyStyles
[] = {
3388 UNUM_CURRENCY_PLURAL
3391 #ifdef NUMFMTST_CACHE_DEBUG
3394 printf("loop: %d\n", deadloop
++);
3396 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
3397 for (int32_t kIndex
= 0; kIndex
< LENGTHOF(currencyStyles
); ++kIndex
) {
3398 UNumberFormatStyle k
= currencyStyles
[kIndex
];
3399 const char* localeString
= DATA
[i
][0];
3400 double numberToBeFormat
= atof(DATA
[i
][1]);
3401 const char* currencyISOCode
= DATA
[i
][2];
3402 Locale
locale(localeString
);
3403 UErrorCode status
= U_ZERO_ERROR
;
3404 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, k
, status
);
3405 if (U_FAILURE(status
)) {
3407 dataerrln((UnicodeString
)"can not create instance, locale:" + localeString
+ ", style: " + k
+ " - " + u_errorName(status
));
3410 UChar currencyCode
[4];
3411 u_charsToUChars(currencyISOCode
, currencyCode
, 4);
3412 numFmt
->setCurrency(currencyCode
, status
);
3413 if (U_FAILURE(status
)) {
3415 errln((UnicodeString
)"can not set currency:" + currencyISOCode
);
3420 UnicodeString strBuf;
3421 numFmt->format(numberToBeFormat, strBuf);
3422 int resultDataIndex = 3 + kIndex;
3423 // DATA[i][resultDataIndex] is the currency format result
3424 // using 'k' currency style.
3425 UnicodeString formatResult = ctou(DATA[i][resultDataIndex]);
3426 if (strBuf.compare(formatResult)) {
3427 errln("FAIL: Expected " + formatResult + " actual: " + strBuf);
3430 // test parsing, and test parsing for all currency formats.
3431 for (int j
= 3; j
< 6; ++j
) {
3432 // DATA[i][3] is the currency format result using
3433 // CURRENCYSTYLE formatter.
3434 // DATA[i][4] is the currency format result using
3435 // ISOCURRENCYSTYLE formatter.
3436 // DATA[i][5] is the currency format result using
3437 // PLURALCURRENCYSTYLE formatter.
3438 UnicodeString oneCurrencyFormatResult
= ctou(DATA
[i
][j
]);
3439 UErrorCode status
= U_ZERO_ERROR
;
3440 Formattable parseResult
;
3441 numFmt
->parse(oneCurrencyFormatResult
, parseResult
, status
);
3442 if (U_FAILURE(status
) ||
3443 (parseResult
.getType() == Formattable::kDouble
&&
3444 parseResult
.getDouble() != numberToBeFormat
) ||
3445 (parseResult
.getType() == Formattable::kLong
&&
3446 parseResult
.getLong() != numberToBeFormat
)) {
3447 errln((UnicodeString
)"FAIL: getCurrencyFormat of locale " +
3448 localeString
+ " failed roundtripping the number" +
3449 "(i,k,j): " + i
+ ", " + k
+ ", " + j
);
3450 if (parseResult
.getType() == Formattable::kDouble
) {
3451 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getDouble());
3453 errln((UnicodeString
)"expected: " + numberToBeFormat
+ "; actual: " +parseResult
.getLong());
3460 #ifdef NUMFMTST_CACHE_DEBUG
3467 NumberFormatTest::TestParseCurrencyInUCurr() {
3468 const char* DATA
[] = {
3469 "1.00 US DOLLAR", // case in-sensitive
3506 "Afghan Afghani (1927-2002)1.00",
3507 "Afghan afghani (1927-2002)1.00",
3508 "Afghan Afghani1.00",
3509 "Afghan Afghanis1.00",
3512 "Albanian lek\\u00eb1.00",
3513 "Algerian Dinar1.00",
3514 "Algerian dinar1.00",
3515 "Algerian dinars1.00",
3516 "Andorran Peseta1.00",
3517 "Andorran peseta1.00",
3518 "Andorran pesetas1.00",
3519 "Angolan Kwanza (1977-1991)1.00",
3520 "Angolan Readjusted Kwanza (1995-1999)1.00",
3521 "Angolan Kwanza1.00",
3522 "Angolan New Kwanza (1990-2000)1.00",
3523 "Angolan kwanza (1977-1991)1.00",
3524 "Angolan readjusted kwanza (1995-1999)1.00",
3525 "Angolan kwanza1.00",
3526 "Angolan kwanzas (1977-1991)1.00",
3527 "Angolan readjusted kwanzas (1995-1999)1.00",
3528 "Angolan kwanzas1.00",
3529 "Angolan new kwanza (1990-2000)1.00",
3530 "Angolan new kwanzas (1990-2000)1.00",
3531 "Argentine Austral1.00",
3532 "Argentine Peso (1983-1985)1.00",
3533 "Argentine Peso1.00",
3534 "Argentine austral1.00",
3535 "Argentine australs1.00",
3536 "Argentine peso (1983-1985)1.00",
3537 "Argentine peso1.00",
3538 "Argentine pesos (1983-1985)1.00",
3539 "Argentine pesos1.00",
3540 "Armenian Dram1.00",
3541 "Armenian dram1.00",
3542 "Armenian drams1.00",
3543 "Aruban Florin1.00",
3544 "Aruban florin1.00",
3545 "Australian Dollar1.00",
3546 "Australian dollar1.00",
3547 "Australian dollars1.00",
3548 "Austrian Schilling1.00",
3549 "Austrian schilling1.00",
3550 "Austrian schillings1.00",
3551 "Azerbaijani Manat (1993-2006)1.00",
3552 "Azerbaijani Manat1.00",
3553 "Azerbaijani manat (1993-2006)1.00",
3554 "Azerbaijani manat1.00",
3555 "Azerbaijani manats (1993-2006)1.00",
3556 "Azerbaijani manats1.00",
3600 "Bahamian Dollar1.00",
3601 "Bahamian dollar1.00",
3602 "Bahamian dollars1.00",
3603 "Bahraini Dinar1.00",
3604 "Bahraini dinar1.00",
3605 "Bahraini dinars1.00",
3606 "Bangladeshi Taka1.00",
3607 "Bangladeshi taka1.00",
3608 "Bangladeshi takas1.00",
3609 "Barbadian Dollar1.00",
3610 "Barbadian dollar1.00",
3611 "Barbadian dollars1.00",
3612 "Belarusian New Ruble (1994-1999)1.00",
3613 "Belarusian Ruble1.00",
3614 "Belarusian new ruble (1994-1999)1.00",
3615 "Belarusian new rubles (1994-1999)1.00",
3616 "Belarusian ruble1.00",
3617 "Belarusian rubles1.00",
3618 "Belgian Franc (convertible)1.00",
3619 "Belgian Franc (financial)1.00",
3620 "Belgian Franc1.00",
3621 "Belgian franc (convertible)1.00",
3622 "Belgian franc (financial)1.00",
3623 "Belgian franc1.00",
3624 "Belgian francs (convertible)1.00",
3625 "Belgian francs (financial)1.00",
3626 "Belgian francs1.00",
3627 "Belize Dollar1.00",
3628 "Belize dollar1.00",
3629 "Belize dollars1.00",
3630 "Bermudan Dollar1.00",
3631 "Bermudan dollar1.00",
3632 "Bermudan dollars1.00",
3633 "Bhutanese Ngultrum1.00",
3634 "Bhutanese ngultrum1.00",
3635 "Bhutanese ngultrums1.00",
3636 "Bolivian Mvdol1.00",
3637 "Bolivian Peso1.00",
3638 "Bolivian mvdol1.00",
3639 "Bolivian mvdols1.00",
3640 "Bolivian peso1.00",
3641 "Bolivian pesos1.00",
3642 "Bolivian Boliviano1.00",
3643 "Bolivian Boliviano1.00",
3644 "Bolivian Bolivianos1.00",
3645 "Bosnia-Herzegovina Convertible Mark1.00",
3646 "Bosnia-Herzegovina Dinar (1992-1994)1.00",
3647 "Bosnia-Herzegovina convertible mark1.00",
3648 "Bosnia-Herzegovina convertible marks1.00",
3649 "Bosnia-Herzegovina dinar (1992-1994)1.00",
3650 "Bosnia-Herzegovina dinars (1992-1994)1.00",
3651 "Botswanan Pula1.00",
3652 "Botswanan pula1.00",
3653 "Botswanan pulas1.00",
3654 "Brazilian New Cruzado (1989-1990)1.00",
3655 "Brazilian Cruzado (1986-1989)1.00",
3656 "Brazilian Cruzeiro (1990-1993)1.00",
3657 "Brazilian New Cruzeiro (1967-1986)1.00",
3658 "Brazilian Cruzeiro (1993-1994)1.00",
3659 "Brazilian Real1.00",
3660 "Brazilian new cruzado (1989-1990)1.00",
3661 "Brazilian new cruzados (1989-1990)1.00",
3662 "Brazilian cruzado (1986-1989)1.00",
3663 "Brazilian cruzados (1986-1989)1.00",
3664 "Brazilian cruzeiro (1990-1993)1.00",
3665 "Brazilian new cruzeiro (1967-1986)1.00",
3666 "Brazilian cruzeiro (1993-1994)1.00",
3667 "Brazilian cruzeiros (1990-1993)1.00",
3668 "Brazilian new cruzeiros (1967-1986)1.00",
3669 "Brazilian cruzeiros (1993-1994)1.00",
3670 "Brazilian real1.00",
3671 "Brazilian reals1.00",
3672 "British Pound Sterling1.00",
3673 "British pound sterling1.00",
3674 "British pounds sterling1.00",
3675 "Brunei Dollar1.00",
3676 "Brunei dollar1.00",
3677 "Brunei dollars1.00",
3678 "Bulgarian Hard Lev1.00",
3679 "Bulgarian Lev1.00",
3680 "Bulgarian Leva1.00",
3681 "Bulgarian hard lev1.00",
3682 "Bulgarian hard leva1.00",
3683 "Bulgarian lev1.00",
3686 "Burmese kyats1.00",
3687 "Burundian Franc1.00",
3688 "Burundian franc1.00",
3689 "Burundian francs1.00",
3694 "CFA Franc BCEAO1.00",
3695 "CFA Franc BEAC1.00",
3696 "CFA franc BCEAO1.00",
3697 "CFA franc BEAC1.00",
3698 "CFA francs BCEAO1.00",
3699 "CFA francs BEAC1.00",
3726 "Cambodian Riel1.00",
3727 "Cambodian riel1.00",
3728 "Cambodian riels1.00",
3729 "Canadian Dollar1.00",
3730 "Canadian dollar1.00",
3731 "Canadian dollars1.00",
3732 "Cape Verdean Escudo1.00",
3733 "Cape Verdean escudo1.00",
3734 "Cape Verdean escudos1.00",
3735 "Cayman Islands Dollar1.00",
3736 "Cayman Islands dollar1.00",
3737 "Cayman Islands dollars1.00",
3739 "Chilean Unit of Account (UF)1.00",
3741 "Chilean pesos1.00",
3742 "Chilean unit of account (UF)1.00",
3743 "Chilean units of account (UF)1.00",
3746 "Colombian Peso1.00",
3747 "Colombian peso1.00",
3748 "Colombian pesos1.00",
3749 "Comorian Franc1.00",
3750 "Comorian franc1.00",
3751 "Comorian francs1.00",
3752 "Congolese Franc1.00",
3753 "Congolese franc1.00",
3754 "Congolese francs1.00",
3755 "Costa Rican Col\\u00f3n1.00",
3756 "Costa Rican col\\u00f3n1.00",
3757 "Costa Rican col\\u00f3ns1.00",
3758 "Croatian Dinar1.00",
3759 "Croatian Kuna1.00",
3760 "Croatian dinar1.00",
3761 "Croatian dinars1.00",
3762 "Croatian kuna1.00",
3763 "Croatian kunas1.00",
3767 "Cypriot Pound1.00",
3768 "Cypriot pound1.00",
3769 "Cypriot pounds1.00",
3770 "Czech Republic Koruna1.00",
3771 "Czech Republic koruna1.00",
3772 "Czech Republic korunas1.00",
3773 "Czechoslovak Hard Koruna1.00",
3774 "Czechoslovak hard koruna1.00",
3775 "Czechoslovak hard korunas1.00",
3786 "Danish kroner1.00",
3790 "Djiboutian Franc1.00",
3791 "Djiboutian franc1.00",
3792 "Djiboutian francs1.00",
3793 "Dominican Peso1.00",
3794 "Dominican peso1.00",
3795 "Dominican pesos1.00",
3814 "East Caribbean Dollar1.00",
3815 "East Caribbean dollar1.00",
3816 "East Caribbean dollars1.00",
3817 "East German Mark1.00",
3818 "East German mark1.00",
3819 "East German marks1.00",
3820 "Ecuadorian Sucre1.00",
3821 "Ecuadorian Unit of Constant Value1.00",
3822 "Ecuadorian sucre1.00",
3823 "Ecuadorian sucres1.00",
3824 "Ecuadorian unit of constant value1.00",
3825 "Ecuadorian units of constant value1.00",
3826 "Egyptian Pound1.00",
3827 "Egyptian pound1.00",
3828 "Egyptian pounds1.00",
3829 "Salvadoran Col\\u00f3n1.00",
3830 "Salvadoran col\\u00f3n1.00",
3831 "Salvadoran colones1.00",
3832 "Equatorial Guinean Ekwele1.00",
3833 "Equatorial Guinean ekwele1.00",
3834 "Eritrean Nakfa1.00",
3835 "Eritrean nakfa1.00",
3836 "Eritrean nakfas1.00",
3837 "Estonian Kroon1.00",
3838 "Estonian kroon1.00",
3839 "Estonian kroons1.00",
3840 "Ethiopian Birr1.00",
3841 "Ethiopian birr1.00",
3842 "Ethiopian birrs1.00",
3844 "European Composite Unit1.00",
3845 "European Currency Unit1.00",
3846 "European Monetary Unit1.00",
3847 "European Unit of Account (XBC)1.00",
3848 "European Unit of Account (XBD)1.00",
3849 "European composite unit1.00",
3850 "European composite units1.00",
3851 "European currency unit1.00",
3852 "European currency units1.00",
3853 "European monetary unit1.00",
3854 "European monetary units1.00",
3855 "European unit of account (XBC)1.00",
3856 "European unit of account (XBD)1.00",
3857 "European units of account (XBC)1.00",
3858 "European units of account (XBD)1.00",
3866 "Falkland Islands Pound1.00",
3867 "Falkland Islands pound1.00",
3868 "Falkland Islands pounds1.00",
3869 "Fijian Dollar1.00",
3870 "Fijian dollar1.00",
3871 "Fijian dollars1.00",
3872 "Finnish Markka1.00",
3873 "Finnish markka1.00",
3874 "Finnish markkas1.00",
3877 "French Gold Franc1.00",
3878 "French UIC-Franc1.00",
3879 "French UIC-franc1.00",
3880 "French UIC-francs1.00",
3882 "French francs1.00",
3883 "French gold franc1.00",
3884 "French gold francs1.00",
3909 "Gambian Dalasi1.00",
3910 "Gambian dalasi1.00",
3911 "Gambian dalasis1.00",
3912 "Georgian Kupon Larit1.00",
3913 "Georgian Lari1.00",
3914 "Georgian kupon larit1.00",
3915 "Georgian kupon larits1.00",
3916 "Georgian lari1.00",
3917 "Georgian laris1.00",
3918 "Ghanaian Cedi (1979-2007)1.00",
3919 "Ghanaian Cedi1.00",
3920 "Ghanaian cedi (1979-2007)1.00",
3921 "Ghanaian cedi1.00",
3922 "Ghanaian cedis (1979-2007)1.00",
3923 "Ghanaian cedis1.00",
3924 "Gibraltar Pound1.00",
3925 "Gibraltar pound1.00",
3926 "Gibraltar pounds1.00",
3929 "Greek Drachma1.00",
3930 "Greek drachma1.00",
3931 "Greek drachmas1.00",
3932 "Guatemalan Quetzal1.00",
3933 "Guatemalan quetzal1.00",
3934 "Guatemalan quetzals1.00",
3935 "Guinean Franc1.00",
3937 "Guinean franc1.00",
3938 "Guinean francs1.00",
3940 "Guinean sylis1.00",
3941 "Guinea-Bissau Peso1.00",
3942 "Guinea-Bissau peso1.00",
3943 "Guinea-Bissau pesos1.00",
3944 "Guyanaese Dollar1.00",
3945 "Guyanaese dollar1.00",
3946 "Guyanaese dollars1.00",
3957 "Haitian Gourde1.00",
3958 "Haitian gourde1.00",
3959 "Haitian gourdes1.00",
3960 "Honduran Lempira1.00",
3961 "Honduran lempira1.00",
3962 "Honduran lempiras1.00",
3963 "Hong Kong Dollar1.00",
3964 "Hong Kong dollar1.00",
3965 "Hong Kong dollars1.00",
3966 "Hungarian Forint1.00",
3967 "Hungarian forint1.00",
3968 "Hungarian forints1.00",
3980 "Icelandic Kr\\u00f3na1.00",
3981 "Icelandic kr\\u00f3na1.00",
3982 "Icelandic kr\\u00f3nur1.00",
3985 "Indian rupees1.00",
3986 "Indonesian Rupiah1.00",
3987 "Indonesian rupiah1.00",
3988 "Indonesian rupiahs1.00",
3991 "Iranian rials1.00",
3998 "Israeli Pound1.00",
3999 "Israeli new sheqel1.00",
4000 "Israeli pound1.00",
4001 "Israeli pounds1.00",
4004 "Italian liras1.00",
4008 "Jamaican Dollar1.00",
4009 "Jamaican dollar1.00",
4010 "Jamaican dollars1.00",
4013 "Jordanian Dinar1.00",
4014 "Jordanian dinar1.00",
4015 "Jordanian dinars1.00",
4027 "Kazakhstani Tenge1.00",
4028 "Kazakhstani tenge1.00",
4029 "Kazakhstani tenges1.00",
4030 "Kenyan Shilling1.00",
4031 "Kenyan shilling1.00",
4032 "Kenyan shillings1.00",
4033 "Kuwaiti Dinar1.00",
4034 "Kuwaiti dinar1.00",
4035 "Kuwaiti dinars1.00",
4036 "Kyrgystani Som1.00",
4037 "Kyrgystani som1.00",
4038 "Kyrgystani soms1.00",
4066 "Latvian Ruble1.00",
4069 "Latvian ruble1.00",
4070 "Latvian rubles1.00",
4071 "Lebanese Pound1.00",
4072 "Lebanese pound1.00",
4073 "Lebanese pounds1.00",
4076 "Lesotho lotis1.00",
4077 "Liberian Dollar1.00",
4078 "Liberian dollar1.00",
4079 "Liberian dollars1.00",
4082 "Libyan dinars1.00",
4083 "Lithuanian Litas1.00",
4084 "Lithuanian Talonas1.00",
4085 "Lithuanian litas1.00",
4086 "Lithuanian litai1.00",
4087 "Lithuanian talonas1.00",
4088 "Lithuanian talonases1.00",
4089 "Luxembourgian Convertible Franc1.00",
4090 "Luxembourg Financial Franc1.00",
4091 "Luxembourgian Franc1.00",
4092 "Luxembourgian convertible franc1.00",
4093 "Luxembourgian convertible francs1.00",
4094 "Luxembourg financial franc1.00",
4095 "Luxembourg financial francs1.00",
4096 "Luxembourgian franc1.00",
4097 "Luxembourgian francs1.00",
4136 "Macanese Pataca1.00",
4137 "Macanese pataca1.00",
4138 "Macanese patacas1.00",
4139 "Macedonian Denar1.00",
4140 "Macedonian denar1.00",
4141 "Macedonian denari1.00",
4142 "Malagasy Ariaries1.00",
4143 "Malagasy Ariary1.00",
4144 "Malagasy Ariary1.00",
4145 "Malagasy Franc1.00",
4146 "Malagasy franc1.00",
4147 "Malagasy francs1.00",
4148 "Malawian Kwacha1.00",
4149 "Malawian Kwacha1.00",
4150 "Malawian Kwachas1.00",
4151 "Malaysian Ringgit1.00",
4152 "Malaysian ringgit1.00",
4153 "Malaysian ringgits1.00",
4154 "Maldivian Rufiyaa1.00",
4155 "Maldivian rufiyaa1.00",
4156 "Maldivian rufiyaas1.00",
4159 "Malian francs1.00",
4161 "Maltese Pound1.00",
4164 "Maltese pound1.00",
4165 "Maltese pounds1.00",
4166 "Mauritanian Ouguiya1.00",
4167 "Mauritanian ouguiya1.00",
4168 "Mauritanian ouguiyas1.00",
4169 "Mauritian Rupee1.00",
4170 "Mauritian rupee1.00",
4171 "Mauritian rupees1.00",
4173 "Mexican Silver Peso (1861-1992)1.00",
4174 "Mexican Investment Unit1.00",
4176 "Mexican pesos1.00",
4177 "Mexican silver peso (1861-1992)1.00",
4178 "Mexican silver pesos (1861-1992)1.00",
4179 "Mexican investment unit1.00",
4180 "Mexican investment units1.00",
4184 "Mongolian Tugrik1.00",
4185 "Mongolian tugrik1.00",
4186 "Mongolian tugriks1.00",
4187 "Moroccan Dirham1.00",
4188 "Moroccan Franc1.00",
4189 "Moroccan dirham1.00",
4190 "Moroccan dirhams1.00",
4191 "Moroccan franc1.00",
4192 "Moroccan francs1.00",
4193 "Mozambican Escudo1.00",
4194 "Mozambican Metical1.00",
4195 "Mozambican escudo1.00",
4196 "Mozambican escudos1.00",
4197 "Mozambican metical1.00",
4198 "Mozambican meticals1.00",
4214 "Namibian Dollar1.00",
4215 "Namibian dollar1.00",
4216 "Namibian dollars1.00",
4217 "Nepalese Rupee1.00",
4218 "Nepalese rupee1.00",
4219 "Nepalese rupees1.00",
4220 "Netherlands Antillean Guilder1.00",
4221 "Netherlands Antillean guilder1.00",
4222 "Netherlands Antillean guilders1.00",
4223 "Dutch Guilder1.00",
4224 "Dutch guilder1.00",
4225 "Dutch guilders1.00",
4226 "Israeli New Sheqel1.00",
4227 "Israeli New Sheqels1.00",
4228 "New Zealand Dollar1.00",
4229 "New Zealand dollar1.00",
4230 "New Zealand dollars1.00",
4231 "Nicaraguan C\\u00f3rdoba1.00",
4232 "Nicaraguan C\\u00f3rdoba (1988-1991)1.00",
4233 "Nicaraguan c\\u00f3rdoba1.00",
4234 "Nicaraguan c\\u00f3rdobas1.00",
4235 "Nicaraguan c\\u00f3rdoba (1988-1991)1.00",
4236 "Nicaraguan c\\u00f3rdobas (1988-1991)1.00",
4237 "Nigerian Naira1.00",
4238 "Nigerian naira1.00",
4239 "Nigerian nairas1.00",
4240 "North Korean Won1.00",
4241 "North Korean won1.00",
4242 "North Korean won1.00",
4243 "Norwegian Krone1.00",
4244 "Norwegian krone1.00",
4245 "Norwegian kroner1.00",
4247 "Mozambican Metical (1980-2006)1.00",
4248 "Mozambican metical (1980-2006)1.00",
4249 "Mozambican meticals (1980-2006)1.00",
4250 "Romanian Lei (1952-2006)1.00",
4251 "Romanian Leu (1952-2006)1.00",
4252 "Romanian leu (1952-2006)1.00",
4253 "Serbian Dinar (2002-2006)1.00",
4254 "Serbian dinar (2002-2006)1.00",
4255 "Serbian dinars (2002-2006)1.00",
4256 "Sudanese Dinar (1992-2007)1.00",
4257 "Sudanese Pound (1957-1998)1.00",
4258 "Sudanese dinar (1992-2007)1.00",
4259 "Sudanese dinars (1992-2007)1.00",
4260 "Sudanese pound (1957-1998)1.00",
4261 "Sudanese pounds (1957-1998)1.00",
4262 "Turkish Lira (1922-2005)1.00",
4263 "Turkish Lira (1922-2005)1.00",
4285 "Pakistani Rupee1.00",
4286 "Pakistani rupee1.00",
4287 "Pakistani rupees1.00",
4290 "Panamanian Balboa1.00",
4291 "Panamanian balboa1.00",
4292 "Panamanian balboas1.00",
4293 "Papua New Guinean Kina1.00",
4294 "Papua New Guinean kina1.00",
4295 "Papua New Guinean kina1.00",
4296 "Paraguayan Guarani1.00",
4297 "Paraguayan guarani1.00",
4298 "Paraguayan guaranis1.00",
4299 "Peruvian Inti1.00",
4300 "Peruvian Nuevo Sol1.00",
4301 "Peruvian Sol (1863-1965)1.00",
4302 "Peruvian inti1.00",
4303 "Peruvian intis1.00",
4304 "Peruvian nuevo sol1.00",
4305 "Peruvian nuevos soles1.00",
4306 "Peruvian sol (1863-1965)1.00",
4307 "Peruvian soles (1863-1965)1.00",
4308 "Philippine Peso1.00",
4309 "Philippine peso1.00",
4310 "Philippine pesos1.00",
4313 "Polish Zloty (1950-1995)1.00",
4315 "Polish zlotys1.00",
4316 "Polish zloty (PLZ)1.00",
4318 "Polish zlotys (PLZ)1.00",
4319 "Portuguese Escudo1.00",
4320 "Portuguese Guinea Escudo1.00",
4321 "Portuguese Guinea escudo1.00",
4322 "Portuguese Guinea escudos1.00",
4323 "Portuguese escudo1.00",
4324 "Portuguese escudos1.00",
4347 "Rhodesian Dollar1.00",
4348 "Rhodesian dollar1.00",
4349 "Rhodesian dollars1.00",
4353 "Russian Ruble (1991-1998)1.00",
4354 "Russian Ruble1.00",
4355 "Russian ruble (1991-1998)1.00",
4356 "Russian ruble1.00",
4357 "Russian rubles (1991-1998)1.00",
4358 "Russian rubles1.00",
4359 "Rwandan Franc1.00",
4360 "Rwandan franc1.00",
4361 "Rwandan francs1.00",
4391 "Saint Helena Pound1.00",
4392 "Saint Helena pound1.00",
4393 "Saint Helena pounds1.00",
4394 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra1.00",
4395 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra1.00",
4396 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras1.00",
4400 "Serbian Dinar1.00",
4401 "Serbian dinar1.00",
4402 "Serbian dinars1.00",
4403 "Seychellois Rupee1.00",
4404 "Seychellois rupee1.00",
4405 "Seychellois rupees1.00",
4406 "Sierra Leonean Leone1.00",
4407 "Sierra Leonean leone1.00",
4408 "Sierra Leonean leones1.00",
4411 "Singapore Dollar1.00",
4412 "Singapore dollar1.00",
4413 "Singapore dollars1.00",
4414 "Slovak Koruna1.00",
4415 "Slovak koruna1.00",
4416 "Slovak korunas1.00",
4417 "Slovenian Tolar1.00",
4418 "Slovenian tolar1.00",
4419 "Slovenian tolars1.00",
4420 "Solomon Islands Dollar1.00",
4421 "Solomon Islands dollar1.00",
4422 "Solomon Islands dollars1.00",
4423 "Somali Shilling1.00",
4424 "Somali shilling1.00",
4425 "Somali shillings1.00",
4426 "South African Rand (financial)1.00",
4427 "South African Rand1.00",
4428 "South African rand (financial)1.00",
4429 "South African rand1.00",
4430 "South African rands (financial)1.00",
4431 "South African rand1.00",
4432 "South Korean Won1.00",
4433 "South Korean won1.00",
4434 "South Korean won1.00",
4435 "Soviet Rouble1.00",
4436 "Soviet rouble1.00",
4437 "Soviet roubles1.00",
4438 "Spanish Peseta (A account)1.00",
4439 "Spanish Peseta (convertible account)1.00",
4440 "Spanish Peseta1.00",
4441 "Spanish peseta (A account)1.00",
4442 "Spanish peseta (convertible account)1.00",
4443 "Spanish peseta1.00",
4444 "Spanish pesetas (A account)1.00",
4445 "Spanish pesetas (convertible account)1.00",
4446 "Spanish pesetas1.00",
4447 "Special Drawing Rights1.00",
4448 "Sri Lankan Rupee1.00",
4449 "Sri Lankan rupee1.00",
4450 "Sri Lankan rupees1.00",
4451 "Sudanese Pound1.00",
4452 "Sudanese pound1.00",
4453 "Sudanese pounds1.00",
4454 "Surinamese Dollar1.00",
4455 "Surinamese dollar1.00",
4456 "Surinamese dollars1.00",
4457 "Surinamese Guilder1.00",
4458 "Surinamese guilder1.00",
4459 "Surinamese guilders1.00",
4460 "Swazi Lilangeni1.00",
4461 "Swazi lilangeni1.00",
4462 "Swazi emalangeni1.00",
4463 "Swedish Krona1.00",
4464 "Swedish krona1.00",
4465 "Swedish kronor1.00",
4471 "Syrian pounds1.00",
4490 "New Taiwan Dollar1.00",
4491 "New Taiwan dollar1.00",
4492 "New Taiwan dollars1.00",
4493 "Tajikistani Ruble1.00",
4494 "Tajikistani Somoni1.00",
4495 "Tajikistani ruble1.00",
4496 "Tajikistani rubles1.00",
4497 "Tajikistani somoni1.00",
4498 "Tajikistani somonis1.00",
4499 "Tanzanian Shilling1.00",
4500 "Tanzanian shilling1.00",
4501 "Tanzanian shillings1.00",
4502 "Testing Currency Code1.00",
4503 "Testing Currency Code1.00",
4507 "Timorese Escudo1.00",
4508 "Timorese escudo1.00",
4509 "Timorese escudos1.00",
4510 "Tongan Pa\\u02bbanga1.00",
4511 "Tongan pa\\u02bbanga1.00",
4512 "Tongan pa\\u02bbanga1.00",
4513 "Trinidad and Tobago Dollar1.00",
4514 "Trinidad and Tobago dollar1.00",
4515 "Trinidad and Tobago dollars1.00",
4516 "Tunisian Dinar1.00",
4517 "Tunisian dinar1.00",
4518 "Tunisian dinars1.00",
4522 "Turkmenistani Manat1.00",
4523 "Turkmenistani manat1.00",
4524 "Turkmenistani manat1.00",
4533 "US Dollar (Next day)1.00",
4534 "US Dollar (Same day)1.00",
4536 "US dollar (next day)1.00",
4537 "US dollar (same day)1.00",
4539 "US dollars (next day)1.00",
4540 "US dollars (same day)1.00",
4554 "Ugandan Shilling (1966-1987)1.00",
4555 "Ugandan Shilling1.00",
4556 "Ugandan shilling (1966-1987)1.00",
4557 "Ugandan shilling1.00",
4558 "Ugandan shillings (1966-1987)1.00",
4559 "Ugandan shillings1.00",
4560 "Ukrainian Hryvnia1.00",
4561 "Ukrainian Karbovanets1.00",
4562 "Ukrainian hryvnia1.00",
4563 "Ukrainian hryvnias1.00",
4564 "Ukrainian karbovanets1.00",
4565 "Ukrainian karbovantsiv1.00",
4566 "Colombian Real Value Unit1.00",
4567 "United Arab Emirates Dirham1.00",
4568 "Unknown Currency1.00",
4569 "Uruguayan Peso (1975-1993)1.00",
4570 "Uruguayan Peso1.00",
4571 "Uruguayan Peso (Indexed Units)1.00",
4572 "Uruguayan peso (1975-1993)1.00",
4573 "Uruguayan peso (indexed units)1.00",
4574 "Uruguayan peso1.00",
4575 "Uruguayan pesos (1975-1993)1.00",
4576 "Uruguayan pesos (indexed units)1.00",
4577 "Uruguayan pesos1.00",
4578 "Uzbekistan Som1.00",
4579 "Uzbekistan som1.00",
4580 "Uzbekistan som1.00",
4587 "Vanuatu vatus1.00",
4588 "Venezuelan Bol\\u00edvar1.00",
4589 "Venezuelan Bol\\u00edvar (1871-2008)1.00",
4590 "Venezuelan bol\\u00edvar1.00",
4591 "Venezuelan bol\\u00edvars1.00",
4592 "Venezuelan bol\\u00edvar (1871-2008)1.00",
4593 "Venezuelan bol\\u00edvars (1871-2008)1.00",
4594 "Vietnamese Dong1.00",
4595 "Vietnamese dong1.00",
4596 "Vietnamese dong1.00",
4656 "Yemeni dinars1.00",
4659 "Yugoslavian Convertible Dinar (1990-1992)1.00",
4660 "Yugoslavian Hard Dinar (1966-1990)1.00",
4661 "Yugoslavian New Dinar (1994-2002)1.00",
4662 "Yugoslavian convertible dinar (1990-1992)1.00",
4663 "Yugoslavian convertible dinars (1990-1992)1.00",
4664 "Yugoslavian hard dinar (1966-1990)1.00",
4665 "Yugoslavian hard dinars (1966-1990)1.00",
4666 "Yugoslavian new dinar (1994-2002)1.00",
4667 "Yugoslavian new dinars (1994-2002)1.00",
4678 "Zairean New Zaire (1993-1998)1.00",
4679 "Zairean Zaire (1971-1993)1.00",
4680 "Zairean new zaire (1993-1998)1.00",
4681 "Zairean new zaires (1993-1998)1.00",
4682 "Zairean zaire (1971-1993)1.00",
4683 "Zairean zaires (1971-1993)1.00",
4684 "Zambian Kwacha1.00",
4685 "Zambian kwacha1.00",
4686 "Zambian kwachas1.00",
4687 "Zimbabwean Dollar (1980-2008)1.00",
4688 "Zimbabwean dollar (1980-2008)1.00",
4689 "Zimbabwean dollars (1980-2008)1.00",
4692 "Turkish lira (1922-2005)1.00",
4693 "special drawing rights1.00",
4694 "Colombian real value unit1.00",
4695 "Colombian real value units1.00",
4696 "unknown currency1.00",
4705 // Following has extra text, should be parsed correctly too
4708 "1.00 US dollar random",
4709 "1.00 US dollars random",
4710 "1.00 Afghan Afghani random",
4711 "1.00 Afghan Afghani random",
4712 "1.00 Afghan Afghanis (1927-1992) random",
4713 "1.00 Afghan Afghanis random",
4714 "1.00 Albanian Lek random",
4715 "1.00 Albanian lek random",
4716 "1.00 Albanian lek\\u00eb random",
4717 "1.00 Algerian Dinar random",
4718 "1.00 Algerian dinar random",
4719 "1.00 Algerian dinars random",
4720 "1.00 Andorran Peseta random",
4721 "1.00 Andorran peseta random",
4722 "1.00 Andorran pesetas random",
4723 "1.00 Angolan Kwanza (1977-1990) random",
4724 "1.00 Angolan Readjusted Kwanza (1995-1999) random",
4725 "1.00 Angolan Kwanza random",
4726 "1.00 Angolan New Kwanza (1990-2000) random",
4727 "1.00 Angolan kwanza (1977-1991) random",
4728 "1.00 Angolan readjusted kwanza (1995-1999) random",
4729 "1.00 Angolan kwanza random",
4730 "1.00 Angolan kwanzas (1977-1991) random",
4731 "1.00 Angolan readjusted kwanzas (1995-1999) random",
4732 "1.00 Angolan kwanzas random",
4733 "1.00 Angolan new kwanza (1990-2000) random",
4734 "1.00 Angolan new kwanzas (1990-2000) random",
4735 "1.00 Argentine Austral random",
4736 "1.00 Argentine Peso (1983-1985) random",
4737 "1.00 Argentine Peso random",
4738 "1.00 Argentine austral random",
4739 "1.00 Argentine australs random",
4740 "1.00 Argentine peso (1983-1985) random",
4741 "1.00 Argentine peso random",
4742 "1.00 Argentine pesos (1983-1985) random",
4743 "1.00 Argentine pesos random",
4744 "1.00 Armenian Dram random",
4745 "1.00 Armenian dram random",
4746 "1.00 Armenian drams random",
4747 "1.00 Aruban Florin random",
4748 "1.00 Aruban florin random",
4749 "1.00 Australian Dollar random",
4750 "1.00 Australian dollar random",
4751 "1.00 Australian dollars random",
4752 "1.00 Austrian Schilling random",
4753 "1.00 Austrian schilling random",
4754 "1.00 Austrian schillings random",
4755 "1.00 Azerbaijani Manat (1993-2006) random",
4756 "1.00 Azerbaijani Manat random",
4757 "1.00 Azerbaijani manat (1993-2006) random",
4758 "1.00 Azerbaijani manat random",
4759 "1.00 Azerbaijani manats (1993-2006) random",
4760 "1.00 Azerbaijani manats random",
4761 "1.00 Bahamian Dollar random",
4762 "1.00 Bahamian dollar random",
4763 "1.00 Bahamian dollars random",
4764 "1.00 Bahraini Dinar random",
4765 "1.00 Bahraini dinar random",
4766 "1.00 Bahraini dinars random",
4767 "1.00 Bangladeshi Taka random",
4768 "1.00 Bangladeshi taka random",
4769 "1.00 Bangladeshi takas random",
4770 "1.00 Barbadian Dollar random",
4771 "1.00 Barbadian dollar random",
4772 "1.00 Barbadian dollars random",
4773 "1.00 Belarusian New Ruble (1994-1999) random",
4774 "1.00 Belarusian Ruble random",
4775 "1.00 Belarusian new ruble (1994-1999) random",
4776 "1.00 Belarusian new rubles (1994-1999) random",
4777 "1.00 Belarusian ruble random",
4778 "1.00 Belarusian rubles random",
4779 "1.00 Belgian Franc (convertible) random",
4780 "1.00 Belgian Franc (financial) random",
4781 "1.00 Belgian Franc random",
4782 "1.00 Belgian franc (convertible) random",
4783 "1.00 Belgian franc (financial) random",
4784 "1.00 Belgian franc random",
4785 "1.00 Belgian francs (convertible) random",
4786 "1.00 Belgian francs (financial) random",
4787 "1.00 Belgian francs random",
4788 "1.00 Belize Dollar random",
4789 "1.00 Belize dollar random",
4790 "1.00 Belize dollars random",
4791 "1.00 Bermudan Dollar random",
4792 "1.00 Bermudan dollar random",
4793 "1.00 Bermudan dollars random",
4794 "1.00 Bhutanese Ngultrum random",
4795 "1.00 Bhutanese ngultrum random",
4796 "1.00 Bhutanese ngultrums random",
4797 "1.00 Bolivian Mvdol random",
4798 "1.00 Bolivian Peso random",
4799 "1.00 Bolivian mvdol random",
4800 "1.00 Bolivian mvdols random",
4801 "1.00 Bolivian peso random",
4802 "1.00 Bolivian pesos random",
4803 "1.00 Bolivian Boliviano random",
4804 "1.00 Bolivian Boliviano random",
4805 "1.00 Bolivian Bolivianos random",
4806 "1.00 Bosnia-Herzegovina Convertible Mark random",
4807 "1.00 Bosnia-Herzegovina Dinar (1992-1994) random",
4808 "1.00 Bosnia-Herzegovina convertible mark random",
4809 "1.00 Bosnia-Herzegovina convertible marks random",
4810 "1.00 Bosnia-Herzegovina dinar (1992-1994) random",
4811 "1.00 Bosnia-Herzegovina dinars (1992-1994) random",
4812 "1.00 Botswanan Pula random",
4813 "1.00 Botswanan pula random",
4814 "1.00 Botswanan pulas random",
4815 "1.00 Brazilian New Cruzado (1989-1990) random",
4816 "1.00 Brazilian Cruzado (1986-1989) random",
4817 "1.00 Brazilian Cruzeiro (1990-1993) random",
4818 "1.00 Brazilian New Cruzeiro (1967-1986) random",
4819 "1.00 Brazilian Cruzeiro (1993-1994) random",
4820 "1.00 Brazilian Real random",
4821 "1.00 Brazilian new cruzado (1989-1990) random",
4822 "1.00 Brazilian new cruzados (1989-1990) random",
4823 "1.00 Brazilian cruzado (1986-1989) random",
4824 "1.00 Brazilian cruzados (1986-1989) random",
4825 "1.00 Brazilian cruzeiro (1990-1993) random",
4826 "1.00 Brazilian new cruzeiro (1967-1986) random",
4827 "1.00 Brazilian cruzeiro (1993-1994) random",
4828 "1.00 Brazilian cruzeiros (1990-1993) random",
4829 "1.00 Brazilian new cruzeiros (1967-1986) random",
4830 "1.00 Brazilian cruzeiros (1993-1994) random",
4831 "1.00 Brazilian real random",
4832 "1.00 Brazilian reals random",
4833 "1.00 British Pound Sterling random",
4834 "1.00 British pound sterling random",
4835 "1.00 British pounds sterling random",
4836 "1.00 Brunei Dollar random",
4837 "1.00 Brunei dollar random",
4838 "1.00 Brunei dollars random",
4839 "1.00 Bulgarian Hard Lev random",
4840 "1.00 Bulgarian Lev random",
4841 "1.00 Bulgarian Leva random",
4842 "1.00 Bulgarian hard lev random",
4843 "1.00 Bulgarian hard leva random",
4844 "1.00 Bulgarian lev random",
4845 "1.00 Burmese Kyat random",
4846 "1.00 Burmese kyat random",
4847 "1.00 Burmese kyats random",
4848 "1.00 Burundian Franc random",
4849 "1.00 Burundian franc random",
4850 "1.00 Burundian francs random",
4851 "1.00 Cambodian Riel random",
4852 "1.00 Cambodian riel random",
4853 "1.00 Cambodian riels random",
4854 "1.00 Canadian Dollar random",
4855 "1.00 Canadian dollar random",
4856 "1.00 Canadian dollars random",
4857 "1.00 Cape Verdean Escudo random",
4858 "1.00 Cape Verdean escudo random",
4859 "1.00 Cape Verdean escudos random",
4860 "1.00 Cayman Islands Dollar random",
4861 "1.00 Cayman Islands dollar random",
4862 "1.00 Cayman Islands dollars random",
4863 "1.00 Chilean Peso random",
4864 "1.00 Chilean Unit of Account (UF) random",
4865 "1.00 Chilean peso random",
4866 "1.00 Chilean pesos random",
4867 "1.00 Chilean unit of account (UF) random",
4868 "1.00 Chilean units of account (UF) random",
4869 "1.00 Chinese Yuan random",
4870 "1.00 Chinese yuan random",
4871 "1.00 Colombian Peso random",
4872 "1.00 Colombian peso random",
4873 "1.00 Colombian pesos random",
4874 "1.00 Comorian Franc random",
4875 "1.00 Comorian franc random",
4876 "1.00 Comorian francs random",
4877 "1.00 Congolese Franc Congolais random",
4878 "1.00 Congolese franc Congolais random",
4879 "1.00 Congolese francs Congolais random",
4880 "1.00 Costa Rican Col\\u00f3n random",
4881 "1.00 Costa Rican col\\u00f3n random",
4882 "1.00 Costa Rican col\\u00f3ns random",
4883 "1.00 Croatian Dinar random",
4884 "1.00 Croatian Kuna random",
4885 "1.00 Croatian dinar random",
4886 "1.00 Croatian dinars random",
4887 "1.00 Croatian kuna random",
4888 "1.00 Croatian kunas random",
4889 "1.00 Cuban Peso random",
4890 "1.00 Cuban peso random",
4891 "1.00 Cuban pesos random",
4892 "1.00 Cypriot Pound random",
4893 "1.00 Cypriot pound random",
4894 "1.00 Cypriot pounds random",
4895 "1.00 Czech Republic Koruna random",
4896 "1.00 Czech Republic koruna random",
4897 "1.00 Czech Republic korunas random",
4898 "1.00 Czechoslovak Hard Koruna random",
4899 "1.00 Czechoslovak hard koruna random",
4900 "1.00 Czechoslovak hard korunas random",
4901 "1.00 Danish Krone random",
4902 "1.00 Danish krone random",
4903 "1.00 Danish kroner random",
4904 "1.00 German Mark random",
4905 "1.00 German mark random",
4906 "1.00 German marks random",
4907 "1.00 Djiboutian Franc random",
4908 "1.00 Djiboutian franc random",
4909 "1.00 Djiboutian francs random",
4910 "1.00 Dominican Peso random",
4911 "1.00 Dominican peso random",
4912 "1.00 Dominican pesos random",
4913 "1.00 East Caribbean Dollar random",
4914 "1.00 East Caribbean dollar random",
4915 "1.00 East Caribbean dollars random",
4916 "1.00 East German Mark random",
4917 "1.00 East German mark random",
4918 "1.00 East German marks random",
4919 "1.00 Ecuadorian Sucre random",
4920 "1.00 Ecuadorian Unit of Constant Value random",
4921 "1.00 Ecuadorian sucre random",
4922 "1.00 Ecuadorian sucres random",
4923 "1.00 Ecuadorian unit of constant value random",
4924 "1.00 Ecuadorian units of constant value random",
4925 "1.00 Egyptian Pound random",
4926 "1.00 Egyptian pound random",
4927 "1.00 Egyptian pounds random",
4928 "1.00 Salvadoran Col\\u00f3n random",
4929 "1.00 Salvadoran col\\u00f3n random",
4930 "1.00 Salvadoran colones random",
4931 "1.00 Equatorial Guinean Ekwele random",
4932 "1.00 Equatorial Guinean ekwele random",
4933 "1.00 Eritrean Nakfa random",
4934 "1.00 Eritrean nakfa random",
4935 "1.00 Eritrean nakfas random",
4936 "1.00 Estonian Kroon random",
4937 "1.00 Estonian kroon random",
4938 "1.00 Estonian kroons random",
4939 "1.00 Ethiopian Birr random",
4940 "1.00 Ethiopian birr random",
4941 "1.00 Ethiopian birrs random",
4942 "1.00 European Composite Unit random",
4943 "1.00 European Currency Unit random",
4944 "1.00 European Monetary Unit random",
4945 "1.00 European Unit of Account (XBC) random",
4946 "1.00 European Unit of Account (XBD) random",
4947 "1.00 European composite unit random",
4948 "1.00 European composite units random",
4949 "1.00 European currency unit random",
4950 "1.00 European currency units random",
4951 "1.00 European monetary unit random",
4952 "1.00 European monetary units random",
4953 "1.00 European unit of account (XBC) random",
4954 "1.00 European unit of account (XBD) random",
4955 "1.00 European units of account (XBC) random",
4956 "1.00 European units of account (XBD) random",
4957 "1.00 Falkland Islands Pound random",
4958 "1.00 Falkland Islands pound random",
4959 "1.00 Falkland Islands pounds random",
4960 "1.00 Fijian Dollar random",
4961 "1.00 Fijian dollar random",
4962 "1.00 Fijian dollars random",
4963 "1.00 Finnish Markka random",
4964 "1.00 Finnish markka random",
4965 "1.00 Finnish markkas random",
4966 "1.00 French Franc random",
4967 "1.00 French Gold Franc random",
4968 "1.00 French UIC-Franc random",
4969 "1.00 French UIC-franc random",
4970 "1.00 French UIC-francs random",
4971 "1.00 French franc random",
4972 "1.00 French francs random",
4973 "1.00 French gold franc random",
4974 "1.00 French gold francs random",
4975 "1.00 Gambian Dalasi random",
4976 "1.00 Gambian dalasi random",
4977 "1.00 Gambian dalasis random",
4978 "1.00 Georgian Kupon Larit random",
4979 "1.00 Georgian Lari random",
4980 "1.00 Georgian kupon larit random",
4981 "1.00 Georgian kupon larits random",
4982 "1.00 Georgian lari random",
4983 "1.00 Georgian laris random",
4984 "1.00 Ghanaian Cedi (1979-2007) random",
4985 "1.00 Ghanaian Cedi random",
4986 "1.00 Ghanaian cedi (1979-2007) random",
4987 "1.00 Ghanaian cedi random",
4988 "1.00 Ghanaian cedis (1979-2007) random",
4989 "1.00 Ghanaian cedis random",
4990 "1.00 Gibraltar Pound random",
4991 "1.00 Gibraltar pound random",
4992 "1.00 Gibraltar pounds random",
4995 "1.00 Greek Drachma random",
4996 "1.00 Greek drachma random",
4997 "1.00 Greek drachmas random",
4998 "1.00 Guatemalan Quetzal random",
4999 "1.00 Guatemalan quetzal random",
5000 "1.00 Guatemalan quetzals random",
5001 "1.00 Guinean Franc random",
5002 "1.00 Guinean Syli random",
5003 "1.00 Guinean franc random",
5004 "1.00 Guinean francs random",
5005 "1.00 Guinean syli random",
5006 "1.00 Guinean sylis random",
5007 "1.00 Guinea-Bissau Peso random",
5008 "1.00 Guinea-Bissau peso random",
5009 "1.00 Guinea-Bissau pesos random",
5010 "1.00 Guyanaese Dollar random",
5011 "1.00 Guyanaese dollar random",
5012 "1.00 Guyanaese dollars random",
5013 "1.00 Haitian Gourde random",
5014 "1.00 Haitian gourde random",
5015 "1.00 Haitian gourdes random",
5016 "1.00 Honduran Lempira random",
5017 "1.00 Honduran lempira random",
5018 "1.00 Honduran lempiras random",
5019 "1.00 Hong Kong Dollar random",
5020 "1.00 Hong Kong dollar random",
5021 "1.00 Hong Kong dollars random",
5022 "1.00 Hungarian Forint random",
5023 "1.00 Hungarian forint random",
5024 "1.00 Hungarian forints random",
5025 "1.00 Icelandic Kr\\u00f3na random",
5026 "1.00 Icelandic kr\\u00f3na random",
5027 "1.00 Icelandic kr\\u00f3nur random",
5028 "1.00 Indian Rupee random",
5029 "1.00 Indian rupee random",
5030 "1.00 Indian rupees random",
5031 "1.00 Indonesian Rupiah random",
5032 "1.00 Indonesian rupiah random",
5033 "1.00 Indonesian rupiahs random",
5034 "1.00 Iranian Rial random",
5035 "1.00 Iranian rial random",
5036 "1.00 Iranian rials random",
5037 "1.00 Iraqi Dinar random",
5038 "1.00 Iraqi dinar random",
5039 "1.00 Iraqi dinars random",
5040 "1.00 Irish Pound random",
5041 "1.00 Irish pound random",
5042 "1.00 Irish pounds random",
5043 "1.00 Israeli Pound random",
5044 "1.00 Israeli new sheqel random",
5045 "1.00 Israeli pound random",
5046 "1.00 Israeli pounds random",
5047 "1.00 Italian Lira random",
5048 "1.00 Italian lira random",
5049 "1.00 Italian liras random",
5050 "1.00 Jamaican Dollar random",
5051 "1.00 Jamaican dollar random",
5052 "1.00 Jamaican dollars random",
5053 "1.00 Japanese Yen random",
5054 "1.00 Japanese yen random",
5055 "1.00 Jordanian Dinar random",
5056 "1.00 Jordanian dinar random",
5057 "1.00 Jordanian dinars random",
5058 "1.00 Kazakhstani Tenge random",
5059 "1.00 Kazakhstani tenge random",
5060 "1.00 Kazakhstani tenges random",
5061 "1.00 Kenyan Shilling random",
5062 "1.00 Kenyan shilling random",
5063 "1.00 Kenyan shillings random",
5064 "1.00 Kuwaiti Dinar random",
5065 "1.00 Kuwaiti dinar random",
5066 "1.00 Kuwaiti dinars random",
5067 "1.00 Kyrgystani Som random",
5068 "1.00 Kyrgystani som random",
5069 "1.00 Kyrgystani soms random",
5070 "1.00 Laotian Kip random",
5071 "1.00 Laotian kip random",
5072 "1.00 Laotian kips random",
5073 "1.00 Latvian Lats random",
5074 "1.00 Latvian Ruble random",
5075 "1.00 Latvian lats random",
5076 "1.00 Latvian lati random",
5077 "1.00 Latvian ruble random",
5078 "1.00 Latvian rubles random",
5079 "1.00 Lebanese Pound random",
5080 "1.00 Lebanese pound random",
5081 "1.00 Lebanese pounds random",
5082 "1.00 Lesotho Loti random",
5083 "1.00 Lesotho loti random",
5084 "1.00 Lesotho lotis random",
5085 "1.00 Liberian Dollar random",
5086 "1.00 Liberian dollar random",
5087 "1.00 Liberian dollars random",
5088 "1.00 Libyan Dinar random",
5089 "1.00 Libyan dinar random",
5090 "1.00 Libyan dinars random",
5091 "1.00 Lithuanian Litas random",
5092 "1.00 Lithuanian Talonas random",
5093 "1.00 Lithuanian litas random",
5094 "1.00 Lithuanian litai random",
5095 "1.00 Lithuanian talonas random",
5096 "1.00 Lithuanian talonases random",
5097 "1.00 Luxembourgian Convertible Franc random",
5098 "1.00 Luxembourg Financial Franc random",
5099 "1.00 Luxembourgian Franc random",
5100 "1.00 Luxembourgian convertible franc random",
5101 "1.00 Luxembourgian convertible francs random",
5102 "1.00 Luxembourg financial franc random",
5103 "1.00 Luxembourg financial francs random",
5104 "1.00 Luxembourgian franc random",
5105 "1.00 Luxembourgian francs random",
5106 "1.00 Macanese Pataca random",
5107 "1.00 Macanese pataca random",
5108 "1.00 Macanese patacas random",
5109 "1.00 Macedonian Denar random",
5110 "1.00 Macedonian denar random",
5111 "1.00 Macedonian denari random",
5112 "1.00 Malagasy Ariaries random",
5113 "1.00 Malagasy Ariary random",
5114 "1.00 Malagasy Ariary random",
5115 "1.00 Malagasy Franc random",
5116 "1.00 Malagasy franc random",
5117 "1.00 Malagasy francs random",
5118 "1.00 Malawian Kwacha random",
5119 "1.00 Malawian Kwacha random",
5120 "1.00 Malawian Kwachas random",
5121 "1.00 Malaysian Ringgit random",
5122 "1.00 Malaysian ringgit random",
5123 "1.00 Malaysian ringgits random",
5124 "1.00 Maldivian Rufiyaa random",
5125 "1.00 Maldivian rufiyaa random",
5126 "1.00 Maldivian rufiyaas random",
5127 "1.00 Malian Franc random",
5128 "1.00 Malian franc random",
5129 "1.00 Malian francs random",
5130 "1.00 Maltese Lira random",
5131 "1.00 Maltese Pound random",
5132 "1.00 Maltese lira random",
5133 "1.00 Maltese liras random",
5134 "1.00 Maltese pound random",
5135 "1.00 Maltese pounds random",
5136 "1.00 Mauritanian Ouguiya random",
5137 "1.00 Mauritanian ouguiya random",
5138 "1.00 Mauritanian ouguiyas random",
5139 "1.00 Mauritian Rupee random",
5140 "1.00 Mauritian rupee random",
5141 "1.00 Mauritian rupees random",
5142 "1.00 Mexican Peso random",
5143 "1.00 Mexican Silver Peso (1861-1992) random",
5144 "1.00 Mexican Investment Unit random",
5145 "1.00 Mexican peso random",
5146 "1.00 Mexican pesos random",
5147 "1.00 Mexican silver peso (1861-1992) random",
5148 "1.00 Mexican silver pesos (1861-1992) random",
5149 "1.00 Mexican investment unit random",
5150 "1.00 Mexican investment units random",
5151 "1.00 Moldovan Leu random",
5152 "1.00 Moldovan leu random",
5153 "1.00 Moldovan lei random",
5154 "1.00 Mongolian Tugrik random",
5155 "1.00 Mongolian tugrik random",
5156 "1.00 Mongolian tugriks random",
5157 "1.00 Moroccan Dirham random",
5158 "1.00 Moroccan Franc random",
5159 "1.00 Moroccan dirham random",
5160 "1.00 Moroccan dirhams random",
5161 "1.00 Moroccan franc random",
5162 "1.00 Moroccan francs random",
5163 "1.00 Mozambican Escudo random",
5164 "1.00 Mozambican Metical random",
5165 "1.00 Mozambican escudo random",
5166 "1.00 Mozambican escudos random",
5167 "1.00 Mozambican metical random",
5168 "1.00 Mozambican meticals random",
5169 "1.00 Myanma Kyat random",
5170 "1.00 Myanma kyat random",
5171 "1.00 Myanma kyats random",
5172 "1.00 Namibian Dollar random",
5173 "1.00 Namibian dollar random",
5174 "1.00 Namibian dollars random",
5175 "1.00 Nepalese Rupee random",
5176 "1.00 Nepalese rupee random",
5177 "1.00 Nepalese rupees random",
5178 "1.00 Netherlands Antillean Guilder random",
5179 "1.00 Netherlands Antillean guilder random",
5180 "1.00 Netherlands Antillean guilders random",
5181 "1.00 Dutch Guilder random",
5182 "1.00 Dutch guilder random",
5183 "1.00 Dutch guilders random",
5184 "1.00 Israeli New Sheqel random",
5185 "1.00 Israeli new sheqels random",
5186 "1.00 New Zealand Dollar random",
5187 "1.00 New Zealand dollar random",
5188 "1.00 New Zealand dollars random",
5189 "1.00 Nicaraguan C\\u00f3rdoba random",
5190 "1.00 Nicaraguan C\\u00f3rdoba (1988-1991) random",
5191 "1.00 Nicaraguan c\\u00f3rdoba random",
5192 "1.00 Nicaraguan c\\u00f3rdoba random",
5193 "1.00 Nicaraguan c\\u00f3rdoba (1988-1991) random",
5194 "1.00 Nicaraguan c\\u00f3rdobas (1988-1991) random",
5195 "1.00 Nigerian Naira random",
5196 "1.00 Nigerian naira random",
5197 "1.00 Nigerian nairas random",
5198 "1.00 North Korean Won random",
5199 "1.00 North Korean won random",
5200 "1.00 North Korean won random",
5201 "1.00 Norwegian Krone random",
5202 "1.00 Norwegian krone random",
5203 "1.00 Norwegian kroner random",
5204 "1.00 Mozambican Metical (1980-2006) random",
5205 "1.00 Mozambican metical (1980-2006) random",
5206 "1.00 Mozambican meticals (1980-2006) random",
5207 "1.00 Romanian Lei (1952-2006) random",
5208 "1.00 Romanian Leu (1952-2006) random",
5209 "1.00 Romanian leu (1952-2006) random",
5210 "1.00 Serbian Dinar (2002-2006) random",
5211 "1.00 Serbian dinar (2002-2006) random",
5212 "1.00 Serbian dinars (2002-2006) random",
5213 "1.00 Sudanese Dinar (1992-2007) random",
5214 "1.00 Sudanese Pound (1957-1998) random",
5215 "1.00 Sudanese dinar (1992-2007) random",
5216 "1.00 Sudanese dinars (1992-2007) random",
5217 "1.00 Sudanese pound (1957-1998) random",
5218 "1.00 Sudanese pounds (1957-1998) random",
5219 "1.00 Turkish Lira (1922-2005) random",
5220 "1.00 Turkish Lira (1922-2005) random",
5221 "1.00 Omani Rial random",
5222 "1.00 Omani rial random",
5223 "1.00 Omani rials random",
5224 "1.00 Pakistani Rupee random",
5225 "1.00 Pakistani rupee random",
5226 "1.00 Pakistani rupees random",
5227 "1.00 Palladium random",
5228 "1.00 Palladium random",
5229 "1.00 Panamanian Balboa random",
5230 "1.00 Panamanian balboa random",
5231 "1.00 Panamanian balboas random",
5232 "1.00 Papua New Guinean Kina random",
5233 "1.00 Papua New Guinean kina random",
5234 "1.00 Papua New Guinean kina random",
5235 "1.00 Paraguayan Guarani random",
5236 "1.00 Paraguayan guarani random",
5237 "1.00 Paraguayan guaranis random",
5238 "1.00 Peruvian Inti random",
5239 "1.00 Peruvian Nuevo Sol random",
5240 "1.00 Peruvian Sol (1863-1965) random",
5241 "1.00 Peruvian inti random",
5242 "1.00 Peruvian intis random",
5243 "1.00 Peruvian nuevo sol random",
5244 "1.00 Peruvian nuevos soles random",
5245 "1.00 Peruvian sol (1863-1965) random",
5246 "1.00 Peruvian soles (1863-1965) random",
5247 "1.00 Philippine Peso random",
5248 "1.00 Philippine peso random",
5249 "1.00 Philippine pesos random",
5250 "1.00 Platinum random",
5251 "1.00 Platinum random",
5252 "1.00 Polish Zloty (1950-1995) random",
5253 "1.00 Polish Zloty random",
5254 "1.00 Polish zlotys random",
5255 "1.00 Polish zloty (PLZ) random",
5256 "1.00 Polish zloty random",
5257 "1.00 Polish zlotys (PLZ) random",
5258 "1.00 Portuguese Escudo random",
5259 "1.00 Portuguese Guinea Escudo random",
5260 "1.00 Portuguese Guinea escudo random",
5261 "1.00 Portuguese Guinea escudos random",
5262 "1.00 Portuguese escudo random",
5263 "1.00 Portuguese escudos random",
5264 "1.00 Qatari Rial random",
5265 "1.00 Qatari rial random",
5266 "1.00 Qatari rials random",
5267 "1.00 RINET Funds random",
5268 "1.00 RINET Funds random",
5269 "1.00 Rhodesian Dollar random",
5270 "1.00 Rhodesian dollar random",
5271 "1.00 Rhodesian dollars random",
5272 "1.00 Romanian Leu random",
5273 "1.00 Romanian lei random",
5274 "1.00 Romanian leu random",
5275 "1.00 Russian Ruble (1991-1998) random",
5276 "1.00 Russian Ruble random",
5277 "1.00 Russian ruble (1991-1998) random",
5278 "1.00 Russian ruble random",
5279 "1.00 Russian rubles (1991-1998) random",
5280 "1.00 Russian rubles random",
5281 "1.00 Rwandan Franc random",
5282 "1.00 Rwandan franc random",
5283 "1.00 Rwandan francs random",
5284 "1.00 Saint Helena Pound random",
5285 "1.00 Saint Helena pound random",
5286 "1.00 Saint Helena pounds random",
5287 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra random",
5288 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra random",
5289 "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras random",
5290 "1.00 Saudi Riyal random",
5291 "1.00 Saudi riyal random",
5292 "1.00 Saudi riyals random",
5293 "1.00 Serbian Dinar random",
5294 "1.00 Serbian dinar random",
5295 "1.00 Serbian dinars random",
5296 "1.00 Seychellois Rupee random",
5297 "1.00 Seychellois rupee random",
5298 "1.00 Seychellois rupees random",
5299 "1.00 Sierra Leonean Leone random",
5300 "1.00 Sierra Leonean leone random",
5301 "1.00 Sierra Leonean leones random",
5302 "1.00 Singapore Dollar random",
5303 "1.00 Singapore dollar random",
5304 "1.00 Singapore dollars random",
5305 "1.00 Slovak Koruna random",
5306 "1.00 Slovak koruna random",
5307 "1.00 Slovak korunas random",
5308 "1.00 Slovenian Tolar random",
5309 "1.00 Slovenian tolar random",
5310 "1.00 Slovenian tolars random",
5311 "1.00 Solomon Islands Dollar random",
5312 "1.00 Solomon Islands dollar random",
5313 "1.00 Solomon Islands dollars random",
5314 "1.00 Somali Shilling random",
5315 "1.00 Somali shilling random",
5316 "1.00 Somali shillings random",
5317 "1.00 South African Rand (financial) random",
5318 "1.00 South African Rand random",
5319 "1.00 South African rand (financial) random",
5320 "1.00 South African rand random",
5321 "1.00 South African rands (financial) random",
5322 "1.00 South African rand random",
5323 "1.00 South Korean Won random",
5324 "1.00 South Korean won random",
5325 "1.00 South Korean won random",
5326 "1.00 Soviet Rouble random",
5327 "1.00 Soviet rouble random",
5328 "1.00 Soviet roubles random",
5329 "1.00 Spanish Peseta (A account) random",
5330 "1.00 Spanish Peseta (convertible account) random",
5331 "1.00 Spanish Peseta random",
5332 "1.00 Spanish peseta (A account) random",
5333 "1.00 Spanish peseta (convertible account) random",
5334 "1.00 Spanish peseta random",
5335 "1.00 Spanish pesetas (A account) random",
5336 "1.00 Spanish pesetas (convertible account) random",
5337 "1.00 Spanish pesetas random",
5338 "1.00 Special Drawing Rights random",
5339 "1.00 Sri Lankan Rupee random",
5340 "1.00 Sri Lankan rupee random",
5341 "1.00 Sri Lankan rupees random",
5342 "1.00 Sudanese Pound random",
5343 "1.00 Sudanese pound random",
5344 "1.00 Sudanese pounds random",
5345 "1.00 Surinamese Dollar random",
5346 "1.00 Surinamese dollar random",
5347 "1.00 Surinamese dollars random",
5348 "1.00 Surinamese Guilder random",
5349 "1.00 Surinamese guilder random",
5350 "1.00 Surinamese guilders random",
5351 "1.00 Swazi Lilangeni random",
5352 "1.00 Swazi lilangeni random",
5353 "1.00 Swazi emalangeni random",
5354 "1.00 Swedish Krona random",
5355 "1.00 Swedish krona random",
5356 "1.00 Swedish kronor random",
5357 "1.00 Swiss Franc random",
5358 "1.00 Swiss franc random",
5359 "1.00 Swiss francs random",
5360 "1.00 Syrian Pound random",
5361 "1.00 Syrian pound random",
5362 "1.00 Syrian pounds random",
5363 "1.00 New Taiwan Dollar random",
5364 "1.00 New Taiwan dollar random",
5365 "1.00 New Taiwan dollars random",
5366 "1.00 Tajikistani Ruble random",
5367 "1.00 Tajikistani Somoni random",
5368 "1.00 Tajikistani ruble random",
5369 "1.00 Tajikistani rubles random",
5370 "1.00 Tajikistani somoni random",
5371 "1.00 Tajikistani somonis random",
5372 "1.00 Tanzanian Shilling random",
5373 "1.00 Tanzanian shilling random",
5374 "1.00 Tanzanian shillings random",
5375 "1.00 Testing Currency Code random",
5376 "1.00 Testing Currency Code random",
5377 "1.00 Thai Baht random",
5378 "1.00 Thai baht random",
5379 "1.00 Thai baht random",
5380 "1.00 Timorese Escudo random",
5381 "1.00 Timorese escudo random",
5382 "1.00 Timorese escudos random",
5383 "1.00 Trinidad and Tobago Dollar random",
5384 "1.00 Trinidad and Tobago dollar random",
5385 "1.00 Trinidad and Tobago dollars random",
5386 "1.00 Tunisian Dinar random",
5387 "1.00 Tunisian dinar random",
5388 "1.00 Tunisian dinars random",
5389 "1.00 Turkish Lira random",
5390 "1.00 Turkish Lira random",
5391 "1.00 Turkish lira random",
5392 "1.00 Turkmenistani Manat random",
5393 "1.00 Turkmenistani manat random",
5394 "1.00 Turkmenistani manat random",
5395 "1.00 US Dollar (Next day) random",
5396 "1.00 US Dollar (Same day) random",
5397 "1.00 US Dollar random",
5398 "1.00 US dollar (next day) random",
5399 "1.00 US dollar (same day) random",
5400 "1.00 US dollar random",
5401 "1.00 US dollars (next day) random",
5402 "1.00 US dollars (same day) random",
5403 "1.00 US dollars random",
5404 "1.00 Ugandan Shilling (1966-1987) random",
5405 "1.00 Ugandan Shilling random",
5406 "1.00 Ugandan shilling (1966-1987) random",
5407 "1.00 Ugandan shilling random",
5408 "1.00 Ugandan shillings (1966-1987) random",
5409 "1.00 Ugandan shillings random",
5410 "1.00 Ukrainian Hryvnia random",
5411 "1.00 Ukrainian Karbovanets random",
5412 "1.00 Ukrainian hryvnia random",
5413 "1.00 Ukrainian hryvnias random",
5414 "1.00 Ukrainian karbovanets random",
5415 "1.00 Ukrainian karbovantsiv random",
5416 "1.00 Colombian Real Value Unit random",
5417 "1.00 United Arab Emirates Dirham random",
5418 "1.00 Unknown Currency random",
5419 "1.00 Uruguayan Peso (1975-1993) random",
5420 "1.00 Uruguayan Peso random",
5421 "1.00 Uruguayan Peso (Indexed Units) random",
5422 "1.00 Uruguayan peso (1975-1993) random",
5423 "1.00 Uruguayan peso (indexed units) random",
5424 "1.00 Uruguayan peso random",
5425 "1.00 Uruguayan pesos (1975-1993) random",
5426 "1.00 Uruguayan pesos (indexed units) random",
5427 "1.00 Uzbekistan Som random",
5428 "1.00 Uzbekistan som random",
5429 "1.00 Uzbekistan som random",
5430 "1.00 Vanuatu Vatu random",
5431 "1.00 Vanuatu vatu random",
5432 "1.00 Vanuatu vatus random",
5433 "1.00 Venezuelan Bol\\u00edvar random",
5434 "1.00 Venezuelan Bol\\u00edvar (1871-2008) random",
5435 "1.00 Venezuelan bol\\u00edvar random",
5436 "1.00 Venezuelan bol\\u00edvars random",
5437 "1.00 Venezuelan bol\\u00edvar (1871-2008) random",
5438 "1.00 Venezuelan bol\\u00edvars (1871-2008) random",
5439 "1.00 Vietnamese Dong random",
5440 "1.00 Vietnamese dong random",
5441 "1.00 Vietnamese dong random",
5442 "1.00 WIR Euro random",
5443 "1.00 WIR Franc random",
5444 "1.00 WIR euro random",
5445 "1.00 WIR euros random",
5446 "1.00 WIR franc random",
5447 "1.00 WIR francs random",
5448 "1.00 Samoan Tala random",
5449 "1.00 Samoan tala random",
5450 "1.00 Samoan tala random",
5451 "1.00 Yemeni Dinar random",
5452 "1.00 Yemeni Rial random",
5453 "1.00 Yemeni dinar random",
5454 "1.00 Yemeni dinars random",
5455 "1.00 Yemeni rial random",
5456 "1.00 Yemeni rials random",
5457 "1.00 Yugoslavian Convertible Dinar (1990-1992) random",
5458 "1.00 Yugoslavian Hard Dinar (1966-1990) random",
5459 "1.00 Yugoslavian New Dinar (1994-2002) random",
5460 "1.00 Yugoslavian convertible dinar (1990-1992) random",
5461 "1.00 Yugoslavian convertible dinars (1990-1992) random",
5462 "1.00 Yugoslavian hard dinar (1966-1990) random",
5463 "1.00 Yugoslavian hard dinars (1966-1990) random",
5464 "1.00 Yugoslavian new dinar (1994-2002) random",
5465 "1.00 Yugoslavian new dinars (1994-2002) random",
5466 "1.00 Zairean New Zaire (1993-1998) random",
5467 "1.00 Zairean Zaire (1971-1993) random",
5468 "1.00 Zairean new zaire (1993-1998) random",
5469 "1.00 Zairean new zaires (1993-1998) random",
5470 "1.00 Zairean zaire (1971-1993) random",
5471 "1.00 Zairean zaires (1971-1993) random",
5472 "1.00 Zambian Kwacha random",
5473 "1.00 Zambian kwacha random",
5474 "1.00 Zambian kwachas random",
5475 "1.00 Zimbabwean Dollar (1980-2008) random",
5476 "1.00 Zimbabwean dollar (1980-2008) random",
5477 "1.00 Zimbabwean dollars (1980-2008) random",
5479 "1.00 euros random",
5480 "1.00 Turkish lira (1922-2005) random",
5481 "1.00 special drawing rights random",
5482 "1.00 Colombian real value unit random",
5483 "1.00 Colombian real value units random",
5484 "1.00 unknown currency random",
5487 const char* WRONG_DATA
[] = {
5488 // Following are missing one last char in the currency name
5489 "usd1.00", // case sensitive
5490 "1.00 Nicaraguan Cordob",
5491 "1.00 Namibian Dolla",
5492 "1.00 Namibian dolla",
5493 "1.00 Nepalese Rupe",
5494 "1.00 Nepalese rupe",
5495 "1.00 Netherlands Antillean Guilde",
5496 "1.00 Netherlands Antillean guilde",
5497 "1.00 Dutch Guilde",
5498 "1.00 Dutch guilde",
5499 "1.00 Israeli New Sheqe",
5500 "1.00 New Zealand Dolla",
5501 "1.00 New Zealand dolla",
5502 "1.00 Nicaraguan cordob",
5503 "1.00 Nigerian Nair",
5504 "1.00 Nigerian nair",
5505 "1.00 North Korean Wo",
5506 "1.00 North Korean wo",
5507 "1.00 Norwegian Kron",
5508 "1.00 Norwegian kron",
5524 "Afghan Afghan1.00",
5525 "Afghan Afghani (1927-20021.00",
5528 "Algerian Dina1.00",
5529 "Andorran Peset1.00",
5530 "Angolan Kwanz1.00",
5531 "Angolan Kwanza (1977-19901.00",
5532 "Angolan Readjusted Kwanza (1995-19991.00",
5533 "Angolan New Kwanza (1990-20001.00",
5534 "Argentine Austra1.00",
5535 "Argentine Pes1.00",
5536 "Argentine Peso (1983-19851.00",
5539 "Australian Dolla1.00",
5540 "Austrian Schillin1.00",
5541 "Azerbaijani Mana1.00",
5542 "Azerbaijani Manat (1993-20061.00",
5560 "Bahamian Dolla1.00",
5561 "Bahraini Dina1.00",
5562 "Bangladeshi Tak1.00",
5563 "Barbadian Dolla1.00",
5565 "Belarusian New Ruble (1994-19991.00",
5566 "Belarusian Rubl1.00",
5568 "Belgian Franc (convertible1.00",
5569 "Belgian Franc (financial1.00",
5571 "Bermudan Dolla1.00",
5572 "Bhutanese Ngultru1.00",
5573 "Bolivian Mvdo1.00",
5575 "Bolivian Bolivian1.00",
5576 "Bosnia-Herzegovina Convertible Mar1.00",
5577 "Bosnia-Herzegovina Dina1.00",
5578 "Botswanan Pul1.00",
5579 "Brazilian Cruzad1.00",
5580 "Brazilian Cruzado Nov1.00",
5581 "Brazilian Cruzeir1.00",
5582 "Brazilian Cruzeiro (1990-19931.00",
5583 "Brazilian New Cruzeiro (1967-19861.00",
5584 "Brazilian Rea1.00",
5585 "British Pound Sterlin1.00",
5587 "Bulgarian Hard Le1.00",
5590 "Burundian Fran1.00",
5594 "CFA Franc BCEA1.00",
5595 "CFA Franc BEA1.00",
5607 "Cambodian Rie1.00",
5608 "Canadian Dolla1.00",
5609 "Cape Verdean Escud1.00",
5610 "Cayman Islands Dolla1.00",
5612 "Chilean Unit of Accoun1.00",
5614 "Colombian Pes1.00",
5616 "Congolese Fran1.00",
5617 "Costa Rican Col\\u00f31.00",
5618 "Croatian Dina1.00",
5622 "Czech Republic Korun1.00",
5623 "Czechoslovak Hard Korun1.00",
5633 "Djiboutian Fran1.00",
5635 "Dominican Pes1.00",
5644 "East Caribbean Dolla1.00",
5645 "East German Ostmar1.00",
5646 "Ecuadorian Sucr1.00",
5647 "Ecuadorian Unit of Constant Valu1.00",
5648 "Egyptian Poun1.00",
5650 "Salvadoran Col\\u00f31.00",
5651 "Equatorial Guinean Ekwel1.00",
5652 "Eritrean Nakf1.00",
5654 "Estonian Kroo1.00",
5655 "Ethiopian Bir1.00",
5657 "European Composite Uni1.00",
5658 "European Currency Uni1.00",
5659 "European Monetary Uni1.00",
5660 "European Unit of Account (XBC1.00",
5661 "European Unit of Account (XBD1.00",
5668 "Falkland Islands Poun1.00",
5671 "Finnish Markk1.00",
5674 "French Gold Fran1.00",
5675 "French UIC-Fran1.00",
5688 "Gambian Dalas1.00",
5689 "Georgian Kupon Lari1.00",
5692 "Ghanaian Cedi (1979-20071.00",
5693 "Gibraltar Poun1.00",
5696 "Guatemalan Quetza1.00",
5699 "Guinea-Bissau Pes1.00",
5700 "Guyanaese Dolla1.00",
5706 "Haitian Gourd1.00",
5707 "Honduran Lempir1.00",
5708 "Hong Kong Dolla1.00",
5709 "Hungarian Forin1.00",
5718 "Icelandic Kron1.00",
5720 "Indonesian Rupia1.00",
5730 "Jamaican Dolla1.00",
5732 "Jordanian Dina1.00",
5743 "Kazakhstani Teng1.00",
5744 "Kenyan Shillin1.00",
5746 "Kyrgystani So1.00",
5758 "Lebanese Poun1.00",
5760 "Liberian Dolla1.00",
5762 "Lithuanian Lit1.00",
5763 "Lithuanian Talona1.00",
5764 "Luxembourgian Convertible Fran1.00",
5765 "Luxembourg Financial Fran1.00",
5766 "Luxembourgian Fran1.00",
5784 "Macanese Patac1.00",
5785 "Macedonian Dena1.00",
5786 "Malagasy Ariar1.00",
5787 "Malagasy Fran1.00",
5788 "Malawian Kwach1.00",
5789 "Malaysian Ringgi1.00",
5790 "Maldivian Rufiya1.00",
5795 "Mauritanian Ouguiy1.00",
5796 "Mauritian Rupe1.00",
5798 "Mexican Silver Peso (1861-19921.00",
5799 "Mexican Investment Uni1.00",
5801 "Mongolian Tugri1.00",
5802 "Moroccan Dirha1.00",
5803 "Moroccan Fran1.00",
5804 "Mozambican Escud1.00",
5805 "Mozambican Metica1.00",
5817 "Namibian Dolla1.00",
5818 "Nepalese Rupe1.00",
5819 "Netherlands Antillean Guilde1.00",
5821 "Israeli New Sheqe1.00",
5822 "New Zealand Dolla1.00",
5823 "Nicaraguan C\\u00f3rdoba (1988-19911.00",
5824 "Nicaraguan C\\u00f3rdob1.00",
5825 "Nigerian Nair1.00",
5826 "North Korean Wo1.00",
5827 "Norwegian Kron1.00",
5830 "Old Mozambican Metica1.00",
5831 "Romanian Leu (1952-20061.00",
5832 "Serbian Dinar (2002-20061.00",
5833 "Sudanese Dinar (1992-20071.00",
5834 "Sudanese Pound (1957-19981.00",
5835 "Turkish Lira (1922-20051.00",
5845 "Pakistani Rupe1.00",
5847 "Panamanian Balbo1.00",
5848 "Papua New Guinean Kin1.00",
5849 "Paraguayan Guaran1.00",
5851 "Peruvian Sol (1863-19651.00",
5852 "Peruvian Sol Nuev1.00",
5853 "Philippine Pes1.00",
5856 "Polish Zloty (1950-19951.00",
5857 "Portuguese Escud1.00",
5858 "Portuguese Guinea Escud1.00",
5869 "Rhodesian Dolla1.00",
5872 "Russian Ruble (1991-19981.00",
5892 "Saint Helena Poun1.00",
5893 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobr1.00",
5896 "Seychellois Rupe1.00",
5898 "Sierra Leonean Leon1.00",
5900 "Singapore Dolla1.00",
5902 "Slovenian Tola1.00",
5903 "Solomon Islands Dolla1.00",
5904 "Somali Shillin1.00",
5905 "South African Ran1.00",
5906 "South African Rand (financial1.00",
5907 "South Korean Wo1.00",
5909 "Spanish Peset1.00",
5910 "Spanish Peseta (A account1.00",
5911 "Spanish Peseta (convertible account1.00",
5912 "Special Drawing Right1.00",
5913 "Sri Lankan Rupe1.00",
5914 "Sudanese Poun1.00",
5915 "Surinamese Dolla1.00",
5916 "Surinamese Guilde1.00",
5917 "Swazi Lilangen1.00",
5932 "New Taiwan Dolla1.00",
5933 "Tajikistani Rubl1.00",
5934 "Tajikistani Somon1.00",
5935 "Tanzanian Shillin1.00",
5936 "Testing Currency Cod1.00",
5938 "Timorese Escud1.00",
5939 "Tongan Pa\\u20bbang1.00",
5940 "Trinidad and Tobago Dolla1.00",
5941 "Tunisian Dina1.00",
5943 "Turkmenistani Mana1.00",
5949 "US Dollar (Next day1.00",
5950 "US Dollar (Same day1.00",
5954 "Ugandan Shillin1.00",
5955 "Ugandan Shilling (1966-19871.00",
5956 "Ukrainian Hryvni1.00",
5957 "Ukrainian Karbovanet1.00",
5958 "Colombian Real Value Uni1.00",
5959 "United Arab Emirates Dirha1.00",
5960 "Unknown Currenc1.00",
5962 "Uruguay Peso (1975-19931.00",
5963 "Uruguay Peso Uruguay1.00",
5964 "Uruguay Peso (Indexed Units1.00",
5965 "Uzbekistan So1.00",
5971 "Venezuelan Bol\\u00edva1.00",
5972 "Venezuelan Bol\\u00edvar Fuert1.00",
5973 "Vietnamese Don1.00",
5994 "Yugoslavian Convertible Dina1.00",
5995 "Yugoslavian Hard Dinar (1966-19901.00",
5996 "Yugoslavian New Dina1.00",
6002 "Zairean New Zaire (1993-19981.00",
6004 "Zambian Kwach1.00",
6005 "Zimbabwean Dollar (1980-20081.00",
6013 Locale
locale("en_US");
6014 for (uint32_t i
=0; i
<sizeof(DATA
)/sizeof(DATA
[0]); ++i
) {
6015 UnicodeString formatted
= ctou(DATA
[i
]);
6016 UErrorCode status
= U_ZERO_ERROR
;
6017 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, UNUM_CURRENCY
, status
);
6018 if (numFmt
!= NULL
&& U_SUCCESS(status
)) {
6019 ParsePosition parsePos
;
6020 LocalPointer
<CurrencyAmount
> currAmt(numFmt
->parseCurrency(formatted
, parsePos
));
6021 if (parsePos
.getIndex() > 0) {
6022 double doubleVal
= currAmt
->getNumber().getDouble(status
);
6023 if ( doubleVal
!= 1.0 ) {
6024 errln("Parsed as currency value other than 1.0: " + formatted
+ " -> " + doubleVal
);
6027 errln("Failed to parse as currency: " + formatted
);
6030 dataerrln("Unable to create NumberFormat. - %s", u_errorName(status
));
6037 for (uint32_t i
=0; i
<sizeof(WRONG_DATA
)/sizeof(WRONG_DATA
[0]); ++i
) {
6038 UnicodeString formatted
= ctou(WRONG_DATA
[i
]);
6039 UErrorCode status
= U_ZERO_ERROR
;
6040 NumberFormat
* numFmt
= NumberFormat::createInstance(locale
, UNUM_CURRENCY
, status
);
6041 if (numFmt
!= NULL
&& U_SUCCESS(status
)) {
6042 ParsePosition parsePos
;
6043 LocalPointer
<CurrencyAmount
> currAmt(numFmt
->parseCurrency(formatted
, parsePos
));
6044 if (parsePos
.getIndex() > 0) {
6045 double doubleVal
= currAmt
->getNumber().getDouble(status
);
6046 errln("Parsed as currency, should not have: " + formatted
+ " -> " + doubleVal
);
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
, UNUM_CURRENCY
, status
);
6159 if (failure(status
, "NumberFormat::createInstance", TRUE
)) return;
6160 double val
= 12345.67;
6163 int32_t expected
[] = {
6164 UNUM_CURRENCY_FIELD
, 0, 1,
6165 UNUM_GROUPING_SEPARATOR_FIELD
, 3, 4,
6166 UNUM_INTEGER_FIELD
, 1, 7,
6167 UNUM_DECIMAL_SEPARATOR_FIELD
, 7, 8,
6168 UNUM_FRACTION_FIELD
, 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(UNUM_INTEGER_FIELD
);
6179 UnicodeString result
;
6180 decFmt
->format(val
, result
, fp
);
6181 expectPosition(fp
, UNUM_INTEGER_FIELD
, 1, 7, result
);
6184 FieldPosition
fp(UNUM_FRACTION_FIELD
);
6185 UnicodeString result
;
6186 decFmt
->format(val
, result
, fp
);
6187 expectPosition(fp
, UNUM_FRACTION_FIELD
, 8, 10, result
);
6191 decFmt
= (DecimalFormat
*) NumberFormat::createInstance(locale
, UNUM_SCIENTIFIC
, status
);
6194 int32_t expected
[] = {
6195 UNUM_SIGN_FIELD
, 0, 1,
6196 UNUM_INTEGER_FIELD
, 1, 2,
6197 UNUM_DECIMAL_SEPARATOR_FIELD
, 2, 3,
6198 UNUM_FRACTION_FIELD
, 3, 5,
6199 UNUM_EXPONENT_SYMBOL_FIELD
, 5, 6,
6200 UNUM_EXPONENT_SIGN_FIELD
, 6, 7,
6201 UNUM_EXPONENT_FIELD
, 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(UNUM_INTEGER_FIELD
);
6212 UnicodeString result
;
6213 decFmt
->format(val
, result
, fp
);
6214 expectPosition(fp
, UNUM_INTEGER_FIELD
, 1, 2, result
);
6217 FieldPosition
fp(UNUM_FRACTION_FIELD
);
6218 UnicodeString result
;
6219 decFmt
->format(val
, result
, fp
);
6220 expectPosition(fp
, UNUM_FRACTION_FIELD
, 3, 5, result
);
6227 const char* attrString(int32_t attrId
) {
6229 case UNUM_INTEGER_FIELD
: return "integer";
6230 case UNUM_FRACTION_FIELD
: return "fraction";
6231 case UNUM_DECIMAL_SEPARATOR_FIELD
: return "decimal separator";
6232 case UNUM_EXPONENT_SYMBOL_FIELD
: return "exponent symbol";
6233 case UNUM_EXPONENT_SIGN_FIELD
: return "exponent sign";
6234 case UNUM_EXPONENT_FIELD
: return "exponent";
6235 case UNUM_GROUPING_SEPARATOR_FIELD
: return "grouping separator";
6236 case UNUM_CURRENCY_FIELD
: return "currency";
6237 case UNUM_PERCENT_FIELD
: return "percent";
6238 case UNUM_PERMILL_FIELD
: return "permille";
6239 case UNUM_SIGN_FIELD
: 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(Locale::getUS(), UNUM_DECIMAL
, status
);
6318 if (U_FAILURE(status
) || fmtr
== NULL
) {
6319 dataerrln("Unable to create NumberFormat");
6321 UnicodeString formattedResult
;
6322 StringPiece
num("244444444444444444444444444444444444446.4");
6323 fmtr
->format(num
, formattedResult
, NULL
, status
);
6324 ASSERT_SUCCESS(status
);
6325 ASSERT_EQUALS("244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult
);
6326 //std::string ss; std::cout << formattedResult.toUTF8String(ss);
6332 // Check formatting a DigitList. DigitList is internal, but this is
6333 // a critical interface that must work.
6334 UErrorCode status
= U_ZERO_ERROR
;
6335 NumberFormat
*fmtr
= NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL
, status
);
6336 if (U_FAILURE(status
) || fmtr
== NULL
) {
6337 dataerrln("Unable to create NumberFormat");
6339 UnicodeString formattedResult
;
6341 StringPiece
num("123.4566666666666666666666666666666666621E+40");
6342 dl
.set(num
, status
);
6343 ASSERT_SUCCESS(status
);
6344 fmtr
->format(dl
, formattedResult
, NULL
, status
);
6345 ASSERT_SUCCESS(status
);
6346 ASSERT_EQUALS("1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult
);
6348 status
= U_ZERO_ERROR
;
6350 dl
.set(num
, status
);
6351 FieldPosition
pos(NumberFormat::FRACTION_FIELD
);
6352 ASSERT_SUCCESS(status
);
6353 formattedResult
.remove();
6354 fmtr
->format(dl
, formattedResult
, pos
, status
);
6355 ASSERT_SUCCESS(status
);
6356 ASSERT_EQUALS("666.666", formattedResult
);
6357 ASSERT_EQUALS(4, pos
.getBeginIndex());
6358 ASSERT_EQUALS(7, pos
.getEndIndex());
6364 // Check a parse with a formatter with a multiplier.
6365 UErrorCode status
= U_ZERO_ERROR
;
6366 NumberFormat
*fmtr
= NumberFormat::createInstance(Locale::getUS(), UNUM_PERCENT
, status
);
6367 if (U_FAILURE(status
) || fmtr
== NULL
) {
6368 dataerrln("Unable to create NumberFormat");
6370 UnicodeString input
= "1.84%";
6372 fmtr
->parse(input
, result
, status
);
6373 ASSERT_SUCCESS(status
);
6374 ASSERT_EQUALS(0, strcmp("0.0184", result
.getDecimalNumber(status
).data()));
6375 //std::cout << result.getDecimalNumber(status).data();
6381 // Check that a parse returns a decimal number with full accuracy
6382 UErrorCode status
= U_ZERO_ERROR
;
6383 NumberFormat
*fmtr
= NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL
, status
);
6384 if (U_FAILURE(status
) || fmtr
== NULL
) {
6385 dataerrln("Unable to create NumberFormat");
6387 UnicodeString input
= "1.002200044400088880000070000";
6389 fmtr
->parse(input
, result
, status
);
6390 ASSERT_SUCCESS(status
);
6391 ASSERT_EQUALS(0, strcmp("1.00220004440008888000007", result
.getDecimalNumber(status
).data()));
6392 ASSERT_EQUALS(1.00220004440008888, result
.getDouble());
6393 //std::cout << result.getDecimalNumber(status).data();
6400 void NumberFormatTest::TestCurrencyFractionDigits() {
6401 UErrorCode status
= U_ZERO_ERROR
;
6402 UnicodeString text1
, text2
;
6403 double value
= 99.12345;
6405 // Create currenct instance
6406 NumberFormat
* fmt
= NumberFormat::createCurrencyInstance("ja_JP", status
);
6407 if (U_FAILURE(status
) || fmt
== NULL
) {
6408 dataerrln("Unable to create NumberFormat");
6410 fmt
->format(value
, text1
);
6412 // Reset the same currency and format the test value again
6413 fmt
->setCurrency(fmt
->getCurrency(), status
);
6414 ASSERT_SUCCESS(status
);
6415 fmt
->format(value
, text2
);
6417 if (text1
!= text2
) {
6418 errln((UnicodeString
)"NumberFormat::format() should return the same result - text1="
6419 + text1
+ " text2=" + text2
);
6425 void NumberFormatTest::TestExponentParse() {
6427 UErrorCode status
= U_ZERO_ERROR
;
6429 ParsePosition
parsePos(0);
6431 // set the exponent symbol
6432 status
= U_ZERO_ERROR
;
6433 DecimalFormatSymbols
*symbols
= new DecimalFormatSymbols(Locale::getDefault(), status
);
6434 if(U_FAILURE(status
)) {
6435 dataerrln((UnicodeString
)"ERROR: Could not create DecimalFormatSymbols (Default)");
6439 // create format instance
6440 status
= U_ZERO_ERROR
;
6441 DecimalFormat
fmt("#####", symbols
, status
);
6442 if(U_FAILURE(status
)) {
6443 errln((UnicodeString
)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
6447 fmt
.parse("5.06e-27", result
, parsePos
);
6448 if(result
.getType() != Formattable::kDouble
&&
6449 result
.getDouble() != 5.06E-27 &&
6450 parsePos
.getIndex() != 8
6453 errln("ERROR: parse failed - expected 5.06E-27, 8 - returned %d, %i",
6454 result
.getDouble(), parsePos
.getIndex());
6458 void NumberFormatTest::TestExplicitParents() {
6460 /* Test that number formats are properly inherited from es_419 */
6461 /* These could be subject to change if the CLDR data changes */
6462 static const char* parentLocaleTests
[][2]= {
6463 /* locale ID */ /* expected */
6464 {"es_CO", "1.250,75" },
6465 {"es_CR", "1.250,75" },
6466 {"es_ES", "1.250,75" },
6467 {"es_GQ", "1.250,75" },
6468 {"es_MX", "1,250.75" },
6469 {"es_US", "1,250.75" },
6470 {"es_VE", "1.250,75" },
6475 for(int i
=0; i
< (int)(sizeof(parentLocaleTests
)/sizeof(parentLocaleTests
[i
])); i
++){
6476 UErrorCode status
= U_ZERO_ERROR
;
6477 const char *localeID
= parentLocaleTests
[i
][0];
6478 UnicodeString
expected(parentLocaleTests
[i
][1], -1, US_INV
);
6479 expected
= expected
.unescape();
6481 uloc_canonicalize(localeID
, loc
, 256, &status
);
6482 NumberFormat
*fmt
= NumberFormat::createInstance(Locale(loc
), status
);
6483 if(U_FAILURE(status
)){
6484 dataerrln("Could not create number formatter for locale %s - %s",localeID
, u_errorName(status
));
6488 fmt
->format(1250.75, s
);
6490 errln(UnicodeString("FAIL: Expected: ")+expected
6491 + UnicodeString(" Got: ") + s
6492 + UnicodeString( " for locale: ")+ UnicodeString(localeID
) );
6494 if (U_FAILURE(status
)){
6495 errln((UnicodeString
)"FAIL: Status " + (int32_t)status
);
6503 * Test available numbering systems API.
6505 void NumberFormatTest::TestAvailableNumberingSystems() {
6506 UErrorCode status
= U_ZERO_ERROR
;
6507 StringEnumeration
*availableNumberingSystems
= NumberingSystem::getAvailableNames(status
);
6508 CHECK_DATA(status
, "NumberingSystem::getAvailableNames()")
6510 int32_t nsCount
= availableNumberingSystems
->count(status
);
6511 if ( nsCount
< 36 ) {
6512 errln("FAIL: Didn't get as many numbering systems as we had hoped for. Need at least 36, got %d",nsCount
);
6515 /* A relatively simple test of the API. We call getAvailableNames() and cycle through */
6516 /* each name returned, attempting to create a numbering system based on that name and */
6517 /* verifying that the name returned from the resulting numbering system is the same */
6518 /* one that we initially thought. */
6521 for ( int32_t i
= 0 ; i
< nsCount
; i
++ ) {
6522 const char *nsname
= availableNumberingSystems
->next(&len
,status
);
6523 NumberingSystem
* ns
= NumberingSystem::createInstanceByName(nsname
,status
);
6524 if ( uprv_strcmp(nsname
,ns
->getName()) ) {
6525 errln("FAIL: Numbering system name didn't match for name = %s\n",nsname
);
6531 delete availableNumberingSystems
;
6535 NumberFormatTest::Test9087(void)
6537 U_STRING_DECL(pattern
,"#",1);
6538 U_STRING_INIT(pattern
,"#",1);
6540 U_STRING_DECL(infstr
,"INF",3);
6541 U_STRING_INIT(infstr
,"INF",3);
6543 U_STRING_DECL(nanstr
,"NAN",3);
6544 U_STRING_INIT(nanstr
,"NAN",3);
6546 UChar outputbuf
[50] = {0};
6547 UErrorCode status
= U_ZERO_ERROR
;
6548 UNumberFormat
* fmt
= unum_open(UNUM_PATTERN_DECIMAL
,pattern
,1,NULL
,NULL
,&status
);
6549 if ( U_FAILURE(status
) ) {
6550 dataerrln("FAIL: error in unum_open() - %s", u_errorName(status
));
6554 unum_setSymbol(fmt
,UNUM_INFINITY_SYMBOL
,infstr
,3,&status
);
6555 unum_setSymbol(fmt
,UNUM_NAN_SYMBOL
,nanstr
,3,&status
);
6556 if ( U_FAILURE(status
) ) {
6557 errln("FAIL: error setting symbols");
6560 double inf
= uprv_getInfinity();
6562 unum_setAttribute(fmt
,UNUM_ROUNDING_MODE
,UNUM_ROUND_HALFEVEN
);
6563 unum_setDoubleAttribute(fmt
,UNUM_ROUNDING_INCREMENT
,0);
6565 UFieldPosition position
= { 0, 0, 0};
6566 unum_formatDouble(fmt
,inf
,outputbuf
,50,&position
,&status
);
6568 if ( u_strcmp(infstr
, outputbuf
)) {
6569 errln((UnicodeString
)"FAIL: unexpected result for infinity - expected " + infstr
+ " got " + outputbuf
);
6574 #endif /* #if !UCONFIG_NO_FORMATTING */