Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/text/Collator/Bug5047314.java
41149 views
1
/*
2
* Copyright (c) 2009, 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
* @bug 5047314
27
* @summary verify that compare() and getCollationKey() don't go into an infinite loop for unfinished Thai/Lao text.
28
* @run main/timeout=60 Bug5047314
29
*/
30
import java.text.Collator;
31
import java.util.Locale;
32
33
public class Bug5047314 {
34
35
private static Collator colLao = Collator.getInstance(new Locale("lo"));
36
private static Collator colThai = Collator.getInstance(new Locale("th"));
37
38
private static String[] textLao = {
39
"\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"
40
};
41
private static String[] textThai = {
42
"\u0e40", "\u0e41", "\u0e42", "\u0e43", "\u0e44"
43
};
44
45
public static void main(String[] args) {
46
testLao1();
47
testLao2();
48
testThai1();
49
testThai2();
50
}
51
52
private static void testLao1() {
53
System.out.print("Test(Lao 1) .... ");
54
for (int i = 0; i < textLao.length; i++) {
55
colLao.compare(textLao[i], textLao[i]);
56
}
57
System.out.println("Passed.");
58
}
59
60
private static void testLao2() {
61
System.out.print("Test(Lao 2) .... ");
62
for (int i = 0; i < textLao.length; i++) {
63
colLao.compare(textLao[i], textLao[i]);
64
}
65
System.out.println("Passed.");
66
}
67
68
private static void testThai1() {
69
System.out.print("Test(Thai 1) .... ");
70
for (int i = 0; i < textThai.length; i++) {
71
colThai.compare(textThai[i], textThai[i]);
72
}
73
System.out.println("Passed.");
74
}
75
76
private static void testThai2() {
77
System.out.print("Test(Thai 2) .... ");
78
for (int i = 0; i < textThai.length; i++) {
79
colThai.getCollationKey(textThai[i]);
80
}
81
System.out.println("Passed.");
82
}
83
84
}
85
86