mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
switched naive_test.go to table driven tests
This commit is contained in:
parent
7ba9e18a51
commit
368bb46f45
3 changed files with 329 additions and 175 deletions
|
|
@ -20,58 +20,92 @@ import (
|
|||
)
|
||||
|
||||
func TestSortSlice(t *testing.T) {
|
||||
a := []uint64{1, 3, 2, 8, 5, 21, 13}
|
||||
sortSlice(a)
|
||||
if !reflect.DeepEqual(a, []uint64{1, 2, 3, 5, 8, 13, 21}) {
|
||||
t.Fatalf("unexpected sorting: %v", a)
|
||||
tests := []struct{ a, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{1, 3, 2, 8, 5, 21, 13},
|
||||
expected: []uint64{1, 2, 3, 5, 8, 13, 21},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sortSlice(test.a)
|
||||
if !reflect.DeepEqual(test.a, test.expected) {
|
||||
t.Fatalf("unexpected sorting: %v", test.a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveSliceDuplicates(t *testing.T) {
|
||||
a := []uint64{2, 3, 2, 1, 2, 5, 8, 5, 13, 3, 2, 5, 144}
|
||||
a = removeSliceDuplicates(a)
|
||||
|
||||
if !reflect.DeepEqual(a, []uint64{1, 2, 3, 5, 8, 13, 144}) {
|
||||
t.Fatalf("unexpected values: %v", a)
|
||||
tests := []struct{ a, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{2, 3, 2, 1, 2, 5, 8, 5, 13, 3, 2, 5, 144},
|
||||
expected: []uint64{1, 2, 3, 5, 8, 13, 144},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 3, 2, 1, 2, 5, 8, 5, 13, 3, 2, 5, 144, 21, 8, 3, 3, 5, 5, 1, 34, 21, 21},
|
||||
expected: []uint64{1, 2, 3, 5, 8, 13, 21, 34, 144},
|
||||
},
|
||||
}
|
||||
|
||||
a = append(a, 21, 8, 3, 3, 5, 5, 1, 34, 21, 21)
|
||||
a = removeSliceDuplicates(a)
|
||||
|
||||
if !reflect.DeepEqual(a, []uint64{1, 2, 3, 5, 8, 13, 21, 34, 144}) {
|
||||
t.Fatalf("unexpected values: %v", a)
|
||||
for _, test := range tests {
|
||||
got := removeSliceDuplicates(test.a)
|
||||
if !reflect.DeepEqual(got, test.expected) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntersectSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
c := intersectSlice(a, b)
|
||||
tests := []struct{ a, b, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{1, 5, 9},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{1, 5, 9},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{1, 5, 9},
|
||||
expected: []uint64{1, 5, 9},
|
||||
},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c, []uint64{1, 5, 9}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(c, intersectSlice(b, a)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(c, intersectSlice(c, a)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := intersectSlice(test.a, test.b)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnionSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
c := unionSlice(a, b)
|
||||
tests := []struct{ a, b, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{1, 2, 4, 5, 9, 12, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{1, 2, 4, 5, 9, 12, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{1, 5, 9},
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c, []uint64{1, 2, 4, 5, 9, 12, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(c, unionSlice(b, a)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(c, unionSlice(c, a)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := unionSlice(test.a, test.b)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,55 +125,93 @@ func TestMaxInSlice(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDifferenceSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
|
||||
c := differenceSlice(a, b)
|
||||
if !reflect.DeepEqual(c, []uint64{4, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
tests := []struct{ a, b, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{4, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{2, 12},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64(nil),
|
||||
},
|
||||
}
|
||||
|
||||
c = differenceSlice(b, a)
|
||||
if !reflect.DeepEqual(c, []uint64{2, 12}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
|
||||
c = differenceSlice(a, a)
|
||||
if !reflect.DeepEqual(c, []uint64(nil)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := differenceSlice(test.a, test.b)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestXorSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
c := xorSlice(a, b)
|
||||
tests := []struct{ a, b, expected []uint64 }{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{2, 4, 12, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{2, 4, 12, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 4, 12, 13, 24},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{1, 2, 5, 9, 12},
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 4, 12, 13, 24},
|
||||
b: []uint64{1, 2, 5, 9, 12},
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c, []uint64{2, 4, 12, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(c, xorSlice(b, a)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(xorSlice(c, a), []uint64{1, 2, 5, 9, 12}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if !reflect.DeepEqual(xorSlice(c, b), []uint64{1, 4, 5, 9, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := xorSlice(test.a, test.b)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestShiftSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
|
||||
c := shiftSlice(a, 12)
|
||||
if !reflect.DeepEqual(c, []uint64{13, 16, 17, 21, 25, 36}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
shift int
|
||||
expected []uint64
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
shift: 12,
|
||||
expected: []uint64{13, 16, 17, 21, 25, 36},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
shift: 0,
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
shift: 1,
|
||||
expected: []uint64{2, 5, 6, 10, 14, 25},
|
||||
},
|
||||
}
|
||||
|
||||
c = shiftSlice(a, 0)
|
||||
if !reflect.DeepEqual(c, []uint64{1, 4, 5, 9, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := shiftSlice(test.a, test.shift)
|
||||
|
||||
if !reflect.DeepEqual(got, test.expected) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,138 +240,220 @@ func TestForEachInRangeSlice(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContainedInSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
|
||||
c := uint64(4)
|
||||
idx, found := containedInSlice(a, c)
|
||||
if !found {
|
||||
t.Fatalf("%v should be in %v", c, a)
|
||||
}
|
||||
if a[idx] != c {
|
||||
t.Fatalf("%v is not at position %v", c, idx)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
c uint64
|
||||
index int
|
||||
found bool
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
c: uint64(4),
|
||||
index: 1,
|
||||
found: true,
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
c: uint64(12),
|
||||
index: -1,
|
||||
found: false,
|
||||
},
|
||||
}
|
||||
|
||||
c = uint64(12)
|
||||
idx, found = containedInSlice(a, c)
|
||||
if found {
|
||||
t.Fatalf("%v should not be in %v", c, a)
|
||||
}
|
||||
if idx != -1 {
|
||||
t.Fatalf("expected %v, got %v", -1, idx)
|
||||
for _, test := range tests {
|
||||
idx, found := containedInSlice(test.a, test.c)
|
||||
if found != test.found {
|
||||
t.Fatalf("expected value of found: %v, got %v", test.found, found)
|
||||
}
|
||||
if idx != test.index {
|
||||
t.Fatalf("expected index %v, got %v", test.index, idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddNToSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
|
||||
c, changed := addNToSlice(a, b...)
|
||||
if !reflect.DeepEqual(c, []uint64{1, 2, 4, 5, 9, 12, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
if changed != 2 {
|
||||
t.Fatalf("changes expected %v, got %v", 2, changed)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
b []uint64
|
||||
expected []uint64
|
||||
changed int
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{1, 2, 4, 5, 9, 12, 13, 24},
|
||||
changed: 2,
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{1, 2, 4, 5, 9, 12, 13, 24},
|
||||
changed: 3,
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
changed: 0,
|
||||
},
|
||||
}
|
||||
|
||||
c, changed = addNToSlice(b, a...)
|
||||
if !reflect.DeepEqual(c, []uint64{1, 2, 4, 5, 9, 12, 13, 24}) {
|
||||
t.Fatalf("%v and %v should be the same", c, a)
|
||||
}
|
||||
if changed != 3 {
|
||||
t.Fatalf("changes expected %v, got %v", 3, changed)
|
||||
}
|
||||
|
||||
c, changed = addNToSlice(a, a...)
|
||||
if !reflect.DeepEqual(c, []uint64{1, 4, 5, 9, 13, 24}) {
|
||||
t.Fatalf("%v and %v should be the same", c, a)
|
||||
}
|
||||
if changed != 0 {
|
||||
t.Fatalf("changes expected %v, got %v", 0, changed)
|
||||
for _, test := range tests {
|
||||
got, changed := addNToSlice(test.a, test.b...)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected slices %v, got %v", test.expected, got)
|
||||
}
|
||||
if changed != test.changed {
|
||||
t.Fatalf("expected changed %v, got %v", test.changed, changed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveNFromSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
b := []uint64{2, 1, 9, 5, 12}
|
||||
|
||||
c, changed := removeNFromSlice(a, b...)
|
||||
if !reflect.DeepEqual(c, []uint64{4, 13, 24}) {
|
||||
t.Fatalf("%v and %v should be the same", c, []uint64{4, 13, 24})
|
||||
}
|
||||
if changed != 3 {
|
||||
t.Fatalf("%v changes expected, got %v", 3, changed)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
b []uint64
|
||||
expected []uint64
|
||||
changed int
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{2, 1, 9, 5, 12},
|
||||
expected: []uint64{4, 13, 24},
|
||||
changed: 3,
|
||||
},
|
||||
{
|
||||
a: []uint64{2, 1, 9, 5, 12},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64{2, 12},
|
||||
changed: 3,
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
b: []uint64{1, 4, 9, 5, 24, 13},
|
||||
expected: []uint64(nil),
|
||||
changed: 6,
|
||||
},
|
||||
}
|
||||
|
||||
c, changed = removeNFromSlice(b, a...)
|
||||
if !reflect.DeepEqual(c, []uint64{2, 12}) {
|
||||
t.Fatalf("%v and %v should be the same", c, []uint64{2, 12})
|
||||
}
|
||||
if changed != 3 {
|
||||
t.Fatalf("%v changes expected, got %v", 3, changed)
|
||||
}
|
||||
|
||||
c, changed = removeNFromSlice(a, a...)
|
||||
if !reflect.DeepEqual(c, []uint64(nil)) {
|
||||
t.Fatalf("%v and %v should be the same", c, a)
|
||||
}
|
||||
if changed != 6 {
|
||||
t.Fatalf("%v changes expected, got %v", 0, changed)
|
||||
for _, test := range tests {
|
||||
got, changed := removeNFromSlice(test.a, test.b...)
|
||||
if !reflect.DeepEqual(test.expected, got) {
|
||||
t.Fatalf("expected slices %v, got %v", test.expected, got)
|
||||
}
|
||||
if changed != test.changed {
|
||||
t.Fatalf("expected changed %v, got %v", test.changed, changed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCountRangeSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
|
||||
c := countRangeSlice(a, uint64(3), uint64(12))
|
||||
if c != 3 {
|
||||
t.Fatalf("expected %v, got %v", 3, c)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
start uint64
|
||||
end uint64
|
||||
expected uint64
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(3),
|
||||
end: uint64(12),
|
||||
expected: uint64(3),
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(0),
|
||||
end: uint64(25),
|
||||
expected: uint64(6),
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(12),
|
||||
end: uint64(4),
|
||||
expected: uint64(0),
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(4),
|
||||
end: uint64(4),
|
||||
expected: uint64(0),
|
||||
},
|
||||
}
|
||||
|
||||
c = countRangeSlice(a, uint64(0), uint64(25))
|
||||
if c != 6 {
|
||||
t.Fatalf("expected %v, got %v", 6, c)
|
||||
}
|
||||
|
||||
c = countRangeSlice(a, uint64(12), uint64(4))
|
||||
if c != 0 {
|
||||
t.Fatalf("expected %v, got %v", 0, c)
|
||||
for _, test := range tests {
|
||||
got := countRangeSlice(test.a, test.start, test.end)
|
||||
if got != test.expected {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRangeSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
|
||||
c := rangeSlice(a, uint64(3), uint64(12))
|
||||
if !reflect.DeepEqual(c, []uint64{4, 5, 9}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
start uint64
|
||||
end uint64
|
||||
expected []uint64
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(3),
|
||||
end: uint64(12),
|
||||
expected: []uint64{4, 5, 9},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(0),
|
||||
end: uint64(25),
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(5),
|
||||
end: uint64(5),
|
||||
expected: []uint64(nil),
|
||||
},
|
||||
}
|
||||
|
||||
c = rangeSlice(a, uint64(0), uint64(25))
|
||||
if !reflect.DeepEqual(c, []uint64{1, 4, 5, 9, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
|
||||
c = rangeSlice(a, uint64(5), uint64(5))
|
||||
if !reflect.DeepEqual(c, []uint64(nil)) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := rangeSlice(test.a, test.start, test.end)
|
||||
if !reflect.DeepEqual(got, test.expected) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlipSlice(t *testing.T) {
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
|
||||
c := flipSlice(a, uint64(3), uint64(12))
|
||||
if !reflect.DeepEqual(c, []uint64{1, 3, 6, 7, 8, 10, 11, 12, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
tests := []struct {
|
||||
a []uint64
|
||||
start uint64
|
||||
end uint64
|
||||
expected []uint64
|
||||
}{
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(3),
|
||||
end: uint64(12),
|
||||
expected: []uint64{1, 3, 6, 7, 8, 10, 11, 12, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(13),
|
||||
end: uint64(12),
|
||||
expected: []uint64{1, 4, 5, 9, 13, 24},
|
||||
},
|
||||
{
|
||||
a: []uint64{1, 4, 9, 5, 24, 13},
|
||||
start: uint64(9),
|
||||
end: uint64(13),
|
||||
expected: []uint64{1, 4, 5, 10, 11, 12, 24},
|
||||
},
|
||||
}
|
||||
|
||||
c = flipSlice(a, uint64(13), uint64(12))
|
||||
if !reflect.DeepEqual(c, []uint64{1, 4, 5, 9, 13, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
}
|
||||
|
||||
c = flipSlice(a, uint64(9), uint64(13))
|
||||
if !reflect.DeepEqual(c, []uint64{1, 4, 5, 10, 11, 12, 24}) {
|
||||
t.Fatalf("unexpected values: %v", c)
|
||||
for _, test := range tests {
|
||||
got := flipSlice(test.a, test.start, test.end)
|
||||
if !reflect.DeepEqual(got, test.expected) {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@
|
|||
|
||||
package roaring
|
||||
|
||||
const roaringSentinel = false
|
||||
const roaringSentinel = false
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@
|
|||
|
||||
package roaring
|
||||
|
||||
const roaringSentinel = true
|
||||
const roaringSentinel = true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue