import org.eclipse.linuxtools.ctf.core.event.types.Definition;
import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
+import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.SequenceDefinition;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
import org.junit.Before;
import org.junit.Test;
+import com.google.common.collect.ImmutableList;
+
/**
* The class <code>SequenceDefinitionTest</code> contains tests for the class
* <code>{@link SequenceDefinition}</code>.
private SequenceDefinition fixture;
private final static int seqLen = 15;
+ private static ImmutableList<String> wrap(String s) {
+ return ImmutableList.<String> builder().add(s).build();
+ }
+
/**
* Perform pre-test initialization.
+ *
* @throws CTFReaderException
*/
@Before
StructDeclaration structDec;
StructDefinition structDef;
- IntegerDeclaration id = new IntegerDeclaration(8, false, 8,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null, 8);
+ IntegerDeclaration id = IntegerDeclaration.createDeclaration(8, false, 8,
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, "", 8);
String lengthName = "LengthName";
structDec = new StructDeclaration(0);
structDec.addField(lengthName, id);
- structDef = new StructDefinition(structDec, null, "x");
+ structDef = new StructDefinition(structDec, null, "x",
+ wrap(lengthName),
+ new Definition[] { new IntegerDefinition(id, null, lengthName, seqLen) });
- structDef.lookupInteger(lengthName).setValue(seqLen);
SequenceDeclaration sd = new SequenceDeclaration(lengthName, id);
- fixture = new SequenceDefinition(sd, structDef, "TestX");
BitBuffer input = new BitBuffer(
java.nio.ByteBuffer.allocateDirect(seqLen * 8));
for (int i = 0; i < seqLen; i++) {
input.putInt(i);
}
- fixture.read(input);
+
+ fixture = sd.createDefinition(structDef, "TestX", input);
assert (fixture != null);
}
StructDefinition structDef;
int len = 32;
- IntegerDeclaration id = new IntegerDeclaration(len, false, len,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null,8);
+ IntegerDeclaration id = IntegerDeclaration.createDeclaration(len, false, len,
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, "", 8);
String lengthName = "LengthName";
structDec = new StructDeclaration(0);
structDec.addField(lengthName, id);
- structDef = new StructDefinition(structDec, null, "x");
- structDef.lookupInteger(lengthName).setValue(seqLen);
+ structDef = new StructDefinition(structDec, null, "x", wrap(lengthName), new Definition[] { new IntegerDefinition(id, null, lengthName, seqLen) });
+
SequenceDeclaration sd = new SequenceDeclaration(lengthName, id);
- SequenceDefinition ret = new SequenceDefinition(sd, structDef, "TestX");
BitBuffer input = new BitBuffer(
java.nio.ByteBuffer.allocateDirect(seqLen * len));
for (int i = 0; i < seqLen; i++) {
input.putInt(i);
}
- ret.read(input);
+
+ SequenceDefinition ret = sd.createDefinition(structDef, "TestX", input);
assertNotNull(ret);
return ret;
}
*/
@Test
public void testIsString() {
- boolean result = fixture.isString();
+ boolean result = fixture.getDeclaration().isString();
assertTrue(result);
}
- /**
- * Run the void read(BitBuffer) method test.
- * @throws CTFReaderException error
- */
- @Test
- public void testRead() throws CTFReaderException {
- BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
- fixture.read(input);
- }
-
/**
* Run the String toString() method test.
*/