@Test
  public void shouldCalculateDataOffsetWithPaddingFromBlockLength() throws Exception {
    final MessageSchema schema =
        parse(TestUtil.getLocalResource("block-length-schema.xml"), ParserOptions.DEFAULT);
    final List<Field> fields = schema.getMessage(4).fields();

    assertThat(valueOf(fields.get(0).computedOffset()), is(valueOf(0)));
    assertThat(valueOf(fields.get(0).type().size()), is(valueOf(8)));
    assertThat(valueOf(fields.get(1).computedOffset()), is(valueOf(64)));
    assertThat(valueOf(fields.get(1).type().size()), is(valueOf(-1)));
  }
  @Test
  public void shouldHandleAllTypeOffsetsSetByXML() throws Exception {
    final MessageSchema schema =
        parse(TestUtil.getLocalResource("basic-types-schema.xml"), ParserOptions.DEFAULT);
    final List<Field> fields = schema.getMessage(2).fields();

    assertThat(valueOf(fields.get(0).computedOffset()), is(valueOf(0)));
    assertThat(valueOf(fields.get(0).type().size()), is(valueOf(8)));
    assertThat(valueOf(fields.get(1).computedOffset()), is(valueOf(8)));
    assertThat(valueOf(fields.get(1).type().size()), is(valueOf(20)));
    assertThat(valueOf(fields.get(2).computedOffset()), is(valueOf(32)));
    assertThat(valueOf(fields.get(2).type().size()), is(valueOf(1)));
    assertThat(valueOf(fields.get(3).computedOffset()), is(valueOf(128)));
    assertThat(valueOf(fields.get(3).type().size()), is(valueOf(4)));
    assertThat(valueOf(fields.get(4).computedOffset()), is(valueOf(136)));
    assertThat(valueOf(fields.get(4).type().size()), is(valueOf(8)));
  }
  @Test
  public void shouldCalculateGroupOffsetWithNoPaddingFromBlockLength() throws Exception {
    final MessageSchema schema =
        parse(TestUtil.getLocalResource("block-length-schema.xml"), ParserOptions.DEFAULT);
    final Message msg = schema.getMessage(1);

    assertThat(valueOf(msg.blockLength()), is(valueOf(8)));

    final List<Field> fields = msg.fields();
    assertThat(valueOf(fields.get(0).computedOffset()), is(valueOf(0)));
    assertThat(valueOf(fields.get(0).type().size()), is(valueOf(8)));
    assertThat(valueOf(fields.get(1).computedOffset()), is(valueOf(8)));
    Assert.assertNull(fields.get(1).type());

    final List<Field> groupFields = fields.get(1).groupFields();
    assertThat(valueOf(groupFields.size()), is(valueOf(2)));
    assertThat(valueOf(groupFields.get(0).computedOffset()), is(valueOf(0)));
    assertThat(valueOf(groupFields.get(0).type().size()), is(valueOf(4)));
    assertThat(valueOf(groupFields.get(1).computedOffset()), is(valueOf(4)));
    assertThat(valueOf(groupFields.get(1).type().size()), is(valueOf(8)));
  }
  @Test
  public void shouldHandleEncodingTypesWithNamedTypes() throws Exception {
    final MessageSchema schema =
        parse(TestUtil.getLocalResource("encoding-types-schema.xml"), ParserOptions.DEFAULT);
    final List<Field> fields = schema.getMessage(1).fields();

    assertNotNull(fields);

    SetType type = (SetType) fields.get(3).type();

    assertThat(type.encodingType(), is(PrimitiveType.UINT8));

    type = (SetType) fields.get(4).type();

    assertThat(type.encodingType(), is(PrimitiveType.UINT16));

    type = (SetType) fields.get(5).type();

    assertThat(type.encodingType(), is(PrimitiveType.UINT32));

    type = (SetType) fields.get(6).type();

    assertThat(type.encodingType(), is(PrimitiveType.UINT64));
  }