author | prr |
Tue, 01 Jul 2014 10:20:56 -0700 | |
changeset 25211 | 2476da7d73bf |
parent 20488 | a2718559a91c |
child 43325 | 033e4cced1dc |
permissions | -rw-r--r-- |
20488
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
1 |
/* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
4 |
* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
8 |
* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
13 |
* accompanied this code). |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
14 |
* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
18 |
* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
21 |
* questions. |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
22 |
*/ |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
23 |
|
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
24 |
/* |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
25 |
* @test |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
26 |
* @bug 8016110 |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
27 |
* @summary verify Japanese character in an argument are treated correctly |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
28 |
* @compile -XDignore.symbol.file I18NArgTest.java |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
29 |
* @run main I18NArgTest |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
30 |
*/ |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
31 |
import java.io.IOException; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
32 |
|
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
33 |
public class I18NArgTest extends TestHelper { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
34 |
public static void main(String... args) throws IOException { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
35 |
if (!isWindows) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
36 |
return; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
37 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
38 |
if (!"MS932".equals(System.getProperty("sun.jnu.encoding"))) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
39 |
System.err.println("MS932 encoding not set, test skipped"); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
40 |
return; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
41 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
42 |
if (args.length == 0) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
43 |
execTest(0x30bd); // MS932 Katakana SO, 0x835C |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
44 |
} else { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
45 |
testCharacters(args); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
46 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
47 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
48 |
static void execTest(int unicodeValue) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
49 |
String hexValue = Integer.toHexString(unicodeValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
50 |
String unicodeStr = Character.toString((char)unicodeValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
51 |
execTest("\"" + unicodeStr + "\"", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
52 |
execTest("\\" + unicodeStr + "\\", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
53 |
execTest(" " + unicodeStr + " ", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
54 |
execTest("'" + unicodeStr + "'", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
55 |
execTest("\t" + unicodeStr + "\t", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
56 |
execTest("*" + unicodeStr + "*", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
57 |
execTest("?" + unicodeStr + "?", hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
58 |
|
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
59 |
execTest("\"" + unicodeStr + unicodeStr + "\"", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
60 |
execTest("\\" + unicodeStr + unicodeStr + "\\", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
61 |
execTest(" " + unicodeStr + unicodeStr + " ", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
62 |
execTest("'" + unicodeStr + unicodeStr + "'", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
63 |
execTest("\t" + unicodeStr + unicodeStr + "\t", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
64 |
execTest("*" + unicodeStr + unicodeStr + "*", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
65 |
execTest("?" + unicodeStr + unicodeStr + "?", hexValue + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
66 |
|
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
67 |
execTest("\"" + unicodeStr + "a" + unicodeStr + "\"", hexValue + "61" + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
68 |
execTest("\\" + unicodeStr + "a" + unicodeStr + "\\", hexValue + "61" + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
69 |
execTest(" " + unicodeStr + "a" + unicodeStr + " ", hexValue + "61"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
70 |
execTest("'" + unicodeStr + "a" + unicodeStr + "'", hexValue + "61"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
71 |
execTest("\t" + unicodeStr + "a" + unicodeStr + "\t", hexValue + "61"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
72 |
execTest("*" + unicodeStr + "a" + unicodeStr + "*", hexValue + "61"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
73 |
execTest("?" + unicodeStr + "a" + unicodeStr + "?", hexValue + "61"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
74 |
|
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
75 |
execTest("\"" + unicodeStr + "\u00b1" + unicodeStr + "\"", hexValue + "b1" + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
76 |
execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "b1" + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
77 |
execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "b1"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
78 |
execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "b1"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
79 |
execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "b1"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
80 |
execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
81 |
execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
82 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
83 |
static void execTest(String unicodeStr, String hexValue) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
84 |
TestResult tr = doExec(javaCmd, |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
85 |
"-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(), |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
86 |
"-Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath(), |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
87 |
"-cp", TEST_CLASSES_DIR.getAbsolutePath(), |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
88 |
"I18NArgTest", unicodeStr, hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
89 |
System.out.println(tr.testOutput); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
90 |
if (!tr.isOK()) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
91 |
System.err.println(tr); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
92 |
throw new RuntimeException("test fails"); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
93 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
94 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
95 |
static void testCharacters(String... args) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
96 |
String input = args[0]; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
97 |
String expected = args[1]; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
98 |
String hexValue = ""; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
99 |
for (int i = 0; i < input.length(); i++) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
100 |
hexValue = hexValue.concat(Integer.toHexString((int)input.charAt(i))); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
101 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
102 |
System.out.println("input:" + input); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
103 |
System.out.println("expected:" + expected); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
104 |
System.out.println("obtained:" + hexValue); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
105 |
if (!hexValue.contains(expected)) { |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
106 |
String message = "Error: output does not contain expected value" + |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
107 |
"expected:" + expected + " obtained:" + hexValue; |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
108 |
throw new RuntimeException(message); |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
109 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
110 |
} |
a2718559a91c
8016110: Japanese char (MS932) 0x5C cannot be used as an argument when quoted
naoto
parents:
diff
changeset
|
111 |
} |