-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitboard_test.go
58 lines (51 loc) · 964 Bytes
/
bitboard_test.go
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
package octad
import "testing"
type bitboardTestPair struct {
initial uint16
reversed uint16
}
var (
tests = []bitboardTestPair{
{
uint16(1),
uint16(32768),
},
{
uint16(24576),
uint16(6),
},
{
uint16(15),
uint16(61440),
},
}
)
func TestBitboardReverse(t *testing.T) {
for _, p := range tests {
r := uint16(bitboard(p.initial).Reverse())
if r != p.reversed {
t.Fatalf("bitboard: reverse of %s expected %s "+
"but got %s", intStr(p.initial), intStr(p.reversed), intStr(r))
}
}
}
func TestBitboardOccupied(t *testing.T) {
m := map[Square]bool{
B3: true,
}
bb := newBitboard(m)
if bb.Occupied(B3) != true {
t.Fatalf("bitboard: occupied of %s expected %t "+
"but got %t", bb, true, false)
}
}
func BenchmarkBitboardReverse(b *testing.B) {
var i uint16
for i = 0; i < uint16(b.N); i++ {
u := uint16(42345)
bitboard(u).Reverse()
}
}
func intStr(i uint16) string {
return bitboard(i).String()
}