-/*\r
- * Copyright(c) 2009 olyutorskii\r
- * $Id: DecodeErrorInfoTest.java 894 2009-11-04 07:26:59Z olyutorskii $\r
- */\r
-\r
-package jp.sourceforge.jindolf.parser;\r
-\r
-import org.junit.After;\r
-import org.junit.AfterClass;\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import static org.junit.Assert.*;\r
-\r
-/**\r
- */\r
-public class DecodeErrorInfoTest {\r
-\r
- public DecodeErrorInfoTest() {\r
- }\r
-\r
- @BeforeClass\r
- public static void setUpClass() throws Exception{\r
- }\r
-\r
- @AfterClass\r
- public static void tearDownClass() throws Exception{\r
- }\r
-\r
- @Before\r
- public void setUp() {\r
- }\r
-\r
- @After\r
- public void tearDown() {\r
- }\r
-\r
- /**\r
- * Test of Constructor\r
- */\r
- @Test\r
- public void testConstructor(){\r
- System.out.println("Constructor");\r
-\r
- new DecodeErrorInfo(99, (byte)0xfe);\r
- new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
-\r
- new DecodeErrorInfo(0, (byte)0xfe);\r
- new DecodeErrorInfo(0, (byte)0x87, (byte)0x40);\r
-\r
- try{\r
- new DecodeErrorInfo(-1, (byte)0xfe);\r
- fail();\r
- }catch(IndexOutOfBoundsException e){\r
- }catch(Throwable e){\r
- fail();\r
- }\r
-\r
- try{\r
- new DecodeErrorInfo(-1, (byte)0x87, (byte)0x40);\r
- fail();\r
- }catch(IndexOutOfBoundsException e){\r
- }catch(Throwable e){\r
- fail();\r
- }\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of getCharPosition method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testGetCharPosition(){\r
- System.out.println("getCharPosition");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- assertEquals(99, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- assertEquals(999, info.getCharPosition());\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of has2nd method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testHas2nd(){\r
- System.out.println("has2nd");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- assertFalse(info.has2nd());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- assertTrue(info.has2nd());\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of getRawByte1st method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testGetRawByte1st(){\r
- System.out.println("getRawByte1st");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- assertEquals((byte)0xfe, info.getRawByte1st());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- assertEquals((byte)0x87, info.getRawByte1st());\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of getRawByte2nd method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testGetRawByte2nd(){\r
- System.out.println("getRawByte2nd");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- try{\r
- info.getRawByte2nd();\r
- fail();\r
- }catch(IllegalStateException e){\r
- }catch(Throwable e){\r
- fail();\r
- }\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- assertEquals((byte)0x40, info.getRawByte2nd());\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of createGappedClone method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testCreateGappedClone(){\r
- System.out.println("createGappedClone");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- info = info.createGappedClone(1);\r
- assertEquals(98, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- info = info.createGappedClone(1);\r
- assertEquals(998, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- info = info.createGappedClone(-1);\r
- assertEquals(100, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- info = info.createGappedClone(-1);\r
- assertEquals(1000, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- info = info.createGappedClone(99);\r
- assertEquals(0, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- info = info.createGappedClone(999);\r
- assertEquals(0, info.getCharPosition());\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- try{\r
- info = info.createGappedClone(100);\r
- fail();\r
- }catch(IndexOutOfBoundsException e){\r
- }catch(Throwable e){\r
- fail();\r
- }\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- try{\r
- info = info.createGappedClone(1000);\r
- fail();\r
- }catch(IndexOutOfBoundsException e){\r
- }catch(Throwable e){\r
- fail();\r
- }\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of toString method, of class DecodeErrorInfo.\r
- */\r
- @Test\r
- public void testToString(){\r
- System.out.println("toString");\r
-\r
- DecodeErrorInfo info;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0x09);\r
- assertEquals("start:99 09", info.toString());\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- assertEquals("start:99 fe", info.toString());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x08, (byte)0x09);\r
- assertEquals("start:999 08:09", info.toString());\r
-\r
- info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);\r
- assertEquals("start:999 87:40", info.toString());\r
-\r
- return;\r
- }\r
-\r
- /**\r
- * Test of POS_COMPARATOR.\r
- */\r
- @Test\r
- public void testCompare(){\r
- System.out.println("POS_COMPARATOR");\r
-\r
- DecodeErrorInfo info;\r
- DecodeErrorInfo other;\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- other = new DecodeErrorInfo(98, (byte)0xfe);\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) > 0);\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- other = new DecodeErrorInfo(100, (byte)0xfe);\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) < 0);\r
-\r
- info = new DecodeErrorInfo(99, (byte)0xfe);\r
- other = new DecodeErrorInfo(99, (byte)0xfe);\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) == 0);\r
-\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, other) < 0);\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, null) > 0);\r
- assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, null) == 0);\r
-\r
- return;\r
- }\r
-\r
-}\r
+/*
+ * License : The MIT License
+ * Copyright(c) 2009 olyutorskii
+ */
+
+package jp.sourceforge.jindolf.parser;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ */
+public class DecodeErrorInfoTest {
+
+ public DecodeErrorInfoTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception{
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception{
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of Constructor
+ */
+ @Test
+ public void testConstructor(){
+ System.out.println("Constructor");
+
+ new DecodeErrorInfo(99, (byte)0xfe);
+ new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+
+ new DecodeErrorInfo(0, (byte)0xfe);
+ new DecodeErrorInfo(0, (byte)0x87, (byte)0x40);
+
+ try{
+ new DecodeErrorInfo(-1, (byte)0xfe);
+ fail();
+ }catch(IndexOutOfBoundsException e){
+ }catch(Throwable e){
+ fail();
+ }
+
+ try{
+ new DecodeErrorInfo(-1, (byte)0x87, (byte)0x40);
+ fail();
+ }catch(IndexOutOfBoundsException e){
+ }catch(Throwable e){
+ fail();
+ }
+
+ return;
+ }
+
+ /**
+ * Test of getCharPosition method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testGetCharPosition(){
+ System.out.println("getCharPosition");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ assertEquals(99, info.getCharPosition());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ assertEquals(999, info.getCharPosition());
+
+ return;
+ }
+
+ /**
+ * Test of has2nd method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testHas2nd(){
+ System.out.println("has2nd");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ assertFalse(info.has2nd());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ assertTrue(info.has2nd());
+
+ return;
+ }
+
+ /**
+ * Test of getRawByte1st method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testGetRawByte1st(){
+ System.out.println("getRawByte1st");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ assertEquals((byte)0xfe, info.getRawByte1st());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ assertEquals((byte)0x87, info.getRawByte1st());
+
+ return;
+ }
+
+ /**
+ * Test of getRawByte2nd method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testGetRawByte2nd(){
+ System.out.println("getRawByte2nd");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ try{
+ info.getRawByte2nd();
+ fail();
+ }catch(IllegalStateException e){
+ }catch(Throwable e){
+ fail();
+ }
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ assertEquals((byte)0x40, info.getRawByte2nd());
+
+ return;
+ }
+
+ /**
+ * Test of createGappedClone method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testCreateGappedClone(){
+ System.out.println("createGappedClone");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ info = info.createGappedClone(1);
+ assertEquals(98, info.getCharPosition());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ info = info.createGappedClone(1);
+ assertEquals(998, info.getCharPosition());
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ info = info.createGappedClone(-1);
+ assertEquals(100, info.getCharPosition());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ info = info.createGappedClone(-1);
+ assertEquals(1000, info.getCharPosition());
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ info = info.createGappedClone(99);
+ assertEquals(0, info.getCharPosition());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ info = info.createGappedClone(999);
+ assertEquals(0, info.getCharPosition());
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ try{
+ info = info.createGappedClone(100);
+ fail();
+ }catch(IndexOutOfBoundsException e){
+ }catch(Throwable e){
+ fail();
+ }
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ try{
+ info = info.createGappedClone(1000);
+ fail();
+ }catch(IndexOutOfBoundsException e){
+ }catch(Throwable e){
+ fail();
+ }
+
+ return;
+ }
+
+ /**
+ * Test of toString method, of class DecodeErrorInfo.
+ */
+ @Test
+ public void testToString(){
+ System.out.println("toString");
+
+ DecodeErrorInfo info;
+
+ info = new DecodeErrorInfo(99, (byte)0x09);
+ assertEquals("start:99 09", info.toString());
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ assertEquals("start:99 fe", info.toString());
+
+ info = new DecodeErrorInfo(999, (byte)0x08, (byte)0x09);
+ assertEquals("start:999 08:09", info.toString());
+
+ info = new DecodeErrorInfo(999, (byte)0x87, (byte)0x40);
+ assertEquals("start:999 87:40", info.toString());
+
+ return;
+ }
+
+ /**
+ * Test of POS_COMPARATOR.
+ */
+ @Test
+ public void testCompare(){
+ System.out.println("POS_COMPARATOR");
+
+ DecodeErrorInfo info;
+ DecodeErrorInfo other;
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ other = new DecodeErrorInfo(98, (byte)0xfe);
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) > 0);
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ other = new DecodeErrorInfo(100, (byte)0xfe);
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) < 0);
+
+ info = new DecodeErrorInfo(99, (byte)0xfe);
+ other = new DecodeErrorInfo(99, (byte)0xfe);
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, other) == 0);
+
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, other) < 0);
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(info, null) > 0);
+ assertTrue(DecodeErrorInfo.POS_COMPARATOR.compare(null, null) == 0);
+
+ return;
+ }
+
+}