author | naoto |
Mon, 05 Mar 2018 08:50:47 -0800 | |
changeset 49129 | fb9f590b9eee |
parent 48742 | 364944ba4e2f |
permissions | -rw-r--r-- |
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
1 |
/* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
4 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
8 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
13 |
* accompanied this code). |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
14 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
18 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
21 |
* questions. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
22 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
23 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
24 |
/* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
25 |
* @test |
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
26 |
* @bug 4533872 4985214 4985217 4993841 5017268 5017280 |
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
27 |
* @summary Unit tests for supplementary character support (JSR-204) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
28 |
* @compile Supplementary.java |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
29 |
* @run main/timeout=600 Supplementary |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
30 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
31 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
32 |
public class Supplementary { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
33 |
private static final char MIN_HIGH = '\uD800'; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
34 |
private static final char MAX_HIGH = '\uDBFF'; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
35 |
private static final char MIN_LOW = MAX_HIGH + 1; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
36 |
private static final char MAX_LOW = '\uDFFF'; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
37 |
private static final int MIN_CODE_POINT = 0x000000; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
38 |
private static final int MIN_SUPPLEMENTARY = 0x010000; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
39 |
private static final int MAX_SUPPLEMENTARY = 0x10ffff; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
40 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
41 |
public static void main(String[] args) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
42 |
// Do not change the order of test method calls since there |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
43 |
// are some interdependencies. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
44 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
45 |
testConstants(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
46 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
47 |
test00(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
48 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
49 |
// Store all Unicode code points, except for surrogate code |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
50 |
// points, in cu[] through the loops below. Then, use the data |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
51 |
// for code point/code unit conversion and other tests later. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
52 |
char[] cu = new char[(MAX_SUPPLEMENTARY+1) * 2]; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
53 |
int length = test01(cu); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
54 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
55 |
String str = new String(cu, 0, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
56 |
cu = null; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
57 |
test02(str); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
58 |
test03(str.toCharArray()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
59 |
test04(str); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
60 |
test05(str); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
61 |
|
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
62 |
// Test for toString(int) |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
63 |
test06(); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
64 |
|
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
65 |
// Test unpaired surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
66 |
testUnpaired(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
67 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
68 |
// Test exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
69 |
testExceptions00(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
70 |
testExceptions01(str); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
71 |
testExceptions02(str.toCharArray()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
72 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
73 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
74 |
static void testConstants() { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
75 |
if (Character.MIN_HIGH_SURROGATE != MIN_HIGH) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
76 |
constantError("MIN_HIGH_SURROGATE", Character.MIN_HIGH_SURROGATE, MIN_HIGH); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
77 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
78 |
if (Character.MAX_HIGH_SURROGATE != MAX_HIGH) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
79 |
constantError("MAX_HIGH_SURROGATE", Character.MAX_HIGH_SURROGATE, MAX_HIGH); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
80 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
81 |
if (Character.MIN_LOW_SURROGATE != MIN_LOW) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
82 |
constantError("MIN_LOW_SURROGATE", Character.MIN_LOW_SURROGATE, MIN_LOW); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
83 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
84 |
if (Character.MAX_LOW_SURROGATE != MAX_LOW) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
85 |
constantError("MAX_LOW_SURROGATE", Character.MAX_LOW_SURROGATE, MAX_LOW); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
86 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
87 |
if (Character.MIN_SURROGATE != MIN_HIGH) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
88 |
constantError("MIN_SURROGATE", Character.MIN_SURROGATE, MIN_HIGH); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
89 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
90 |
if (Character.MAX_SURROGATE != MAX_LOW) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
91 |
constantError("MAX_SURROGATE", Character.MAX_SURROGATE, MAX_LOW); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
92 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
93 |
if (Character.MIN_SUPPLEMENTARY_CODE_POINT != MIN_SUPPLEMENTARY) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
94 |
constantError("MIN_SUPPLEMENTARY_CODE_POINT", |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
95 |
Character.MIN_SUPPLEMENTARY_CODE_POINT, MIN_SUPPLEMENTARY); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
96 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
97 |
if (Character.MIN_CODE_POINT != MIN_CODE_POINT) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
98 |
constantError("MIN_CODE_POINT", Character.MIN_CODE_POINT, MIN_CODE_POINT); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
99 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
100 |
if (Character.MAX_CODE_POINT != MAX_SUPPLEMENTARY) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
101 |
constantError("MAX_CODE_POINT", Character.MAX_CODE_POINT, MAX_SUPPLEMENTARY); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
102 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
103 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
104 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
105 |
static void constantError(String name, int value, int expectedValue) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
106 |
throw new RuntimeException("Character." + name + " has a wrong value: got " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
107 |
+ toHexString(value) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
108 |
+ ", expected " + toHexString(expectedValue)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
109 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
110 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
111 |
/* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
112 |
* Test isValidCodePoint(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
113 |
* isSupplementaryCodePoint(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
114 |
* charCount(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
115 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
116 |
static void test00() { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
117 |
for (int cp = -MAX_SUPPLEMENTARY; cp <= MAX_SUPPLEMENTARY*2; cp++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
118 |
boolean isValid = cp >= 0 && cp <= MAX_SUPPLEMENTARY; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
119 |
if (Character.isValidCodePoint(cp) != isValid) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
120 |
throw new RuntimeException("isValidCodePoint failed with " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
121 |
+ toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
122 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
123 |
boolean isSupplementary = cp >= MIN_SUPPLEMENTARY && cp <= MAX_SUPPLEMENTARY; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
124 |
if (Character.isSupplementaryCodePoint(cp) != isSupplementary) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
125 |
throw new RuntimeException("isSupplementaryCodePoint failed with " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
126 |
+ toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
127 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
128 |
int len = Character.charCount(cp); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
129 |
if (isValid) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
130 |
if ((isSupplementary && len != 2) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
131 |
|| (!isSupplementary && len != 1)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
132 |
throw new RuntimeException("wrong character length "+len+" for " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
133 |
+ toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
134 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
135 |
} else if (len != 1 && len != 2) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
136 |
throw new RuntimeException("wrong character length "+len+" for " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
137 |
+ toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
138 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
139 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
140 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
141 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
142 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
143 |
* Test toChar(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
144 |
* toChar(int, char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
145 |
* isHighSurrogate(char) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
146 |
* isLowSurrogate(char) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
147 |
* isSurrogatePair(int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
148 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
149 |
* While testing those methods, this method generates all Unicode |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
150 |
* code points (except for surrogate code points) and store them |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
151 |
* in cu. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
152 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
153 |
* @return the number of code units generated in cu |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
154 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
155 |
static int test01(char[] cu) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
156 |
int index = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
157 |
// Test toChar(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
158 |
// toChar(int, char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
159 |
// isHighSurrogate(char) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
160 |
// isLowSurrogate(char) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
161 |
// with BMP code points |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
162 |
for (int i = 0; i <= Character.MAX_VALUE; i++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
163 |
char[] u = Character.toChars(i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
164 |
if (u.length != 1 || u[0] != i) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
165 |
throw new RuntimeException("wrong toChars(int) result for BMP: " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
166 |
+ toHexString("u", u)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
167 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
168 |
int n = Character.toChars(i, cu, index); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
169 |
if (n != 1 || cu[index] != i) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
170 |
throw new RuntimeException("wrong toChars(int, char[], int) result for BMP:" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
171 |
+ " len=" + n |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
172 |
+ ", cu["+index+"]="+toHexString(cu[index])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
173 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
174 |
boolean isHigh = i >= MIN_HIGH && i <= MAX_HIGH; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
175 |
if (Character.isHighSurrogate((char) i) != isHigh) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
176 |
throw new RuntimeException("wrong high-surrogate test for " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
177 |
+ toHexString(i)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
178 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
179 |
boolean isLow = i >= MIN_LOW && i <= MAX_LOW; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
180 |
if (Character.isLowSurrogate((char)i) != isLow) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
181 |
throw new RuntimeException("wrong low-surrogate test for " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
182 |
+ toHexString(i)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
183 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
184 |
if (!isHigh && !isLow) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
185 |
index++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
186 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
187 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
188 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
189 |
// Test isSurrogatePair with all surrogate pairs |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
190 |
// Test toChars(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
191 |
// toChars(int, char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
192 |
// with all supplementary characters |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
193 |
int supplementary = MIN_SUPPLEMENTARY; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
194 |
for (int i = Character.MAX_VALUE/2; i <= Character.MAX_VALUE; i++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
195 |
char hi = (char) i; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
196 |
boolean isHigh = Character.isHighSurrogate(hi); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
197 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
198 |
for (int j = Character.MAX_VALUE/2; j <= Character.MAX_VALUE; j++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
199 |
char lo = (char) j; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
200 |
boolean isLow = Character.isLowSurrogate(lo); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
201 |
boolean isSurrogatePair = isHigh && isLow; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
202 |
if (Character.isSurrogatePair(hi, lo) != isSurrogatePair) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
203 |
throw new RuntimeException("wrong surrogate pair test for hi=" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
204 |
+ toHexString(hi) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
205 |
+ ", lo="+toHexString(lo)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
206 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
207 |
if (isSurrogatePair) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
208 |
int cp = Character.toCodePoint(hi, lo); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
209 |
if (cp != supplementary) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
210 |
throw new RuntimeException("wrong code point: got " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
211 |
+ toHexString(cp) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
212 |
+ ", expected=" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
213 |
+ toHexString(supplementary)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
214 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
215 |
char[] u = Character.toChars(cp); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
216 |
if (u.length != 2 || u[0] != hi || u[1] != lo) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
217 |
throw new RuntimeException("wrong toChars(int) result for supplementary: "+ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
218 |
toHexString("u", u)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
219 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
220 |
int n = Character.toChars(cp, cu, index); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
221 |
if (n != 2 || cu[index] != hi || cu[index+1] != lo) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
222 |
throw new RuntimeException("wrong toChars(int, char[], int) result " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
223 |
+ "for supplementary: len=" + n |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
224 |
+ ", cu["+index+"]=" + toHexString(cu[index]) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
225 |
+ ", cu["+(index+1)+"]=" + toHexString(cu[index+1])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
226 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
227 |
index += n; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
228 |
supplementary++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
229 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
230 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
231 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
232 |
if (supplementary != MAX_SUPPLEMENTARY + 1) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
233 |
throw new RuntimeException("wrong supplementary count (supplementary=" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
234 |
+ toHexString(supplementary)+")"); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
235 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
236 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
237 |
int nCodeUnits = Character.MAX_VALUE + 1 - (MAX_LOW - MIN_HIGH + 1) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
238 |
+ ((MAX_SUPPLEMENTARY - MIN_SUPPLEMENTARY + 1) * 2); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
239 |
if (index != nCodeUnits) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
240 |
throw new RuntimeException("wrong number of code units: " + index |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
241 |
+ ", expected " + nCodeUnits); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
242 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
243 |
return index; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
244 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
245 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
246 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
247 |
* Test codePointAt(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
248 |
* codePointBefore(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
249 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
250 |
static void test02(CharSequence cs) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
251 |
int cp = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
252 |
int ch; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
253 |
for (int i = 0; i < cs.length(); i += Character.charCount(ch)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
254 |
ch = Character.codePointAt(cs, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
255 |
if (ch != cp) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
256 |
throw new RuntimeException("wrong codePointAt(CharSequence, "+i+") value: got " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
257 |
+ toHexString(ch) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
258 |
+ ", expected "+toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
259 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
260 |
cp++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
261 |
// Skip surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
262 |
if (cp == MIN_HIGH) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
263 |
cp = MAX_LOW + 1; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
264 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
265 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
266 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
267 |
cp--; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
268 |
for (int i = cs.length(); i > 0; i -= Character.charCount(ch)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
269 |
ch = Character.codePointBefore(cs, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
270 |
if (ch != cp) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
271 |
throw new RuntimeException("codePointBefore(CharSequence, "+i+") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
272 |
+ toHexString(ch) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
273 |
+ ", expected " + toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
274 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
275 |
cp--; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
276 |
// Skip surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
277 |
if (cp == MAX_LOW) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
278 |
cp = MIN_HIGH - 1; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
279 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
280 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
281 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
282 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
283 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
284 |
* Test codePointAt(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
285 |
* codePointAt(char[], int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
286 |
* codePointBefore(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
287 |
* codePointBefore(char[], int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
288 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
289 |
static void test03(char[] a) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
290 |
int cp = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
291 |
int ch; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
292 |
for (int i = 0; i < a.length; i += Character.charCount(ch)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
293 |
ch = Character.codePointAt(a, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
294 |
if (ch != cp) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
295 |
throw new RuntimeException("codePointAt(char[], "+i+") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
296 |
+ toHexString(ch) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
297 |
+ ", expected "+toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
298 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
299 |
int x = Character.codePointAt(a, i, i+1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
300 |
if (x != a[i]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
301 |
throw new RuntimeException(String.format( |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
302 |
"codePointAt(char[], %d, %d) returned 0x%04x, expected 0x%04x\n", |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
303 |
i, i+1, x, (int)a[i])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
304 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
305 |
cp++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
306 |
// Skip surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
307 |
if (cp == MIN_HIGH) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
308 |
cp = MAX_LOW + 1; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
309 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
310 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
311 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
312 |
cp--; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
313 |
for (int i = a.length; i > 0; i -= Character.charCount(ch)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
314 |
ch = Character.codePointBefore(a, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
315 |
if (ch != cp) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
316 |
throw new RuntimeException("codePointBefore(char[], "+i+") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
317 |
+ toHexString(ch) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
318 |
+ ", expected " + toHexString(cp)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
319 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
320 |
int x = Character.codePointBefore(a, i, i-1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
321 |
if (x != a[i-1]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
322 |
throw new RuntimeException(String.format( |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
323 |
"codePointAt(char[], %d, %d) returned 0x%04x, expected 0x%04x\n", |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
324 |
i, i-1, x, (int)a[i-1])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
325 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
326 |
cp--; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
327 |
// Skip surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
328 |
if (cp == MAX_LOW) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
329 |
cp = MIN_HIGH - 1; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
330 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
331 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
332 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
333 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
334 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
335 |
* Test codePointCount(CharSequence, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
336 |
* codePointCount(char[], int, int, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
337 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
338 |
static void test04(String str) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
339 |
int length = str.length(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
340 |
char[] a = str.toCharArray(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
341 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
342 |
for (int i = 0; i <= length; i += 99, length -= 29999) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
343 |
int n = Character.codePointCount(str, i, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
344 |
int m = codePointCount(str.substring(i, length)); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
345 |
checkCodePointCount(str, n, m); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
346 |
n = Character.codePointCount(a, i, length - i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
347 |
checkCodePointCount(a, n, m); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
348 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
349 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
350 |
// test special cases |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
351 |
length = str.length(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
352 |
int n = Character.codePointCount(str, 0, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
353 |
checkCodePointCount(str, n, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
354 |
n = Character.codePointCount(str, length, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
355 |
checkCodePointCount(str, n, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
356 |
n = Character.codePointCount(a, 0, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
357 |
checkCodePointCount(a, n, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
358 |
n = Character.codePointCount(a, length, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
359 |
checkCodePointCount(a, n, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
360 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
361 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
362 |
// This method assumes that Character.codePointAt() and |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
363 |
// Character.charCount() work correctly. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
364 |
private static int codePointCount(CharSequence seq) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
365 |
int n = 0, len; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
366 |
for (int i = 0; i < seq.length(); i += len) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
367 |
int codepoint = Character.codePointAt(seq, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
368 |
n++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
369 |
len = Character.charCount(codepoint); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
370 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
371 |
return n; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
372 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
373 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
374 |
private static void checkCodePointCount(Object data, int n, int expected) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
375 |
String type = getType(data); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
376 |
if (n != expected) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
377 |
throw new RuntimeException("codePointCount(" + type + "...) returned " + n |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
378 |
+ ", expected " + expected); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
379 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
380 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
381 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
382 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
383 |
* Test offsetByCodePoints(CharSequence, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
384 |
* offsetByCodePoints(char[], int, int, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
385 |
* |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
386 |
* This test case assumes that Character.codePointCount()s work |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
387 |
* correctly. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
388 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
389 |
static void test05(String str) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
390 |
int length = str.length(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
391 |
char[] a = str.toCharArray(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
392 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
393 |
for (int i = 0; i <= length; i += 99, length -= 29999) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
394 |
int nCodePoints = Character.codePointCount(a, i, length - i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
395 |
int index; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
396 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
397 |
// offsetByCodePoints(CharSequence, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
398 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
399 |
int expectedHighIndex = length; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
400 |
// For forward CharSequence scan, we need to adjust the |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
401 |
// expected index in case the last char in the text range |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
402 |
// is a high surrogate and forms a valid supplementary |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
403 |
// code point with the next char. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
404 |
if (length < a.length) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
405 |
int cp = Character.codePointAt(a, length - 1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
406 |
if (Character.isSupplementaryCodePoint(cp)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
407 |
expectedHighIndex++; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
408 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
409 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
410 |
index = Character.offsetByCodePoints(str, i, nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
411 |
checkNewIndex(str, nCodePoints, index, expectedHighIndex); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
412 |
int expectedLowIndex = i; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
413 |
if (i > 0) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
414 |
int cp = Character.codePointBefore(a, i + 1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
415 |
if (Character.isSupplementaryCodePoint(cp)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
416 |
expectedLowIndex--; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
417 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
418 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
419 |
index = Character.offsetByCodePoints(str, length, -nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
420 |
checkNewIndex(str, -nCodePoints, index, expectedLowIndex); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
421 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
422 |
// offsetByCodePoints(char[], int, int, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
423 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
424 |
int start = Math.max(0, i-1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
425 |
int limit = Math.min(a.length, length+1); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
426 |
index = Character.offsetByCodePoints(a, start, limit - start, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
427 |
i, nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
428 |
checkNewIndex(a, nCodePoints, index, expectedHighIndex); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
429 |
if (length != expectedHighIndex) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
430 |
index = Character.offsetByCodePoints(a, start, length - start, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
431 |
i, nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
432 |
checkNewIndex(a, nCodePoints, index, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
433 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
434 |
index = Character.offsetByCodePoints(a, start, limit - start, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
435 |
length, -nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
436 |
checkNewIndex(a, -nCodePoints, index, expectedLowIndex); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
437 |
if (i != expectedLowIndex) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
438 |
index = Character.offsetByCodePoints(a, i, limit - i, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
439 |
length, -nCodePoints); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
440 |
checkNewIndex(a, -nCodePoints, index, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
441 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
442 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
443 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
444 |
// test special cases for 0-length text ranges. |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
445 |
length = str.length(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
446 |
int index = Character.offsetByCodePoints(str, 0, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
447 |
checkNewIndex(str, 0, index, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
448 |
index = Character.offsetByCodePoints(str, length, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
449 |
checkNewIndex(str, 0, index, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
450 |
index = Character.offsetByCodePoints(a, 0, 0, 0, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
451 |
checkNewIndex(a, 0, index, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
452 |
index = Character.offsetByCodePoints(a, 0, length, 0, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
453 |
checkNewIndex(a, 0, index, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
454 |
index = Character.offsetByCodePoints(a, 0, length, length, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
455 |
checkNewIndex(a, 0, index, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
456 |
index = Character.offsetByCodePoints(a, length, 0, length, 0); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
457 |
checkNewIndex(a, 0, index, length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
458 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
459 |
|
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
460 |
/** |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
461 |
* Test toString(int) |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
462 |
* |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
463 |
* This test case assumes that Character.toChars()/String(char[]) work |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
464 |
* correctly. |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
465 |
*/ |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
466 |
static void test06() { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
467 |
for (int cp = Character.MIN_CODE_POINT; cp <= Character.MAX_CODE_POINT; cp++) { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
468 |
String result = Character.toString(cp); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
469 |
String expected = new String(Character.toChars(cp)); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
470 |
if (!result.equals(expected)) { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
471 |
throw new RuntimeException("Wrong string is created. code point: " + |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
472 |
cp + ", result: " + result + ", expected: " + expected); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
473 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
474 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
475 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
476 |
|
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
477 |
private static void checkNewIndex(Object data, int offset, int result, int expected) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
478 |
String type = getType(data); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
479 |
String offsetType = (offset > 0) ? "positive" : (offset < 0) ? "negative" : "0"; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
480 |
if (result != expected) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
481 |
throw new RuntimeException("offsetByCodePoints(" + type + ", ...) [" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
482 |
+ offsetType + " offset]" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
483 |
+ " returned " + result |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
484 |
+ ", expected " + expected); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
485 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
486 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
487 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
488 |
// Test codePointAt(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
489 |
// codePointBefore(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
490 |
// codePointAt(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
491 |
// codePointBefore(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
492 |
// toChar(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
493 |
// toChar(int, char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
494 |
// with unpaired surrogates |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
495 |
static void testUnpaired() { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
496 |
testCodePoint("\uD800", new int[] { 0xD800 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
497 |
testCodePoint("\uDC00", new int[] { 0xDC00 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
498 |
testCodePoint("a\uD800", new int[] { 'a', 0xD800 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
499 |
testCodePoint("a\uDC00", new int[] { 'a', 0xDC00 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
500 |
testCodePoint("\uD800a", new int[] { 0xD800, 'a' }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
501 |
testCodePoint("\uDBFFa", new int[] { 0xDBFF, 'a' }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
502 |
testCodePoint("a\uD800\uD801", new int[] { 'a', 0xD800, 0xD801 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
503 |
testCodePoint("a\uD800x\uDC00", new int[] { 'a', 0xD800, 'x', 0xDC00 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
504 |
testCodePoint("\uDC00\uD800", new int[] { 0xDC00, 0xD800 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
505 |
testCodePoint("\uD800\uDC00\uDC00", new int[] { 0x10000, 0xDC00 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
506 |
testCodePoint("\uD800\uD800\uDC00", new int[] { 0xD800, 0x10000 }); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
507 |
testCodePoint("\uD800\uD800\uD800\uD800\uDC00\uDC00\uDC00\uDC00", |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
508 |
new int[] { 0xD800, 0xD800, 0xD800, 0x10000, 0xDC00, 0xDC00, 0xDC00}); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
509 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
510 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
511 |
static void testCodePoint(String str, int[] codepoints) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
512 |
int c; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
513 |
// Test Character.codePointAt/Before(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
514 |
int j = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
515 |
for (int i = 0; i < str.length(); i += Character.charCount(c)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
516 |
c = Character.codePointAt(str, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
517 |
if (c != codepoints[j++]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
518 |
throw new RuntimeException("codePointAt(CharSequence, " + i + ") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
519 |
+ toHexString(c) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
520 |
+ ", expected " + toHexString(codepoints[j-1])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
521 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
522 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
523 |
if (j != codepoints.length) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
524 |
throw new RuntimeException("j != codepoints.length after codePointAt(CharSequence, int)" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
525 |
+ " (j=" + j + ")" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
526 |
+ ", expected: " + codepoints.length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
527 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
528 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
529 |
j = codepoints.length; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
530 |
for (int i = str.length(); i > 0 ; i -= Character.charCount(c)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
531 |
c = Character.codePointBefore(str, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
532 |
if (c != codepoints[--j]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
533 |
throw new RuntimeException("codePointBefore(CharSequence, " + i + ") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
534 |
+ toHexString(c) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
535 |
+ ", expected " + toHexString(codepoints[j])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
536 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
537 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
538 |
if (j != 0) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
539 |
throw new RuntimeException("j != 0 after codePointBefore(CharSequence, int)" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
540 |
+ " (j=" + j + ")"); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
541 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
542 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
543 |
// Test Character.codePointAt/Before(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
544 |
char[] a = str.toCharArray(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
545 |
j = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
546 |
for (int i = 0; i < a.length; i += Character.charCount(c)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
547 |
c = Character.codePointAt(a, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
548 |
if (c != codepoints[j++]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
549 |
throw new RuntimeException("codePointAt(char[], " + i + ") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
550 |
+ toHexString(c) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
551 |
+ ", expected " + toHexString(codepoints[j-1])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
552 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
553 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
554 |
if (j != codepoints.length) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
555 |
throw new RuntimeException("j != codepoints.length after codePointAt(char[], int)" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
556 |
+ " (j=" + j + ")" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
557 |
+ ", expected: " + codepoints.length); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
558 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
559 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
560 |
j = codepoints.length; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
561 |
for (int i = a.length; i > 0 ; i -= Character.charCount(c)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
562 |
c = Character.codePointBefore(a, i); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
563 |
if (c != codepoints[--j]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
564 |
throw new RuntimeException("codePointBefore(char[], " + i + ") returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
565 |
+ toHexString(c) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
566 |
+ ", expected " + toHexString(codepoints[j])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
567 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
568 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
569 |
if (j != 0) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
570 |
throw new RuntimeException("j != 0 after codePointBefore(char[], int)" |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
571 |
+ " (j=" + j + ")"); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
572 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
573 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
574 |
// Test toChar(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
575 |
j = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
576 |
for (int i = 0; i < codepoints.length; i++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
577 |
a = Character.toChars(codepoints[i]); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
578 |
for (int k = 0; k < a.length; k++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
579 |
if (str.charAt(j++) != a[k]) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
580 |
throw new RuntimeException("toChars(int) returned " + toHexString("result", a) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
581 |
+ " from codepoint=" + toHexString(codepoints[i])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
582 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
583 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
584 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
585 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
586 |
// Test toChars(int, char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
587 |
a = new char[codepoints.length * 2]; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
588 |
j = 0; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
589 |
for (int i = 0; i < codepoints.length; i++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
590 |
int n = Character.toChars(codepoints[i], a, j); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
591 |
j += n; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
592 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
593 |
String s = new String(a, 0, j); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
594 |
if (!str.equals(s)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
595 |
throw new RuntimeException("toChars(int, char[], int) returned " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
596 |
+ toHexString("dst", s.toCharArray()) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
597 |
+ ", expected " + toHexString("data", str.toCharArray())); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
598 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
599 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
600 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
601 |
// Test toChar(int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
602 |
// toChar(int, char[], int) |
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
603 |
// toString(int) |
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
604 |
// for exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
605 |
static void testExceptions00() { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
606 |
callToChars1(-1, IllegalArgumentException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
607 |
callToChars1(MAX_SUPPLEMENTARY + 1, IllegalArgumentException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
608 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
609 |
callToChars3(MAX_SUPPLEMENTARY, null, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
610 |
callToChars3(-MIN_SUPPLEMENTARY, new char[2], 0, IllegalArgumentException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
611 |
callToChars3(MAX_SUPPLEMENTARY + 1, new char[2], 0, IllegalArgumentException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
612 |
callToChars3('A', new char[0], 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
613 |
callToChars3('A', new char[1], -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
614 |
callToChars3('A', new char[1], 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
615 |
callToChars3(MIN_SUPPLEMENTARY, new char[0], 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
616 |
callToChars3(MIN_SUPPLEMENTARY, new char[1], 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
617 |
callToChars3(MIN_SUPPLEMENTARY, new char[2], -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
618 |
callToChars3(MIN_SUPPLEMENTARY, new char[2], 1, IndexOutOfBoundsException.class); |
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
619 |
|
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
620 |
callToString(Character.MIN_CODE_POINT - 1, IllegalArgumentException.class); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
621 |
callToString(Character.MAX_CODE_POINT + 1, IllegalArgumentException.class); |
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
622 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
623 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
624 |
static final boolean At = true, Before = false; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
625 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
626 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
627 |
* Test codePointAt(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
628 |
* codePointBefore(CharSequence, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
629 |
* codePointCount(CharSequence, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
630 |
* offsetByCodePoints(CharSequence, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
631 |
* for exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
632 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
633 |
static void testExceptions01(CharSequence cs) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
634 |
CharSequence nullSeq = null; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
635 |
// codePointAt |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
636 |
callCodePoint(At, nullSeq, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
637 |
callCodePoint(At, cs, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
638 |
callCodePoint(At, cs, cs.length(), IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
639 |
callCodePoint(At, cs, cs.length()*3, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
640 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
641 |
// codePointBefore |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
642 |
callCodePoint(Before, nullSeq, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
643 |
callCodePoint(Before, cs, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
644 |
callCodePoint(Before, cs, 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
645 |
callCodePoint(Before, cs, cs.length()+1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
646 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
647 |
// codePointCount |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
648 |
callCodePointCount(nullSeq, 0, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
649 |
callCodePointCount(cs, -1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
650 |
callCodePointCount(cs, 0, cs.length()+1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
651 |
callCodePointCount(cs, 3, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
652 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
653 |
// offsetByCodePoints |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
654 |
callOffsetByCodePoints(nullSeq, 0, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
655 |
callOffsetByCodePoints(cs, -1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
656 |
callOffsetByCodePoints(cs, cs.length()+1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
657 |
callOffsetByCodePoints(cs, 0, cs.length()*2, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
658 |
callOffsetByCodePoints(cs, cs.length(), 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
659 |
callOffsetByCodePoints(cs, 0, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
660 |
callOffsetByCodePoints(cs, cs.length(), -cs.length()*2, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
661 |
IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
662 |
callOffsetByCodePoints(cs, cs.length(), Integer.MIN_VALUE, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
663 |
IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
664 |
callOffsetByCodePoints(cs, 0, Integer.MAX_VALUE, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
665 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
666 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
667 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
668 |
* Test codePointAt(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
669 |
* codePointAt(char[], int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
670 |
* codePointBefore(char[], int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
671 |
* codePointBefore(char[], int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
672 |
* codePointCount(char[], int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
673 |
* offsetByCodePoints(char[], int, int, int, int) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
674 |
* for exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
675 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
676 |
static void testExceptions02(char[] a) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
677 |
char[] nullArray = null; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
678 |
callCodePoint(At, nullArray, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
679 |
callCodePoint(At, a, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
680 |
callCodePoint(At, a, a.length, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
681 |
callCodePoint(At, a, a.length*3, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
682 |
callCodePoint(Before, nullArray, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
683 |
callCodePoint(Before, a, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
684 |
callCodePoint(Before, a, 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
685 |
callCodePoint(Before, a, a.length+1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
686 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
687 |
// tests for the methods with limit |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
688 |
callCodePoint(At, nullArray, 0, 1, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
689 |
callCodePoint(At, a, 0, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
690 |
callCodePoint(At, a, 0, 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
691 |
callCodePoint(At, a, 0, a.length+1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
692 |
callCodePoint(At, a, 2, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
693 |
callCodePoint(At, a, -1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
694 |
callCodePoint(At, a, a.length, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
695 |
callCodePoint(At, a, a.length*3, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
696 |
callCodePoint(Before, nullArray, 1, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
697 |
callCodePoint(Before, a, 2, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
698 |
callCodePoint(Before, a, 2, 2, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
699 |
callCodePoint(Before, a, 2, 3, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
700 |
callCodePoint(Before, a, 2, a.length, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
701 |
callCodePoint(Before, a, -1, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
702 |
callCodePoint(Before, a, 0, 0, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
703 |
callCodePoint(Before, a, a.length+1, a.length-1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
704 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
705 |
// codePointCount |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
706 |
callCodePointCount(nullArray, 0, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
707 |
callCodePointCount(a, -1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
708 |
callCodePointCount(a, 0, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
709 |
callCodePointCount(a, 0, a.length+1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
710 |
callCodePointCount(a, 1, a.length, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
711 |
callCodePointCount(a, a.length, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
712 |
callCodePointCount(a, a.length+1, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
713 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
714 |
// offsetByCodePoints |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
715 |
callOffsetByCodePoints(nullArray, 0, 0, 0, 0, NullPointerException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
716 |
callOffsetByCodePoints(a, -1, a.length, 1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
717 |
callOffsetByCodePoints(a, 0, a.length+1, 1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
718 |
callOffsetByCodePoints(a, 10, a.length, 1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
719 |
callOffsetByCodePoints(a, 10, a.length-10, 1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
720 |
callOffsetByCodePoints(a, 10, 10, 21, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
721 |
callOffsetByCodePoints(a, 20, -10, 15, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
722 |
callOffsetByCodePoints(a, 10, 10, 15, 20, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
723 |
callOffsetByCodePoints(a, 10, 10, 15, -20, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
724 |
callOffsetByCodePoints(a, 0, a.length, -1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
725 |
callOffsetByCodePoints(a, 0, a.length, a.length+1, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
726 |
callOffsetByCodePoints(a, 0, a.length, 0, a.length*2, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
727 |
callOffsetByCodePoints(a, 0, a.length, a.length, 1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
728 |
callOffsetByCodePoints(a, 0, a.length, 0, -1, IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
729 |
callOffsetByCodePoints(a, 0, a.length, a.length, -a.length*2, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
730 |
IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
731 |
callOffsetByCodePoints(a, 0, a.length, a.length, Integer.MIN_VALUE, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
732 |
IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
733 |
callOffsetByCodePoints(a, 0, a.length, 0, Integer.MAX_VALUE, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
734 |
IndexOutOfBoundsException.class); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
735 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
736 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
737 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
738 |
* Test the 1-arg toChars(int) for exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
739 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
740 |
private static void callToChars1(int codePoint, Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
741 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
742 |
char[] a = Character.toChars(codePoint); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
743 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
744 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
745 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
746 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
747 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
748 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
749 |
throw new RuntimeException("toChars(int) didn't throw " + expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
750 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
751 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
752 |
/** |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
753 |
* Test the 3-arg toChars(int, char[], int) for exceptions |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
754 |
*/ |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
755 |
private static void callToChars3(int codePoint, char[] dst, int index, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
756 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
757 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
758 |
int n = Character.toChars(codePoint, dst, index); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
759 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
760 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
761 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
762 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
763 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
764 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
765 |
throw new RuntimeException("toChars(int,char[],int) didn't throw " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
766 |
+ expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
767 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
768 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
769 |
private static void callCodePoint(boolean isAt, CharSequence cs, int index, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
770 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
771 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
772 |
int c = isAt ? Character.codePointAt(cs, index) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
773 |
: Character.codePointBefore(cs, index); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
774 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
775 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
776 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
777 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
778 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
779 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
780 |
throw new RuntimeException("codePoint" + (isAt ? "At" : "Before") |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
781 |
+ " didn't throw " + expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
782 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
783 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
784 |
private static void callCodePoint(boolean isAt, char[] a, int index, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
785 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
786 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
787 |
int c = isAt ? Character.codePointAt(a, index) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
788 |
: Character.codePointBefore(a, index); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
789 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
790 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
791 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
792 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
793 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
794 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
795 |
throw new RuntimeException("codePoint" + (isAt ? "At" : "Before") |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
796 |
+ " didn't throw " + expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
797 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
798 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
799 |
private static void callCodePoint(boolean isAt, char[] a, int index, int limit, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
800 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
801 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
802 |
int c = isAt ? Character.codePointAt(a, index, limit) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
803 |
: Character.codePointBefore(a, index, limit); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
804 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
805 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
806 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
807 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
808 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
809 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
810 |
throw new RuntimeException("codePoint" + (isAt ? "At" : "Before") |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
811 |
+ " didn't throw " + expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
812 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
813 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
814 |
private static void callCodePointCount(Object data, int beginIndex, int endIndex, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
815 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
816 |
String type = getType(data); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
817 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
818 |
int n = (data instanceof CharSequence) ? |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
819 |
Character.codePointCount((CharSequence) data, beginIndex, endIndex) |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
820 |
: Character.codePointCount((char[]) data, beginIndex, endIndex); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
821 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
822 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
823 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
824 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
825 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
826 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
827 |
throw new RuntimeException("codePointCount(" + type + "...) didn't throw " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
828 |
+ expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
829 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
830 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
831 |
private static void callOffsetByCodePoints(CharSequence seq, int index, int offset, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
832 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
833 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
834 |
int n = Character.offsetByCodePoints(seq, index, offset); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
835 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
836 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
837 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
838 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
839 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
840 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
841 |
throw new RuntimeException("offsetCodePointCounts(CharSequnce...) didn't throw " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
842 |
+ expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
843 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
844 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
845 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
846 |
private static void callOffsetByCodePoints(char[] a, int start, int count, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
847 |
int index, int offset, |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
848 |
Class expectedException) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
849 |
try { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
850 |
int n = Character.offsetByCodePoints(a, start, count, index, offset); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
851 |
} catch (Exception e) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
852 |
if (expectedException.isInstance(e)) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
853 |
return; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
854 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
855 |
throw new RuntimeException("Unspecified exception", e); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
856 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
857 |
throw new RuntimeException("offsetCodePointCounts(char[]...) didn't throw " |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
858 |
+ expectedException.getName()); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
859 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
860 |
|
49129
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
861 |
private static void callToString(int codePoint, Class expectedException) { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
862 |
try { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
863 |
String s = Character.toString(codePoint); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
864 |
} catch (Exception e) { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
865 |
if (expectedException.isInstance(e)) { |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
866 |
return; |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
867 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
868 |
throw new RuntimeException("Unspecified exception", e); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
869 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
870 |
throw new RuntimeException("toString(int) didn't throw " |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
871 |
+ expectedException.getName()); |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
872 |
} |
fb9f590b9eee
4993841: (str) java.lang.Character should have a toString(int) method
naoto
parents:
48742
diff
changeset
|
873 |
|
48742
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
874 |
private static String getType(Object data) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
875 |
return (data instanceof CharSequence) ? "CharSequence" : "char[]"; |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
876 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
877 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
878 |
private static String toHexString(int c) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
879 |
return "0x" + Integer.toHexString(c); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
880 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
881 |
|
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
882 |
private static String toHexString(String name, char[] a) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
883 |
StringBuffer sb = new StringBuffer(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
884 |
for (int i = 0; i < a.length; i++) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
885 |
if (i > 0) { |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
886 |
sb.append(", "); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
887 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
888 |
sb.append(name).append('[').append(i).append("]="); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
889 |
sb.append(toHexString(a[i])); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
890 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
891 |
return sb.toString(); |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
892 |
} |
364944ba4e2f
8195981: Move some tests to OpenJDK for jdk_lang test group
amlu
parents:
diff
changeset
|
893 |
} |