Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/launcher/I18NArgTest.java
41144 views
1
/*
2
* Copyright (c) 2013, 2016, 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 8016110 8170832
27
* @summary verify Japanese character in an argument are treated correctly
28
* @compile -XDignore.symbol.file I18NArgTest.java
29
* @run main I18NArgTest
30
*/
31
import java.io.IOException;
32
import java.util.Map;
33
import java.util.HashMap;
34
35
public class I18NArgTest extends TestHelper {
36
public static void main(String... args) throws IOException {
37
if (!isWindows) {
38
return;
39
}
40
if (!"MS932".equals(System.getProperty("sun.jnu.encoding"))) {
41
System.err.println("MS932 encoding not set, test skipped");
42
return;
43
}
44
if (args.length == 0) {
45
execTest(0x30bd); // MS932 Katakana SO, 0x835C
46
} else {
47
testCharacters(args);
48
}
49
}
50
static void execTest(int unicodeValue) {
51
String hexValue = Integer.toHexString(unicodeValue);
52
String unicodeStr = Character.toString((char)unicodeValue);
53
execTest("\"" + unicodeStr + "\"", hexValue);
54
execTest("\\" + unicodeStr + "\\", hexValue);
55
execTest(" " + unicodeStr + " ", hexValue);
56
execTest("'" + unicodeStr + "'", hexValue);
57
execTest("\t" + unicodeStr + "\t", hexValue);
58
execTest("*" + unicodeStr + "*", hexValue);
59
execTest("?" + unicodeStr + "?", hexValue);
60
61
execTest("\"" + unicodeStr + unicodeStr + "\"", hexValue + hexValue);
62
execTest("\\" + unicodeStr + unicodeStr + "\\", hexValue + hexValue);
63
execTest(" " + unicodeStr + unicodeStr + " ", hexValue + hexValue);
64
execTest("'" + unicodeStr + unicodeStr + "'", hexValue + hexValue);
65
execTest("\t" + unicodeStr + unicodeStr + "\t", hexValue + hexValue);
66
execTest("*" + unicodeStr + unicodeStr + "*", hexValue + hexValue);
67
execTest("?" + unicodeStr + unicodeStr + "?", hexValue + hexValue);
68
69
execTest("\"" + unicodeStr + "a" + unicodeStr + "\"", hexValue + "61" + hexValue);
70
execTest("\\" + unicodeStr + "a" + unicodeStr + "\\", hexValue + "61" + hexValue);
71
execTest(" " + unicodeStr + "a" + unicodeStr + " ", hexValue + "61"+ hexValue);
72
execTest("'" + unicodeStr + "a" + unicodeStr + "'", hexValue + "61"+ hexValue);
73
execTest("\t" + unicodeStr + "a" + unicodeStr + "\t", hexValue + "61"+ hexValue);
74
execTest("*" + unicodeStr + "a" + unicodeStr + "*", hexValue + "61"+ hexValue);
75
execTest("?" + unicodeStr + "a" + unicodeStr + "?", hexValue + "61"+ hexValue);
76
77
execTest("\"" + unicodeStr + "\u00b1" + unicodeStr + "\"", hexValue + "b1" + hexValue);
78
execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "b1" + hexValue);
79
execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "b1"+ hexValue);
80
execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "b1"+ hexValue);
81
execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "b1"+ hexValue);
82
execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue);
83
execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue);
84
}
85
86
static void execTest(String unicodeStr, String hexValue) {
87
TestResult tr = doExec(javaCmd,
88
"-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(),
89
"-Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath(),
90
"-cp", TEST_CLASSES_DIR.getAbsolutePath(),
91
"I18NArgTest", unicodeStr, hexValue);
92
System.out.println(tr.testOutput);
93
if (!tr.isOK()) {
94
System.err.println(tr);
95
throw new RuntimeException("test fails");
96
}
97
98
// Test via JDK_JAVA_OPTIONS
99
Map<String, String> env = new HashMap<>();
100
String cmd = "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath() +
101
" -Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath() +
102
" -cp " + TEST_CLASSES_DIR.getAbsolutePath() +
103
" I18NArgTest " + unicodeStr + " " + hexValue;
104
env.put("JDK_JAVA_OPTIONS", cmd);
105
tr = doExec(env, javaCmd);
106
System.out.println(tr.testOutput);
107
if (!tr.isOK()) {
108
System.err.println(tr);
109
throw new RuntimeException("test fails");
110
}
111
}
112
113
static void testCharacters(String... args) {
114
String input = args[0];
115
String expected = args[1];
116
String hexValue = "";
117
for (int i = 0; i < input.length(); i++) {
118
hexValue = hexValue.concat(Integer.toHexString((int)input.charAt(i)));
119
}
120
System.out.println("input:" + input);
121
System.out.println("expected:" + expected);
122
System.out.println("obtained:" + hexValue);
123
if (!hexValue.contains(expected)) {
124
String message = "Error: output does not contain expected value" +
125
"expected:" + expected + " obtained:" + hexValue;
126
throw new RuntimeException(message);
127
}
128
}
129
}
130
131