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