2 * License : The MIT License
3 * Copyright(c) 2009 olyutorskii
6 package jp.osdn.jindolf.parser.content;
8 import java.io.UnsupportedEncodingException;
9 import org.junit.After;
10 import org.junit.AfterClass;
11 import org.junit.Before;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
15 import static org.junit.Assert.*;
19 public class ShiftJisTest {
21 public ShiftJisTest() {
25 public static void setUpClass() throws Exception{
29 public static void tearDownClass() throws Exception{
37 public void tearDown() {
41 * Test of isShiftJIS1stByte method, of class ShiftJis.
44 public void testIsShiftJIS1stByte(){
45 System.out.println("isShiftJIS1stByte");
47 for(int ival=0x00; ival <= 0x80; ival++){
48 byte bval = (byte)ival;
49 assertFalse(ShiftJis.isShiftJIS1stByte(bval));
52 for(int ival=0x81; ival <= 0x9f; ival++){
53 byte bval = (byte)ival;
54 assertTrue(ShiftJis.isShiftJIS1stByte(bval));
57 for(int ival=0xa0; ival <= 0xdf; ival++){
58 byte bval = (byte)ival;
59 assertFalse(ShiftJis.isShiftJIS1stByte(bval));
62 for(int ival=0xe0; ival <= 0xfc; ival++){
63 byte bval = (byte)ival;
64 assertTrue(ShiftJis.isShiftJIS1stByte(bval));
67 for(int ival=0xfd; ival <= 0xff; ival++){
68 byte bval = (byte)ival;
69 assertFalse(ShiftJis.isShiftJIS1stByte(bval));
75 array = "\u3000".getBytes("Shift_JIS");
76 assertTrue(ShiftJis.isShiftJIS1stByte(array[0]));
78 array = "\u7199".getBytes("Shift_JIS");
79 assertTrue(ShiftJis.isShiftJIS1stByte(array[0]));
81 array = "\uff02".getBytes("Windows-31J");
82 assertTrue(ShiftJis.isShiftJIS1stByte(array[0]));
83 }catch(UnsupportedEncodingException e){
91 * Test of isShiftJIS2ndByte method, of class ShiftJis.
94 public void testIsShiftJIS2ndByte(){
95 System.out.println("isShiftJIS2ndByte");
97 for(int ival=0x00; ival <= 0x3f; ival++){
98 byte bval = (byte)ival;
99 assertFalse(ShiftJis.isShiftJIS2ndByte(bval));
102 for(int ival=0x40; ival <= 0x7e; ival++){
103 byte bval = (byte)ival;
104 assertTrue(ShiftJis.isShiftJIS2ndByte(bval));
107 for(int ival=0x7f; ival <= 0x7f; ival++){
108 byte bval = (byte)ival;
109 assertFalse(ShiftJis.isShiftJIS2ndByte(bval));
112 for(int ival=0x80; ival <= 0xfc; ival++){
113 byte bval = (byte)ival;
114 assertTrue(ShiftJis.isShiftJIS2ndByte(bval));
117 for(int ival=0xfd; ival <= 0xff; ival++){
118 byte bval = (byte)ival;
119 assertFalse(ShiftJis.isShiftJIS2ndByte(bval));
125 array = "\u3000".getBytes("Shift_JIS");
126 assertTrue(ShiftJis.isShiftJIS2ndByte(array[1]));
128 array = "\u7199".getBytes("Shift_JIS");
129 assertTrue(ShiftJis.isShiftJIS2ndByte(array[1]));
131 array = "\uff02".getBytes("Windows-31J");
132 assertTrue(ShiftJis.isShiftJIS2ndByte(array[1]));
133 }catch(UnsupportedEncodingException e){
141 * Test of isShiftJIS method, of class ShiftJis.
144 public void testIsShiftJIS(){
145 System.out.println("isShiftJIS");
150 array = "\u3000".getBytes("Shift_JIS");
151 assertTrue(ShiftJis.isShiftJIS(array[0], array[1]));
153 array = "\u7199".getBytes("Shift_JIS");
154 assertTrue(ShiftJis.isShiftJIS(array[0], array[1]));
156 array = "\uff02".getBytes("Windows-31J");
157 assertTrue(ShiftJis.isShiftJIS(array[0], array[1]));
158 }catch(UnsupportedEncodingException e){