(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestReadStruct(t *testing.T) { |
| 105 | type S struct { |
| 106 | A uint8 |
| 107 | B uint16 |
| 108 | C uint32 |
| 109 | D uint64 |
| 110 | } |
| 111 | expected := S{0x01, 0x0203, 0x04050607, 0x08090A0B0C0D0E0F} |
| 112 | raw := []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F} |
| 113 | var output S |
| 114 | buffer := packetBuffer{bytes: raw} |
| 115 | err := buffer.read(&output) |
| 116 | assert.NoError(t, err) |
| 117 | assert.Equal(t, expected, output) |
| 118 | } |
| 119 | |
| 120 | func TestReadSlice(t *testing.T) { |
| 121 | expected := []uint16{0x0102, 0x0304, 0x0506, 0x0708} |
nothing calls this directly
no test coverage detected
searching dependent graphs…