author | jiangli |
Wed, 27 Sep 2017 17:55:20 -0400 | |
changeset 47548 | 664b9d44db74 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
796 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2008, 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 |
|
44115
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
5506
diff
changeset
|
25 |
* @bug 6529796 6710199 |
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
5506
diff
changeset
|
26 |
* @summary Test SJIS/MS932_0213 charsets |
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
5506
diff
changeset
|
27 |
* @modules jdk.charsets |
796 | 28 |
*/ |
29 |
||
30 |
import java.util.Arrays; |
|
31 |
||
32 |
public class TestSJIS0213 { |
|
33 |
private static String sjisStr = "\u2014\u301C\u2016\u2212\u00A2\u00A3\u00AC"; |
|
34 |
private static String winStr = "\u2015\uFF5E\u2225\uFF0D\uFFE0\uFFE1\uFFE2\u2252\u2261\u222B\u2211\u221A\u22A5\u2220\u2235\u2229\u222A"; |
|
35 |
||
36 |
private static String compStr = "\u304B\u309A\u304D\u309A\u304F\u309A\u3051\u309A\u3053\u309A\u30AB\u309A\u30AD\u309A\u30AF\u309A\u30B1\u309A\u30B3\u309A\u30BB\u309A\u30C4\u309A\u30C8\u309A\u31F7\u309A\u00E6\u0300\u0254\u0300\u0254\u0301\u028C\u0300\u028C\u0301\u0259\u0300\u0259\u0301\u025A\u0300\u025A\u0301\u02E9\u02E5\u02E5\u02E9"; |
|
37 |
private static byte[] compBytes = new byte[] { |
|
38 |
(byte)0x82, (byte)0xf5, |
|
39 |
(byte)0x82, (byte)0xf6, |
|
40 |
(byte)0x82, (byte)0xf7, |
|
41 |
(byte)0x82, (byte)0xf8, |
|
42 |
(byte)0x82, (byte)0xf9, |
|
43 |
(byte)0x83, (byte)0x97, |
|
44 |
(byte)0x83, (byte)0x98, |
|
45 |
(byte)0x83, (byte)0x99, |
|
46 |
(byte)0x83, (byte)0x9a, |
|
47 |
(byte)0x83, (byte)0x9b, |
|
48 |
(byte)0x83, (byte)0x9c, |
|
49 |
(byte)0x83, (byte)0x9d, |
|
50 |
(byte)0x83, (byte)0x9e, |
|
51 |
(byte)0x83, (byte)0xf6, |
|
52 |
(byte)0x86, (byte)0x63, |
|
53 |
(byte)0x86, (byte)0x67, |
|
54 |
(byte)0x86, (byte)0x68, |
|
55 |
(byte)0x86, (byte)0x69, |
|
56 |
(byte)0x86, (byte)0x6a, |
|
57 |
(byte)0x86, (byte)0x6b, |
|
58 |
(byte)0x86, (byte)0x6c, |
|
59 |
(byte)0x86, (byte)0x6d, |
|
60 |
(byte)0x86, (byte)0x6e, |
|
61 |
(byte)0x86, (byte)0x85, |
|
62 |
(byte)0x86, (byte)0x86 }; |
|
63 |
||
64 |
private static String mixedStr = "\u002B\u0041\u007a\uff61\uff9f\u3000\u30a1\u4e00\u304B\u309A\u304b"; |
|
65 |
private static byte[] mixedBytes = new byte[] { |
|
66 |
(byte)0x2b, |
|
67 |
(byte)0x41, (byte)0x7a, |
|
68 |
(byte)0xa1, (byte)0xdf, |
|
69 |
(byte)0x81, (byte)0x40, |
|
70 |
(byte)0x83, (byte)0x40, |
|
71 |
(byte)0x88, (byte)0xea, |
|
72 |
(byte)0x82, (byte)0xf5, // composite |
|
73 |
(byte)0x82, (byte)0xa9 }; // base without cc |
|
74 |
||
75 |
//base + base + cc |
|
76 |
private static String mixedCompStr = "\u304D\u304B\u309A"; |
|
77 |
private static byte[] mixedCompBytes = new byte[] { |
|
78 |
(byte)0x82, (byte)0xab, (byte)0x82, (byte)0xf5}; |
|
79 |
||
80 |
private static char[] unmappableChars = new char[] { |
|
81 |
0x80, 0xfffc, 0xfffd}; |
|
82 |
||
83 |
private static byte[] unmappableBytes = new byte[] { |
|
84 |
0x3f, 0x3f, 0x3f}; |
|
85 |
||
86 |
public static void main(String[] args) throws Exception { |
|
87 |
if (!winStr.equals(new String(winStr.getBytes("MS932"), "MS932_0213"))) |
|
88 |
throw new RuntimeException("MS932_0213 failed on special codepoints!"); |
|
89 |
||
90 |
if (!(Arrays.equals(compStr.getBytes("MS932_0213"), compBytes)) || |
|
91 |
!compStr.equals(new String(compBytes, "MS932_0213"))) |
|
92 |
throw new RuntimeException("MS932_0213 failed on composites!"); |
|
93 |
||
94 |
if (!(Arrays.equals(mixedStr.getBytes("MS932_0213"), mixedBytes)) || |
|
95 |
!mixedStr.equals(new String(mixedBytes, "MS932_0213"))) |
|
96 |
throw new RuntimeException("MS932_0213 failed on mixed!"); |
|
97 |
||
98 |
if (!sjisStr.equals(new String(sjisStr.getBytes("SJIS"), "SJIS_0213"))) |
|
99 |
throw new RuntimeException("SJIS_0213 failed on special codepoints!"); |
|
100 |
||
101 |
if (!(Arrays.equals(compStr.getBytes("SJIS_0213"), compBytes)) || |
|
102 |
!compStr.equals(new String(compBytes, "SJIS_0213"))) |
|
103 |
throw new RuntimeException("SJIS_0213 failed on composites!"); |
|
104 |
||
105 |
if (!(Arrays.equals(mixedStr.getBytes("SJIS_0213"), mixedBytes)) || |
|
106 |
!mixedStr.equals(new String(mixedBytes, "SJIS_0213"))) |
|
107 |
throw new RuntimeException("SJIS_0213 failed on mixed!"); |
|
108 |
||
109 |
if (!(Arrays.equals(mixedCompStr.getBytes("SJIS_0213"), mixedCompBytes)) || |
|
110 |
!mixedCompStr.equals(new String(mixedCompBytes, "SJIS_0213"))) |
|
111 |
throw new RuntimeException("SJIS_0213 failed on mixedComp!"); |
|
112 |
||
113 |
if (!Arrays.equals(new String(unmappableChars).getBytes("SJIS_0213"), unmappableBytes) || |
|
114 |
!Arrays.equals(new String(unmappableChars).getBytes("MS932_0213"), unmappableBytes)) |
|
115 |
throw new RuntimeException("SJIS/MS932_0213 failed on unmappable encoding!"); |
|
116 |
} |
|
117 |
} |