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.
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 8202771
27 * @summary Check j.l.Character.isDigit/isLetter/isLetterOrDigit/isSpaceChar
28 * /isWhitespace/isTitleCase/isISOControl/isIdentifierIgnorable
29 * /isJavaIdentifierStart/isJavaIdentifierPart/isUnicodeIdentifierStart
30 * /isUnicodeIdentifierPart
31 * @run main CharPropTest
32 */
33
34 import java.nio.file.Files;
35 import java.nio.file.Path;
36 import java.nio.file.Paths;
37 import java.util.stream.Stream;
38
39 public class CharPropTest {
40 private static int diffs = 0;
41 private static int rangeStart = 0x0000;
42 private static boolean isRange = false;
43
44 public static void main(String[] args) throws Exception {
45 Path path = Paths.get(System.getProperty("test.src", "."),
46 "UnicodeData.txt");
47 try (Stream<String> lines = Files.lines(path)) {
48 lines.map(String::trim)
49 .filter(line -> line.length() != 0 && line.charAt(0) != '#')
50 .forEach(line -> handleOneLine(line));
51
52 if (diffs != 0) {
53 throw new RuntimeException("Total differences: " + diffs);
54 }
55 }
56 }
57
58 private static void handleOneLine(String line) {
59 String[] fields = line.split(";");
60 int currentCp = Integer.parseInt(fields[0], 16);
61 String name = fields[1];
62 String category = fields[2];
63
64 // Except single code point, also handle ranges like the following:
65 // 3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
66 // 4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;
67 if (isRange) {
|
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.
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 8202771 8221431
27 * @summary Check j.l.Character.isDigit/isLetter/isLetterOrDigit/isSpaceChar
28 * /isWhitespace/isTitleCase/isISOControl/isIdentifierIgnorable
29 * /isJavaIdentifierStart/isJavaIdentifierPart/isUnicodeIdentifierStart
30 * /isUnicodeIdentifierPart
31 * @library /lib/testlibrary/java/lang
32 * @run main CharPropTest
33 */
34
35 import java.nio.file.Files;
36 import java.util.stream.Stream;
37
38 public class CharPropTest {
39 private static int diffs = 0;
40 private static int rangeStart = 0x0000;
41 private static boolean isRange = false;
42
43 public static void main(String[] args) throws Exception {
44 try (Stream<String> lines = Files.lines(UCDFiles.UNICODE_DATA)) {
45 lines.map(String::trim)
46 .filter(line -> line.length() != 0 && line.charAt(0) != '#')
47 .forEach(line -> handleOneLine(line));
48
49 if (diffs != 0) {
50 throw new RuntimeException("Total differences: " + diffs);
51 }
52 }
53 }
54
55 private static void handleOneLine(String line) {
56 String[] fields = line.split(";");
57 int currentCp = Integer.parseInt(fields[0], 16);
58 String name = fields[1];
59 String category = fields[2];
60
61 // Except single code point, also handle ranges like the following:
62 // 3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
63 // 4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;
64 if (isRange) {
|