author | cl |
Thu, 25 Jul 2013 03:18:14 -0700 | |
changeset 18968 | de18c7eb70e2 |
parent 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
796 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
13366
diff
changeset
|
2 |
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
796 | 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 |
* |
|
5506 | 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. |
|
796 | 22 |
*/ |
23 |
||
24 |
/* @test |
|
25 |
* @bug 4195325 |
|
26 |
* @summary name() should return "X11JIS0201" |
|
27 |
* |
|
28 |
*/ |
|
29 |
||
30 |
import java.nio.charset.*; |
|
31 |
||
32 |
public class TestX11JIS0201 { |
|
33 |
||
34 |
public static void main(String args[]) |
|
35 |
throws Exception |
|
36 |
{ |
|
37 |
test(); |
|
38 |
} |
|
39 |
||
40 |
private static void test() |
|
41 |
throws Exception |
|
42 |
{ |
|
43 |
Class cl = null; |
|
44 |
try { |
|
45 |
cl = Class.forName("sun.awt.motif.X11JIS0201"); |
|
46 |
} catch (Exception e){ |
|
47 |
return; |
|
48 |
} |
|
49 |
Charset cs = (Charset)cl.newInstance(); |
|
50 |
if (! cs.name().equals("X11JIS0201")){ |
|
51 |
throw new Exception("X11JIS0201 does not work correctly"); |
|
52 |
} |
|
13366
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
53 |
CharsetEncoder enc = cs.newEncoder(); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
54 |
char[] cc = new char[0xffff]; |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
55 |
for (char c = 0; c < 0xffff; c++) { |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
56 |
cc[c] = c; |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
57 |
if (enc.canEncode(c) != |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
58 |
((c >= 0xff61 && c <= 0xff9f) || c == 0x203e || c == 0xa5)) { |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
59 |
throw new RuntimeException("x11jis0201 canEncod() failed!"); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
60 |
} |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
61 |
} |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
62 |
String s = new String(cc); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
63 |
byte[] bb_x11 = s.getBytes(cs); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
64 |
byte[] bb = s.getBytes("jis0201"); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
65 |
if (!java.util.Arrays.equals(bb, bb_x11)) { |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
66 |
throw new RuntimeException("x11jis0201 encoding failed"); |
2f5fdf6d8c22
6653797: Reimplement JDK charset repository charsets.jar
sherman
parents:
5506
diff
changeset
|
67 |
} |
796 | 68 |
} |
69 |
} |