ctf: make SIPIE enums store both key and value
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.ctf.core.tests / src / org / eclipse / tracecompass / ctf / core / tests / trace / CTFStreamInputPacketIndexEntryTest.java
index d0c0eebbca79f258ae4914fbda828e75eb2acda6..f1677c7268b7da6e9b47f03dcf91c39a7e645305 100644 (file)
@@ -61,7 +61,7 @@ public class CTFStreamInputPacketIndexEntryTest {
     @Test
     public void testStreamInputPacketIndexEntry_1() {
         String expectedResult = "StreamInputPacketIndexEntry [offsetBits=1, " +
-                "timestampBegin=" + Long.MIN_VALUE +
+                "timestampBegin=" + 0 +
                 ", timestampEnd=" + Long.MAX_VALUE +
                 "]";
 
@@ -84,8 +84,9 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
         sd.addField("load_factor", new FloatDeclaration(24, 8, ByteOrder.nativeOrder(), 8));
         sd.addField("target", StringDeclaration.getStringDeclaration(Encoding.ASCII));
-        sd.addField("Enum", new EnumDeclaration(IntegerDeclaration.INT_8_DECL));
-        @SuppressWarnings("null")
+        final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        declaration.add(-100, 100, "");
+        sd.addField("Enum", declaration);
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(100);
         bb.getByteBuffer().putInt(200);
@@ -113,8 +114,9 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
         sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
         sd.addField("target", StringDeclaration.getStringDeclaration(Encoding.ASCII));
-        sd.addField("Enum", new EnumDeclaration(IntegerDeclaration.INT_8_DECL));
-        @SuppressWarnings("null")
+        final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        declaration.add(-100, 100, "");
+        sd.addField("Enum", declaration);
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(100);
         bb.getByteBuffer().putInt(200);
@@ -142,9 +144,10 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
         sd.addField("packet_size", IntegerDeclaration.INT_32B_DECL);
         sd.addField("target", StringDeclaration.getStringDeclaration(Encoding.ASCII));
-        sd.addField("Enum", new EnumDeclaration(IntegerDeclaration.INT_8_DECL));
+        final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        declaration.add(-100, 100, "");
+        sd.addField("Enum", declaration);
         sd.addField("intruder", new StructDeclaration(8));
-        @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(100);
         bb.getByteBuffer().putInt(200);
@@ -173,8 +176,9 @@ public class CTFStreamInputPacketIndexEntryTest {
         StructDeclaration sd = new StructDeclaration(8);
         sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
         sd.addField("target", StringDeclaration.getStringDeclaration(Encoding.ASCII));
-        sd.addField("Enum", new EnumDeclaration(IntegerDeclaration.INT_8_DECL));
-        @SuppressWarnings("null")
+        final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        declaration.add(-100, 100, "");
+        sd.addField("Enum", declaration);
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(0);
         bb.getByteBuffer().put(("Test").getBytes());
@@ -183,7 +187,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         ICTFPacketDescriptor sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertNull(sipie.getTarget());
-        assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
+        assertEquals(0, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
     }
 
@@ -199,8 +203,9 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
         sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
         sd.addField("device", StringDeclaration.getStringDeclaration(Encoding.ASCII));
-        sd.addField("Enum", new EnumDeclaration(IntegerDeclaration.INT_8_DECL));
-        @SuppressWarnings("null")
+        final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        declaration.add(-100, 100, "");
+        sd.addField("Enum", declaration);
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(-1);
         bb.getByteBuffer().putInt(0);
@@ -209,7 +214,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put((byte) 0);
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         ICTFPacketDescriptor sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
-        assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
+        assertEquals(0, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
         assertEquals("Test66", sipie.getTarget());
         assertEquals(66, sipie.getTargetId());
@@ -228,7 +233,6 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
         sd.addField("cpu_id", IntegerDeclaration.INT_32B_DECL);
         sd.addField("events_discarded", IntegerDeclaration.INT_32B_DECL);
-        @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(-1);
         bb.getByteBuffer().putInt(0);
@@ -236,7 +240,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().putInt(300);
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         ICTFPacketDescriptor sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 100);
-        assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
+        assertEquals(0, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
         assertEquals("CPU66", sipie.getTarget());
         assertEquals(66, sipie.getTargetId());
@@ -259,14 +263,13 @@ public class CTFStreamInputPacketIndexEntryTest {
         final EnumDeclaration declaration = new EnumDeclaration(IntegerDeclaration.createDeclaration(16, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 8));
         declaration.add(313, 315, "CPU-PI");
         sd.addField("device", declaration);
-        @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(-1);
         bb.getByteBuffer().putInt(0);
         bb.getByteBuffer().putShort((short) 314);
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         ICTFPacketDescriptor sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
-        assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
+        assertEquals(0, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
         assertEquals("CPU-PI", sipie.getTarget());
         assertEquals(314, sipie.getTargetId());
@@ -285,14 +288,13 @@ public class CTFStreamInputPacketIndexEntryTest {
         sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
         final IDeclaration declaration = IntegerDeclaration.createDeclaration(16, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 8);
         sd.addField("device", declaration);
-        @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
         bb.getByteBuffer().putInt(-1);
         bb.getByteBuffer().putInt(0);
         bb.getByteBuffer().putShort((short) 314);
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         ICTFPacketDescriptor sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
-        assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
+        assertEquals(0, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
         assertEquals("314", sipie.getTarget());
         assertEquals(314, sipie.getTargetId());
@@ -311,7 +313,6 @@ public class CTFStreamInputPacketIndexEntryTest {
         StructDeclaration sd = new StructDeclaration(8);
         sd.addField("timestamp_begin", IntegerDeclaration.INT_32B_DECL);
         sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
-        @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
 
         StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
This page took 0.031153 seconds and 5 git commands to generate.