MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestBytes

Function TestBytes

libs/bits/bit_array_test.go:146–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestBytes(t *testing.T) {
147 bA := NewBitArray(4)
148 bA.SetIndex(0, true)
149 check := func(bA *BitArray, bz []byte) {
150 if !bytes.Equal(bA.Bytes(), bz) {
151 panic(fmt.Sprintf("Expected %X but got %X", bz, bA.Bytes()))
152 }
153 }
154 check(bA, []byte{0x01})
155 bA.SetIndex(3, true)
156 check(bA, []byte{0x09})
157
158 bA = NewBitArray(9)
159 check(bA, []byte{0x00, 0x00})
160 bA.SetIndex(7, true)
161 check(bA, []byte{0x80, 0x00})
162 bA.SetIndex(8, true)
163 check(bA, []byte{0x80, 0x01})
164
165 bA = NewBitArray(16)
166 check(bA, []byte{0x00, 0x00})
167 bA.SetIndex(7, true)
168 check(bA, []byte{0x80, 0x00})
169 bA.SetIndex(8, true)
170 check(bA, []byte{0x80, 0x01})
171 bA.SetIndex(9, true)
172 check(bA, []byte{0x80, 0x03})
173}
174
175func TestEmptyFull(t *testing.T) {
176 ns := []int{47, 123}

Callers

nothing calls this directly

Calls 4

SetIndexMethod · 0.95
BytesMethod · 0.95
NewBitArrayFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected