Add byte slice accessor to Go code

This commit is contained in:
Ben Harper
2015-04-01 16:39:53 +02:00
parent ca5c9e7496
commit 8fb6c4f764
4 changed files with 48 additions and 1 deletions

View File

@@ -213,6 +213,11 @@ func CheckReadBuffer(buf []byte, offset flatbuffers.UOffsetT, fail func(string,
fail(FailString("monster2.Name()", "Fred", got))
}
inventorySlice := monster.InventoryBytes()
if len(inventorySlice) != monster.InventoryLength() {
fail(FailString("len(monster.InventoryBytes) != monster.InventoryLength", len(inventorySlice), monster.InventoryLength()))
}
if got := monster.InventoryLength(); 5 != got {
fail(FailString("monster.InventoryLength", 5, got))
}
@@ -221,6 +226,9 @@ func CheckReadBuffer(buf []byte, offset flatbuffers.UOffsetT, fail func(string,
l := monster.InventoryLength()
for i := 0; i < l; i++ {
v := monster.Inventory(i)
if v != inventorySlice[i] {
fail(FailString("monster inventory slice[i] != Inventory(i)", v, inventorySlice[i]))
}
invsum += int(v)
}
if invsum != 10 {