mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 20:07:51 +00:00
Add array-bitmap conversion test
This commit is contained in:
parent
2e540d275c
commit
a51f7d66bb
1 changed files with 30 additions and 1 deletions
|
|
@ -731,6 +731,35 @@ func TestBitmapSetRange(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestArrayToBitmap(t *testing.T) {
|
||||
a := &container{ctype: ARRAY}
|
||||
tests := []struct {
|
||||
array []uint32
|
||||
exp []uint64
|
||||
}{
|
||||
{
|
||||
array: []uint32{0, 1, 2, 3},
|
||||
exp: []uint64{0xF},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
exp := make([]uint64, bitmapN)
|
||||
for i, v := range test.exp {
|
||||
exp[i] = v
|
||||
}
|
||||
|
||||
a.array = test.array
|
||||
a.arrayToBitmap()
|
||||
if !reflect.DeepEqual(a.bitmap, exp) {
|
||||
t.Fatalf("test #%v expected %v, but got %v", i, exp, a.bitmap)
|
||||
}
|
||||
if a.ctype != BITMAP {
|
||||
t.Fatalf("test #%v expected type %v but got %v", i, BITMAP, a.ctype)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunToBitmap(t *testing.T) {
|
||||
a := &container{}
|
||||
tests := []struct {
|
||||
|
|
@ -764,7 +793,7 @@ func TestRunToBitmap(t *testing.T) {
|
|||
a.runs = test.runs
|
||||
a.runToBitmap()
|
||||
if !reflect.DeepEqual(a.bitmap, exp) {
|
||||
t.Logf("test #%v expected %v, but got (%d) %v", i, exp, a.bitmap)
|
||||
t.Fatalf("test #%v expected %v, but got %v", i, exp, a.bitmap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue