roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types
(t *testing.T)
| 250 | |
| 251 | // roaringarray.writeTo and .readFrom should serialize and unserialize when containing all 3 container types |
| 252 | func 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 | |
| 291 | func TestGobcoding043(t *testing.T) { |
| 292 | rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000) |
nothing calls this directly
no test coverage detected
searching dependent graphs…