Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/text/Collator/KoreanTest.java
41149 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/12
26
* @bug 4176141 4655819
27
* @summary Regression tests for Korean Collation
28
* @modules jdk.localedata
29
*/
30
31
import java.text.*;
32
import java.util.*;
33
34
public class KoreanTest {
35
36
// NOTE:
37
// Golden data in this test case is locale data dependent and
38
// may need to be changed if the Korean locale collation rules
39
// are changed.
40
41
// And, CollationDecomp has been set to 0(NO_DECOMPOSITION) in
42
// LocaleElements_ko.java.
43
// This is very important to consider what is correct behavior in
44
// Korean Collator. Sometimes different from other locales.
45
46
/*
47
* TERTIARY(default): s1 < s2, SECONDARY: s1 < s2, PRIMARY: s1 < s2
48
*/
49
static final String[][] compData1 = {
50
/*
51
* Data to verify '<' relationship in LocaleElements_ja.java
52
*/
53
{"\uACE0\uC591\uC774", "\u732B",
54
"Hangul \"Cat\"(0xACE0 0xC591 0xC774) <---> Chinese Kanji \"Cat\"(0x732B)"},
55
{"\u30FB", "\u2025",
56
"Katakana middle dot(0x30FB) <---> Two dot leader(0x2025)"},
57
58
{"\u00B1", "\u2260",
59
"Plus-Minus Sign(0x00B1) <---> Not Equal To(0x2260)"},
60
{"\u3011", "\u2260",
61
"Right Black Lenticular Bracket(0x3011) <---> Not Equal To(0x2260)"},
62
{"\u2260", "\u2103",
63
"Not Equal To(0x2260) <---> Degree Celsius(0x2103)"},
64
{"\u2260", "\u2606",
65
"Not Equal To(0x2260) <---> White Star(0x2606)"},
66
67
// Unlike other locales' Collator, compare() returns -1 because of
68
// NO_DECOMPOSITION.
69
/* above "assumption" is no longer true, now we do normalize ("decomposition")
70
for the pattern in ko locale, but exclude those hangul syllables, so the
71
test case below need to be excluded from tiger/1.5
72
{"\u003D\u0338", "\u2260",
73
"Equal(0x003D)Combining Long Solidus Overlay(0x0338) <---> Not Equal To(0x2260)"},
74
*/
75
};
76
77
/*
78
* TERTIARY(default): s1 = s2, SECONDARY: s1 = s2, PRIMARY: s1 = s2
79
*/
80
static final String[][] compData2 = {
81
// Verify a character which has been added since Unicode 2.1.X.
82
{"\u798F", "\uFA1B",
83
"CJK Unified Ideograph \"FUKU\"(0x798F) <---> CJK Compatibility Ideograph \"FUKU\"(0xFA1B)"},
84
85
};
86
87
Collator col = Collator.getInstance(Locale.KOREA);
88
int result = 0;
89
90
public static void main(String[] args) throws Exception {
91
new KoreanTest().run();
92
}
93
94
public void run() {
95
//
96
// Test for TERTIARY(default)
97
//
98
doCompare(compData1);
99
doEquals(compData2);
100
101
//
102
// Test for SECONDARY
103
//
104
col.setStrength(Collator.SECONDARY);
105
doCompare(compData1);
106
doEquals(compData2);
107
108
//
109
// Test for PRIMARY
110
//
111
col.setStrength(Collator.PRIMARY);
112
doCompare(compData1);
113
doEquals(compData2);
114
115
if (result !=0) {
116
throw new RuntimeException("Unexpected results on Korean collation.");
117
}
118
}
119
120
/* compare() should return -1 for each combination. */
121
void doCompare(String[][] s) {
122
int value;
123
for (int i=0; i < s.length; i++) {
124
if ((value = col.compare(s[i][0], s[i][1])) > -1) {
125
result++;
126
System.err.println("TERTIARY: The first string should be less than the second string: " +
127
s[i][2] + " compare() returned " + value + ".");
128
}
129
}
130
}
131
132
/* equals() should return true for each combination. */
133
void doEquals(String[][] s) {
134
for (int i=0; i < s.length; i++) {
135
if (!col.equals(s[i][0], s[i][1])) {
136
result++;
137
System.err.println("TERTIARY: The first string should be equals to the second string: " +
138
s[i][2] + " compare() returned " +
139
col.compare(s[i][0], s[i][1] + "."));
140
}
141
}
142
}
143
}
144
145