1
2
3 package bitset
4
5 import (
6 "testing"
7 )
8
9 func TestPopcntSliceGo(t *testing.T) {
10 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
11 res := popcntSliceGo(s)
12 const l uint64 = 27
13 if res != l {
14 t.Errorf("Wrong popcount %d != %d", res, l)
15 }
16 }
17
18 func TestPopcntMaskSliceGo(t *testing.T) {
19 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
20 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
21 res := popcntMaskSliceGo(s, m)
22 const l uint64 = 9
23 if res != l {
24 t.Errorf("Wrong mask %d != %d", res, l)
25 }
26 }
27
28 func TestPopcntAndSliceGo(t *testing.T) {
29 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
30 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
31 res := popcntAndSliceGo(s, m)
32 const l uint64 = 18
33 if res != l {
34 t.Errorf("Wrong And %d != %d", res, l)
35 }
36 }
37
38 func TestPopcntOrSliceGo(t *testing.T) {
39 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
40 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
41 res := popcntOrSliceGo(s, m)
42 const l uint64 = 50
43 if res != l {
44 t.Errorf("Wrong OR %d != %d", res, l)
45 }
46 }
47
48 func TestPopcntXorSliceGo(t *testing.T) {
49 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
50 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
51 res := popcntXorSliceGo(s, m)
52 const l uint64 = 32
53 if res != l {
54 t.Errorf("Wrong OR %d != %d", res, l)
55 }
56 }
57
View as plain text