Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/Character/TestNegativeCodepoint.java
41149 views
1
/*
2
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4899380
27
* @summary Character.is<Property>(int codePoint) methods should return false
28
* for negative codepoint values. The to<CaseMap> methods should return
29
* the original codePoint for invalid codePoint ranges.
30
* @author John O'Conner
31
*/
32
33
public class TestNegativeCodepoint {
34
35
public static void main(String[] args) {
36
37
int[] invalidCodePoints = { -1, -'a', 0x110000};
38
for (int x = 0; x < invalidCodePoints.length; ++x) {
39
int cp = invalidCodePoints[x];
40
41
System.out.println("Testing codepoint: " + cp);
42
// test all of the is<Property> methods
43
if (Character.isLowerCase(cp) ||
44
Character.isUpperCase(cp) ||
45
Character.isTitleCase(cp) ||
46
Character.isISOControl(cp) ||
47
Character.isLetterOrDigit(cp) ||
48
Character.isLetter(cp) ||
49
Character.isDigit(cp) ||
50
Character.isDefined(cp) ||
51
Character.isJavaIdentifierStart(cp) ||
52
Character.isJavaIdentifierPart(cp) ||
53
Character.isUnicodeIdentifierStart(cp) ||
54
Character.isUnicodeIdentifierPart(cp) ||
55
Character.isIdentifierIgnorable(cp) ||
56
Character.isSpaceChar(cp) ||
57
Character.isWhitespace(cp) ||
58
Character.isMirrored(cp) ||
59
60
// test the case mappings
61
Character.toLowerCase(cp) != cp ||
62
Character.toUpperCase(cp) != cp ||
63
Character.toTitleCase(cp) != cp ||
64
65
// test directionality of invalid codepoints
66
Character.getDirectionality(cp) != Character.DIRECTIONALITY_UNDEFINED ||
67
68
// test type
69
Character.getType(cp) != Character.UNASSIGNED ||
70
71
// test numeric and digit values
72
Character.getNumericValue(cp) != -1 ||
73
Character.digit(cp, 10) != -1 ) {
74
75
System.out.println("Failed.");
76
throw new RuntimeException();
77
}
78
79
// test block value
80
Character.UnicodeBlock block = null;
81
try {
82
block = Character.UnicodeBlock.of(cp);
83
// if we haven't already thrown an exception because of the illegal
84
// arguments, then we need to throw one because of an error in the of() method
85
System.out.println("Failed.");
86
throw new RuntimeException();
87
}
88
catch(IllegalArgumentException e) {
89
// Since we're testing illegal values, we
90
// expect to land here every time. If not,
91
// our test has failed
92
}
93
94
}
95
System.out.println("Passed.");
96
}
97
}
98
99