OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package binary | 5 package binary |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "bytes" | 9 "bytes" |
10 "math" | 10 "math" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 slice := make([]int32, 2) | 105 slice := make([]int32, 2) |
106 err := Read(bytes.NewBuffer(src), BigEndian, slice) | 106 err := Read(bytes.NewBuffer(src), BigEndian, slice) |
107 checkResult(t, "ReadSlice", BigEndian, err, slice, res) | 107 checkResult(t, "ReadSlice", BigEndian, err, slice, res) |
108 } | 108 } |
109 | 109 |
110 func TestWriteSlice(t *testing.T) { | 110 func TestWriteSlice(t *testing.T) { |
111 buf := new(bytes.Buffer) | 111 buf := new(bytes.Buffer) |
112 err := Write(buf, BigEndian, res) | 112 err := Write(buf, BigEndian, res) |
113 checkResult(t, "WriteSlice", BigEndian, err, buf.Bytes(), src) | 113 checkResult(t, "WriteSlice", BigEndian, err, buf.Bytes(), src) |
114 } | 114 } |
| 115 |
| 116 |
| 117 type Issue478Test struct { |
| 118 A uint8 |
| 119 B uint8 |
| 120 C []byte |
| 121 } |
| 122 |
| 123 func TestIssue478(t *testing.T) { |
| 124 var buf bytes.Buffer |
| 125 s := Issue478Test{1, 2, []byte{3, 4}} |
| 126 err := Write(&buf, BigEndian, s) |
| 127 exp := []uint8{1, 2, 3, 4} |
| 128 checkResult(t, "Issue478", BigEndian, err, buf.Bytes(), exp) |
| 129 } |
OLD | NEW |