Upstream kelindar/bitmap state of the touched files before 7c356f442d
This commit is contained in:
1 parent
666c48ccf8
commit
58b05bdfdd
4 files changed
+12
-139
No files matched your search
@@ -130,25 +130,6 @@ func BenchmarkMany(b *testing.B) {
|
||||
run(b, "and4-batch", func(index Bitmap) {
|
||||
index.And(other, other, other, other)
|
||||
})
|
||||
|
||||
run(b, "or4-batch", func(index Bitmap) {
|
||||
index.Or(other, other, other, other)
|
||||
})
|
||||
|
||||
run(b, "xor4-batch", func(index Bitmap) {
|
||||
index.Xor(other, other, other, other)
|
||||
})
|
||||
|
||||
shorter := make(Bitmap, 1000000/64/2)
|
||||
shorter.Set(1000000 / 2)
|
||||
|
||||
run(b, "or4-batch-ragged", func(index Bitmap) {
|
||||
index.Or(other, other, shorter, other)
|
||||
})
|
||||
|
||||
run(b, "xor4-batch-ragged", func(index Bitmap) {
|
||||
index.Xor(other, other, shorter, other)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSetRemove(t *testing.T) {
|
||||
@@ -648,49 +629,3 @@ func testTruthTables(t *testing.T) {
|
||||
assert.Equal(t, 0b0110, int(a[0]))
|
||||
}
|
||||
}
|
||||
|
||||
func TestOr_ExtraDifferentBitmapSizes(t *testing.T) {
|
||||
// Ragged inputs: every set bit must survive regardless of which is longest.
|
||||
var dst Bitmap
|
||||
dst.Set(1) // word 0
|
||||
dst.Set(70) // word 1
|
||||
|
||||
var other Bitmap
|
||||
other.Set(3) // word 0
|
||||
other.Set(200) // word 3, beyond every extra bitmap
|
||||
|
||||
var short Bitmap
|
||||
short.Set(5) // word 0 only
|
||||
|
||||
var mid Bitmap
|
||||
mid.Set(130) // word 2
|
||||
|
||||
dst.Or(other, short, mid)
|
||||
|
||||
want := []uint32{1, 70, 3, 200, 5, 130}
|
||||
for _, v := range want {
|
||||
assert.True(t, dst.Contains(v), "missing bit "+strconv.Itoa(int(v)))
|
||||
}
|
||||
assert.Equal(t, len(want), dst.Count())
|
||||
}
|
||||
|
||||
func TestXor_ExtraDifferentBitmapSizes(t *testing.T) {
|
||||
var dst Bitmap
|
||||
dst.Set(1)
|
||||
dst.Set(200) // shared with other, must cancel out
|
||||
|
||||
var other Bitmap
|
||||
other.Set(200) // cancels dst's bit 200
|
||||
other.Set(201) // survives, beyond every extra bitmap
|
||||
|
||||
var short Bitmap
|
||||
short.Set(5)
|
||||
|
||||
dst.Xor(other, short)
|
||||
|
||||
assert.True(t, dst.Contains(1))
|
||||
assert.False(t, dst.Contains(200), "bit 200 should cancel")
|
||||
assert.True(t, dst.Contains(201), "bit 201 from longer source must survive")
|
||||
assert.True(t, dst.Contains(5))
|
||||
assert.Equal(t, 3, dst.Count())
|
||||
}
|
||||
Reference in new issue
Block a user