4138N/A/*
4138N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4138N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4138N/A *
4138N/A * This code is free software; you can redistribute it and/or modify it
4138N/A * under the terms of the GNU General Public License version 2 only, as
4138N/A * published by the Free Software Foundation.
4138N/A *
4138N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4138N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4138N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4138N/A * version 2 for more details (a copy is included in the LICENSE file that
4138N/A * accompanied this code).
4138N/A *
4138N/A * You should have received a copy of the GNU General Public License version
4138N/A * 2 along with this work; if not, write to the Free Software Foundation,
4138N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4138N/A *
4138N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4138N/A * or visit www.oracle.com if you need additional information or have any
4138N/A * questions.
4138N/A */
4138N/A
4138N/A
4138N/A/**
4138N/A * @test
4138N/A * @bug 7037261
4138N/A * @summary Check j.l.Character.isLowerCase/isUppercase/isAlphabetic/isIdeographic
4138N/A */
4138N/A
4138N/Aimport java.util.regex.*;
4138N/Aimport java.util.*;
4138N/Aimport java.io.*;
4138N/Aimport static java.lang.Character.*;
4138N/A
4138N/Apublic class CheckProp {
4138N/A
4138N/A public static void main(String[] args) throws IOException {
4138N/A File fPropList = new File(System.getProperty("test.src", "."), "PropList.txt");
4138N/A int i, j;
4138N/A BufferedReader sbfr = new BufferedReader(new FileReader(fPropList));
4138N/A Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s*;\\s+(\\w+)\\s+#.*").matcher("");
4138N/A Map<String, ArrayList<Integer>> propMap = new LinkedHashMap<>();
4138N/A
4138N/A String line = null;
4138N/A int lineNo = 0;
4138N/A while ((line = sbfr.readLine()) != null) {
4138N/A lineNo++;
4138N/A if (line.length() <= 1 || line.charAt(0) == '#') {
4138N/A continue;
4138N/A }
4138N/A m.reset(line);
4138N/A if (m.matches()) {
4138N/A int start = Integer.parseInt(m.group(1), 16);
4138N/A int end = (m.group(2)==null)?start
4138N/A :Integer.parseInt(m.group(2), 16);
4138N/A String name = m.group(3);
4138N/A
4138N/A ArrayList<Integer> list = propMap.get(name);
4138N/A if (list == null) {
4138N/A list = new ArrayList<Integer>();
4138N/A propMap.put(name, list);
4138N/A }
4138N/A while (start <= end)
4138N/A list.add(start++);
4138N/A } else {
4138N/A System.out.printf("Warning: Unrecognized line %d <%s>%n", lineNo, line);
4138N/A }
4138N/A }
4138N/A sbfr.close();
4138N/A //for (String name: propMap.keySet()) {
4138N/A // System.out.printf("%s %d%n", name, propMap.get(name).size());
4138N/A //}
4138N/A
4138N/A Integer[] otherLowercase = propMap.get("Other_Lowercase").toArray(new Integer[0]);
4138N/A Integer[] otherUppercase = propMap.get("Other_Uppercase").toArray(new Integer[0]);
4138N/A Integer[] otherAlphabetic = propMap.get("Other_Alphabetic").toArray(new Integer[0]);
4138N/A Integer[] ideographic = propMap.get("Ideographic").toArray(new Integer[0]);
4138N/A
4138N/A int fails = 0;
4138N/A for (int cp = MIN_CODE_POINT; cp < MAX_CODE_POINT; cp++) {
4138N/A int type = getType(cp);
4138N/A if (isLowerCase(cp) !=
4138N/A (type == LOWERCASE_LETTER ||
4138N/A Arrays.binarySearch(otherLowercase, cp) >= 0))
4138N/A {
4138N/A fails++;
4138N/A System.err.printf("Wrong isLowerCase(U+%04x)\n", cp);
4138N/A }
4138N/A if (isUpperCase(cp) !=
4138N/A (type == UPPERCASE_LETTER ||
4138N/A Arrays.binarySearch(otherUppercase, cp) >= 0))
4138N/A {
4138N/A fails++;
4138N/A System.err.printf("Wrong isUpperCase(U+%04x)\n", cp);
4138N/A }
4138N/A if (isAlphabetic(cp) !=
4138N/A (type == UPPERCASE_LETTER || type == LOWERCASE_LETTER ||
4138N/A type == TITLECASE_LETTER || type == MODIFIER_LETTER ||
4138N/A type == OTHER_LETTER || type == OTHER_LETTER ||
4138N/A type == LETTER_NUMBER ||
4138N/A Arrays.binarySearch(otherAlphabetic, cp) >=0))
4138N/A {
4138N/A fails++;
4138N/A System.err.printf("Wrong isAlphabetic(U+%04x)\n", cp);
4138N/A }
4138N/A if (isIdeographic(cp) !=
4138N/A (Arrays.binarySearch(ideographic, cp) >= 0))
4138N/A {
4138N/A fails++;
4138N/A System.err.printf("Wrong isIdeographic(U+%04x)\n", cp);
4138N/A }
4138N/A }
4138N/A if (fails != 0)
4138N/A throw new RuntimeException("CheckProp failed=" + fails);
4138N/A }
4138N/A}