]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/numfmtst.cpp
ICU-491.11.3.tar.gz
[apple/icu.git] / icuSources / test / intltest / numfmtst.cpp
CommitLineData
b75a7d8f 1/********************************************************************
729e4ab9 2 * COPYRIGHT:
4388f060 3 * Copyright (c) 1997-2012, International Business Machines Corporation and
b75a7d8f
A
4 * others. All Rights Reserved.
5 ********************************************************************/
6/* Modification History:
7* Date Name Description
8* 07/15/99 helena Ported to HPUX 10/11 CC.
9*/
10
11#include "unicode/utypes.h"
12
13#if !UCONFIG_NO_FORMATTING
14
15#include "numfmtst.h"
16#include "unicode/dcfmtsym.h"
17#include "unicode/decimfmt.h"
4388f060 18#include "unicode/localpointer.h"
b75a7d8f
A
19#include "unicode/ucurr.h"
20#include "unicode/ustring.h"
374ca955
A
21#include "unicode/measfmt.h"
22#include "unicode/curramt.h"
23#include "digitlst.h"
24#include "textfile.h"
25#include "tokiter.h"
26#include "charstr.h"
27#include "putilimp.h"
73c04bcf 28#include "winnmtst.h"
b75a7d8f
A
29#include <float.h>
30#include <string.h>
46f4442e
A
31#include <stdlib.h>
32#include "cstring.h"
729e4ab9
A
33#include "unicode/numsys.h"
34
35//#define NUMFMTST_CACHE_DEBUG 1
729e4ab9 36#include "stdio.h" /* for sprintf */
729e4ab9
A
37// #include "iostream" // for cout
38
39//#define NUMFMTST_DEBUG 1
40
4388f060 41#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
b75a7d8f
A
42
43static const UChar EUR[] = {69,85,82,0}; // "EUR"
729e4ab9
A
44static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
45
b75a7d8f
A
46// *****************************************************************************
47// class NumberFormatTest
48// *****************************************************************************
49
50#define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
51
729e4ab9
A
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; }
b75a7d8f
A
54
55void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
56{
57 // if (exec) logln((UnicodeString)"TestSuite DateFormatTest");
58 switch (index) {
59 CASE(0,TestCurrencySign);
60 CASE(1,TestCurrency);
61 CASE(2,TestParse);
62 CASE(3,TestRounding487);
63 CASE(4,TestQuotes);
64 CASE(5,TestExponential);
65 CASE(6,TestPatterns);
66
67 // Upgrade to alphaWorks - liu 5/99
68 CASE(7,TestExponent);
69 CASE(8,TestScientific);
70 CASE(9,TestPad);
71 CASE(10,TestPatterns2);
72 CASE(11,TestSecondaryGrouping);
73 CASE(12,TestSurrogateSupport);
74 CASE(13,TestAPI);
75
76 CASE(14,TestCurrencyObject);
77 CASE(15,TestCurrencyPatterns);
46f4442e
A
78 //CASE(16,TestDigitList);
79 CASE(16,TestWhiteSpaceParsing);
729e4ab9 80 CASE(17,TestComplexCurrency); // This test removed because CLDR no longer uses choice formats in currency symbols.
46f4442e
A
81 CASE(18,TestRegCurrency);
82 CASE(19,TestSymbolsWithBadLocale);
83 CASE(20,TestAdoptDecimalFormatSymbols);
84
85 CASE(21,TestScientific2);
86 CASE(22,TestScientificGrouping);
87 CASE(23,TestInt64);
88
89 CASE(24,TestPerMill);
90 CASE(25,TestIllegalPatterns);
91 CASE(26,TestCases);
92
93 CASE(27,TestCurrencyNames);
94 CASE(28,TestCurrencyAmount);
95 CASE(29,TestCurrencyUnit);
96 CASE(30,TestCoverage);
97 CASE(31,TestJB3832);
98 CASE(32,TestHost);
99 CASE(33,TestHostClone);
73c04bcf 100 CASE(34,TestCurrencyFormat);
46f4442e
A
101 CASE(35,TestRounding);
102 CASE(36,TestNonpositiveMultiplier);
729e4ab9
A
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);
4388f060
A
116 CASE(50,TestExplicitParents);
117 CASE(51,TestLenientParse);
118 CASE(52,TestAvailableNumberingSystems);
119 CASE(53,TestRoundingPattern);
120 CASE(54,Test9087);
b75a7d8f
A
121 default: name = ""; break;
122 }
123}
729e4ab9 124
b75a7d8f
A
125// -------------------------------------
126
127// Test API (increase code coverage)
128void
129NumberFormatTest::TestAPI(void)
130{
131 logln("Test API");
132 UErrorCode status = U_ZERO_ERROR;
133 NumberFormat *test = NumberFormat::createInstance("root", status);
134 if(U_FAILURE(status)) {
729e4ab9 135 dataerrln("unable to create format object - %s", u_errorName(status));
b75a7d8f
A
136 }
137 if(test != NULL) {
138 test->setMinimumIntegerDigits(10);
139 test->setMaximumIntegerDigits(2);
140
141 test->setMinimumFractionDigits(10);
142 test->setMaximumFractionDigits(2);
143
144 UnicodeString result;
145 FieldPosition pos;
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!");
150 } else {
151 status = U_ZERO_ERROR;
152 }
153
73c04bcf
A
154 result.remove();
155 int64_t ll = 12;
156 test->format(ll, result);
157 if (result != "12.00"){
158 errln("format int64_t error");
159 }
160
729e4ab9 161 ParsePosition ppos;
4388f060
A
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");
729e4ab9
A
166 }
167
168 delete test;
b75a7d8f 169 }
b75a7d8f
A
170}
171
73c04bcf
A
172class StubNumberForamt :public NumberFormat{
173public:
174 StubNumberForamt(){};
175 virtual UnicodeString& format(double ,UnicodeString& appendTo,FieldPosition& ) const {
176 return appendTo;
177 }
178 virtual UnicodeString& format(int32_t ,UnicodeString& appendTo,FieldPosition& ) const {
179 return appendTo.append((UChar)0x0033);
180 }
181 virtual UnicodeString& format(int64_t number,UnicodeString& appendTo,FieldPosition& pos) const {
182 return NumberFormat::format(number, appendTo, pos);
183 }
184 virtual UnicodeString& format(const Formattable& , UnicodeString& appendTo, FieldPosition& , UErrorCode& ) const {
185 return appendTo;
186 }
187 virtual void parse(const UnicodeString& ,
188 Formattable& ,
189 ParsePosition& ) const {}
190 virtual void parse( const UnicodeString& ,
191 Formattable& ,
192 UErrorCode& ) const {}
193 virtual UClassID getDynamicClassID(void) const {
194 static char classID = 0;
729e4ab9 195 return (UClassID)&classID;
73c04bcf
A
196 }
197 virtual Format* clone() const {return NULL;}
198};
199
729e4ab9 200void
73c04bcf
A
201NumberFormatTest::TestCoverage(void){
202 StubNumberForamt stub;
203 UnicodeString agent("agent");
204 FieldPosition pos;
205 int64_t num = 4;
206 if (stub.format(num, agent, pos) != UnicodeString("agent3")){
207 errln("NumberFormat::format(int64, UnicodString&, FieldPosition&) should delegate to (int32, ,)");
208 };
209}
210
b75a7d8f
A
211// Test various patterns
212void
213NumberFormatTest::TestPatterns(void)
214{
215 UErrorCode status = U_ZERO_ERROR;
216 DecimalFormatSymbols sym(Locale::getUS(), status);
729e4ab9 217 if (U_FAILURE(status)) { errcheckln(status, "FAIL: Could not construct DecimalFormatSymbols - %s", u_errorName(status)); return; }
b75a7d8f
A
218
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)
224 {
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");
232
233 UnicodeString s; (*(NumberFormat*)&fmt).format((int32_t)0, s);
234 if (!(s == num[i]))
235 {
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());
239 }
240 }
241}
242
46f4442e 243/*
729e4ab9
A
244icu_2_4::DigitList::operator== 0 0 2 icuuc24d.dll digitlst.cpp Doug
245icu_2_4::DigitList::append 0 0 4 icuin24d.dll digitlst.h Doug
246icu_2_4::DigitList::operator!= 0 0 1 icuuc24d.dll digitlst.h Doug
46f4442e
A
247*/
248/*
729e4ab9 249void
b75a7d8f
A
250NumberFormatTest::TestDigitList(void)
251{
252 // API coverage for DigitList
b75a7d8f
A
253 DigitList list1;
254 list1.append('1');
255 list1.fDecimalAt = 1;
256 DigitList list2;
374ca955 257 list2.set((int32_t)1);
b75a7d8f
A
258 if (list1 != list2) {
259 errln("digitlist append, operator!= or set failed ");
260 }
261 if (!(list1 == list2)) {
262 errln("digitlist append, operator== or set failed ");
263 }
264}
46f4442e 265*/
b75a7d8f
A
266
267// -------------------------------------
268
269// Test exponential pattern
270void
271NumberFormatTest::TestExponential(void)
272{
273 UErrorCode status = U_ZERO_ERROR;
274 DecimalFormatSymbols sym(Locale::getUS(), status);
729e4ab9 275 if (U_FAILURE(status)) { errcheckln(status, "FAIL: Bad status returned by DecimalFormatSymbols ct - %s", u_errorName(status)); return; }
b75a7d8f
A
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]));
278
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.
284
285// This section may be expanded as needed.
286
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[] =
291 {
292 // 0.####E0
293 "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
294 // 00.000E00
295 "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
296 // ##0.######E000
297 "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
298 // 0.###E0;[0.###E0]
299 "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
300 };
301 double valParse[] =
302 {
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,
307 };
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]);
311 char* valFormat[] =
312 {
313 // 0.####E0
314 "1.234E-2", "1.2346E8", "1.23E70", "-3.1416E-71",
315 // 00.000E00
316 "12.340E-03", "12.346E07", "12.300E69", "-31.416E-72",
317 // ##0.######E000
318 "12.34E-003", "123.4568E006", "12.3E069", "-31.41593E-072",
319 // 0.###E0;[0.###E0]
320 "1.234E-2", "1.235E8", "1.23E70", "[3.142E-71]"
321 };
322 double valParse[] =
323 {
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,
328 };
329#else
330 // Don't test double conversion
331 double* val = 0;
332 int32_t val_length = 0;
333 char** valFormat = 0;
334 double* valParse = 0;
335 logln("Warning: Skipping double conversion tests");
336#endif
337
338 int32_t lval[] = { 0, -1, 1, 123456789 };
339 int32_t lval_length = (int32_t)(sizeof(lval) / sizeof(lval[0]));
340 const char* lvalFormat[] =
341 {
342 // 0.####E0
343 "0E0", "-1E0", "1E0", "1.2346E8",
344 // 00.000E00
345 "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
346 // ##0.######E000
347 "0E000", "-1E000", "1E000", "123.4568E006",
348 // 0.###E0;[0.###E0]
349 "0E0", "[1E0]", "1E0", "1.235E8"
350 };
351 int32_t lvalParse[] =
352 {
353 0, -1, 1, 123460000,
354 0, -1, 1, 123460000,
355 0, -1, 1, 123456800,
356 0, -1, 1, 123500000,
357 };
358 int32_t ival = 0, ilval = 0;
359 for (int32_t p=0; p<pat_length; ++p)
360 {
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) + "\"");
366 int32_t v;
367 for (v=0; v<val_length; ++v)
368 {
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]);
373
374 ParsePosition pos(0);
375 Formattable af;
376 fmt.parse(s, af, pos);
377 double a;
378 UBool useEpsilon = FALSE;
379 if (af.getType() == Formattable::kLong)
380 a = af.getLong();
381 else if (af.getType() == Formattable::kDouble) {
382 a = af.getDouble();
4388f060 383#if U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400
b75a7d8f
A
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.
391 useEpsilon = TRUE;
392#endif
393 }
394 else {
395 errln((UnicodeString)"FAIL: Non-numeric Formattable returned");
396 continue;
397 }
398 if (pos.getIndex() == s.length())
399 {
400 logln((UnicodeString)" -parse-> " + a);
401 // Use epsilon comparison as necessary
402 if ((useEpsilon &&
403 (uprv_fabs(a - valParse[v+ival]) / a > (2*DBL_EPSILON))) ||
404 (!useEpsilon && a != valParse[v+ival]))
405 {
406 errln((UnicodeString)"FAIL: Expected " + valParse[v+ival]);
407 }
408 }
409 else {
410 errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a);
411 errln((UnicodeString)" should be (" + s.length() + " chars) -> " + valParse[v+ival]);
412 }
413 }
414 for (v=0; v<lval_length; ++v)
415 {
416 UnicodeString s;
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);
421
422 ParsePosition pos(0);
423 Formattable af;
424 fmt.parse(s, af, pos);
374ca955
A
425 if (af.getType() == Formattable::kLong ||
426 af.getType() == Formattable::kInt64) {
427 UErrorCode status = U_ZERO_ERROR;
428 int32_t a = af.getLong(status);
b75a7d8f
A
429 if (pos.getIndex() == s.length())
430 {
431 logln((UnicodeString)" -parse-> " + a);
432 if (a != lvalParse[v+ilval])
433 errln((UnicodeString)"FAIL: Expected " + lvalParse[v+ilval]);
434 }
435 else
436 errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a);
437 }
438 else
439 errln((UnicodeString)"FAIL: Non-long Formattable returned for " + s
440 + " Double: " + af.getDouble()
441 + ", Long: " + af.getLong());
442 }
443 ival += val_length;
444 ilval += lval_length;
445 }
446}
447
374ca955
A
448void
449NumberFormatTest::TestScientific2() {
450 // jb 2552
451 UErrorCode status = U_ZERO_ERROR;
452 DecimalFormat* fmt = (DecimalFormat*)NumberFormat::createCurrencyInstance("en_US", status);
453 if (U_SUCCESS(status)) {
454 double num = 12.34;
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");
460 }
461 delete fmt;
462}
463
729e4ab9 464void
374ca955
A
465NumberFormatTest::TestScientificGrouping() {
466 // jb 2552
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");
476 }
477}
478
46f4442e 479/*static void setFromString(DigitList& dl, const char* str) {
374ca955
A
480 char c;
481 UBool decimalSet = FALSE;
482 dl.clear();
483 while ((c = *str++)) {
484 if (c == '-') {
485 dl.fIsPositive = FALSE;
486 } else if (c == '+') {
487 dl.fIsPositive = TRUE;
488 } else if (c == '.') {
489 dl.fDecimalAt = dl.fCount;
490 decimalSet = TRUE;
491 } else {
492 dl.append(c);
493 }
494 }
495 if (!decimalSet) {
496 dl.fDecimalAt = dl.fCount;
497 }
46f4442e 498}*/
374ca955
A
499
500void
501NumberFormatTest::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");
513 }
514
515 // also test digitlist
46f4442e 516/* int64_t int64max = U_INT64_MAX;
374ca955
A
517 int64_t int64min = U_INT64_MIN;
518 const char* int64maxstr = "9223372036854775807";
519 const char* int64minstr = "-9223372036854775808";
520 UnicodeString fail("fail: ");
521
522 // test max int64 value
523 DigitList dl;
524 setFromString(dl, int64maxstr);
525 {
526 if (!dl.fitsIntoInt64(FALSE)) {
527 errln(fail + int64maxstr + " didn't fit");
528 }
529 int64_t int64Value = dl.getInt64();
530 if (int64Value != int64max) {
531 errln(fail + int64maxstr);
532 }
533 dl.set(int64Value);
534 int64Value = dl.getInt64();
535 if (int64Value != int64max) {
536 errln(fail + int64maxstr);
537 }
538 }
539 // test negative of max int64 value (1 shy of min int64 value)
540 dl.fIsPositive = FALSE;
541 {
542 if (!dl.fitsIntoInt64(FALSE)) {
543 errln(fail + "-" + int64maxstr + " didn't fit");
544 }
545 int64_t int64Value = dl.getInt64();
546 if (int64Value != -int64max) {
547 errln(fail + "-" + int64maxstr);
548 }
549 dl.set(int64Value);
550 int64Value = dl.getInt64();
551 if (int64Value != -int64max) {
552 errln(fail + "-" + int64maxstr);
553 }
554 }
555 // test min int64 value
556 setFromString(dl, int64minstr);
557 {
558 if (!dl.fitsIntoInt64(FALSE)) {
559 errln(fail + "-" + int64minstr + " didn't fit");
560 }
561 int64_t int64Value = dl.getInt64();
562 if (int64Value != int64min) {
563 errln(fail + int64minstr);
564 }
565 dl.set(int64Value);
566 int64Value = dl.getInt64();
567 if (int64Value != int64min) {
568 errln(fail + int64minstr);
569 }
570 }
571 // test negative of min int 64 value (1 more than max int64 value)
572 dl.fIsPositive = TRUE; // won't fit
573 {
574 if (dl.fitsIntoInt64(FALSE)) {
575 errln(fail + "-(" + int64minstr + ") didn't fit");
576 }
46f4442e 577 }*/
374ca955
A
578}
579
b75a7d8f
A
580// -------------------------------------
581
582// Test the handling of quotes
583void
584NumberFormatTest::TestQuotes(void)
585{
586 UErrorCode status = U_ZERO_ERROR;
587 UnicodeString *pat;
588 DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), status);
729e4ab9
A
589 if (U_FAILURE(status)) {
590 errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status));
591 delete sym;
592 return;
593 }
b75a7d8f
A
594 pat = new UnicodeString("a'fo''o'b#");
595 DecimalFormat *fmt = new DecimalFormat(*pat, *sym, status);
729e4ab9 596 UnicodeString s;
b75a7d8f
A
597 ((NumberFormat*)fmt)->format((int32_t)123, s);
598 logln((UnicodeString)"Pattern \"" + *pat + "\"");
599 logln((UnicodeString)" Format 123 -> " + escape(s));
729e4ab9 600 if (!(s=="afo'ob123"))
b75a7d8f 601 errln((UnicodeString)"FAIL: Expected afo'ob123");
729e4ab9 602
b75a7d8f
A
603 s.truncate(0);
604 delete fmt;
605 delete pat;
606
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));
729e4ab9 612 if (!(s=="a'b123"))
b75a7d8f
A
613 errln((UnicodeString)"FAIL: Expected a'b123");
614 delete fmt;
615 delete pat;
616 delete sym;
617}
618
619/**
620 * Test the handling of the currency symbol in patterns.
621 */
622void
623NumberFormatTest::TestCurrencySign(void)
624{
625 UErrorCode status = U_ZERO_ERROR;
626 DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale::getUS(), status);
627 UnicodeString pat;
628 UChar currency = 0x00A4;
729e4ab9
A
629 if (U_FAILURE(status)) {
630 errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status));
631 delete sym;
632 return;
633 }
b75a7d8f
A
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);
639 pat.truncate(0);
640 logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
641 logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
729e4ab9 642 if (s != "$1,234.56") dataerrln((UnicodeString)"FAIL: Expected $1,234.56");
b75a7d8f
A
643 s.truncate(0);
644 ((NumberFormat*)fmt)->format(- 1234.56, s);
645 logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
729e4ab9 646 if (s != "-$1,234.56") dataerrln((UnicodeString)"FAIL: Expected -$1,234.56");
b75a7d8f
A
647 delete fmt;
648 pat.truncate(0);
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);
655 s.truncate(0);
656 ((NumberFormat*)fmt)->format(1234.56, s);
657 logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\"");
658 logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s));
729e4ab9 659 if (s != "USD 1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD 1,234.56");
b75a7d8f
A
660 s.truncate(0);
661 ((NumberFormat*)fmt)->format(-1234.56, s);
662 logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s));
729e4ab9 663 if (s != "USD -1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD -1,234.56");
b75a7d8f
A
664 delete fmt;
665 delete sym;
729e4ab9 666 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + u_errorName(status));
b75a7d8f 667}
729e4ab9 668
b75a7d8f
A
669// -------------------------------------
670
671static UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
672
673UnicodeString&
674NumberFormatTest::escape(UnicodeString& s)
675{
676 UnicodeString buf;
677 for (int32_t i=0; i<s.length(); ++i)
678 {
679 UChar c = s[(int32_t)i];
680 if (c <= (UChar)0x7F) buf += c;
681 else {
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);
687 }
688 }
689 return (s = buf);
690}
691
729e4ab9 692
b75a7d8f 693// -------------------------------------
374ca955
A
694static const char* testCases[][2]= {
695 /* locale ID */ /* expected */
46f4442e
A
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" },
4388f060
A
699 {"en_BE_PREEURO", "1.150,50\\u00A0BEF" },
700 {"es_ES_PREEURO", "1.150\\u00A0\\u20A7" },
729e4ab9 701 {"eu_ES_PREEURO", "1.150\\u00A0\\u20A7" },
46f4442e 702 {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" },
4388f060 703 {"it_IT_PREEURO", "ITL\\u00A01.150" },
46f4442e 704 {"pt_PT_PREEURO", "1,150$50\\u00A0Esc."},
729e4ab9
A
705 {"en_US@currency=JPY", "\\u00A51,150"},
706 {"en_US@currency=jpy", "\\u00A51,150"},
707 {"en-US-u-cu-jpy", "\\u00A51,150"}
374ca955 708};
b75a7d8f
A
709/**
710 * Test localized currency patterns.
711 */
712void
713NumberFormatTest::TestCurrency(void)
714{
715 UErrorCode status = U_ZERO_ERROR;
716 NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(Locale::getCanadaFrench(), status);
73c04bcf
A
717 if (U_FAILURE(status)) {
718 dataerrln("Error calling NumberFormat::createCurrencyInstance()");
719 return;
720 }
721
b75a7d8f
A
722 UnicodeString s; currencyFmt->format(1.50, s);
723 logln((UnicodeString)"Un pauvre ici a..........." + s);
46f4442e
A
724 if (!(s==CharsToUnicodeString("1,50\\u00A0$")))
725 errln((UnicodeString)"FAIL: Expected 1,50<nbsp>$");
b75a7d8f
A
726 delete currencyFmt;
727 s.truncate(0);
374ca955
A
728 char loc[256]={0};
729 int len = uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
730 currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc),status);
b75a7d8f
A
731 currencyFmt->format(1.50, s);
732 logln((UnicodeString)"Un pauvre en Allemagne a.." + s);
4388f060
A
733 if (!(s==CharsToUnicodeString("1,50\\u00A0DEM")))
734 errln((UnicodeString)"FAIL: Expected 1,50<nbsp>DEM");
b75a7d8f
A
735 delete currencyFmt;
736 s.truncate(0);
374ca955
A
737 len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
738 currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status);
b75a7d8f
A
739 currencyFmt->format(1.50, s);
740 logln((UnicodeString)"Un pauvre en France a....." + s);
46f4442e
A
741 if (!(s==CharsToUnicodeString("1,50\\u00A0F")))
742 errln((UnicodeString)"FAIL: Expected 1,50<nbsp>F");
b75a7d8f
A
743 delete currencyFmt;
744 if (U_FAILURE(status))
745 errln((UnicodeString)"FAIL: Status " + (int32_t)status);
729e4ab9 746
374ca955
A
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];
46f4442e 750 UnicodeString expected(testCases[i][1], -1, US_INV);
374ca955
A
751 expected = expected.unescape();
752 s.truncate(0);
753 char loc[256]={0};
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);
758 continue;
759 }
760 currencyFmt->format(1150.50, s);
761 if(s!=expected){
729e4ab9
A
762 errln(UnicodeString("FAIL: Expected: ")+expected
763 + UnicodeString(" Got: ") + s
374ca955
A
764 + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
765 }
766 if (U_FAILURE(status)){
767 errln((UnicodeString)"FAIL: Status " + (int32_t)status);
768 }
769 delete currencyFmt;
770 }
b75a7d8f 771}
729e4ab9 772
b75a7d8f
A
773// -------------------------------------
774
775/**
776 * Test the Currency object handling, new as of ICU 2.2.
777 */
778void NumberFormatTest::TestCurrencyObject() {
779 UErrorCode ec = U_ZERO_ERROR;
729e4ab9 780 NumberFormat* fmt =
b75a7d8f
A
781 NumberFormat::createCurrencyInstance(Locale::getUS(), ec);
782
783 if (U_FAILURE(ec)) {
729e4ab9 784 dataerrln("FAIL: getCurrencyInstance(US) - %s", u_errorName(ec));
b75a7d8f
A
785 delete fmt;
786 return;
787 }
788
789 Locale null("", "", "");
729e4ab9 790
b75a7d8f
A
791 expectCurrency(*fmt, null, 1234.56, "$1,234.56");
792
793 expectCurrency(*fmt, Locale::getFrance(),
794 1234.56, CharsToUnicodeString("\\u20AC1,234.56")); // Euro
795
796 expectCurrency(*fmt, Locale::getJapan(),
797 1234.56, CharsToUnicodeString("\\u00A51,235")); // Yen
798
799 expectCurrency(*fmt, Locale("fr", "CH", ""),
729e4ab9 800 1234.56, "CHF1,234.55"); // 0.05 rounding
b75a7d8f
A
801
802 expectCurrency(*fmt, Locale::getUS(),
803 1234.56, "$1,234.56");
804
805 delete fmt;
806 fmt = NumberFormat::createCurrencyInstance(Locale::getFrance(), ec);
807
808 if (U_FAILURE(ec)) {
809 errln("FAIL: getCurrencyInstance(FRANCE)");
810 delete fmt;
811 return;
812 }
729e4ab9 813
b75a7d8f
A
814 expectCurrency(*fmt, null, 1234.56, CharsToUnicodeString("1 234,56 \\u20AC"));
815
816 expectCurrency(*fmt, Locale::getJapan(),
46f4442e 817 1234.56, CharsToUnicodeString("1 235 \\u00A5JP")); // Yen
b75a7d8f
A
818
819 expectCurrency(*fmt, Locale("fr", "CH", ""),
729e4ab9 820 1234.56, "1 234,55 CHF"); // 0.05 rounding
b75a7d8f
A
821
822 expectCurrency(*fmt, Locale::getUS(),
46f4442e 823 1234.56, "1 234,56 $US");
b75a7d8f
A
824
825 expectCurrency(*fmt, Locale::getFrance(),
826 1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); // Euro
827
828 delete fmt;
829}
729e4ab9 830
b75a7d8f
A
831// -------------------------------------
832
833/**
834 * Do rudimentary testing of parsing.
835 */
836void
837NumberFormatTest::TestParse(void)
838{
839 UErrorCode status = U_ZERO_ERROR;
840 UnicodeString arg("0");
841 DecimalFormat* format = new DecimalFormat("00", status);
842 //try {
4388f060 843 Formattable n; format->parse(arg, n, status);
b75a7d8f
A
844 logln((UnicodeString)"parse(" + arg + ") = " + n.getLong());
845 if (n.getType() != Formattable::kLong ||
846 n.getLong() != 0) errln((UnicodeString)"FAIL: Expected 0");
847 delete format;
729e4ab9 848 if (U_FAILURE(status)) errcheckln(status, (UnicodeString)"FAIL: Status " + u_errorName(status));
b75a7d8f
A
849 //}
850 //catch(Exception e) {
851 // errln((UnicodeString)"Exception caught: " + e);
852 //}
853}
729e4ab9 854
b75a7d8f
A
855// -------------------------------------
856
46f4442e 857static const char *lenientAffixTestCases[] = {
4388f060
A
858 "(1)",
859 "( 1)",
860 "(1 )",
861 "( 1 )"
46f4442e
A
862};
863
7393aa2f
A
864static const char *lenientMinusTestCases[] = {
865 "-5",
866 "\\u22125",
867 "\\u20105"
868};
869
46f4442e 870static const char *lenientCurrencyTestCases[] = {
4388f060
A
871 "$1,000",
872 "$ 1,000",
873 "$1000",
874 "$ 1000",
875 "$1 000.00",
876 "$ 1 000.00",
877 "$ 1\\u00A0000.00",
878 "1000.00"
46f4442e
A
879};
880
881static const char *lenientNegativeCurrencyTestCases[] = {
4388f060
A
882 "($1,000)",
883 "($ 1,000)",
884 "($1000)",
885 "($ 1000)",
886 "($1 000.00)",
887 "($ 1 000.00)",
888 "( $ 1,000.00 )",
889 "($ 1\\u00A0000.00)",
890 "(1000.00)"
46f4442e
A
891};
892
893static const char *lenientPercentTestCases[] = {
4388f060
A
894 "25%",
895 " 25%",
896 " 25 %",
897 "25 %",
729e4ab9
A
898 "25\\u00A0%",
899 "25"
46f4442e
A
900};
901
902static const char *lenientNegativePercentTestCases[] = {
729e4ab9
A
903 "-25%",
904 " -25%",
905 " - 25%",
906 "- 25 %",
907 " - 25 %",
908 "-25 %",
909 "-25\\u00A0%",
910 "-25",
911 "- 25"
46f4442e
A
912};
913
914static const char *strictFailureTestCases[] = {
729e4ab9
A
915 " 1000",
916 "10,00",
917 "1,000,.0"
46f4442e
A
918};
919
920#define ARRAY_SIZE(array) ((int32_t) (sizeof (array) / sizeof(array[0])))
921
922/**
923 * Test lenient parsing.
924 */
925void
926NumberFormatTest::TestLenientParse(void)
927{
928 UErrorCode status = U_ZERO_ERROR;
929 DecimalFormat *format = new DecimalFormat("(#,##0)", status);
930 Formattable n;
729e4ab9 931
4388f060
A
932 if (format == NULL || U_FAILURE(status)) {
933 dataerrln("Unable to create DecimalFormat (#,##0) - %s", u_errorName(status));
934 } else {
935 format->setLenient(TRUE);
936 for (int32_t t = 0; t < ARRAY_SIZE (lenientAffixTestCases); t += 1) {
937 UnicodeString testCase = ctou(lenientAffixTestCases[t]);
729e4ab9 938
4388f060
A
939 format->parse(testCase, n, status);
940 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
729e4ab9 941
4388f060
A
942 if (U_FAILURE(status) || n.getType() != Formattable::kLong ||
943 n.getLong() != 1) {
944 errln((UnicodeString)"Lenient parse failed for \"" + (UnicodeString) lenientAffixTestCases[t] + (UnicodeString) "\"");
945 status = U_ZERO_ERROR;
946 }
947 }
948 delete format;
949 }
729e4ab9 950
7393aa2f
A
951 Locale en_US("en_US");
952 Locale sv_SE("sv_SE");
953
4388f060 954 NumberFormat *mFormat = NumberFormat::createInstance(sv_SE, UNUM_DECIMAL, status);
7393aa2f 955
4388f060
A
956 if (mFormat == NULL || U_FAILURE(status)) {
957 dataerrln("Unable to create NumberFormat (sv_SE, UNUM_DECIMAL) - %s", u_errorName(status));
958 } else {
959 mFormat->setLenient(TRUE);
960 for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
961 UnicodeString testCase = ctou(lenientMinusTestCases[t]);
962
963 mFormat->parse(testCase, n, status);
964 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
965
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;
969 }
7393aa2f 970 }
4388f060 971 delete mFormat;
7393aa2f
A
972 }
973
4388f060 974 mFormat = NumberFormat::createInstance(en_US, UNUM_DECIMAL, status);
7393aa2f 975
4388f060
A
976 if (mFormat == NULL || U_FAILURE(status)) {
977 dataerrln("Unable to create NumberFormat (en_US, UNUM_DECIMAL) - %s", u_errorName(status));
978 } else {
979 mFormat->setLenient(TRUE);
980 for (int32_t t = 0; t < ARRAY_SIZE(lenientMinusTestCases); t += 1) {
981 UnicodeString testCase = ctou(lenientMinusTestCases[t]);
982
983 mFormat->parse(testCase, n, status);
984 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
985
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;
989 }
7393aa2f 990 }
4388f060 991 delete mFormat;
7393aa2f
A
992 }
993
4388f060 994 NumberFormat *cFormat = NumberFormat::createInstance(en_US, UNUM_CURRENCY, status);
729e4ab9 995
4388f060
A
996 if (cFormat == NULL || U_FAILURE(status)) {
997 dataerrln("Unable to create NumberFormat (en_US, UNUM_CURRENCY) - %s", u_errorName(status));
998 } else {
999 cFormat->setLenient(TRUE);
1000 for (int32_t t = 0; t < ARRAY_SIZE (lenientCurrencyTestCases); t += 1) {
1001 UnicodeString testCase = ctou(lenientCurrencyTestCases[t]);
729e4ab9 1002
4388f060
A
1003 cFormat->parse(testCase, n, status);
1004 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
729e4ab9 1005
4388f060
A
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;
1010 }
46f4442e 1011 }
729e4ab9 1012
4388f060
A
1013 for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativeCurrencyTestCases); t += 1) {
1014 UnicodeString testCase = ctou(lenientNegativeCurrencyTestCases[t]);
729e4ab9 1015
4388f060
A
1016 cFormat->parse(testCase, n, status);
1017 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
729e4ab9 1018
4388f060
A
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;
1023 }
46f4442e 1024 }
729e4ab9 1025
4388f060
A
1026 delete cFormat;
1027 }
729e4ab9 1028
7393aa2f 1029 NumberFormat *pFormat = NumberFormat::createPercentInstance(en_US, status);
729e4ab9 1030
4388f060
A
1031 if (pFormat == NULL || U_FAILURE(status)) {
1032 dataerrln("Unable to create NumberFormat::createPercentInstance (en_US) - %s", u_errorName(status));
1033 } else {
1034 pFormat->setLenient(TRUE);
1035 for (int32_t t = 0; t < ARRAY_SIZE (lenientPercentTestCases); t += 1) {
1036 UnicodeString testCase = ctou(lenientPercentTestCases[t]);
729e4ab9 1037
4388f060
A
1038 pFormat->parse(testCase, n, status);
1039 logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
729e4ab9 1040
4388f060
A
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;
1045 }
46f4442e 1046 }
729e4ab9 1047
4388f060
A
1048 for (int32_t t = 0; t < ARRAY_SIZE (lenientNegativePercentTestCases); t += 1) {
1049 UnicodeString testCase = ctou(lenientNegativePercentTestCases[t]);
729e4ab9 1050
4388f060
A
1051 pFormat->parse(testCase, n, status);
1052 logln((UnicodeString)"parse(" + testCase + ") = " + n.getDouble());
729e4ab9 1053
4388f060
A
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;
1058 }
46f4442e 1059 }
729e4ab9 1060
4388f060
A
1061 delete pFormat;
1062 }
729e4ab9
A
1063
1064 // Test cases that should fail with a strict parse and pass with a
1065 // lenient parse.
1066 NumberFormat *nFormat = NumberFormat::createInstance(en_US, status);
4388f060
A
1067
1068 if (nFormat == NULL || U_FAILURE(status)) {
1069 dataerrln("Unable to create NumberFormat (en_US) - %s", u_errorName(status));
1070 } else {
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]);
1074
1075 nFormat->parse(testCase, n, status);
1076 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
1077
1078 if (! U_FAILURE(status)) {
1079 errln((UnicodeString)"Strict Parse succeeded for \"" + (UnicodeString) strictFailureTestCases[t] + (UnicodeString) "\"");
1080 }
1081
1082 status = U_ZERO_ERROR;
1083 }
1084
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]);
1089
1090 nFormat->parse(testCase, n, status);
1091 logln((UnicodeString)"parse(" + testCase + ") = " + n.getLong());
1092
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;
1097 }
1098 }
1099
1100 delete nFormat;
729e4ab9 1101 }
46f4442e
A
1102}
1103
1104// -------------------------------------
1105
b75a7d8f
A
1106/**
1107 * Test proper rounding by the format method.
1108 */
1109void
1110NumberFormatTest::TestRounding487(void)
1111{
1112 UErrorCode status = U_ZERO_ERROR;
1113 NumberFormat *nf = NumberFormat::createInstance(status);
73c04bcf
A
1114 if (U_FAILURE(status)) {
1115 dataerrln("Error calling NumberFormat::createInstance()");
1116 return;
1117 }
1118
b75a7d8f
A
1119 roundingTest(*nf, 0.00159999, 4, "0.0016");
1120 roundingTest(*nf, 0.00995, 4, "0.01");
1121
1122 roundingTest(*nf, 12.3995, 3, "12.4");
1123
1124 roundingTest(*nf, 12.4999, 0, "12");
1125 roundingTest(*nf, - 19.5, 0, "-20");
1126 delete nf;
1127 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + (int32_t)status);
1128}
1129
1130/**
1131 * Test the functioning of the secondary grouping value.
1132 */
1133void NumberFormatTest::TestSecondaryGrouping(void) {
1134 UErrorCode status = U_ZERO_ERROR;
1135 DecimalFormatSymbols US(Locale::getUS(), status);
1136 CHECK(status, "DecimalFormatSymbols ct");
1137
1138 DecimalFormat f("#,##,###", US, status);
1139 CHECK(status, "DecimalFormat ct");
1140
1141 expect2(f, (int32_t)123456789L, "12,34,56,789");
1142 expectPat(f, "#,##,###");
1143 f.applyPattern("#,###", status);
1144 CHECK(status, "applyPattern");
1145
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);
729e4ab9 1150 CHECK_DATA(status, "createInstance(hi_IN)");
b75a7d8f
A
1151
1152 UnicodeString out;
1153 int32_t l = (int32_t)1876543210L;
1154 g->format(l, out);
1155 delete g;
1156 // expect "1,87,65,43,210", but with Hindi digits
1157 // 01234567890123
1158 UBool ok = TRUE;
1159 if (out.length() != 14) {
1160 ok = FALSE;
1161 } else {
1162 for (int32_t i=0; i<out.length(); ++i) {
1163 UBool expectGroup = FALSE;
1164 switch (i) {
1165 case 1:
1166 case 4:
1167 case 7:
1168 case 10:
1169 expectGroup = TRUE;
1170 break;
1171 }
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) {
1176 ok = FALSE;
1177 break;
1178 }
1179 }
1180 }
1181 if (!ok) {
1182 errln((UnicodeString)"FAIL Expected " + l +
1183 " x hi_IN -> \"1,87,65,43,210\" (with Hindi digits), got \"" +
1184 escape(out) + "\"");
1185 } else {
1186 logln((UnicodeString)"Ok " + l +
1187 " x hi_IN -> \"" +
1188 escape(out) + "\"");
1189 }
1190}
1191
1192void 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)) {
729e4ab9 1197 errcheckln(ec, "FAIL: Constructor - %s", u_errorName(ec));
b75a7d8f
A
1198 return;
1199 }
1200 int32_t n = 1234;
1201 expect(fmt, "a b1234c ", n);
1202 expect(fmt, "a b1234c ", n);
1203}
1204
1205/**
1206 * Test currencies whose display name is a ChoiceFormat.
1207 */
1208void NumberFormatTest::TestComplexCurrency() {
729e4ab9
A
1209
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"));
1221// } else {
1222// errln("FAIL: getCurrencyInstance(kn_IN)");
1223// }
1224// delete fmt;
1225
b75a7d8f 1226}
729e4ab9 1227
b75a7d8f 1228// -------------------------------------
729e4ab9 1229
b75a7d8f
A
1230void
1231NumberFormatTest::roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected)
1232{
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);
1237}
1238
1239/**
1240 * Upgrade to alphaWorks
1241 */
1242void 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)");
1250 int32_t n = 1234;
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"
1254}
1255
1256/**
1257 * Upgrade to alphaWorks
1258 */
1259void NumberFormatTest::TestScientific(void) {
1260 UErrorCode status = U_ZERO_ERROR;
1261 DecimalFormatSymbols US(Locale::getUS(), status);
1262 CHECK(status, "DecimalFormatSymbols constructor");
1263
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]"
1275 };
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");
1280 UnicodeString pat2;
1281 df.toPattern(pat2);
1282 if (pat == pat2) {
1283 logln(UnicodeString("Ok Pattern rt \"") +
1284 pat + "\" -> \"" +
1285 pat2 + "\"");
1286 } else {
1287 errln(UnicodeString("FAIL Pattern rt \"") +
1288 pat + "\" -> \"" +
1289 pat2 + "\"");
1290 }
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 " +
1302 DIGITS[4*i] + "/" +
1303 DIGITS[4*i+1] + ";" +
1304 DIGITS[4*i+2] + "/" +
1305 DIGITS[4*i+3]);
1306 }
1307 }
1308
1309
1310 // Test the constructor for default locale. We have to
729e4ab9
A
1311 // manually set the default locale, as there is no
1312 // guarantee that the default locale has the same
b75a7d8f
A
1313 // scientific format.
1314 Locale def = Locale::getDefault();
1315 Locale::setDefault(Locale::getUS(), status);
1316 expect2(NumberFormat::createScientificInstance(status),
1317 12345.678901,
1318 "1.2345678901E4", status);
1319 Locale::setDefault(def, status);
1320
1321 expect2(new DecimalFormat("#E0", US, status),
1322 12345.0,
1323 "1.2345E4", status);
1324 expect(new DecimalFormat("0E0", US, status),
1325 12345.0,
1326 "1E4", status);
1327 expect2(NumberFormat::createScientificInstance(Locale::getUS(), status),
1328 12345.678901,
1329 "1.2345678901E4", status);
1330 expect(new DecimalFormat("##0.###E0", US, status),
1331 12345.0,
1332 "12.34E3", status);
1333 expect(new DecimalFormat("##0.###E0", US, status),
1334 12345.00001,
1335 "12.35E3", status);
1336 expect2(new DecimalFormat("##0.####E0", US, status),
1337 (int32_t) 12345,
1338 "12.345E3", status);
1339 expect2(NumberFormat::createScientificInstance(Locale::getFrance(), status),
1340 12345.678901,
1341 "1,2345678901E4", status);
1342 expect(new DecimalFormat("##0.####E0", US, status),
1343 789.12345e-9,
1344 "789.12E-9", status);
1345 expect2(new DecimalFormat("##0.####E0", US, status),
1346 780.e-9,
1347 "780E-9", status);
1348 expect(new DecimalFormat(".###E0", US, status),
1349 45678.0,
1350 ".457E5", status);
1351 expect2(new DecimalFormat(".###E0", US, status),
1352 (int32_t) 0,
1353 ".0E0", status);
1354 /*
1355 expect(new DecimalFormat[] { new DecimalFormat("#E0", US),
1356 new DecimalFormat("##E0", US),
1357 new DecimalFormat("####E0", US),
729e4ab9
A
1358 new DecimalFormat("0E0", US),
1359 new DecimalFormat("00E0", US),
1360 new DecimalFormat("000E0", US),
b75a7d8f
A
1361 },
1362 new Long(45678000),
1363 new String[] { "4.5678E7",
1364 "45.678E6",
1365 "4567.8E4",
1366 "5E7",
729e4ab9 1367 "46E6",
b75a7d8f
A
1368 "457E5",
1369 }
1370 );
1371 !
1372 ! Unroll this test into individual tests below...
1373 !
1374 */
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);
1387 /*
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",
1398 });
1399 !
1400 ! Unroll this test into individual tests below...
1401 !
1402 */
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);
1421 /*
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",
1425 });
1426 !
1427 ! Unroll this test into individual tests below...
1428 !
1429 */
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);
1434}
1435
1436/**
1437 * Upgrade to alphaWorks
1438 */
1439void NumberFormatTest::TestPad(void) {
1440 UErrorCode status = U_ZERO_ERROR;
1441 DecimalFormatSymbols US(Locale::getUS(), status);
1442 CHECK(status, "DecimalFormatSymbols constructor");
1443
1444 expect2(new DecimalFormat("*^##.##", US, status),
1445 int32_t(0), "^^^^0", status);
1446 expect2(new DecimalFormat("*^##.##", US, status),
1447 -1.3, "^-1.3", status);
374ca955 1448 expect2(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status),
b75a7d8f 1449 int32_t(0), "0.0E0______ g-m/s^2", status);
374ca955 1450 expect(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status),
b75a7d8f 1451 1.0/3, "333.333E-3_ g-m/s^2", status);
374ca955 1452 expect2(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status),
b75a7d8f 1453 int32_t(0), "0.0______ g-m/s^2", status);
374ca955 1454 expect(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status),
b75a7d8f
A
1455 1.0/3, "0.33333__ g-m/s^2", status);
1456
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);
1475
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);
1492
1493
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);
1512
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);
1529
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)"^^^");
1541 padString.remove();
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);
1548 */
1549
1550}
1551
1552/**
1553 * Upgrade to alphaWorks
1554 */
1555void NumberFormatTest::TestPatterns2(void) {
1556 UErrorCode status = U_ZERO_ERROR;
1557 DecimalFormatSymbols US(Locale::getUS(), status);
1558 CHECK(status, "DecimalFormatSymbols constructor");
1559
1560 DecimalFormat fmt("#", US, status);
1561 CHECK(status, "DecimalFormat constructor");
729e4ab9 1562
b75a7d8f
A
1563 UChar hat = 0x005E; /*^*/
1564
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*/);
1577
1578 fmt.applyPattern("AA#,##0.00ZZ", status);
1579 CHECK(status, "applyPattern");
1580 fmt.setPadCharacter(hat);
1581
1582 fmt.setFormatWidth(10);
1583
1584 fmt.setPadPosition(DecimalFormat::kPadBeforePrefix);
1585 expectPat(fmt, "*^AA#,##0.00ZZ");
1586
1587 fmt.setPadPosition(DecimalFormat::kPadBeforeSuffix);
1588 expectPat(fmt, "AA#,##0.00*^ZZ");
1589
1590 fmt.setPadPosition(DecimalFormat::kPadAfterSuffix);
1591 expectPat(fmt, "AA#,##0.00ZZ*^");
1592
1593 // 12 3456789012
1594 UnicodeString exp("AA*^#,##0.00ZZ", "");
1595 fmt.setFormatWidth(12);
1596 fmt.setPadPosition(DecimalFormat::kPadAfterPrefix);
1597 expectPat(fmt, exp);
1598
1599 fmt.setFormatWidth(13);
1600 // 12 34567890123
1601 expectPat(fmt, "AA*^##,##0.00ZZ");
1602
1603 fmt.setFormatWidth(14);
1604 // 12 345678901234
1605 expectPat(fmt, "AA*^###,##0.00ZZ");
1606
1607 fmt.setFormatWidth(15);
1608 // 12 3456789012345
1609 expectPat(fmt, "AA*^####,##0.00ZZ"); // This is the interesting case
1610
1611 fmt.setFormatWidth(16);
1612 // 12 34567890123456
1613 expectPat(fmt, "AA*^#,###,##0.00ZZ");
1614}
1615
1616void NumberFormatTest::TestSurrogateSupport(void) {
1617 UErrorCode status = U_ZERO_ERROR;
1618 DecimalFormatSymbols custom(Locale::getUS(), status);
1619 CHECK(status, "DecimalFormatSymbols constructor");
1620
1621 custom.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, "decimal");
1622 custom.setSymbol(DecimalFormatSymbols::kPlusSignSymbol, "plus");
1623 custom.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, " minus ");
1624 custom.setSymbol(DecimalFormatSymbols::kExponentialSymbol, "exponent");
1625
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);
1632
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;
374ca955 1640 expect2(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status),
b75a7d8f
A
1641 int32_t(0), "0decimal0exponent0 g-m/s^2", status);
1642 status = U_ZERO_ERROR;
374ca955 1643 expect(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status),
b75a7d8f
A
1644 1.0/3, "333decimal333exponent minus 3 g-m/s^2", status);
1645 status = U_ZERO_ERROR;
374ca955 1646 expect2(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status),
b75a7d8f
A
1647 int32_t(0), "0decimal0 g-m/s^2", status);
1648 status = U_ZERO_ERROR;
374ca955 1649 expect(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status),
b75a7d8f
A
1650 1.0/3, "0decimal33333 g-m/s^2", status);
1651
1652 UnicodeString zero((UChar32)0x10000);
729e4ab9
A
1653 UnicodeString one((UChar32)0x10001);
1654 UnicodeString two((UChar32)0x10002);
1655 UnicodeString five((UChar32)0x10005);
b75a7d8f 1656 custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, zero);
729e4ab9
A
1657 custom.setSymbol(DecimalFormatSymbols::kOneDigitSymbol, one);
1658 custom.setSymbol(DecimalFormatSymbols::kTwoDigitSymbol, two);
1659 custom.setSymbol(DecimalFormatSymbols::kFiveDigitSymbol, five);
b75a7d8f
A
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);
1665
1666 custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, (UChar)0x30);
1667 custom.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "units of money");
1668 custom.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, "money separator");
46f4442e 1669 patternStr = UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'");
b75a7d8f
A
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);
1675
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);
1683}
1684
1685void 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)) {
374ca955 1692 errln("FAIL: Can't create NumberFormat(%s) - %s", locs[i].getName(), u_errorName(ec));
b75a7d8f
A
1693 } else {
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();
1698 if (min != max) {
1699 UnicodeString a, b;
1700 nf->format(1.0, a);
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));
1706 }
1707
1708 // Make sure EURO currency formats have exactly 2 fraction digits
729e4ab9
A
1709 DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
1710 if (df != NULL) {
b75a7d8f
A
1711 if (u_strcmp(EUR, df->getCurrency()) == 0) {
1712 if (min != 2 || max != 2) {
1713 UnicodeString a;
1714 nf->format(1.0, a);
1715 errln((UnicodeString)"FAIL: " + locs[i].getName() +
1716 " is a EURO format but it does not have 2 fraction digits; "
1717 "x 1.0 => " +
1718 escape(a));
1719 }
1720 }
1721 }
1722 }
1723 delete nf;
1724 }
1725}
1726
1727void NumberFormatTest::TestRegCurrency(void) {
374ca955
A
1728#if !UCONFIG_NO_SERVICE
1729 UErrorCode status = U_ZERO_ERROR;
1730 UChar USD[4];
1731 ucurr_forLocale("en_US", USD, 4, &status);
1732 UChar YEN[4];
1733 ucurr_forLocale("ja_JP", YEN, 4, &status);
1734 UChar TMP[4];
1735 static const UChar QQQ[] = {0x51, 0x51, 0x51, 0};
1736 if(U_FAILURE(status)) {
729e4ab9 1737 errcheckln(status, "Unable to get currency for locale, error %s", u_errorName(status));
374ca955
A
1738 return;
1739 }
729e4ab9 1740
374ca955
A
1741 UCurrRegistryKey enkey = ucurr_register(YEN, "en_US", &status);
1742 UCurrRegistryKey enUSEUROkey = ucurr_register(QQQ, "en_US_EURO", &status);
729e4ab9 1743
374ca955
A
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");
1747 }
b75a7d8f 1748
374ca955
A
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");
1752 }
729e4ab9 1753
374ca955
A
1754 int32_t fallbackLen = ucurr_forLocale("en_XX_BAR", TMP, 4, &status);
1755 if (fallbackLen) {
1756 errln("FAIL: tried to fallback en_XX_BAR");
1757 }
1758 status = U_ZERO_ERROR; // reset
729e4ab9 1759
374ca955
A
1760 if (!ucurr_unregister(enkey, &status)) {
1761 errln("FAIL: couldn't unregister enkey");
1762 }
b75a7d8f 1763
729e4ab9 1764 ucurr_forLocale("en_US", TMP, 4, &status);
374ca955
A
1765 if (u_strcmp(USD, TMP) != 0) {
1766 errln("FAIL: didn't return USD for en_US after unregister of en_US");
1767 }
1768 status = U_ZERO_ERROR; // reset
729e4ab9 1769
374ca955
A
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");
1773 }
729e4ab9 1774
374ca955
A
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");
1778 }
1779 status = U_ZERO_ERROR; // reset
729e4ab9 1780
374ca955
A
1781 if (!ucurr_unregister(enUSEUROkey, &status)) {
1782 errln("FAIL: couldn't unregister enUSEUROkey");
1783 }
729e4ab9 1784
374ca955
A
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");
1788 }
1789 status = U_ZERO_ERROR; // reset
1790#endif
1791}
b75a7d8f 1792
374ca955
A
1793void NumberFormatTest::TestCurrencyNames(void) {
1794 // Do a basic check of getName()
1795 // USD { "US$", "US Dollar" } // 04/04/1792-
1796 UErrorCode ec = U_ZERO_ERROR;
46f4442e
A
1797 static const UChar USD[] = {0x55, 0x53, 0x44, 0}; /*USD*/
1798 static const UChar USX[] = {0x55, 0x53, 0x58, 0}; /*USX*/
73c04bcf
A
1799 static const UChar CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
1800 static const UChar ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
374ca955
A
1801 UBool isChoiceFormat;
1802 int32_t len;
729e4ab9 1803 const UBool possibleDataError = TRUE;
374ca955
A
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)",
46f4442e 1807 UnicodeString("$"),
374ca955
A
1808 UnicodeString(ucurr_getName(USD, "en",
1809 UCURR_SYMBOL_NAME,
729e4ab9
A
1810 &isChoiceFormat, &len, &ec)),
1811 possibleDataError);
374ca955
A
1812 assertEquals("USD.getName(LONG_NAME)",
1813 UnicodeString("US Dollar"),
1814 UnicodeString(ucurr_getName(USD, "en",
1815 UCURR_LONG_NAME,
729e4ab9
A
1816 &isChoiceFormat, &len, &ec)),
1817 possibleDataError);
46f4442e
A
1818 assertEquals("CAD.getName(SYMBOL_NAME)",
1819 UnicodeString("CA$"),
1820 UnicodeString(ucurr_getName(CAD, "en",
1821 UCURR_SYMBOL_NAME,
729e4ab9
A
1822 &isChoiceFormat, &len, &ec)),
1823 possibleDataError);
46f4442e
A
1824 assertEquals("CAD.getName(SYMBOL_NAME)",
1825 UnicodeString("$"),
1826 UnicodeString(ucurr_getName(CAD, "en_CA",
1827 UCURR_SYMBOL_NAME,
729e4ab9
A
1828 &isChoiceFormat, &len, &ec)),
1829 possibleDataError);
4388f060 1830 assertEquals("USD.getName(SYMBOL_NAME) in en_AU",
46f4442e
A
1831 UnicodeString("US$"),
1832 UnicodeString(ucurr_getName(USD, "en_AU",
1833 UCURR_SYMBOL_NAME,
729e4ab9
A
1834 &isChoiceFormat, &len, &ec)),
1835 possibleDataError);
46f4442e
A
1836 assertEquals("CAD.getName(SYMBOL_NAME)",
1837 UnicodeString("CA$"),
1838 UnicodeString(ucurr_getName(CAD, "en_AU",
1839 UCURR_SYMBOL_NAME,
729e4ab9
A
1840 &isChoiceFormat, &len, &ec)),
1841 possibleDataError);
46f4442e
A
1842 assertEquals("USX.getName(LONG_NAME)",
1843 UnicodeString("USX"),
1844 UnicodeString(ucurr_getName(USX, "en_US",
1845 UCURR_LONG_NAME,
729e4ab9
A
1846 &isChoiceFormat, &len, &ec)),
1847 possibleDataError);
374ca955 1848 assertSuccess("ucurr_getName", ec);
729e4ab9 1849
46f4442e
A
1850 ec = U_ZERO_ERROR;
1851
73c04bcf 1852 // Test that a default or fallback warning is being returned. JB 4239.
46f4442e
A
1853 ucurr_getName(CAD, "es_ES", UCURR_LONG_NAME, &isChoiceFormat,
1854 &len, &ec);
729e4ab9
A
1855 assertTrue("ucurr_getName (es_ES fallback)",
1856 U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError);
46f4442e
A
1857
1858 ucurr_getName(CAD, "zh_TW", UCURR_LONG_NAME, &isChoiceFormat,
73c04bcf 1859 &len, &ec);
729e4ab9
A
1860 assertTrue("ucurr_getName (zh_TW fallback)",
1861 U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError);
46f4442e
A
1862
1863 ucurr_getName(CAD, "en_US", UCURR_LONG_NAME, &isChoiceFormat,
1864 &len, &ec);
729e4ab9
A
1865 assertTrue("ucurr_getName (en_US default)",
1866 U_USING_DEFAULT_WARNING == ec || U_USING_FALLBACK_WARNING == ec, TRUE);
1867
4388f060 1868 ucurr_getName(CAD, "ti", UCURR_LONG_NAME, &isChoiceFormat,
73c04bcf 1869 &len, &ec);
4388f060 1870 assertTrue("ucurr_getName (ti default)",
73c04bcf 1871 U_USING_DEFAULT_WARNING == ec, TRUE);
729e4ab9 1872
73c04bcf 1873 // Test that a default warning is being returned when falling back to root. JB 4536.
46f4442e 1874 ucurr_getName(ITL, "cy", UCURR_LONG_NAME, &isChoiceFormat,
73c04bcf 1875 &len, &ec);
729e4ab9 1876 assertTrue("ucurr_getName (cy default to root)",
73c04bcf 1877 U_USING_DEFAULT_WARNING == ec, TRUE);
729e4ab9 1878
374ca955 1879 // TODO add more tests later
b75a7d8f
A
1880}
1881
73c04bcf
A
1882void 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);
1887
1888 const UChar * r = cu.getISOCurrency(); // who is the buffer owner ?
1889 assertEquals("getISOCurrency()", USD, r);
1890
1891 CurrencyUnit cu2(cu);
1892 if (!(cu2 == cu)){
1893 errln("CurrencyUnit copy constructed object should be same");
1894 }
1895
1896 CurrencyUnit * cu3 = (CurrencyUnit *)cu.clone();
1897 if (!(*cu3 == cu)){
1898 errln("CurrencyUnit cloned object should be same");
1899 }
1900 delete cu3;
1901}
1902
1903void 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);
1908
1909 CurrencyAmount ca2(ca);
1910 if (!(ca2 == ca)){
1911 errln("CurrencyAmount copy constructed object should be same");
1912 }
1913
1914 ca2=ca;
1915 if (!(ca2 == ca)){
1916 errln("CurrencyAmount assigned object should be same");
1917 }
729e4ab9 1918
73c04bcf
A
1919 CurrencyAmount *ca3 = (CurrencyAmount *)ca.clone();
1920 if (!(*ca3 == ca)){
1921 errln("CurrencyAmount cloned object should be same");
1922 }
1923 delete ca3;
1924}
1925
b75a7d8f
A
1926void NumberFormatTest::TestSymbolsWithBadLocale(void) {
1927 Locale locDefault;
4388f060
A
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",
1931
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
1935
1936 unsigned int i;
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);
b75a7d8f 1942
4388f060 1943 intlCurrencySymbol.append((UChar)0xa4);
374ca955 1944
4388f060
A
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.");
1951 }
1952 if (strcmp(mySymbols.getLocale().getName(), locBad.getName()) != 0) {
1953 errln("DecimalFormatSymbols does not have the right locale.", locBad.getName());
1954 }
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)
1962 {
1963 errln("DecimalFormatSymbols has an empty string at index %d.", symbolEnum);
1964 }
b75a7d8f 1965 }
4388f060
A
1966
1967 status = U_ZERO_ERROR;
1968 Locale::setDefault(locDefault, status);
1969 logln("Current locale is %s", Locale::getDefault().getName());
b75a7d8f 1970 }
b75a7d8f
A
1971}
1972
1973/**
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.)
1977 */
1978void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
1979 UErrorCode ec = U_ZERO_ERROR;
1980 DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), ec);
1981 if (U_FAILURE(ec)) {
729e4ab9 1982 errcheckln(ec, "Fail: DecimalFormatSymbols constructor - %s", u_errorName(ec));
b75a7d8f
A
1983 delete sym;
1984 return;
1985 }
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");
1991 return;
1992 }
1993
1994 UnicodeString str;
1995 fmt.format(2350.75, str);
1996 if (str == "$ 2,350.75") {
1997 logln(str);
1998 } else {
729e4ab9 1999 dataerrln("Fail: " + str + ", expected $ 2,350.75");
b75a7d8f
A
2000 }
2001
2002 sym = new DecimalFormatSymbols(Locale::getUS(), ec);
2003 if (U_FAILURE(ec)) {
2004 errln("Fail: DecimalFormatSymbols constructor");
2005 delete sym;
2006 return;
2007 }
2008 sym->setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q");
2009 fmt.adoptDecimalFormatSymbols(sym);
2010
2011 str.truncate(0);
2012 fmt.format(2350.75, str);
2013 if (str == "Q 2,350.75") {
2014 logln(str);
2015 } else {
729e4ab9 2016 dataerrln("Fail: adoptDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
b75a7d8f
A
2017 }
2018
2019 sym = new DecimalFormatSymbols(Locale::getUS(), ec);
2020 if (U_FAILURE(ec)) {
2021 errln("Fail: DecimalFormatSymbols constructor");
2022 delete sym;
2023 return;
2024 }
2025 DecimalFormat fmt2(pat, sym, ec);
2026 if (U_FAILURE(ec)) {
2027 errln("Fail: DecimalFormat constructor");
2028 return;
2029 }
729e4ab9 2030
b75a7d8f
A
2031 DecimalFormatSymbols sym2(Locale::getUS(), ec);
2032 if (U_FAILURE(ec)) {
2033 errln("Fail: DecimalFormatSymbols constructor");
2034 return;
2035 }
2036 sym2.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q");
2037 fmt2.setDecimalFormatSymbols(sym2);
2038
2039 str.truncate(0);
2040 fmt2.format(2350.75, str);
2041 if (str == "Q 2,350.75") {
2042 logln(str);
2043 } else {
729e4ab9 2044 dataerrln("Fail: setDecimalFormatSymbols -> " + str + ", expected Q 2,350.75");
b75a7d8f
A
2045 }
2046}
2047
374ca955
A
2048void NumberFormatTest::TestPerMill() {
2049 UErrorCode ec = U_ZERO_ERROR;
2050 UnicodeString str;
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));
729e4ab9 2055
374ca955
A
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;
2061 str.truncate(0);
2062 assertEquals("0.4857 x ###.###m",
2063 "485.7m", fmt2.format(0.4857, str));
2064}
2065
2066/**
2067 * Generic test for patterns that should be legal/illegal.
2068 */
2069void NumberFormatTest::TestIllegalPatterns() {
2070 // Test cases:
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
2075 "-:000.000|###",
2076 "+:000.000'|###'",
2077 0
2078 };
2079 for (int32_t i=0; DATA[i]; ++i) {
2080 const char* pat=DATA[i];
2081 UBool valid = (*pat) == '+';
2082 pat += 2;
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));
2088 } else {
729e4ab9 2089 errcheckln(ec, "FAIL: pattern \"%s\" should have %s; got %s",
374ca955
A
2090 pat, (valid?"succeeded":"failed"),
2091 u_errorName(ec));
2092 }
2093 }
2094}
2095
2096//----------------------------------------------------------------------
2097
2098static 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>
2108 0
2109};
2110
2111/**
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
2115 * the list.
2116 */
2117static int32_t keywordIndex(const UnicodeString& tok) {
2118 for (int32_t i=0; KEYWORDS[i]!=0; ++i) {
2119 if (tok==KEYWORDS[i]) {
2120 return i;
2121 }
2122 }
2123 return -1;
2124}
2125
2126/**
2127 * Parse a CurrencyAmount using the given NumberFormat, with
2128 * the 'delim' character separating the number and the currency.
2129 */
2130static void parseCurrencyAmount(const UnicodeString& str,
2131 const NumberFormat& fmt,
2132 UChar delim,
2133 Formattable& result,
2134 UErrorCode& ec) {
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);
2139 Formattable n;
2140 fmt.parse(num, n, ec);
2141 result.adoptObject(new CurrencyAmount(n, cur.getTerminatedBuffer(), ec));
2142}
2143
2144void NumberFormatTest::TestCases() {
2145 UErrorCode ec = U_ZERO_ERROR;
2146 TextFile reader("NumberFormatTestCases.txt", "UTF8", ec);
2147 if (U_FAILURE(ec)) {
729e4ab9 2148 dataerrln("Couldn't open NumberFormatTestCases.txt");
374ca955
A
2149 return;
2150 }
2151 TokenIterator tokens(&reader);
2152
2153 Locale loc("en", "US", "");
2154 DecimalFormat *ref = 0, *fmt = 0;
2155 MeasureFormat *mfmt = 0;
2156 UnicodeString pat, tok, mloc, str, out, where, currAmt;
2157 Formattable n;
2158
2159 for (;;) {
2160 ec = U_ZERO_ERROR;
2161 if (!tokens.next(tok, ec)) {
2162 break;
2163 }
2164 where = UnicodeString("(") + tokens.getLineNumber() + ") ";
2165 int32_t cmd = keywordIndex(tok);
2166 switch (cmd) {
2167 case 0:
2168 // ref= <reference pattern>
2169 if (!tokens.next(tok, ec)) goto error;
2170 delete ref;
2171 ref = new DecimalFormat(tok,
2172 new DecimalFormatSymbols(Locale::getUS(), ec), ec);
73c04bcf
A
2173 if (U_FAILURE(ec)) {
2174 dataerrln("Error constructing DecimalFormat");
2175 goto error;
2176 }
374ca955
A
2177 break;
2178 case 1:
2179 // loc= <locale>
2180 if (!tokens.next(tok, ec)) goto error;
729e4ab9 2181 loc = Locale::createFromName(CharString().appendInvariantChars(tok, ec).data());
374ca955
A
2182 break;
2183 case 2: // f:
2184 case 3: // fp:
2185 case 4: // rt:
2186 case 5: // p:
2187 if (!tokens.next(tok, ec)) goto error;
2188 if (tok != "-") {
2189 pat = tok;
2190 delete fmt;
2191 fmt = new DecimalFormat(pat, new DecimalFormatSymbols(loc, ec), ec);
2192 if (U_FAILURE(ec)) {
2193 errln("FAIL: " + where + "Pattern \"" + pat + "\": " + u_errorName(ec));
2194 ec = U_ZERO_ERROR;
2195 if (!tokens.next(tok, ec)) goto error;
2196 if (!tokens.next(tok, ec)) goto error;
2197 if (cmd == 3) {
2198 if (!tokens.next(tok, ec)) goto error;
2199 }
2200 continue;
2201 }
2202 }
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>
2207 UnicodeString num;
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);
2219 }
2220 if (cmd != 2) { // != f:
2221 Formattable m;
2222 fmt->parse(str, m, ec);
2223 assertSuccess("parse", ec);
2224 assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")",
2225 n, m);
729e4ab9 2226 }
374ca955
A
2227 }
2228 // p: <pattern or '-'> <string to parse> <exp. number>
2229 else {
2230 UnicodeString expstr;
2231 if (!tokens.next(str, ec)) goto error;
2232 if (!tokens.next(expstr, ec)) goto error;
2233 Formattable exp, n;
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 + "\")",
2239 exp, n);
2240 }
2241 break;
2242 case 8: // fpc:
2243 if (!tokens.next(tok, ec)) goto error;
2244 if (tok != "-") {
2245 mloc = tok;
2246 delete mfmt;
2247 mfmt = MeasureFormat::createCurrencyFormat(
729e4ab9
A
2248 Locale::createFromName(
2249 CharString().appendInvariantChars(mloc, ec).data()), ec);
374ca955
A
2250 if (U_FAILURE(ec)) {
2251 errln("FAIL: " + where + "Loc \"" + mloc + "\": " + u_errorName(ec));
2252 ec = U_ZERO_ERROR;
2253 if (!tokens.next(tok, ec)) goto error;
2254 if (!tokens.next(tok, ec)) goto error;
2255 if (!tokens.next(tok, ec)) goto error;
2256 continue;
2257 }
2258 }
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);
2267 }
2268 if (!tokens.next(currAmt, ec)) goto error;
2269 parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec);
2270 if (assertSuccess("parseCurrencyAmount", ec)) {
2271 Formattable m;
729e4ab9 2272
374ca955
A
2273 mfmt->parseObject(str, m, ec);
2274 if (assertSuccess("parseCurrency", ec)) {
2275 assertEquals(where + "getCurrencyFormat(" + mloc + ").parse(\"" + str + "\")",
2276 n, m);
729e4ab9
A
2277 } else {
2278 errln("FAIL: source " + str);
374ca955
A
2279 }
2280 }
2281 break;
2282 case 6:
2283 // perr: <pattern or '-'> <invalid string>
2284 errln("FAIL: Under construction");
2285 goto done;
2286 case 7: {
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 == "-") {
2295 if (err) {
2296 errln("FAIL: " + where + "Invalid command \"pat: - err\"");
2297 continue;
2298 }
2299 existingPat = TRUE;
2300 testpat = pat;
2301 }
2302 if (exppat == "-") exppat = testpat;
2303 DecimalFormat* f = 0;
2304 UErrorCode ec2 = U_ZERO_ERROR;
2305 if (existingPat) {
2306 f = fmt;
2307 } else {
2308 f = new DecimalFormat(testpat, ec2);
2309 }
2310 if (U_SUCCESS(ec2)) {
2311 if (err) {
2312 errln("FAIL: " + where + "Invalid pattern \"" + testpat +
2313 "\" was accepted");
2314 } else {
2315 UnicodeString pat2;
2316 assertEquals(where + "\"" + testpat + "\".toPattern()",
2317 exppat, f->toPattern(pat2));
2318 }
2319 } else {
2320 if (err) {
2321 logln("Ok: " + where + "Invalid pattern \"" + testpat +
2322 "\" failed: " + u_errorName(ec2));
2323 } else {
2324 errln("FAIL: " + where + "Valid pattern \"" + testpat +
2325 "\" failed: " + u_errorName(ec2));
2326 }
2327 }
2328 if (!existingPat) delete f;
2329 } break;
2330 case -1:
2331 errln("FAIL: " + where + "Unknown command \"" + tok + "\"");
2332 goto done;
2333 }
2334 }
2335 goto done;
2336
2337 error:
2338 if (U_SUCCESS(ec)) {
2339 errln("FAIL: Unexpected EOF");
2340 } else {
729e4ab9 2341 errcheckln(ec, "FAIL: " + where + "Unexpected " + u_errorName(ec));
374ca955
A
2342 }
2343
2344 done:
2345 delete mfmt;
2346 delete fmt;
2347 delete ref;
2348}
2349
2350
b75a7d8f
A
2351//----------------------------------------------------------------------
2352// Support methods
2353//----------------------------------------------------------------------
2354
2355UBool NumberFormatTest::equalValue(const Formattable& a, const Formattable& b) {
374ca955
A
2356 if (a.getType() == b.getType()) {
2357 return a == b;
2358 }
2359
b75a7d8f 2360 if (a.getType() == Formattable::kLong) {
374ca955 2361 if (b.getType() == Formattable::kInt64) {
b75a7d8f
A
2362 return a.getLong() == b.getLong();
2363 } else if (b.getType() == Formattable::kDouble) {
729e4ab9 2364 return (double) a.getLong() == b.getDouble(); // TODO check use of double instead of long
b75a7d8f
A
2365 }
2366 } else if (a.getType() == Formattable::kDouble) {
2367 if (b.getType() == Formattable::kLong) {
2368 return a.getDouble() == (double) b.getLong();
374ca955
A
2369 } else if (b.getType() == Formattable::kInt64) {
2370 return a.getDouble() == (double)b.getInt64();
2371 }
2372 } else if (a.getType() == Formattable::kInt64) {
2373 if (b.getType() == Formattable::kLong) {
2374 return a.getInt64() == (int64_t)b.getLong();
b75a7d8f 2375 } else if (b.getType() == Formattable::kDouble) {
374ca955 2376 return a.getInt64() == (int64_t)b.getDouble();
b75a7d8f
A
2377 }
2378 }
2379 return FALSE;
2380}
2381
729e4ab9
A
2382void 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);
2386}
2387
b75a7d8f
A
2388void 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);
2392}
2393
2394void NumberFormatTest::expect2(NumberFormat* fmt, const Formattable& n,
2395 const UnicodeString& exp,
2396 UErrorCode status) {
729e4ab9
A
2397 if (fmt == NULL || U_FAILURE(status)) {
2398 dataerrln("FAIL: NumberFormat constructor");
b75a7d8f
A
2399 } else {
2400 expect2(*fmt, n, exp);
2401 }
2402 delete fmt;
2403}
2404
2405void NumberFormatTest::expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) {
2406 UErrorCode status = U_ZERO_ERROR;
2407 Formattable num;
2408 fmt.parse(str, num, status);
2409 if (U_FAILURE(status)) {
729e4ab9 2410 dataerrln(UnicodeString("FAIL: Parse failed for \"") + str + "\" - " + u_errorName(status));
b75a7d8f
A
2411 return;
2412 }
2413 UnicodeString pat;
2414 ((DecimalFormat*) &fmt)->toPattern(pat);
2415 if (equalValue(num, n)) {
2416 logln(UnicodeString("Ok \"") + str + "\" x " +
2417 pat + " = " +
2418 toString(num));
2419 } else {
729e4ab9 2420 dataerrln(UnicodeString("FAIL \"") + str + "\" x " +
b75a7d8f
A
2421 pat + " = " +
2422 toString(num) + ", expected " + toString(n));
2423 }
2424}
2425
729e4ab9
A
2426void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) {
2427 UErrorCode status = U_ZERO_ERROR;
2428 Formattable num;
2429 fmt.parse(str, num, status);
2430 if (U_FAILURE(status)) {
2431 errln(UnicodeString("FAIL: Parse failed for \"") + str + "\"");
2432 return;
2433 }
2434 if (equalValue(num, n)) {
2435 logln(UnicodeString("Ok \"") + str + " = " +
2436 toString(num));
2437 } else {
2438 errln(UnicodeString("FAIL \"") + str + " = " +
2439 toString(num) + ", expected " + toString(n));
2440 }
2441}
2442
2443void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const Formattable& n,
2444 const UnicodeString& exp, UBool rt) {
2445 UnicodeString saw;
2446 FieldPosition pos;
2447 UErrorCode status = U_ZERO_ERROR;
2448 fmt.format(n, saw, pos, status);
2449 CHECK(status, "NumberFormat::format");
2450 if (saw == exp) {
2451 logln(UnicodeString("Ok ") + toString(n) +
2452 " = \"" +
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):
2457 if (rt) {
2458 Formattable n2;
2459 fmt.parse(exp, n2, status);
2460 if (U_FAILURE(status)) {
2461 errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\"");
2462 return;
2463 }
2464 UnicodeString saw2;
2465 fmt.format(n2, saw2, pos, status);
2466 CHECK(status, "NumberFormat::format");
2467 if (saw2 != exp) {
2468 errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) +
2469 " => \"" + saw2 + "\"");
2470 }
2471 }
2472 } else {
2473 errln(UnicodeString("FAIL ") + toString(n) +
2474 " = \"" +
2475 escape(saw) + "\", expected \"" + exp + "\"");
2476 }
2477}
2478
b75a7d8f
A
2479void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n,
2480 const UnicodeString& exp, UBool rt) {
2481 UnicodeString saw;
2482 FieldPosition pos;
2483 UErrorCode status = U_ZERO_ERROR;
2484 fmt.format(n, saw, pos, status);
2485 CHECK(status, "NumberFormat::format");
2486 UnicodeString pat;
2487 ((DecimalFormat*) &fmt)->toPattern(pat);
2488 if (saw == exp) {
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):
2495 if (rt) {
2496 Formattable n2;
2497 fmt.parse(exp, n2, status);
2498 if (U_FAILURE(status)) {
729e4ab9 2499 errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\" - " + u_errorName(status));
b75a7d8f
A
2500 return;
2501 }
2502 UnicodeString saw2;
2503 fmt.format(n2, saw2, pos, status);
2504 CHECK(status, "NumberFormat::format");
2505 if (saw2 != exp) {
2506 errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) +
2507 " => \"" + saw2 + "\"");
2508 }
2509 }
2510 } else {
729e4ab9 2511 dataerrln(UnicodeString("FAIL ") + toString(n) + " x " +
b75a7d8f
A
2512 escape(pat) + " = \"" +
2513 escape(saw) + "\", expected \"" + exp + "\"");
2514 }
2515}
2516
2517void NumberFormatTest::expect(NumberFormat* fmt, const Formattable& n,
2518 const UnicodeString& exp,
2519 UErrorCode status) {
729e4ab9
A
2520 if (fmt == NULL || U_FAILURE(status)) {
2521 dataerrln("FAIL: NumberFormat constructor");
b75a7d8f
A
2522 } else {
2523 expect(*fmt, n, exp);
2524 }
2525 delete fmt;
2526}
2527
2528void 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};
374ca955
A
2533 UChar curr[4];
2534 u_strcpy(curr, DEFAULT_CURR);
b75a7d8f 2535 if (*locale.getLanguage() != 0) {
374ca955
A
2536 ucurr_forLocale(locale.getName(), curr, 4, &ec);
2537 assertSuccess("ucurr_forLocale", ec);
2538 fmt.setCurrency(curr, ec);
2539 assertSuccess("DecimalFormat::setCurrency", ec);
73c04bcf 2540 fmt.setCurrency(curr); //Deprecated variant, for coverage only
b75a7d8f
A
2541 }
2542 UnicodeString s;
2543 fmt.format(value, s);
2544 s.findAndReplace((UChar32)0x00A0, (UChar32)0x0020);
2545
2546 // Default display of the number yields "1234.5599999999999"
2547 // instead of "1234.56". Use a formatter to fix this.
729e4ab9 2548 NumberFormat* f =
b75a7d8f
A
2549 NumberFormat::createInstance(Locale::getUS(), ec);
2550 UnicodeString v;
2551 if (U_FAILURE(ec)) {
2552 // Oops; bad formatter. Use default op+= display.
2553 v = (UnicodeString)"" + value;
2554 } else {
2555 f->setMaximumFractionDigits(4);
2556 f->setGroupingUsed(FALSE);
2557 f->format(value, v);
2558 }
2559 delete f;
2560
2561 if (s == string) {
2562 logln((UnicodeString)"Ok: " + v + " x " + curr + " => " + prettify(s));
2563 } else {
2564 errln((UnicodeString)"FAIL: " + v + " x " + curr + " => " + prettify(s) +
2565 ", expected " + prettify(string));
2566 }
2567}
2568
2569void NumberFormatTest::expectPat(DecimalFormat& fmt, const UnicodeString& exp) {
2570 UnicodeString pat;
2571 fmt.toPattern(pat);
2572 if (pat == exp) {
2573 logln(UnicodeString("Ok \"") + pat + "\"");
2574 } else {
2575 errln(UnicodeString("FAIL \"") + pat + "\", expected \"" + exp + "\"");
2576 }
2577}
2578
2579void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
2580 int32_t pos) {
2581 expectPad(fmt, pat, pos, 0, (UnicodeString)"");
2582}
2583void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
2584 int32_t pos, int32_t width, UChar pad) {
2585 expectPad(fmt, pat, pos, width, UnicodeString(pad));
2586}
2587void 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();
2597 } else {
2598 apos = -1;
2599 awidth = width;
2600 apadStr = pad;
2601 }
2602 if (apos == pos && awidth == width && apadStr == pad) {
374ca955
A
2603 UnicodeString infoStr;
2604 if (pos == ILLEGAL) {
2605 infoStr = UnicodeString(" width=", "") + awidth + UnicodeString(" pad=", "") + apadStr;
2606 }
2607 logln(UnicodeString("Ok \"") + pat + "\" pos=" + apos + infoStr);
b75a7d8f
A
2608 } else {
2609 errln(UnicodeString("FAIL \"") + pat + "\" pos=" + apos +
2610 " width=" + awidth + " pad=" + apadStr +
2611 ", expected " + pos + " " + width + " " + pad);
2612 }
2613}
73c04bcf
A
2614void NumberFormatTest::TestJB3832(){
2615 const char* localeID = "pt_PT@currency=PTE";
2616 Locale loc(localeID);
2617 UErrorCode status = U_ZERO_ERROR;
46f4442e 2618 UnicodeString expected(CharsToUnicodeString("1,150$50\\u00A0Esc."));
73c04bcf
A
2619 UnicodeString s;
2620 NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(loc, status);
2621 if(U_FAILURE(status)){
729e4ab9 2622 dataerrln("Could not create currency formatter for locale %s - %s", localeID, u_errorName(status));
73c04bcf
A
2623 return;
2624 }
2625 currencyFmt->format(1150.50, s);
2626 if(s!=expected){
729e4ab9
A
2627 errln(UnicodeString("FAIL: Expected: ")+expected
2628 + UnicodeString(" Got: ") + s
73c04bcf
A
2629 + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
2630 }
2631 if (U_FAILURE(status)){
2632 errln("FAIL: Status %s", u_errorName(status));
2633 }
2634 delete currencyFmt;
2635}
2636
2637void NumberFormatTest::TestHost()
2638{
4388f060 2639#if U_PLATFORM_USES_ONLY_WIN32_API
73c04bcf
A
2640 Win32NumberTest::testLocales(this);
2641#endif
4388f060
A
2642 Locale loc("en_US@compat=host");
2643 for (UNumberFormatStyle k = UNUM_DECIMAL;
2644 k < UNUM_FORMAT_STYLE_COUNT; k = (UNumberFormatStyle)(k+1)) {
729e4ab9 2645 UErrorCode status = U_ZERO_ERROR;
4388f060
A
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));
2651 }
2652 continue;
2653 }
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));
729e4ab9
A
2657 return;
2658 }
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");
2664 return;
2665 }
2666 Formattable formattable;
2667 full->parse(result1, formattable, status);
2668 if (U_FAILURE(status)) {
2669 errln("FAIL: Can't parse for host");
2670 return;
2671 }
729e4ab9 2672 }
73c04bcf
A
2673}
2674
46f4442e
A
2675void NumberFormatTest::TestHostClone()
2676{
2677 /*
2678 Verify that a cloned formatter gives the same results
2679 and is useable after the original has been deleted.
2680 */
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)) {
729e4ab9 2687 dataerrln("FAIL: Can't create Relative date instance - %s", u_errorName(status));
46f4442e
A
2688 return;
2689 }
2690 UnicodeString result1;
2691 full->format(now, result1, status);
2692 Format *fullClone = full->clone();
2693 delete full;
2694 full = NULL;
2695
2696 UnicodeString result2;
2697 fullClone->format(now, result2, status);
2698 if (U_FAILURE(status)) {
2699 errln("FAIL: format failure.");
2700 }
2701 if (result1 != result2) {
2702 errln("FAIL: Clone returned different result from non-clone.");
2703 }
2704 delete fullClone;
2705}
2706
73c04bcf
A
2707void NumberFormatTest::TestCurrencyFormat()
2708{
2709 // This test is here to increase code coverage.
2710 UErrorCode status = U_ZERO_ERROR;
2711 MeasureFormat *cloneObj;
2712 UnicodeString str;
2713 Formattable toFormat, result;
2714 static const UChar ISO_CODE[4] = {0x0047, 0x0042, 0x0050, 0};
2715
2716 Locale saveDefaultLocale = Locale::getDefault();
2717 Locale::setDefault( Locale::getUK(), status );
2718 if (U_FAILURE(status)) {
2719 errln("couldn't set default Locale!");
2720 return;
2721 }
2722
2723 MeasureFormat *measureObj = MeasureFormat::createCurrencyFormat(status);
2724 Locale::setDefault( saveDefaultLocale, status );
2725 if (U_FAILURE(status)){
729e4ab9 2726 dataerrln("FAIL: Status %s", u_errorName(status));
73c04bcf
A
2727 return;
2728 }
2729 cloneObj = (MeasureFormat *)measureObj->clone();
2730 if (cloneObj == NULL) {
2731 errln("Clone doesn't work");
2732 return;
2733 }
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));
2739 }
2740 if (result != toFormat) {
2741 errln("measureObj does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat));
2742 }
2743 status = U_ZERO_ERROR;
2744 str.truncate(0);
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));
2749 }
2750 if (result != toFormat) {
2751 errln("Clone does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat));
2752 }
46f4442e
A
2753 if (*measureObj != *cloneObj) {
2754 errln("Cloned object is not equal to the original object");
2755 }
73c04bcf
A
2756 delete measureObj;
2757 delete cloneObj;
2758
46f4442e
A
2759 status = U_USELESS_COLLATOR_ERROR;
2760 if (MeasureFormat::createCurrencyFormat(status) != NULL) {
2761 errln("createCurrencyFormat should have returned NULL.");
2762 }
2763}
2764
2765/* Port of ICU4J rounding test. */
2766void NumberFormatTest::TestRounding() {
2767 UErrorCode status = U_ZERO_ERROR;
2768 DecimalFormat *df = (DecimalFormat*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status);
2769
2770 if (U_FAILURE(status)) {
729e4ab9 2771 dataerrln("Unable to create decimal formatter. - %s", u_errorName(status));
46f4442e
A
2772 return;
2773 }
2774
2775 int roundingIncrements[]={1, 2, 5, 20, 50, 100};
2776 int testValues[]={0, 300};
2777
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);
2787 }
2788 }
2789 }
2790 delete df;
2791}
2792
4388f060
A
2793void NumberFormatTest::TestRoundingPattern() {
2794 UErrorCode status = U_ZERO_ERROR;
2795 struct {
2796 UnicodeString pattern;
2797 double testCase;
2798 UnicodeString expected;
2799 } tests[] = {
2800 { (UnicodeString)"##0.65", 1.234, (UnicodeString)"1.30" },
2801 { (UnicodeString)"#50", 1230, (UnicodeString)"1250" }
2802 };
2803 int32_t numOfTests = (sizeof(tests)/sizeof(tests[0]));
2804 UnicodeString result;
2805
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));
2809 return;
2810 }
2811
2812 for (int32_t i = 0; i < numOfTests; i++) {
2813 result.remove();
2814
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));
2818 }
2819
2820 df->format(tests[i].testCase, result);
2821
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);
2824 }
2825 }
2826
2827 delete df;
2828}
2829
46f4442e
A
2830void 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;
2836 if (iValue!=0) {
2837 smallIncrement*=iValue;
2838 }
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);
2843 }
2844}
2845
2846double NumberFormatTest::checkRound(DecimalFormat* df, double iValue, double lastParsed) {
2847 UErrorCode status=U_ZERO_ERROR;
2848 UnicodeString formattedDecimal;
2849 double parsed;
2850 Formattable result;
2851 df->format(iValue, formattedDecimal, status);
2852
2853 if (U_FAILURE(status)) {
2854 errln("Error formatting number.");
2855 }
2856
2857 df->parse(formattedDecimal, result, status);
2858
2859 if (U_FAILURE(status)) {
2860 errln("Error parsing number.");
2861 }
2862
2863 parsed=result.getDouble();
2864
2865 if (lastParsed>parsed) {
2866 errln("Rounding wrong direction! %d > %d", lastParsed, parsed);
2867 }
2868
2869 return lastParsed;
2870}
2871
2872void 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)");
729e4ab9 2878
46f4442e
A
2879 // test zero multiplier
2880
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");
2885 }
729e4ab9 2886
46f4442e 2887 // test negative multiplier
729e4ab9 2888
46f4442e
A
2889 df.setMultiplier(-1);
2890 if (df.getMultiplier() != -1) {
2891 errln("DecimalFormat.setMultiplier(-1) ignored its negative input");
2892 return;
2893 }
729e4ab9 2894
46f4442e
A
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);
2899
729e4ab9
A
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");
46f4442e 2909 expect(df, U_INT64_MAX-1, "-9223372036854775806");
729e4ab9 2910 expect(df, U_INT64_MAX, "-9223372036854775807");
46f4442e
A
2911
2912 df.setMultiplier(-2);
2913 expect(df, -(U_INT64_MIN/2)-1, "-9223372036854775806");
729e4ab9
A
2914 expect(df, -(U_INT64_MIN/2), "-9223372036854775808");
2915 expect(df, -(U_INT64_MIN/2)+1, "-9223372036854775810", FALSE);
46f4442e
A
2916
2917 df.setMultiplier(-7);
729e4ab9
A
2918 expect(df, -(U_INT64_MAX/7)-1, "9223372036854775814", FALSE);
2919 expect(df, -(U_INT64_MAX/7), "9223372036854775807");
46f4442e
A
2920 expect(df, -(U_INT64_MAX/7)+1, "9223372036854775800");
2921
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)));
2928
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());
2934}
2935
4388f060
A
2936typedef struct {
2937 const char * stringToParse;
2938 int parsedPos;
2939 int errorIndex;
2940 UBool lenient;
2941} TestSpaceParsingItem;
729e4ab9 2942
46f4442e
A
2943void
2944NumberFormatTest::TestSpaceParsing() {
2945 // the data are:
2946 // the string to be parsed, parsed position, parsed error index
4388f060
A
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},
46f4442e 2970 };
46f4442e 2971 UErrorCode status = U_ZERO_ERROR;
729e4ab9 2972 Locale locale("en_US");
46f4442e 2973 NumberFormat* foo = NumberFormat::createCurrencyInstance(locale, status);
729e4ab9 2974
46f4442e
A
2975 if (U_FAILURE(status)) {
2976 delete foo;
2977 return;
2978 }
46f4442e
A
2979 for (uint32_t i = 0; i < sizeof(DATA)/sizeof(DATA[0]); ++i) {
2980 ParsePosition parsePosition(0);
4388f060
A
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);
46f4442e
A
2985 Formattable result;
2986 foo->parse(stringToBeParsed, result, parsePosition);
2987 if (parsePosition.getIndex() != parsedPosition ||
2988 parsePosition.getErrorIndex() != errorIndex) {
4388f060 2989 errln("FAILED parse " + stringToBeParsed + "; lenient: " + DATA[i].lenient + "; wrong position, expected: (" + parsedPosition + ", " + errorIndex + "); got (" + parsePosition.getIndex() + ", " + parsePosition.getErrorIndex() + ")");
46f4442e
A
2990 }
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());
2995 }
2996 }
2997 delete foo;
73c04bcf 2998}
b75a7d8f 2999
729e4ab9
A
3000/**
3001 * Test using various numbering systems and numbering system keyword.
3002 */
4388f060
A
3003typedef struct {
3004 const char *localeName;
3005 double value;
3006 UBool isRBNF;
3007 const char *expectedResult;
3008} TestNumberingSystemItem;
3009
729e4ab9 3010void NumberFormatTest::TestNumberingSystems() {
729e4ab9 3011
4388f060
A
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 }
3027 };
729e4ab9 3028
4388f060 3029 UErrorCode ec;
729e4ab9 3030
4388f060
A
3031 const TestNumberingSystemItem *item;
3032 for (item = DATA; item->localeName != NULL; item++) {
3033 ec = U_ZERO_ERROR;
3034 Locale loc = Locale::createFromName(item->localeName);
3035 NumberFormat *fmt = NumberFormat::createInstance(loc,ec);
729e4ab9 3036
4388f060
A
3037 if (U_FAILURE(ec)) {
3038 dataerrln("FAIL: getInstance(%s) - %s", item->localeName, u_errorName(ec));
3039 continue;
3040 }
3041
3042 if (item->isRBNF) {
3043 expect3(*fmt,item->value,CharsToUnicodeString(item->expectedResult));
3044 } else {
3045 expect2(*fmt,item->value,CharsToUnicodeString(item->expectedResult));
3046 }
3047 delete fmt;
729e4ab9
A
3048 }
3049
4388f060 3050
729e4ab9 3051 // Test bogus keyword value
4388f060
A
3052 ec = U_ZERO_ERROR;
3053 Locale loc4 = Locale::createFromName("en_US@numbers=foobar");
729e4ab9
A
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");
4388f060 3057 delete fmt4;
729e4ab9
A
3058 }
3059
3060 ec = U_ZERO_ERROR;
3061 NumberingSystem *ns = NumberingSystem::createInstance(ec);
3062 if (U_FAILURE(ec)) {
3063 dataerrln("FAIL: NumberingSystem::createInstance(ec); - %s", u_errorName(ec));
3064 }
3065
3066 if ( ns != NULL ) {
3067 ns->getDynamicClassID();
3068 ns->getStaticClassID();
3069 } else {
3070 errln("FAIL: getInstance() returned NULL.");
3071 }
3072
3073 NumberingSystem *ns1 = new NumberingSystem(*ns);
3074 if (ns1 == NULL) {
3075 errln("FAIL: NumberSystem copy constructor returned NULL.");
3076 }
3077
3078 delete ns1;
3079 delete ns;
4388f060 3080
729e4ab9
A
3081}
3082
3083
3084void
3085NumberFormatTest::TestMultiCurrencySign() {
3086 const char* DATA[][6] = {
3087 // the fields in the following test are:
3088 // locale,
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".
3094 // for US locale
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"},
3098 // for CHINA locale
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"}
3102 };
3103
3104 const UChar doubleCurrencySign[] = {0xA4, 0xA4, 0};
3105 UnicodeString doubleCurrencyStr(doubleCurrencySign);
3106 const UChar tripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
3107 UnicodeString tripleCurrencyStr(tripleCurrencySign);
3108
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)) {
3116 delete sym;
3117 continue;
3118 }
3119 for (int j=1; j<=3; ++j) {
3120 // j represents the number of currency sign in the pattern.
3121 if (j == 2) {
3122 pat = pat.findAndReplace(ctou("\\u00A4"), doubleCurrencyStr);
3123 } else if (j == 3) {
3124 pat = pat.findAndReplace(ctou("\\u00A4\\u00A4"), tripleCurrencyStr);
3125 }
3126
3127 DecimalFormat* fmt = new DecimalFormat(pat, new DecimalFormatSymbols(*sym), status);
3128 if (U_FAILURE(status)) {
3129 errln("FAILED init DecimalFormat ");
3130 delete fmt;
3131 continue;
3132 }
3133 UnicodeString s;
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);
3146 }
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);
3166 }
3167 }
3168 delete fmt;
3169 }
3170 delete sym;
3171 }
3172}
3173
3174
3175void
3176NumberFormatTest::TestCurrencyFormatForMixParsing() {
3177 UErrorCode status = U_ZERO_ERROR;
3178 MeasureFormat* curFmt = MeasureFormat::createCurrencyFormat(Locale("en_US"), status);
3179 if (U_FAILURE(status)) {
3180 delete curFmt;
3181 return;
3182 }
3183 const char* formats[] = {
3184 "$1,234.56", // string to be parsed
3185 "USD1,234.56",
3186 "US dollars1,234.56",
3187 "1,234.56 US dollars"
3188 };
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);
3193 Formattable result;
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)
3202 ) {
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());
3206 }
3207 if (curramt->getISOCurrency() != ISO_CURRENCY_USD) {
3208 errln((UnicodeString)"wong currency, expect: USD" + ", got: " + curramt->getISOCurrency());
3209 }
3210 }
3211 }
3212 delete curFmt;
3213}
3214
3215
3216void
3217NumberFormatTest::TestDecimalFormatCurrencyParse() {
3218 // Locale.US
3219 UErrorCode status = U_ZERO_ERROR;
3220 DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale("en_US"), status);
3221 if (U_FAILURE(status)) {
3222 delete sym;
3223 return;
3224 }
3225 UnicodeString pat;
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)) {
3231 delete fmt;
3232 errln("failed to new DecimalFormat in TestDecimalFormatCurrencyParse");
3233 return;
3234 }
3235 const char* DATA[][2] = {
3236 // the data are:
3237 // string to be parsed, the parsed result (number)
3238 {"$1.00", "1"},
3239 {"USD1.00", "1"},
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"},
3244 };
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;
3249 Formattable result;
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);
3257 }
3258 }
3259 delete fmt;
3260}
3261
3262
3263void
3264NumberFormatTest::TestCurrencyIsoPluralFormat() {
4388f060 3265 static const char* DATA[][6] = {
729e4ab9
A
3266 // the data are:
3267 // locale,
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,
3273
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"},
4388f060
A
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"},
729e4ab9
A
3286 // test locale without currency information
3287 {"root", "-1.23", "USD", "-US$\\u00A01.23", "-USD\\u00A01.23", "-1.23 USD"},
3288 // test choice format
4388f060
A
3289 {"es_AR", "1", "INR", "\\u20B91,00", "INR1,00", "1,00 rupia india"},
3290 };
3291 static const UNumberFormatStyle currencyStyles[] = {
3292 UNUM_CURRENCY,
3293 UNUM_CURRENCY_ISO,
3294 UNUM_CURRENCY_PLURAL
729e4ab9
A
3295 };
3296
4388f060
A
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];
729e4ab9
A
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)) {
3307 delete numFmt;
3308 dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
3309 continue;
3310 }
3311 UChar currencyCode[4];
3312 u_charsToUChars(currencyISOCode, currencyCode, 4);
3313 numFmt->setCurrency(currencyCode, status);
3314 if (U_FAILURE(status)) {
3315 delete numFmt;
3316 errln((UnicodeString)"can not set currency:" + currencyISOCode);
3317 continue;
3318 }
3319
3320 UnicodeString strBuf;
3321 numFmt->format(numberToBeFormat, strBuf);
4388f060 3322 int resultDataIndex = 3 + kIndex;
729e4ab9
A
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);
3328 }
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());
3350 } else {
3351 errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong());
3352 }
3353 }
3354 }
3355 delete numFmt;
3356 }
3357 }
3358}
3359
3360void
3361NumberFormatTest::TestCurrencyParsing() {
4388f060 3362 static const char* DATA[][6] = {
729e4ab9
A
3363 // the data are:
3364 // locale,
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"},
4388f060
A
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"},
729e4ab9
A
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"},
4388f060 3377 {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 Dolar Amerika Serikat"},
729e4ab9
A
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"},
3384 };
4388f060
A
3385 static const UNumberFormatStyle currencyStyles[] = {
3386 UNUM_CURRENCY,
3387 UNUM_CURRENCY_ISO,
3388 UNUM_CURRENCY_PLURAL
3389 };
729e4ab9
A
3390
3391#ifdef NUMFMTST_CACHE_DEBUG
3392int deadloop = 0;
3393for (;;) {
3394 printf("loop: %d\n", deadloop++);
3395#endif
3396 for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) {
4388f060
A
3397 for (int32_t kIndex = 0; kIndex < LENGTHOF(currencyStyles); ++kIndex) {
3398 UNumberFormatStyle k = currencyStyles[kIndex];
729e4ab9
A
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)) {
3406 delete numFmt;
3407 dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
3408 continue;
3409 }
729e4ab9 3410 UChar currencyCode[4];
4388f060 3411 u_charsToUChars(currencyISOCode, currencyCode, 4);
729e4ab9
A
3412 numFmt->setCurrency(currencyCode, status);
3413 if (U_FAILURE(status)) {
3414 delete numFmt;
3415 errln((UnicodeString)"can not set currency:" + currencyISOCode);
3416 continue;
3417 }
3418
3419 /*
3420 UnicodeString strBuf;
3421 numFmt->format(numberToBeFormat, strBuf);
4388f060 3422 int resultDataIndex = 3 + kIndex;
729e4ab9
A
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);
3428 }
3429 */
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());
3452 } else {
3453 errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong());
3454 }
3455 }
3456 }
3457 delete numFmt;
3458 }
3459 }
3460#ifdef NUMFMTST_CACHE_DEBUG
3461}
3462#endif
3463}
3464
3465
3466void
3467NumberFormatTest::TestParseCurrencyInUCurr() {
3468 const char* DATA[] = {
3469 "1.00 US DOLLAR", // case in-sensitive
3470 "$1.00",
3471 "USD1.00",
3472 "US dollar1.00",
3473 "US dollars1.00",
3474 "$1.00",
3475 "AU$1.00",
3476 "ADP1.00",
3477 "ADP1.00",
3478 "AED1.00",
3479 "AED1.00",
3480 "AFA1.00",
3481 "AFA1.00",
3482 "AFN1.00",
3483 "ALL1.00",
3484 "AMD1.00",
3485 "ANG1.00",
3486 "AOA1.00",
3487 "AOK1.00",
3488 "AOK1.00",
3489 "AON1.00",
3490 "AON1.00",
3491 "AOR1.00",
3492 "AOR1.00",
4388f060 3493 "ARS1.00",
729e4ab9
A
3494 "ARA1.00",
3495 "ARA1.00",
3496 "ARP1.00",
3497 "ARP1.00",
3498 "ARS1.00",
3499 "ATS1.00",
3500 "ATS1.00",
3501 "AUD1.00",
3502 "AWG1.00",
3503 "AZM1.00",
3504 "AZM1.00",
3505 "AZN1.00",
729e4ab9 3506 "Afghan Afghani (1927-2002)1.00",
4388f060 3507 "Afghan afghani (1927-2002)1.00",
729e4ab9 3508 "Afghan Afghani1.00",
729e4ab9 3509 "Afghan Afghanis1.00",
729e4ab9
A
3510 "Albanian Lek1.00",
3511 "Albanian lek1.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",
729e4ab9
A
3557 "BAD1.00",
3558 "BAD1.00",
3559 "BAM1.00",
3560 "BBD1.00",
729e4ab9
A
3561 "BDT1.00",
3562 "BEC1.00",
3563 "BEC1.00",
3564 "BEF1.00",
3565 "BEL1.00",
3566 "BEL1.00",
729e4ab9
A
3567 "BGL1.00",
3568 "BGN1.00",
3569 "BGN1.00",
3570 "BHD1.00",
3571 "BIF1.00",
3572 "BMD1.00",
3573 "BND1.00",
3574 "BOB1.00",
3575 "BOP1.00",
3576 "BOP1.00",
3577 "BOV1.00",
3578 "BOV1.00",
3579 "BRB1.00",
3580 "BRB1.00",
3581 "BRC1.00",
3582 "BRC1.00",
3583 "BRE1.00",
3584 "BRE1.00",
3585 "BRL1.00",
3586 "BRN1.00",
3587 "BRN1.00",
3588 "BRR1.00",
3589 "BRR1.00",
3590 "BSD1.00",
3591 "BSD1.00",
3592 "BTN1.00",
3593 "BUK1.00",
3594 "BUK1.00",
3595 "BWP1.00",
3596 "BYB1.00",
3597 "BYB1.00",
3598 "BYR1.00",
729e4ab9
A
3599 "BZD1.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",
729e4ab9
A
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",
729e4ab9
A
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",
729e4ab9
A
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",
3684 "Burmese Kyat1.00",
3685 "Burmese kyat1.00",
3686 "Burmese kyats1.00",
3687 "Burundian Franc1.00",
3688 "Burundian franc1.00",
3689 "Burundian francs1.00",
729e4ab9
A
3690 "CA$1.00",
3691 "CAD1.00",
3692 "CDF1.00",
3693 "CDF1.00",
729e4ab9
A
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",
3700 "CFP Franc1.00",
3701 "CFP franc1.00",
3702 "CFP francs1.00",
3703 "CFPF1.00",
3704 "CHE1.00",
3705 "CHE1.00",
3706 "CHF1.00",
3707 "CHW1.00",
3708 "CHW1.00",
729e4ab9
A
3709 "CLF1.00",
3710 "CLF1.00",
3711 "CLP1.00",
3712 "CNY1.00",
729e4ab9
A
3713 "COP1.00",
3714 "COU1.00",
3715 "COU1.00",
3716 "CRC1.00",
3717 "CSD1.00",
3718 "CSD1.00",
3719 "CSK1.00",
3720 "CSK1.00",
3721 "CUP1.00",
3722 "CUP1.00",
3723 "CVE1.00",
3724 "CYP1.00",
3725 "CZK1.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",
3738 "Chilean Peso1.00",
3739 "Chilean Unit of Account (UF)1.00",
3740 "Chilean peso1.00",
3741 "Chilean pesos1.00",
3742 "Chilean unit of account (UF)1.00",
3743 "Chilean units of account (UF)1.00",
3744 "Chinese Yuan1.00",
3745 "Chinese yuan1.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",
3764 "Cuban Peso1.00",
3765 "Cuban peso1.00",
3766 "Cuban pesos1.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",
729e4ab9
A
3776 "DDM1.00",
3777 "DDM1.00",
3778 "DEM1.00",
3779 "DEM1.00",
3780 "DJF1.00",
3781 "DKK1.00",
3782 "DOP1.00",
3783 "DZD1.00",
3784 "Danish Krone1.00",
3785 "Danish krone1.00",
3786 "Danish kroner1.00",
729e4ab9
A
3787 "German Mark1.00",
3788 "German mark1.00",
3789 "German marks1.00",
3790 "Djiboutian Franc1.00",
3791 "Djiboutian franc1.00",
3792 "Djiboutian francs1.00",
729e4ab9
A
3793 "Dominican Peso1.00",
3794 "Dominican peso1.00",
3795 "Dominican pesos1.00",
3796 "EC$1.00",
3797 "ECS1.00",
3798 "ECS1.00",
3799 "ECV1.00",
3800 "ECV1.00",
3801 "EEK1.00",
3802 "EEK1.00",
3803 "EGP1.00",
3804 "EGP1.00",
3805 "ERN1.00",
3806 "ERN1.00",
3807 "ESA1.00",
3808 "ESA1.00",
3809 "ESB1.00",
3810 "ESB1.00",
3811 "ESP1.00",
3812 "ETB1.00",
3813 "EUR1.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",
729e4ab9
A
3837 "Estonian Kroon1.00",
3838 "Estonian kroon1.00",
3839 "Estonian kroons1.00",
3840 "Ethiopian Birr1.00",
3841 "Ethiopian birr1.00",
3842 "Ethiopian birrs1.00",
3843 "Euro1.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",
729e4ab9
A
3859 "FIM1.00",
3860 "FIM1.00",
3861 "FJD1.00",
3862 "FKP1.00",
3863 "FKP1.00",
3864 "FRF1.00",
3865 "FRF1.00",
3866 "Falkland Islands Pound1.00",
3867 "Falkland Islands pound1.00",
3868 "Falkland Islands pounds1.00",
729e4ab9
A
3869 "Fijian Dollar1.00",
3870 "Fijian dollar1.00",
3871 "Fijian dollars1.00",
3872 "Finnish Markka1.00",
3873 "Finnish markka1.00",
3874 "Finnish markkas1.00",
3875 "CHF1.00",
3876 "French Franc1.00",
3877 "French Gold Franc1.00",
3878 "French UIC-Franc1.00",
3879 "French UIC-franc1.00",
3880 "French UIC-francs1.00",
3881 "French franc1.00",
3882 "French francs1.00",
3883 "French gold franc1.00",
3884 "French gold francs1.00",
729e4ab9
A
3885 "GBP1.00",
3886 "GEK1.00",
3887 "GEK1.00",
3888 "GEL1.00",
729e4ab9
A
3889 "GHC1.00",
3890 "GHC1.00",
3891 "GHS1.00",
3892 "GIP1.00",
3893 "GIP1.00",
3894 "GMD1.00",
3895 "GMD1.00",
3896 "GNF1.00",
3897 "GNS1.00",
3898 "GNS1.00",
3899 "GQE1.00",
3900 "GQE1.00",
3901 "GRD1.00",
3902 "GRD1.00",
3903 "GTQ1.00",
3904 "GWE1.00",
3905 "GWE1.00",
3906 "GWP1.00",
3907 "GWP1.00",
3908 "GYD1.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",
3927 "Gold1.00",
3928 "Gold1.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",
3936 "Guinean Syli1.00",
3937 "Guinean franc1.00",
3938 "Guinean francs1.00",
3939 "Guinean syli1.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",
3947 "HK$1.00",
3948 "HKD1.00",
3949 "HNL1.00",
3950 "HRD1.00",
3951 "HRD1.00",
3952 "HRK1.00",
3953 "HRK1.00",
3954 "HTG1.00",
3955 "HTG1.00",
3956 "HUF1.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",
3969 "IDR1.00",
3970 "IEP1.00",
3971 "ILP1.00",
3972 "ILP1.00",
3973 "ILS1.00",
3974 "INR1.00",
3975 "IQD1.00",
3976 "IRR1.00",
729e4ab9
A
3977 "ISK1.00",
3978 "ISK1.00",
3979 "ITL1.00",
3980 "Icelandic Kr\\u00f3na1.00",
3981 "Icelandic kr\\u00f3na1.00",
3982 "Icelandic kr\\u00f3nur1.00",
3983 "Indian Rupee1.00",
3984 "Indian rupee1.00",
3985 "Indian rupees1.00",
3986 "Indonesian Rupiah1.00",
3987 "Indonesian rupiah1.00",
3988 "Indonesian rupiahs1.00",
3989 "Iranian Rial1.00",
3990 "Iranian rial1.00",
3991 "Iranian rials1.00",
3992 "Iraqi Dinar1.00",
3993 "Iraqi dinar1.00",
3994 "Iraqi dinars1.00",
3995 "Irish Pound1.00",
3996 "Irish pound1.00",
3997 "Irish pounds1.00",
3998 "Israeli Pound1.00",
3999 "Israeli new sheqel1.00",
4000 "Israeli pound1.00",
4001 "Israeli pounds1.00",
4002 "Italian Lira1.00",
4003 "Italian lira1.00",
4004 "Italian liras1.00",
729e4ab9
A
4005 "JMD1.00",
4006 "JOD1.00",
4007 "JPY1.00",
4008 "Jamaican Dollar1.00",
4009 "Jamaican dollar1.00",
4010 "Jamaican dollars1.00",
4011 "Japanese Yen1.00",
4012 "Japanese yen1.00",
4013 "Jordanian Dinar1.00",
4014 "Jordanian dinar1.00",
4015 "Jordanian dinars1.00",
729e4ab9
A
4016 "KES1.00",
4017 "KGS1.00",
4018 "KHR1.00",
4019 "KMF1.00",
4020 "KPW1.00",
4021 "KPW1.00",
4022 "KRW1.00",
4023 "KWD1.00",
4024 "KYD1.00",
4025 "KYD1.00",
4026 "KZT1.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",
729e4ab9
A
4039 "HNL1.00",
4040 "LAK1.00",
4041 "LAK1.00",
4042 "LBP1.00",
729e4ab9 4043 "LKR1.00",
729e4ab9
A
4044 "LRD1.00",
4045 "LRD1.00",
4046 "LSL1.00",
4047 "LTL1.00",
4048 "LTL1.00",
4049 "LTT1.00",
4050 "LTT1.00",
4051 "LUC1.00",
4052 "LUC1.00",
4053 "LUF1.00",
4054 "LUF1.00",
4055 "LUL1.00",
4056 "LUL1.00",
4057 "LVL1.00",
4058 "LVL1.00",
4059 "LVR1.00",
4060 "LVR1.00",
4061 "LYD1.00",
4062 "Laotian Kip1.00",
4063 "Laotian kip1.00",
4064 "Laotian kips1.00",
4065 "Latvian Lats1.00",
4066 "Latvian Ruble1.00",
4067 "Latvian lats1.00",
4068 "Latvian lati1.00",
4069 "Latvian ruble1.00",
4070 "Latvian rubles1.00",
4071 "Lebanese Pound1.00",
4072 "Lebanese pound1.00",
4073 "Lebanese pounds1.00",
4074 "Lesotho Loti1.00",
4075 "Lesotho loti1.00",
4076 "Lesotho lotis1.00",
4077 "Liberian Dollar1.00",
4078 "Liberian dollar1.00",
4079 "Liberian dollars1.00",
4080 "Libyan Dinar1.00",
4081 "Libyan dinar1.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",
729e4ab9
A
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",
4098 "MAD1.00",
4099 "MAD1.00",
4100 "MAF1.00",
4101 "MAF1.00",
4102 "MDL1.00",
4103 "MDL1.00",
4104 "MX$1.00",
4105 "MGA1.00",
4106 "MGA1.00",
4107 "MGF1.00",
4108 "MGF1.00",
4109 "MKD1.00",
4110 "MLF1.00",
4111 "MLF1.00",
4112 "MMK1.00",
4113 "MMK1.00",
4114 "MNT1.00",
4115 "MOP1.00",
4116 "MOP1.00",
4117 "MRO1.00",
4118 "MTL1.00",
4119 "MTP1.00",
4120 "MTP1.00",
729e4ab9
A
4121 "MUR1.00",
4122 "MUR1.00",
4123 "MVR1.00",
4124 "MVR1.00",
4125 "MWK1.00",
4126 "MXN1.00",
4127 "MXP1.00",
4128 "MXP1.00",
4129 "MXV1.00",
4130 "MXV1.00",
4131 "MYR1.00",
4132 "MZE1.00",
4133 "MZE1.00",
4134 "MZM1.00",
4135 "MZN1.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",
4157 "Malian Franc1.00",
4158 "Malian franc1.00",
4159 "Malian francs1.00",
4160 "Maltese Lira1.00",
4161 "Maltese Pound1.00",
4162 "Maltese lira1.00",
4163 "Maltese lira1.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",
4172 "Mexican Peso1.00",
4173 "Mexican Silver Peso (1861-1992)1.00",
4174 "Mexican Investment Unit1.00",
4175 "Mexican peso1.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",
4181 "Moldovan Leu1.00",
4182 "Moldovan leu1.00",
4183 "Moldovan lei1.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",
729e4ab9
A
4199 "Myanma Kyat1.00",
4200 "Myanma kyat1.00",
4201 "Myanma kyats1.00",
729e4ab9 4202 "NAD1.00",
729e4ab9
A
4203 "NGN1.00",
4204 "NIC1.00",
4205 "NIO1.00",
4206 "NIO1.00",
729e4ab9
A
4207 "NLG1.00",
4208 "NLG1.00",
4209 "NOK1.00",
4210 "NPR1.00",
4211 "NT$1.00",
4212 "NZ$1.00",
4213 "NZD1.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",
729e4ab9
A
4246 "OMR1.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",
4264 "Omani Rial1.00",
4265 "Omani rial1.00",
4266 "Omani rials1.00",
4267 "PAB1.00",
4268 "PAB1.00",
4269 "PEI1.00",
4270 "PEI1.00",
4271 "PEN1.00",
4272 "PEN1.00",
4273 "PES1.00",
4274 "PES1.00",
4275 "PGK1.00",
4276 "PGK1.00",
4277 "PHP1.00",
4278 "PKR1.00",
4279 "PLN1.00",
4280 "PLZ1.00",
4281 "PLZ1.00",
4282 "PTE1.00",
4283 "PTE1.00",
4284 "PYG1.00",
4285 "Pakistani Rupee1.00",
4286 "Pakistani rupee1.00",
4287 "Pakistani rupees1.00",
4288 "Palladium1.00",
4289 "Palladium1.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",
4311 "Platinum1.00",
4312 "Platinum1.00",
4313 "Polish Zloty (1950-1995)1.00",
4314 "Polish Zloty1.00",
4315 "Polish zlotys1.00",
4316 "Polish zloty (PLZ)1.00",
4317 "Polish zloty1.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",
729e4ab9
A
4325 "GTQ1.00",
4326 "QAR1.00",
729e4ab9
A
4327 "Qatari Rial1.00",
4328 "Qatari rial1.00",
4329 "Qatari rials1.00",
729e4ab9
A
4330 "RHD1.00",
4331 "RHD1.00",
4332 "RINET Funds1.00",
4333 "RINET Funds1.00",
729e4ab9
A
4334 "CN\\u00a51.00",
4335 "ROL1.00",
4336 "ROL1.00",
4337 "RON1.00",
4338 "RON1.00",
4339 "RSD1.00",
4340 "RSD1.00",
4341 "RUB1.00",
4342 "RUB1.00",
4343 "RUR1.00",
4344 "RUR1.00",
4345 "RWF1.00",
4346 "RWF1.00",
4347 "Rhodesian Dollar1.00",
4348 "Rhodesian dollar1.00",
4349 "Rhodesian dollars1.00",
4350 "Romanian Leu1.00",
4351 "Romanian lei1.00",
4352 "Romanian leu1.00",
729e4ab9
A
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",
729e4ab9
A
4362 "SAR1.00",
4363 "SBD1.00",
4364 "SCR1.00",
4365 "SDD1.00",
4366 "SDD1.00",
4367 "SDG1.00",
4368 "SDG1.00",
4369 "SDP1.00",
4370 "SDP1.00",
4371 "SEK1.00",
4372 "SGD1.00",
4373 "SHP1.00",
4374 "SHP1.00",
729e4ab9
A
4375 "SIT1.00",
4376 "SIT1.00",
4377 "SKK1.00",
729e4ab9
A
4378 "SLL1.00",
4379 "SLL1.00",
4380 "SOS1.00",
4381 "SRD1.00",
4382 "SRD1.00",
4383 "SRG1.00",
729e4ab9
A
4384 "STD1.00",
4385 "SUR1.00",
4386 "SUR1.00",
4387 "SVC1.00",
4388 "SVC1.00",
4389 "SYP1.00",
4390 "SZL1.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",
4397 "Saudi Riyal1.00",
4398 "Saudi riyal1.00",
4399 "Saudi riyals1.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",
729e4ab9
A
4406 "Sierra Leonean Leone1.00",
4407 "Sierra Leonean leone1.00",
4408 "Sierra Leonean leones1.00",
4409 "Silver1.00",
4410 "Silver1.00",
4411 "Singapore Dollar1.00",
4412 "Singapore dollar1.00",
4413 "Singapore dollars1.00",
729e4ab9
A
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",
4466 "Swiss Franc1.00",
4467 "Swiss franc1.00",
4468 "Swiss francs1.00",
4469 "Syrian Pound1.00",
4470 "Syrian pound1.00",
4471 "Syrian pounds1.00",
729e4ab9
A
4472 "THB1.00",
4473 "TJR1.00",
4474 "TJR1.00",
4475 "TJS1.00",
4476 "TJS1.00",
729e4ab9
A
4477 "TMM1.00",
4478 "TMM1.00",
4479 "TND1.00",
4480 "TND1.00",
4481 "TOP1.00",
4482 "TPE1.00",
4483 "TPE1.00",
4484 "TRL1.00",
4485 "TRY1.00",
4486 "TRY1.00",
729e4ab9
A
4487 "TTD1.00",
4488 "TWD1.00",
4489 "TZS1.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",
4504 "Thai Baht1.00",
4505 "Thai baht1.00",
4506 "Thai baht1.00",
4507 "Timorese Escudo1.00",
4508 "Timorese escudo1.00",
4509 "Timorese escudos1.00",
729e4ab9
A
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",
4519 "Turkish Lira1.00",
4520 "Turkish Lira1.00",
4521 "Turkish lira1.00",
4522 "Turkmenistani Manat1.00",
4523 "Turkmenistani manat1.00",
4524 "Turkmenistani manat1.00",
729e4ab9
A
4525 "UAE dirham1.00",
4526 "UAE dirhams1.00",
4527 "UAH1.00",
4528 "UAK1.00",
4529 "UAK1.00",
4530 "UGS1.00",
4531 "UGS1.00",
4532 "UGX1.00",
729e4ab9
A
4533 "US Dollar (Next day)1.00",
4534 "US Dollar (Same day)1.00",
4535 "US Dollar1.00",
4536 "US dollar (next day)1.00",
4537 "US dollar (same day)1.00",
4538 "US dollar1.00",
4539 "US dollars (next day)1.00",
4540 "US dollars (same day)1.00",
4541 "US dollars1.00",
4542 "USD1.00",
4543 "USN1.00",
4544 "USN1.00",
4545 "USS1.00",
4546 "USS1.00",
4547 "UYI1.00",
4548 "UYI1.00",
4549 "UYP1.00",
4550 "UYP1.00",
4551 "UYU1.00",
4552 "UZS1.00",
4553 "UZS1.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",
729e4ab9
A
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",
4581 "VEB1.00",
4582 "VEF1.00",
4583 "VND1.00",
729e4ab9
A
4584 "VUV1.00",
4585 "Vanuatu Vatu1.00",
4586 "Vanuatu vatu1.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",
4597 "WIR Euro1.00",
4598 "WIR Franc1.00",
4599 "WIR euro1.00",
4600 "WIR euros1.00",
4601 "WIR franc1.00",
4602 "WIR francs1.00",
4603 "WST1.00",
4604 "WST1.00",
4605 "Samoan Tala1.00",
4606 "Samoan tala1.00",
4607 "Samoan tala1.00",
4608 "XAF1.00",
4609 "XAF1.00",
4610 "XAG1.00",
4611 "XAG1.00",
4612 "XAU1.00",
4613 "XAU1.00",
4614 "XBA1.00",
4615 "XBA1.00",
4616 "XBB1.00",
4617 "XBB1.00",
4618 "XBC1.00",
4619 "XBC1.00",
4620 "XBD1.00",
4621 "XBD1.00",
4622 "XCD1.00",
4623 "XDR1.00",
4624 "XDR1.00",
4625 "XEU1.00",
4626 "XEU1.00",
4627 "XFO1.00",
4628 "XFO1.00",
4629 "XFU1.00",
4630 "XFU1.00",
4631 "XOF1.00",
4632 "XOF1.00",
4633 "XPD1.00",
4634 "XPD1.00",
4635 "XPF1.00",
4636 "XPT1.00",
4637 "XPT1.00",
4638 "XRE1.00",
4639 "XRE1.00",
4640 "XTS1.00",
4641 "XTS1.00",
4642 "XXX1.00",
4643 "XXX1.00",
4644 "YDD1.00",
4645 "YDD1.00",
4646 "YER1.00",
4647 "YUD1.00",
4648 "YUD1.00",
4649 "YUM1.00",
4650 "YUM1.00",
4651 "YUN1.00",
4652 "YUN1.00",
4653 "Yemeni Dinar1.00",
4654 "Yemeni Rial1.00",
4655 "Yemeni dinar1.00",
4656 "Yemeni dinars1.00",
4657 "Yemeni rial1.00",
4658 "Yemeni rials1.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",
729e4ab9
A
4668 "ZAL1.00",
4669 "ZAL1.00",
4670 "ZAR1.00",
4671 "ZMK1.00",
4672 "ZMK1.00",
4673 "ZRN1.00",
4674 "ZRN1.00",
4675 "ZRZ1.00",
4676 "ZRZ1.00",
4677 "ZWD1.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",
4690 "euro1.00",
4691 "euros1.00",
729e4ab9
A
4692 "Turkish lira (1922-2005)1.00",
4693 "special drawing rights1.00",
4694 "Colombian real value unit1.00",
4695 "Colombian real value units1.00",
4388f060 4696 "unknown currency1.00",
729e4ab9 4697 "\\u00a31.00",
729e4ab9
A
4698 "\\u00a51.00",
4699 "\\u0e3f1.00",
4700 "\\u20ab1.00",
729e4ab9
A
4701 "\\u20aa1.00",
4702 "\\u20ac1.00",
4703 "\\u20b91.00",
729e4ab9
A
4704 //
4705 // Following has extra text, should be parsed correctly too
4706 "$1.00 random",
4707 "USD1.00 random",
4708 "1.00 US dollar random",
4709 "1.00 US dollars random",
4710 "1.00 Afghan Afghani random",
4711 "1.00 Afghan Afghani random",
4388f060 4712 "1.00 Afghan Afghanis (1927-1992) random",
729e4ab9
A
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",
4993 "1.00 Gold random",
4994 "1.00 Gold 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",
5478 "1.00 euro 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",
4388f060 5484 "1.00 unknown currency random",
729e4ab9
A
5485 };
5486
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",
5509 "1.00 US dolla",
5510 "1.00",
5511 "A1.00",
5512 "AD1.00",
5513 "AE1.00",
5514 "AF1.00",
5515 "AL1.00",
5516 "AM1.00",
5517 "AN1.00",
5518 "AO1.00",
5519 "AR1.00",
5520 "AT1.00",
5521 "AU1.00",
5522 "AW1.00",
5523 "AZ1.00",
5524 "Afghan Afghan1.00",
5525 "Afghan Afghani (1927-20021.00",
5526 "Afl1.00",
5527 "Albanian Le1.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",
5537 "Armenian Dra1.00",
5538 "Aruban Flori1.00",
5539 "Australian Dolla1.00",
5540 "Austrian Schillin1.00",
5541 "Azerbaijani Mana1.00",
5542 "Azerbaijani Manat (1993-20061.00",
5543 "B1.00",
5544 "BA1.00",
5545 "BB1.00",
5546 "BE1.00",
5547 "BG1.00",
5548 "BH1.00",
5549 "BI1.00",
5550 "BM1.00",
5551 "BN1.00",
5552 "BO1.00",
5553 "BR1.00",
5554 "BS1.00",
5555 "BT1.00",
5556 "BU1.00",
5557 "BW1.00",
5558 "BY1.00",
5559 "BZ1.00",
5560 "Bahamian Dolla1.00",
5561 "Bahraini Dina1.00",
5562 "Bangladeshi Tak1.00",
5563 "Barbadian Dolla1.00",
5564 "Bds1.00",
5565 "Belarusian New Ruble (1994-19991.00",
5566 "Belarusian Rubl1.00",
5567 "Belgian Fran1.00",
5568 "Belgian Franc (convertible1.00",
5569 "Belgian Franc (financial1.00",
5570 "Belize Dolla1.00",
5571 "Bermudan Dolla1.00",
5572 "Bhutanese Ngultru1.00",
5573 "Bolivian Mvdo1.00",
5574 "Bolivian Pes1.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",
5586 "Brunei Dolla1.00",
5587 "Bulgarian Hard Le1.00",
5588 "Bulgarian Le1.00",
5589 "Burmese Kya1.00",
5590 "Burundian Fran1.00",
5591 "C1.00",
5592 "CA1.00",
5593 "CD1.00",
5594 "CFA Franc BCEA1.00",
5595 "CFA Franc BEA1.00",
5596 "CFP Fran1.00",
5597 "CFP1.00",
5598 "CH1.00",
5599 "CL1.00",
5600 "CN1.00",
5601 "CO1.00",
5602 "CS1.00",
5603 "CU1.00",
5604 "CV1.00",
5605 "CY1.00",
5606 "CZ1.00",
5607 "Cambodian Rie1.00",
5608 "Canadian Dolla1.00",
5609 "Cape Verdean Escud1.00",
5610 "Cayman Islands Dolla1.00",
5611 "Chilean Pes1.00",
5612 "Chilean Unit of Accoun1.00",
5613 "Chinese Yua1.00",
5614 "Colombian Pes1.00",
5615 "Comoro Fran1.00",
5616 "Congolese Fran1.00",
5617 "Costa Rican Col\\u00f31.00",
5618 "Croatian Dina1.00",
5619 "Croatian Kun1.00",
5620 "Cuban Pes1.00",
5621 "Cypriot Poun1.00",
5622 "Czech Republic Korun1.00",
5623 "Czechoslovak Hard Korun1.00",
5624 "D1.00",
5625 "DD1.00",
5626 "DE1.00",
5627 "DJ1.00",
5628 "DK1.00",
5629 "DO1.00",
5630 "DZ1.00",
5631 "Danish Kron1.00",
5632 "German Mar1.00",
5633 "Djiboutian Fran1.00",
5634 "Dk1.00",
5635 "Dominican Pes1.00",
5636 "EC1.00",
5637 "EE1.00",
5638 "EG1.00",
5639 "EQ1.00",
5640 "ER1.00",
5641 "ES1.00",
5642 "ET1.00",
5643 "EU1.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",
5649 "Ekwel1.00",
5650 "Salvadoran Col\\u00f31.00",
5651 "Equatorial Guinean Ekwel1.00",
5652 "Eritrean Nakf1.00",
5653 "Es1.00",
5654 "Estonian Kroo1.00",
5655 "Ethiopian Bir1.00",
5656 "Eur1.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",
5662 "F1.00",
5663 "FB1.00",
5664 "FI1.00",
5665 "FJ1.00",
5666 "FK1.00",
5667 "FR1.00",
5668 "Falkland Islands Poun1.00",
5669 "Fd1.00",
5670 "Fijian Dolla1.00",
5671 "Finnish Markk1.00",
5672 "Fr1.00",
5673 "French Fran1.00",
5674 "French Gold Fran1.00",
5675 "French UIC-Fran1.00",
5676 "G1.00",
5677 "GB1.00",
5678 "GE1.00",
5679 "GH1.00",
5680 "GI1.00",
5681 "GM1.00",
5682 "GN1.00",
5683 "GQ1.00",
5684 "GR1.00",
5685 "GT1.00",
5686 "GW1.00",
5687 "GY1.00",
5688 "Gambian Dalas1.00",
5689 "Georgian Kupon Lari1.00",
5690 "Georgian Lar1.00",
5691 "Ghanaian Ced1.00",
5692 "Ghanaian Cedi (1979-20071.00",
5693 "Gibraltar Poun1.00",
5694 "Gol1.00",
5695 "Greek Drachm1.00",
5696 "Guatemalan Quetza1.00",
5697 "Guinean Fran1.00",
5698 "Guinean Syl1.00",
5699 "Guinea-Bissau Pes1.00",
5700 "Guyanaese Dolla1.00",
5701 "HK1.00",
5702 "HN1.00",
5703 "HR1.00",
5704 "HT1.00",
5705 "HU1.00",
5706 "Haitian Gourd1.00",
5707 "Honduran Lempir1.00",
5708 "Hong Kong Dolla1.00",
5709 "Hungarian Forin1.00",
5710 "I1.00",
5711 "IE1.00",
5712 "IL1.00",
5713 "IN1.00",
5714 "IQ1.00",
5715 "IR1.00",
5716 "IS1.00",
5717 "IT1.00",
5718 "Icelandic Kron1.00",
5719 "Indian Rupe1.00",
5720 "Indonesian Rupia1.00",
5721 "Iranian Ria1.00",
5722 "Iraqi Dina1.00",
5723 "Irish Poun1.00",
5724 "Israeli Poun1.00",
5725 "Italian Lir1.00",
5726 "J1.00",
5727 "JM1.00",
5728 "JO1.00",
5729 "JP1.00",
5730 "Jamaican Dolla1.00",
5731 "Japanese Ye1.00",
5732 "Jordanian Dina1.00",
5733 "K S1.00",
5734 "K1.00",
5735 "KE1.00",
5736 "KG1.00",
5737 "KH1.00",
5738 "KP1.00",
5739 "KR1.00",
5740 "KW1.00",
5741 "KY1.00",
5742 "KZ1.00",
5743 "Kazakhstani Teng1.00",
5744 "Kenyan Shillin1.00",
5745 "Kuwaiti Dina1.00",
5746 "Kyrgystani So1.00",
5747 "LA1.00",
5748 "LB1.00",
5749 "LK1.00",
5750 "LR1.00",
5751 "LT1.00",
5752 "LU1.00",
5753 "LV1.00",
5754 "LY1.00",
5755 "Laotian Ki1.00",
5756 "Latvian Lat1.00",
5757 "Latvian Rubl1.00",
5758 "Lebanese Poun1.00",
5759 "Lesotho Lot1.00",
5760 "Liberian Dolla1.00",
5761 "Libyan Dina1.00",
5762 "Lithuanian Lit1.00",
5763 "Lithuanian Talona1.00",
5764 "Luxembourgian Convertible Fran1.00",
5765 "Luxembourg Financial Fran1.00",
5766 "Luxembourgian Fran1.00",
5767 "MA1.00",
5768 "MD1.00",
5769 "MDe1.00",
5770 "MEX1.00",
5771 "MG1.00",
5772 "ML1.00",
5773 "MM1.00",
5774 "MN1.00",
5775 "MO1.00",
5776 "MR1.00",
5777 "MT1.00",
5778 "MU1.00",
5779 "MV1.00",
5780 "MW1.00",
5781 "MX1.00",
5782 "MY1.00",
5783 "MZ1.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",
5791 "Malian Fran1.00",
5792 "Malot1.00",
5793 "Maltese Lir1.00",
5794 "Maltese Poun1.00",
5795 "Mauritanian Ouguiy1.00",
5796 "Mauritian Rupe1.00",
5797 "Mexican Pes1.00",
5798 "Mexican Silver Peso (1861-19921.00",
5799 "Mexican Investment Uni1.00",
5800 "Moldovan Le1.00",
5801 "Mongolian Tugri1.00",
5802 "Moroccan Dirha1.00",
5803 "Moroccan Fran1.00",
5804 "Mozambican Escud1.00",
5805 "Mozambican Metica1.00",
5806 "Myanma Kya1.00",
5807 "N1.00",
5808 "NA1.00",
5809 "NAf1.00",
5810 "NG1.00",
5811 "NI1.00",
5812 "NK1.00",
5813 "NL1.00",
5814 "NO1.00",
5815 "NP1.00",
5816 "NT1.00",
5817 "Namibian Dolla1.00",
5818 "Nepalese Rupe1.00",
5819 "Netherlands Antillean Guilde1.00",
5820 "Dutch 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",
5828 "Nr1.00",
5829 "OM1.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",
5836 "Omani Ria1.00",
5837 "PA1.00",
5838 "PE1.00",
5839 "PG1.00",
5840 "PH1.00",
5841 "PK1.00",
5842 "PL1.00",
5843 "PT1.00",
5844 "PY1.00",
5845 "Pakistani Rupe1.00",
5846 "Palladiu1.00",
5847 "Panamanian Balbo1.00",
5848 "Papua New Guinean Kin1.00",
5849 "Paraguayan Guaran1.00",
5850 "Peruvian Int1.00",
5851 "Peruvian Sol (1863-19651.00",
5852 "Peruvian Sol Nuev1.00",
5853 "Philippine Pes1.00",
5854 "Platinu1.00",
5855 "Polish Zlot1.00",
5856 "Polish Zloty (1950-19951.00",
5857 "Portuguese Escud1.00",
5858 "Portuguese Guinea Escud1.00",
5859 "Pr1.00",
5860 "QA1.00",
5861 "Qatari Ria1.00",
5862 "RD1.00",
5863 "RH1.00",
5864 "RINET Fund1.00",
5865 "RS1.00",
5866 "RU1.00",
5867 "RW1.00",
5868 "Rb1.00",
5869 "Rhodesian Dolla1.00",
5870 "Romanian Le1.00",
5871 "Russian Rubl1.00",
5872 "Russian Ruble (1991-19981.00",
5873 "Rwandan Fran1.00",
5874 "S1.00",
5875 "SA1.00",
5876 "SB1.00",
5877 "SC1.00",
5878 "SD1.00",
5879 "SE1.00",
5880 "SG1.00",
5881 "SH1.00",
5882 "SI1.00",
5883 "SK1.00",
5884 "SL R1.00",
5885 "SL1.00",
5886 "SO1.00",
5887 "ST1.00",
5888 "SU1.00",
5889 "SV1.00",
5890 "SY1.00",
5891 "SZ1.00",
5892 "Saint Helena Poun1.00",
5893 "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobr1.00",
5894 "Saudi Riya1.00",
5895 "Serbian Dina1.00",
5896 "Seychellois Rupe1.00",
5897 "Sh1.00",
5898 "Sierra Leonean Leon1.00",
5899 "Silve1.00",
5900 "Singapore Dolla1.00",
5901 "Slovak Korun1.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",
5908 "Soviet Roubl1.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",
5918 "Swedish Kron1.00",
5919 "Swiss Fran1.00",
5920 "Syrian Poun1.00",
5921 "T S1.00",
5922 "TH1.00",
5923 "TJ1.00",
5924 "TM1.00",
5925 "TN1.00",
5926 "TO1.00",
5927 "TP1.00",
5928 "TR1.00",
5929 "TT1.00",
5930 "TW1.00",
5931 "TZ1.00",
5932 "New Taiwan Dolla1.00",
5933 "Tajikistani Rubl1.00",
5934 "Tajikistani Somon1.00",
5935 "Tanzanian Shillin1.00",
5936 "Testing Currency Cod1.00",
5937 "Thai Bah1.00",
5938 "Timorese Escud1.00",
5939 "Tongan Pa\\u20bbang1.00",
5940 "Trinidad and Tobago Dolla1.00",
5941 "Tunisian Dina1.00",
5942 "Turkish Lir1.00",
5943 "Turkmenistani Mana1.00",
5944 "U S1.00",
5945 "U1.00",
5946 "UA1.00",
5947 "UG1.00",
5948 "US Dolla1.00",
5949 "US Dollar (Next day1.00",
5950 "US Dollar (Same day1.00",
5951 "US1.00",
5952 "UY1.00",
5953 "UZ1.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",
5961 "Ur1.00",
5962 "Uruguay Peso (1975-19931.00",
5963 "Uruguay Peso Uruguay1.00",
5964 "Uruguay Peso (Indexed Units1.00",
5965 "Uzbekistan So1.00",
5966 "V1.00",
5967 "VE1.00",
5968 "VN1.00",
5969 "VU1.00",
5970 "Vanuatu Vat1.00",
5971 "Venezuelan Bol\\u00edva1.00",
5972 "Venezuelan Bol\\u00edvar Fuert1.00",
5973 "Vietnamese Don1.00",
5974 "WIR Eur1.00",
5975 "WIR Fran1.00",
5976 "WS1.00",
5977 "Samoa Tal1.00",
5978 "XA1.00",
5979 "XB1.00",
5980 "XC1.00",
5981 "XD1.00",
5982 "XE1.00",
5983 "XF1.00",
5984 "XO1.00",
5985 "XP1.00",
5986 "XR1.00",
5987 "XT1.00",
5988 "XX1.00",
5989 "YD1.00",
5990 "YE1.00",
5991 "YU1.00",
5992 "Yemeni Dina1.00",
5993 "Yemeni Ria1.00",
5994 "Yugoslavian Convertible Dina1.00",
5995 "Yugoslavian Hard Dinar (1966-19901.00",
5996 "Yugoslavian New Dina1.00",
5997 "Z1.00",
5998 "ZA1.00",
5999 "ZM1.00",
6000 "ZR1.00",
6001 "ZW1.00",
6002 "Zairean New Zaire (1993-19981.00",
6003 "Zairean Zair1.00",
6004 "Zambian Kwach1.00",
6005 "Zimbabwean Dollar (1980-20081.00",
6006 "dra1.00",
6007 "lar1.00",
6008 "le1.00",
6009 "man1.00",
6010 "so1.00",
6011 };
6012
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;
4388f060 6017 NumberFormat* numFmt = NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
729e4ab9 6018 if (numFmt != NULL && U_SUCCESS(status)) {
4388f060
A
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);
6025 }
6026 } else {
6027 errln("Failed to parse as currency: " + formatted);
729e4ab9
A
6028 }
6029 } else {
6030 dataerrln("Unable to create NumberFormat. - %s", u_errorName(status));
6031 delete numFmt;
6032 break;
6033 }
6034 delete numFmt;
6035 }
6036
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;
4388f060 6040 NumberFormat* numFmt = NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
729e4ab9 6041 if (numFmt != NULL && U_SUCCESS(status)) {
4388f060
A
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);
729e4ab9
A
6047 }
6048 } else {
6049 dataerrln("Unable to create NumberFormat. - %s", u_errorName(status));
6050 delete numFmt;
6051 break;
6052 }
6053 delete numFmt;
6054 }
6055}
6056
6057const char* attrString(int32_t);
6058
6059// UnicodeString s;
6060// std::string ss;
6061// std::cout << s.toUTF8String(ss)
6062void NumberFormatTest::expectPositions(FieldPositionIterator& iter, int32_t *values, int32_t tupleCount,
6063 const UnicodeString& str) {
6064 UBool found[10];
6065 FieldPosition fp;
6066
6067 if (tupleCount > 10) {
6068 assertTrue("internal error, tupleCount too large", FALSE);
6069 } else {
6070 for (int i = 0; i < tupleCount; ++i) {
6071 found[i] = FALSE;
6072 }
6073 }
6074
6075 logln(str);
6076 while (iter.next(fp)) {
6077 UBool ok = FALSE;
6078 int32_t id = fp.getField();
6079 int32_t start = fp.getBeginIndex();
6080 int32_t limit = fp.getEndIndex();
6081
6082 // is there a logln using printf?
6083 char buf[128];
6084 sprintf(buf, "%24s %3d %3d %3d", attrString(id), id, start, limit);
6085 logln(buf);
6086
6087 for (int i = 0; i < tupleCount; ++i) {
6088 if (found[i]) {
6089 continue;
6090 }
6091 if (values[i*3] == id &&
6092 values[i*3+1] == start &&
6093 values[i*3+2] == limit) {
6094 found[i] = ok = TRUE;
6095 break;
6096 }
6097 }
6098
6099 assertTrue((UnicodeString)"found [" + id + "," + start + "," + limit + "]", ok);
6100 }
6101
6102 // check that all were found
6103 UBool ok = TRUE;
6104 for (int i = 0; i < tupleCount; ++i) {
6105 if (!found[i]) {
6106 ok = FALSE;
6107 assertTrue((UnicodeString) "missing [" + values[i*3] + "," + values[i*3+1] + "," + values[i*3+2] + "]", found[i]);
6108 }
6109 }
6110 assertTrue("no expected values were missing", ok);
6111}
6112
6113void NumberFormatTest::expectPosition(FieldPosition& pos, int32_t id, int32_t start, int32_t limit,
6114 const UnicodeString& str) {
6115 logln(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());
6119}
6120
6121void NumberFormatTest::TestFieldPositionIterator() {
6122 // bug 7372
6123 UErrorCode status = U_ZERO_ERROR;
6124 FieldPositionIterator iter1;
6125 FieldPositionIterator iter2;
6126 FieldPosition pos;
6127
6128 DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(status);
6129 if (failure(status, "NumberFormat::createInstance", TRUE)) return;
6130
6131 double num = 1234.56;
6132 UnicodeString str1;
6133 UnicodeString str2;
6134
6135 assertTrue((UnicodeString)"self==", iter1 == iter1);
6136 assertTrue((UnicodeString)"iter1==iter2", iter1 == iter2);
6137
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);
6142 iter1.next(pos);
6143 assertTrue((UnicodeString)"iter1 != iter2 (2)", iter1 != iter2);
6144 iter2.next(pos);
6145 assertTrue((UnicodeString)"iter1 == iter2 (3)", iter1 == iter2);
6146
6147 // should format ok with no iterator
6148 str2.remove();
6149 decFmt->format(num, str2, NULL, status);
6150 assertEquals("null fpiter", str1, str2);
6151
6152 delete decFmt;
6153}
6154
6155void NumberFormatTest::TestFormatAttributes() {
6156 Locale locale("en_US");
6157 UErrorCode status = U_ZERO_ERROR;
4388f060 6158 DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, UNUM_CURRENCY, status);
729e4ab9
A
6159 if (failure(status, "NumberFormat::createInstance", TRUE)) return;
6160 double val = 12345.67;
6161
6162 {
6163 int32_t expected[] = {
4388f060
A
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,
729e4ab9
A
6169 };
6170 int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
6171
6172 FieldPositionIterator posIter;
6173 UnicodeString result;
6174 decFmt->format(val, result, &posIter, status);
6175 expectPositions(posIter, expected, tupleCount, result);
6176 }
6177 {
4388f060 6178 FieldPosition fp(UNUM_INTEGER_FIELD);
729e4ab9
A
6179 UnicodeString result;
6180 decFmt->format(val, result, fp);
4388f060 6181 expectPosition(fp, UNUM_INTEGER_FIELD, 1, 7, result);
729e4ab9
A
6182 }
6183 {
4388f060 6184 FieldPosition fp(UNUM_FRACTION_FIELD);
729e4ab9
A
6185 UnicodeString result;
6186 decFmt->format(val, result, fp);
4388f060 6187 expectPosition(fp, UNUM_FRACTION_FIELD, 8, 10, result);
729e4ab9
A
6188 }
6189 delete decFmt;
6190
4388f060 6191 decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, UNUM_SCIENTIFIC, status);
729e4ab9
A
6192 val = -0.0000123;
6193 {
6194 int32_t expected[] = {
4388f060
A
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
729e4ab9
A
6202 };
6203 int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected));
6204
6205 FieldPositionIterator posIter;
6206 UnicodeString result;
6207 decFmt->format(val, result, &posIter, status);
6208 expectPositions(posIter, expected, tupleCount, result);
6209 }
6210 {
4388f060 6211 FieldPosition fp(UNUM_INTEGER_FIELD);
729e4ab9
A
6212 UnicodeString result;
6213 decFmt->format(val, result, fp);
4388f060 6214 expectPosition(fp, UNUM_INTEGER_FIELD, 1, 2, result);
729e4ab9
A
6215 }
6216 {
4388f060 6217 FieldPosition fp(UNUM_FRACTION_FIELD);
729e4ab9
A
6218 UnicodeString result;
6219 decFmt->format(val, result, fp);
4388f060 6220 expectPosition(fp, UNUM_FRACTION_FIELD, 3, 5, result);
729e4ab9
A
6221 }
6222 delete decFmt;
6223
6224 fflush(stderr);
6225}
6226
6227const char* attrString(int32_t attrId) {
6228 switch (attrId) {
4388f060
A
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";
729e4ab9
A
6240 default: return "";
6241 }
6242}
6243
6244//
6245// Test formatting & parsing of big decimals.
6246// API test, not a comprehensive test.
6247// See DecimalFormatTest/DataDrivenTests
6248//
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);}
6253
6254static UBool operator != (const char *s1, UnicodeString &s2) {
6255 // This function lets ASSERT_EQUALS("literal", UnicodeString) work.
6256 UnicodeString us1(s1);
6257 return us1 != s2;
6258}
6259
6260void NumberFormatTest::TestDecimal() {
6261 {
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());
6269 }
6270
6271 {
6272 UErrorCode status = U_ZERO_ERROR;
6273 Formattable f1("this is not a number", status);
6274 ASSERT_EQUALS(U_DECIMAL_NUMBER_SYNTAX_ERROR, status);
6275 }
6276
6277 {
6278 UErrorCode status = U_ZERO_ERROR;
6279 Formattable f;
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);
6288
6289 f.setDecimalNumber("4.5678E7", status);
6290 int32_t n;
6291 n = f.getLong();
6292 ASSERT_EQUALS(45678000, n);
6293
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);
6303
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);
6313 }
6314
6315 {
6316 UErrorCode status = U_ZERO_ERROR;
4388f060 6317 NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
729e4ab9
A
6318 if (U_FAILURE(status) || fmtr == NULL) {
6319 dataerrln("Unable to create NumberFormat");
6320 } else {
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);
6327 delete fmtr;
6328 }
6329 }
6330
6331 {
6332 // Check formatting a DigitList. DigitList is internal, but this is
6333 // a critical interface that must work.
6334 UErrorCode status = U_ZERO_ERROR;
4388f060 6335 NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
729e4ab9
A
6336 if (U_FAILURE(status) || fmtr == NULL) {
6337 dataerrln("Unable to create NumberFormat");
6338 } else {
6339 UnicodeString formattedResult;
6340 DigitList dl;
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);
6347
6348 status = U_ZERO_ERROR;
6349 num.set("666.666");
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());
6359 delete fmtr;
6360 }
6361 }
6362
6363 {
6364 // Check a parse with a formatter with a multiplier.
6365 UErrorCode status = U_ZERO_ERROR;
4388f060 6366 NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_PERCENT, status);
729e4ab9
A
6367 if (U_FAILURE(status) || fmtr == NULL) {
6368 dataerrln("Unable to create NumberFormat");
6369 } else {
6370 UnicodeString input = "1.84%";
6371 Formattable result;
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();
6376 delete fmtr;
6377 }
6378 }
6379
6380 {
6381 // Check that a parse returns a decimal number with full accuracy
6382 UErrorCode status = U_ZERO_ERROR;
4388f060 6383 NumberFormat *fmtr = NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, status);
729e4ab9
A
6384 if (U_FAILURE(status) || fmtr == NULL) {
6385 dataerrln("Unable to create NumberFormat");
6386 } else {
6387 UnicodeString input = "1.002200044400088880000070000";
6388 Formattable result;
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();
6394 delete fmtr;
6395 }
6396 }
6397
6398}
6399
6400void NumberFormatTest::TestCurrencyFractionDigits() {
6401 UErrorCode status = U_ZERO_ERROR;
6402 UnicodeString text1, text2;
6403 double value = 99.12345;
6404
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");
6409 } else {
6410 fmt->format(value, text1);
6411
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);
6416
6417 if (text1 != text2) {
6418 errln((UnicodeString)"NumberFormat::format() should return the same result - text1="
6419 + text1 + " text2=" + text2);
6420 }
6421 delete fmt;
6422 }
6423}
6424
6425void NumberFormatTest::TestExponentParse() {
6426
6427 UErrorCode status = U_ZERO_ERROR;
6428 Formattable result;
6429 ParsePosition parsePos(0);
6430
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)");
6436 return;
6437 }
6438
729e4ab9
A
6439 // create format instance
6440 status = U_ZERO_ERROR;
6441 DecimalFormat fmt("#####", symbols, status);
4388f060 6442 if(U_FAILURE(status)) {
729e4ab9
A
6443 errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
6444 }
6445
6446 // parse the text
6447 fmt.parse("5.06e-27", result, parsePos);
6448 if(result.getType() != Formattable::kDouble &&
6449 result.getDouble() != 5.06E-27 &&
6450 parsePos.getIndex() != 8
6451 )
6452 {
6453 errln("ERROR: parse failed - expected 5.06E-27, 8 - returned %d, %i",
6454 result.getDouble(), parsePos.getIndex());
6455 }
729e4ab9
A
6456}
6457
4388f060
A
6458void NumberFormatTest::TestExplicitParents() {
6459
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" },
6471 };
6472
6473 UnicodeString s;
6474
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();
6480 char loc[256]={0};
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));
6485 continue;
6486 }
6487 s.remove();
6488 fmt->format(1250.75, s);
6489 if(s!=expected){
6490 errln(UnicodeString("FAIL: Expected: ")+expected
6491 + UnicodeString(" Got: ") + s
6492 + UnicodeString( " for locale: ")+ UnicodeString(localeID) );
6493 }
6494 if (U_FAILURE(status)){
6495 errln((UnicodeString)"FAIL: Status " + (int32_t)status);
6496 }
6497 delete fmt;
6498 }
6499
6500}
6501
6502/**
6503 * Test available numbering systems API.
6504 */
6505void NumberFormatTest::TestAvailableNumberingSystems() {
6506 UErrorCode status = U_ZERO_ERROR;
6507 StringEnumeration *availableNumberingSystems = NumberingSystem::getAvailableNames(status);
6508 CHECK_DATA(status, "NumberingSystem::getAvailableNames()")
6509
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);
6513 }
6514
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. */
6519
6520 int32_t len;
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);
6526 }
6527
6528 delete ns;
6529 }
6530
6531 delete availableNumberingSystems;
6532}
6533
6534void
6535NumberFormatTest::Test9087(void)
6536{
6537 U_STRING_DECL(pattern,"#",1);
6538 U_STRING_INIT(pattern,"#",1);
6539
6540 U_STRING_DECL(infstr,"INF",3);
6541 U_STRING_INIT(infstr,"INF",3);
6542
6543 U_STRING_DECL(nanstr,"NAN",3);
6544 U_STRING_INIT(nanstr,"NAN",3);
6545
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));
6551 return;
6552 }
6553
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");
6558 }
6559
6560 double inf = uprv_getInfinity();
6561
6562 unum_setAttribute(fmt,UNUM_ROUNDING_MODE,UNUM_ROUND_HALFEVEN);
6563 unum_setDoubleAttribute(fmt,UNUM_ROUNDING_INCREMENT,0);
6564
6565 UFieldPosition position = { 0, 0, 0};
6566 unum_formatDouble(fmt,inf,outputbuf,50,&position,&status);
6567
6568 if ( u_strcmp(infstr, outputbuf)) {
6569 errln((UnicodeString)"FAIL: unexpected result for infinity - expected " + infstr + " got " + outputbuf);
6570 }
6571
6572 unum_close(fmt);
6573}
b75a7d8f 6574#endif /* #if !UCONFIG_NO_FORMATTING */