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;
13 import static org.junit.Assert.*;
17 public class DecodeErrorInfoTest {
19 public DecodeErrorInfoTest() {
23 public static void setUpClass() throws Exception{
27 public static void tearDownClass() throws Exception{
35 public void tearDown() {
42 public void testConstructor(){
43 System.out.println("Constructor");
45 new DecodeErrorInfo(99, (byte)0xfe);
46 new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
48 new DecodeErrorInfo(0, (byte)0xfe);
49 new DecodeErrorInfo(0, (byte)0x87, (byte)0x40);
52 new DecodeErrorInfo(-1, (byte)0xfe);
54 }catch(IndexOutOfBoundsException e){
60 new DecodeErrorInfo(-1, (byte)0x87, (byte)0x40);
62 }catch(IndexOutOfBoundsException e){
71 * Test of getCharPosition method, of class DecodeErrorInfo.
74 public void testGetCharPosition(){
75 System.out.println("getCharPosition");
79 info = new DecodeErrorInfo(99, (byte)0xfe);
80 assertEquals(99, info.getCharPosition());
82 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
83 assertEquals(999, info.getCharPosition());
89 * Test of has2nd method, of class DecodeErrorInfo.
92 public void testHas2nd(){
93 System.out.println("has2nd");
97 info = new DecodeErrorInfo(99, (byte)0xfe);
98 assertFalse(info.has2nd());
100 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
101 assertTrue(info.has2nd());
107 * Test of getRawByte1st method, of class DecodeErrorInfo.
110 public void testGetRawByte1st(){
111 System.out.println("getRawByte1st");
113 DecodeErrorInfo info;
115 info = new DecodeErrorInfo(99, (byte)0xfe);
116 assertEquals((byte)0xfe, info.getRawByte1st());
118 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
119 assertEquals((byte)0x87, info.getRawByte1st());
125 * Test of getRawByte2nd method, of class DecodeErrorInfo.
128 public void testGetRawByte2nd(){
129 System.out.println("getRawByte2nd");
131 DecodeErrorInfo info;
133 info = new DecodeErrorInfo(99, (byte)0xfe);
135 info.getRawByte2nd();
137 }catch(IllegalStateException e){
142 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
143 assertEquals((byte)0x40, info.getRawByte2nd());
149 * Test of createGappedClone method, of class DecodeErrorInfo.
152 public void testCreateGappedClone(){
153 System.out.println("createGappedClone");
155 DecodeErrorInfo info;
157 info = new DecodeErrorInfo(99, (byte)0xfe);
158 info = info.createGappedClone(1);
159 assertEquals(98, info.getCharPosition());
161 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
162 info = info.createGappedClone(1);
163 assertEquals(998, info.getCharPosition());
165 info = new DecodeErrorInfo(99, (byte)0xfe);
166 info = info.createGappedClone(-1);
167 assertEquals(100, info.getCharPosition());
169 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
170 info = info.createGappedClone(-1);
171 assertEquals(1000, info.getCharPosition());
173 info = new DecodeErrorInfo(99, (byte)0xfe);
174 info = info.createGappedClone(99);
175 assertEquals(0, info.getCharPosition());
177 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
178 info = info.createGappedClone(999);
179 assertEquals(0, info.getCharPosition());
181 info = new DecodeErrorInfo(99, (byte)0xfe);
183 info = info.createGappedClone(100);
185 }catch(IndexOutOfBoundsException e){
190 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
192 info = info.createGappedClone(1000);
194 }catch(IndexOutOfBoundsException e){
203 * Test of toString method, of class DecodeErrorInfo.
206 public void testToString(){
207 System.out.println("toString");
209 DecodeErrorInfo info;
211 info = new DecodeErrorInfo(99, (byte)0x09);
212 assertEquals("start:99 09", info.toString());
214 info = new DecodeErrorInfo(99, (byte)0xfe);
215 assertEquals("start:99 fe", info.toString());
217 info = new DecodeErrorInfo(999, (byte)0x08, (byte)0x09);
218 assertEquals("start:999 08:09", info.toString());
220 info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
221 assertEquals("start:999 87:40", info.toString());
227 * Test of POS_COMPARATOR.
230 public void testCompare(){
231 System.out.println("POS_COMPARATOR");
233 DecodeErrorInfo info;
234 DecodeErrorInfo other;
236 info = new DecodeErrorInfo(99, (byte)0xfe);
237 other = new DecodeErrorInfo(98, (byte)0xfe);
238 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) > 0);
240 info = new DecodeErrorInfo(99, (byte)0xfe);
241 other = new DecodeErrorInfo(100, (byte)0xfe);
242 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) < 0);
244 info = new DecodeErrorInfo(99, (byte)0xfe);
245 other = new DecodeErrorInfo(99, (byte)0xfe);
246 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) == 0);
248 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, other) < 0);
249 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, null) > 0);
250 assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, null) == 0);