| Index: mojom/generators/go/templates/declarations_test.go
|
| diff --git a/mojom/generators/go/templates/declarations_test.go b/mojom/generators/go/templates/declarations_test.go
|
| index 5b4b3329a6096069dcb38968d0a8a7cfd9463828..899ad97cf6917dfd9e43a3f79afc58968718f27e 100644
|
| --- a/mojom/generators/go/templates/declarations_test.go
|
| +++ b/mojom/generators/go/templates/declarations_test.go
|
| @@ -51,3 +51,46 @@ func TestStructDecl(t *testing.T) {
|
|
|
| check(t, expected, "StructDecl", s)
|
| }
|
| +
|
| +func TestUnionInterfaceDecl(t *testing.T) {
|
| + expected := `type SomeUnion interface {
|
| + Tag() uint32
|
| + Interface() interface{}
|
| + __Reflect(__SomeUnionReflect)
|
| + Encode(encoder *bindings.Encoder) error
|
| +}
|
| +
|
| +type __SomeUnionReflect struct {
|
| + Alpha string
|
| + Beta uint32
|
| +}`
|
| +
|
| + union := translator.UnionTemplate{
|
| + Name: "SomeUnion",
|
| + Fields: []translator.UnionFieldTemplate{
|
| + {Name: "Alpha", Type: "string"},
|
| + {Name: "Beta", Type: "uint32"},
|
| + },
|
| + }
|
| +
|
| + check(t, expected, "UnionInterfaceDecl", union)
|
| +}
|
| +
|
| +func TestUnionFieldDecl(t *testing.T) {
|
| + expected := `type SomeUnionAlpha struct{ Value string }
|
| +
|
| +func (u *SomeUnionAlpha) Tag() uint32 { return 5 }
|
| +func (u *SomeUnionAlpha) Interface() interface{} { return u.Value }
|
| +func (u *SomeUnionAlpha) __Reflect(__SomeUnionReflect) {}`
|
| +
|
| + union := translator.UnionTemplate{Name: "SomeUnion"}
|
| +
|
| + field := translator.UnionFieldTemplate{
|
| + Name: "Alpha",
|
| + Type: "string",
|
| + Tag: 5,
|
| + Union: &union,
|
| + }
|
| +
|
| + check(t, expected, "UnionFieldDecl", field)
|
| +}
|
|
|