1 /* |
|
2 * Copyright (c) 2008, 2012, 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 /* @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 } |
|
53 CharsetEncoder enc = cs.newEncoder(); |
|
54 char[] cc = new char[0xffff]; |
|
55 for (char c = 0; c < 0xffff; c++) { |
|
56 cc[c] = c; |
|
57 if (enc.canEncode(c) != |
|
58 ((c >= 0xff61 && c <= 0xff9f) || c == 0x203e || c == 0xa5)) { |
|
59 throw new RuntimeException("x11jis0201 canEncod() failed!"); |
|
60 } |
|
61 } |
|
62 String s = new String(cc); |
|
63 byte[] bb_x11 = s.getBytes(cs); |
|
64 byte[] bb = s.getBytes("jis0201"); |
|
65 if (!java.util.Arrays.equals(bb, bb_x11)) { |
|
66 throw new RuntimeException("x11jis0201 encoding failed"); |
|
67 } |
|
68 } |
|
69 } |
|