MCPcopy Index your code
hub / github.com/Workiva/go-datastructures / TestSparseBitArraySerialization

Function TestSparseBitArraySerialization

bitarray/encoding_test.go:25–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestSparseBitArraySerialization(t *testing.T) {
26 numItems := uint64(1280)
27 input := newSparseBitArray()
28
29 for i := uint64(0); i < numItems; i++ {
30 if i%3 == 0 {
31 input.SetBit(i)
32 }
33 }
34
35 outBytes, err := input.Serialize()
36 assert.Equal(t, err, nil)
37
38 assert.Equal(t, len(outBytes), 337)
39 assert.True(t, outBytes[0] == 'S')
40 expected := []byte{83, 20, 0, 0, 0, 0, 0, 0, 0, 73}
41 assert.Equal(t, expected, outBytes[:10])
42
43 output := newSparseBitArray()
44 err = output.Deserialize(outBytes)
45 assert.Equal(t, err, nil)
46 assert.True(t, input.Equals(output))
47}
48
49func TestBitArraySerialization(t *testing.T) {
50 numItems := uint64(1280)

Callers

nothing calls this directly

Calls 5

newSparseBitArrayFunction · 0.85
SetBitMethod · 0.65
EqualsMethod · 0.65
SerializeMethod · 0.45
DeserializeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…