< prev index next >

test/jdk/java/lang/Character/UnicodeCasingTest.java

Print this page
rev 54996 : 8221431: Support for Unicode 12.1
Reviewed-by:
   1 /*
   2  * Copyright (c) 2018, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * @test
  28  * @bug 4397357 6565620 6959267 8032446 8072600
  29  * @summary Confirm normal case mappings are handled correctly.

  30  * @run main/timeout=200 UnicodeCasingTest
  31  */
  32 
  33 import java.io.BufferedReader;
  34 import java.io.File;
  35 import java.io.FileReader;
  36 import java.util.ArrayList;
  37 import java.util.List;
  38 import java.util.Locale;
  39 
  40 public class UnicodeCasingTest {
  41 
  42     private static boolean err = false;
  43 
  44     // Locales which are used for testing
  45     private static List<Locale> locales = new ArrayList<>();
  46     static {
  47         locales.add(new Locale("az", ""));
  48         locales.addAll(java.util.Arrays.asList(Locale.getAvailableLocales()));
  49     }
  50 
  51 
  52     public static void main(String[] args) {
  53         UnicodeCasingTest specialCasingTest = new UnicodeCasingTest();
  54         specialCasingTest.test();
  55     }
  56 
  57     private void test() {
  58         Locale defaultLocale = Locale.getDefault();
  59 
  60         BufferedReader in = null;
  61 
  62         try {
  63             File file = new File(System.getProperty("test.src", "."),
  64                                  "UnicodeData.txt");
  65 
  66             int locale_num = locales.size();
  67             for (int l = 0; l < locale_num; l++) {
  68                 Locale locale = locales.get(l);
  69                 Locale.setDefault(locale);
  70                 System.out.println("Testing on " + locale + " locale....");
  71 
  72                 in = new BufferedReader(new FileReader(file));
  73 
  74                 String line;
  75                 while ((line = in.readLine()) != null) {
  76                     if (line.length() == 0 || line.charAt(0) == '#') {
  77                         continue;
  78                     }
  79 
  80                     test(line);
  81                 }
  82 
  83                 in.close();
  84                 in = null;


   1 /*
   2  * Copyright (c) 2018, 2019, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * @test
  28  * @bug 4397357 6565620 6959267 8032446 8072600 8221431
  29  * @summary Confirm normal case mappings are handled correctly.
  30  * @library /lib/testlibrary/java/lang
  31  * @run main/timeout=200 UnicodeCasingTest
  32  */
  33 
  34 import java.io.BufferedReader;
  35 import java.io.File;
  36 import java.io.FileReader;
  37 import java.util.ArrayList;
  38 import java.util.List;
  39 import java.util.Locale;
  40 
  41 public class UnicodeCasingTest {
  42 
  43     private static boolean err = false;
  44 
  45     // Locales which are used for testing
  46     private static List<Locale> locales = new ArrayList<>();
  47     static {
  48         locales.add(new Locale("az", ""));
  49         locales.addAll(java.util.Arrays.asList(Locale.getAvailableLocales()));
  50     }
  51 
  52 
  53     public static void main(String[] args) {
  54         UnicodeCasingTest specialCasingTest = new UnicodeCasingTest();
  55         specialCasingTest.test();
  56     }
  57 
  58     private void test() {
  59         Locale defaultLocale = Locale.getDefault();
  60 
  61         BufferedReader in = null;
  62 
  63         try {
  64             File file = UCDFiles.UNICODE_DATA.toFile();

  65 
  66             int locale_num = locales.size();
  67             for (int l = 0; l < locale_num; l++) {
  68                 Locale locale = locales.get(l);
  69                 Locale.setDefault(locale);
  70                 System.out.println("Testing on " + locale + " locale....");
  71 
  72                 in = new BufferedReader(new FileReader(file));
  73 
  74                 String line;
  75                 while ((line = in.readLine()) != null) {
  76                     if (line.length() == 0 || line.charAt(0) == '#') {
  77                         continue;
  78                     }
  79 
  80                     test(line);
  81                 }
  82 
  83                 in.close();
  84                 in = null;


< prev index next >