]>
Commit | Line | Data |
---|---|---|
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 | ||
23 | test plus sign | |
0f5d89e8 | 24 | set locale ar-EG |
2ca993e8 A |
25 | set pattern +0;-# |
26 | begin | |
27 | format output breaks | |
0f5d89e8 A |
28 | 6 \u061C+\u0666 HK |
29 | -6 \u061C-\u0666 K | |
2ca993e8 A |
30 | |
31 | test basic patterns | |
32 | set locale fr_FR | |
33 | set format 1234.567 | |
34 | begin | |
3d1f044b A |
35 | pattern output breaks |
36 | // K does not use \u202f narrow space | |
37 | #,##0.## 1\u202f234,57 K | |
2ca993e8 A |
38 | 0.## 1234,57 |
39 | 0 1235 | |
3d1f044b | 40 | #,##0.### 1\u202f234,567 K |
2ca993e8 A |
41 | ###0.###### 1234,567 |
42 | ###0.0000# 1234,5670 | |
43 | 00000.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 | ||
49 | test minimum and maximum fraction digits | |
50 | set locale en | |
51 | set minIntegerDigits 2 | |
52 | set maxIntegerDigits 4 | |
53 | set minFractionDigits 3 | |
54 | set maxFractionDigits 5 | |
55 | begin | |
56 | format output | |
57 | 6 06.000 | |
58 | 6.000005 06.000 | |
59 | 6.000006 06.00001 | |
60 | 1002003004005 4005.000 | |
61 | -1002003004005 -4005.000 | |
62 | 12 12.000 | |
63 | 12345 2345.000 | |
64 | 72.1234 72.1234 | |
65 | ||
0f5d89e8 A |
66 | test patterns with no '0' symbols |
67 | set locale en_US | |
68 | begin | |
69 | pattern 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 | ||
95 | test behavior on numbers approaching zero | |
96 | set locale en | |
97 | begin | |
98 | pattern 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 | |
105 | 0.00 0.01 0.01 | |
106 | 0.00 0.001 0.00 | |
107 | 0.00 0 0.00 | |
108 | ||
109 | // Not in official spec, but needed for backwards compatibility | |
110 | test patterns with leading grouping separator | |
111 | set locale en_US | |
112 | begin | |
113 | pattern format output breaks | |
114 | ,##0 1234.56 1,235 | |
115 | '#',## 3456 #34,56 | |
116 | ||
117 | test patterns with valid and invalid quote marks | |
118 | set locale et | |
119 | begin | |
120 | pattern 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 |
135 | test int64 |
136 | set locale en | |
137 | begin | |
138 | format output | |
139 | 1002003004005 1002003004005 | |
140 | -1002003004005 -1002003004005 | |
141 | ||
142 | test rounding | |
143 | set locale fr | |
144 | begin | |
145 | pattern format output breaks | |
146 | 0.5 1.25 1,0 K | |
147 | 0.5 1.75 2,0 K | |
148 | 0.5 -1.25 -1,0 K | |
149 | 00.5 -1.75 -02,0 K | |
150 | 4 2.0 0 K | |
151 | 4 6.0 8 K | |
152 | 4 10.0 8 K | |
153 | 2.70 99.0 99,90 K | |
154 | 2.73 272.0 273,00 K | |
3d1f044b | 155 | #,#3.70 104.0 1\u202f03,60 K |
2ca993e8 A |
156 | |
157 | test significant digits | |
158 | set locale en | |
159 | set pattern #,#@,@### | |
160 | begin | |
161 | format output breaks | |
162 | 7 7.0 K | |
163 | 23 23 K | |
164 | 100 100 K | |
165 | 1000 1000 K | |
166 | 10000 1,0000 K | |
167 | 10001 1,0001 K | |
168 | 10001.5 1,0002 K | |
169 | 1234567 1,23,4600 K | |
170 | -1234567 -1,23,4600 K | |
171 | 3.14159 3.1416 K | |
172 | ||
173 | test scientific notation | |
174 | set locale fr | |
175 | begin | |
176 | pattern format output breaks | |
177 | 0.00E0 12345 1,23E4 | |
178 | 000.00E0 12300 123,00E2 | |
179 | 000.0#E0 12300 123,0E2 | |
180 | 000.0#E0 12300.1 123,0E2 | |
181 | 000.0#E0 12301.0 123,01E2 | |
182 | // JDK does not support exponent signs | |
183 | 000.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 | 191 | 0.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 | |
205 | 0E0 52413 5E4 | |
2ca993e8 | 206 | |
3d1f044b A |
207 | test scientific infinite precision |
208 | // ICU-11511, ICU-7460, CLDR-10103 | |
209 | set locale en | |
210 | begin | |
211 | pattern format output breaks | |
212 | // From the spec: | |
213 | // "0.##E0 means a max of 3 significant digits." | |
214 | 0.##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." | |
220 | 0E0 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 |
230 | test percents |
231 | set locale fr | |
232 | begin | |
233 | pattern format output breaks | |
234 | 0.0% 0.573 57,3% | |
235 | %0.0 0.573 %57,3 | |
236 | p%p0.0 0.573 p%p57,3 | |
237 | p'%'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 | ||
245 | test permille | |
246 | set locale fr | |
247 | begin | |
248 | pattern format output breaks | |
249 | 0.0\u2030 0.573 573,0‰ | |
250 | \u20300.0 0.573 \u2030573,0 | |
251 | p\u2030p0.0 0.573 p\u2030p573,0 | |
252 | p'\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 | ||
259 | test padding | |
260 | set locale fr_FR | |
261 | begin | |
262 | pattern 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 | |
278 | test padding and currencies | |
279 | begin | |
280 | locale 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 | 283 | fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 HK |
2ca993e8 A |
284 | // JDK doesn't correct rounding for currency, shows USD (433 |
285 | en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K | |
286 | ||
287 | test currencies | |
288 | set locale fr | |
289 | set format 1234.567 | |
290 | begin | |
291 | pattern 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 | |
298 | test prefixes and suffixes | |
299 | set locale en | |
300 | set pattern 0.00+;(#) | |
301 | begin | |
302 | format output breaks | |
303 | 7 7.00+ | |
304 | // JDK does not support negative suffixes | |
305 | -3.5 (3.50) K | |
306 | ||
307 | test minimum grouping digits | |
308 | set locale en | |
309 | set pattern #,##0 | |
310 | set minGroupingDigits 2 | |
311 | begin | |
312 | format 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 | 315 | 1000 1000 HK |
2ca993e8 A |
316 | 10000 10,000 |
317 | 100000 100,000 | |
318 | 1000000 1,000,000 | |
319 | ||
320 | test min max fraction digits | |
321 | set locale en | |
322 | set pattern #,##0.### | |
323 | set format 1234.567 | |
324 | begin | |
325 | minFractionDigits maxFractionDigits output | |
326 | 0 0 1,235 | |
327 | 0 2 1,234.57 | |
328 | 4 5 1,234.5670 | |
329 | ||
330 | test min max integer digits | |
331 | set locale en | |
332 | set pattern #,##0.### | |
333 | set format 1234.567 | |
334 | begin | |
335 | minIntegerDigits maxIntegerDigits output | |
336 | 0 0 .567 | |
337 | 0 3 234.567 | |
338 | 5 5 01,234.567 | |
339 | ||
340 | test min max fraction digits scientific | |
341 | set locale en | |
342 | set pattern #E0 | |
343 | set format 299792458.0 | |
344 | begin | |
345 | minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks | |
0f5d89e8 A |
346 | // JDK gives 2.99792458E8 (maxInt + maxFrac instead of minInt + maxFrac) |
347 | 1 99 0 5 2.99792E8 K | |
2ca993e8 A |
348 | // JDK gives .3E9 instead of unlimited precision. |
349 | 0 1 0 0 2.99792458E8 K | |
350 | 1 1 0 0 3E8 | |
351 | // JDK gives E0 instead of allowing for unlimited precision | |
352 | 0 0 0 0 2.99792458E8 K | |
3d1f044b A |
353 | // J gives 2.9979E8 |
354 | 0 1 0 5 2.99792E8 HK | |
2ca993e8 A |
355 | // JDK gives 300E6 |
356 | 0 3 0 0 299.792458E6 K | |
357 | // JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)? | |
358 | 0 3 0 1 300E6 K | |
359 | // JDK gives 299.7925E6 | |
360 | 2 3 0 4 299.792E6 K | |
361 | // JDK gives 299.79246E6 | |
362 | 2 3 0 5 299.7925E6 K | |
363 | 3 3 0 5 299.79246E6 | |
364 | 3 3 0 4 299.7925E6 | |
365 | 2 2 0 3 29.979E7 | |
366 | 4 4 0 0 2998E5 | |
367 | 0 0 1 5 .29979E9 | |
368 | // JDK gives E0 | |
369 | 0 0 1 0 2.99792458E8 K | |
3d1f044b A |
370 | // J gives 2.998E8 |
371 | 0 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 |
374 | 2 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. | |
378 | 2 9 1 6 29.979246E7 K | |
379 | ||
3d1f044b A |
380 | test ticket 20058 |
381 | set locale en | |
382 | begin | |
383 | pattern 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 |
389 | test significant digits scientific |
390 | set locale en | |
391 | set pattern #E0 | |
392 | set format 290000000.0 | |
393 | begin | |
394 | minSigDigits maxSigDigits output breaks | |
395 | 0 1 3E8 K | |
396 | 0 2 2.9E8 K | |
397 | 0 3 2.9E8 K | |
398 | 1 1 3E8 K | |
399 | 1 2 2.9E8 K | |
400 | 1 3 2.9E8 K | |
401 | 2 2 2.9E8 K | |
402 | 2 3 2.9E8 K | |
403 | 3 3 2.90E8 K | |
404 | 3 4 2.90E8 K | |
405 | ||
406 | test min max fraction digits scientific 2 | |
407 | set locale en | |
408 | set pattern #E0 | |
409 | set format 29979245.0 | |
410 | begin | |
411 | minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks | |
412 | // JDK gives E0 | |
413 | 0 0 0 0 2.9979245E7 K | |
414 | // JDK gives .3E8 | |
415 | 0 1 0 0 2.9979245E7 K | |
416 | // JDK gives 2998E4. | |
417 | 0 4 0 0 2997.9245E4 K | |
418 | ||
419 | test ticket 11524 | |
420 | set locale en | |
421 | set pattern #,##0.### | |
422 | begin | |
0f5d89e8 A |
423 | format maxIntegerDigits output breaks |
424 | 123 1 3 | |
3d1f044b A |
425 | // C obeys maxIntegerDigits and prints after the decimal place |
426 | 0 0 .0 HKP | |
427 | // CJP ignore max integer if it is less than zero and prints "123" | |
428 | 123 -2147483648 0 CJP | |
0f5d89e8 | 429 | 12345 1 5 |
3d1f044b | 430 | 12345 -2147483648 0 CJP |
0f5d89e8 | 431 | 5.3 1 5.3 |
3d1f044b | 432 | 5.3 -2147483648 .3 CJP |
2ca993e8 A |
433 | |
434 | test patterns with zero | |
435 | set locale en | |
436 | set format 0 | |
437 | begin | |
0f5d89e8 | 438 | pattern output breaks |
2ca993e8 A |
439 | #.# 0 |
440 | #. 0. | |
441 | .# .0 | |
442 | # 0 | |
0f5d89e8 A |
443 | #,##0.00 0.00 |
444 | #,###.00 .00 | |
2ca993e8 A |
445 | 00.000E00 00.000E00 |
446 | 0.####E0 0E0 | |
447 | ##0.######E000 0E000 | |
448 | ||
449 | test significant digits manually set | |
450 | set locale en_US | |
451 | set pattern 0.0 | |
452 | set useSigDigits 1 | |
453 | set minSigDigits 3 | |
454 | set maxSigDigits 5 | |
455 | begin | |
456 | format output breaks | |
457 | 0.0012 0.00120 K | |
458 | 0.00123 0.00123 K | |
459 | 0.001234 0.001234 K | |
460 | 0.0012345 0.0012345 K | |
461 | 0.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 | ||
468 | test grouping used setters | |
469 | set locale en_US | |
470 | set pattern #,##0 | |
471 | set format 12345 | |
472 | begin | |
473 | output useGrouping | |
474 | 12,345 | |
475 | 12,345 1 | |
476 | 12345 0 | |
477 | ||
0f5d89e8 A |
478 | test grouping used setters in parsing |
479 | set pattern #,##0 | |
480 | begin | |
481 | locale useGrouping parse output breaks | |
482 | en_US 1 123,456 123456 | |
483 | en_US 0 123,456 123 | |
484 | en_US 1 123.456 123.456 | |
485 | en_US 0 123.456 123.456 | |
486 | it_IT 1 123,456 123.456 | |
487 | it_IT 0 123,456 123.456 | |
488 | it_IT 1 123.456 123456 | |
489 | it_IT 0 123.456 123 | |
490 | ||
491 | test no grouping in pattern with parsing | |
492 | set pattern 0 | |
493 | begin | |
494 | locale parse output breaks | |
495 | en_US 123,456 123 | |
496 | en_US 123.456 123.456 | |
497 | fr_FR 123,456 123.456 | |
498 | fr_FR 123.456 123 | |
499 | ||
2ca993e8 A |
500 | test grouping setters |
501 | set locale en_US | |
502 | set pattern 0 | |
503 | set format 123456789 | |
504 | set useGrouping 1 | |
505 | begin | |
0f5d89e8 | 506 | output grouping grouping2 breaks |
2ca993e8 | 507 | 1,2345,6789 4 |
0f5d89e8 A |
508 | 1,23,45,6789 4 2 K |
509 | ||
510 | test grouping setters with min grouping digits | |
511 | set locale en_US | |
512 | set pattern 0 | |
513 | set format 123456789 | |
514 | set useGrouping 1 | |
515 | begin | |
516 | output grouping grouping2 minGroupingDigits breaks | |
517 | 1,23,45,6789 4 2 2 K | |
518 | 123,456789 6 6 3 | |
519 | 123456789 6 6 4 HK | |
2ca993e8 A |
520 | |
521 | test multiplier setters | |
522 | set locale en_US | |
523 | begin | |
524 | format multiplier output breaks | |
525 | 23 -12 -276 | |
526 | 23 -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. | |
530 | 23 0 0 CHJ | |
2ca993e8 A |
531 | 23 1 23 |
532 | 23 12 276 | |
533 | -23 12 -276 | |
534 | -23 -12 276 | |
535 | ||
536 | test rounding setters | |
537 | set locale en_US | |
538 | set pattern 0.0# | |
539 | set roundingIncrement 0.25 | |
540 | begin | |
541 | format output breaks | |
542 | -0.35 -0.25 K | |
543 | 0.35 0.25 K | |
0f5d89e8 A |
544 | // P doesn't support mixing minFrac with roundingIncrement (prints 0.50). |
545 | 0.39 0.5 JKP | |
546 | 0.62 0.5 JKP | |
2ca993e8 A |
547 | 0.63 0.75 K |
548 | ||
549 | test padding setters | |
550 | set locale en_US | |
551 | set pattern bill0 | |
552 | set format 1357 | |
553 | begin | |
554 | padCharacter formatWidth output breaks | |
0f5d89e8 | 555 | * 8 bill1357 |
2ca993e8 A |
556 | * 9 *bill1357 K |
557 | ^ 10 ^^bill1357 K | |
558 | ||
559 | test use scientific setter | |
560 | set locale en_US | |
561 | set pattern 0.00 | |
562 | set format 186283 | |
563 | begin | |
0f5d89e8 | 564 | output useScientific breaks |
2ca993e8 | 565 | 186283.00 |
0f5d89e8 A |
566 | 1.86E5 1 K |
567 | 186283.00 0 | |
2ca993e8 A |
568 | |
569 | test rounding mode setters | |
570 | set locale en_US | |
0f5d89e8 | 571 | set pattern 0.5 |
2ca993e8 A |
572 | begin |
573 | format roundingMode output breaks | |
0f5d89e8 A |
574 | 1.24 halfUp 1.0 K |
575 | 1.25 halfUp 1.5 | |
576 | 1.25 halfDown 1.0 K | |
577 | 1.26 halfDown 1.5 | |
578 | 1.25 halfEven 1.0 K | |
579 | -1.01 up -1.5 | |
580 | -1.49 down -1.0 K | |
581 | 1.01 up 1.5 | |
582 | 1.49 down 1.0 K | |
583 | -1.01 ceiling -1.0 K | |
584 | -1.49 floor -1.5 | |
2ca993e8 A |
585 | |
586 | test currency usage setters | |
2ca993e8 | 587 | set locale CH |
2ca993e8 A |
588 | set pattern \u00a4\u00a4 0 |
589 | begin | |
0f5d89e8 A |
590 | format currency currencyUsage output breaks |
591 | 0.37 CHF standard CHF 0.37 K | |
592 | 0.37 CHF cash CHF 0.35 K | |
593 | 1.234 CZK standard CZK 1.23 K | |
594 | 1.234 CZK cash CZK 1 | |
595 | ||
596 | test currency usage to pattern | |
597 | set locale en | |
598 | begin | |
599 | currency 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 |
602 | USD standard 0.00 HK |
603 | CHF standard 0.00 HK | |
604 | CZK standard 0.00 HK | |
605 | USD cash 0.00 HK | |
606 | CHF cash 0.05 HK | |
607 | CZK cash 0 HK | |
0f5d89e8 A |
608 | |
609 | test currency rounding | |
610 | set locale en | |
611 | set currency USD | |
612 | begin | |
613 | pattern 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 | |
621 | test exponent parameter setters | |
622 | set locale en_US | |
623 | set pattern 0.##E0 | |
624 | set format 299792458 | |
625 | begin | |
626 | decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks | |
627 | 0 0 2 3E08 K | |
628 | 0 1 3 3E+008 K | |
2ca993e8 A |
629 | // decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J |
630 | // See ticket 11621 | |
0f5d89e8 A |
631 | 1 0 2 3.E08 K |
632 | 1 1 3 3.E+008 K | |
f3c0d7a5 | 633 | 1 0 1 3.E8 |
2ca993e8 A |
634 | 0 0 1 3E8 |
635 | ||
636 | test exponent decimalSeparatorAlwaysShown default | |
637 | set locale en_US | |
638 | set pattern 0.##E0 | |
639 | begin | |
0f5d89e8 | 640 | format output decimalSeparatorAlwaysShown breaks |
2ca993e8 A |
641 | // decimalSeparatorAlwaysShown off by default |
642 | 299792458 3E8 | |
643 | 299000000 2.99E8 | |
0f5d89e8 | 644 | 299792458 3.E8 1 |
2ca993e8 A |
645 | |
646 | test pad position setters | |
647 | set locale en_US | |
648 | set pattern **[#####0.##];((#)) | |
649 | begin | |
650 | format padPosition output breaks | |
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 | -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 | ||
660 | test affix setters | |
661 | set locale fr_FR | |
662 | set currency EUR | |
663 | set pattern 0.00 | |
664 | begin | |
665 | format positivePrefix positiveSuffix negativePrefix negativeSuffix output | |
666 | 12.34 % %12,34 | |
667 | 12.34 \u00a4\u00a4 12,34\u00a4\u00a4 | |
668 | 12.34 - + 12,34 | |
669 | -12.34 - + -12,34+ | |
670 | -12.34 \u00a4 \u00a412,34 | |
671 | 12.34 \u00a4 12,34 | |
672 | -12.34 % 12,34% | |
673 | 12.34 % 12,34 | |
674 | ||
675 | test more affix setters | |
676 | set locale fr_FR | |
677 | set pattern %0.00 | |
678 | begin | |
679 | format positivePrefix negativePrefix output | |
680 | 0.648 booya cooya booya64,80 | |
681 | ||
682 | test nan and infinity | |
683 | set locale en_US | |
684 | set pattern [0.00];(#) | |
685 | begin | |
686 | format output breaks | |
0f5d89e8 | 687 | Inf [\u221e] |
2ca993e8 | 688 | -Inf (\u221e) K |
0f5d89e8 A |
689 | // J does not print the affixes |
690 | // K prints \uFFFD | |
3d1f044b | 691 | NaN [NaN] HK |
2ca993e8 A |
692 | |
693 | test nan and infinity with multiplication | |
694 | set locale en | |
695 | set multiplier 100 | |
696 | begin | |
697 | format output breaks | |
698 | Inf \u221e | |
699 | -Inf -\u221e | |
700 | NaN NaN K | |
701 | ||
702 | test nan and infinity with padding | |
703 | set locale en_US | |
704 | set pattern $$$0.00$ | |
0f5d89e8 | 705 | set formatWidth 8 |
2ca993e8 A |
706 | begin |
707 | format padPosition output breaks | |
0f5d89e8 A |
708 | Inf beforePrefix $$$\u221e$ K |
709 | Inf afterPrefix $$$ \u221e$ K | |
710 | Inf beforeSuffix $$$\u221e $ K | |
711 | Inf afterSuffix $$$\u221e$ K | |
712 | // J does not print the affixes | |
713 | // K prints \uFFFD | |
3d1f044b A |
714 | NaN beforePrefix $$$NaN$ HK |
715 | NaN afterPrefix $$$ NaN$ HK | |
716 | NaN beforeSuffix $$$NaN $ HK | |
717 | NaN afterSuffix $$$NaN$ HK | |
2ca993e8 | 718 | |
f3c0d7a5 | 719 | test apply formerly localized patterns |
2ca993e8 | 720 | begin |
f3c0d7a5 A |
721 | // documentation says localizedPattern is not supported, change to pattern |
722 | locale pattern format output breaks | |
723 | en #0% 0.4376 44% | |
2ca993e8 | 724 | // This next test breaks JDK. JDK doesn't multiply by 100. |
0f5d89e8 A |
725 | fa \u0025\u00a0\u0023\u0030 0.4376 \u066a\u00a0\u06f4\u06f4 K |
726 | ||
727 | test localized pattern basic symbol coverage | |
728 | begin | |
729 | locale localizedPattern toPattern breaks | |
730 | it #.##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 | |
733 | sl #.##0;#.##0− #,##0;#,##0- K | |
734 | // JDK does not have data for "×10^" in this locale | |
735 | en_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 | |
737 | ar_SA #\u066C##\u0660\u066B\u0660\u0660;a# #,##0.00;a#,##0.00 K | |
2ca993e8 A |
738 | |
739 | test toPattern | |
740 | set locale en | |
741 | begin | |
742 | pattern 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 | 751 | 0,000 #0,000 CJP |
2ca993e8 | 752 | .00 #.00 |
3d1f044b A |
753 | 000 #000 CJP |
754 | 000,000 #,000,000 CJP | |
2ca993e8 | 755 | pp#,000 pp#,000 |
3d1f044b | 756 | 00.## #00.## CJP |
2ca993e8 A |
757 | #,#00.025 #,#00.025 |
758 | // No secondary grouping in JDK | |
759 | #,##,###.02500 #,##,###.02500 K | |
760 | pp#,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 | |
765 | 0.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 | |
771 | 0.00E+00 0.00E+00 K | |
772 | 000.00E00 000.00E00 | |
773 | ###0.00#E00 ###0.00#E00 | |
774 | ||
775 | test parse | |
776 | set locale en | |
777 | set pattern +#,##0.0###;(#) | |
778 | begin | |
779 | parse 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 |
787 | 5,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 | ||
848 | test parse suffix | |
849 | set locale en | |
850 | set pattern #,##0.0###+;#- | |
851 | begin | |
852 | parse output breaks | |
0f5d89e8 | 853 | // J and K just bail. |
3d1f044b | 854 | 3426 3426 HK |
2ca993e8 | 855 | 3426+ 3426 |
3d1f044b A |
856 | // J bails; K sees -34 |
857 | 34 d1+ 34 HK | |
2ca993e8 | 858 | // JDK sees this as -1234 for some reason |
0f5d89e8 | 859 | // H bails b/c of trailing separators |
3d1f044b | 860 | 1,234,,,+ 1234 HK |
2ca993e8 | 861 | 1,234- -1234 |
3d1f044b A |
862 | // H, C, and P bail because of trailing separators |
863 | 1,234,- -1234 CHJP | |
2ca993e8 | 864 | // J bails here too |
0f5d89e8 | 865 | 1234 - -1234 H |
2ca993e8 A |
866 | |
867 | ||
868 | ||
869 | test parse strict | |
870 | set locale en | |
0f5d89e8 | 871 | set pattern +#,##,##0.0###;(#) |
2ca993e8 | 872 | set lenient 0 |
0f5d89e8 | 873 | set minGroupingDigits 2 |
2ca993e8 A |
874 | begin |
875 | parse 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 |
885 | 65,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 |
924 | test parse strict scientific |
925 | // See #13737: Old behavior should be retained in this case | |
926 | set locale en | |
927 | set pattern #E0 | |
928 | set lenient 0 | |
929 | begin | |
930 | parse output breaks | |
931 | 123 123 | |
932 | 123E1 1230 | |
933 | 123E0 123 | |
934 | 123E 123 | |
935 | ||
936 | test parse strict without prefix/suffix | |
937 | set locale en | |
938 | set pattern # | |
939 | set lenient 0 | |
940 | begin | |
941 | parse output breaks | |
942 | 12.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 |
948 | test parse integer only |
949 | set locale en | |
950 | set pattern 0.00 | |
951 | set parseIntegerOnly 1 | |
952 | begin | |
953 | parse output breaks | |
954 | 35 35 | |
0f5d89e8 | 955 | // S accepts leading plus signs |
3d1f044b | 956 | +35 35 HK |
2ca993e8 A |
957 | -35 -35 |
958 | 2.63 2 | |
959 | -39.99 -39 | |
960 | ||
961 | test parse no exponent flag | |
962 | set pattern 0 | |
963 | set locale en | |
964 | begin | |
965 | parseNoExponent parse output breaks | |
966 | // JDK doesn't allow lowercase exponent but ICU4J and ICU4C do. | |
967 | 0 5e2 500 K | |
968 | 0 5.3E2 530 | |
969 | // See ticket 11725 | |
0f5d89e8 A |
970 | 1 5e2 5 H |
971 | 1 5.3E2 5.3 HK | |
2ca993e8 A |
972 | |
973 | test parse currency fail | |
974 | set pattern 0 | |
975 | set locale en | |
976 | begin | |
977 | parse output outputCurrency breaks | |
0f5d89e8 A |
978 | // Fixed in ticket 11735 |
979 | 53.45 fail USD | |
2ca993e8 A |
980 | |
981 | test parse strange prefix | |
982 | set locale en | |
983 | set positivePrefix dd | |
984 | set negativePrefix ddd | |
985 | begin | |
986 | parse output | |
987 | dd4582 4582 | |
988 | ddd4582 -4582 | |
989 | ||
990 | test parse strange suffix | |
991 | set locale en | |
992 | set positiveSuffix dd | |
993 | set negativePrefix | |
994 | set negativeSuffix ddd | |
995 | begin | |
996 | parse output | |
997 | 4582dd 4582 | |
998 | 4582ddd -4582 | |
999 | ||
1000 | test really strange suffix | |
1001 | set locale en | |
1002 | set positiveSuffix 9K | |
1003 | set negativePrefix | |
1004 | set negativeSuffix 9N | |
1005 | begin | |
1006 | parse output breaks | |
0f5d89e8 A |
1007 | // A non-greedy parse is required to pass these cases. |
1008 | // All of the implementations being tested are greedy. | |
1009 | 6549K 654 CHJKP | |
1010 | 6549N -654 CHJKP | |
2ca993e8 A |
1011 | |
1012 | test really strange prefix | |
1013 | set locale en | |
1014 | set positivePrefix 82 | |
1015 | set negativePrefix 28 | |
1016 | begin | |
1017 | parse output | |
1018 | 8245 45 | |
1019 | 2845 -45 | |
1020 | ||
0f5d89e8 A |
1021 | test parse pattern with quotes |
1022 | set locale en | |
1023 | set pattern '-'#y | |
1024 | begin | |
1025 | parse output breaks | |
1026 | -45y 45 | |
1027 | ||
1028 | test parse with locale symbols | |
1029 | // The grouping separator in it_CH is an apostrophe | |
1030 | set locale it_CH | |
1031 | set pattern #,##0 | |
1032 | begin | |
1033 | parse output breaks | |
1034 | १३ 13 | |
1035 | १३.३१ 13.31 | |
1036 | 123'456 123456 | |
1037 | 524'11.3 52411.3 | |
1038 | ३'११ 311 | |
1039 | ||
1040 | test parse with European-style comma/period | |
1041 | set locale pt | |
1042 | set pattern #,##0 | |
1043 | begin | |
1044 | parse output breaks | |
1045 | 123.456 123456 | |
1046 | 123,456 123.456 | |
1047 | 987,654.321 987.654 | |
1048 | 987,654 321 987.654 | |
1049 | 987.654,321 987654.321 | |
1050 | ||
2ca993e8 A |
1051 | test select |
1052 | set locale sr | |
1053 | begin | |
1054 | format pattern plural | |
1055 | Inf 0 other | |
1056 | -Inf 0 other | |
1057 | NaN 0 other | |
1058 | Inf 0.0 other | |
1059 | -Inf 0.0 other | |
1060 | NaN 0.0 other | |
1061 | 1 0 one | |
1062 | 1 0.0 other | |
1063 | 2 0 few | |
1064 | 2 0.0 other | |
1065 | 2 0E0 other | |
1066 | 5.1 0.0 one | |
1067 | 5.09 0.0 one | |
1068 | ||
1069 | test parse currency ISO | |
1070 | set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4 | |
0f5d89e8 | 1071 | set locale en_GB |
2ca993e8 A |
1072 | begin |
1073 | parse output outputCurrency breaks | |
0f5d89e8 A |
1074 | 53.45 fail GBP |
1075 | £53.45 53.45 GBP | |
3d1f044b | 1076 | $53.45 53.45 USD C |
2ca993e8 | 1077 | 53.45 USD 53.45 USD |
0f5d89e8 A |
1078 | 53.45 GBP 53.45 GBP |
1079 | USD 53.45 53.45 USD H | |
3d1f044b | 1080 | 53.45USD 53.45 USD H |
2ca993e8 A |
1081 | USD53.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 | |
1087 | USD (7.926) -7.926 USD H | |
1088 | USD (7.92) -7.92 USD H | |
1089 | (7.92)USD -7.92 USD H | |
1090 | USD(7.92) -7.92 USD H | |
2ca993e8 | 1091 | (8) USD -8 USD |
3d1f044b | 1092 | -8 USD -8 USD |
2ca993e8 | 1093 | 67 USD 67 USD |
3d1f044b | 1094 | 53.45$ 53.45 USD CH |
0f5d89e8 | 1095 | US Dollars 53.45 53.45 USD H |
2ca993e8 | 1096 | 53.45 US Dollars 53.45 USD |
0f5d89e8 | 1097 | US Dollar 53.45 53.45 USD H |
2ca993e8 A |
1098 | 53.45 US Dollar 53.45 USD |
1099 | US Dollars53.45 53.45 USD | |
3d1f044b | 1100 | 53.45US Dollars 53.45 USD H |
2ca993e8 A |
1101 | US Dollar53.45 53.45 USD |
1102 | US Dollat53.45 fail USD | |
3d1f044b A |
1103 | 53.45US Dollar 53.45 USD H |
1104 | US 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 | 1107 | US Dollar (53.45) -53.45 USD H |
2ca993e8 | 1108 | (53.45) US Dollar -53.45 USD |
3d1f044b A |
1109 | US Dollars(53.45) -53.45 USD H |
1110 | (53.45)US Dollars -53.45 USD H | |
1111 | US Dollar(53.45) -53.45 USD H | |
2ca993e8 | 1112 | US Dollat(53.45) fail USD |
3d1f044b | 1113 | (53.45)US Dollar -53.45 USD H |
2ca993e8 A |
1114 | |
1115 | ||
1116 | test parse currency ISO negative | |
1117 | set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4 | |
0f5d89e8 | 1118 | set locale en_GB |
2ca993e8 A |
1119 | begin |
1120 | parse output outputCurrency breaks | |
0f5d89e8 A |
1121 | 53.45 fail GBP |
1122 | £53.45 53.45 GBP | |
3d1f044b | 1123 | $53.45 53.45 USD C |
2ca993e8 | 1124 | 53.45 USD 53.45 USD |
0f5d89e8 A |
1125 | 53.45 GBP 53.45 GBP |
1126 | USD 53.45 53.45 USD H | |
3d1f044b | 1127 | 53.45USD 53.45 USD H |
2ca993e8 A |
1128 | USD53.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 |
1132 | USD -7.926 -7.926 USD H |
1133 | -7.92USD -7.92 USD H | |
1134 | USD-7.92 -7.92 USD H | |
2ca993e8 A |
1135 | -8 USD -8 USD |
1136 | 67 USD 67 USD | |
0f5d89e8 A |
1137 | 53.45$ 53.45 USD CH |
1138 | US Dollars 53.45 53.45 USD H | |
2ca993e8 | 1139 | 53.45 US Dollars 53.45 USD |
0f5d89e8 | 1140 | US Dollar 53.45 53.45 USD H |
2ca993e8 A |
1141 | 53.45 US Dollar 53.45 USD |
1142 | US Dollars53.45 53.45 USD | |
3d1f044b | 1143 | 53.45US Dollars 53.45 USD H |
2ca993e8 A |
1144 | US Dollar53.45 53.45 USD |
1145 | US Dollat53.45 fail USD | |
3d1f044b | 1146 | 53.45US Dollar 53.45 USD H |
2ca993e8 A |
1147 | |
1148 | ||
1149 | test parse currency long | |
1150 | set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4 | |
0f5d89e8 | 1151 | set locale en_GB |
2ca993e8 A |
1152 | begin |
1153 | parse output outputCurrency breaks | |
0f5d89e8 A |
1154 | // H throws a NullPointerException on the first case |
1155 | 53.45 fail GBP | |
1156 | £53.45 53.45 GBP | |
3d1f044b | 1157 | $53.45 53.45 USD C |
2ca993e8 | 1158 | 53.45 USD 53.45 USD |
0f5d89e8 A |
1159 | 53.45 GBP 53.45 GBP |
1160 | USD 53.45 53.45 USD H | |
3d1f044b | 1161 | 53.45USD 53.45 USD H |
2ca993e8 A |
1162 | USD53.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 | |
1168 | USD (7.926) -7.926 USD H | |
1169 | USD (7.92) -7.92 USD H | |
1170 | (7.92)USD -7.92 USD H | |
1171 | USD(7.92) -7.92 USD H | |
2ca993e8 | 1172 | (8) USD -8 USD |
3d1f044b | 1173 | -8 USD -8 USD |
2ca993e8 | 1174 | 67 USD 67 USD |
0f5d89e8 A |
1175 | // H throws a NullPointerException on the next case |
1176 | 53.45$ 53.45 USD CH | |
1177 | US Dollars 53.45 53.45 USD H | |
2ca993e8 | 1178 | 53.45 US Dollars 53.45 USD |
0f5d89e8 | 1179 | US Dollar 53.45 53.45 USD H |
2ca993e8 A |
1180 | 53.45 US Dollar 53.45 USD |
1181 | US Dollars53.45 53.45 USD | |
3d1f044b | 1182 | 53.45US Dollars 53.45 USD H |
2ca993e8 A |
1183 | US Dollar53.45 53.45 USD |
1184 | US Dollat53.45 fail USD | |
3d1f044b | 1185 | 53.45US Dollar 53.45 USD H |
2ca993e8 A |
1186 | |
1187 | ||
1188 | test parse currency short | |
1189 | set pattern 0.00 \u00a4;(#) \u00a4 | |
0f5d89e8 | 1190 | set locale en_GB |
2ca993e8 A |
1191 | begin |
1192 | parse output outputCurrency breaks | |
0f5d89e8 A |
1193 | 53.45 fail GBP |
1194 | £53.45 53.45 GBP | |
3d1f044b | 1195 | $53.45 53.45 USD C |
2ca993e8 | 1196 | 53.45 USD 53.45 USD |
0f5d89e8 A |
1197 | 53.45 GBP 53.45 GBP |
1198 | USD 53.45 53.45 USD H | |
3d1f044b | 1199 | 53.45USD 53.45 USD H |
2ca993e8 A |
1200 | USD53.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 | |
1206 | USD (7.926) -7.926 USD H | |
1207 | USD (7.92) -7.92 USD H | |
1208 | (7.92)USD -7.92 USD H | |
1209 | USD(7.92) -7.92 USD H | |
2ca993e8 | 1210 | (8) USD -8 USD |
3d1f044b | 1211 | -8 USD -8 USD |
2ca993e8 | 1212 | 67 USD 67 USD |
0f5d89e8 A |
1213 | 53.45$ 53.45 USD CH |
1214 | US Dollars 53.45 53.45 USD H | |
2ca993e8 | 1215 | 53.45 US Dollars 53.45 USD |
0f5d89e8 | 1216 | US Dollar 53.45 53.45 USD H |
2ca993e8 A |
1217 | 53.45 US Dollar 53.45 USD |
1218 | US Dollars53.45 53.45 USD | |
3d1f044b | 1219 | 53.45US Dollars 53.45 USD H |
2ca993e8 A |
1220 | US Dollar53.45 53.45 USD |
1221 | US Dollat53.45 fail USD | |
3d1f044b | 1222 | 53.45US Dollar 53.45 USD H |
2ca993e8 A |
1223 | |
1224 | ||
1225 | test parse currency short prefix | |
1226 | set pattern \u00a40.00;(\u00a4#) | |
0f5d89e8 | 1227 | set locale en_GB |
2ca993e8 A |
1228 | begin |
1229 | parse output outputCurrency breaks | |
0f5d89e8 A |
1230 | 53.45 fail GBP |
1231 | £53.45 53.45 GBP | |
3d1f044b A |
1232 | $53.45 53.45 USD C |
1233 | 53.45 USD 53.45 USD | |
1234 | 53.45 GBP 53.45 GBP | |
0f5d89e8 | 1235 | USD 53.45 53.45 USD H |
3d1f044b | 1236 | 53.45USD 53.45 USD H |
2ca993e8 | 1237 | USD53.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 | |
1244 | USD (7.926) -7.926 USD CHJP | |
1245 | USD (7.92) -7.92 USD CHJP | |
1246 | (7.92)USD -7.92 USD CHJP | |
1247 | USD(7.92) -7.92 USD CHJP | |
1248 | (8) USD -8 USD CHJP | |
3d1f044b A |
1249 | -8 USD -8 USD |
1250 | 67 USD 67 USD | |
0f5d89e8 A |
1251 | 53.45$ 53.45 USD CH |
1252 | US Dollars 53.45 53.45 USD H | |
2ca993e8 | 1253 | 53.45 US Dollars 53.45 USD |
0f5d89e8 | 1254 | US Dollar 53.45 53.45 USD H |
2ca993e8 A |
1255 | 53.45 US Dollar 53.45 USD |
1256 | US Dollars53.45 53.45 USD | |
3d1f044b | 1257 | 53.45US Dollars 53.45 USD H |
2ca993e8 | 1258 | US Dollar53.45 53.45 USD |
3d1f044b | 1259 | 53.45US Dollar 53.45 USD H |
2ca993e8 A |
1260 | |
1261 | test format foreign currency | |
1262 | set locale fa_IR | |
0f5d89e8 | 1263 | set currency IRR |
2ca993e8 A |
1264 | begin |
1265 | pattern 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 | ||
1270 | test parse foreign currency symbol | |
1271 | set pattern \u00a4 0.00;\u00a4 -# | |
1272 | set locale fa_IR | |
1273 | begin | |
0f5d89e8 | 1274 | parse output outputCurrency breaks |
2ca993e8 A |
1275 | \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR |
1276 | IRR \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 |
1279 | IRR 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 | |
1283 | test parse foreign currency ISO | |
1284 | set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -# | |
1285 | set locale fa_IR | |
1286 | begin | |
0f5d89e8 | 1287 | parse output outputCurrency breaks |
2ca993e8 A |
1288 | \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR |
1289 | IRR \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 |
1291 | IRR 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 | |
1295 | test parse foreign currency full | |
1296 | set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -# | |
1297 | set locale fa_IR | |
1298 | begin | |
0f5d89e8 | 1299 | parse output outputCurrency breaks |
2ca993e8 A |
1300 | \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR |
1301 | IRR \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 |
1303 | IRR 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 | |
1307 | test parse currency with foreign symbols symbol english | |
1308 | set pattern \u00a4 0.00;\u00a4 (#) | |
1309 | set locale en_US | |
1310 | begin | |
1311 | parse output outputCurrency | |
1312 | EUR 7.82 7.82 EUR | |
1313 | \u20ac 7.82 7.82 EUR | |
1314 | Euro 7.82 7.82 EUR | |
1315 | Euros 7.82 7.82 EUR | |
1316 | ||
1317 | test parse currency with foreign symbols ISO english | |
1318 | set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#) | |
1319 | set locale en_US | |
1320 | begin | |
1321 | parse output outputCurrency | |
1322 | EUR 7.82 7.82 EUR | |
1323 | \u20ac 7.82 7.82 EUR | |
1324 | Euro 7.82 7.82 EUR | |
1325 | Euros 7.82 7.82 EUR | |
1326 | ||
1327 | test parse currency with foreign symbols full english | |
1328 | set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#) | |
1329 | set locale en_US | |
1330 | begin | |
1331 | parse output outputCurrency | |
1332 | EUR 7.82 7.82 EUR | |
1333 | \u20ac 7.82 7.82 EUR | |
1334 | Euro 7.82 7.82 EUR | |
1335 | Euros 7.82 7.82 EUR | |
1336 | ||
0f5d89e8 A |
1337 | test 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. | |
1340 | set locale en_US | |
1341 | set pattern \u00a4#,##0.00 | |
1342 | begin | |
1343 | parse currency output breaks | |
1344 | $52.41 USD 52.41 | |
1345 | USD52.41 USD 52.41 K | |
1346 | \u20ac52.41 USD fail | |
1347 | EUR52.41 USD fail | |
1348 | $52.41 EUR fail | |
1349 | USD52.41 EUR fail | |
1350 | \u20ac52.41 EUR 52.41 K | |
1351 | EUR52.41 EUR 52.41 | |
1352 | ||
2ca993e8 A |
1353 | test parse currency ISO strict |
1354 | set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4 | |
1355 | set locale en_US | |
1356 | set lenient 0 | |
1357 | begin | |
1358 | parse output outputCurrency breaks | |
3d1f044b | 1359 | $53.45 53.45 USD CJP |
2ca993e8 A |
1360 | 53.45 USD 53.45 USD |
1361 | USD 53.45 fail USD | |
1362 | 53.45USD fail USD | |
3d1f044b | 1363 | USD53.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 | |
1369 | USD (7.926) fail USD | |
1370 | USD (7.92) fail USD | |
1371 | (7.92)USD fail USD | |
1372 | USD(7.92) fail USD | |
1373 | (8) USD -8 USD | |
0f5d89e8 | 1374 | -8 USD fail USD H |
2ca993e8 A |
1375 | 67 USD 67 USD |
1376 | 53.45$ fail USD | |
1377 | US Dollars 53.45 fail USD | |
1378 | 53.45 US Dollars 53.45 USD | |
1379 | US Dollar 53.45 fail USD | |
1380 | 53.45 US Dollar 53.45 USD | |
3d1f044b | 1381 | US Dollars53.45 53.45 USD CJP |
2ca993e8 | 1382 | 53.45US Dollars fail USD |
3d1f044b | 1383 | US Dollar53.45 53.45 USD CJP |
2ca993e8 A |
1384 | US Dollat53.45 fail USD |
1385 | 53.45US Dollar fail USD | |
1386 | US Dollars (53.45) fail USD | |
1387 | (53.45) US Dollars -53.45 USD | |
1388 | US Dollar (53.45) fail USD | |
1389 | (53.45) US Dollar -53.45 USD | |
1390 | US Dollars(53.45) fail USD | |
1391 | (53.45)US Dollars fail USD | |
1392 | US Dollar(53.45) fail USD | |
1393 | US Dollat(53.45) fail USD | |
1394 | (53.45)US Dollar fail USD | |
1395 | ||
1396 | test ticket 10436 | |
1397 | set locale en | |
1398 | set roundingMode ceiling | |
1399 | set minFractionDigits 0 | |
1400 | set maxFractionDigits 0 | |
1401 | begin | |
1402 | format output breaks | |
0f5d89e8 A |
1403 | -0.99 -0 HK |
1404 | ||
1405 | test parse decimalPatternMatchRequired | |
1406 | set locale en | |
1407 | set decimalPatternMatchRequired 1 | |
1408 | begin | |
1409 | pattern parse output breaks | |
1410 | // K doesn't support this feature. | |
1411 | 0 123 123 | |
3d1f044b A |
1412 | 0 123. fail HK |
1413 | 0 1.23 fail HK | |
0f5d89e8 | 1414 | 0 -513 -513 |
3d1f044b A |
1415 | 0 -513. fail HK |
1416 | 0 -5.13 fail HK | |
0f5d89e8 | 1417 | 0.0 123 fail K |
3d1f044b A |
1418 | 0.0 123. 123 |
1419 | 0.0 1.23 1.23 | |
0f5d89e8 A |
1420 | 0.0 -513 fail K |
1421 | 0.0 -513. -513 | |
1422 | 0.0 -5.13 -5.13 | |
1423 | ||
1424 | test parse minus sign | |
1425 | set locale en | |
1426 | set pattern # | |
1427 | begin | |
1428 | pattern 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 | ||
1438 | test parse case sensitive | |
1439 | set locale en | |
1440 | set lenient 1 | |
1441 | set pattern Aa# | |
1442 | begin | |
1443 | parse parseCaseSensitive output breaks | |
1444 | Aa1.23 1 1.23 | |
1445 | Aa1.23 0 1.23 | |
1446 | AA1.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 | 1449 | AA1.23 0 1.23 HK |
0f5d89e8 | 1450 | aa1.23 1 fail |
3d1f044b | 1451 | aa1.23 0 1.23 HK |
0f5d89e8 A |
1452 | Aa1.23E3 1 1230 |
1453 | Aa1.23E3 0 1230 | |
3d1f044b | 1454 | Aa1.23e3 1 1.23 H |
0f5d89e8 A |
1455 | Aa1.23e3 0 1230 K |
1456 | NaN 1 NaN K | |
1457 | NaN 0 NaN K | |
1458 | nan 1 fail | |
3d1f044b | 1459 | nan 0 NaN HK |
0f5d89e8 A |
1460 | |
1461 | test parse infinity and scientific notation overflow | |
1462 | set locale en | |
1463 | set lenient 1 | |
1464 | begin | |
1465 | parse output breaks | |
1466 | NaN NaN K | |
1467 | // JDK returns zero | |
1468 | 1E999999999999999 Inf K | |
1469 | -1E999999999999999 -Inf K | |
1470 | 1E-99999999999999 0.0 | |
1471 | // Note: The test suite code doesn't properly check for 0.0 vs. -0.0 | |
1472 | -1E-99999999999999 -0.0 | |
1473 | 1E2147483648 Inf K | |
1474 | 1E2147483647 Inf K | |
1475 | // H, J and K get Infinity | |
1476 | 1E2147483646 1E+2147483646 HJK | |
1477 | 1E-2147483649 0 | |
1478 | 1E-2147483648 0 | |
1479 | // H and K return zero here | |
1480 | 1E-2147483647 1E-2147483647 HJK | |
1481 | 1E-2147483646 1E-2147483646 HJK | |
1482 | ||
1483 | test format push limits | |
1484 | set locale en | |
1485 | set minFractionDigits 2 | |
1486 | set roundingMode halfDown | |
1487 | begin | |
1488 | maxFractionDigits format output breaks | |
1489 | 100 987654321987654321 987654321987654321.00 | |
1490 | 100 987654321.987654321 987654321.987654321 | |
1491 | 100 9999999999999.9950000000001 9999999999999.9950000000001 | |
1492 | 2 9999999999999.9950000000001 10000000000000.00 | |
1493 | 2 9999999.99499999 9999999.99 | |
1494 | // K doesn't support halfDown rounding mode? | |
1495 | 2 9999999.995 9999999.99 K | |
1496 | 2 9999999.99500001 10000000.00 | |
1497 | 100 56565656565656565656565656565656565656565656565656565656565656 56565656565656565656565656565656565656565656565656565656565656.00 | |
1498 | 100 454545454545454545454545454545.454545454545454545454545454545 454545454545454545454545454545.454545454545454545454545454545 | |
1499 | 100 0.0000000000000000000123 0.0000000000000000000123 | |
1500 | 100 -78787878787878787878787878787878 -78787878787878787878787878787878.00 | |
1501 | 100 -8989898989898989898989.8989898989898989 -8989898989898989898989.8989898989898989 | |
1502 | ||
1503 | test ticket 11230 | |
1504 | set locale en | |
1505 | begin | |
1506 | pattern 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 |
1517 | 0 1 9 9 9 | |
1518 | 0 1 9 99 9 | |
1519 | 0 1 9 999 9 | |
1520 | 0 1 9 9 9 9 | |
1521 | 0 1 ,9 fail | |
1522 | 0 1 99,.0 99 | |
1523 | 0 1 9 9. 9 | |
1524 | 0 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 | |
1533 | 0 0 9 9 9 | |
1534 | 0 0 9 99 9 | |
1535 | 0 0 9 999 9 | |
1536 | 0 0 9 9 9 9 | |
1537 | 0 0 ,9 fail | |
1538 | 0 0 99,.0 99 | |
1539 | 0 0 9 9. 9 | |
1540 | 0 0 9 99. 9 | |
1541 | ||
1542 | test more strict grouping parse | |
1543 | set locale en | |
1544 | set pattern #,##,##0 | |
1545 | begin | |
1546 | lenient parse output breaks | |
1547 | 1 1,23,, 123 | |
1548 | 0 9999, 9999 | |
1549 | 0 1,23,, fail K | |
1550 | ||
1551 | test parse ignorables | |
1552 | set locale ar | |
1553 | // Note: Prefixes contain RLMs, as do some of the test cases. | |
1554 | set pattern x ab0c df | |
1555 | set negativePrefix y gh | |
1556 | set negativeSuffix i jk | |
1557 | begin | |
1558 | parse output breaks | |
1559 | x ab56c df 56 | |
1560 | x ab56c df 56 K | |
1561 | x ab56c df 56 K | |
1562 | x ab56c df 56 HK | |
1563 | x ab56c df 56 K | |
1564 | x ab56 56 HK | |
1565 | x a b56 56 HK | |
1566 | 56cdf 56 HK | |
1567 | 56c df 56 HK | |
1568 | 56cd f 56 HK | |
1569 | 56cdf 56 HK | |
1570 | 56cdf 56 HK | |
1571 | 56c df 56 HK | |
1572 | 56c df 56 HK | |
1573 | y gh56i jk -56 | |
1574 | y gh56i jk -56 K | |
1575 | y gh56i jk -56 K | |
1576 | y gh56i jk -56 HK | |
1577 | y gh56i jk -56 K | |
1578 | y gh56 -56 HK | |
1579 | y 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 |
1582 | 56ijk -56 HK |
1583 | 56i jk -56 HK | |
1584 | 56ij k -56 HK | |
1585 | 56ijk -56 HK | |
1586 | 56ijk -56 HK | |
1587 | 56i jk -56 HK | |
1588 | 56i jk -56 HK | |
0f5d89e8 A |
1589 | // S and C get 56 (accepts ' ' gs grouping); H and K get null |
1590 | 5 6 fail CJP | |
1591 | 56 5 HK | |
1592 | ||
1593 | test 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 | |
1597 | set locale en | |
1598 | set pattern #,##0 | |
1599 | begin | |
1600 | parse output breaks | |
3d1f044b | 1601 | 1 2 1 H |
0f5d89e8 A |
1602 | 1 23 123 K |
1603 | // K gets 1 here; doesn't pick up the grouping separator | |
1604 | 1 234 1234 K | |
1605 | ||
1606 | test rounding increment significant digits | |
1607 | // This test is for #13111 | |
1608 | set locale en | |
1609 | set pattern 0.1 | |
1610 | set useSigDigits 1 | |
1611 | set maxSigDigits 2 | |
1612 | begin | |
1613 | format output breaks | |
1614 | // C and J get "1" | |
1615 | // P gets "1.0" | |
1616 | // K gets "1.1" (??) | |
1617 | 0.975 0.98 CHJKP | |
1618 | ||
1619 | test lenient parse currency match | |
1620 | // This test is for #13112 | |
1621 | set locale en | |
1622 | set pattern ¤#,##0.00 | |
1623 | begin | |
1624 | parse output breaks | |
1625 | // H and K get null | |
1626 | 1.23!@#$%^ 1.23 HK | |
1627 | ||
1628 | test percentage parsing multiplier | |
1629 | // This test is for #13114 | |
1630 | set locale en | |
1631 | set pattern 0% | |
1632 | begin | |
1633 | parse output breaks | |
1634 | 55% 0.55 | |
1635 | // H and K get null | |
1636 | // C and P scale by 100 even if the percent sign is not present | |
1637 | 55 0.55 HK | |
1638 | ||
1639 | test trailing grouping separators in pattern | |
1640 | // This test is for #13115 | |
1641 | set locale en | |
1642 | begin | |
1643 | pattern 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 | ||
1649 | test empty negative subpattern | |
1650 | // This test is for #13117 | |
1651 | set locale en | |
1652 | begin | |
1653 | pattern format output breaks | |
1654 | 0 -15 -15 | |
1655 | 0; -15 -15 | |
3d1f044b A |
1656 | // H and K still prepend a '-' even though the pattern says otherwise |
1657 | 0;0 -15 15 HK | |
0f5d89e8 A |
1658 | |
1659 | test percentage multiplier parsing | |
1660 | // This test is for #13129 | |
1661 | set locale en | |
1662 | set pattern 0% | |
1663 | begin | |
1664 | parse output breaks | |
1665 | 9223372036854775807% 92233720368547758.07 K | |
1666 | ||
1667 | test sign always shown | |
1668 | set locale en | |
1669 | set pattern 0 | |
1670 | set signAlwaysShown 1 | |
1671 | begin | |
1672 | format output breaks | |
3d1f044b A |
1673 | // H and K do not support this feature |
1674 | 42 +42 HK | |
1675 | 0 +0 HK | |
0f5d89e8 A |
1676 | -42 -42 |
1677 | ||
1678 | test parse strict with plus sign | |
1679 | set locale en | |
1680 | set pattern 0 | |
1681 | set signAlwaysShown 1 | |
1682 | begin | |
1683 | lenient parse output breaks | |
1684 | 1 42 42 | |
1685 | 1 -42 -42 | |
3d1f044b | 1686 | 1 +42 42 HK |
0f5d89e8 | 1687 | 1 0 0 |
3d1f044b A |
1688 | 1 +0 0 HK |
1689 | 0 42 fail HK | |
0f5d89e8 | 1690 | 0 -42 -42 |
3d1f044b A |
1691 | 0 +42 42 HK |
1692 | 0 0 fail HK | |
1693 | 0 +0 0 HK | |
0f5d89e8 A |
1694 | |
1695 | test parse with scientific-separator-affix overlap | |
1696 | set locale en | |
1697 | begin | |
1698 | pattern lenient parse output breaks | |
1699 | 0E0','x 1 5E3,x 5000 | |
1700 | 0E0','x 0 5E3,x 5000 | |
1701 | 0E0'.'x 1 5E3.x 5000 | |
1702 | 0E0'.'x 0 5E3.x 5000 | |
1703 | ||
3d1f044b A |
1704 | test parse() lowercase currency |
1705 | set locale en | |
1706 | set pattern ¤¤0 | |
1707 | set currency USD | |
1708 | begin | |
1709 | parse output breaks | |
1710 | USD123 123 | |
1711 | USD 123 123 HK | |
1712 | usd123 123 K | |
1713 | usd 123 123 HK | |
1714 | Usd123 123 K | |
1715 | Usd 123 123 HK | |
1716 | // US$ is not used for US dollars in en-US | |
1717 | US$123 fail H | |
1718 | us$123 fail | |
1719 | Us$123 fail | |
1720 | 123 US dollars 123 K | |
1721 | 123 US DOLLARS 123 K | |
1722 | 123 us dollars 123 K | |
1723 | // Foreign currencies are not accepted in .parse() | |
1724 | GBP123 fail | |
1725 | gbp123 fail | |
1726 | British pounds 123 fail | |
1727 | british POUNDS 123 fail | |
1728 | ||
1729 | test parseCurrency() lowercase currency | |
0f5d89e8 A |
1730 | set locale en |
1731 | set pattern ¤¤0 | |
1732 | set currency USD | |
1733 | begin | |
1734 | parse output outputCurrency breaks | |
1735 | USD123 123 USD | |
1736 | USD 123 123 USD H | |
3d1f044b A |
1737 | usd123 123 USD |
1738 | usd 123 123 USD H | |
1739 | Usd123 123 USD | |
1740 | Usd 123 123 USD H | |
0f5d89e8 A |
1741 | US$123 123 USD C |
1742 | us$123 fail fail | |
1743 | Us$123 fail fail | |
1744 | 123 US dollars 123 USD | |
1745 | 123 US DOLLARS 123 USD | |
1746 | 123 us dollars 123 USD | |
3d1f044b A |
1747 | GBP123 123 GBP |
1748 | gbp123 123 GBP C | |
1749 | British pounds 123 123 GBP H | |
1750 | british 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 |