From cf900e03f9c1ea95beb50fa683c3ed4518891e0c Mon Sep 17 00:00:00 2001 From: Ashley Svetlik Date: Wed, 19 Jun 2019 13:54:39 -0500 Subject: [PATCH] changed testLoop/testValues and rearranged for loop --- roaring/roaring_internal_test.go | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index d2affe3a1..258ed0add 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -3259,7 +3259,7 @@ func runContainerFunc(f interface{}, c ...*Container) *Container { } func TestUnmarshalRoaringWithNoErrors(t *testing.T) { - testValues := []struct { + testCases := []struct { hexString string count uint64 expectedBits string @@ -3281,26 +3281,21 @@ func TestUnmarshalRoaringWithNoErrors(t *testing.T) { }, } - for _, testLoop := range testValues { - if testLoop.hexString != "testdata/bitmapcontainer.roaringbitmap" { - testContainer, _ := hex.DecodeString(testLoop.hexString) + for _, testCase := range testCases { + if testCase.hexString != "testdata/bitmapcontainer.roaringbitmap" { + testContainer, _ := hex.DecodeString(testCase.hexString) + } else { + testContainer, _ := ioutil.ReadFile(testCase.hexString) + } bm := NewBitmap() er:= bm.UnmarshalBinary(testContainer) if er != nil { t.Fatalf("UnmarshalOfficialRoaring %s", er) } - if bm.Count() != testLoop.count { - t.Fatalf("unexpected bitmap %v expected bits %s", bm.Slice(), testLoop.expectedBits) - } - } else { - testContainer, _ := ioutil.ReadFile(testLoop.hexString) - bm := NewBitmap() - er := bm.UnmarshalBinary(testContainer) - if er != nil { - t.Fatalf("UnmarshalOfficialRoaring %s", er) - } - if bm.Count() != 10000 { - t.Fatalf("expecting %s got %d", testLoop.expectedBits, bm.Count()) + if bm.Count() != testCase.count && testCase.hexString != "testdata/bitmapcontainer.roaringbitmap" { + t.Fatalf("unexpected bitmap %v expected bits %s", bm.Slice(), testCase.expectedBits) + } else if bm.Count() != testCase.count { + t.Fatalf("expecting %s got %d", testCase.expectedBits, bm.Count()) } } }