a few tweaks after rebasing 334-rle onto master

This commit is contained in:
Matt Jaffee 2017-06-19 11:19:27 -05:00
parent 4cf56f8b73
commit 057be3703e
3 changed files with 6 additions and 11 deletions

View file

@ -17,7 +17,6 @@ package ctl
import (
"bytes"
"encoding/hex"
"golang.org/x/net/context"
"io"
"io/ioutil"
"math/rand"
@ -25,6 +24,8 @@ import (
"path/filepath"
"strings"
"testing"
"context"
)
func TestCheckCommand_RunCacheFile(t *testing.T) {
@ -84,7 +85,7 @@ func TestCheckCommand_Run(t *testing.T) {
var buf bytes.Buffer
io.Copy(&buf, r)
if err.Error() != "invalid roaring file" {
if !strings.HasPrefix(err.Error(), "invalid roaring file") {
t.Fatalf("expect error: invalid roaring file, actual: '%s'", err)
}
// Todo: need correct roaring file for happy path

View file

@ -1333,9 +1333,9 @@ func (c *container) bitmapContains(v uint32) bool {
return (c.bitmap[v/64] & (1 << uint64(v%64))) != 0
}
// runBinSearch returns the index of the run containing v, and true, when v is contained;
// binSearchRuns returns the index of the run containing v, and true, when v is contained;
// or the index of the next run starting after v, and false, when v is not contained.
func runBinSearch(v uint32, a []interval32) (int, bool) {
func binSearchRuns(v uint32, a []interval32) (int, bool) {
i := sort.Search(len(a),
func(i int) bool { return a[i].last >= v })
if i < len(a) {

View file

@ -223,12 +223,6 @@ func TestBitmapCountRange(t *testing.T) {
t.Fatalf("test #%v count of %v from %v to %v should be %v but got %v", i, test.bitmap, test.start, test.end, test.exp, ret)
}
}
c = container{bitmap: []uint64{0xF0000001, 0xFF000000, 0xFF00000000000000}}
cnt := c.bitmapCountRange(62, 129)
if cnt != 10 {
t.Fatalf("count of %v from 62 to 129 should be 10, but got %v", c.bitmap, cnt)
}
}
func TestIntersectionCountArrayBitmap2(t *testing.T) {
@ -1929,7 +1923,7 @@ func TestRunBinSearch(t *testing.T) {
},
}
for i, test := range tests {
idx, contains := runBinSearch(test.search, test.runs)
idx, contains := binSearchRuns(test.search, test.runs)
if !(test.exp == contains && test.expi == idx) {
t.Fatalf("test #%v expected (%v, %v) but got (%v, %v)", i, test.exp, test.expi, contains, idx)
}