ctf: Make events immutable
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / IntegerEndiannessTest.java
index 8801313148791554ddd8312ea69a0a60f5398baf..9ce8bc81d57b4f5f4aeab95dcb5ce4202a8844c9 100644 (file)
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
@@ -34,11 +35,11 @@ import org.junit.Test;
  */
 public class IntegerEndiannessTest {
 
-    private static String name = "testInt";
-    private static String clockName = "clock";
+    @NonNull private static final String name = "testInt";
+    @NonNull private static final String clockName = "clock";
 
     private ByteBuffer bb;
-    private BitBuffer input;
+    @NonNull private BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocate(0));
 
     /**
      * Set up the bit-buffer to be used
@@ -65,9 +66,8 @@ public class IntegerEndiannessTest {
      */
     @Test
     public void test32BE() throws CTFReaderException {
-        IntegerDeclaration be = new IntegerDeclaration(32, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
-        IntegerDefinition fixture_be = be.createDefinition(null, name);
-        fixture_be.read(input);
+        IntegerDeclaration be = IntegerDeclaration.createDeclaration(32, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
+        IntegerDefinition fixture_be = be.createDefinition(null, name, input);
         assertEquals(0xabcdef12, fixture_be.getValue());
     }
 
@@ -79,9 +79,8 @@ public class IntegerEndiannessTest {
      */
     @Test
     public void test64BE() throws CTFReaderException {
-        IntegerDeclaration be = new IntegerDeclaration(64, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
-        IntegerDefinition fixture_be = be.createDefinition(null, name);
-        fixture_be.read(input);
+        IntegerDeclaration be = IntegerDeclaration.createDeclaration(64, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
+        IntegerDefinition fixture_be = be.createDefinition(null, name, input);
         assertEquals(0xabcdef123456789aL, fixture_be.getValue());
     }
 
@@ -93,9 +92,8 @@ public class IntegerEndiannessTest {
      */
     @Test
     public void test32LE() throws CTFReaderException {
-        IntegerDeclaration le = new IntegerDeclaration(32, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
-        IntegerDefinition fixture_le = le.createDefinition(null, name);
-        fixture_le.read(input);
+        IntegerDeclaration le = IntegerDeclaration.createDeclaration(32, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
+        IntegerDefinition fixture_le = le.createDefinition(null, name, input);
         assertEquals(0x12efcdab, fixture_le.getValue());
     }
 
@@ -107,9 +105,8 @@ public class IntegerEndiannessTest {
      */
     @Test
     public void test64LE() throws CTFReaderException {
-        IntegerDeclaration le = new IntegerDeclaration(64, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
-        IntegerDefinition fixture_le = le.createDefinition(null, name);
-        fixture_le.read(input);
+        IntegerDeclaration le = IntegerDeclaration.createDeclaration(64, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
+        IntegerDefinition fixture_le = le.createDefinition(null, name, input);
         assertEquals(0x9a78563412efcdabL, fixture_le.getValue());
     }
 }
This page took 0.024863 seconds and 5 git commands to generate.