Skip to content

Commit

Permalink
add test for Or with COW containers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewhouse committed Oct 16, 2020
1 parent c40b88b commit d5f9722
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions roaringcow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1939,3 +1939,38 @@ func TestCloneCOWContainers(t *testing.T) {

assert.EqualValues(t, rb.ToArray(), newRb1.ToArray())
}

func TestInPlaceCOWContainers(t *testing.T) {
// write bitmap
wb1 := NewBitmap()
wb2 := NewBitmap()

wb1.AddRange(0, 3000)
wb2.AddRange(2000, 5000)

buf1 := &bytes.Buffer{}
buf2 := &bytes.Buffer{}

wb1.WriteTo(buf1)
wb2.WriteTo(buf2)

// read bitmaps
rb1 := NewBitmap()
rb2 := NewBitmap()

rb1.FromBuffer(buf1.Bytes())
rb2.FromBuffer(buf2.Bytes())

assert.True(t, wb1.Equals(rb1))
assert.True(t, wb2.Equals(rb2))

rb1.Or(rb2)

assert.True(t, Or(wb1, wb2).Equals(rb1))
assert.True(t, wb2.Equals(rb2))

rb3 := NewBitmap()
rb3.FromBuffer(buf1.Bytes())

assert.True(t, rb3.Equals(wb1))
}

0 comments on commit d5f9722

Please sign in to comment.