(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestWriteStructOn64bitArch(t *testing.T) { |
| 142 | arch := device.Big64 |
| 143 | values := encodableStruct{0x12, BytePtr(0xbeefdeaddeadbeef), 0x3456, 0x8888888899999999} |
| 144 | |
| 145 | buf := &bytes.Buffer{} |
| 146 | e := NewEncoder(endian.Writer(buf, arch.GetEndian()), arch) |
| 147 | Write(e, values) |
| 148 | |
| 149 | got := buf.Bytes() |
| 150 | expected := []byte{ |
| 151 | 0x12, // uint8 |
| 152 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before pointer |
| 153 | 0xbe, 0xef, 0xde, 0xad, 0xde, 0xad, 0xbe, 0xef, // pointer |
| 154 | 0x34, 0x56, // int16 |
| 155 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before uint64 |
| 156 | 0x88, 0x88, 0x88, 0x88, |
| 157 | 0x99, 0x99, 0x99, 0x99, |
| 158 | } |
| 159 | |
| 160 | if !bytes.Equal(got, expected) { |
| 161 | t.Errorf("Bytes were not as expected.\nExpected: % x\nGot: % x", expected, got) |
| 162 | } |
| 163 | } |
nothing calls this directly
no test coverage detected