author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58058 | b553ad95acf0 |
permissions | -rw-r--r-- |
57679 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* |
|
26 |
* @test |
|
58058
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
27 |
* @bug 8215181 8230284 |
57679 | 28 |
* @summary Tests the "u-cf" extension |
29 |
* @modules jdk.localedata |
|
58058
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
30 |
* @run testng/othervm -Djava.locale.providers=CLDR CurrencyFormatTests |
57679 | 31 |
*/ |
32 |
||
33 |
import static org.testng.Assert.assertEquals; |
|
34 |
||
35 |
import java.text.NumberFormat; |
|
36 |
import java.util.Locale; |
|
37 |
||
38 |
import org.testng.annotations.DataProvider; |
|
39 |
import org.testng.annotations.Test; |
|
40 |
||
41 |
/** |
|
42 |
* Test NumberFormat with BCP47 u-cf extensions. Note that this test depends |
|
43 |
* on the particular CLDR release. Results may vary on other CLDR releases. |
|
44 |
*/ |
|
45 |
@Test |
|
46 |
public class CurrencyFormatTests { |
|
47 |
||
48 |
@DataProvider(name="getInstanceData") |
|
49 |
Object[][] getInstanceData() { |
|
50 |
return new Object[][] { |
|
51 |
// Locale, amount, expected |
|
52 |
// US dollar |
|
53 |
{Locale.US, -100, "-$100.00"}, |
|
54 |
{Locale.forLanguageTag("en-US-u-cf-standard"), -100, "-$100.00"}, |
|
55 |
{Locale.forLanguageTag("en-US-u-cf-account"), -100, "($100.00)"}, |
|
56 |
{Locale.forLanguageTag("en-US-u-cf-bogus"), -100, "-$100.00"}, |
|
57 |
||
58 |
// Euro |
|
59 |
{Locale.forLanguageTag("en-AT"), -100, "-\u20ac\u00a0100,00"}, |
|
60 |
{Locale.forLanguageTag("en-AT-u-cf-standard"), -100, "-\u20ac\u00a0100,00"}, |
|
61 |
{Locale.forLanguageTag("en-AT-u-cf-account"), -100, "-\u20ac\u00a0100,00"}, |
|
62 |
{Locale.forLanguageTag("en-AT-u-cf-bogus"), -100, "-\u20ac\u00a0100,00"}, |
|
63 |
||
64 |
// Rupee |
|
65 |
{Locale.forLanguageTag("en-IN"), -100, "-\u20b9\u00a0100.00"}, |
|
66 |
{Locale.forLanguageTag("en-IN-u-cf-standard"), -100, "-\u20b9\u00a0100.00"}, |
|
67 |
{Locale.forLanguageTag("en-IN-u-cf-account"), -100, "(\u20b9100.00)"}, |
|
68 |
{Locale.forLanguageTag("en-IN-u-cf-bogus"), -100, "-\u20b9\u00a0100.00"}, |
|
69 |
||
70 |
// Swiss franc |
|
71 |
{Locale.forLanguageTag("en-CH"), -100, "CHF-100.00"}, |
|
72 |
{Locale.forLanguageTag("en-CH-u-cf-standard"), -100, "CHF-100.00"}, |
|
73 |
{Locale.forLanguageTag("en-CH-u-cf-account"), -100, "CHF-100.00"}, |
|
74 |
{Locale.forLanguageTag("en-CH-u-cf-bogus"), -100, "CHF-100.00"}, |
|
75 |
||
76 |
// Region override |
|
77 |
{Locale.forLanguageTag("en-US-u-rg-CHZZZZ"), -100, "CHF-100.00"}, |
|
78 |
{Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-standard"), -100, "CHF-100.00"}, |
|
79 |
{Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-account"), -100, "CHF-100.00"}, |
|
80 |
{Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-bogus"), -100, "CHF-100.00"}, |
|
58058
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
81 |
|
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
82 |
// Numbering systems |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
83 |
// explicit |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
84 |
{Locale.forLanguageTag("zh-CN-u-nu-arab"), -100, "\u061c-\uffe5\u0661\u0660\u0660\u066b\u0660\u0660"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
85 |
{Locale.forLanguageTag("zh-CN-u-nu-arab-cf-standard"), -100, "\u061c-\uffe5\u0661\u0660\u0660\u066b\u0660\u0660"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
86 |
{Locale.forLanguageTag("zh-CN-u-nu-arab-cf-account"), -100, "\u061c-\uffe5\u0661\u0660\u0660\u066b\u0660\u0660"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
87 |
{Locale.forLanguageTag("zh-CN-u-nu-arab-cf-bogus"), -100, "\u061c-\uffe5\u0661\u0660\u0660\u066b\u0660\u0660"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
88 |
// implicit |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
89 |
{Locale.forLanguageTag("zh-CN"), -100, "-\uffe5100.00"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
90 |
{Locale.forLanguageTag("zh-CN-u-cf-standard"), -100, "-\uffe5100.00"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
91 |
{Locale.forLanguageTag("zh-CN-u-cf-account"), -100, "(\uffe5100.00)"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
92 |
{Locale.forLanguageTag("zh-CN-u-cf-bogus"), -100, "-\uffe5100.00"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
93 |
{Locale.forLanguageTag("ar-SA"), -100, "\u061c-\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
94 |
{Locale.forLanguageTag("ar-SA-u-cf-standard"), -100, "\u061c-\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
95 |
{Locale.forLanguageTag("ar-SA-u-cf-account"), -100, "\u061c-\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, |
b553ad95acf0
8230284: Accounting currency format support does not cope with explicit number system
naoto
parents:
57679
diff
changeset
|
96 |
{Locale.forLanguageTag("ar-SA-u-cf-bogus"), -100, "\u061c-\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, |
57679 | 97 |
}; |
98 |
} |
|
99 |
||
100 |
@Test(dataProvider="getInstanceData") |
|
101 |
public void test_getInstance(Locale locale, int amount, String expected) { |
|
102 |
assertEquals(NumberFormat.getCurrencyInstance(locale).format(amount), expected); |
|
103 |
} |
|
104 |
} |