本文整理汇总了Golang中MyGame/Example.Vec3.Y方法的典型用法代码示例。如果您正苦于以下问题:Golang Vec3.Y方法的具体用法?Golang Vec3.Y怎么用?Golang Vec3.Y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyGame/Example.Vec3
的用法示例。
在下文中一共展示了Vec3.Y方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BenchmarkParseGold
// BenchmarkParseGold measures the speed of parsing the 'gold' data
// used throughout this test suite.
func BenchmarkParseGold(b *testing.B) {
buf, offset := CheckGeneratedBuild(b.Fatalf)
monster := example.GetRootAsMonster(buf, offset)
// use these to prevent allocations:
reuse_pos := example.Vec3{}
reuse_test3 := example.Test{}
reuse_table2 := flatbuffers.Table{}
reuse_monster2 := example.Monster{}
reuse_test4_0 := example.Test{}
reuse_test4_1 := example.Test{}
b.SetBytes(int64(len(buf[offset:])))
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
monster.Hp()
monster.Mana()
name := monster.Name()
_ = name[0]
_ = name[len(name)-1]
monster.Pos(&reuse_pos)
reuse_pos.X()
reuse_pos.Y()
reuse_pos.Z()
reuse_pos.Test1()
reuse_pos.Test2()
reuse_pos.Test3(&reuse_test3)
reuse_test3.A()
reuse_test3.B()
monster.TestType()
monster.Test(&reuse_table2)
reuse_monster2.Init(reuse_table2.Bytes, reuse_table2.Pos)
name2 := reuse_monster2.Name()
_ = name2[0]
_ = name2[len(name2)-1]
monster.InventoryLength()
l := monster.InventoryLength()
for i := 0; i < l; i++ {
monster.Inventory(i)
}
monster.Test4Length()
monster.Test4(&reuse_test4_0, 0)
monster.Test4(&reuse_test4_1, 1)
reuse_test4_0.A()
reuse_test4_0.B()
reuse_test4_1.A()
reuse_test4_1.B()
monster.TestarrayofstringLength()
str0 := monster.Testarrayofstring(0)
_ = str0[0]
_ = str0[len(str0)-1]
str1 := monster.Testarrayofstring(1)
_ = str1[0]
_ = str1[len(str1)-1]
}
}
示例2: CheckReadBuffer
// CheckReadBuffer checks that the given buffer is evaluated correctly
// as the example Monster.
func CheckReadBuffer(buf []byte, offset flatbuffers.UOffsetT, fail func(string, ...interface{})) {
monster := example.GetRootAsMonster(buf, offset)
if got := monster.Hp(); 80 != got {
fail(FailString("hp", 80, got))
}
// default
if got := monster.Mana(); 150 != got {
fail(FailString("mana", 150, got))
}
if got := monster.Name(); !bytes.Equal([]byte("MyMonster"), got) {
fail(FailString("name", "MyMonster", got))
}
// initialize a Vec3 from Pos()
vec := new(example.Vec3)
vec = monster.Pos(vec)
if vec == nil {
fail("vec3 initialization failed")
}
// check that new allocs equal given ones:
vec2 := monster.Pos(nil)
if !reflect.DeepEqual(vec, vec2) {
fail("fresh allocation failed")
}
// verify the properties of the Vec3
if got := vec.X(); float32(1.0) != got {
fail(FailString("Pos.X", float32(1.0), got))
}
if got := vec.Y(); float32(2.0) != got {
fail(FailString("Pos.Y", float32(2.0), got))
}
if got := vec.Z(); float32(3.0) != got {
fail(FailString("Pos.Z", float32(3.0), got))
}
if got := vec.Test1(); float64(3.0) != got {
fail(FailString("Pos.Test1", float64(3.0), got))
}
if got := vec.Test2(); int8(2) != got {
fail(FailString("Pos.Test2", int8(2), got))
}
// initialize a Test from Test3(...)
t := new(example.Test)
t = vec.Test3(t)
if t == nil {
fail("vec.Test3(&t) failed")
}
// check that new allocs equal given ones:
t2 := vec.Test3(nil)
if !reflect.DeepEqual(t, t2) {
fail("fresh allocation failed")
}
// verify the properties of the Test
if got := t.A(); int16(5) != got {
fail(FailString("t.A()", int16(5), got))
}
if got := t.B(); int8(6) != got {
fail(FailString("t.B()", int8(6), got))
}
if got := monster.TestType(); example.AnyMonster != got {
fail(FailString("monster.TestType()", example.AnyMonster, got))
}
if unionType := monster.TestType(); unionType != example.AnyMonster {
fail("monster.TestType()")
}
// initialize a Table from a union field Test(...)
var table2 flatbuffers.Table
if ok := monster.Test(&table2); !ok {
fail("monster.Test(&monster2) failed")
}
// initialize a Monster from the Table from the union
var monster2 example.Monster
monster2.Init(table2.Bytes, table2.Pos)
if got := monster2.Name(); !bytes.Equal([]byte("Fred"), got) {
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()))
}
//.........这里部分代码省略.........