public void testTile() {
    Tile tile = new Tile();
    DataBlock b1 = new DataBlock();
    b1.setA(17);
    b1.setB((short) 18);
    tile.setBlock1(b1);

    DataBlock b2 = new DataBlock();
    b2.setA(19);
    b2.setB((short) 20);
    tile.setBlock2(b2);

    DataBlock b3 = new DataBlock();
    b3.setA(30);
    b3.setB((short) 31);
    tile.setBlock3(b3);
    byte[] blob = DataScriptIO.write(tile);

    assertEquals(6, tile.getOffset1());
    assertEquals(12, tile.getOffset2());
    assertEquals(18, tile.getOffset3());

    Tile tile2 = DataScriptIO.read(Tile.class, blob);
    assertEquals(tile2, tile);
  }
  public void testTileWithOptionalBlocks() {
    TileWithOptionalBlocks tile = new TileWithOptionalBlocks();
    TileHeader2 header = new TileHeader2();
    tile.setHeader(header);
    header.setHasBlock1((byte) 1);
    header.setHasBlock2((byte) 0);
    header.setHasBlock3((byte) 1);
    header.setOffset1(0);
    header.setOffset3(0);

    VarBlock b1 = new VarBlock();
    b1.setNumItems(1);
    short[] items = {99};
    b1.setItems(new UnsignedByteArray(items, 0, 1));
    tile.setB1(b1);

    DataBlock b3 = new DataBlock();
    b3.setA(30);
    b3.setB((short) 31);
    tile.setB3(b3);
    byte[] blob = DataScriptIO.write(tile);

    assertEquals(5, tile.getHeader().getOffset1().intValue());
    assertEquals(8, tile.getHeader().getOffset3().intValue());

    TileWithOptionalBlocks tile2 = DataScriptIO.read(TileWithOptionalBlocks.class, blob);
    assertEquals(tile2, tile);
  }