ctf: BitBuffer improvements
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / io / BitBufferIntTest.java
index 79b4bc2fc7eb3c5df86c80c66ec2d985ba2eac3d..22fee78a6b50007e110fe4d116755141ea7fd2e2 100644 (file)
@@ -13,9 +13,9 @@ import org.junit.Test;
 /**
  * Part of the BitBuffet tests with test the methods to read/write integers.
  * These are separated from the main file because the fixture is different.
- * 
+ *
  * @author alexmont
- * 
+ *
  */
 public class BitBufferIntTest {
 
@@ -23,7 +23,7 @@ public class BitBufferIntTest {
 
     /**
      * Launch the test.
-     * 
+     *
      * @param args
      *            the command line arguments
      */
@@ -113,11 +113,10 @@ public class BitBufferIntTest {
     @Test
     public void testGetInt_signed() {
         fixture.position(1);
-        int index = 1;
         int length = 0;
         boolean signed = true;
 
-        int result = fixture.getInt(index, length, signed);
+        int result = fixture.getInt(length, signed);
         assertEquals(0, result);
     }
 
@@ -127,11 +126,10 @@ public class BitBufferIntTest {
     @Test
     public void testGetInt_signed_length1() {
         fixture.position(1);
-        int index = 1;
         int length = 1;
         boolean signed = true;
 
-        int result = fixture.getInt(index, length, signed);
+        int result = fixture.getInt(length, signed);
         assertEquals(0, result);
     }
 
@@ -146,9 +144,8 @@ public class BitBufferIntTest {
         le_fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
         createBuffer(le_fixture);
         le_fixture.position(1);
-        int index = 1;
         int length = 24;
-        int result = le_fixture.getInt(index, length, false);
+        int result = le_fixture.getInt(length, false);
 
         /* 0x020100 downshifted */
         assertEquals(0x810080, result);
@@ -165,9 +162,8 @@ public class BitBufferIntTest {
         le_fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
         createBuffer(le_fixture);
         le_fixture.position(0);
-        int index = 0;
         int length = 24;
-        int result = le_fixture.getInt(index, length, false);
+        int result = le_fixture.getInt(length, false);
         assertEquals(0x020100, result);
     }
 
@@ -198,11 +194,10 @@ public class BitBufferIntTest {
         small_fixture.setByteOrder(ByteOrder.BIG_ENDIAN);
         createBuffer(small_fixture, 2);
         small_fixture.position(1);
-        int index = 1;
         int length = 64;
         boolean signed = true;
 
-        int result = small_fixture.getInt(index, length, signed);
+        int result = small_fixture.getInt(length, signed);
         assertEquals(0, result);
     }
 
@@ -233,12 +228,11 @@ public class BitBufferIntTest {
      */
     @Test
     public void testPutInt_length0() {
-        int index = 1;
         int length = 0;
         int value = 1;
 
         fixture.position(1);
-        fixture.putInt(index, length, value);
+        fixture.putInt(length, value);
     }
 
     /**
@@ -246,12 +240,11 @@ public class BitBufferIntTest {
      */
     @Test
     public void testPutInt_length1() {
-        int index = 1;
         int length = 1;
         int value = 1;
 
         fixture.position(1);
-        fixture.putInt(index, length, value);
+        fixture.putInt(length, value);
     }
 
     /**
@@ -259,12 +252,18 @@ public class BitBufferIntTest {
      */
     @Test
     public void testPutInt_hex() {
-        int value = 0x010203;
+        final int value = 0x010203;
+        int read;
 
-        fixture.position(1);
-        fixture.putInt(value);
-        int read = fixture.getInt();
-        assertEquals(value, read);
+        for (int i = 0; i <= 32; i++) {
+            fixture.position(i);
+            fixture.putInt(value);
+
+            fixture.position(i);
+            read = fixture.getInt();
+
+            assertEquals(value, read);
+        }
     }
 
     /**
@@ -278,11 +277,10 @@ public class BitBufferIntTest {
         createBuffer(fixture2, 4);
         fixture2.position(1);
 
-        int index = 16;
         int length = 32;
         int value = 1;
 
-        fixture2.putInt(index, length, value);
+        fixture2.putInt(length, value);
 
         int read = fixture2.getInt(1, true);
         assertEquals(value, read);
This page took 0.026508 seconds and 5 git commands to generate.