1
2
3
4
5
6 package bitset
7
8 import (
9 "testing"
10 )
11
12 func TestPopcntSliceCond(t *testing.T) {
13 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
14 oldUseAsm := useAsm
15 defer func() { useAsm = oldUseAsm }()
16 useAsm = false
17 resGo := popcntSlice(s)
18 useAsm = (true && oldUseAsm)
19 resAsm := popcntSlice(s)
20 if resGo != resAsm {
21 t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm)
22 }
23 }
24
25 func TestPopcntMaskSliceCond(t *testing.T) {
26 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
27 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
28 oldUseAsm := useAsm
29 defer func() { useAsm = oldUseAsm }()
30 useAsm = false
31 resGo := popcntMaskSlice(s, m)
32 useAsm = (true && oldUseAsm)
33 resAsm := popcntMaskSlice(s, m)
34 if resGo != resAsm {
35 t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm)
36 }
37 }
38
39 func TestPopcntAndSliceCond(t *testing.T) {
40 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
41 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
42 oldUseAsm := useAsm
43 defer func() { useAsm = oldUseAsm }()
44 useAsm = false
45 resGo := popcntAndSlice(s, m)
46 useAsm = (true && oldUseAsm)
47 resAsm := popcntAndSlice(s, m)
48 if resGo != resAsm {
49 t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm)
50 }
51 }
52
53 func TestPopcntOrSliceCond(t *testing.T) {
54 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
55 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
56 oldUseAsm := useAsm
57 defer func() { useAsm = oldUseAsm }()
58 useAsm = false
59 resGo := popcntOrSlice(s, m)
60 useAsm = (true && oldUseAsm)
61 resAsm := popcntOrSlice(s, m)
62 if resGo != resAsm {
63 t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm)
64 }
65 }
66
67 func TestPopcntXorSliceCond(t *testing.T) {
68 s := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
69 m := []uint64{31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
70 oldUseAsm := useAsm
71 defer func() { useAsm = oldUseAsm }()
72 useAsm = false
73 resGo := popcntXorSlice(s, m)
74 useAsm = (true && oldUseAsm)
75 resAsm := popcntXorSlice(s, m)
76 if resGo != resAsm {
77 t.Errorf("The implementations are different: GO %d != ASM %d", resGo, resAsm)
78 }
79 }
80
View as plain text