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;
*/
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
*/
@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());
}
*/
@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());
}
*/
@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());
}
*/
@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());
}
}