1/*
2 * Copyright (c) 2003, 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 * @bug 4932968 5015215
27 * @library /java/text/testlib
28 * @summary test Vietnamese Collation
29 * @modules jdk.localedata
30 */
31
32/*
33 *******************************************************************************
34 * (C) Copyright IBM Corp. 1996-2003 - All Rights Reserved                     *
35 *                                                                             *
36 * The original version of this source code and documentation is copyrighted   *
37 * and owned by IBM, These materials are provided under terms of a License     *
38 * Agreement between IBM and Sun. This technology is protected by multiple     *
39 * US and International patents. This notice and attribution to IBM may not    *
40 * to removed.                                                                 *
41 *******************************************************************************
42 */
43
44import java.util.Locale;
45import java.text.Collator;
46
47// Quick dummy program for printing out test results
48public class VietnameseTest extends CollatorTest {
49
50    public static void main(String[] args) throws Exception {
51        new VietnameseTest().run(args);
52    }
53
54    private final static String testPS[] = {
55        "a",
56        "a",
57        "\u00c2",
58        "Cz",
59        "d",
60        "e",
61        "e",
62        "\u1ec7",
63        "gz",
64        "i",
65        "kz",
66        "nz",
67        "nh",
68        "o",
69        "o",
70        "\u01a0",
71        "pz",
72        "tz",
73        "tr",
74        "u",
75        "u",
76        "y"
77    };
78
79    private final static String testPT[] = {
80        "\u00e0",
81        "\u0102",
82        "\u0102",
83        "Ch",
84        "\u0110",
85        "\u0111",
86        "\u1eb9",
87        "\u1eb9",
88        "gi",
89        "\u0128",
90        "kh",
91        "ng",
92        "ng",
93        "\u00f2",
94        "\u00f4",
95        "\u00f4",
96        "ph",
97        "th",
98        "th",
99        "\u1ee5",
100        "\u01b0",
101        "\u1ef4"
102    };
103
104    private final static int testPR[] = {
105        0,
106        -1,
107        1,
108        1,
109        -1,
110        1,
111        0,
112        1,
113        1,
114        0,
115        1,
116        1,
117        1,
118        0,
119        -1,
120        1,
121        1,
122        1,
123        1,
124        0,
125        -1,
126        0
127    };
128
129    private final static String testT[] = {
130        "a",
131        "A",
132        "\u00e0",
133        "\u00c0",
134        "\u1ea3",
135        "\u1ea2",
136        "\u00e3",
137        "\u00c3",
138        "\u00e1",
139        "\u00c1",
140        "\u1ea1",
141        "\u1ea0",
142        "\u0103",
143        "\u0102",
144        "\u1eb1",
145        "\u1eb0",
146        "\u1eb3",
147        "\u1eb2",
148        "\u1eb5",
149        "\u1eb4",
150        "\u1eaf",
151        "\u1eae",
152        "\u1eb7",
153        "\u1eb6",
154        "\u00e2",
155        "\u00c2",
156        "\u1ea7",
157        "\u1ea6",
158        "\u1ea9",
159        "\u1ea8",
160        "\u1eab",
161        "\u1eaa",
162        "\u1ea5",
163        "\u1ea4",
164        "\u1ead",
165        "\u1eac",
166        "b",
167        "B",
168        "c",
169        "C",
170        "ch",
171        "Ch",
172        "CH",
173        "d",
174        "D",
175        "\u0111",
176        "\u0110",
177        "e",
178        "E",
179        "\u00e8",
180        "\u00c8",
181        "\u1ebb",
182        "\u1eba",
183        "\u1ebd",
184        "\u1ebc",
185        "\u00e9",
186        "\u00c9",
187        "\u1eb9",
188        "\u1eb8",
189        "\u00ea",
190        "\u00ca",
191        "\u1ec1",
192        "\u1ec0",
193        "\u1ec3",
194        "\u1ec2",
195        "\u1ec5",
196        "\u1ec4",
197        "\u1ebf",
198        "\u1ebe",
199        "\u1ec7",
200        "\u1ec6",
201        "f",
202        "F",
203        "g",
204        "G",
205        "gi",
206        "Gi",
207        "GI",
208        "gz",
209        "h",
210        "H",
211        "i",
212        "I",
213        "\u00ec",
214        "\u00cc",
215        "\u1ec9",
216        "\u1ec8",
217        "\u0129",
218        "\u0128",
219        "\u00ed",
220        "\u00cd",
221        "\u1ecb",
222        "\u1eca",
223        "j",
224        "J",
225        "k",
226        "K",
227        "kh",
228        "Kh",
229        "KH",
230        "kz",
231        "l",
232        "L",
233        "m",
234        "M",
235        "n",
236        "N",
237        "ng",
238        "Ng",
239        "NG",
240        "ngz",
241        "nh",
242        "Nh",
243        "NH",
244        "nz",
245        "o",
246        "O",
247        "\u00f2",
248        "\u00d2",
249        "\u1ecf",
250        "\u1ece",
251        "\u00f5",
252        "\u00d5",
253        "\u00f3",
254        "\u00d3",
255        "\u1ecd",
256        "\u1ecc",
257        "\u00f4",
258        "\u00d4",
259        "\u1ed3",
260        "\u1ed2",
261        "\u1ed5",
262        "\u1ed4",
263        "\u1ed7",
264        "\u1ed6",
265        "\u1ed1",
266        "\u1ed0",
267        "\u1ed9",
268        "\u1ed8",
269        "\u01a1",
270        "\u01a0",
271        "\u1edd",
272        "\u1edc",
273        "\u1edf",
274        "\u1ede",
275        "\u1ee1",
276        "\u1ee0",
277        "\u1edb",
278        "\u1eda",
279        "\u1ee3",
280        "\u1ee2",
281        "p",
282        "P",
283        "ph",
284        "Ph",
285        "PH",
286        "pz",
287        "q",
288        "Q",
289        "r",
290        "R",
291        "s",
292        "S",
293        "t",
294        "T",
295        "th",
296        "Th",
297        "TH",
298        "thz",
299        "tr",
300        "Tr",
301        "TR",
302        "tz",
303        "u",
304        "U",
305        "\u00f9",
306        "\u00d9",
307        "\u1ee7",
308        "\u1ee6",
309        "\u0169",
310        "\u0168",
311        "\u00fa",
312        "\u00da",
313        "\u1ee5",
314        "\u1ee4",
315        "\u01b0",
316        "\u01af",
317        "\u1eeb",
318        "\u1eea",
319        "\u1eed",
320        "\u1eec",
321        "\u1eef",
322        "\u1eee",
323        "\u1ee9",
324        "\u1ee8",
325        "\u1ef1",
326        "\u1ef0",
327        "v",
328        "V",
329        "w",
330        "W",
331        "x",
332        "X",
333        "y",
334        "Y",
335        "\u1ef3",
336        "\u1ef2",
337        "\u1ef7",
338        "\u1ef6",
339        "\u1ef9",
340        "\u1ef8",
341        "\u00fd",
342        "\u00dd",
343        "\u1ef5",
344        "\u1ef4",
345        "z",
346        "Z"
347    };
348
349    public void TestPrimary() {
350        doTest(myCollation, Collator.PRIMARY, testPS, testPT, testPR);
351    }
352
353    public void TestTertiary() {
354        int testLength = testT.length;
355
356        myCollation.setStrength(Collator.TERTIARY);
357        for (int i = 0; i < testLength - 1; i++) {
358            for (int j = i+1; j < testLength; j++) {
359                doTest(myCollation, testT[i], testT[j], -1);
360            }
361        }
362    }
363
364    private final Collator myCollation = Collator.getInstance(new Locale("vi", "VN"));
365}
366