forked from RoaringBitmap/roaring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiter123_test.go
More file actions
111 lines (88 loc) · 1.81 KB
/
iter123_test.go
File metadata and controls
111 lines (88 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//go:build go1.23
// +build go1.23
package roaring
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBackwardCount123(t *testing.T) {
array := []int{2, 63, 64, 65, 4095, 4096, 4097, 4159, 4160, 4161, 5000, 20000, 66666}
for _, testSize := range array {
b := New()
for i := uint32(0); i < uint32(testSize); i++ {
b.Add(i)
}
count := 0
for range Values(b) {
count++
}
assert.Equal(t, testSize, count)
}
}
func TestBackward123(t *testing.T) {
t.Run("#1", func(t *testing.T) {
values := []uint32{0, 2, 15, 16, 31, 32, 33, 9999, MaxUint16, MaxUint32}
b := New()
for n := 0; n < len(values); n++ {
b.Add(values[n])
}
n := len(values) - 1
for val := range Backward(b) {
assert.EqualValues(t, val, values[n])
n--
}
})
t.Run("#2", func(t *testing.T) {
b := New()
count := 0
for range Backward(b) {
count++
}
assert.Equal(t, 0, count)
})
t.Run("#3", func(t *testing.T) {
b := New()
b.AddInt(0)
// only one value zero
for val := range Backward(b) {
assert.EqualValues(t, 0, val)
}
})
t.Run("#4", func(t *testing.T) {
b := New()
b.AddInt(9999)
// only one value 9999
for val := range Backward(b) {
assert.EqualValues(t, 9999, val)
}
})
t.Run("#5", func(t *testing.T) {
b := New()
b.AddInt(MaxUint16)
// only one value MaxUint16
for val := range Backward(b) {
assert.EqualValues(t, MaxUint16, val)
}
})
t.Run("#6", func(t *testing.T) {
b := New()
b.AddInt(MaxUint32)
// only one value MaxUint32
for val := range Backward(b) {
assert.EqualValues(t, MaxUint32, val)
}
})
}
func TestValues123(t *testing.T) {
b := New()
testSize := 5000
for i := 0; i < testSize; i++ {
b.AddInt(i)
}
n := 0
for val := range Values(b) {
assert.Equal(t, uint32(n), val)
n++
}
assert.Equal(t, testSize, n)
}