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/G7Test.java
47182 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
26
* @library /java/text/testlib
27
* @summary test G7 Collation
28
*/
29
/*
30
*
31
*
32
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
33
* (C) Copyright IBM Corp. 1996, 1997 - All Rights Reserved
34
*
35
* Portions copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
36
*
37
* The original version of this source code and documentation is copyrighted
38
* and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
39
* materials are provided under terms of a License Agreement between Taligent
40
* and Sun. This technology is protected by multiple US and International
41
* patents. This notice and attribution to Taligent may not be removed.
42
* Taligent is a registered trademark of Taligent, Inc.
43
*
44
*/
45
46
/**
47
* G7 Test cases
48
*
49
* @author Helena Shih
50
*/
51
52
import java.text.Collator;
53
import java.text.RuleBasedCollator;
54
import java.util.Locale;
55
56
// G7 test program for printing out test results
57
58
public class G7Test extends CollatorTest {
59
60
public static void main(String[] args) throws Exception {
61
new G7Test().run(args);
62
}
63
64
private static final String testCases[] = {
65
"black-birds", // 0
66
"Pat", // 1
67
"p\u00E9ch\u00E9", // 2
68
"p\u00EAche", // 3
69
"p\u00E9cher", // 4
70
"p\u00EAcher", // 5
71
"Tod", // 6
72
"T\u00F6ne", // 7
73
"Tofu", // 8
74
"blackbirds", // 9
75
"Ton", // 10
76
"PAT", // 11
77
"blackbird", // 12
78
"black-bird", // 13
79
"pat", // 14
80
// Additional tests
81
"czar", // 15
82
"churo", // 16
83
"cat", // 17
84
"darn", // 18
85
"?", // 19
86
"quick", // 20
87
"#", // 21
88
"&", // 22
89
"aardvark", // 23
90
"a-rdvark", // 24
91
"abbot", // 25
92
"coop", // 26
93
"co-p", // 27
94
"cop", // 28
95
"zebra" // 29
96
};
97
98
// loop to TOTALTESTSET
99
private static final int[][] G7Results = {
100
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
101
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
102
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // en_US
103
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
104
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
105
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // en_GB
106
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
107
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
108
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // en_CA
109
{ 12, 13, 9, 0, 14, 1, 11, 3, 2, 4,
110
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
111
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // fr_FR
112
{ 12, 13, 9, 0, 14, 1, 11, 3, 2, 4,
113
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
114
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // fr_CA
115
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
116
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
117
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // de_DE
118
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
119
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
120
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // it_IT
121
{ 12, 13, 9, 0, 14, 1, 11, 2, 3, 4,
122
5, 6, 8, 10, 7, 31, 31, 31, 31, 31,
123
31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, // ja_JP
124
};
125
126
// new table collation with rules "& Z < p, P"
127
// loop to FIXEDTESTSET
128
private static final int[] Test1Results = {
129
12, 13, 9, 0, 6, 8, 10, 7, 14, 1,
130
11, 2, 3, 4, 5, 31, 31, 31, 31, 31,
131
31, 31, 31, 31, 31, 31, 31, 31, 31, 31
132
};
133
134
// new table collation with rules "& C < ch , cH, Ch, CH "
135
// loop to TOTALTESTSET
136
private static final int[] Test2Results = {
137
19, 22, 21, 23, 25, 24, 12, 13, 9, 0,
138
17, 26, 28, 27, 15, 16, 18, 14, 1, 11,
139
2, 3, 4, 5, 20, 6, 8, 10, 7, 29
140
};
141
142
// new table collation with rules
143
// "& Question-mark ; ? & Hash-mark ; # & Ampersand ; '&' "
144
// loop to TOTALTESTSET
145
private static final int[] Test3Results = {
146
23, 25, 22, 24, 12, 13, 9, 0, 17, 16,
147
26, 28, 27, 15, 18, 21, 14, 1, 11, 2,
148
3, 4, 5, 19, 20, 6, 8, 10, 7, 29
149
};
150
151
// analogous to Japanese rules
152
// " & aa ; a- & ee ; e- & ii ; i- & oo ; o- & uu ; u- "
153
// loop to TOTALTESTSET
154
private static final int[] Test4Results = {
155
19, 22, 21, 23, 24, 25, 12, 13, 9, 0,
156
17, 16, 26, 27, 28, 15, 18, 14, 1, 11,
157
2, 3, 4, 5, 20, 6, 8, 10, 7, 29
158
};
159
160
public void TestG7Data() {
161
for (int i = 0; i < locales.length; i++) {
162
Collator myCollation= null;
163
RuleBasedCollator tblColl1 = null;
164
165
try {
166
myCollation = Collator.getInstance(locales[i]);
167
tblColl1 = new RuleBasedCollator(((RuleBasedCollator)myCollation).getRules());
168
} catch (Exception foo) {
169
errln("Exception: " + foo.getMessage() +
170
" Locale : " + locales[i].getDisplayName() +
171
" getRules failed\n");
172
continue;
173
}
174
for (int j = 0; j < FIXEDTESTSET; j++) {
175
for (int n = j+1; n < FIXEDTESTSET; n++) {
176
doTest(tblColl1, testCases[G7Results[i][j]],
177
testCases[G7Results[i][n]], -1);
178
}
179
}
180
myCollation = null;
181
}
182
}
183
184
/*
185
* Demo Test 1 : Create a new table collation with rules "& Z < p, P"
186
*/
187
public void TestDemoTest1() {
188
int j = 0;
189
final Collator myCollation = Collator.getInstance(Locale.US);
190
final String defRules = ((RuleBasedCollator)myCollation).getRules();
191
RuleBasedCollator tblColl = null;
192
String newRules = defRules + " & Z < p, P";
193
194
try {
195
tblColl = new RuleBasedCollator(newRules);
196
for (j = 0; j < FIXEDTESTSET; j++) {
197
for (int n = j+1; n < FIXEDTESTSET; n++) {
198
doTest(tblColl, testCases[Test1Results[j]],
199
testCases[Test1Results[n]], -1);
200
}
201
}
202
tblColl = null;
203
} catch (Exception foo) {
204
errln("Exception: " + foo.getMessage() +
205
"\nDemo Test 1 Table Collation object creation failed.");
206
}
207
}
208
209
/*
210
* Demo Test 2 : Create a new table collation with rules
211
* "& C < ch , cH, Ch, CH"
212
*/
213
public void TestDemoTest2() {
214
final Collator myCollation = Collator.getInstance(Locale.US);
215
final String defRules = ((RuleBasedCollator)myCollation).getRules();
216
String newRules = defRules + "& C < ch , cH, Ch, CH";
217
218
try {
219
RuleBasedCollator tblColl = new RuleBasedCollator(newRules);
220
for (int j = 0; j < TOTALTESTSET; j++) {
221
for (int n = j+1; n < TOTALTESTSET; n++) {
222
doTest(tblColl, testCases[Test2Results[j]],
223
testCases[Test2Results[n]], -1);
224
}
225
}
226
} catch (Exception foo) {
227
errln("Exception: " + foo.getMessage() +
228
"\nDemo Test 2 Table Collation object creation failed.\n");
229
}
230
}
231
232
/*
233
* Demo Test 3 : Create a new table collation with rules
234
* "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'"
235
*/
236
public void TestDemoTest3() {
237
final Collator myCollation = Collator.getInstance(Locale.US);
238
final String defRules = ((RuleBasedCollator)myCollation).getRules();
239
RuleBasedCollator tblColl = null;
240
String newRules = defRules + "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&";
241
242
try {
243
tblColl = new RuleBasedCollator(newRules);
244
for (int j = 0; j < TOTALTESTSET; j++) {
245
for (int n = j+1; n < TOTALTESTSET; n++) {
246
doTest(tblColl, testCases[Test3Results[j]],
247
testCases[Test3Results[n]], -1);
248
}
249
}
250
} catch (Exception foo) {
251
errln("Exception: " + foo.getMessage() +
252
"\nDemo Test 3 Table Collation object creation failed.");
253
}
254
}
255
256
/*
257
* Demo Test 4 : Create a new table collation with rules
258
* " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' "
259
*/
260
public void TestDemoTest4() {
261
final Collator myCollation = Collator.getInstance(Locale.US);
262
final String defRules = ((RuleBasedCollator)myCollation).getRules();
263
RuleBasedCollator tblColl = null;
264
String newRules = defRules + " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' ";
265
266
try {
267
tblColl = new RuleBasedCollator(newRules);
268
for (int j = 0; j < TOTALTESTSET; j++) {
269
for (int n = j+1; n < TOTALTESTSET; n++) {
270
doTest(tblColl, testCases[Test4Results[j]],
271
testCases[Test4Results[n]], -1);
272
}
273
}
274
} catch (Exception foo) {
275
errln("Exception: " + foo.getMessage() +
276
"\nDemo Test 4 Table Collation object creation failed.");
277
}
278
tblColl = null;
279
}
280
281
private static final int FIXEDTESTSET = 15;
282
private static final int TOTALTESTSET = 30;
283
284
private static final Locale locales[] = {
285
Locale.US,
286
Locale.UK,
287
Locale.CANADA,
288
Locale.FRANCE,
289
Locale.CANADA_FRENCH,
290
Locale.GERMANY,
291
Locale.JAPAN,
292
Locale.ITALY
293
};
294
}
295
296