Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/text/Collator/JapaneseTest.java
47066 views
1
/*
2
* Copyright (c) 1997, 2016, 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
* @test 1.1 02/09/11
26
* @bug 4176141 4655819
27
* @summary Regression tests for Japanese Collation
28
*/
29
30
import java.text.*;
31
import java.util.*;
32
33
public class JapaneseTest {
34
35
// NOTE:
36
// Golden data in this test case is locale data dependent and
37
// may need to be changed if the Japanese locale collation rules
38
// are changed.
39
40
/*
41
* | NO_DECOMP(default) | CANONICAL_DECOMP | FULL_DECOMP
42
* -------------------+--------------------+------------------+-------------
43
* PRIMARY | s1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
44
* SECONDARY | s1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
45
* TERTIARY(default) | S1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
46
*/
47
static final int[][] results1 = {
48
{ -1, -1, -1},
49
{ -1, -1, -1},
50
{ -1, -1, -1},
51
};
52
static final String[][] compData1 = {
53
/*
54
* Data to verify '<' relationship in LocaleElements_ja.java
55
*/
56
{"\u3084", "\u30E6",
57
"Hiragana \"YA\"(0x3084) <---> Katakana \"YU\"(0x30E6)"},
58
{"\u30E6", "\u3088",
59
"Katakana \"YU\"(0x30E6) <---> Hiragana \"YO\"(0x3088)"},
60
{"\u00B1", "\u2260",
61
"Plus-Minus Sign(0x00B1) <---> Not Equal To(0x2260)"},
62
{"\u3011", "\u2260",
63
"Right Black Lenticular Bracket(0x3011) <---> Not Equal To(0x2260)"},
64
{"\u2260", "\u2103",
65
"Not Equal To(0x2260) <---> Degree Celsius(0x2103)"},
66
{"\u2260", "\u2606",
67
"Not Equal To(0x2260) <---> White Star(0x2606)"},
68
{"\u30FD", "\u309E",
69
"Katakana Iteration Mark(0x30FD) <---> Hiragana Voiced Iteration Mark(0x309E)"},
70
{"\u3059\u309D", "\u3059\u309E",
71
"Hiragana \"SU\"(0x3059)Hiragana Iteration Mark(0x309D) <---> Hiragana \"SU\"(0x3059)Hiragana Voiced Iteration Mark(0x309E)"},
72
{"\u821E", "\u798F",
73
"CJK Unified Ideograph(0x821E) <---> CJK Unified Ideograph(0x798F)"},
74
75
/*
76
* Data to verify normalization
77
*/
78
{"\u2260", "\u225F",
79
"Not Equal To(0x2260) <---> Questioned Equal To(0x225F)"},
80
{"\u226E", "\u2260",
81
"Not Less-than(0x226E) <---> Not Equal To(0x2260)"},
82
{"\u226E", "\u226D",
83
"Not Less-than(0x226E) <---> Not Equivalent To(0x226D)"},
84
};
85
86
/*
87
* | NO_DECOMP(default) | CANONICAL_DECOMP | FULL_DECOMP
88
* -------------------+--------------------+------------------+-------------
89
* PRIMARY | s1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
90
* SECONDARY | s1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
91
* TERTIARY(default) | S1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
92
*/
93
static final int[][] results2 = {
94
{ 0, 0, 0},
95
{ -1, -1, -1},
96
{ -1, -1, -1},
97
};
98
static final String[][] compData2 = {
99
/*
100
* Data to verify ';' relationship in LocaleElements_ja.java
101
*/
102
{"\u3099", "\u309A",
103
"Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Combining Katakana-Hiragana Semi-voiced Sound Mark(0x309A)"},
104
{"\u3053\u3046\u3068\u3046", "\u3053\u3046\u3068\u3099\u3046",
105
"Hiragana \"KOUTOU\"(0x3053 0x3046 0x3068 0x3046) <---> Hiragana \"KOUTO\"(0x3053 0x3046 0x3068)Combining Katakana-Hiragana Voiced Sound Mark(0X3099)\"U\"(0x3046)"},
106
{"\u3053\u3046\u3068\u3046", "\u3053\u3046\u3069\u3046",
107
"Hiragana \"KOUTOU\"(0x3053 0x3046 0x3068 0x3046) <---> Hiragana \"KOUDOU\"(0x3053 0x3046 0x3069 0x3046)"},
108
{"\u3053\u3046\u3069\u3046", "\u3054\u3046\u3068\u3046",
109
"Hiragana \"KOUTOU\"(0x3053 0x3046 0x3069 0x3046) <---> Hiragana \"GOUTOU\"(0x3054 0x3046 0x3068 0x3046)"},
110
{"\u3054\u3046\u3068\u3046", "\u3054\u3046\u3069\u3046",
111
"Hiragana \"GOUTOU\"(0x3054 0x3046 0x3068 0x3046) <---> Hiragana \"GOUDOU\"(0x3054 0x3046 0x3069 0x3046)"},
112
};
113
114
/*
115
* | NO_DECOMP(default) | CANONICAL_DECOMP | FULL_DECOMP
116
* -------------------+--------------------+------------------+-------------
117
* PRIMARY | s1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
118
* SECONDARY | s1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
119
* TERTIARY(default) | S1 < s2 (-1) | s1 < s2 (-1) | s1 < s2 (-1)
120
*/
121
static final int[][] results3 = {
122
{ 0, 0, 0},
123
{ 0, 0, 0},
124
{ -1, -1, -1},
125
};
126
static final String[][] compData3 = {
127
/*
128
* Data to verify ',' relationship in LocaleElements_ja.java
129
*/
130
{"\u3042", "\u3041",
131
"Hiragana \"A\"(0x3042) <---> Hiragana \"a\"(0x3041)"},
132
{"\u3041", "\u30A2",
133
"Hiragana \"a\"(0x3041) <---> Katakana \"A\"(0x30A2)"},
134
{"\u30A2", "\u30A1",
135
"Katakana \"A\"(0x30A2) <---> Katakana \"a\"(0x30A1)"},
136
{"\u3094", "\u30F4",
137
"Hiragana \"VU\"(0x3094) <---> Katakana \"VU\"(0x30F4)"},
138
{"\u3094", "\u30A6\u3099",
139
"Hiragana \"VU\"(0x3094) <---> Katakana \"U\"(0x30A6)Combining Katakana-Hiragana Voiced Sound Mark(0x3099)"},
140
{"\u3046\u3099", "\u30F4",
141
"Hiragana \"U\"(0x3046)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VU\"(0x30F4)"},
142
{"\u3046\u3099", "\u30A6\u3099",
143
"Hiragana \"U\"(0x3046)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"U\"(0x30A6)Combining Katakana-Hiragana Voiced Sound Mark(0x3099)"},
144
{"\u30AB\u30A2", "\u30AB\u30FC",
145
"Katakana \"KAA\"(0x30AB 0x30A2) <---> Katakana \"KA-\"(0x30AB 0x30FC)"},
146
{"\u30CB\u30A1\u30A2", "\u30CB\u30A1\u30FC",
147
"Katakana \"NyaA\"(0x30CB 0x30A1 0x30A2) <---> Katakana \"Nya-\"(0x30CB 0x30A1 0x30FC)"},
148
{"\u30B3\u30AA\u30D2\u30A4", "\u30B3\u30FC\u30D2\u30FC",
149
"Katakana \"KOOHII\"(0x30B3 0x30AA 0x30D2 0x30A4) <---> Katakana \"KO-HI-\"(0x30B3 0x30FC 0x30D2 0x30FC)"},
150
{"\u308A\u3088\u3046", "\u308A\u3087\u3046",
151
"Hiragana \"RIYOU\"(0x308A 0x3088 0x3046) <---> Hiragana \"Ryou\"(0x308A 0x3087 0x3046)"},
152
{"\u3081\u3064\u304D", "\u3081\u3063\u304D",
153
"Hiragana \"METSUKI\"(0x3081 0x3064 0x304D) <---> Hiragana \"MEKKI\"(0x3081 0x3063 0x304D)"},
154
{"\u3075\u3042\u3093", "\u30D5\u30A1\u30F3",
155
"Hiragana \"FUAN\"(0x3075 0x3042 0x3093) <---> Katakana \"FUaN\"(0x30D5 0x30A1 0x30F3)"},
156
{"\u3075\u3041\u3093", "\u30D5\u30A2\u30F3",
157
"Hiragana \"FUaN\"(0x3075 0x3041 0x3093) <---> Katakana \"FUAN\"(0x30D5 0x30A2 0x30F3)"},
158
{"\u30D5\u30A2\u30F3", "\u30D5\u30A1\u30F3",
159
"Katakana \"FUAN\"(0x30D5 0x30A2 0x30F3) <---> Katakana \"FUaN\"(0x30D5 0x30A1 0x30F3)"},
160
};
161
162
/*
163
* | NO_DECOMP(default) | CANONICAL_DECOMP | FULL_DECOMP
164
* -------------------+--------------------+------------------+-------------
165
* PRIMARY | s1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
166
* SECONDARY | s1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
167
* TERTIARY(default) | S1 = s2 (0) | s1 = s2 (0) | s1 = s2 (0)
168
*/
169
static final int[][] results4 = {
170
{ 0, 0, 0},
171
{ 0, 0, 0},
172
{ 0, 0, 0},
173
};
174
static final String[][] compData4 = {
175
/*
176
* Data to verify Japanese normalization
177
*/
178
{"\u309E", "\u309D\u3099",
179
"Hiragana Voiced Iteration Mark(0x309E) <---> Hiragana Iteration Mark(0x309D)Combining Katakana-Hiragana Voiced Sound Mark(0x3099)"},
180
{"\u30FE", "\u30FD\u3099",
181
"Katakana Voiced Iteration Mark(0x30FE) <---> Katakana iteration mark(0x30FD)Combining Katakana-Hiragana Voiced Sound Mark(0x3099)"},
182
{"\u306F\u3099", "\u3070",
183
"Hiragana \"HA\"(0x306F)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Hiragana \"BA\"(0x3070)"},
184
{"\u306F\u309A", "\u3071",
185
"Hiragana \"HA\"(0x306F)Combining Katakana-Hiragana Semi-voiced Sound Mark(0x309A) <---> Hiragana \"PA\"(0x3071)"},
186
{"\u30EF\u3099", "\u30F7",
187
"Katakana \"WA\"(0x306F)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VA\"(0x30F7)"},
188
{"\u30F0\u3099", "\u30F8",
189
"Katakana \"WI\"(0x30F0)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VI\"(0x30F8)"},
190
{"\u30F1\u3099", "\u30F9",
191
"Katakana \"WE\"(0x30F1)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VE\"(0x30F9)"},
192
{"\u30F2\u3099", "\u30FA",
193
"Katakana \"WO\"(0x30F2)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VO\"(0x30FA)"},
194
{"\u3046\u3099", "\u3094",
195
"Hiragana \"U\"(0x3046)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Hiragana \"VU\"(0x3094)"},
196
{"\u30A6\u3099", "\u30F4",
197
"Katakana \"U\"(0x30A6)Combining Katakana-Hiragana Voiced Sound Mark(0x3099) <---> Katakana \"VU\"(0x30F4)"},
198
199
// verify normalization
200
{"\u2260", "\u003D\u0338",
201
"Not Equal To(0x2260) <---> Equal(0x003D)Combining Long Solidus Overlay(0x0338)"},
202
{"\u2262", "\u2261\u0338",
203
"Not Identical To(0x2262) <---> Identical To(0x2261)Combining Long Solidus Overlay(0x0338)"},
204
{"\u226E", "\u003C\u0338",
205
"Not Less-than(0x226E) <---> Less-than Sign(0x003C)Combining Long Solidus Overlay(0x0338)"},
206
207
// Verify a character which has been added since Unicode 2.1.X.
208
{"\u798F", "\uFA1B",
209
"CJK Unified Ideograph \"FUKU\"(0x798F) <---> CJK Compatibility Ideograph \"FUKU\"(0xFA1B)"},
210
};
211
212
/*
213
* | NO_DECOMP(default) | CANONICAL_DECOMP | FULL_DECOMP
214
* -------------------+--------------------+------------------+-------------
215
* PRIMARY | s1 > s2 (1) | s1 = s2 (0) | s1 = s2 (0)
216
* SECONDARY | s1 > s2 (1) | s1 = s2 (0) | s1 = s2 (0)
217
* TERTIARY(default) | S1 > s2 (1) | s1 = s2 (0) | s1 = s2 (0)
218
*/
219
static final int[][] results5 = {
220
{ 1, 0, 0},
221
{ 1, 0, 0},
222
{ 1, 0, 0},
223
};
224
static final String[][] compData5 = {
225
/*
226
* Data to verify normalization
227
*/
228
{"\u226D", "\u224D\u0338",
229
"Not Equivalent To(0x226D) <---> Equivalent To(0x224D)Combining Long Solidus Overlay(0x0338)"},
230
};
231
232
static final int[][] results6 = {
233
{ 1, -1, -1},
234
{ 1, -1, -1},
235
{ 1, -1, -1},
236
};
237
static final String[][] compData6 = {
238
/*
239
* Data to verify normalization
240
*/
241
{"\u226D", "\u226C",
242
"Not Equivalent To(0x226D) <---> Between(0x226C)"},
243
{"\u226D", "\u225F",
244
"Not Equivalent To(0x226D) <---> Questioned Equal To(0x225F)"},
245
};
246
247
248
/*
249
* The following data isn't used at the moment because iteration marks
250
* aren't supported now.
251
*/
252
static final String[][] compData0 = {
253
{"\u307F\u307F", "\u307F\u309D",
254
"Hiragana \"MIMI\"(0x307F 0x307F) <---> Hiragana \"MI\"(0x307F)Hiragana Iteration Mark(0x309D)"},
255
{"\u3044\u3059\u305A", "\u3044\u3059\u309E",
256
"Hiragana \"ISUZU\"(0x3044 0x3059 0x305A) <---> Hiragana \"ISU\"(0x3044 0x3059)Hiragana Voiced Iteration Mark(0x309E)"},
257
{"\u30DF\u30DF", "\u30DF\u30FD",
258
"Katakana \"MIMI\"(0x30DF 0x30DF) <---> Katakana \"MI\"(0x30DF)Katakana Iteration Mark(0x30FD)"},
259
{"\u30A4\u30B9\u30BA", "\u30A4\u30B9\u30FE",
260
"Katakana \"ISUZU\"(0x30A4 0x30B9 0x30BA) <---> Katakana \"ISU\"(0x30A4 0x30B9)Katakana Voiced Iteration Mark(0x30FE)"},
261
};
262
263
264
static final String[] decomp_name = {
265
"NO_DECOMP", "CANONICAL_DECOMP", "FULL_DECOMP"
266
};
267
268
static final String[] strength_name = {
269
"PRIMARY", "SECONDARY", "TERTIARY"
270
};
271
272
273
Collator col = Collator.getInstance(Locale.JAPAN);
274
int result = 0;
275
276
public static void main(String[] args) throws Exception {
277
new JapaneseTest().run();
278
}
279
280
public void run() {
281
// Use all available localse on the initial testing....
282
// Locale[] locales = Locale.getAvailableLocales();
283
Locale[] locales = { Locale.getDefault() };
284
285
for (int l = 0; l < locales.length; l++) {
286
Locale.setDefault(locales[l]);
287
288
for (int decomp = 0; decomp < 3; decomp++) {// See decomp_name.
289
col.setDecomposition(decomp);
290
291
for (int strength = 0; strength < 3; strength++) {// See strength_name.
292
// System.err.println("\n" + locales[l] + ": " + strength_name[strength] + " --- " + decomp_name[decomp]);
293
294
col.setStrength(strength);
295
doCompare(compData1, results1[strength][decomp], strength, decomp);
296
doCompare(compData2, results2[strength][decomp], strength, decomp);
297
doCompare(compData3, results3[strength][decomp], strength, decomp);
298
doCompare(compData4, results4[strength][decomp], strength, decomp);
299
doCompare(compData5, results5[strength][decomp], strength, decomp);
300
doCompare(compData6, results6[strength][decomp], strength, decomp);
301
}
302
}
303
}
304
305
/* Check result */
306
if (result !=0) {
307
throw new RuntimeException("Unexpected results on Japanese collation.");
308
}
309
}
310
311
void doCompare(String[][] s, int expectedValue, int strength, int decomp) {
312
int value;
313
for (int i=0; i < s.length; i++) {
314
if ((value = col.compare(s[i][0], s[i][1])) != expectedValue) {
315
result++;
316
System.err.println(strength_name[strength] +
317
": compare() returned unexpected value.(" +
318
value + ") on " + decomp_name[decomp] +
319
" Expected(" + expectedValue +
320
") for " + s[i][2]);
321
}
322
}
323
}
324
}
325
326