blob: f307a55103a666013632ac98c1dc85ab0b55139b [file] [log] [blame]
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build fuchsia
package fidl_test
import (
"testing"
. "syscall/zx/fidl/bindingstest"
)
func TestUnionStructFieldFactory(t *testing.T) {
b := TestSimple{X: 13}
union := Union1WithB(b)
if union.Which() != Union1B {
t.Error("expected union with tag Union1B")
}
if union.B != b {
t.Error("union has incorrect value")
}
}
func TestUnionPrimitiveFieldFactory(t *testing.T) {
union := Union1WithD(3.14)
if union.Which() != Union1D {
t.Error("expected union with tag Union1D")
}
if union.D != 3.14 {
t.Error("union has incorrect value")
}
}
func TestXUnionStructFieldFactory(t *testing.T) {
b := TestSimple{X: 13}
xunion := XUnion1WithB(b)
if xunion.Which() != XUnion1B {
t.Error("expected xunion with tag XUnion1B")
}
if xunion.B != b {
t.Error("xunion has incorrect value")
}
}
func TestXUnionPrimitiveFieldFactory(t *testing.T) {
xunion := XUnion1WithD(3.14)
if xunion.Which() != XUnion1D {
t.Error("expected xunion with tag XUnion1D")
}
if xunion.D != 3.14 {
t.Error("xunion has incorrect value")
}
}
func TestXUnionArrayFieldFactory(t *testing.T) {
a := [3]int8{1, 2, 3}
xunion := XUnion1WithA(a)
if xunion.Which() != XUnion1A {
t.Error("expected xunion with tag XUnion1A")
}
if xunion.A != a {
t.Error("xunion has incorrect value")
}
}