mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 23:28:06 +00:00
Add byte slice accessor to Go code
Change-Id: I15cc8924d6607bd93068c762fd67e6088cfd9789
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
c4a3e2f6bd
commit
8b99bf614c
@@ -214,6 +214,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))
|
||||
}
|
||||
@@ -222,6 +227,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 {
|
||||
|
||||
Reference in New Issue
Block a user