Skip to content

Commit

Permalink
run 1.17 go fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewhouse committed Dec 16, 2021
1 parent fb03177 commit 50df8cb
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 81 deletions.
7 changes: 3 additions & 4 deletions aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package roaring
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"sort"
"testing"
)

func testAggregations(t *testing.T,
Expand Down Expand Up @@ -265,7 +265,6 @@ func TestHeapAggregations(t *testing.T) {
testAggregations(t, nil, HeapOr, HeapXor)
}


type uints []uint32

func (u uints) Len() int { return len(u) }
Expand All @@ -282,9 +281,9 @@ func TestIssue330(t *testing.T) {
{1332290, 1447737, 1549291, 1187244, 1598129, 1579851, 1424171, 1538999, 1445358, 1586739, 1575050, 1437657, 1366343, 1062799, 1421550, 1460317, 1474875, 1060737, 1330773, 1447797, 1348633, 1559437, 1556214, 1187305, 1187234, 1187240, 1464660, 1567794, 1187260, 1260646, 1311938, 1573195, 1318525, 1484524, 1456152, 1087954, 1556007, 1187265, 1460920, 1485316, 1447849, 1447744, 1474001, 1537891, 1478211, 1313292, 1488405, 1187239, 1378814, 1343620, 1500498, 1567809, 1435838, 1506575, 1368282, 1447441, 1598101, 1067076, 1572997, 1598102, 1332697, 1324653, 1561437, 1187290, 1059945, 1187278, 1457187, 1430003, 1450643, 1447436, 1260650, 1473393, 1187247, 1087323, 1324967, 1187291, 1480771, 1472729, 1555881, 1187253, 1456481, 1452672, 1447435, 1378603, 1574771, 1187235, 1417857, 1568706, 1576739, 1534662, 1410189, 1587745, 1473791, 1187308, 1447730, 1328158, 1409164, 1506591, 1500147, 1433961, 1483709, 1187227, 1456479, 1562595, 1314333, 1187281, 1598012, 1415200, 1447791, 1371379, 1598019, 1435836, 1457188, 1457351, 1187248, 1417111, 1187289, 1187252, 1187257, 1316665, 1473464, 1187263, 1447732, 1520371, 1525651, 1598177, 1406947, 1465787, 1524659, 1324213, 1418439, 1575816, 1522696, 1187286, 1497821, 1333179, 1187282, 1335988, 1548952, 1556066, 1314993, 1187276, 1420503, 1187301, 1456468, 1423939, 1598089, 1504357, 1343247, 1437659, 1525768, 1539279, 1307385, 1187275, 1524305, 1332938, 1516498, 1303247, 1304237, 1187238, 1385283, 1595495, 1187300, 1187241, 1061740, 1316383, 1187307, 1062037, 1538693, 1454292, 1447731, 1187272, 1561442, 1187268, 1567150, 1597966, 1447745, 1598178, 1187262, 1464067, 1325394, 1537893, 1332693, 1479200, 1522335, 1589378, 1450573, 1399161, 1421274, 1561501, 1187232, 1187302, 1258469, 1331600, 1447740, 1187242, 1328147, 1264069, 1187294, 1299943, 1598013, 1526975, 1260604, 1487518, 1187229, 1487617, 1354087, 1456595, 1462047, 1561438, 1598363, 1332691, 1424655, 1567105, 1574774, 1598035, 1526981, 1384038, 1475987, 1343587, 1447437, 1454912, 1382215, 1447739, 1456512, 1447779, 1187283, 1440988, 1187293, 1187298, 1574754, 1354772, 1598018, 1447429, 1598181, 1447738, 1598273, 1312197, 1574752, 1572995, 1526127, 1473908, 1437660, 1447743, 1362262, 1456513, 1539280, 1348625, 1415878, 1332694, 1471020, 1432462, 1058088, 1526710, 1371788, 1187288, 1537984, 1316874, 1187270, 1333565, 1187292, 1447796, 1187311, 1187237, 1187231, 1574755, 1553822, 1522019, 1447418, 1187269, 1332692, 1447735, 1529638, 1468154, 1328031, 1447733, 1447402, 1593884, 1332696, 1560622, 1564819, 1538967, 1315756, 1328338, 1598113, 1324212, 1449895, 1567793, 1260629, 1430010, 1187266, 1187256, 1312754, 1449417, 1595494, 1529054, 1187261, 1187306, 1526976, 1425490, 1366922, 1527390, 1187299, 1561510, 1319222, 1187250, 1057262, 1457999, 1332937, 1187243, 1556213, 1278602, 1546839, 1187296, 1548950, 1580141, 1187303, 1187255, 1525650, 1572998, 1576740, 1187267, 1464664, 1440427, 1456467, 1187271, 1187258, 1585428, 1548760, 1342254, 1447793, 1406348, 1500177, 1260644, 1416954, 1323722, 1412713, 1187280, 1187310, 1538015, 1537285, 1187285, 1456482, 1260611, 1490508, 1187274, 1585641, 1416648, 1484655, 1421520, 1347485, 1525652, 1568987, 1526974, 1314375, 1187246, 1455623, 1488117, 1445025, 1447401, 1478237, 1561440, 1187287, 1561434, 1509337, 1451859, 1599630, 1348639, 1449436, 1361844, 1464661, 1263064, 1526973, 1187279, 1562080, 1354770, 1454521, 1520719, 1478236, 1526972, 1423948, 1334866, 1325026, 1438275, 1422582, 1437646, 1315530, 1458323, 1447795, 1528218, 1187254, 1598056, 1417853, 1423514, 1187297, 1187245, 1187264, 1524662, 1187251, 1524660, 1328113, 1187304, 1374767, 1474057, 1187284, 1331601, 1598180, 1062814, 1488818, 1187309, 1087494, 1063499, 1458325, 1187295, 1432336, 1260001, 1597982, 1537147, 1445355, 1595491, 1396111, 1546848, 1474048, 1495251, 1447734, 1464071, 1526978, 1187236, 1526977, 1566267, 1187277, 1421549, 1430015, 1316024, 1332695, 1561433, 1435837, 1087250, 1574753, 1476183, 1325395, 1561432, 1447736, 1500181, 1424164, 1456483, 1187228, 1573384, 1273769, 1598085, 1437661, 1306415, 1407257, 1187249, 1338215, 1458047, 1520791, 1447741, 1537263, 1472490, 1524661, 1061729, 1187273, 1417861, 1470196, 1485881, 1260595, 1538846, 1568762, 1315170, 1500469, 1372455, 1558140, 1425202, 1432702, 1472734, 1187230, 1187312, 1598191, 1569680, 1187233, 1263091, 1447417, 1504429, 1430016, 1435839, 1458324, 1546845, 1575027, 1187259, 1464610},
{1578810, 1166701, 1335901, 1063397, 1578812, 1526471, 1166702, 1067008, 1412862, 1059750, 1060729, 1166812, 1493768, 1335772, 1336194, 1166772, 1465775, 1166704, 1355314, 1314138, 1060727, 1388260, 1465786, 1565378, 1522096, 1312490, 1319284, 1418573, 1319169, 1060730, 1307995, 1465780, 1060728, 1404061, 1407842, 1326256, 1578754, 1410577, 1060732, 1461338, 1264209, 1166705, 1581273, 1414196, 1565398, 1355106, 1060731, 1412641, 1306618, 1060726, 1356302, 1310896, 1457885, 1497721, 1166709, 1067009, 1310812, 1578800, 1422203, 1484409, 1485278, 1322057, 1369956, 1311089, 1576614, 1355711, 1355798, 1564832, 1304166, 1166773, 1319071, 1578805, 1575869, 1403066},
}

bitmaps := []*Bitmap{}

for _, v := range values {
bitmap := BitmapOf(v...)
bitmap.RunOptimize()
Expand Down
2 changes: 1 addition & 1 deletion benchmark_memory_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.13
// +build go1.13

package roaring
Expand Down Expand Up @@ -72,4 +73,3 @@ func BenchmarkSizeRoaring(b *testing.B) {
}
b.ReportMetric(float64(s1.GetSerializedSizeInBytes()+s2.GetSerializedSizeInBytes())/(1024.0*1024), "RoaringSizeInMB")
}

1 change: 0 additions & 1 deletion bitmapcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ func (bc *bitmapContainer) getCardinality() int {
return bc.cardinality
}


func (bc *bitmapContainer) isEmpty() bool {
return bc.cardinality == 0
}
Expand Down
2 changes: 2 additions & 0 deletions clz.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build go1.9
// +build go1.9

// "go1.9", from Go version 1.9 onward
// See https://golang.org/pkg/go/build/#hdr-Build_Constraints

Expand Down
1 change: 1 addition & 0 deletions clz_compat.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.9
// +build !go1.9

package roaring
Expand Down
2 changes: 2 additions & 0 deletions ctz.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build go1.9
// +build go1.9

// "go1.9", from Go version 1.9 onward
// See https://golang.org/pkg/go/build/#hdr-Build_Constraints

Expand Down
1 change: 1 addition & 0 deletions ctz_compat.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.9
// +build !go1.9

package roaring
Expand Down
2 changes: 2 additions & 0 deletions popcnt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build go1.9
// +build go1.9

// "go1.9", from Go version 1.9 onward
// See https://golang.org/pkg/go/build/#hdr-Build_Constraints

Expand Down
1 change: 1 addition & 0 deletions popcnt_asm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build amd64 && !appengine && !go1.9
// +build amd64,!appengine,!go1.9

package roaring
Expand Down
1 change: 1 addition & 0 deletions popcnt_compat.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.9
// +build !go1.9

package roaring
Expand Down
1 change: 1 addition & 0 deletions popcnt_generic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !amd64 || appengine || go1.9
// +build !amd64 appengine go1.9

package roaring
Expand Down
1 change: 1 addition & 0 deletions popcnt_slices_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build amd64 && !appengine && !go1.9
// +build amd64,!appengine,!go1.9

// This file tests the popcnt functions
Expand Down
63 changes: 31 additions & 32 deletions roaring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"
"testing"

"github.com/stretchr/testify/assert"
"github.com/bits-and-blooms/bitset"
"github.com/stretchr/testify/assert"
)

