(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestReadBitsToByteArray(t *testing.T) { |
| 139 | |
| 140 | // Input: 01010101 01010101 |
| 141 | byteArray := []byte{0x55, 0x55} |
| 142 | reader := NewBitReader(byteArray) |
| 143 | |
| 144 | reader.Reset() |
| 145 | buf, _ := reader.ReadBitsToByteArray(3) |
| 146 | if reflect.DeepEqual([]byte{0x02}, buf) == false { |
| 147 | t.Errorf("buf %#v must equal {0x02}", buf) |
| 148 | } |
| 149 | |
| 150 | reader.Reset() |
| 151 | buf, _ = reader.ReadBitsToByteArray(4) |
| 152 | if reflect.DeepEqual([]byte{0x05}, buf) == false { |
| 153 | t.Errorf("buf %#v must equal {0x05}", buf) |
| 154 | } |
| 155 | |
| 156 | reader.Reset() |
| 157 | buf, _ = reader.ReadBitsToByteArray(8) |
| 158 | if reflect.DeepEqual([]byte{0x55}, buf) == false { |
| 159 | t.Errorf("buf %#v must equal {0x55}", buf) |
| 160 | } |
| 161 | |
| 162 | reader.Reset() |
| 163 | buf, _ = reader.ReadBitsToByteArray(12) |
| 164 | if reflect.DeepEqual([]byte{0x05, 0x55}, buf) == false { |
| 165 | t.Errorf("buf %#v must equal {0x05, 0x55}", buf) |
| 166 | } |
| 167 | |
| 168 | reader.Reset() |
| 169 | buf, _ = reader.ReadBitsToByteArray(16) |
| 170 | if reflect.DeepEqual([]byte{0x55, 0x55}, buf) == false { |
| 171 | t.Errorf("buf %#v must equal {0x55, 0x55}", buf) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func TestReadBytes(t *testing.T) { |
| 176 |
nothing calls this directly
no test coverage detected