-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffset_test.go
76 lines (69 loc) · 1.2 KB
/
offset_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package k2tree
import "testing"
func TestFourBOffset(t *testing.T) {
k2 := &K2Tree{
tk: FourBitsPerLayer,
lk: FourBitsPerLayer,
}
tt := []struct {
i int
j int
expectedL int
expectedT1 int
expectedT2 int
}{
{
i: 0,
j: 0,
expectedL: 0,
expectedT1: 0,
expectedT2: 0,
},
{
i: 2,
j: 2,
expectedL: 0,
expectedT1: 3,
expectedT2: 0,
},
{
i: 0,
j: 6,
expectedL: 0,
expectedT1: 1,
expectedT2: 1,
},
{
i: 4,
j: 4,
expectedL: 0,
expectedT1: 0,
expectedT2: 3,
},
{
i: 4,
j: 5,
expectedL: 1,
expectedT1: 0,
expectedT2: 3,
},
}
for _, x := range tt {
out := k2.offsetL(x.i, x.j)
if out != x.expectedL {
t.Errorf("unexpected result %d for L on test %#v\n", out, x)
}
}
for _, x := range tt {
out := k2.offsetTForLayer(x.i, x.j, 1)
if out != x.expectedT1 {
t.Errorf("unexpected result %d for T1 on test %#v\n", out, x)
}
}
for _, x := range tt {
out := k2.offsetTForLayer(x.i, x.j, 2)
if out != x.expectedT2 {
t.Errorf("unexpected result %d for T2 on test %#v\n", out, x)
}
}
}