diff options
Diffstat (limited to 'libgo/go/encoding/binary/binary_test.go')
-rw-r--r-- | libgo/go/encoding/binary/binary_test.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libgo/go/encoding/binary/binary_test.go b/libgo/go/encoding/binary/binary_test.go index d372d2d0272c..e09ec489fd4c 100644 --- a/libgo/go/encoding/binary/binary_test.go +++ b/libgo/go/encoding/binary/binary_test.go @@ -28,6 +28,13 @@ type Struct struct { Array [4]uint8 } +type T struct { + Int int + Uint uint + Uintptr uintptr + Array [4]int +} + var s = Struct{ 0x01, 0x0203, @@ -40,11 +47,11 @@ var s = Struct{ math.Float32frombits(0x1f202122), math.Float64frombits(0x232425262728292a), - cmplx( + complex( math.Float32frombits(0x2b2c2d2e), math.Float32frombits(0x2f303132), ), - cmplx( + complex( math.Float64frombits(0x333435363738393a), math.Float64frombits(0x3b3c3d3e3f404142), ), @@ -136,3 +143,20 @@ func TestWriteSlice(t *testing.T) { err := Write(buf, BigEndian, res) checkResult(t, "WriteSlice", BigEndian, err, buf.Bytes(), src) } + +func TestWriteT(t *testing.T) { + buf := new(bytes.Buffer) + ts := T{} + err := Write(buf, BigEndian, ts) + if err == nil { + t.Errorf("WriteT: have nil, want non-nil") + } + + tv := reflect.Indirect(reflect.NewValue(ts)).(*reflect.StructValue) + for i, n := 0, tv.NumField(); i < n; i++ { + err = Write(buf, BigEndian, tv.Field(i).Interface()) + if err == nil { + t.Errorf("WriteT.%v: have nil, want non-nil", tv.Field(i).Type()) + } + } +} |