1 // Copyright (C) 2015-2016, International Business Machines
2 // Corporation and others. All Rights Reserved.
4 // This file is divided into test suites separated by whitespace. Each test
5 // suite starts with the name of the test followed by global field settings
6 // for that test suite. After the global settings, comes "begin", the
7 // per-test field names, and finally the test specific field values, 1 test
9 // For more information on the format of this file, including all the available
10 // field names, please see
11 // https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
26 #,##0.## 1\u00a0234,57
29 #,##0.### 1\u00a0234,567
33 #,##0.00 \u00a4 1\u00a0234,57 \u20ac
34 'tick''bitten '0.00 tick'bitten 1234,57
35 'tick' 'bitten '0.00 tick bitten 1234,57
38 test minimum and maximum fraction digits
40 set minIntegerDigits 2
41 set maxIntegerDigits 4
42 set minFractionDigits 3
43 set maxFractionDigits 5
49 1002003004005 4005.000
50 -1002003004005 -4005.000
59 1002003004005 1002003004005
60 -1002003004005 -1002003004005
65 pattern format output breaks
75 #,#3.70 104.0 1\u00a003,60 K
77 test significant digits
93 test scientific notation
96 pattern format output breaks
98 000.00E0 12300 123,00E2
99 000.0#E0 12300 123,0E2
100 000.0#E0 12300.1 123,0E2
101 000.0#E0 12301.0 123,01E2
102 // JDK does not support exponent signs
103 000.0#E+00 12301.0 123,01E+02 K
104 // JDK gives 12,345E3. JDK seems to include the hashes in significant digits
105 ##0.00E0 12345 12,3E3 K
106 // JDK gives 12,3001E3
107 ##0.0000E0 12300.1 12,300E3 K
108 // JDK gives 12,3001E3
109 ##0.000#E0 12300.1 12,30E3 K
110 ##0.000#E0 12301 12,301E3
111 0.05E0 12301.2 1,25E4 JK
112 ##0.000#E0 0.17 170,0E-3
113 // JDK doesn't support significant digits in exponents
116 @@@#E0 6201 6,201E3 K
117 @@@#E0 6201.7 6,202E3 K
118 @@@#E00 6201.7 6,202E03 K
119 @@@#E+00 6201.7 6,202E+03 K
124 pattern format output breaks
128 p'%'p0.0 0.573 p%p0,6
129 %@@@@ 0.0326 %3,260 K
130 %#,@@@ 15.43 %1\u00a0540 K
131 // JDK does not support rounding increments
132 %#,##4.1 16.55 %1\u00a0656,4 K
133 // JDK gives %16,255E3
134 %##0.00E0 162.55 %16,3E3 K
139 pattern format output breaks
140 0.0\u2030 0.573 573,0‰
141 \u20300.0 0.573 \u2030573,0
142 p\u2030p0.0 0.573 p\u2030p573,0
143 p'\u2030'p0.0 0.573 p\u2030p0,6
144 \u2030@@@@ 0.0326 \u203032,60 K
145 \u2030#,@@@ 15.43 \u203015\u00a0400 K
146 \u2030#,##4.1 16.55 \u203016\u00a0551,7 K
147 // JDK gives \u2030162,55E3
148 \u2030##0.00E0 162.55 \u2030163E3 K
153 pattern format output breaks
154 // JDK does not seem to support padding
155 $**####,##0 1234 $***1\u00a0234 K
156 *x$####,##0 1234 xxx$1\u00a0234 K
157 ####,##0*x$ 1234 1\u00a0234xxx$ K
158 ####,##0$*x 1234 1\u00a0234$xxx K
159 // JDK doesn't seem to handle suffixes correctly dropping the 'nx' entirely
160 ####,##0$*x;ne#n -1234 ne1\u00a0234nx K
161 ####,##0$*x;n#'*' -1234 n1\u00a0234*xx K
162 *y%4.2###### 4.33 yyyy%432,6 K
163 // In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
164 \u00a4\u00a4 **####0.00 433.0 EUR *433,00 JK
165 // In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
166 \u00a4\u00a4 **#######0 433.0 EUR *433,00 JK
168 test padding and currencies
170 locale currency pattern format output breaks
171 // In J, JPY is considered 2 char (2 * 0xa4) even though padding is done
172 // after prefix. In C this test works.
173 fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 JK
174 // JDK doesn't correct rounding for currency, shows USD (433
175 en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K
181 pattern currency output breaks
182 // JDK gives shows EUR instead of the euro symbol in this case
183 #,##0.00 \u00a4 EUR 1\u00a0234,57 \u20ac K
184 // JDK gives 1\u00A0234,57. JDK doesn't seem to correct rounding
185 // based on currency.
186 #,##0.00 \u00a4 JPY 1\u00a0235 JPY K
188 test prefixes and suffixes
190 set pattern 0.00+;(#)
194 // JDK does not support negative suffixes
197 test minimum grouping digits
200 set minGroupingDigits 2
203 // min grouping digits not supported in any existing implementation
204 // but could be easily added to the new DecimalFormat C code.
210 test min max fraction digits
212 set pattern #,##0.###
215 minFractionDigits maxFractionDigits output
220 test min max integer digits
222 set pattern #,##0.###
225 minIntegerDigits maxIntegerDigits output
230 test min max fraction digits scientific
233 set format 299792458.0
235 minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
236 // JDK gives .3E9 instead of unlimited precision.
237 0 1 0 0 2.99792458E8 K
239 // JDK gives E0 instead of allowing for unlimited precision
240 0 0 0 0 2.99792458E8 K
241 // JDK gives .299792E9
244 0 3 0 0 299.792458E6 K
245 // JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)?
247 // JDK gives 299.7925E6
249 // JDK gives 299.79246E6
257 0 0 1 0 2.99792458E8 K
260 // JDK uses 8 + 6 for significant digits instead of 2 + 6
261 2 8 1 6 2.9979246E8 K
262 // Treat max int digits > 8 as being the same as min int digits.
263 // This behavior is not spelled out in the specification.
264 // JDK fails here because it tries to use 9 + 6 = 15 sig digits.
265 2 9 1 6 29.979246E7 K
267 test significant digits scientific
270 set format 290000000.0
272 minSigDigits maxSigDigits output breaks
284 test min max fraction digits scientific 2
287 set format 29979245.0
289 minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
291 0 0 0 0 2.9979245E7 K
293 0 1 0 0 2.9979245E7 K
295 0 4 0 0 2997.9245E4 K
299 set pattern #,##0.###
301 format maxIntegerDigits output
309 test patterns with zero
322 test significant digits manually set
333 0.0012345 0.0012345 K
334 0.00123456 0.0012346 K
341 test grouping used setters
351 test grouping setters
357 output grouping breaks grouping2 minGroupingDigits
364 test multiplier setters
367 format multiplier output breaks
370 // ICU4J and JDK throw exception on zero multiplier. ICU4C does not.
377 test rounding setters
380 set roundingIncrement 0.25
394 padCharacter formatWidth output breaks
399 test use scientific setter
404 output breaks useScientific
409 test rounding mode setters
412 set roundingIncrement 0.5
414 format roundingMode output breaks
427 test currency usage setters
428 // TODO: Find a country and currency where standard and cash differ
431 set pattern \u00a4\u00a4 0
433 format currencyUsage output breaks
434 0.37 standard CHF 0.37 K
435 // TODO: Get the rounding data into ICU4C and ICU4J
436 0.37 cash CHF 0.35 CJK
438 test exponent parameter setters
443 decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks
446 // ICU DecimalFormat J does not honor decimalSeparatorAlwaysShown
447 // for scientific notation. But JDK DecimalFormat does honor
448 // decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J
455 test exponent decimalSeparatorAlwaysShown default
459 format output breaks decimalSeparatorAlwaysShown
460 // decimalSeparatorAlwaysShown off by default
465 test pad position setters
467 set pattern **[#####0.##];((#))
469 format padPosition output breaks
470 12.34 beforePrefix ****[12.34] K
471 12.34 afterPrefix [****12.34] K
472 12.34 beforeSuffix [12.34****] K
473 12.34 afterSuffix [12.34]**** K
474 -12.34 beforePrefix **((12.34)) K
475 -12.34 afterPrefix ((**12.34)) K
476 -12.34 beforeSuffix ((12.34**)) K
477 -12.34 afterSuffix ((12.34))** K
484 format positivePrefix positiveSuffix negativePrefix negativeSuffix output
486 12.34 \u00a4\u00a4 12,34\u00a4\u00a4
489 -12.34 \u00a4 \u00a412,34
494 test more affix setters
498 format positivePrefix negativePrefix output
499 0.648 booya cooya booya64,80
501 test nan and infinity
503 set pattern [0.00];(#)
510 test nan and infinity with multiplication
519 test nan and infinity with padding
524 format padPosition output breaks
525 Inf beforePrefix $$$\u221e$ K
526 Inf afterPrefix $$$ \u221e$ K
527 Inf beforeSuffix $$$\u221e $ K
528 Inf afterSuffix $$$\u221e$ K
529 NaN beforePrefix NaN K
530 NaN afterPrefix NaN K
531 NaN beforeSuffix NaN K
532 NaN afterSuffix NaN K
534 test apply localized patterns
536 locale localizedPattern format output breaks
538 // This next test breaks JDK. JDK doesn't multiply by 100.
539 fa \u06f0\u066a 0.4376 \u06f4\u06f4\u066a K
544 pattern toPattern breaks
545 // JDK doesn't support any patterns with padding or both negative prefix and suffix
546 // Breaks ICU4J See ticket 11671
548 **##0,000 **##0,000 K
549 **###0,000 **###0,000 K
550 **####0,000 **#,##0,000 K
559 // No secondary grouping in JDK
560 #,##,###.02500 #,##,###.02500 K
561 pp#,000;(#) pp#,000;(#,000) K
562 **####,##,##0.0##;(#) **#,##,##,##0.0##;**(##,##,##0.0##) K
563 // No significant digits in JDK
568 ###0.00#E0 ###0.00#E0
569 ##00.00#E0 ##00.00#E0
572 ###0.00#E00 ###0.00#E00
576 set pattern +#,##0.0###;(#)
585 // J requires prefix and suffix for lenient parsing, but C doesn't
591 // JDK stops parsing at the spaces. JDK doesn't see space as a grouping separator
594 // J doesn't allow trailing separators before E but C does
595 (34,,25,E-1) -342.5 J
596 (34 25 E-1) -342.5 JK
598 // Spaces are not allowed after exponent symbol
599 // C parses up to the E but J bails
602 +1,234,567.8901 1234567.8901
603 +1,23,4567.8901 1234567.8901
604 +1,23,4567.89,01 1234567.89
605 +1,23,456.78.9 123456.78
609 // Parsing stops at comma as it is different from other separators
615 // Whitespace immediately after prefix doesn't count as digit separator
616 // in C but is does in J
619 // C allows trailing separators when there is a prefix and suffix.
620 // J allows trailing separators only when there is just a prefix.
621 // In this case, J just bails
624 // C parses to the space, but J bails
626 // J bails b/c comma different separator than space. C doesn't treat leading spaces
629 // J bails. Doesn't allow trailing separators when there is prefix and suffix.
631 // J bails on next 4 because J doesn't allow letters inside prefix and suffix.
632 // C will parse up to the letter.
637 // J does allow trailing separator before a decimal point
639 // 2nd decimal points are ignored
644 set pattern #,##0.0###+;#-
647 // C sees this as -3426, don't understand why
650 // J bails, but JDK will parse up to the space and get 34.
653 // JDK sees this as -1234 for some reason
654 // J bails b/c of trailing separators
655 // C parses until trailing separators, but sees -1234
658 // J bails because of trailing separators
667 set pattern +#,##0.0###;(#)
673 // separators in wrong place cause failure, no separators ok.
677 // JDK does allow separators in the wrong place and parses as -5347.25
679 // strict requires prefix or suffix
684 // Strict doesn't allow separators in sci notation.
686 // JDK allows separators in sci notation and parses as -342.5
688 // Both prefix and suffix needed for strict.
689 // JDK accepts this and parses as -342.5
692 +1,234,567.8901 1234567.8901
693 // With strict digit separators don't have to be the right type
694 // JDK doesn't acknowledge space as a separator
695 +1 234 567.8901 1234567.8901 K
696 // In general the grouping separators have to match their expected
697 // location exactly. The only exception is when string being parsed
698 // have no separators at all.
699 +1,234,567.8901 1234567.8901
700 // JDK doesn't require separators to be in the right place
701 +1,23,4567.8901 fail K
702 +1234,567.8901 fail K
703 +1,234567.8901 fail K
704 +1234567.8901 1234567.8901
705 // Comma after decimal means parse to a comma
706 +123,456.78,9 123456.78
707 // A decimal after a decimal means bail
708 // JDK parses as 123456.78
713 // JDK parses as -1945
716 test parse integer only
719 set parseIntegerOnly 1
728 test parse no exponent flag
732 parseNoExponent parse output breaks
733 // JDK doesn't allow lowercase exponent but ICU4J and ICU4C do.
740 test parse currency fail
744 parse output outputCurrency breaks
748 test parse strange prefix
750 set positivePrefix dd
751 set negativePrefix ddd
757 test parse strange suffix
759 set positiveSuffix dd
761 set negativeSuffix ddd
767 test really strange suffix
769 set positiveSuffix 9K
771 set negativeSuffix 9N
774 // C consumes the '9' as a digit and assumes number is negative
777 // C consumes the '9' as a digit and assumes number is negative
781 test really strange prefix
783 set positivePrefix 82
784 set negativePrefix 28
793 format pattern plural
808 test parse currency ISO
809 set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
812 parse output outputCurrency breaks
815 USD 53.45 53.45 USD J
820 (7.926) USD -7.926 USD
831 US Dollars 53.45 53.45 USD J
832 53.45 US Dollars 53.45 USD
833 US Dollar 53.45 53.45 USD J
834 53.45 US Dollar 53.45 USD
835 US Dollars53.45 53.45 USD
836 53.45US Dollars fail USD
837 US Dollar53.45 53.45 USD
838 US Dollat53.45 fail USD
839 53.45US Dollar fail USD
840 US Dollars (53.45) fail USD
841 (53.45) US Dollars -53.45 USD
842 US Dollar (53.45) fail USD
843 (53.45) US Dollar -53.45 USD
844 US Dollars(53.45) fail USD
845 (53.45)US Dollars fail USD
846 US Dollar(53.45) fail USD
847 US Dollat(53.45) fail USD
848 (53.45)US Dollar fail USD
851 test parse currency ISO negative
852 set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4
855 parse output outputCurrency breaks
858 USD 53.45 53.45 USD J
863 -7.926 USD -7.926 USD
870 US Dollars 53.45 53.45 USD J
871 53.45 US Dollars 53.45 USD
872 US Dollar 53.45 53.45 USD J
873 53.45 US Dollar 53.45 USD
874 US Dollars53.45 53.45 USD
875 53.45US Dollars fail USD
876 US Dollar53.45 53.45 USD
877 US Dollat53.45 fail USD
878 53.45US Dollar fail USD
881 test parse currency long
882 set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4
885 parse output outputCurrency breaks
888 USD 53.45 53.45 USD J
893 (7.926) USD -7.926 USD
906 US Dollars 53.45 53.45 USD J
907 53.45 US Dollars 53.45 USD
908 US Dollar 53.45 53.45 USD J
909 53.45 US Dollar 53.45 USD
910 US Dollars53.45 53.45 USD
912 53.45US Dollars fail USD J
913 US Dollar53.45 53.45 USD
914 US Dollat53.45 fail USD
916 53.45US Dollar fail USD J
919 test parse currency short
920 set pattern 0.00 \u00a4;(#) \u00a4
923 parse output outputCurrency breaks
926 USD 53.45 53.45 USD J
930 (7.926) USD -7.926 USD
941 US Dollars 53.45 53.45 USD J
942 53.45 US Dollars 53.45 USD
943 US Dollar 53.45 53.45 USD J
944 53.45 US Dollar 53.45 USD
945 US Dollars53.45 53.45 USD
946 53.45US Dollars fail USD
947 US Dollar53.45 53.45 USD
948 US Dollat53.45 fail USD
949 53.45US Dollar fail USD
952 test parse currency short prefix
953 set pattern \u00a40.00;(\u00a4#)
956 parse output outputCurrency breaks
959 USD 53.45 53.45 USD J
965 (USD 7.926) -7.926 USD J
974 US Dollars 53.45 53.45 USD J
975 53.45 US Dollars 53.45 USD
976 US Dollar 53.45 53.45 USD J
977 53.45 US Dollar 53.45 USD
978 US Dollars53.45 53.45 USD
979 53.45US Dollars fail USD
980 US Dollar53.45 53.45 USD
981 53.45US Dollar fail USD
983 test format foreign currency
986 pattern format output breaks
987 \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 # 1235 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 K
988 \u00a4\u00a4 0.00;\u00a4\u00a4 -# 1235 IRR \u06F1\u06F2\u06F3\u06F5 K
989 \u00a4 0.00;\u00a4 -# 1235 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 K
991 test parse foreign currency symbol
992 set pattern \u00a4 0.00;\u00a4 -#
995 parse output outputCurrency
996 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
997 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
998 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1000 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1001 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1003 test parse foreign currency ISO
1004 set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -#
1007 parse output outputCurrency
1008 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1009 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
1010 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1012 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1013 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1015 test parse foreign currency full
1016 set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -#
1019 parse output outputCurrency
1020 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1021 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
1022 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1024 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1025 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1027 test parse currency with foreign symbols symbol english
1028 set pattern \u00a4 0.00;\u00a4 (#)
1031 parse output outputCurrency
1033 \u20ac 7.82 7.82 EUR
1037 test parse currency with foreign symbols ISO english
1038 set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#)
1041 parse output outputCurrency
1043 \u20ac 7.82 7.82 EUR
1047 test parse currency with foreign symbols full english
1048 set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#)
1051 parse output outputCurrency
1053 \u20ac 7.82 7.82 EUR
1057 test parse currency ISO strict
1058 set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
1062 parse output outputCurrency breaks
1068 (7.92) USD -7.92 USD
1069 (7.92) EUR -7.92 EUR
1070 (7.926) USD -7.926 USD
1071 (7.926 USD) fail USD
1072 (USD 7.926) fail USD
1073 USD (7.926) fail USD
1081 US Dollars 53.45 fail USD
1082 53.45 US Dollars 53.45 USD
1083 US Dollar 53.45 fail USD
1084 53.45 US Dollar 53.45 USD
1085 US Dollars53.45 53.45 USD
1086 53.45US Dollars fail USD
1087 US Dollar53.45 53.45 USD
1088 US Dollat53.45 fail USD
1089 53.45US Dollar fail USD
1090 US Dollars (53.45) fail USD
1091 (53.45) US Dollars -53.45 USD
1092 US Dollar (53.45) fail USD
1093 (53.45) US Dollar -53.45 USD
1094 US Dollars(53.45) fail USD
1095 (53.45)US Dollars fail USD
1096 US Dollar(53.45) fail USD
1097 US Dollat(53.45) fail USD
1098 (53.45)US Dollar fail USD
1102 set roundingMode ceiling
1103 set minFractionDigits 0
1104 set maxFractionDigits 0
1106 format output breaks