1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 // Copyright (C) 2015-2016, International Business Machines
4 // Corporation and others. All Rights Reserved.
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
11 // For more information on the format of this file, including all the available
12 // field names, please see
13 // https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
28 #,##0.## 1\u00a0234,57
31 #,##0.### 1\u00a0234,567
35 #,##0.00 \u00a4 1\u00a0234,57 \u20ac
36 'tick''bitten '0.00 tick'bitten 1234,57
37 'tick' 'bitten '0.00 tick bitten 1234,57
40 test minimum and maximum fraction digits
42 set minIntegerDigits 2
43 set maxIntegerDigits 4
44 set minFractionDigits 3
45 set maxFractionDigits 5
51 1002003004005 4005.000
52 -1002003004005 -4005.000
61 1002003004005 1002003004005
62 -1002003004005 -1002003004005
67 pattern format output breaks
77 #,#3.70 104.0 1\u00a003,60 K
79 test significant digits
95 test scientific notation
98 pattern format output breaks
100 000.00E0 12300 123,00E2
101 000.0#E0 12300 123,0E2
102 000.0#E0 12300.1 123,0E2
103 000.0#E0 12301.0 123,01E2
104 // JDK does not support exponent signs
105 000.0#E+00 12301.0 123,01E+02 K
106 // JDK gives 12,345E3. JDK seems to include the hashes in significant digits
107 ##0.00E0 12345 12,3E3 K
108 // JDK gives 12,3001E3
109 ##0.0000E0 12300.1 12,300E3 K
110 // JDK gives 12,3001E3
111 ##0.000#E0 12300.1 12,30E3 K
112 ##0.000#E0 12301 12,301E3
113 0.05E0 12301.2 1,25E4 JK
114 ##0.000#E0 0.17 170,0E-3
115 // JDK doesn't support significant digits in exponents
118 @@@#E0 6201 6,201E3 K
119 @@@#E0 6201.7 6,202E3 K
120 @@@#E00 6201.7 6,202E03 K
121 @@@#E+00 6201.7 6,202E+03 K
126 pattern format output breaks
130 p'%'p0.0 0.573 p%p0,6
131 %@@@@ 0.0326 %3,260 K
132 %#,@@@ 15.43 %1\u00a0540 K
133 // JDK does not support rounding increments
134 %#,##4.1 16.55 %1\u00a0656,4 K
135 // JDK gives %16,255E3
136 %##0.00E0 162.55 %16,3E3 K
141 pattern format output breaks
142 0.0\u2030 0.573 573,0‰
143 \u20300.0 0.573 \u2030573,0
144 p\u2030p0.0 0.573 p\u2030p573,0
145 p'\u2030'p0.0 0.573 p\u2030p0,6
146 \u2030@@@@ 0.0326 \u203032,60 K
147 \u2030#,@@@ 15.43 \u203015\u00a0400 K
148 \u2030#,##4.1 16.55 \u203016\u00a0551,7 K
149 // JDK gives \u2030162,55E3
150 \u2030##0.00E0 162.55 \u2030163E3 K
155 pattern format output breaks
156 // JDK does not seem to support padding
157 $**####,##0 1234 $***1\u00a0234 K
158 *x$####,##0 1234 xxx$1\u00a0234 K
159 ####,##0*x$ 1234 1\u00a0234xxx$ K
160 ####,##0$*x 1234 1\u00a0234$xxx K
161 // JDK doesn't seem to handle suffixes correctly dropping the 'nx' entirely
162 ####,##0$*x;ne#n -1234 ne1\u00a0234nx K
163 ####,##0$*x;n#'*' -1234 n1\u00a0234*xx K
164 *y%4.2###### 4.33 yyyy%432,6 K
165 // In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
166 \u00a4\u00a4 **####0.00 433.0 EUR *433,00 JK
167 // In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
168 \u00a4\u00a4 **#######0 433.0 EUR *433,00 JK
170 test padding and currencies
172 locale currency pattern format output breaks
173 // In J, JPY is considered 2 char (2 * 0xa4) even though padding is done
174 // after prefix. In C this test works.
175 fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 JK
176 // JDK doesn't correct rounding for currency, shows USD (433
177 en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K
183 pattern currency output breaks
184 // JDK gives shows EUR instead of the euro symbol in this case
185 #,##0.00 \u00a4 EUR 1\u00a0234,57 \u20ac K
186 // JDK gives 1\u00A0234,57. JDK doesn't seem to correct rounding
187 // based on currency.
188 #,##0.00 \u00a4 JPY 1\u00a0235 JPY K
190 test prefixes and suffixes
192 set pattern 0.00+;(#)
196 // JDK does not support negative suffixes
199 test minimum grouping digits
202 set minGroupingDigits 2
205 // min grouping digits not supported in any existing implementation
206 // but could be easily added to the new DecimalFormat C code.
212 test min max fraction digits
214 set pattern #,##0.###
217 minFractionDigits maxFractionDigits output
222 test min max integer digits
224 set pattern #,##0.###
227 minIntegerDigits maxIntegerDigits output
232 test min max fraction digits scientific
235 set format 299792458.0
237 minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
238 // JDK gives .3E9 instead of unlimited precision.
239 0 1 0 0 2.99792458E8 K
241 // JDK gives E0 instead of allowing for unlimited precision
242 0 0 0 0 2.99792458E8 K
243 // JDK gives .299792E9
246 0 3 0 0 299.792458E6 K
247 // JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)?
249 // JDK gives 299.7925E6
251 // JDK gives 299.79246E6
259 0 0 1 0 2.99792458E8 K
262 // JDK uses 8 + 6 for significant digits instead of 2 + 6
263 2 8 1 6 2.9979246E8 K
264 // Treat max int digits > 8 as being the same as min int digits.
265 // This behavior is not spelled out in the specification.
266 // JDK fails here because it tries to use 9 + 6 = 15 sig digits.
267 2 9 1 6 29.979246E7 K
269 test significant digits scientific
272 set format 290000000.0
274 minSigDigits maxSigDigits output breaks
286 test min max fraction digits scientific 2
289 set format 29979245.0
291 minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
293 0 0 0 0 2.9979245E7 K
295 0 1 0 0 2.9979245E7 K
297 0 4 0 0 2997.9245E4 K
301 set pattern #,##0.###
303 format maxIntegerDigits output
311 test patterns with zero
324 test significant digits manually set
335 0.0012345 0.0012345 K
336 0.00123456 0.0012346 K
343 test grouping used setters
353 test grouping setters
359 output grouping breaks grouping2 minGroupingDigits
366 test multiplier setters
369 format multiplier output breaks
372 // ICU4J and JDK throw exception on zero multiplier. ICU4C does not.
379 test rounding setters
382 set roundingIncrement 0.25
396 padCharacter formatWidth output breaks
401 test use scientific setter
406 output breaks useScientific
411 test rounding mode setters
414 set roundingIncrement 0.5
416 format roundingMode output breaks
429 test currency usage setters
430 // TODO: Find a country and currency where standard and cash differ
433 set pattern \u00a4\u00a4 0
435 format currencyUsage output breaks
436 0.37 standard CHF 0.37 K
437 // TODO: Get the rounding data into ICU4C and ICU4J
438 0.37 cash CHF 0.35 CJK
440 test exponent parameter setters
445 decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks
448 // ICU DecimalFormat J does not honor decimalSeparatorAlwaysShown
449 // for scientific notation. But JDK DecimalFormat does honor
450 // decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J
457 test exponent decimalSeparatorAlwaysShown default
461 format output breaks decimalSeparatorAlwaysShown
462 // decimalSeparatorAlwaysShown off by default
467 test pad position setters
469 set pattern **[#####0.##];((#))
471 format padPosition output breaks
472 12.34 beforePrefix ****[12.34] K
473 12.34 afterPrefix [****12.34] K
474 12.34 beforeSuffix [12.34****] K
475 12.34 afterSuffix [12.34]**** K
476 -12.34 beforePrefix **((12.34)) K
477 -12.34 afterPrefix ((**12.34)) K
478 -12.34 beforeSuffix ((12.34**)) K
479 -12.34 afterSuffix ((12.34))** K
486 format positivePrefix positiveSuffix negativePrefix negativeSuffix output
488 12.34 \u00a4\u00a4 12,34\u00a4\u00a4
491 -12.34 \u00a4 \u00a412,34
496 test more affix setters
500 format positivePrefix negativePrefix output
501 0.648 booya cooya booya64,80
503 test nan and infinity
505 set pattern [0.00];(#)
512 test nan and infinity with multiplication
521 test nan and infinity with padding
526 format padPosition output breaks
527 Inf beforePrefix $$$\u221e$ K
528 Inf afterPrefix $$$ \u221e$ K
529 Inf beforeSuffix $$$\u221e $ K
530 Inf afterSuffix $$$\u221e$ K
531 NaN beforePrefix NaN K
532 NaN afterPrefix NaN K
533 NaN beforeSuffix NaN K
534 NaN afterSuffix NaN K
536 test apply formerly localized patterns
538 // documentation says localizedPattern is not supported, change to pattern
539 locale pattern format output breaks
541 // This next test breaks JDK. JDK doesn't multiply by 100.
542 // It also is now broken in ICU4J until #10368 is fixed.
543 fa \u0025\u00a0\u0023\u0030 0.4376 \u200e\u066a\u00a0\u06f4\u06f4 JK
548 pattern toPattern breaks
549 // JDK doesn't support any patterns with padding or both negative prefix and suffix
550 // Breaks ICU4J See ticket 11671
552 **##0,000 **##0,000 K
553 **###0,000 **###0,000 K
554 **####0,000 **#,##0,000 K
563 // No secondary grouping in JDK
564 #,##,###.02500 #,##,###.02500 K
565 pp#,000;(#) pp#,000;(#,000) K
566 **####,##,##0.0##;(#) **#,##,##,##0.0##;**(##,##,##0.0##) K
567 // No significant digits in JDK
572 ###0.00#E0 ###0.00#E0
573 ##00.00#E0 ##00.00#E0
576 ###0.00#E00 ###0.00#E00
580 set pattern +#,##0.0###;(#)
589 // J requires prefix and suffix for lenient parsing, but C doesn't
595 // JDK stops parsing at the spaces. JDK doesn't see space as a grouping separator
598 // J doesn't allow trailing separators before E but C does
599 (34,,25,E-1) -342.5 J
600 (34 25 E-1) -342.5 JK
602 // Spaces are not allowed after exponent symbol
603 // C parses up to the E but J bails
606 +1,234,567.8901 1234567.8901
607 +1,23,4567.8901 1234567.8901
608 +1,23,4567.89,01 1234567.89
609 +1,23,456.78.9 123456.78
613 // Parsing stops at comma as it is different from other separators
619 // Whitespace immediately after prefix doesn't count as digit separator
620 // in C but is does in J
623 // C allows trailing separators when there is a prefix and suffix.
624 // J allows trailing separators only when there is just a prefix.
625 // In this case, J just bails
628 // C parses to the space, but J bails
630 // J bails b/c comma different separator than space. C doesn't treat leading spaces
633 // J bails. Doesn't allow trailing separators when there is prefix and suffix.
635 // J bails on next 4 because J doesn't allow letters inside prefix and suffix.
636 // C will parse up to the letter.
641 // J does allow trailing separator before a decimal point
643 // 2nd decimal points are ignored
648 set pattern #,##0.0###+;#-
651 // C sees this as -3426, don't understand why
654 // J bails, but JDK will parse up to the space and get 34.
657 // JDK sees this as -1234 for some reason
658 // J bails b/c of trailing separators
659 // C parses until trailing separators, but sees -1234
662 // J bails because of trailing separators
671 set pattern +#,##0.0###;(#)
677 // separators in wrong place cause failure, no separators ok.
681 // JDK does allow separators in the wrong place and parses as -5347.25
683 // strict requires prefix or suffix
688 // Strict doesn't allow separators in sci notation.
690 // JDK allows separators in sci notation and parses as -342.5
692 // Both prefix and suffix needed for strict.
693 // JDK accepts this and parses as -342.5
696 +1,234,567.8901 1234567.8901
697 // With strict digit separators don't have to be the right type
698 // JDK doesn't acknowledge space as a separator
699 +1 234 567.8901 1234567.8901 K
700 // In general the grouping separators have to match their expected
701 // location exactly. The only exception is when string being parsed
702 // have no separators at all.
703 +1,234,567.8901 1234567.8901
704 // JDK doesn't require separators to be in the right place
705 +1,23,4567.8901 fail K
706 +1234,567.8901 fail K
707 +1,234567.8901 fail K
708 +1234567.8901 1234567.8901
709 // Comma after decimal means parse to a comma
710 +123,456.78,9 123456.78
711 // A decimal after a decimal means bail
712 // JDK parses as 123456.78
717 // JDK parses as -1945
720 test parse integer only
723 set parseIntegerOnly 1
732 test parse no exponent flag
736 parseNoExponent parse output breaks
737 // JDK doesn't allow lowercase exponent but ICU4J and ICU4C do.
744 test parse currency fail
748 parse output outputCurrency breaks
752 test parse strange prefix
754 set positivePrefix dd
755 set negativePrefix ddd
761 test parse strange suffix
763 set positiveSuffix dd
765 set negativeSuffix ddd
771 test really strange suffix
773 set positiveSuffix 9K
775 set negativeSuffix 9N
778 // C consumes the '9' as a digit and assumes number is negative
781 // C consumes the '9' as a digit and assumes number is negative
785 test really strange prefix
787 set positivePrefix 82
788 set negativePrefix 28
797 format pattern plural
812 test parse currency ISO
813 set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
816 parse output outputCurrency breaks
819 USD 53.45 53.45 USD J
824 (7.926) USD -7.926 USD
835 US Dollars 53.45 53.45 USD J
836 53.45 US Dollars 53.45 USD
837 US Dollar 53.45 53.45 USD J
838 53.45 US Dollar 53.45 USD
839 US Dollars53.45 53.45 USD
840 53.45US Dollars fail USD
841 US Dollar53.45 53.45 USD
842 US Dollat53.45 fail USD
843 53.45US Dollar fail USD
844 US Dollars (53.45) fail USD
845 (53.45) US Dollars -53.45 USD
846 US Dollar (53.45) fail USD
847 (53.45) US Dollar -53.45 USD
848 US Dollars(53.45) fail USD
849 (53.45)US Dollars fail USD
850 US Dollar(53.45) fail USD
851 US Dollat(53.45) fail USD
852 (53.45)US Dollar fail USD
855 test parse currency ISO negative
856 set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4
859 parse output outputCurrency breaks
862 USD 53.45 53.45 USD J
867 -7.926 USD -7.926 USD
874 US Dollars 53.45 53.45 USD J
875 53.45 US Dollars 53.45 USD
876 US Dollar 53.45 53.45 USD J
877 53.45 US Dollar 53.45 USD
878 US Dollars53.45 53.45 USD
879 53.45US Dollars fail USD
880 US Dollar53.45 53.45 USD
881 US Dollat53.45 fail USD
882 53.45US Dollar fail USD
885 test parse currency long
886 set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4
889 parse output outputCurrency breaks
892 USD 53.45 53.45 USD J
897 (7.926) USD -7.926 USD
910 US Dollars 53.45 53.45 USD J
911 53.45 US Dollars 53.45 USD
912 US Dollar 53.45 53.45 USD J
913 53.45 US Dollar 53.45 USD
914 US Dollars53.45 53.45 USD
916 53.45US Dollars fail USD J
917 US Dollar53.45 53.45 USD
918 US Dollat53.45 fail USD
920 53.45US Dollar fail USD J
923 test parse currency short
924 set pattern 0.00 \u00a4;(#) \u00a4
927 parse output outputCurrency breaks
930 USD 53.45 53.45 USD J
934 (7.926) USD -7.926 USD
945 US Dollars 53.45 53.45 USD J
946 53.45 US Dollars 53.45 USD
947 US Dollar 53.45 53.45 USD J
948 53.45 US Dollar 53.45 USD
949 US Dollars53.45 53.45 USD
950 53.45US Dollars fail USD
951 US Dollar53.45 53.45 USD
952 US Dollat53.45 fail USD
953 53.45US Dollar fail USD
956 test parse currency short prefix
957 set pattern \u00a40.00;(\u00a4#)
960 parse output outputCurrency breaks
963 USD 53.45 53.45 USD J
969 (USD 7.926) -7.926 USD J
978 US Dollars 53.45 53.45 USD J
979 53.45 US Dollars 53.45 USD
980 US Dollar 53.45 53.45 USD J
981 53.45 US Dollar 53.45 USD
982 US Dollars53.45 53.45 USD
983 53.45US Dollars fail USD
984 US Dollar53.45 53.45 USD
985 53.45US Dollar fail USD
987 test format foreign currency
990 pattern format output breaks
991 \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 # 1235 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 K
992 \u00a4\u00a4 0.00;\u00a4\u00a4 -# 1235 IRR \u06F1\u06F2\u06F3\u06F5 K
993 \u00a4 0.00;\u00a4 -# 1235 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 K
995 test parse foreign currency symbol
996 set pattern \u00a4 0.00;\u00a4 -#
999 parse output outputCurrency
1000 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1001 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
1002 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1004 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1005 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1007 test parse foreign currency ISO
1008 set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -#
1011 parse output outputCurrency
1012 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1013 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
1014 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1016 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1017 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1019 test parse foreign currency full
1020 set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -#
1023 parse output outputCurrency
1024 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1025 IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
1026 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1028 \u0631\u06cc\u0627\u0644 1235 1235 IRR
1029 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR
1031 test parse currency with foreign symbols symbol english
1032 set pattern \u00a4 0.00;\u00a4 (#)
1035 parse output outputCurrency
1037 \u20ac 7.82 7.82 EUR
1041 test parse currency with foreign symbols ISO english
1042 set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#)
1045 parse output outputCurrency
1047 \u20ac 7.82 7.82 EUR
1051 test parse currency with foreign symbols full english
1052 set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#)
1055 parse output outputCurrency
1057 \u20ac 7.82 7.82 EUR
1061 test parse currency ISO strict
1062 set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
1066 parse output outputCurrency breaks
1072 (7.92) USD -7.92 USD
1073 (7.92) EUR -7.92 EUR
1074 (7.926) USD -7.926 USD
1075 (7.926 USD) fail USD
1076 (USD 7.926) fail USD
1077 USD (7.926) fail USD
1085 US Dollars 53.45 fail USD
1086 53.45 US Dollars 53.45 USD
1087 US Dollar 53.45 fail USD
1088 53.45 US Dollar 53.45 USD
1089 US Dollars53.45 53.45 USD
1090 53.45US Dollars fail USD
1091 US Dollar53.45 53.45 USD
1092 US Dollat53.45 fail USD
1093 53.45US Dollar fail USD
1094 US Dollars (53.45) fail USD
1095 (53.45) US Dollars -53.45 USD
1096 US Dollar (53.45) fail USD
1097 (53.45) US Dollar -53.45 USD
1098 US Dollars(53.45) fail USD
1099 (53.45)US Dollars fail USD
1100 US Dollar(53.45) fail USD
1101 US Dollat(53.45) fail USD
1102 (53.45)US Dollar fail USD
1106 set roundingMode ceiling
1107 set minFractionDigits 0
1108 set maxFractionDigits 0
1110 format output breaks