-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitvector_test.go
More file actions
59 lines (48 loc) · 1.17 KB
/
bitvector_test.go
File metadata and controls
59 lines (48 loc) · 1.17 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
// bitvector_test.go -- test suite for bitvector
//
// (c) Sudhi Herle 2018
//
// Author: Sudhi Herle <sudhi@herle.net>
//
// This software does not come with any express or implied
// warranty; it is provided "as is". No claim is made to its
// suitability for any purpose.
package chd
import (
"testing"
)
func TestBitVectorSimple(t *testing.T) {
assert := newAsserter(t)
bv := newBitVector(100)
assert(bv.Size() == 128, "size mismatch; exp 128, saw %d", bv.Size())
for i := uint64(0); i < bv.Size(); i++ {
if 1 == (i & 1) {
bv.Set(i)
}
}
for i := uint64(0); i < bv.Size(); i++ {
if 1 == (i & 1) {
assert(bv.IsSet(i), "%d not set", i)
} else {
assert(!bv.IsSet(i), "%d is set", i)
}
}
}
func TestBitVectorMerge(t *testing.T) {
assert := newAsserter(t)
av := newBitVector(60)
bv := newBitVector(60)
assert(av.Size() == 64, "a:size mismatch; exp 64, saw %d", av.Size())
assert(bv.Size() == 64, "b:size mismatch; exp 64, saw %d", bv.Size())
for i := uint64(0); i < av.Size(); i++ {
if 1 == (i & 1) {
bv.Set(i)
} else {
av.Set(i)
}
}
av.Merge(bv)
for i := uint64(0); i < av.Size(); i++ {
assert(av.IsSet(i), "merged bit %d not set", i)
}
}