(t *testing.T)
| 128 | } |
| 129 | |
| 130 | func TestReadComplex(t *testing.T) { |
| 131 | raw := []byte{ |
| 132 | 0xf8, |
| 133 | 0x12, 0x34, |
| 134 | 0x56, 0x78, 0x9A, 0xBC, |
| 135 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 136 | 0x12, |
| 137 | 0x11, 0x22, 0x33, 0x44, 9, |
| 138 | 0x00, 0x00, 0x00, 0x01, 1, 0x00, 0x00, 0x00, 0x02, 5, |
| 139 | } |
| 140 | |
| 141 | type Subtree struct { |
| 142 | SubA uint32 |
| 143 | SubB uint8 |
| 144 | } |
| 145 | |
| 146 | type Tree struct { |
| 147 | A uint8 |
| 148 | B uint16 |
| 149 | C uint32 |
| 150 | D uint64 |
| 151 | _ uint8 |
| 152 | F Subtree |
| 153 | G []Subtree |
| 154 | } |
| 155 | |
| 156 | expected := Tree{ |
| 157 | 0xf8, |
| 158 | 0x1234, |
| 159 | 0x56789ABC, |
| 160 | 0x0102030405060708, |
| 161 | 0x00, |
| 162 | Subtree{0x11223344, 9}, |
| 163 | []Subtree{{0x01, 1}, {0x02, 5}}, |
| 164 | } |
| 165 | |
| 166 | var output Tree |
| 167 | |
| 168 | buffer := packetBuffer{bytes: raw} |
| 169 | err := buffer.read(&output) |
| 170 | assert.NoError(t, err) |
| 171 | assert.Equal(t, expected, output) |
| 172 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…