]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/testdata/numberformattestspecification.txt
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / test / testdata / numberformattestspecification.txt
CommitLineData
0f5d89e8 1// Copyright (C) 2016 and later: Unicode, Inc. and others.
f3c0d7a5
A
2// License & terms of use: http://www.unicode.org/copyright.html
3// Copyright (C) 2015-2016, International Business Machines
2ca993e8
A
4// Corporation and others. All Rights Reserved.
5//
6// This file is divided into test suites separated by whitespace. Each test
7// suite starts with the name of the test followed by global field settings
8// for that test suite. After the global settings, comes "begin", the
9// per-test field names, and finally the test specific field values, 1 test
10// per line.
0f5d89e8 11//
3d1f044b 12// Field names:
0f5d89e8
A
13// H = ICU4J 58 (archive)
14// J = ICU4J (current)
15// K = JDK (ignored if not OpenJDK 1.8)
16// C = ICU4C (current)
17// P = Properties-based ICU4J (bypasses DecimalFormat wrapper)
0f5d89e8 18//
2ca993e8
A
19// For more information on the format of this file, including all the available
20// field names, please see
21// https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
22
23test plus sign
0f5d89e8 24set locale ar-EG
2ca993e8
A
25set pattern +0;-#
26begin
27format output breaks
0f5d89e8
A
286 \u061C+\u0666 HK
29-6 \u061C-\u0666 K
2ca993e8
A
30
31test basic patterns
32set locale fr_FR
33set format 1234.567
34begin
3d1f044b
A
35pattern output breaks
36// K does not use \u202f narrow space
37#,##0.## 1\u202f234,57 K
2ca993e8
A
380.## 1234,57
390 1235
3d1f044b 40#,##0.### 1\u202f234,567 K
2ca993e8
A
41###0.###### 1234,567
42###0.0000# 1234,5670
4300000.0000 01234,5670
3d1f044b 44#,##0.00 \u00a4 1\u202f234,57 \u20ac K
2ca993e8
A
45'tick''bitten '0.00 tick'bitten 1234,57
46'tick' 'bitten '0.00 tick bitten 1234,57
47
48
49test minimum and maximum fraction digits
50set locale en
51set minIntegerDigits 2
52set maxIntegerDigits 4
53set minFractionDigits 3
54set maxFractionDigits 5
55begin
56format output
576 06.000
586.000005 06.000
596.000006 06.00001
601002003004005 4005.000
61-1002003004005 -4005.000
6212 12.000
6312345 2345.000
6472.1234 72.1234
65
0f5d89e8
A
66test patterns with no '0' symbols
67set locale en_US
68begin
69pattern format output breaks
70# 514.23 514
71# 0.23 0
72# 0 0
73# 1 1
74##.# 514.23 514.2
75##.# 0.23 0.2
76##.# 0 0
77##.# 1 1
78#.# 514.23 514.2
79#.# 0.23 0.2
80#.# 0 0
81#.# 1 1
82.# 514.23 514.2
83.# 0.23 .2
84.# 0 .0
85.# 1 1.0
86#. 514.23 514.
87#. 0.23 0.
88#. 0 0.
89#. 1 1.
90. 514.23 514.
91. 0.23 0.
92. 0 0.
93. 1 1.
94
95test behavior on numbers approaching zero
96set locale en
97begin
98pattern format output breaks
99#.## 0.01 0.01
100#.## 0.001 0
101#.## 0 0
102#.00 0.01 .01
103#.00 0.001 .00
104#.00 0 .00
1050.00 0.01 0.01
1060.00 0.001 0.00
1070.00 0 0.00
108
109// Not in official spec, but needed for backwards compatibility
110test patterns with leading grouping separator
111set locale en_US
112begin
113pattern format output breaks
114,##0 1234.56 1,235
115'#',## 3456 #34,56
116
117test patterns with valid and invalid quote marks
118set locale et
119begin
120pattern format output breaks
121'# 1 fail
122''# 1 '1
123'''# 1 fail
124''''# 1 ''1
125'''''# 1 fail
126'-''-'# 1 -'-1
127// K doesn't know the locale symbol for et
128-'-'# 1 −-1 K
129'#'# 1 #1
130''#'' 1 '1'
131''#- 1 '1− K
132'-'#- 1 -1− K
133-#'-' 1 −1- K
134
2ca993e8
A
135test int64
136set locale en
137begin
138format output
1391002003004005 1002003004005
140-1002003004005 -1002003004005
141
142test rounding
143set locale fr
144begin
145pattern format output breaks
1460.5 1.25 1,0 K
1470.5 1.75 2,0 K
1480.5 -1.25 -1,0 K
14900.5 -1.75 -02,0 K
1504 2.0 0 K
1514 6.0 8 K
1524 10.0 8 K
1532.70 99.0 99,90 K
1542.73 272.0 273,00 K
3d1f044b 155#,#3.70 104.0 1\u202f03,60 K
2ca993e8
A
156
157test significant digits
158set locale en
159set pattern #,#@,@###
160begin
161format output breaks
1627 7.0 K
16323 23 K
164100 100 K
1651000 1000 K
16610000 1,0000 K
16710001 1,0001 K
16810001.5 1,0002 K
1691234567 1,23,4600 K
170-1234567 -1,23,4600 K
1713.14159 3.1416 K
172
173test scientific notation
174set locale fr
175begin
176pattern format output breaks
1770.00E0 12345 1,23E4
178000.00E0 12300 123,00E2
179000.0#E0 12300 123,0E2
180000.0#E0 12300.1 123,0E2
181000.0#E0 12301.0 123,01E2
182// JDK does not support exponent signs
183000.0#E+00 12301.0 123,01E+02 K
184// JDK gives 12,345E3. JDK seems to include the hashes in significant digits
185##0.00E0 12345 12,3E3 K
186// JDK gives 12,3001E3
187##0.0000E0 12300.1 12,300E3 K
188// JDK gives 12,3001E3
189##0.000#E0 12300.1 12,30E3 K
190##0.000#E0 12301 12,301E3
0f5d89e8 1910.05E0 12301.2 1,25E4 HK
2ca993e8
A
192##0.000#E0 0.17 170,0E-3
193// JDK doesn't support significant digits in exponents
0f5d89e8 194@@@E0 6.235 6,24E0 K
2ca993e8
A
195@@@E0 6235 6,24E3 K
196@@@#E0 6200 6,20E3 K
197@@@#E0 6201 6,201E3 K
198@@@#E0 6201.7 6,202E3 K
199@@@#E00 6201.7 6,202E03 K
200@@@#E+00 6201.7 6,202E+03 K
0f5d89e8
A
201// If no zeros are specified, significant digits is fraction length plus 1
202#.##E0 52413 5,24E4
203###.##E0 52413 52,4E3 K
204#E0 52413 5,2413E4 K
2050E0 52413 5E4
2ca993e8 206
3d1f044b
A
207test scientific infinite precision
208// ICU-11511, ICU-7460, CLDR-10103
209set locale en
210begin
211pattern format output breaks
212// From the spec:
213// "0.##E0 means a max of 3 significant digits."
2140.##E0 98760 9.88E4
215// "#.##E0 also means a max of 3 significant digits."
216#.##E0 98760 9.88E4
217// "#.0#E0 means a max of 2 significant digits."
218#.0#E0 98760 9.9E4 K
219// "0E0 means a max of 1 significant digit."
2200E0 98760 1E5
221// "#E0 means infinite precision."
222#E0 98760 9.876E4 K
223// "###E0 means engineering notation with infinite precision."
224###E0 98760 98.76E3 K
225// Additional tests:
226##0.#E0 98760 99E3 K
227###.#E0 98760 99E3 K
228##0E0 98760 100E3 K
229
2ca993e8
A
230test percents
231set locale fr
232begin
233pattern format output breaks
2340.0% 0.573 57,3%
235%0.0 0.573 %57,3
236p%p0.0 0.573 p%p57,3
237p'%'p0.0 0.573 p%p0,6
238%@@@@ 0.0326 %3,260 K
3d1f044b 239%#,@@@ 15.43 %1\u202f540 K
2ca993e8 240// JDK does not support rounding increments
3d1f044b 241%#,##4.1 16.55 %1\u202f656,4 K
2ca993e8
A
242// JDK gives %16,255E3
243%##0.00E0 162.55 %16,3E3 K
244
245test permille
246set locale fr
247begin
248pattern format output breaks
2490.0\u2030 0.573 573,0‰
250\u20300.0 0.573 \u2030573,0
251p\u2030p0.0 0.573 p\u2030p573,0
252p'\u2030'p0.0 0.573 p\u2030p0,6
253\u2030@@@@ 0.0326 \u203032,60 K
3d1f044b
A
254\u2030#,@@@ 15.43 \u203015\u202f400 K
255\u2030#,##4.1 16.55 \u203016\u202f551,7 K
2ca993e8
A
256// JDK gives \u2030162,55E3
257\u2030##0.00E0 162.55 \u2030163E3 K
258
259test padding
260set locale fr_FR
261begin
262pattern format output breaks
263// JDK does not seem to support padding
3d1f044b
A
264$**####,##0 1234 $***1\u202f234 K
265*x$####,##0 1234 xxx$1\u202f234 K
266####,##0*x$ 1234 1\u202f234xxx$ K
267####,##0$*x 1234 1\u202f234$xxx K
2ca993e8 268// JDK doesn't seem to handle suffixes correctly dropping the 'nx' entirely
3d1f044b
A
269####,##0$*x;ne#n -1234 ne1\u202f234nx K
270####,##0$*x;n#'*' -1234 n1\u202f234*xx K
2ca993e8
A
271*y%4.2###### 4.33 yyyy%432,6 K
272// In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
0f5d89e8
A
273\u00a4\u00a4 **####0.00 433.0 EUR *433,00 HK
274// In H ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
275// P fails this one because the test code bypasses CurrencyUsage
276\u00a4\u00a4 **#######0 433.0 EUR *433,00 HKP
2ca993e8
A
277
278test padding and currencies
279begin
280locale currency pattern format output breaks
281// In J, JPY is considered 2 char (2 * 0xa4) even though padding is done
282// after prefix. In C this test works.
0f5d89e8 283fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 HK
2ca993e8
A
284// JDK doesn't correct rounding for currency, shows USD (433
285en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K
286
287test currencies
288set locale fr
289set format 1234.567
290begin
291pattern currency output breaks
292// JDK gives shows EUR instead of the euro symbol in this case
3d1f044b 293#,##0.00 \u00a4 EUR 1\u202f234,57 \u20ac K
2ca993e8
A
294// JDK gives 1\u00A0234,57. JDK doesn't seem to correct rounding
295// based on currency.
3d1f044b 296#,##0.00 \u00a4 JPY 1\u202f235 JPY K
2ca993e8
A
297
298test prefixes and suffixes
299set locale en
300set pattern 0.00+;(#)
301begin
302format output breaks
3037 7.00+
304// JDK does not support negative suffixes
305-3.5 (3.50) K
306
307test minimum grouping digits
308set locale en
309set pattern #,##0
310set minGroupingDigits 2
311begin
312format output breaks
313// min grouping digits not supported in any existing implementation
314// but could be easily added to the new DecimalFormat C code.
0f5d89e8 3151000 1000 HK
2ca993e8
A
31610000 10,000
317100000 100,000
3181000000 1,000,000
319
320test min max fraction digits
321set locale en
322set pattern #,##0.###
323set format 1234.567
324begin
325minFractionDigits maxFractionDigits output
3260 0 1,235
3270 2 1,234.57
3284 5 1,234.5670
329
330test min max integer digits
331set locale en
332set pattern #,##0.###
333set format 1234.567
334begin
335minIntegerDigits maxIntegerDigits output
3360 0 .567
3370 3 234.567
3385 5 01,234.567
339
340test min max fraction digits scientific
341set locale en
342set pattern #E0
343set format 299792458.0
344begin
345minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
0f5d89e8
A
346// JDK gives 2.99792458E8 (maxInt + maxFrac instead of minInt + maxFrac)
3471 99 0 5 2.99792E8 K
2ca993e8
A
348// JDK gives .3E9 instead of unlimited precision.
3490 1 0 0 2.99792458E8 K
3501 1 0 0 3E8
351// JDK gives E0 instead of allowing for unlimited precision
3520 0 0 0 2.99792458E8 K
3d1f044b
A
353// J gives 2.9979E8
3540 1 0 5 2.99792E8 HK
2ca993e8
A
355// JDK gives 300E6
3560 3 0 0 299.792458E6 K
357// JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)?
3580 3 0 1 300E6 K
359// JDK gives 299.7925E6
3602 3 0 4 299.792E6 K
361// JDK gives 299.79246E6
3622 3 0 5 299.7925E6 K
3633 3 0 5 299.79246E6
3643 3 0 4 299.7925E6
3652 2 0 3 29.979E7
3664 4 0 0 2998E5
3670 0 1 5 .29979E9
368// JDK gives E0
3690 0 1 0 2.99792458E8 K
3d1f044b
A
370// J gives 2.998E8
3710 0 0 4 .29979E9 HK
0f5d89e8
A
372// According to the spec, if maxInt>minInt and minInt>1, then set
373// Context: #13289
2ca993e8
A
3742 8 1 6 2.9979246E8 K
375// Treat max int digits > 8 as being the same as min int digits.
376// This behavior is not spelled out in the specification.
377// JDK fails here because it tries to use 9 + 6 = 15 sig digits.
3782 9 1 6 29.979246E7 K
379
3d1f044b
A
380test ticket 20058
381set locale en
382begin
383pattern format output breaks
384#00.0##E0 0 0.0E0 K
385#00.0##E0 1.2 1.2E0 K
386#00.0E0 0 0.0E0 K
387#00.0E0 1.2 1.2E0 K
388
2ca993e8
A
389test significant digits scientific
390set locale en
391set pattern #E0
392set format 290000000.0
393begin
394minSigDigits maxSigDigits output breaks
3950 1 3E8 K
3960 2 2.9E8 K
3970 3 2.9E8 K
3981 1 3E8 K
3991 2 2.9E8 K
4001 3 2.9E8 K
4012 2 2.9E8 K
4022 3 2.9E8 K
4033 3 2.90E8 K
4043 4 2.90E8 K
405
406test min max fraction digits scientific 2
407set locale en
408set pattern #E0
409set format 29979245.0
410begin
411minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
412// JDK gives E0
4130 0 0 0 2.9979245E7 K
414// JDK gives .3E8
4150 1 0 0 2.9979245E7 K
416// JDK gives 2998E4.
4170 4 0 0 2997.9245E4 K
418
419test ticket 11524
420set locale en
421set pattern #,##0.###
422begin
0f5d89e8
A
423format maxIntegerDigits output breaks
424123 1 3
3d1f044b
A
425// C obeys maxIntegerDigits and prints after the decimal place
4260 0 .0 HKP
427// CJP ignore max integer if it is less than zero and prints "123"
428123 -2147483648 0 CJP
0f5d89e8 42912345 1 5
3d1f044b 43012345 -2147483648 0 CJP
0f5d89e8 4315.3 1 5.3
3d1f044b 4325.3 -2147483648 .3 CJP
2ca993e8
A
433
434test patterns with zero
435set locale en
436set format 0
437begin
0f5d89e8 438pattern output breaks
2ca993e8
A
439#.# 0
440#. 0.
441.# .0
442# 0
0f5d89e8
A
443#,##0.00 0.00
444#,###.00 .00
2ca993e8
A
44500.000E00 00.000E00
4460.####E0 0E0
447##0.######E000 0E000
448
449test significant digits manually set
450set locale en_US
451set pattern 0.0
452set useSigDigits 1
453set minSigDigits 3
454set maxSigDigits 5
455begin
456format output breaks
4570.0012 0.00120 K
4580.00123 0.00123 K
4590.001234 0.001234 K
4600.0012345 0.0012345 K
4610.00123456 0.0012346 K
0f5d89e8
A
462-43 -43.0
463-43.7 -43.7
2ca993e8
A
464-43.76 -43.76 K
465-43.762 -43.762 K
466-43.7626 -43.763 K
467
468test grouping used setters
469set locale en_US
470set pattern #,##0
471set format 12345
472begin
473output useGrouping
47412,345
47512,345 1
47612345 0
477
0f5d89e8
A
478test grouping used setters in parsing
479set pattern #,##0
480begin
481locale useGrouping parse output breaks
482en_US 1 123,456 123456
483en_US 0 123,456 123
484en_US 1 123.456 123.456
485en_US 0 123.456 123.456
486it_IT 1 123,456 123.456
487it_IT 0 123,456 123.456
488it_IT 1 123.456 123456
489it_IT 0 123.456 123
490
491test no grouping in pattern with parsing
492set pattern 0
493begin
494locale parse output breaks
495en_US 123,456 123
496en_US 123.456 123.456
497fr_FR 123,456 123.456
498fr_FR 123.456 123
499
2ca993e8
A
500test grouping setters
501set locale en_US
502set pattern 0
503set format 123456789
504set useGrouping 1
505begin
0f5d89e8 506output grouping grouping2 breaks
2ca993e8 5071,2345,6789 4
0f5d89e8
A
5081,23,45,6789 4 2 K
509
510test grouping setters with min grouping digits
511set locale en_US
512set pattern 0
513set format 123456789
514set useGrouping 1
515begin
516output grouping grouping2 minGroupingDigits breaks
5171,23,45,6789 4 2 2 K
518123,456789 6 6 3
519123456789 6 6 4 HK
2ca993e8
A
520
521test multiplier setters
522set locale en_US
523begin
524format multiplier output breaks
52523 -12 -276
52623 -1 -23
0f5d89e8
A
527// H (ICU4J 58) and J (current ICU4J) throw exception on zero multiplier.
528// ICU4C prints 23.
529// Q multiplies by zero and prints 0.
53023 0 0 CHJ
2ca993e8
A
53123 1 23
53223 12 276
533-23 12 -276
534-23 -12 276
535
536test rounding setters
537set locale en_US
538set pattern 0.0#
539set roundingIncrement 0.25
540begin
541format output breaks
542-0.35 -0.25 K
5430.35 0.25 K
0f5d89e8
A
544// P doesn't support mixing minFrac with roundingIncrement (prints 0.50).
5450.39 0.5 JKP
5460.62 0.5 JKP
2ca993e8
A
5470.63 0.75 K
548
549test padding setters
550set locale en_US
551set pattern bill0
552set format 1357
553begin
554padCharacter formatWidth output breaks
0f5d89e8 555* 8 bill1357
2ca993e8
A
556* 9 *bill1357 K
557^ 10 ^^bill1357 K
558
559test use scientific setter
560set locale en_US
561set pattern 0.00
562set format 186283
563begin
0f5d89e8 564output useScientific breaks
2ca993e8 565186283.00
0f5d89e8
A
5661.86E5 1 K
567186283.00 0
2ca993e8
A
568
569test rounding mode setters
570set locale en_US
0f5d89e8 571set pattern 0.5
2ca993e8
A
572begin
573format roundingMode output breaks
0f5d89e8
A
5741.24 halfUp 1.0 K
5751.25 halfUp 1.5
5761.25 halfDown 1.0 K
5771.26 halfDown 1.5
5781.25 halfEven 1.0 K
579-1.01 up -1.5
580-1.49 down -1.0 K
5811.01 up 1.5
5821.49 down 1.0 K
583-1.01 ceiling -1.0 K
584-1.49 floor -1.5
2ca993e8
A
585
586test currency usage setters
2ca993e8 587set locale CH
2ca993e8
A
588set pattern \u00a4\u00a4 0
589begin
0f5d89e8
A
590format currency currencyUsage output breaks
5910.37 CHF standard CHF 0.37 K
5920.37 CHF cash CHF 0.35 K
5931.234 CZK standard CZK 1.23 K
5941.234 CZK cash CZK 1
595
596test currency usage to pattern
597set locale en
598begin
599currency currencyUsage toPattern breaks
600// These work in J, but it prepends an extra hash sign to the pattern.
0f5d89e8 601// K does not support this feature.
3d1f044b
A
602USD standard 0.00 HK
603CHF standard 0.00 HK
604CZK standard 0.00 HK
605USD cash 0.00 HK
606CHF cash 0.05 HK
607CZK cash 0 HK
0f5d89e8
A
608
609test currency rounding
610set locale en
611set currency USD
612begin
613pattern format output breaks
614# 123 123 P
615// Currency rounding should always override the pattern.
616// K prints the currency in ISO format for some reason.
617\u00a4# 123 $123.00 K
618\u00a4#.000 123 $123.00 K
619\u00a4#.## 123 $123.00 K
2ca993e8
A
620
621test exponent parameter setters
622set locale en_US
623set pattern 0.##E0
624set format 299792458
625begin
626decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks
6270 0 2 3E08 K
6280 1 3 3E+008 K
2ca993e8
A
629// decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J
630// See ticket 11621
0f5d89e8
A
6311 0 2 3.E08 K
6321 1 3 3.E+008 K
f3c0d7a5 6331 0 1 3.E8
2ca993e8
A
6340 0 1 3E8
635
636test exponent decimalSeparatorAlwaysShown default
637set locale en_US
638set pattern 0.##E0
639begin
0f5d89e8 640format output decimalSeparatorAlwaysShown breaks
2ca993e8
A
641// decimalSeparatorAlwaysShown off by default
642299792458 3E8
643299000000 2.99E8
0f5d89e8 644299792458 3.E8 1
2ca993e8
A
645
646test pad position setters
647set locale en_US
648set pattern **[#####0.##];((#))
649begin
650format padPosition output breaks
65112.34 beforePrefix ****[12.34] K
65212.34 afterPrefix [****12.34] K
65312.34 beforeSuffix [12.34****] K
65412.34 afterSuffix [12.34]**** K
655-12.34 beforePrefix **((12.34)) K
656-12.34 afterPrefix ((**12.34)) K
657-12.34 beforeSuffix ((12.34**)) K
658-12.34 afterSuffix ((12.34))** K
659
660test affix setters
661set locale fr_FR
662set currency EUR
663set pattern 0.00
664begin
665format positivePrefix positiveSuffix negativePrefix negativeSuffix output
66612.34 % %12,34
66712.34 \u00a4\u00a4 12,34\u00a4\u00a4
66812.34 - + 12,34
669-12.34 - + -12,34+
670-12.34 \u00a4 \u00a412,34
67112.34 \u00a4 12,34
672-12.34 % 12,34%
67312.34 % 12,34
674
675test more affix setters
676set locale fr_FR
677set pattern %0.00
678begin
679format positivePrefix negativePrefix output
6800.648 booya cooya booya64,80
681
682test nan and infinity
683set locale en_US
684set pattern [0.00];(#)
685begin
686format output breaks
0f5d89e8 687Inf [\u221e]
2ca993e8 688-Inf (\u221e) K
0f5d89e8
A
689// J does not print the affixes
690// K prints \uFFFD
3d1f044b 691NaN [NaN] HK
2ca993e8
A
692
693test nan and infinity with multiplication
694set locale en
695set multiplier 100
696begin
697format output breaks
698Inf \u221e
699-Inf -\u221e
700NaN NaN K
701
702test nan and infinity with padding
703set locale en_US
704set pattern $$$0.00$
0f5d89e8 705set formatWidth 8
2ca993e8
A
706begin
707format padPosition output breaks
0f5d89e8
A
708Inf beforePrefix $$$\u221e$ K
709Inf afterPrefix $$$ \u221e$ K
710Inf beforeSuffix $$$\u221e $ K
711Inf afterSuffix $$$\u221e$ K
712// J does not print the affixes
713// K prints \uFFFD
3d1f044b
A
714NaN beforePrefix $$$NaN$ HK
715NaN afterPrefix $$$ NaN$ HK
716NaN beforeSuffix $$$NaN $ HK
717NaN afterSuffix $$$NaN$ HK
2ca993e8 718
f3c0d7a5 719test apply formerly localized patterns
2ca993e8 720begin
f3c0d7a5
A
721// documentation says localizedPattern is not supported, change to pattern
722locale pattern format output breaks
723en #0% 0.4376 44%
2ca993e8 724// This next test breaks JDK. JDK doesn't multiply by 100.
0f5d89e8
A
725fa \u0025\u00a0\u0023\u0030 0.4376 \u066a\u00a0\u06f4\u06f4 K
726
727test localized pattern basic symbol coverage
728begin
729locale localizedPattern toPattern breaks
730it #.##0,00 #,##0.00
731// JDK either doesn't know sl uses this character for minus sign
732// or doesn't support minus sign in localized pattern
733sl #.##0;#.##0− #,##0;#,##0- K
734// JDK does not have data for "×10^" in this locale
735en_SE 0,00×10^0;0,00×10^0- 0.00E0;0.00E0- K
736// JDK does not seem to transform the digits in localized patterns
737ar_SA #\u066C##\u0660\u066B\u0660\u0660;a# #,##0.00;a#,##0.00 K
2ca993e8
A
738
739test toPattern
740set locale en
741begin
742pattern toPattern breaks
0f5d89e8 743// All of the C and S failures in this section are because of functionally equivalent patterns
2ca993e8
A
744// JDK doesn't support any patterns with padding or both negative prefix and suffix
745// Breaks ICU4J See ticket 11671
0f5d89e8 746**0,000 **0,000 HK
2ca993e8
A
747**##0,000 **##0,000 K
748**###0,000 **###0,000 K
3d1f044b 749**####0,000 **#,##0,000 CJKP
2ca993e8 750###,000. #,000.
3d1f044b 7510,000 #0,000 CJP
2ca993e8 752.00 #.00
3d1f044b
A
753000 #000 CJP
754000,000 #,000,000 CJP
2ca993e8 755pp#,000 pp#,000
3d1f044b 75600.## #00.## CJP
2ca993e8
A
757#,#00.025 #,#00.025
758// No secondary grouping in JDK
759#,##,###.02500 #,##,###.02500 K
760pp#,000;(#) pp#,000;(#,000) K
3d1f044b 761**####,##,##0.0##;(#) **#,##,##,##0.0##;**(##,##,##0.0##) CJKP
2ca993e8
A
762// No significant digits in JDK
763@@### @@### K
764@,@#,### @,@#,### K
7650.00E0 0.00E0
0f5d89e8
A
766// The following one works in JDK, probably because
767// it just returns the same string
768@@@##E0 @@@##E0
2ca993e8
A
769###0.00#E0 ###0.00#E0
770##00.00#E0 ##00.00#E0
7710.00E+00 0.00E+00 K
772000.00E00 000.00E00
773###0.00#E00 ###0.00#E00
774
775test parse
776set locale en
777set pattern +#,##0.0###;(#)
778begin
779parse output breaks
780+5,347.25 5347.25
781+5,347,.25 5347.25
782+5,347, 5347
783+5347,,, 5347
784+5347,,,d8 5347
785(5,347.25) -5347.25
0f5d89e8
A
786// H requires prefix and suffix for lenient parsing, but C doesn't
7875,347.25 5347.25 HK
788(5,347.25 -5347.25 H
789// S is successful at parsing this as -5347.25 in lenient mode
3d1f044b 790-5,347.25 -5347.25 HK
2ca993e8
A
791+3.52E4 35200
792(34.8E-3) -0.0348
793// JDK stops parsing at the spaces. JDK doesn't see space as a grouping separator
794(34 25E-1) -342.5 K
795(34,,25E-1) -342.5
0f5d89e8
A
796// Trailing grouping separators are not OK.
797// H fails; C/J/P stop at the offending separator.
798(34,,25,E-1) fail CJKP
3d1f044b 799(34,,25,E-1) -3425 HK
0f5d89e8 800(34 25 E-1) -342.5 HK
3d1f044b 801(34,,25 E-1) -342.5 HK
2ca993e8 802// Spaces are not allowed after exponent symbol
0f5d89e8
A
803// C parses up to the E but H bails
804(34 25E -1) -3425 HK
2ca993e8
A
805+3.52EE4 3.52
806+1,234,567.8901 1234567.8901
807+1,23,4567.8901 1234567.8901
0f5d89e8 808// Fraction grouping is disabled by default
2ca993e8
A
809+1,23,4567.89,01 1234567.89
810+1,23,456.78.9 123456.78
811+12.34,56 12.34
0f5d89e8
A
812+79,,20,33 792033
813// JDK gets 79
814+79 20 33 792033 K
2ca993e8 815// Parsing stops at comma as it is different from other separators
0f5d89e8
A
816+79 20,33 7920 K
817+79,,20 33 7920
2ca993e8 818+ 79 79 K
0f5d89e8 819+,79,,20,33 792033
2ca993e8
A
820+7920d3 7920
821// Whitespace immediately after prefix doesn't count as digit separator
0f5d89e8
A
822// in C but is does in H
823+ ,79,,20,33 792033 HK
2ca993e8
A
824( 19 45) -1945 K
825// C allows trailing separators when there is a prefix and suffix.
0f5d89e8
A
826// H allows trailing separators only when there is just a prefix.
827// In this case, H just bails
828( 19 45 ) -1945 HK
2ca993e8 829(,,19,45) -1945
0f5d89e8
A
830// C parses to the space, but H bails
831(,,19 45) -19 H
832// H bails b/c comma different separator than space. C doesn't treat leading spaces
2ca993e8 833// as a separator.
0f5d89e8
A
834( 19,45) -1945 HK
835// H bails. Doesn't allow trailing separators when there is prefix and suffix.
836(,,19,45,) -1945 H
837// H bails on next 4 because H doesn't allow letters inside prefix and suffix.
2ca993e8 838// C will parse up to the letter.
0f5d89e8
A
839(,,19,45,d1) -1945 H
840(,,19,45d1) -1945 H
841( 19 45 d1) -1945 HK
842( 19 45d1) -1945 HK
843// H does allow trailing separator before a decimal point
2ca993e8
A
844(19,45,.25) -1945.25
845// 2nd decimal points are ignored
846+4.12.926 4.12
847
848test parse suffix
849set locale en
850set pattern #,##0.0###+;#-
851begin
852parse output breaks
0f5d89e8 853// J and K just bail.
3d1f044b 8543426 3426 HK
2ca993e8 8553426+ 3426
3d1f044b
A
856// J bails; K sees -34
85734 d1+ 34 HK
2ca993e8 858// JDK sees this as -1234 for some reason
0f5d89e8 859// H bails b/c of trailing separators
3d1f044b 8601,234,,,+ 1234 HK
2ca993e8 8611,234- -1234
3d1f044b
A
862// H, C, and P bail because of trailing separators
8631,234,- -1234 CHJP
2ca993e8 864// J bails here too
0f5d89e8 8651234 - -1234 H
2ca993e8
A
866
867
868
869test parse strict
870set locale en
0f5d89e8 871set pattern +#,##,##0.0###;(#)
2ca993e8 872set lenient 0
0f5d89e8 873set minGroupingDigits 2
2ca993e8
A
874begin
875parse output breaks
876+123d5 123
877+5347.25 5347.25
878// separators in wrong place cause failure, no separators ok.
0f5d89e8
A
879+65,347.25 65347.25
880(65347.25) -65347.25
881(65,347.25) -65347.25
2ca993e8
A
882// JDK does allow separators in the wrong place and parses as -5347.25
883(53,47.25) fail K
0f5d89e8
A
884// strict requires prefix or suffix, except in C
88565,347.25 fail
2ca993e8
A
886+3.52E4 35200
887(34.8E-3) -0.0348
888(3425E-1) -342.5
889// Strict doesn't allow separators in sci notation.
0f5d89e8
A
890(63,425) -63425
891// H does not allow grouping separators in scientific notation.
892(63,425E-1) -6342.5 H
2ca993e8
A
893// Both prefix and suffix needed for strict.
894// JDK accepts this and parses as -342.5
895(3425E-1 fail K
896+3.52EE4 3.52
0f5d89e8 897+12,34,567.8901 1234567.8901
2ca993e8
A
898// With strict digit separators don't have to be the right type
899// JDK doesn't acknowledge space as a separator
0f5d89e8 900+12 34 567.8901 1234567.8901 K
2ca993e8
A
901// In general the grouping separators have to match their expected
902// location exactly. The only exception is when string being parsed
903// have no separators at all.
0f5d89e8
A
904+12,345.67 12345.67
905// JDK doesn't require separators to be in the right place.
2ca993e8 906+1,23,4567.8901 fail K
0f5d89e8 907+1,234,567.8901 fail K
2ca993e8
A
908+1234,567.8901 fail K
909+1,234567.8901 fail K
910+1234567.8901 1234567.8901
0f5d89e8
A
911// Minimum grouping is not satisfied below, but that's ok
912// because minimum grouping is optional.
913+1,234.5 1234.5
2ca993e8 914// Comma after decimal means parse to a comma
0f5d89e8 915+1,23,456.78,9 123456.78
3d1f044b
A
916// H fails upon seeing the second decimal point
917+1,23,456.78.9 123456.78 H
2ca993e8
A
918+79 79
919+79 79
920+ 79 fail
921// JDK parses as -1945
922(1,945d1) fail K
923
0f5d89e8
A
924test parse strict scientific
925// See #13737: Old behavior should be retained in this case
926set locale en
927set pattern #E0
928set lenient 0
929begin
930parse output breaks
931123 123
932123E1 1230
933123E0 123
934123E 123
935
936test parse strict without prefix/suffix
937set locale en
938set pattern #
939set lenient 0
940begin
941parse output breaks
94212.34 12.34
943-12.34 -12.34
944// The following case passes only when setSignAlwaysShown is enabled
945+12.34 fail
946$12.34 fail
947
2ca993e8
A
948test parse integer only
949set locale en
950set pattern 0.00
951set parseIntegerOnly 1
952begin
953parse output breaks
95435 35
0f5d89e8 955// S accepts leading plus signs
3d1f044b 956+35 35 HK
2ca993e8
A
957-35 -35
9582.63 2
959-39.99 -39
960
961test parse no exponent flag
962set pattern 0
963set locale en
964begin
965parseNoExponent parse output breaks
966// JDK doesn't allow lowercase exponent but ICU4J and ICU4C do.
9670 5e2 500 K
9680 5.3E2 530
969// See ticket 11725
0f5d89e8
A
9701 5e2 5 H
9711 5.3E2 5.3 HK
2ca993e8
A
972
973test parse currency fail
974set pattern 0
975set locale en
976begin
977parse output outputCurrency breaks
0f5d89e8
A
978// Fixed in ticket 11735
97953.45 fail USD
2ca993e8
A
980
981test parse strange prefix
982set locale en
983set positivePrefix dd
984set negativePrefix ddd
985begin
986parse output
987dd4582 4582
988ddd4582 -4582
989
990test parse strange suffix
991set locale en
992set positiveSuffix dd
993set negativePrefix
994set negativeSuffix ddd
995begin
996parse output
9974582dd 4582
9984582ddd -4582
999
1000test really strange suffix
1001set locale en
1002set positiveSuffix 9K
1003set negativePrefix
1004set negativeSuffix 9N
1005begin
1006parse output breaks
0f5d89e8
A
1007// A non-greedy parse is required to pass these cases.
1008// All of the implementations being tested are greedy.
10096549K 654 CHJKP
10106549N -654 CHJKP
2ca993e8
A
1011
1012test really strange prefix
1013set locale en
1014set positivePrefix 82
1015set negativePrefix 28
1016begin
1017parse output
10188245 45
10192845 -45
1020
0f5d89e8
A
1021test parse pattern with quotes
1022set locale en
1023set pattern '-'#y
1024begin
1025parse output breaks
1026-45y 45
1027
1028test parse with locale symbols
1029// The grouping separator in it_CH is an apostrophe
1030set locale it_CH
1031set pattern #,##0
1032begin
1033parse output breaks
1034१३ 13
1035१३.३१‍ 13.31
1036123'456 123456
1037524'11.3 52411.3
1038३'११‍ 311
1039
1040test parse with European-style comma/period
1041set locale pt
1042set pattern #,##0
1043begin
1044parse output breaks
1045123.456 123456
1046123,456 123.456
1047987,654.321 987.654
1048987,654 321 987.654
1049987.654,321 987654.321
1050
2ca993e8
A
1051test select
1052set locale sr
1053begin
1054format pattern plural
1055Inf 0 other
1056-Inf 0 other
1057NaN 0 other
1058Inf 0.0 other
1059-Inf 0.0 other
1060NaN 0.0 other
10611 0 one
10621 0.0 other
10632 0 few
10642 0.0 other
10652 0E0 other
10665.1 0.0 one
10675.09 0.0 one
1068
1069test parse currency ISO
1070set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
0f5d89e8 1071set locale en_GB
2ca993e8
A
1072begin
1073parse output outputCurrency breaks
0f5d89e8
A
107453.45 fail GBP
1075£53.45 53.45 GBP
3d1f044b 1076$53.45 53.45 USD C
2ca993e8 107753.45 USD 53.45 USD
0f5d89e8
A
107853.45 GBP 53.45 GBP
1079USD 53.45 53.45 USD H
3d1f044b 108053.45USD 53.45 USD H
2ca993e8
A
1081USD53.45 53.45 USD
1082(7.92) USD -7.92 USD
0f5d89e8 1083(7.92) GBP -7.92 GBP
2ca993e8 1084(7.926) USD -7.926 USD
3d1f044b
A
1085(7.926 USD) -7.926 USD H
1086(USD 7.926) -7.926 USD H
1087USD (7.926) -7.926 USD H
1088USD (7.92) -7.92 USD H
1089(7.92)USD -7.92 USD H
1090USD(7.92) -7.92 USD H
2ca993e8 1091(8) USD -8 USD
3d1f044b 1092-8 USD -8 USD
2ca993e8 109367 USD 67 USD
3d1f044b 109453.45$ 53.45 USD CH
0f5d89e8 1095US Dollars 53.45 53.45 USD H
2ca993e8 109653.45 US Dollars 53.45 USD
0f5d89e8 1097US Dollar 53.45 53.45 USD H
2ca993e8
A
109853.45 US Dollar 53.45 USD
1099US Dollars53.45 53.45 USD
3d1f044b 110053.45US Dollars 53.45 USD H
2ca993e8
A
1101US Dollar53.45 53.45 USD
1102US Dollat53.45 fail USD
3d1f044b
A
110353.45US Dollar 53.45 USD H
1104US Dollars (53.45) -53.45 USD H
2ca993e8 1105(53.45) US Dollars -53.45 USD
0f5d89e8 1106(53.45) Euros -53.45 EUR
3d1f044b 1107US Dollar (53.45) -53.45 USD H
2ca993e8 1108(53.45) US Dollar -53.45 USD
3d1f044b
A
1109US Dollars(53.45) -53.45 USD H
1110(53.45)US Dollars -53.45 USD H
1111US Dollar(53.45) -53.45 USD H
2ca993e8 1112US Dollat(53.45) fail USD
3d1f044b 1113(53.45)US Dollar -53.45 USD H
2ca993e8
A
1114
1115
1116test parse currency ISO negative
1117set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4
0f5d89e8 1118set locale en_GB
2ca993e8
A
1119begin
1120parse output outputCurrency breaks
0f5d89e8
A
112153.45 fail GBP
1122£53.45 53.45 GBP
3d1f044b 1123$53.45 53.45 USD C
2ca993e8 112453.45 USD 53.45 USD
0f5d89e8
A
112553.45 GBP 53.45 GBP
1126USD 53.45 53.45 USD H
3d1f044b 112753.45USD 53.45 USD H
2ca993e8
A
1128USD53.45 53.45 USD
1129-7.92 USD -7.92 USD
0f5d89e8 1130-7.92 GBP -7.92 GBP
2ca993e8 1131-7.926 USD -7.926 USD
3d1f044b
A
1132USD -7.926 -7.926 USD H
1133-7.92USD -7.92 USD H
1134USD-7.92 -7.92 USD H
2ca993e8
A
1135-8 USD -8 USD
113667 USD 67 USD
0f5d89e8
A
113753.45$ 53.45 USD CH
1138US Dollars 53.45 53.45 USD H
2ca993e8 113953.45 US Dollars 53.45 USD
0f5d89e8 1140US Dollar 53.45 53.45 USD H
2ca993e8
A
114153.45 US Dollar 53.45 USD
1142US Dollars53.45 53.45 USD
3d1f044b 114353.45US Dollars 53.45 USD H
2ca993e8
A
1144US Dollar53.45 53.45 USD
1145US Dollat53.45 fail USD
3d1f044b 114653.45US Dollar 53.45 USD H
2ca993e8
A
1147
1148
1149test parse currency long
1150set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4
0f5d89e8 1151set locale en_GB
2ca993e8
A
1152begin
1153parse output outputCurrency breaks
0f5d89e8
A
1154// H throws a NullPointerException on the first case
115553.45 fail GBP
1156£53.45 53.45 GBP
3d1f044b 1157$53.45 53.45 USD C
2ca993e8 115853.45 USD 53.45 USD
0f5d89e8
A
115953.45 GBP 53.45 GBP
1160USD 53.45 53.45 USD H
3d1f044b 116153.45USD 53.45 USD H
2ca993e8
A
1162USD53.45 53.45 USD
1163(7.92) USD -7.92 USD
0f5d89e8 1164(7.92) GBP -7.92 GBP
2ca993e8 1165(7.926) USD -7.926 USD
3d1f044b
A
1166(7.926 USD) -7.926 USD H
1167(USD 7.926) -7.926 USD H
1168USD (7.926) -7.926 USD H
1169USD (7.92) -7.92 USD H
1170(7.92)USD -7.92 USD H
1171USD(7.92) -7.92 USD H
2ca993e8 1172(8) USD -8 USD
3d1f044b 1173-8 USD -8 USD
2ca993e8 117467 USD 67 USD
0f5d89e8
A
1175// H throws a NullPointerException on the next case
117653.45$ 53.45 USD CH
1177US Dollars 53.45 53.45 USD H
2ca993e8 117853.45 US Dollars 53.45 USD
0f5d89e8 1179US Dollar 53.45 53.45 USD H
2ca993e8
A
118053.45 US Dollar 53.45 USD
1181US Dollars53.45 53.45 USD
3d1f044b 118253.45US Dollars 53.45 USD H
2ca993e8
A
1183US Dollar53.45 53.45 USD
1184US Dollat53.45 fail USD
3d1f044b 118553.45US Dollar 53.45 USD H
2ca993e8
A
1186
1187
1188test parse currency short
1189set pattern 0.00 \u00a4;(#) \u00a4
0f5d89e8 1190set locale en_GB
2ca993e8
A
1191begin
1192parse output outputCurrency breaks
0f5d89e8
A
119353.45 fail GBP
1194£53.45 53.45 GBP
3d1f044b 1195$53.45 53.45 USD C
2ca993e8 119653.45 USD 53.45 USD
0f5d89e8
A
119753.45 GBP 53.45 GBP
1198USD 53.45 53.45 USD H
3d1f044b 119953.45USD 53.45 USD H
2ca993e8
A
1200USD53.45 53.45 USD
1201(7.92) USD -7.92 USD
0f5d89e8 1202(7.92) GBP -7.92 GBP
2ca993e8 1203(7.926) USD -7.926 USD
3d1f044b
A
1204(7.926 USD) -7.926 USD H
1205(USD 7.926) -7.926 USD H
1206USD (7.926) -7.926 USD H
1207USD (7.92) -7.92 USD H
1208(7.92)USD -7.92 USD H
1209USD(7.92) -7.92 USD H
2ca993e8 1210(8) USD -8 USD
3d1f044b 1211-8 USD -8 USD
2ca993e8 121267 USD 67 USD
0f5d89e8
A
121353.45$ 53.45 USD CH
1214US Dollars 53.45 53.45 USD H
2ca993e8 121553.45 US Dollars 53.45 USD
0f5d89e8 1216US Dollar 53.45 53.45 USD H
2ca993e8
A
121753.45 US Dollar 53.45 USD
1218US Dollars53.45 53.45 USD
3d1f044b 121953.45US Dollars 53.45 USD H
2ca993e8
A
1220US Dollar53.45 53.45 USD
1221US Dollat53.45 fail USD
3d1f044b 122253.45US Dollar 53.45 USD H
2ca993e8
A
1223
1224
1225test parse currency short prefix
1226set pattern \u00a40.00;(\u00a4#)
0f5d89e8 1227set locale en_GB
2ca993e8
A
1228begin
1229parse output outputCurrency breaks
0f5d89e8
A
123053.45 fail GBP
1231£53.45 53.45 GBP
3d1f044b
A
1232$53.45 53.45 USD C
123353.45 USD 53.45 USD
123453.45 GBP 53.45 GBP
0f5d89e8 1235USD 53.45 53.45 USD H
3d1f044b 123653.45USD 53.45 USD H
2ca993e8 1237USD53.45 53.45 USD
0f5d89e8
A
1238// C and P fail these because '(' is an incomplete prefix.
1239(7.92) USD -7.92 USD CHJP
1240(7.92) GBP -7.92 GBP CHJP
1241(7.926) USD -7.926 USD CHJP
1242(7.926 USD) -7.926 USD CHJP
1243(USD 7.926) -7.926 USD H
1244USD (7.926) -7.926 USD CHJP
1245USD (7.92) -7.92 USD CHJP
1246(7.92)USD -7.92 USD CHJP
1247USD(7.92) -7.92 USD CHJP
1248(8) USD -8 USD CHJP
3d1f044b
A
1249-8 USD -8 USD
125067 USD 67 USD
0f5d89e8
A
125153.45$ 53.45 USD CH
1252US Dollars 53.45 53.45 USD H
2ca993e8 125353.45 US Dollars 53.45 USD
0f5d89e8 1254US Dollar 53.45 53.45 USD H
2ca993e8
A
125553.45 US Dollar 53.45 USD
1256US Dollars53.45 53.45 USD
3d1f044b 125753.45US Dollars 53.45 USD H
2ca993e8 1258US Dollar53.45 53.45 USD
3d1f044b 125953.45US Dollar 53.45 USD H
2ca993e8
A
1260
1261test format foreign currency
1262set locale fa_IR
0f5d89e8 1263set currency IRR
2ca993e8
A
1264begin
1265pattern format output breaks
1266\u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 # 1235 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 K
1267\u00a4\u00a4 0.00;\u00a4\u00a4 -# 1235 IRR \u06F1\u06F2\u06F3\u06F5 K
1268\u00a4 0.00;\u00a4 -# 1235 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 K
1269
1270test parse foreign currency symbol
1271set pattern \u00a4 0.00;\u00a4 -#
1272set locale fa_IR
1273begin
0f5d89e8 1274parse output outputCurrency breaks
2ca993e8
A
1275\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1276IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
0f5d89e8 1277// P fails here because this currency name is in the Trie only, but it has the same prefix as the non-Trie currency
3d1f044b 1278\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1279IRR 1235 1235 IRR
1280\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1281\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1282
1283test parse foreign currency ISO
1284set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -#
1285set locale fa_IR
1286begin
0f5d89e8 1287parse output outputCurrency breaks
2ca993e8
A
1288\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1289IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
3d1f044b 1290\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1291IRR 1235 1235 IRR
1292\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1293\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1294
1295test parse foreign currency full
1296set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -#
1297set locale fa_IR
1298begin
0f5d89e8 1299parse output outputCurrency breaks
2ca993e8
A
1300\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1301IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
3d1f044b 1302\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1303IRR 1235 1235 IRR
1304\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1305\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1306
1307test parse currency with foreign symbols symbol english
1308set pattern \u00a4 0.00;\u00a4 (#)
1309set locale en_US
1310begin
1311parse output outputCurrency
1312EUR 7.82 7.82 EUR
1313\u20ac 7.82 7.82 EUR
1314Euro 7.82 7.82 EUR
1315Euros 7.82 7.82 EUR
1316
1317test parse currency with foreign symbols ISO english
1318set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#)
1319set locale en_US
1320begin
1321parse output outputCurrency
1322EUR 7.82 7.82 EUR
1323\u20ac 7.82 7.82 EUR
1324Euro 7.82 7.82 EUR
1325Euros 7.82 7.82 EUR
1326
1327test parse currency with foreign symbols full english
1328set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#)
1329set locale en_US
1330begin
1331parse output outputCurrency
1332EUR 7.82 7.82 EUR
1333\u20ac 7.82 7.82 EUR
1334Euro 7.82 7.82 EUR
1335Euros 7.82 7.82 EUR
1336
0f5d89e8
A
1337test parse currency without currency mode
1338// Should accept a symbol associated with the currency specified by the API,
1339// but should not traverse the full currency data.
1340set locale en_US
1341set pattern \u00a4#,##0.00
1342begin
1343parse currency output breaks
1344$52.41 USD 52.41
1345USD52.41 USD 52.41 K
1346\u20ac52.41 USD fail
1347EUR52.41 USD fail
1348$52.41 EUR fail
1349USD52.41 EUR fail
1350\u20ac52.41 EUR 52.41 K
1351EUR52.41 EUR 52.41
1352
2ca993e8
A
1353test parse currency ISO strict
1354set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
1355set locale en_US
1356set lenient 0
1357begin
1358parse output outputCurrency breaks
3d1f044b 1359$53.45 53.45 USD CJP
2ca993e8
A
136053.45 USD 53.45 USD
1361USD 53.45 fail USD
136253.45USD fail USD
3d1f044b 1363USD53.45 53.45 USD CJP
2ca993e8
A
1364(7.92) USD -7.92 USD
1365(7.92) EUR -7.92 EUR
1366(7.926) USD -7.926 USD
1367(7.926 USD) fail USD
1368(USD 7.926) fail USD
1369USD (7.926) fail USD
1370USD (7.92) fail USD
1371(7.92)USD fail USD
1372USD(7.92) fail USD
1373(8) USD -8 USD
0f5d89e8 1374-8 USD fail USD H
2ca993e8
A
137567 USD 67 USD
137653.45$ fail USD
1377US Dollars 53.45 fail USD
137853.45 US Dollars 53.45 USD
1379US Dollar 53.45 fail USD
138053.45 US Dollar 53.45 USD
3d1f044b 1381US Dollars53.45 53.45 USD CJP
2ca993e8 138253.45US Dollars fail USD
3d1f044b 1383US Dollar53.45 53.45 USD CJP
2ca993e8
A
1384US Dollat53.45 fail USD
138553.45US Dollar fail USD
1386US Dollars (53.45) fail USD
1387(53.45) US Dollars -53.45 USD
1388US Dollar (53.45) fail USD
1389(53.45) US Dollar -53.45 USD
1390US Dollars(53.45) fail USD
1391(53.45)US Dollars fail USD
1392US Dollar(53.45) fail USD
1393US Dollat(53.45) fail USD
1394(53.45)US Dollar fail USD
1395
1396test ticket 10436
1397set locale en
1398set roundingMode ceiling
1399set minFractionDigits 0
1400set maxFractionDigits 0
1401begin
1402format output breaks
0f5d89e8
A
1403-0.99 -0 HK
1404
1405test parse decimalPatternMatchRequired
1406set locale en
1407set decimalPatternMatchRequired 1
1408begin
1409pattern parse output breaks
1410// K doesn't support this feature.
14110 123 123
3d1f044b
A
14120 123. fail HK
14130 1.23 fail HK
0f5d89e8 14140 -513 -513
3d1f044b
A
14150 -513. fail HK
14160 -5.13 fail HK
0f5d89e8 14170.0 123 fail K
3d1f044b
A
14180.0 123. 123
14190.0 1.23 1.23
0f5d89e8
A
14200.0 -513 fail K
14210.0 -513. -513
14220.0 -5.13 -5.13
1423
1424test parse minus sign
1425set locale en
1426set pattern #
1427begin
1428pattern parse output breaks
1429# -123 -123
1430# - 123 -123 HK
1431# -123 -123 HK
1432# - 123 -123 HK
1433# 123- 123
1434# 123 - 123
1435#;#- 123- -123
1436#;#- 123 - -123 HK
1437
1438test parse case sensitive
1439set locale en
1440set lenient 1
1441set pattern Aa#
1442begin
1443parse parseCaseSensitive output breaks
1444Aa1.23 1 1.23
1445Aa1.23 0 1.23
1446AA1.23 1 fail
1447// H and K do not support case-insensitive parsing for prefix/suffix.
1448// H supports it for the exponent separator, but not K.
3d1f044b 1449AA1.23 0 1.23 HK
0f5d89e8 1450aa1.23 1 fail
3d1f044b 1451aa1.23 0 1.23 HK
0f5d89e8
A
1452Aa1.23E3 1 1230
1453Aa1.23E3 0 1230
3d1f044b 1454Aa1.23e3 1 1.23 H
0f5d89e8
A
1455Aa1.23e3 0 1230 K
1456NaN 1 NaN K
1457NaN 0 NaN K
1458nan 1 fail
3d1f044b 1459nan 0 NaN HK
0f5d89e8
A
1460
1461test parse infinity and scientific notation overflow
1462set locale en
1463set lenient 1
1464begin
1465parse output breaks
1466NaN NaN K
1467// JDK returns zero
14681E999999999999999 Inf K
1469-1E999999999999999 -Inf K
14701E-99999999999999 0.0
1471// Note: The test suite code doesn't properly check for 0.0 vs. -0.0
1472-1E-99999999999999 -0.0
14731E2147483648 Inf K
14741E2147483647 Inf K
1475// H, J and K get Infinity
14761E2147483646 1E+2147483646 HJK
14771E-2147483649 0
14781E-2147483648 0
1479// H and K return zero here
14801E-2147483647 1E-2147483647 HJK
14811E-2147483646 1E-2147483646 HJK
1482
1483test format push limits
1484set locale en
1485set minFractionDigits 2
1486set roundingMode halfDown
1487begin
1488maxFractionDigits format output breaks
1489100 987654321987654321 987654321987654321.00
1490100 987654321.987654321 987654321.987654321
1491100 9999999999999.9950000000001 9999999999999.9950000000001
14922 9999999999999.9950000000001 10000000000000.00
14932 9999999.99499999 9999999.99
1494// K doesn't support halfDown rounding mode?
14952 9999999.995 9999999.99 K
14962 9999999.99500001 10000000.00
1497100 56565656565656565656565656565656565656565656565656565656565656 56565656565656565656565656565656565656565656565656565656565656.00
1498100 454545454545454545454545454545.454545454545454545454545454545 454545454545454545454545454545.454545454545454545454545454545
1499100 0.0000000000000000000123 0.0000000000000000000123
1500100 -78787878787878787878787878787878 -78787878787878787878787878787878.00
1501100 -8989898989898989898989.8989898989898989 -8989898989898989898989.8989898989898989
1502
1503test ticket 11230
1504set locale en
1505begin
1506pattern lenient parse output breaks
1507// Groups after the first group need 2 digits to be accepted.
1508// JDK does not see space as grouping and parses most of these as 9.
3d1f044b 1509#,##0 1 9 9 9 H
0f5d89e8
A
1510#,##0 1 9 99 999 K
1511#,##0 1 9 999 9999 K
3d1f044b 1512#,##0 1 9 9 9 9 H
0f5d89e8
A
1513#,##0 1 ,9 9
1514#,##0 1 99,.0 99
3d1f044b 1515#,##0 1 9 9. 9 H
0f5d89e8
A
1516#,##0 1 9 99. 999 K
15170 1 9 9 9
15180 1 9 99 9
15190 1 9 999 9
15200 1 9 9 9 9
15210 1 ,9 fail
15220 1 99,.0 99
15230 1 9 9. 9
15240 1 9 99. 9
1525#,##0 0 9 9 fail K
1526#,##0 0 9 99 fail K
1527#,##0 0 9 999 9999 K
1528#,##0 0 9 9 9 fail K
1529#,##0 0 ,9 fail K
1530#,##0 0 99,.0 fail K
1531#,##0 0 9 9. fail K
1532#,##0 0 9 99. fail K
15330 0 9 9 9
15340 0 9 99 9
15350 0 9 999 9
15360 0 9 9 9 9
15370 0 ,9 fail
15380 0 99,.0 99
15390 0 9 9. 9
15400 0 9 99. 9
1541
1542test more strict grouping parse
1543set locale en
1544set pattern #,##,##0
1545begin
1546lenient parse output breaks
15471 1,23,, 123
15480 9999, 9999
15490 1,23,, fail K
1550
1551test parse ignorables
1552set locale ar
1553// Note: Prefixes contain RLMs, as do some of the test cases.
1554set pattern x a‎b0c df
1555set negativePrefix y g‎h
1556set negativeSuffix i jk
1557begin
1558parse output breaks
1559x a‎b56c df 56
1560x a‎b56c df 56 K
1561x ab56c df 56 K
1562x ab56c df 56 HK
1563x ab56c df 56 K
1564x ab56 56 HK
1565x a b56 56 HK
156656cdf 56 HK
156756c df 56 HK
156856cd f 56 HK
156956c‎d‎f 56 HK
157056cdf 56 HK
157156c d‎f 56 HK
157256‎c df 56 HK
1573y g‎h56i jk -56
1574y g‎h56i jk -56 K
1575y gh56i jk -56 K
1576y gh56i jk -56 HK
1577y gh56i jk -56 K
1578y gh56 -56 HK
1579y g h56 -56 HK
1580// S stops parsing after the 'i' for these and returns -56
1581// C stops before the 'i' and gets 56
3d1f044b
A
158256ijk -56 HK
158356i jk -56 HK
158456ij k -56 HK
158556i‎j‎k -56 HK
158656ijk -56 HK
158756i j‎k -56 HK
158856‎i jk -56 HK
0f5d89e8
A
1589// S and C get 56 (accepts ' ' gs grouping); H and K get null
15905 6 fail CJP
15915‎6 5 HK
1592
1593test parse spaces in grouping
1594// This test gives the ideal behavior of these cases, which
1595// none of the implementations currently support.
1596// Similar to the test above for ticket #11230
1597set locale en
1598set pattern #,##0
1599begin
1600parse output breaks
3d1f044b 16011 2 1 H
0f5d89e8
A
16021 23 123 K
1603// K gets 1 here; doesn't pick up the grouping separator
16041 234 1234 K
1605
1606test rounding increment significant digits
1607// This test is for #13111
1608set locale en
1609set pattern 0.1
1610set useSigDigits 1
1611set maxSigDigits 2
1612begin
1613format output breaks
1614// C and J get "1"
1615// P gets "1.0"
1616// K gets "1.1" (??)
16170.975 0.98 CHJKP
1618
1619test lenient parse currency match
1620// This test is for #13112
1621set locale en
1622set pattern ¤#,##0.00
1623begin
1624parse output breaks
1625// H and K get null
16261.23!@#$%^ 1.23 HK
1627
1628test percentage parsing multiplier
1629// This test is for #13114
1630set locale en
1631set pattern 0%
1632begin
1633parse output breaks
163455% 0.55
1635// H and K get null
1636// C and P scale by 100 even if the percent sign is not present
163755 0.55 HK
1638
1639test trailing grouping separators in pattern
1640// This test is for #13115
1641set locale en
1642begin
1643pattern format output breaks
1644$0M 123456 $123456M
1645// The following patterns are rejected as malformed.
1646$0,M 123456 fail
1647$0,,M 123456 fail
1648
1649test empty negative subpattern
1650// This test is for #13117
1651set locale en
1652begin
1653pattern format output breaks
16540 -15 -15
16550; -15 -15
3d1f044b
A
1656// H and K still prepend a '-' even though the pattern says otherwise
16570;0 -15 15 HK
0f5d89e8
A
1658
1659test percentage multiplier parsing
1660// This test is for #13129
1661set locale en
1662set pattern 0%
1663begin
1664parse output breaks
16659223372036854775807% 92233720368547758.07 K
1666
1667test sign always shown
1668set locale en
1669set pattern 0
1670set signAlwaysShown 1
1671begin
1672format output breaks
3d1f044b
A
1673// H and K do not support this feature
167442 +42 HK
16750 +0 HK
0f5d89e8
A
1676-42 -42
1677
1678test parse strict with plus sign
1679set locale en
1680set pattern 0
1681set signAlwaysShown 1
1682begin
1683lenient parse output breaks
16841 42 42
16851 -42 -42
3d1f044b 16861 +42 42 HK
0f5d89e8 16871 0 0
3d1f044b
A
16881 +0 0 HK
16890 42 fail HK
0f5d89e8 16900 -42 -42
3d1f044b
A
16910 +42 42 HK
16920 0 fail HK
16930 +0 0 HK
0f5d89e8
A
1694
1695test parse with scientific-separator-affix overlap
1696set locale en
1697begin
1698pattern lenient parse output breaks
16990E0','x 1 5E3,x 5000
17000E0','x 0 5E3,x 5000
17010E0'.'x 1 5E3.x 5000
17020E0'.'x 0 5E3.x 5000
1703
3d1f044b
A
1704test parse() lowercase currency
1705set locale en
1706set pattern ¤¤0
1707set currency USD
1708begin
1709parse output breaks
1710USD123 123
1711USD 123 123 HK
1712usd123 123 K
1713usd 123 123 HK
1714Usd123 123 K
1715Usd 123 123 HK
1716// US$ is not used for US dollars in en-US
1717US$123 fail H
1718us$123 fail
1719Us$123 fail
1720123 US dollars 123 K
1721123 US DOLLARS 123 K
1722123 us dollars 123 K
1723// Foreign currencies are not accepted in .parse()
1724GBP123 fail
1725gbp123 fail
1726British pounds 123 fail
1727british POUNDS 123 fail
1728
1729test parseCurrency() lowercase currency
0f5d89e8
A
1730set locale en
1731set pattern ¤¤0
1732set currency USD
1733begin
1734parse output outputCurrency breaks
1735USD123 123 USD
1736USD 123 123 USD H
3d1f044b
A
1737usd123 123 USD
1738usd 123 123 USD H
1739Usd123 123 USD
1740Usd 123 123 USD H
0f5d89e8
A
1741US$123 123 USD C
1742us$123 fail fail
1743Us$123 fail fail
1744123 US dollars 123 USD
1745123 US DOLLARS 123 USD
1746123 us dollars 123 USD
3d1f044b
A
1747GBP123 123 GBP
1748gbp123 123 GBP C
1749British pounds 123 123 GBP H
1750british POUNDS 123 123 GBP H
0f5d89e8
A
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
2ca993e8 1792