use of composite.elements.MsgDecoder in project simple-binary-encoding by real-logic.
the class CompositeElementsGenerationTest method shouldDecodeCorrectly.
@Test
public void shouldDecodeCorrectly() {
final ByteBuffer encodedMsgBuffer = ByteBuffer.allocate(MSG_BUFFER_CAPACITY);
encodeTestMessage(encodedMsgBuffer);
final DirectBuffer decodeBuffer = new UnsafeBuffer(encodedMsgBuffer);
final MessageHeaderDecoder hdrDecoder = new MessageHeaderDecoder();
final MsgDecoder msgDecoder = new MsgDecoder();
hdrDecoder.wrap(decodeBuffer, 0);
msgDecoder.wrap(decodeBuffer, hdrDecoder.encodedLength(), MSG_ENCODER.sbeBlockLength(), MSG_ENCODER.sbeSchemaVersion());
assertThat(hdrDecoder.blockLength(), is(22));
assertThat(hdrDecoder.templateId(), is(1));
assertThat(hdrDecoder.schemaId(), is(3));
assertThat(hdrDecoder.version(), is(0));
assertThat(msgDecoder.structure().enumOne(), is(EnumOne.Value10));
assertThat(msgDecoder.structure().zeroth(), is((short) 42));
assertThat(msgDecoder.structure().setOne().bit0(), is(false));
assertThat(msgDecoder.structure().setOne().bit16(), is(true));
assertThat(msgDecoder.structure().setOne().bit26(), is(false));
assertThat(msgDecoder.structure().inner().first(), is(101L));
assertThat(msgDecoder.structure().inner().second(), is(202L));
assertThat(msgDecoder.encodedLength(), is(22));
}
Aggregations