func TestPodUnion(t *testing.T) { tests := []test_unions.PodUnion{ &test_unions.PodUnionFInt8{8}, &test_unions.PodUnionFInt16{16}, &test_unions.PodUnionFUint64{64}, &test_unions.PodUnionFBool{true}, &test_unions.PodUnionFEnum{test_unions.AnEnum_Second}, } for _, union := range tests { var wrapper, zeroWrapper test_unions.WrapperStruct wrapper.PodUnion = union check(t, &wrapper, &zeroWrapper) } }
func TestUnknownTag(t *testing.T) { var wrapper test_unions.WrapperStruct wrapper.PodUnion = &test_unions.PodUnionFInt16{10} bytes, handles, err := encode(t, &wrapper) if err != nil { t.Fatalf("Test failed prematurely.") } // Set PodUnion tag to unknown. bytes[8*3+4] = 100 decoder := bindings.NewDecoder(bytes, handles) var decoded test_unions.WrapperStruct err = decoded.Decode(decoder) if err != nil { t.Fatalf("Failed to decode union with unknown tag.") } if decoded.PodUnion.Tag() != 100 { t.Fatalf("Wrong unknown tag number") } }