From 057be3703e49804e0ae4584b9fc762e2aa1be7e2 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Mon, 19 Jun 2017 11:19:27 -0500 Subject: [PATCH] a few tweaks after rebasing 334-rle onto master --- ctl/check_test.go | 5 +++-- roaring/roaring.go | 4 ++-- roaring/roaring_internal_test.go | 8 +------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ctl/check_test.go b/ctl/check_test.go index af223c18d..33a19feb3 100644 --- a/ctl/check_test.go +++ b/ctl/check_test.go @@ -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 diff --git a/roaring/roaring.go b/roaring/roaring.go index 958a36d00..80dbfa79a 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -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) { diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index 0c499a795..291036ef8 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -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) }