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