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

Function TestSerializationBasic3_042

serialization_test.go:252–289  ·  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

250
251// roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types
252func TestSerializationBasic3_042(t *testing.T) {
253 rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000, 10000, 100000, 1000000)
254 for i := 5000000; i < 5000000+2*(1<<16); i++ {
255 rb.AddInt(i)
256 }
257
258 // confirm all three types present
259 var bc, ac, rc bool
260 for _, v := range rb.highlowcontainer.containers {
261 switch cn := v.(type) {
262 case *bitmapContainer:
263 bc = true
264 case *arrayContainer:
265 ac = true
266 case *runContainer16:
267 rc = true
268 default:
269 t.Fatalf("Unrecognized container implementation: %T", cn)
270 }
271 }
272
273 assert.True(t, bc, "no bitmapContainer found, change your test input so we test all three!")
274 assert.True(t, ac, "no arrayContainer found, change your test input so we test all three!")
275 assert.True(t, rc, "no runContainer16 found, change your test input so we test all three!")
276
277 var buf bytes.Buffer
278 _, err := rb.WriteTo(&buf)
279
280 require.NoError(t, err)
281 assert.EqualValues(t, buf.Len(), rb.GetSerializedSizeInBytes())
282
283 newrb := NewBitmap()
284 _, err = newrb.ReadFrom(&buf)
285
286 require.NoError(t, err)
287 assert.Equal(t, rb.GetCardinality(), newrb.GetCardinality())
288 assert.True(t, newrb.Equals(rb))
289}
290
291func TestGobcoding043(t *testing.T) {
292 rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)

Callers

nothing calls this directly

Calls 9

ReadFromMethod · 0.95
GetCardinalityMethod · 0.95
EqualsMethod · 0.95
BitmapOfFunction · 0.70
NewBitmapFunction · 0.70
AddIntMethod · 0.45
WriteToMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…