-
Notifications
You must be signed in to change notification settings - Fork 0
/
inner_test.go
63 lines (55 loc) · 1.06 KB
/
inner_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
package art
import (
"github.com/stretchr/testify/assert"
"testing"
)
type LeftmostSet struct {
nodeFactor func() inode[Value]
expected node[Value]
}
func TestLeftmost(t *testing.T) {
l := &leaf[Value]{key: Key("a key"), value: Value("value")}
assert.Equal(t, l, l.leftmost())
sets := []LeftmostSet{
{
nodeFactor: func() inode[Value] {
return &node4[Value]{}
},
expected: l,
},
{
nodeFactor: func() inode[Value] {
return &node16[Value]{}
},
expected: l,
},
{
nodeFactor: func() inode[Value] {
return &node48[Value]{}
},
expected: l,
},
{
nodeFactor: func() inode[Value] {
return &node256[Value]{}
},
expected: l,
},
}
var child node[Value]
for _, set := range sets {
// leaf level
child = l
// level + 1
n := set.nodeFactor()
n.addChild('a', child)
child = &inner[Value]{node: n}
// level + 1
nn := set.nodeFactor()
nn.addChild('a', child)
upper := &inner[Value]{node: n}
leftmost := upper.leftmost()
assert.NotNil(t, leftmost)
assert.Equal(t, set.expected, leftmost)
}
}