MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / TestBitmapFromBufferCOW

Function TestBitmapFromBufferCOW

serialization_test.go:611–643  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

609}
610
611func TestBitmapFromBufferCOW(t *testing.T) {
612 rbbogus := NewBitmap()
613 rbbogus.Add(100)
614 rbbogus.Add(100000)
615 rb1 := NewBitmap()
616 rb1.Add(1)
617 buf1 := &bytes.Buffer{}
618 rb1.WriteTo(buf1)
619 rb2 := NewBitmap()
620 rb2.Add(1000000)
621 buf2 := &bytes.Buffer{}
622 rb2.WriteTo(buf2)
623 newRb1 := NewBitmap()
624 newRb1.FromBuffer(buf1.Bytes())
625 newRb2 := NewBitmap()
626 newRb2.FromBuffer(buf2.Bytes())
627 rbor1 := Or(newRb1, newRb2)
628 rbor2 := rbor1
629 rbor3 := Or(newRb1, newRb2)
630 rbor1.CloneCopyOnWriteContainers()
631 rbor2.CloneCopyOnWriteContainers()
632 rbor3.CloneCopyOnWriteContainers()
633 buf1.Reset()
634 buf2.Reset()
635 rbbogus.WriteTo(buf1)
636 rbbogus.WriteTo(buf2)
637 rbexpected := NewBitmap()
638 rbexpected.Add(1)
639 rbexpected.Add(1000000)
640
641 assert.True(t, rbexpected.Equals(rbor2))
642 assert.True(t, rbexpected.Equals(rbor3))
643}
644
645func TestHoldReference(t *testing.T) {
646 t.Run("Test Hold Reference", func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AddMethod · 0.95
WriteToMethod · 0.95
FromBufferMethod · 0.95
EqualsMethod · 0.95
NewBitmapFunction · 0.70
OrFunction · 0.70
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…