func TestReverseIteratorCount(t *testing.T) {
Expand Down Expand Up @@ -68,26 +68,25 @@ func TestRoaringRangeEnd(t *testing.T) {
}

func TestMaxPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
}
}()
defer func() {
if r := recover(); r != nil {
}
}()
bm := New()
bm.Maximum()
t.Errorf("The code did not panic")
t.Errorf("The code did not panic")
}

func TestMinPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
}
}()
defer func() {
if r := recover(); r != nil {
}
}()
bm := New()
bm.Minimum()
t.Errorf("The code did not panic")
t.Errorf("The code did not panic")
}


func TestFirstLast(t *testing.T) {
bm := New()
bm.AddInt(2)
Expand Down Expand Up @@ -183,45 +182,45 @@ func testAddOffset(t *testing.T, arr []uint32, offset int64) {

func TestRoaringBitmapAddOffset(t *testing.T) {
type testCase struct {
arr []uint32
offset int64
arr []uint32
offset int64
}
cases := []testCase{
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: 25000,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: 25000,
},
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -25000,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -25000,
},
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -83097,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -83097,
},
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: MaxUint32,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: MaxUint32,
},
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -MaxUint32,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: -MaxUint32,
},
{
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: 0,
arr: []uint32{5580, 33722, 44031, 57276, 83097},
offset: 0,
},
{
arr: []uint32{0},
offset: 100,
arr: []uint32{0},
offset: 100,
},
{
arr: []uint32{0},
offset: 0xffff0000,
arr: []uint32{0},
offset: 0xffff0000,
},
{
arr: []uint32{0},
offset: 0xffff0001,
arr: []uint32{0},
offset: 0xffff0001,
},
}

