2
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 4804273
|
|
27 |
* @summary updating collation tables for swedish
|
|
28 |
*/
|
|
29 |
|
|
30 |
import java.text.*;
|
|
31 |
import java.util.*;
|
|
32 |
|
|
33 |
public class Bug4804273 {
|
|
34 |
|
|
35 |
/********************************************************
|
|
36 |
*********************************************************/
|
|
37 |
public static void main (String[] args) {
|
|
38 |
int errors=0;
|
|
39 |
|
|
40 |
Locale loc = new Locale ("sv", "se"); // Swedish
|
|
41 |
|
|
42 |
Locale.setDefault (loc);
|
|
43 |
Collator col = Collator.getInstance ();
|
|
44 |
|
|
45 |
String[] data = {"A",
|
|
46 |
"Aa",
|
|
47 |
"Ae",
|
|
48 |
"B",
|
|
49 |
"Y",
|
|
50 |
"U\u0308", // U-umlaut
|
|
51 |
"Z",
|
|
52 |
"A\u030a", // A-ring
|
|
53 |
"A\u0308", // A-umlaut
|
|
54 |
"\u00c6", // AE ligature
|
|
55 |
"O\u0308", // O-umlaut
|
|
56 |
"a\u030b", // a-double-acute
|
|
57 |
"\u00d8", // O-stroke
|
|
58 |
"a",
|
|
59 |
"aa",
|
|
60 |
"ae",
|
|
61 |
"b",
|
|
62 |
"y",
|
|
63 |
"u\u0308", // u-umlaut
|
|
64 |
"z",
|
|
65 |
"A\u030b", // A-double-acute
|
|
66 |
"a\u030a", // a-ring
|
|
67 |
"a\u0308", // a-umlaut
|
|
68 |
"\u00e6", // ae ligature
|
|
69 |
"o\u0308", // o-umlaut
|
|
70 |
"\u00f8", // o-stroke
|
|
71 |
};
|
|
72 |
|
|
73 |
|
|
74 |
String[] sortedData = {"a",
|
|
75 |
"A",
|
|
76 |
"aa",
|
|
77 |
"Aa",
|
|
78 |
"ae",
|
|
79 |
"Ae",
|
|
80 |
"b",
|
|
81 |
"B",
|
|
82 |
"y",
|
|
83 |
"Y",
|
|
84 |
"u\u0308", // o-umlaut
|
|
85 |
"U\u0308", // o-umlaut
|
|
86 |
"z",
|
|
87 |
"Z",
|
|
88 |
"a\u030a", // a-ring
|
|
89 |
"A\u030a", // A-ring
|
|
90 |
"a\u0308", // a-umlaut
|
|
91 |
"A\u0308", // A-umlaut
|
|
92 |
"a\u030b", // a-double-acute
|
|
93 |
"A\u030b", // A-double-acute
|
|
94 |
"\u00e6", // ae ligature
|
|
95 |
"\u00c6", // AE ligature
|
|
96 |
"o\u0308", // o-umlaut
|
|
97 |
"O\u0308", // O-umlaut
|
|
98 |
"\u00f8", // o-stroke
|
|
99 |
"\u00d8", // O-stroke
|
|
100 |
};
|
|
101 |
|
|
102 |
Arrays.sort (data, col);
|
|
103 |
|
|
104 |
System.out.println ("Using " + loc.getDisplayName());
|
|
105 |
for (int i = 0; i < data.length; i++) {
|
|
106 |
System.out.println(data[i] + " : " + sortedData[i]);
|
|
107 |
if (sortedData[i].compareTo(data[i]) != 0) {
|
|
108 |
errors++;
|
|
109 |
}
|
|
110 |
}//end for
|
|
111 |
|
|
112 |
if (errors > 0)
|
|
113 |
throw new RuntimeException("There are " + errors + " words sorted incorrectly!");
|
|
114 |
}//end main
|
|
115 |
|
|
116 |
}//end class CollatorTest
|