LEFT | RIGHT |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 /*******************************************************************************
********** | 3 /*******************************************************************************
********** |
4 * | 4 * |
5 * Copyright (C) 1996-2016, International Business Machines | 5 * Copyright (C) 1996-2016, International Business Machines |
6 * Corporation and others. All Rights Reserved. | 6 * Corporation and others. All Rights Reserved. |
7 **/ | 7 **/ |
8 | 8 |
9 /** | 9 /** |
10 * Port From: JDK 1.4b1 : java.text.Format.IntlTestDecimalFormatSymbols | 10 * Port From: JDK 1.4b1 : java.text.Format.IntlTestDecimalFormatSymbols |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // Reset digits to Latin | 306 // Reset digits to Latin |
307 symbols.setZeroDigit(defZero); | 307 symbols.setZeroDigit(defZero); |
308 if (!Arrays.equals(symbols.getDigitStrings(), defDigitStrings)) { | 308 if (!Arrays.equals(symbols.getDigitStrings(), defDigitStrings)) { |
309 errln("ERROR: Latin digits should be set" + symbols.getDigitStrings(
)[0]); | 309 errln("ERROR: Latin digits should be set" + symbols.getDigitStrings(
)[0]); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 @Test | 313 @Test |
314 public void testNumberingSystem() { | 314 public void testNumberingSystem() { |
315 Object[][] cases = { | 315 Object[][] cases = { |
316 {new ULocale("en"), NumberingSystem.getInstanceByName("latn"), "
1,234.56", ';'}, | 316 {"en", "latn", "1,234.56", ';'}, |
317 {new ULocale("en"), NumberingSystem.getInstanceByName("arab"), "
١٬٢٣٤٫٥٦", '؛'}, | 317 {"en", "arab", "١٬٢٣٤٫٥٦", '؛'}, |
318 {new ULocale("en"), NumberingSystem.getInstanceByName("mathsanb"
), "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'}, | 318 {"en", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'}, |
319 {new ULocale("en"), NumberingSystem.getInstanceByName("mymr"), "
၁,၂၃၄.၅၆", ';'}, | 319 {"en", "mymr", "၁,၂၃၄.၅၆", ';'}, |
320 {new ULocale("my"), NumberingSystem.getInstanceByName("latn"), "
1,234.56", ';'}, | 320 {"my", "latn", "1,234.56", ';'}, |
321 {new ULocale("my"), NumberingSystem.getInstanceByName("arab"), "
١٬٢٣٤٫٥٦", '؛'}, | 321 {"my", "arab", "١٬٢٣٤٫٥٦", '؛'}, |
322 {new ULocale("my"), NumberingSystem.getInstanceByName("mathsanb"
), "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'}, | 322 {"my", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'}, |
323 {new ULocale("my"), NumberingSystem.getInstanceByName("mymr"), "
၁,၂၃၄.၅၆", '၊'}, | 323 {"my", "mymr", "၁,၂၃၄.၅၆", '၊'}, |
| 324 {"en@numbers=thai", "mymr", "၁,၂၃၄.၅၆", ';'}, // conflicting num
bering system |
324 }; | 325 }; |
325 | 326 |
326 for (Object[] cas : cases) { | 327 for (Object[] cas : cases) { |
327 ULocale loc = (ULocale) cas[0]; | 328 ULocale loc = new ULocale((String) cas[0]); |
328 NumberingSystem ns = (NumberingSystem) cas[1]; | 329 NumberingSystem ns = NumberingSystem.getInstanceByName((String) cas[
1]); |
329 String expected1 = (String) cas[2]; | 330 String expectedFormattedNumberString = (String) cas[2]; |
330 char expected2 = (Character) cas[3]; | 331 char expectedPatternSeparator = (Character) cas[3]; |
331 | 332 |
332 DecimalFormatSymbols dfs = DecimalFormatSymbols.forNumberingSystem(l
oc, ns); | 333 DecimalFormatSymbols dfs = DecimalFormatSymbols.forNumberingSystem(l
oc, ns); |
333 DecimalFormat df = new DecimalFormat("#,##0.##", dfs); | 334 DecimalFormat df = new DecimalFormat("#,##0.##", dfs); |
334 String actual1 = df.format(1234.56); | 335 String actual1 = df.format(1234.56); |
335 assertEquals("1234.56 with " + loc + " and " + ns.getName(), expecte
d1, actual1); | 336 assertEquals("1234.56 with " + loc + " and " + ns.getName(), |
| 337 expectedFormattedNumberString, actual1); |
336 // The pattern separator is something that differs by numbering syst
em in my@numbers=mymr. | 338 // The pattern separator is something that differs by numbering syst
em in my@numbers=mymr. |
337 char actual2 = dfs.getPatternSeparator(); | 339 char actual2 = dfs.getPatternSeparator(); |
338 assertEquals("Pattern separator with " + loc + " and " + ns.getName(
), expected2, actual2); | 340 assertEquals("Pattern separator with " + loc + " and " + ns.getName(
), |
| 341 expectedPatternSeparator, actual2); |
339 | 342 |
340 // Coverage for JDK Locale overload | 343 // Coverage for JDK Locale overload |
341 DecimalFormatSymbols dfs2 = DecimalFormatSymbols.forNumberingSystem(
loc.toLocale(), ns); | 344 DecimalFormatSymbols dfs2 = DecimalFormatSymbols.forNumberingSystem(
loc.toLocale(), ns); |
342 assertEquals("JDK Locale and ICU Locale should produce the same obje
ct", dfs, dfs2); | 345 assertEquals("JDK Locale and ICU Locale should produce the same obje
ct", dfs, dfs2); |
343 } | 346 } |
344 } | 347 } |
345 } | 348 } |
LEFT | RIGHT |