(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func TestWriteStructOn32bitArch(t *testing.T) { |
| 80 | arch := device.Big32 |
| 81 | values := encodableStruct{0x12, BytePtr(0xdeadbeef), 0x3456, 0x8888888899999999} |
| 82 | |
| 83 | buf := &bytes.Buffer{} |
| 84 | e := NewEncoder(endian.Writer(buf, arch.GetEndian()), arch) |
| 85 | Write(e, values) |
| 86 | |
| 87 | got := buf.Bytes() |
| 88 | expected := []byte{ |
| 89 | 0x12, // uint8 |
| 90 | 0x00, 0x00, 0x00, // padding before pointer |
| 91 | 0xde, 0xad, 0xbe, 0xef, // pointer |
| 92 | 0x34, 0x56, // int16 |
| 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before uint64 |
| 94 | 0x88, 0x88, 0x88, 0x88, |
| 95 | 0x99, 0x99, 0x99, 0x99, |
| 96 | } |
| 97 | |
| 98 | if !bytes.Equal(got, expected) { |
| 99 | t.Errorf("Bytes were not as expected.\nExpected: % x\nGot: % x", expected, got) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func TestWriteOn64bitArch(t *testing.T) { |
| 104 | arch := device.Big64 |
nothing calls this directly
no test coverage detected