MCPcopy
hub / github.com/RoaringBitmap/roaring / TestSerializationBasic3_042

Function TestSerializationBasic3_042

roaring64/serialization_test.go:149–171  ·  view source on GitHub ↗

roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types

(t *testing.T)

Source from the content-addressed store, hash-verified

147
148// roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types
149func TestSerializationBasic3_042(t *testing.T) {
150 rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000, 10000, 100000, 1000000, maxUint32+10, maxUint32<<10)
151 for i := uint64(maxUint32); i < maxUint32+2*(1<<16); i++ {
152 rb.Add(i)
153 }
154
155 var buf bytes.Buffer
156 _, err := rb.WriteTo(&buf)
157
158 require.NoError(t, err)
159 assert.EqualValues(t, buf.Len(), int(rb.GetSerializedSizeInBytes()))
160 data := buf.Bytes()
161
162 newrb := NewBitmap()
163 _, err = newrb.ReadFrom(&buf)
164
165 require.NoError(t, err)
166 assert.True(t, newrb.Equals(rb))
167
168 newrb2 := NewBitmap()
169 fromUnsafeBytesChecked(t, newrb2, data)
170 assert.True(t, rb.Equals(newrb2))
171}
172
173func TestHoldReference(t *testing.T) {
174 t.Run("Test Hold Reference", func(t *testing.T) {

Callers

nothing calls this directly

Calls 10

ReadFromMethod · 0.95
EqualsMethod · 0.95
fromUnsafeBytesCheckedFunction · 0.85
BitmapOfFunction · 0.70
NewBitmapFunction · 0.70
AddMethod · 0.45
WriteToMethod · 0.45
LenMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…