2 * License : The MIT License
3 * Copyright(c) 2009 olyutorskii
6 package jp.sourceforge.jindolf.parser;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
14 import static org.junit.Assert.*;
18 public class DecodeErrorInfoTest {
20 public DecodeErrorInfoTest() {
24 public static void setUpClass() throws Exception{
28 public static void tearDownClass() throws Exception{
36 public void tearDown() {
43 public void testConstructor(){
44 System.out.println("Constructor");
46 new DecodeErrorInfo(99, (byte)0xfe);
47 new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
49 new DecodeErrorInfo(0, (byte)0xfe);
50 new DecodeErrorInfo(0, (byte)0x87, (byte)0x40);
53 new DecodeErrorInfo(-1, (byte)0xfe);
55 }catch(IndexOutOfBoundsException e){
61 new DecodeErrorInfo(-1, (byte)0x87, (byte)0x40);
63 }catch(IndexOutOfBoundsException e){
72 * Test of getCharPosition method, of class DecodeErrorInfo.
75 public void testGetCharPosition(){
76 System.out.println("getCharPosition");
80 info = new DecodeErrorInfo(99, (byte)0xfe);
81 assertEquals(99, info.getCharPosition());
83 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
84 assertEquals(999, info.getCharPosition());
90 * Test of has2nd method, of class DecodeErrorInfo.
93 public void testHas2nd(){
94 System.out.println("has2nd");
98 info = new DecodeErrorInfo(99, (byte)0xfe);
99 assertFalse(info.has2nd());
101 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
102 assertTrue(info.has2nd());
108 * Test of getRawByte1st method, of class DecodeErrorInfo.
111 public void testGetRawByte1st(){
112 System.out.println("getRawByte1st");
114 DecodeErrorInfo info;
116 info = new DecodeErrorInfo(99, (byte)0xfe);
117 assertEquals((byte)0xfe, info.getRawByte1st());
119 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
120 assertEquals((byte)0x87, info.getRawByte1st());
126 * Test of getRawByte2nd method, of class DecodeErrorInfo.
129 public void testGetRawByte2nd(){
130 System.out.println("getRawByte2nd");
132 DecodeErrorInfo info;
134 info = new DecodeErrorInfo(99, (byte)0xfe);
136 info.getRawByte2nd();
138 }catch(IllegalStateException e){
143 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
144 assertEquals((byte)0x40, info.getRawByte2nd());
150 * Test of createGappedClone method, of class DecodeErrorInfo.
153 public void testCreateGappedClone(){
154 System.out.println("createGappedClone");
156 DecodeErrorInfo info;
158 info = new DecodeErrorInfo(99, (byte)0xfe);
159 info = info.createGappedClone(1);
160 assertEquals(98, info.getCharPosition());
162 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
163 info = info.createGappedClone(1);
164 assertEquals(998, info.getCharPosition());
166 info = new DecodeErrorInfo(99, (byte)0xfe);
167 info = info.createGappedClone(-1);
168 assertEquals(100, info.getCharPosition());
170 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
171 info = info.createGappedClone(-1);
172 assertEquals(1000, info.getCharPosition());
174 info = new DecodeErrorInfo(99, (byte)0xfe);
175 info = info.createGappedClone(99);
176 assertEquals(0, info.getCharPosition());
178 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
179 info = info.createGappedClone(999);
180 assertEquals(0, info.getCharPosition());
182 info = new DecodeErrorInfo(99, (byte)0xfe);
184 info = info.createGappedClone(100);
186 }catch(IndexOutOfBoundsException e){
191 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
193 info = info.createGappedClone(1000);
195 }catch(IndexOutOfBoundsException e){
204 * Test of toString method, of class DecodeErrorInfo.
207 public void testToString(){
208 System.out.println("toString");
210 DecodeErrorInfo info;
212 info = new DecodeErrorInfo(99, (byte)0x09);
213 assertEquals("start:99 09", info.toString());
215 info = new DecodeErrorInfo(99, (byte)0xfe);
216 assertEquals("start:99 fe", info.toString());
218 info = new DecodeErrorInfo(999, (byte)0x08, (byte)0x09);
219 assertEquals("start:999 08:09", info.toString());
221 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
222 assertEquals("start:999 87:40", info.toString());
228 * Test of POS_COMPARATOR.
231 public void testCompare(){
232 System.out.println("POS_COMPARATOR");
234 DecodeErrorInfo info;
235 DecodeErrorInfo other;
237 info = new DecodeErrorInfo(99, (byte)0xfe);
238 other = new DecodeErrorInfo(98, (byte)0xfe);
239 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) > 0);
241 info = new DecodeErrorInfo(99, (byte)0xfe);
242 other = new DecodeErrorInfo(100, (byte)0xfe);
243 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) < 0);
245 info = new DecodeErrorInfo(99, (byte)0xfe);
246 other = new DecodeErrorInfo(99, (byte)0xfe);
247 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) == 0);
249 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, other) < 0);
250 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, null) > 0);
251 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, null) == 0);