]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/testdata/numberformattestspecification.txt
ICU-66108.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// J = ICU4J (current)
14// K = JDK (ignored if not OpenJDK 1.8)
15// C = ICU4C (current)
16// P = Properties-based ICU4J (bypasses DecimalFormat wrapper)
0f5d89e8 17//
2ca993e8
A
18// For more information on the format of this file, including all the available
19// field names, please see
20// https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
21
22test plus sign
0f5d89e8 23set locale ar-EG
2ca993e8
A
24set pattern +0;-#
25begin
26format output breaks
340931cb 276 \u061C+\u0666 K
0f5d89e8 28-6 \u061C-\u0666 K
2ca993e8
A
29
30test basic patterns
31set locale fr_FR
32set format 1234.567
33begin
3d1f044b
A
34pattern output breaks
35// K does not use \u202f narrow space
36#,##0.## 1\u202f234,57 K
2ca993e8
A
370.## 1234,57
380 1235
3d1f044b 39#,##0.### 1\u202f234,567 K
2ca993e8
A
40###0.###### 1234,567
41###0.0000# 1234,5670
4200000.0000 01234,5670
3d1f044b 43#,##0.00 \u00a4 1\u202f234,57 \u20ac K
2ca993e8
A
44'tick''bitten '0.00 tick'bitten 1234,57
45'tick' 'bitten '0.00 tick bitten 1234,57
46
47
48test minimum and maximum fraction digits
49set locale en
50set minIntegerDigits 2
51set maxIntegerDigits 4
52set minFractionDigits 3
53set maxFractionDigits 5
54begin
55format output
566 06.000
576.000005 06.000
586.000006 06.00001
591002003004005 4005.000
60-1002003004005 -4005.000
6112 12.000
6212345 2345.000
6372.1234 72.1234
64
0f5d89e8
A
65test patterns with no '0' symbols
66set locale en_US
67begin
68pattern format output breaks
69# 514.23 514
70# 0.23 0
71# 0 0
72# 1 1
73##.# 514.23 514.2
74##.# 0.23 0.2
75##.# 0 0
76##.# 1 1
77#.# 514.23 514.2
78#.# 0.23 0.2
79#.# 0 0
80#.# 1 1
81.# 514.23 514.2
82.# 0.23 .2
83.# 0 .0
84.# 1 1.0
85#. 514.23 514.
86#. 0.23 0.
87#. 0 0.
88#. 1 1.
89. 514.23 514.
90. 0.23 0.
91. 0 0.
92. 1 1.
93
94test behavior on numbers approaching zero
95set locale en
96begin
97pattern format output breaks
98#.## 0.01 0.01
99#.## 0.001 0
100#.## 0 0
101#.00 0.01 .01
102#.00 0.001 .00
103#.00 0 .00
1040.00 0.01 0.01
1050.00 0.001 0.00
1060.00 0 0.00
107
108// Not in official spec, but needed for backwards compatibility
109test patterns with leading grouping separator
110set locale en_US
111begin
112pattern format output breaks
113,##0 1234.56 1,235
114'#',## 3456 #34,56
115
116test patterns with valid and invalid quote marks
117set locale et
118begin
119pattern format output breaks
120'# 1 fail
121''# 1 '1
122'''# 1 fail
123''''# 1 ''1
124'''''# 1 fail
125'-''-'# 1 -'-1
126// K doesn't know the locale symbol for et
127-'-'# 1 −-1 K
128'#'# 1 #1
129''#'' 1 '1'
130''#- 1 '1− K
131'-'#- 1 -1− K
132-#'-' 1 −1- K
133
2ca993e8
A
134test int64
135set locale en
136begin
137format output
1381002003004005 1002003004005
139-1002003004005 -1002003004005
140
141test rounding
142set locale fr
143begin
144pattern format output breaks
1450.5 1.25 1,0 K
1460.5 1.75 2,0 K
1470.5 -1.25 -1,0 K
14800.5 -1.75 -02,0 K
1494 2.0 0 K
1504 6.0 8 K
1514 10.0 8 K
1522.70 99.0 99,90 K
1532.73 272.0 273,00 K
3d1f044b 154#,#3.70 104.0 1\u202f03,60 K
2ca993e8
A
155
156test significant digits
157set locale en
158set pattern #,#@,@###
159begin
160format output breaks
1617 7.0 K
16223 23 K
163100 100 K
1641000 1000 K
16510000 1,0000 K
16610001 1,0001 K
16710001.5 1,0002 K
1681234567 1,23,4600 K
169-1234567 -1,23,4600 K
1703.14159 3.1416 K
171
172test scientific notation
173set locale fr
174begin
175pattern format output breaks
1760.00E0 12345 1,23E4
177000.00E0 12300 123,00E2
178000.0#E0 12300 123,0E2
179000.0#E0 12300.1 123,0E2
180000.0#E0 12301.0 123,01E2
181// JDK does not support exponent signs
182000.0#E+00 12301.0 123,01E+02 K
183// JDK gives 12,345E3. JDK seems to include the hashes in significant digits
184##0.00E0 12345 12,3E3 K
185// JDK gives 12,3001E3
186##0.0000E0 12300.1 12,300E3 K
187// JDK gives 12,3001E3
188##0.000#E0 12300.1 12,30E3 K
189##0.000#E0 12301 12,301E3
340931cb 1900.05E0 12301.2 1,25E4 K
2ca993e8
A
191##0.000#E0 0.17 170,0E-3
192// JDK doesn't support significant digits in exponents
0f5d89e8 193@@@E0 6.235 6,24E0 K
2ca993e8
A
194@@@E0 6235 6,24E3 K
195@@@#E0 6200 6,20E3 K
196@@@#E0 6201 6,201E3 K
197@@@#E0 6201.7 6,202E3 K
198@@@#E00 6201.7 6,202E03 K
199@@@#E+00 6201.7 6,202E+03 K
0f5d89e8
A
200// If no zeros are specified, significant digits is fraction length plus 1
201#.##E0 52413 5,24E4
202###.##E0 52413 52,4E3 K
203#E0 52413 5,2413E4 K
2040E0 52413 5E4
2ca993e8 205
3d1f044b
A
206test scientific infinite precision
207// ICU-11511, ICU-7460, CLDR-10103
208set locale en
209begin
210pattern format output breaks
211// From the spec:
212// "0.##E0 means a max of 3 significant digits."
2130.##E0 98760 9.88E4
214// "#.##E0 also means a max of 3 significant digits."
215#.##E0 98760 9.88E4
216// "#.0#E0 means a max of 2 significant digits."
217#.0#E0 98760 9.9E4 K
218// "0E0 means a max of 1 significant digit."
2190E0 98760 1E5
220// "#E0 means infinite precision."
221#E0 98760 9.876E4 K
222// "###E0 means engineering notation with infinite precision."
223###E0 98760 98.76E3 K
224// Additional tests:
225##0.#E0 98760 99E3 K
226###.#E0 98760 99E3 K
227##0E0 98760 100E3 K
228
2ca993e8
A
229test percents
230set locale fr
231begin
232pattern format output breaks
2330.0% 0.573 57,3%
234%0.0 0.573 %57,3
235p%p0.0 0.573 p%p57,3
236p'%'p0.0 0.573 p%p0,6
237%@@@@ 0.0326 %3,260 K
3d1f044b 238%#,@@@ 15.43 %1\u202f540 K
2ca993e8 239// JDK does not support rounding increments
3d1f044b 240%#,##4.1 16.55 %1\u202f656,4 K
2ca993e8
A
241// JDK gives %16,255E3
242%##0.00E0 162.55 %16,3E3 K
243
244test permille
245set locale fr
246begin
247pattern format output breaks
2480.0\u2030 0.573 573,0‰
249\u20300.0 0.573 \u2030573,0
250p\u2030p0.0 0.573 p\u2030p573,0
251p'\u2030'p0.0 0.573 p\u2030p0,6
252\u2030@@@@ 0.0326 \u203032,60 K
3d1f044b
A
253\u2030#,@@@ 15.43 \u203015\u202f400 K
254\u2030#,##4.1 16.55 \u203016\u202f551,7 K
2ca993e8
A
255// JDK gives \u2030162,55E3
256\u2030##0.00E0 162.55 \u2030163E3 K
257
258test padding
259set locale fr_FR
260begin
261pattern format output breaks
262// JDK does not seem to support padding
3d1f044b
A
263$**####,##0 1234 $***1\u202f234 K
264*x$####,##0 1234 xxx$1\u202f234 K
265####,##0*x$ 1234 1\u202f234xxx$ K
266####,##0$*x 1234 1\u202f234$xxx K
2ca993e8 267// JDK doesn't seem to handle suffixes correctly dropping the 'nx' entirely
3d1f044b
A
268####,##0$*x;ne#n -1234 ne1\u202f234nx K
269####,##0$*x;n#'*' -1234 n1\u202f234*xx K
2ca993e8
A
270*y%4.2###### 4.33 yyyy%432,6 K
271// In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
340931cb 272\u00a4\u00a4 **####0.00 433.0 EUR *433,00 K
0f5d89e8 273// P fails this one because the test code bypasses CurrencyUsage
340931cb 274\u00a4\u00a4 **#######0 433.0 EUR *433,00 KP
2ca993e8
A
275
276test padding and currencies
277begin
278locale currency pattern format output breaks
279// In J, JPY is considered 2 char (2 * 0xa4) even though padding is done
280// after prefix. In C this test works.
340931cb 281fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 K
2ca993e8
A
282// JDK doesn't correct rounding for currency, shows USD (433
283en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K
284
285test currencies
286set locale fr
287set format 1234.567
288begin
289pattern currency output breaks
290// JDK gives shows EUR instead of the euro symbol in this case
3d1f044b 291#,##0.00 \u00a4 EUR 1\u202f234,57 \u20ac K
2ca993e8
A
292// JDK gives 1\u00A0234,57. JDK doesn't seem to correct rounding
293// based on currency.
3d1f044b 294#,##0.00 \u00a4 JPY 1\u202f235 JPY K
2ca993e8
A
295
296test prefixes and suffixes
297set locale en
298set pattern 0.00+;(#)
299begin
300format output breaks
3017 7.00+
302// JDK does not support negative suffixes
303-3.5 (3.50) K
304
305test minimum grouping digits
306set locale en
307set pattern #,##0
308set minGroupingDigits 2
309begin
310format output breaks
340931cb 3111000 1000 K
2ca993e8
A
31210000 10,000
313100000 100,000
3141000000 1,000,000
315
316test min max fraction digits
317set locale en
318set pattern #,##0.###
319set format 1234.567
320begin
321minFractionDigits maxFractionDigits output
3220 0 1,235
3230 2 1,234.57
3244 5 1,234.5670
325
326test min max integer digits
327set locale en
328set pattern #,##0.###
329set format 1234.567
330begin
331minIntegerDigits maxIntegerDigits output
3320 0 .567
3330 3 234.567
3345 5 01,234.567
335
336test min max fraction digits scientific
337set locale en
338set pattern #E0
339set format 299792458.0
340begin
341minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
0f5d89e8
A
342// JDK gives 2.99792458E8 (maxInt + maxFrac instead of minInt + maxFrac)
3431 99 0 5 2.99792E8 K
2ca993e8
A
344// JDK gives .3E9 instead of unlimited precision.
3450 1 0 0 2.99792458E8 K
3461 1 0 0 3E8
347// JDK gives E0 instead of allowing for unlimited precision
3480 0 0 0 2.99792458E8 K
3d1f044b 349// J gives 2.9979E8
340931cb 3500 1 0 5 2.99792E8 K
2ca993e8
A
351// JDK gives 300E6
3520 3 0 0 299.792458E6 K
353// JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)?
3540 3 0 1 300E6 K
355// JDK gives 299.7925E6
3562 3 0 4 299.792E6 K
357// JDK gives 299.79246E6
3582 3 0 5 299.7925E6 K
3593 3 0 5 299.79246E6
3603 3 0 4 299.7925E6
3612 2 0 3 29.979E7
3624 4 0 0 2998E5
3630 0 1 5 .29979E9
364// JDK gives E0
3650 0 1 0 2.99792458E8 K
3d1f044b 366// J gives 2.998E8
340931cb 3670 0 0 4 .29979E9 K
0f5d89e8
A
368// According to the spec, if maxInt>minInt and minInt>1, then set
369// Context: #13289
2ca993e8
A
3702 8 1 6 2.9979246E8 K
371// Treat max int digits > 8 as being the same as min int digits.
372// This behavior is not spelled out in the specification.
373// JDK fails here because it tries to use 9 + 6 = 15 sig digits.
3742 9 1 6 29.979246E7 K
375
3d1f044b
A
376test ticket 20058
377set locale en
378begin
379pattern format output breaks
380#00.0##E0 0 0.0E0 K
381#00.0##E0 1.2 1.2E0 K
382#00.0E0 0 0.0E0 K
383#00.0E0 1.2 1.2E0 K
384
2ca993e8
A
385test significant digits scientific
386set locale en
387set pattern #E0
388set format 290000000.0
389begin
390minSigDigits maxSigDigits output breaks
3910 1 3E8 K
3920 2 2.9E8 K
3930 3 2.9E8 K
3941 1 3E8 K
3951 2 2.9E8 K
3961 3 2.9E8 K
3972 2 2.9E8 K
3982 3 2.9E8 K
3993 3 2.90E8 K
4003 4 2.90E8 K
401
402test min max fraction digits scientific 2
403set locale en
404set pattern #E0
405set format 29979245.0
406begin
407minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
408// JDK gives E0
4090 0 0 0 2.9979245E7 K
410// JDK gives .3E8
4110 1 0 0 2.9979245E7 K
412// JDK gives 2998E4.
4130 4 0 0 2997.9245E4 K
414
415test ticket 11524
416set locale en
417set pattern #,##0.###
418begin
0f5d89e8
A
419format maxIntegerDigits output breaks
420123 1 3
3d1f044b 421// C obeys maxIntegerDigits and prints after the decimal place
340931cb 4220 0 .0 KP
3d1f044b
A
423// CJP ignore max integer if it is less than zero and prints "123"
424123 -2147483648 0 CJP
0f5d89e8 42512345 1 5
3d1f044b 42612345 -2147483648 0 CJP
0f5d89e8 4275.3 1 5.3
3d1f044b 4285.3 -2147483648 .3 CJP
2ca993e8
A
429
430test patterns with zero
431set locale en
432set format 0
433begin
0f5d89e8 434pattern output breaks
2ca993e8
A
435#.# 0
436#. 0.
437.# .0
438# 0
0f5d89e8
A
439#,##0.00 0.00
440#,###.00 .00
2ca993e8
A
44100.000E00 00.000E00
4420.####E0 0E0
443##0.######E000 0E000
444
445test significant digits manually set
446set locale en_US
447set pattern 0.0
448set useSigDigits 1
449set minSigDigits 3
450set maxSigDigits 5
451begin
452format output breaks
4530.0012 0.00120 K
4540.00123 0.00123 K
4550.001234 0.001234 K
4560.0012345 0.0012345 K
4570.00123456 0.0012346 K
0f5d89e8
A
458-43 -43.0
459-43.7 -43.7
2ca993e8
A
460-43.76 -43.76 K
461-43.762 -43.762 K
462-43.7626 -43.763 K
463
464test grouping used setters
465set locale en_US
466set pattern #,##0
467set format 12345
468begin
469output useGrouping
47012,345
47112,345 1
47212345 0
473
0f5d89e8
A
474test grouping used setters in parsing
475set pattern #,##0
476begin
477locale useGrouping parse output breaks
478en_US 1 123,456 123456
479en_US 0 123,456 123
480en_US 1 123.456 123.456
481en_US 0 123.456 123.456
482it_IT 1 123,456 123.456
483it_IT 0 123,456 123.456
484it_IT 1 123.456 123456
485it_IT 0 123.456 123
486
487test no grouping in pattern with parsing
488set pattern 0
489begin
490locale parse output breaks
491en_US 123,456 123
492en_US 123.456 123.456
493fr_FR 123,456 123.456
494fr_FR 123.456 123
495
2ca993e8
A
496test grouping setters
497set locale en_US
498set pattern 0
499set format 123456789
500set useGrouping 1
501begin
0f5d89e8 502output grouping grouping2 breaks
2ca993e8 5031,2345,6789 4
0f5d89e8
A
5041,23,45,6789 4 2 K
505
506test grouping setters with min grouping digits
507set locale en_US
508set pattern 0
509set format 123456789
510set useGrouping 1
511begin
512output grouping grouping2 minGroupingDigits breaks
5131,23,45,6789 4 2 2 K
514123,456789 6 6 3
340931cb 515123456789 6 6 4 K
2ca993e8
A
516
517test multiplier setters
518set locale en_US
519begin
520format multiplier output breaks
52123 -12 -276
52223 -1 -23
340931cb 523// J (current ICU4J) throws exception on zero multiplier.
0f5d89e8
A
524// ICU4C prints 23.
525// Q multiplies by zero and prints 0.
340931cb 52623 0 0 CJ
2ca993e8
A
52723 1 23
52823 12 276
529-23 12 -276
530-23 -12 276
531
532test rounding setters
533set locale en_US
534set pattern 0.0#
535set roundingIncrement 0.25
536begin
537format output breaks
538-0.35 -0.25 K
5390.35 0.25 K
0f5d89e8
A
540// P doesn't support mixing minFrac with roundingIncrement (prints 0.50).
5410.39 0.5 JKP
5420.62 0.5 JKP
2ca993e8
A
5430.63 0.75 K
544
545test padding setters
546set locale en_US
547set pattern bill0
548set format 1357
549begin
550padCharacter formatWidth output breaks
0f5d89e8 551* 8 bill1357
2ca993e8
A
552* 9 *bill1357 K
553^ 10 ^^bill1357 K
554
555test use scientific setter
556set locale en_US
557set pattern 0.00
558set format 186283
559begin
0f5d89e8 560output useScientific breaks
2ca993e8 561186283.00
0f5d89e8
A
5621.86E5 1 K
563186283.00 0
2ca993e8
A
564
565test rounding mode setters
566set locale en_US
0f5d89e8 567set pattern 0.5
2ca993e8
A
568begin
569format roundingMode output breaks
0f5d89e8
A
5701.24 halfUp 1.0 K
5711.25 halfUp 1.5
5721.25 halfDown 1.0 K
5731.26 halfDown 1.5
5741.25 halfEven 1.0 K
575-1.01 up -1.5
576-1.49 down -1.0 K
5771.01 up 1.5
5781.49 down 1.0 K
579-1.01 ceiling -1.0 K
580-1.49 floor -1.5
2ca993e8
A
581
582test currency usage setters
2ca993e8 583set locale CH
2ca993e8
A
584set pattern \u00a4\u00a4 0
585begin
0f5d89e8
A
586format currency currencyUsage output breaks
5870.37 CHF standard CHF 0.37 K
5880.37 CHF cash CHF 0.35 K
5891.234 CZK standard CZK 1.23 K
5901.234 CZK cash CZK 1
591
592test currency usage to pattern
593set locale en
594begin
595currency currencyUsage toPattern breaks
596// These work in J, but it prepends an extra hash sign to the pattern.
0f5d89e8 597// K does not support this feature.
340931cb
A
598USD standard 0.00 K
599CHF standard 0.00 K
600CZK standard 0.00 K
601USD cash 0.00 K
602CHF cash 0.05 K
603CZK cash 0 K
0f5d89e8
A
604
605test currency rounding
606set locale en
607set currency USD
608begin
609pattern format output breaks
610# 123 123 P
611// Currency rounding should always override the pattern.
612// K prints the currency in ISO format for some reason.
613\u00a4# 123 $123.00 K
614\u00a4#.000 123 $123.00 K
615\u00a4#.## 123 $123.00 K
2ca993e8
A
616
617test exponent parameter setters
618set locale en_US
619set pattern 0.##E0
620set format 299792458
621begin
622decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks
6230 0 2 3E08 K
6240 1 3 3E+008 K
2ca993e8
A
625// decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J
626// See ticket 11621
0f5d89e8
A
6271 0 2 3.E08 K
6281 1 3 3.E+008 K
f3c0d7a5 6291 0 1 3.E8
2ca993e8
A
6300 0 1 3E8
631
632test exponent decimalSeparatorAlwaysShown default
633set locale en_US
634set pattern 0.##E0
635begin
0f5d89e8 636format output decimalSeparatorAlwaysShown breaks
2ca993e8
A
637// decimalSeparatorAlwaysShown off by default
638299792458 3E8
639299000000 2.99E8
0f5d89e8 640299792458 3.E8 1
2ca993e8
A
641
642test pad position setters
643set locale en_US
644set pattern **[#####0.##];((#))
645begin
646format padPosition output breaks
64712.34 beforePrefix ****[12.34] K
64812.34 afterPrefix [****12.34] K
64912.34 beforeSuffix [12.34****] K
65012.34 afterSuffix [12.34]**** K
651-12.34 beforePrefix **((12.34)) K
652-12.34 afterPrefix ((**12.34)) K
653-12.34 beforeSuffix ((12.34**)) K
654-12.34 afterSuffix ((12.34))** K
655
656test affix setters
657set locale fr_FR
658set currency EUR
659set pattern 0.00
660begin
661format positivePrefix positiveSuffix negativePrefix negativeSuffix output
66212.34 % %12,34
66312.34 \u00a4\u00a4 12,34\u00a4\u00a4
66412.34 - + 12,34
665-12.34 - + -12,34+
666-12.34 \u00a4 \u00a412,34
66712.34 \u00a4 12,34
668-12.34 % 12,34%
66912.34 % 12,34
670
671test more affix setters
672set locale fr_FR
673set pattern %0.00
674begin
675format positivePrefix negativePrefix output
6760.648 booya cooya booya64,80
677
678test nan and infinity
679set locale en_US
680set pattern [0.00];(#)
681begin
682format output breaks
0f5d89e8 683Inf [\u221e]
2ca993e8 684-Inf (\u221e) K
0f5d89e8
A
685// J does not print the affixes
686// K prints \uFFFD
340931cb 687NaN [NaN] K
2ca993e8
A
688
689test nan and infinity with multiplication
690set locale en
691set multiplier 100
692begin
693format output breaks
694Inf \u221e
695-Inf -\u221e
696NaN NaN K
697
698test nan and infinity with padding
699set locale en_US
700set pattern $$$0.00$
0f5d89e8 701set formatWidth 8
2ca993e8
A
702begin
703format padPosition output breaks
0f5d89e8
A
704Inf beforePrefix $$$\u221e$ K
705Inf afterPrefix $$$ \u221e$ K
706Inf beforeSuffix $$$\u221e $ K
707Inf afterSuffix $$$\u221e$ K
708// J does not print the affixes
709// K prints \uFFFD
340931cb
A
710NaN beforePrefix $$$NaN$ K
711NaN afterPrefix $$$ NaN$ K
712NaN beforeSuffix $$$NaN $ K
713NaN afterSuffix $$$NaN$ K
2ca993e8 714
f3c0d7a5 715test apply formerly localized patterns
2ca993e8 716begin
f3c0d7a5
A
717// documentation says localizedPattern is not supported, change to pattern
718locale pattern format output breaks
719en #0% 0.4376 44%
2ca993e8 720// This next test breaks JDK. JDK doesn't multiply by 100.
0f5d89e8
A
721fa \u0025\u00a0\u0023\u0030 0.4376 \u066a\u00a0\u06f4\u06f4 K
722
723test localized pattern basic symbol coverage
724begin
725locale localizedPattern toPattern breaks
726it #.##0,00 #,##0.00
727// JDK either doesn't know sl uses this character for minus sign
728// or doesn't support minus sign in localized pattern
729sl #.##0;#.##0− #,##0;#,##0- K
730// JDK does not have data for "×10^" in this locale
731en_SE 0,00×10^0;0,00×10^0- 0.00E0;0.00E0- K
732// JDK does not seem to transform the digits in localized patterns
733ar_SA #\u066C##\u0660\u066B\u0660\u0660;a# #,##0.00;a#,##0.00 K
2ca993e8
A
734
735test toPattern
736set locale en
737begin
738pattern toPattern breaks
0f5d89e8 739// All of the C and S failures in this section are because of functionally equivalent patterns
2ca993e8 740// JDK doesn't support any patterns with padding or both negative prefix and suffix
340931cb 741**0,000 **0,000 K
2ca993e8
A
742**##0,000 **##0,000 K
743**###0,000 **###0,000 K
3d1f044b 744**####0,000 **#,##0,000 CJKP
2ca993e8 745###,000. #,000.
3d1f044b 7460,000 #0,000 CJP
2ca993e8 747.00 #.00
3d1f044b
A
748000 #000 CJP
749000,000 #,000,000 CJP
2ca993e8 750pp#,000 pp#,000
3d1f044b 75100.## #00.## CJP
2ca993e8
A
752#,#00.025 #,#00.025
753// No secondary grouping in JDK
754#,##,###.02500 #,##,###.02500 K
755pp#,000;(#) pp#,000;(#,000) K
3d1f044b 756**####,##,##0.0##;(#) **#,##,##,##0.0##;**(##,##,##0.0##) CJKP
2ca993e8
A
757// No significant digits in JDK
758@@### @@### K
759@,@#,### @,@#,### K
7600.00E0 0.00E0
0f5d89e8
A
761// The following one works in JDK, probably because
762// it just returns the same string
763@@@##E0 @@@##E0
2ca993e8
A
764###0.00#E0 ###0.00#E0
765##00.00#E0 ##00.00#E0
7660.00E+00 0.00E+00 K
767000.00E00 000.00E00
768###0.00#E00 ###0.00#E00
769
770test parse
771set locale en
772set pattern +#,##0.0###;(#)
773begin
774parse output breaks
775+5,347.25 5347.25
776+5,347,.25 5347.25
777+5,347, 5347
778+5347,,, 5347
779+5347,,,d8 5347
780(5,347.25) -5347.25
340931cb
A
7815,347.25 5347.25 K
782(5,347.25 -5347.25
0f5d89e8 783// S is successful at parsing this as -5347.25 in lenient mode
340931cb 784-5,347.25 -5347.25 K
2ca993e8
A
785+3.52E4 35200
786(34.8E-3) -0.0348
787// JDK stops parsing at the spaces. JDK doesn't see space as a grouping separator
788(34 25E-1) -342.5 K
789(34,,25E-1) -342.5
0f5d89e8 790// Trailing grouping separators are not OK.
340931cb 791// C/J/P stop at the offending separator.
0f5d89e8 792(34,,25,E-1) fail CJKP
340931cb
A
793(34,,25,E-1) -3425 K
794(34 25 E-1) -342.5 K
795(34,,25 E-1) -342.5 K
2ca993e8 796// Spaces are not allowed after exponent symbol
340931cb
A
797// C parses up to the E
798(34 25E -1) -3425 K
2ca993e8
A
799+3.52EE4 3.52
800+1,234,567.8901 1234567.8901
801+1,23,4567.8901 1234567.8901
0f5d89e8 802// Fraction grouping is disabled by default
2ca993e8
A
803+1,23,4567.89,01 1234567.89
804+1,23,456.78.9 123456.78
805+12.34,56 12.34
0f5d89e8
A
806+79,,20,33 792033
807// JDK gets 79
808+79 20 33 792033 K
2ca993e8 809// Parsing stops at comma as it is different from other separators
0f5d89e8
A
810+79 20,33 7920 K
811+79,,20 33 7920
2ca993e8 812+ 79 79 K
0f5d89e8 813+,79,,20,33 792033
2ca993e8 814+7920d3 7920
340931cb
A
815// Whitespace immediately after prefix doesn't count as digit separator in C
816+ ,79,,20,33 792033 K
2ca993e8
A
817( 19 45) -1945 K
818// C allows trailing separators when there is a prefix and suffix.
340931cb 819( 19 45 ) -1945 K
2ca993e8 820(,,19,45) -1945
340931cb
A
821// C parses to the spaces
822(,,19 45) -19
823( 19,45) -1945 K
824(,,19,45,) -1945
2ca993e8 825// C will parse up to the letter.
340931cb
A
826(,,19,45,d1) -1945
827(,,19,45d1) -1945
828( 19 45 d1) -1945 K
829( 19 45d1) -1945 K
2ca993e8
A
830(19,45,.25) -1945.25
831// 2nd decimal points are ignored
832+4.12.926 4.12
833
834test parse suffix
835set locale en
836set pattern #,##0.0###+;#-
837begin
838parse output breaks
0f5d89e8 839// J and K just bail.
340931cb 8403426 3426 K
2ca993e8 8413426+ 3426
3d1f044b 842// J bails; K sees -34
340931cb 84334 d1+ 34 K
2ca993e8 844// JDK sees this as -1234 for some reason
340931cb 8451,234,,,+ 1234 K
2ca993e8 8461,234- -1234
340931cb
A
847// C and P bail because of trailing separators
8481,234,- -1234 CJP
8491234 - -1234
2ca993e8
A
850
851
852
853test parse strict
854set locale en
0f5d89e8 855set pattern +#,##,##0.0###;(#)
2ca993e8 856set lenient 0
0f5d89e8 857set minGroupingDigits 2
2ca993e8
A
858begin
859parse output breaks
860+123d5 123
861+5347.25 5347.25
862// separators in wrong place cause failure, no separators ok.
0f5d89e8
A
863+65,347.25 65347.25
864(65347.25) -65347.25
865(65,347.25) -65347.25
2ca993e8
A
866// JDK does allow separators in the wrong place and parses as -5347.25
867(53,47.25) fail K
0f5d89e8
A
868// strict requires prefix or suffix, except in C
86965,347.25 fail
2ca993e8
A
870+3.52E4 35200
871(34.8E-3) -0.0348
872(3425E-1) -342.5
873// Strict doesn't allow separators in sci notation.
0f5d89e8 874(63,425) -63425
340931cb 875(63,425E-1) -6342.5
2ca993e8
A
876// Both prefix and suffix needed for strict.
877// JDK accepts this and parses as -342.5
878(3425E-1 fail K
879+3.52EE4 3.52
0f5d89e8 880+12,34,567.8901 1234567.8901
2ca993e8
A
881// With strict digit separators don't have to be the right type
882// JDK doesn't acknowledge space as a separator
0f5d89e8 883+12 34 567.8901 1234567.8901 K
2ca993e8
A
884// In general the grouping separators have to match their expected
885// location exactly. The only exception is when string being parsed
886// have no separators at all.
0f5d89e8
A
887+12,345.67 12345.67
888// JDK doesn't require separators to be in the right place.
2ca993e8 889+1,23,4567.8901 fail K
0f5d89e8 890+1,234,567.8901 fail K
2ca993e8
A
891+1234,567.8901 fail K
892+1,234567.8901 fail K
893+1234567.8901 1234567.8901
0f5d89e8
A
894// Minimum grouping is not satisfied below, but that's ok
895// because minimum grouping is optional.
896+1,234.5 1234.5
2ca993e8 897// Comma after decimal means parse to a comma
0f5d89e8 898+1,23,456.78,9 123456.78
340931cb 899+1,23,456.78.9 123456.78
2ca993e8
A
900+79 79
901+79 79
902+ 79 fail
903// JDK parses as -1945
904(1,945d1) fail K
905
0f5d89e8
A
906test parse strict scientific
907// See #13737: Old behavior should be retained in this case
908set locale en
909set pattern #E0
910set lenient 0
911begin
912parse output breaks
913123 123
914123E1 1230
915123E0 123
916123E 123
917
918test parse strict without prefix/suffix
919set locale en
920set pattern #
921set lenient 0
922begin
923parse output breaks
92412.34 12.34
925-12.34 -12.34
926// The following case passes only when setSignAlwaysShown is enabled
927+12.34 fail
928$12.34 fail
929
2ca993e8
A
930test parse integer only
931set locale en
932set pattern 0.00
933set parseIntegerOnly 1
934begin
935parse output breaks
93635 35
340931cb 937+35 35 K
2ca993e8
A
938-35 -35
9392.63 2
940-39.99 -39
941
942test parse no exponent flag
943set pattern 0
944set locale en
945begin
946parseNoExponent parse output breaks
947// JDK doesn't allow lowercase exponent but ICU4J and ICU4C do.
9480 5e2 500 K
9490 5.3E2 530
950// See ticket 11725
340931cb
A
9511 5e2 5
9521 5.3E2 5.3 K
2ca993e8
A
953
954test parse currency fail
955set pattern 0
956set locale en
957begin
958parse output outputCurrency breaks
0f5d89e8
A
959// Fixed in ticket 11735
96053.45 fail USD
2ca993e8
A
961
962test parse strange prefix
963set locale en
964set positivePrefix dd
965set negativePrefix ddd
966begin
967parse output
968dd4582 4582
969ddd4582 -4582
970
971test parse strange suffix
972set locale en
973set positiveSuffix dd
974set negativePrefix
975set negativeSuffix ddd
976begin
977parse output
9784582dd 4582
9794582ddd -4582
980
981test really strange suffix
982set locale en
983set positiveSuffix 9K
984set negativePrefix
985set negativeSuffix 9N
986begin
987parse output breaks
0f5d89e8
A
988// A non-greedy parse is required to pass these cases.
989// All of the implementations being tested are greedy.
340931cb
A
9906549K 654 CJKP
9916549N -654 CJKP
2ca993e8
A
992
993test really strange prefix
994set locale en
995set positivePrefix 82
996set negativePrefix 28
997begin
998parse output
9998245 45
10002845 -45
1001
0f5d89e8
A
1002test parse pattern with quotes
1003set locale en
1004set pattern '-'#y
1005begin
1006parse output breaks
1007-45y 45
1008
1009test parse with locale symbols
1010// The grouping separator in it_CH is an apostrophe
1011set locale it_CH
1012set pattern #,##0
1013begin
1014parse output breaks
1015१३ 13
1016१३.३१‍ 13.31
1017123'456 123456
1018524'11.3 52411.3
1019३'११‍ 311
1020
1021test parse with European-style comma/period
1022set locale pt
1023set pattern #,##0
1024begin
1025parse output breaks
1026123.456 123456
1027123,456 123.456
1028987,654.321 987.654
1029987,654 321 987.654
1030987.654,321 987654.321
1031
2ca993e8
A
1032test select
1033set locale sr
1034begin
1035format pattern plural
1036Inf 0 other
1037-Inf 0 other
1038NaN 0 other
1039Inf 0.0 other
1040-Inf 0.0 other
1041NaN 0.0 other
10421 0 one
10431 0.0 other
10442 0 few
10452 0.0 other
10462 0E0 other
10475.1 0.0 one
10485.09 0.0 one
1049
1050test parse currency ISO
1051set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
0f5d89e8 1052set locale en_GB
2ca993e8
A
1053begin
1054parse output outputCurrency breaks
0f5d89e8
A
105553.45 fail GBP
1056£53.45 53.45 GBP
3d1f044b 1057$53.45 53.45 USD C
2ca993e8 105853.45 USD 53.45 USD
0f5d89e8 105953.45 GBP 53.45 GBP
340931cb
A
1060USD 53.45 53.45 USD
106153.45USD 53.45 USD
2ca993e8
A
1062USD53.45 53.45 USD
1063(7.92) USD -7.92 USD
0f5d89e8 1064(7.92) GBP -7.92 GBP
2ca993e8 1065(7.926) USD -7.926 USD
340931cb
A
1066(7.926 USD) -7.926 USD
1067(USD 7.926) -7.926 USD
1068USD (7.926) -7.926 USD
1069USD (7.92) -7.92 USD
1070(7.92)USD -7.92 USD
1071USD(7.92) -7.92 USD
2ca993e8 1072(8) USD -8 USD
3d1f044b 1073-8 USD -8 USD
2ca993e8 107467 USD 67 USD
340931cb
A
107553.45$ 53.45 USD C
1076US Dollars 53.45 53.45 USD
2ca993e8 107753.45 US Dollars 53.45 USD
340931cb 1078US Dollar 53.45 53.45 USD
2ca993e8
A
107953.45 US Dollar 53.45 USD
1080US Dollars53.45 53.45 USD
340931cb 108153.45US Dollars 53.45 USD
2ca993e8
A
1082US Dollar53.45 53.45 USD
1083US Dollat53.45 fail USD
340931cb
A
108453.45US Dollar 53.45 USD
1085US Dollars (53.45) -53.45 USD
2ca993e8 1086(53.45) US Dollars -53.45 USD
0f5d89e8 1087(53.45) Euros -53.45 EUR
340931cb 1088US Dollar (53.45) -53.45 USD
2ca993e8 1089(53.45) US Dollar -53.45 USD
340931cb
A
1090US Dollars(53.45) -53.45 USD
1091(53.45)US Dollars -53.45 USD
1092US Dollar(53.45) -53.45 USD
2ca993e8 1093US Dollat(53.45) fail USD
340931cb 1094(53.45)US Dollar -53.45 USD
2ca993e8
A
1095
1096
1097test parse currency ISO negative
1098set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4
0f5d89e8 1099set locale en_GB
2ca993e8
A
1100begin
1101parse output outputCurrency breaks
0f5d89e8
A
110253.45 fail GBP
1103£53.45 53.45 GBP
3d1f044b 1104$53.45 53.45 USD C
2ca993e8 110553.45 USD 53.45 USD
0f5d89e8 110653.45 GBP 53.45 GBP
340931cb
A
1107USD 53.45 53.45 USD
110853.45USD 53.45 USD
2ca993e8
A
1109USD53.45 53.45 USD
1110-7.92 USD -7.92 USD
0f5d89e8 1111-7.92 GBP -7.92 GBP
2ca993e8 1112-7.926 USD -7.926 USD
340931cb
A
1113USD -7.926 -7.926 USD
1114-7.92USD -7.92 USD
1115USD-7.92 -7.92 USD
2ca993e8
A
1116-8 USD -8 USD
111767 USD 67 USD
340931cb
A
111853.45$ 53.45 USD C
1119US Dollars 53.45 53.45 USD
2ca993e8 112053.45 US Dollars 53.45 USD
340931cb 1121US Dollar 53.45 53.45 USD
2ca993e8
A
112253.45 US Dollar 53.45 USD
1123US Dollars53.45 53.45 USD
340931cb 112453.45US Dollars 53.45 USD
2ca993e8
A
1125US Dollar53.45 53.45 USD
1126US Dollat53.45 fail USD
340931cb 112753.45US Dollar 53.45 USD
2ca993e8
A
1128
1129
1130test parse currency long
1131set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4
0f5d89e8 1132set locale en_GB
2ca993e8
A
1133begin
1134parse output outputCurrency breaks
0f5d89e8
A
113553.45 fail GBP
1136£53.45 53.45 GBP
3d1f044b 1137$53.45 53.45 USD C
2ca993e8 113853.45 USD 53.45 USD
0f5d89e8 113953.45 GBP 53.45 GBP
340931cb
A
1140USD 53.45 53.45 USD
114153.45USD 53.45 USD
2ca993e8
A
1142USD53.45 53.45 USD
1143(7.92) USD -7.92 USD
0f5d89e8 1144(7.92) GBP -7.92 GBP
2ca993e8 1145(7.926) USD -7.926 USD
340931cb
A
1146(7.926 USD) -7.926 USD
1147(USD 7.926) -7.926 USD
1148USD (7.926) -7.926 USD
1149USD (7.92) -7.92 USD
1150(7.92)USD -7.92 USD
1151USD(7.92) -7.92 USD
2ca993e8 1152(8) USD -8 USD
3d1f044b 1153-8 USD -8 USD
2ca993e8 115467 USD 67 USD
340931cb
A
115553.45$ 53.45 USD C
1156US Dollars 53.45 53.45 USD
2ca993e8 115753.45 US Dollars 53.45 USD
340931cb 1158US Dollar 53.45 53.45 USD
2ca993e8
A
115953.45 US Dollar 53.45 USD
1160US Dollars53.45 53.45 USD
340931cb 116153.45US Dollars 53.45 USD
2ca993e8
A
1162US Dollar53.45 53.45 USD
1163US Dollat53.45 fail USD
340931cb 116453.45US Dollar 53.45 USD
2ca993e8
A
1165
1166
1167test parse currency short
1168set pattern 0.00 \u00a4;(#) \u00a4
0f5d89e8 1169set locale en_GB
2ca993e8
A
1170begin
1171parse output outputCurrency breaks
0f5d89e8
A
117253.45 fail GBP
1173£53.45 53.45 GBP
3d1f044b 1174$53.45 53.45 USD C
2ca993e8 117553.45 USD 53.45 USD
0f5d89e8 117653.45 GBP 53.45 GBP
340931cb
A
1177USD 53.45 53.45 USD
117853.45USD 53.45 USD
2ca993e8
A
1179USD53.45 53.45 USD
1180(7.92) USD -7.92 USD
0f5d89e8 1181(7.92) GBP -7.92 GBP
2ca993e8 1182(7.926) USD -7.926 USD
340931cb
A
1183(7.926 USD) -7.926 USD
1184(USD 7.926) -7.926 USD
1185USD (7.926) -7.926 USD
1186USD (7.92) -7.92 USD
1187(7.92)USD -7.92 USD
1188USD(7.92) -7.92 USD
2ca993e8 1189(8) USD -8 USD
3d1f044b 1190-8 USD -8 USD
2ca993e8 119167 USD 67 USD
340931cb
A
119253.45$ 53.45 USD C
1193US Dollars 53.45 53.45 USD
2ca993e8 119453.45 US Dollars 53.45 USD
340931cb 1195US Dollar 53.45 53.45 USD
2ca993e8
A
119653.45 US Dollar 53.45 USD
1197US Dollars53.45 53.45 USD
340931cb 119853.45US Dollars 53.45 USD
2ca993e8
A
1199US Dollar53.45 53.45 USD
1200US Dollat53.45 fail USD
340931cb 120153.45US Dollar 53.45 USD
2ca993e8
A
1202
1203
1204test parse currency short prefix
1205set pattern \u00a40.00;(\u00a4#)
0f5d89e8 1206set locale en_GB
2ca993e8
A
1207begin
1208parse output outputCurrency breaks
0f5d89e8
A
120953.45 fail GBP
1210£53.45 53.45 GBP
3d1f044b
A
1211$53.45 53.45 USD C
121253.45 USD 53.45 USD
121353.45 GBP 53.45 GBP
340931cb
A
1214USD 53.45 53.45 USD
121553.45USD 53.45 USD
2ca993e8 1216USD53.45 53.45 USD
0f5d89e8 1217// C and P fail these because '(' is an incomplete prefix.
340931cb
A
1218(7.92) USD -7.92 USD CJP
1219(7.92) GBP -7.92 GBP CJP
1220(7.926) USD -7.926 USD CJP
1221(7.926 USD) -7.926 USD CJP
1222(USD 7.926) -7.926 USD
1223USD (7.926) -7.926 USD CJP
1224USD (7.92) -7.92 USD CJP
1225(7.92)USD -7.92 USD CJP
1226USD(7.92) -7.92 USD CJP
1227(8) USD -8 USD CJP
3d1f044b
A
1228-8 USD -8 USD
122967 USD 67 USD
340931cb
A
123053.45$ 53.45 USD C
1231US Dollars 53.45 53.45 USD
2ca993e8 123253.45 US Dollars 53.45 USD
340931cb 1233US Dollar 53.45 53.45 USD
2ca993e8
A
123453.45 US Dollar 53.45 USD
1235US Dollars53.45 53.45 USD
340931cb 123653.45US Dollars 53.45 USD
2ca993e8 1237US Dollar53.45 53.45 USD
340931cb 123853.45US Dollar 53.45 USD
2ca993e8
A
1239
1240test format foreign currency
1241set locale fa_IR
0f5d89e8 1242set currency IRR
2ca993e8
A
1243begin
1244pattern format output breaks
1245\u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 # 1235 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 K
1246\u00a4\u00a4 0.00;\u00a4\u00a4 -# 1235 IRR \u06F1\u06F2\u06F3\u06F5 K
1247\u00a4 0.00;\u00a4 -# 1235 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 K
1248
1249test parse foreign currency symbol
1250set pattern \u00a4 0.00;\u00a4 -#
1251set locale fa_IR
1252begin
0f5d89e8 1253parse output outputCurrency breaks
2ca993e8
A
1254\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1255IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
0f5d89e8 1256// P fails here because this currency name is in the Trie only, but it has the same prefix as the non-Trie currency
3d1f044b 1257\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1258IRR 1235 1235 IRR
1259\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1260\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1261
1262test parse foreign currency ISO
1263set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -#
1264set locale fa_IR
1265begin
0f5d89e8 1266parse output outputCurrency breaks
2ca993e8
A
1267\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1268IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
3d1f044b 1269\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1270IRR 1235 1235 IRR
1271\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1272\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1273
1274test parse foreign currency full
1275set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -#
1276set locale fa_IR
1277begin
0f5d89e8 1278parse output outputCurrency breaks
2ca993e8
A
1279\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1280IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
3d1f044b 1281\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR CJP
2ca993e8
A
1282IRR 1235 1235 IRR
1283\u0631\u06cc\u0627\u0644 1235 1235 IRR
3d1f044b 1284\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR CJP
2ca993e8
A
1285
1286test parse currency with foreign symbols symbol english
1287set pattern \u00a4 0.00;\u00a4 (#)
1288set locale en_US
1289begin
1290parse output outputCurrency
1291EUR 7.82 7.82 EUR
1292\u20ac 7.82 7.82 EUR
1293Euro 7.82 7.82 EUR
1294Euros 7.82 7.82 EUR
1295
1296test parse currency with foreign symbols ISO english
1297set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#)
1298set locale en_US
1299begin
1300parse output outputCurrency
1301EUR 7.82 7.82 EUR
1302\u20ac 7.82 7.82 EUR
1303Euro 7.82 7.82 EUR
1304Euros 7.82 7.82 EUR
1305
1306test parse currency with foreign symbols full english
1307set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#)
1308set locale en_US
1309begin
1310parse output outputCurrency
1311EUR 7.82 7.82 EUR
1312\u20ac 7.82 7.82 EUR
1313Euro 7.82 7.82 EUR
1314Euros 7.82 7.82 EUR
1315
0f5d89e8
A
1316test parse currency without currency mode
1317// Should accept a symbol associated with the currency specified by the API,
1318// but should not traverse the full currency data.
1319set locale en_US
1320set pattern \u00a4#,##0.00
1321begin
1322parse currency output breaks
1323$52.41 USD 52.41
1324USD52.41 USD 52.41 K
1325\u20ac52.41 USD fail
1326EUR52.41 USD fail
1327$52.41 EUR fail
1328USD52.41 EUR fail
1329\u20ac52.41 EUR 52.41 K
1330EUR52.41 EUR 52.41
1331
2ca993e8
A
1332test parse currency ISO strict
1333set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
1334set locale en_US
1335set lenient 0
1336begin
1337parse output outputCurrency breaks
3d1f044b 1338$53.45 53.45 USD CJP
2ca993e8
A
133953.45 USD 53.45 USD
1340USD 53.45 fail USD
134153.45USD fail USD
3d1f044b 1342USD53.45 53.45 USD CJP
2ca993e8
A
1343(7.92) USD -7.92 USD
1344(7.92) EUR -7.92 EUR
1345(7.926) USD -7.926 USD
1346(7.926 USD) fail USD
1347(USD 7.926) fail USD
1348USD (7.926) fail USD
1349USD (7.92) fail USD
1350(7.92)USD fail USD
1351USD(7.92) fail USD
1352(8) USD -8 USD
340931cb 1353-8 USD fail USD
2ca993e8
A
135467 USD 67 USD
135553.45$ fail USD
1356US Dollars 53.45 fail USD
135753.45 US Dollars 53.45 USD
1358US Dollar 53.45 fail USD
135953.45 US Dollar 53.45 USD
3d1f044b 1360US Dollars53.45 53.45 USD CJP
2ca993e8 136153.45US Dollars fail USD
3d1f044b 1362US Dollar53.45 53.45 USD CJP
2ca993e8
A
1363US Dollat53.45 fail USD
136453.45US Dollar fail USD
1365US Dollars (53.45) fail USD
1366(53.45) US Dollars -53.45 USD
1367US Dollar (53.45) fail USD
1368(53.45) US Dollar -53.45 USD
1369US Dollars(53.45) fail USD
1370(53.45)US Dollars fail USD
1371US Dollar(53.45) fail USD
1372US Dollat(53.45) fail USD
1373(53.45)US Dollar fail USD
1374
1375test ticket 10436
1376set locale en
1377set roundingMode ceiling
1378set minFractionDigits 0
1379set maxFractionDigits 0
1380begin
1381format output breaks
340931cb 1382-0.99 -0 K
0f5d89e8
A
1383
1384test parse decimalPatternMatchRequired
1385set locale en
1386set decimalPatternMatchRequired 1
1387begin
1388pattern parse output breaks
1389// K doesn't support this feature.
13900 123 123
340931cb
A
13910 123. fail K
13920 1.23 fail K
0f5d89e8 13930 -513 -513
340931cb
A
13940 -513. fail K
13950 -5.13 fail K
0f5d89e8 13960.0 123 fail K
3d1f044b
A
13970.0 123. 123
13980.0 1.23 1.23
0f5d89e8
A
13990.0 -513 fail K
14000.0 -513. -513
14010.0 -5.13 -5.13
1402
1403test parse minus sign
1404set locale en
1405set pattern #
1406begin
1407pattern parse output breaks
1408# -123 -123
340931cb
A
1409# - 123 -123 K
1410# -123 -123 K
1411# - 123 -123 K
0f5d89e8
A
1412# 123- 123
1413# 123 - 123
1414#;#- 123- -123
340931cb 1415#;#- 123 - -123 K
0f5d89e8
A
1416
1417test parse case sensitive
1418set locale en
1419set lenient 1
1420set pattern Aa#
1421begin
1422parse parseCaseSensitive output breaks
1423Aa1.23 1 1.23
1424Aa1.23 0 1.23
1425AA1.23 1 fail
340931cb
A
1426// K does not support case-insensitive parsing for prefix/suffix.
1427AA1.23 0 1.23 K
0f5d89e8 1428aa1.23 1 fail
340931cb 1429aa1.23 0 1.23 K
0f5d89e8
A
1430Aa1.23E3 1 1230
1431Aa1.23E3 0 1230
340931cb 1432Aa1.23e3 1 1.23
0f5d89e8
A
1433Aa1.23e3 0 1230 K
1434NaN 1 NaN K
1435NaN 0 NaN K
1436nan 1 fail
340931cb 1437nan 0 NaN K
0f5d89e8
A
1438
1439test parse infinity and scientific notation overflow
1440set locale en
1441set lenient 1
1442begin
1443parse output breaks
1444NaN NaN K
1445// JDK returns zero
14461E999999999999999 Inf K
1447-1E999999999999999 -Inf K
14481E-99999999999999 0.0
1449// Note: The test suite code doesn't properly check for 0.0 vs. -0.0
1450-1E-99999999999999 -0.0
14511E2147483648 Inf K
14521E2147483647 Inf K
340931cb
A
1453// J and K get Infinity
14541E2147483646 1E+2147483646 JK
0f5d89e8
A
14551E-2147483649 0
14561E-2147483648 0
340931cb
A
1457// K returns zero here
14581E-2147483647 1E-2147483647 JK
14591E-2147483646 1E-2147483646 JK
0f5d89e8
A
1460
1461test format push limits
1462set locale en
1463set minFractionDigits 2
1464set roundingMode halfDown
1465begin
1466maxFractionDigits format output breaks
1467100 987654321987654321 987654321987654321.00
1468100 987654321.987654321 987654321.987654321
1469100 9999999999999.9950000000001 9999999999999.9950000000001
14702 9999999999999.9950000000001 10000000000000.00
14712 9999999.99499999 9999999.99
1472// K doesn't support halfDown rounding mode?
14732 9999999.995 9999999.99 K
14742 9999999.99500001 10000000.00
1475100 56565656565656565656565656565656565656565656565656565656565656 56565656565656565656565656565656565656565656565656565656565656.00
1476100 454545454545454545454545454545.454545454545454545454545454545 454545454545454545454545454545.454545454545454545454545454545
1477100 0.0000000000000000000123 0.0000000000000000000123
1478100 -78787878787878787878787878787878 -78787878787878787878787878787878.00
1479100 -8989898989898989898989.8989898989898989 -8989898989898989898989.8989898989898989
1480
1481test ticket 11230
1482set locale en
1483begin
1484pattern lenient parse output breaks
1485// Groups after the first group need 2 digits to be accepted.
1486// JDK does not see space as grouping and parses most of these as 9.
340931cb 1487#,##0 1 9 9 9
0f5d89e8
A
1488#,##0 1 9 99 999 K
1489#,##0 1 9 999 9999 K
340931cb 1490#,##0 1 9 9 9 9
0f5d89e8
A
1491#,##0 1 ,9 9
1492#,##0 1 99,.0 99
340931cb 1493#,##0 1 9 9. 9
0f5d89e8
A
1494#,##0 1 9 99. 999 K
14950 1 9 9 9
14960 1 9 99 9
14970 1 9 999 9
14980 1 9 9 9 9
14990 1 ,9 fail
15000 1 99,.0 99
15010 1 9 9. 9
15020 1 9 99. 9
1503#,##0 0 9 9 fail K
1504#,##0 0 9 99 fail K
1505#,##0 0 9 999 9999 K
1506#,##0 0 9 9 9 fail K
1507#,##0 0 ,9 fail K
1508#,##0 0 99,.0 fail K
1509#,##0 0 9 9. fail K
1510#,##0 0 9 99. fail K
15110 0 9 9 9
15120 0 9 99 9
15130 0 9 999 9
15140 0 9 9 9 9
15150 0 ,9 fail
15160 0 99,.0 99
15170 0 9 9. 9
15180 0 9 99. 9
1519
1520test more strict grouping parse
1521set locale en
1522set pattern #,##,##0
1523begin
1524lenient parse output breaks
15251 1,23,, 123
15260 9999, 9999
15270 1,23,, fail K
1528
1529test parse ignorables
1530set locale ar
1531// Note: Prefixes contain RLMs, as do some of the test cases.
1532set pattern x a‎b0c df
1533set negativePrefix y g‎h
1534set negativeSuffix i jk
1535begin
1536parse output breaks
1537x a‎b56c df 56
1538x a‎b56c df 56 K
1539x ab56c df 56 K
340931cb 1540x ab56c df 56 K
0f5d89e8 1541x ab56c df 56 K
340931cb
A
1542x ab56 56 K
1543x a b56 56 K
154456cdf 56 K
154556c df 56 K
154656cd f 56 K
154756c‎d‎f 56 K
154856cdf 56 K
154956c d‎f 56 K
155056‎c df 56 K
0f5d89e8
A
1551y g‎h56i jk -56
1552y g‎h56i jk -56 K
1553y gh56i jk -56 K
340931cb 1554y gh56i jk -56 K
0f5d89e8 1555y gh56i jk -56 K
340931cb
A
1556y gh56 -56 K
1557y g h56 -56 K
0f5d89e8
A
1558// S stops parsing after the 'i' for these and returns -56
1559// C stops before the 'i' and gets 56
340931cb
A
156056ijk -56 K
156156i jk -56 K
156256ij k -56 K
156356i‎j‎k -56 K
156456ijk -56 K
156556i j‎k -56 K
156656‎i jk -56 K
1567// S and C get 56 (accepts ' ' gs grouping); K gets null
0f5d89e8 15685 6 fail CJP
340931cb 15695‎6 5 K
0f5d89e8
A
1570
1571test parse spaces in grouping
1572// This test gives the ideal behavior of these cases, which
1573// none of the implementations currently support.
1574// Similar to the test above for ticket #11230
1575set locale en
1576set pattern #,##0
1577begin
1578parse output breaks
340931cb 15791 2 1
0f5d89e8
A
15801 23 123 K
1581// K gets 1 here; doesn't pick up the grouping separator
15821 234 1234 K
1583
1584test rounding increment significant digits
1585// This test is for #13111
1586set locale en
1587set pattern 0.1
1588set useSigDigits 1
1589set maxSigDigits 2
1590begin
1591format output breaks
1592// C and J get "1"
1593// P gets "1.0"
1594// K gets "1.1" (??)
340931cb 15950.975 0.98 CJKP
0f5d89e8
A
1596
1597test lenient parse currency match
1598// This test is for #13112
1599set locale en
1600set pattern ¤#,##0.00
1601begin
1602parse output breaks
340931cb
A
1603// K gets null
16041.23!@#$%^ 1.23 K
0f5d89e8
A
1605
1606test percentage parsing multiplier
1607// This test is for #13114
1608set locale en
1609set pattern 0%
1610begin
1611parse output breaks
161255% 0.55
340931cb 1613// K gets null
0f5d89e8 1614// C and P scale by 100 even if the percent sign is not present
340931cb 161555 0.55 K
0f5d89e8
A
1616
1617test trailing grouping separators in pattern
1618// This test is for #13115
1619set locale en
1620begin
1621pattern format output breaks
1622$0M 123456 $123456M
1623// The following patterns are rejected as malformed.
1624$0,M 123456 fail
1625$0,,M 123456 fail
1626
1627test empty negative subpattern
1628// This test is for #13117
1629set locale en
1630begin
1631pattern format output breaks
16320 -15 -15
16330; -15 -15
340931cb
A
1634// K still prepends a '-' even though the pattern says otherwise
16350;0 -15 15 K
0f5d89e8
A
1636
1637test percentage multiplier parsing
1638// This test is for #13129
1639set locale en
1640set pattern 0%
1641begin
1642parse output breaks
16439223372036854775807% 92233720368547758.07 K
1644
1645test sign always shown
1646set locale en
1647set pattern 0
1648set signAlwaysShown 1
1649begin
1650format output breaks
340931cb
A
1651// K does not support this feature
165242 +42 K
16530 +0 K
0f5d89e8
A
1654-42 -42
1655
1656test parse strict with plus sign
1657set locale en
1658set pattern 0
1659set signAlwaysShown 1
1660begin
1661lenient parse output breaks
16621 42 42
16631 -42 -42
340931cb 16641 +42 42 K
0f5d89e8 16651 0 0
340931cb
A
16661 +0 0 K
16670 42 fail K
0f5d89e8 16680 -42 -42
340931cb
A
16690 +42 42 K
16700 0 fail K
16710 +0 0 K
0f5d89e8
A
1672
1673test parse with scientific-separator-affix overlap
1674set locale en
1675begin
1676pattern lenient parse output breaks
16770E0','x 1 5E3,x 5000
16780E0','x 0 5E3,x 5000
16790E0'.'x 1 5E3.x 5000
16800E0'.'x 0 5E3.x 5000
1681
3d1f044b
A
1682test parse() lowercase currency
1683set locale en
1684set pattern ¤¤0
1685set currency USD
1686begin
1687parse output breaks
1688USD123 123
340931cb 1689USD 123 123 K
3d1f044b 1690usd123 123 K
340931cb 1691usd 123 123 K
3d1f044b 1692Usd123 123 K
340931cb 1693Usd 123 123 K
3d1f044b 1694// US$ is not used for US dollars in en-US
340931cb 1695US$123 fail
3d1f044b
A
1696us$123 fail
1697Us$123 fail
1698123 US dollars 123 K
1699123 US DOLLARS 123 K
1700123 us dollars 123 K
1701// Foreign currencies are not accepted in .parse()
1702GBP123 fail
1703gbp123 fail
1704British pounds 123 fail
1705british POUNDS 123 fail
1706
1707test parseCurrency() lowercase currency
0f5d89e8
A
1708set locale en
1709set pattern ¤¤0
1710set currency USD
1711begin
1712parse output outputCurrency breaks
1713USD123 123 USD
340931cb 1714USD 123 123 USD
3d1f044b 1715usd123 123 USD
340931cb 1716usd 123 123 USD
3d1f044b 1717Usd123 123 USD
340931cb 1718Usd 123 123 USD
0f5d89e8
A
1719US$123 123 USD C
1720us$123 fail fail
1721Us$123 fail fail
1722123 US dollars 123 USD
1723123 US DOLLARS 123 USD
1724123 us dollars 123 USD
3d1f044b
A
1725GBP123 123 GBP
1726gbp123 123 GBP C
340931cb
A
1727British pounds 123 123 GBP
1728british POUNDS 123 123 GBP
0f5d89e8 1729
340931cb
A
1730test parse scientific with bidi marks
1731begin
1732locale parse output breaks
1733en 4E\u200E+02 400 K
1734en 4E+02 400 K
1735he 4E\u200E+02 400 K
1736he 4E+02 400 K
0f5d89e8
A
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
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
2ca993e8 1776