Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/text/resources/Collator/Bug6755060.java
38855 views
1
/*
2
* Copyright (c) 2011, 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 6755060
27
* @summary updating collation tables for thai to make it consistent with CLDR 1.9
28
*/
29
30
import java.text.*;
31
import java.util.*;
32
33
public class Bug6755060 {
34
35
/********************************************************
36
*********************************************************/
37
public static void main (String[] args) {
38
39
Locale reservedLocale = Locale.getDefault();
40
41
try{
42
43
int errors=0;
44
45
Locale loc = new Locale ("th", "TH"); // Thai
46
47
Locale.setDefault (loc);
48
Collator col = Collator.getInstance ();
49
50
/*
51
* The original data "data" are the data to be sorted provided by the submitter of the CR.
52
* It's in correct order in accord with thai collation in CLDR 1.9. If we use old Java without this fix,
53
* the output order will be incorrect. Correct order will be turned into incorrect order.
54
55
* If fix is there, "data" after sorting will be unchanged, same as "sortedData". If fix is lost (regression),
56
* "data" after sorting will be changed, not as "sortedData".(not correct anymore)
57
58
* The submitter of the CR also gives a expected "sortedData" in the CR, but it's in accord with collation in CLDR 1.4.
59
* His data to be sorted are actually well sorted in accord with CLDR 1.9.
60
*/
61
62
String[] data = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
63
64
String[] sortedData = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
65
66
Arrays.sort (data, col);
67
68
System.out.println ("Using " + loc.getDisplayName());
69
for (int i = 0; i < data.length; i++) {
70
System.out.println(data[i] + " : " + sortedData[i]);
71
if (sortedData[i].compareTo(data[i]) != 0) {
72
errors++;
73
}
74
}//end for
75
76
if (errors > 0){
77
StringBuffer expected = new StringBuffer(), actual = new StringBuffer();
78
expected.append(sortedData[0]);
79
actual.append(data[0]);
80
81
for (int i=1; i<data.length; i++) {
82
expected.append(",");
83
expected.append(sortedData[i]);
84
85
actual.append(",");
86
actual.append(data[i]);
87
}
88
89
String errmsg = "Error is found in collation testing in Thai\n" + "exepected order is: " + expected.toString() + "\n" + "actual order is: " + actual.toString() + "\n";
90
91
throw new RuntimeException(errmsg);
92
}
93
}finally{
94
// restore the reserved locale
95
Locale.setDefault(reservedLocale);
96
}
97
98
}//end main
99
100
}//end class CollatorTest
101
102