Expand Down
8 changes: 4 additions & 4 deletions roaringarray.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"encoding/binary"
"fmt"
"io"
"github.com/RoaringBitmap/roaring/internal"
"io"
)

type container interface {
Expand Down Expand Up @@ -554,9 +554,9 @@ func (ra *roaringArray) toBytes() ([]byte, error) {
}

func (ra *roaringArray) readFrom(stream internal.ByteInput, cookieHeader ...byte) (int64, error) {
var cookie uint32
var cookie uint32
var err error
if len(cookieHeader) > 0 && len(cookieHeader) != 4 {
if len(cookieHeader) > 0 && len(cookieHeader) != 4 {
return int64(len(cookieHeader)), fmt.Errorf("error in roaringArray.readFrom: could not read initial cookie: incorrect size of cookie header")
}
if len(cookieHeader) == 4 {
Expand Down Expand Up @@ -648,7 +648,7 @@ func (ra *roaringArray) readFrom(stream internal.ByteInput, cookieHeader ...byte
}

nb := runContainer16{
iv: byteSliceAsInterval16Slice(buf),
iv: byteSliceAsInterval16Slice(buf),
}

ra.containers[i] = &nb
Expand Down
2 changes: 1 addition & 1 deletion roaringcow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strconv"
"testing"

"github.com/stretchr/testify/assert"
"github.com/bits-and-blooms/bitset"
"github.com/stretchr/testify/assert"
)

func TestCloneOfCOW(t *testing.T) {
Expand Down
25 changes: 13 additions & 12 deletions serialization_frozen_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (386 && !appengine) || (amd64 && !appengine) || (arm && !appengine) || (arm64 && !appengine) || (ppc64le && !appengine) || (mipsle && !appengine) || (mips64le && !appengine) || (mips64p32le && !appengine) || (wasm && !appengine)
// +build 386,!appengine amd64,!appengine arm,!appengine arm64,!appengine ppc64le,!appengine mipsle,!appengine mips64le,!appengine mips64p32le,!appengine wasm,!appengine

package roaring
Expand All @@ -10,27 +11,27 @@ import (
)

func TestFrozenFormat(t *testing.T) {
tests := [...]struct{
tests := [...]struct {
name, frozenPath, portablePath string
}{
{
name: "bitmaps only",
frozenPath: "testfrozendata/bitmaps_only.frozen",
name: "bitmaps only",
frozenPath: "testfrozendata/bitmaps_only.frozen",
portablePath: "testfrozendata/bitmaps_only.portable",
},
{
name: "arrays only",
frozenPath: "testfrozendata/arrays_only.frozen",
name: "arrays only",
frozenPath: "testfrozendata/arrays_only.frozen",
portablePath: "testfrozendata/arrays_only.portable",
},
{
name: "runs only",
frozenPath: "testfrozendata/runs_only.frozen",
name: "runs only",
frozenPath: "testfrozendata/runs_only.frozen",
portablePath: "testfrozendata/runs_only.portable",
},
{
name: "mixed",
frozenPath: "testfrozendata/mixed.frozen",
name: "mixed",
frozenPath: "testfrozendata/mixed.frozen",
portablePath: "testfrozendata/mixed.portable",
},
}
Expand All @@ -41,7 +42,7 @@ func TestFrozenFormat(t *testing.T) {
// 2. In a buggy scenario one of the tests may write into the buffer and cause
// a race condition, making it harder to figure out why the tests fail.
name, fpath, ppath := test.name, test.frozenPath, test.portablePath
t.Run("view " + name, func(t *testing.T) {
t.Run("view "+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
Expand All @@ -65,7 +66,7 @@ func TestFrozenFormat(t *testing.T) {
t.Fatalf("bitmaps for %s and %s differ", fpath, ppath)
}
})
t.Run("freeze " + name, func(t *testing.T) {
t.Run("freeze "+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
Expand Down Expand Up @@ -94,7 +95,7 @@ func TestFrozenFormat(t *testing.T) {
t.Fatalf("frozen file for %s and %s differ", fpath, ppath)
}
})
t.Run("freeze with writer" + name, func(t *testing.T) {
t.Run("freeze with writer"+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
Expand Down
1 change: 1 addition & 0 deletions serialization_generic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (!amd64 && !386 && !arm && !arm64 && !ppc64le && !mipsle && !mips64le && !mips64p32le && !wasm) || appengine
// +build !amd64,!386,!arm,!arm64,!ppc64le,!mipsle,!mips64le,!mips64p32le,!wasm appengine

package roaring
Expand Down
Loading

0 comments on commit 50df8cb

Please sign in to comment.