-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpert_graph_test.go
65 lines (50 loc) · 1.42 KB
/
expert_graph_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
package incr
import (
"testing"
"github.com/wcharczuk/go-incr/testutil"
)
func Test_ExpertGraph_SetID(t *testing.T) {
g := New()
eg := ExpertGraph(g)
newID := NewIdentifier()
eg.SetID(newID)
testutil.Equal(t, newID, g.ID())
}
func Test_ExpertGraph_SetStabilizationNum(t *testing.T) {
g := New()
eg := ExpertGraph(g)
eg.SetStabilizationNum(1234)
testutil.Equal(t, 1234, eg.StabilizationNum())
}
func Test_ExpertGraph_RecomputeHeapAdd(t *testing.T) {
g := New()
eg := ExpertGraph(g)
n1 := newMockBareNode(g)
n2 := newMockBareNode(g)
eg.RecomputeHeapAdd(n1, n2)
testutil.Equal(t, 2, g.recomputeHeap.len())
testutil.Equal(t, 2, eg.RecomputeHeapLen())
}
func Test_ExpertGraph_stats(t *testing.T) {
g := New()
g.numNodes = 12
g.numNodesChanged = 13
g.numNodesRecomputed = 14
eg := ExpertGraph(g)
testutil.Equal(t, 12, eg.NumNodes())
testutil.Equal(t, 13, eg.NumNodesChanged())
testutil.Equal(t, 14, eg.NumNodesRecomputed())
}
func Test_ExpertGraph_RecomputeHeapIDs(t *testing.T) {
g := New()
eg := ExpertGraph(g)
n1 := newMockBareNode(g)
n2 := newMockBareNode(g)
n2.n.height = 3
eg.RecomputeHeapAdd(n1, n2)
testutil.Equal(t, 2, g.recomputeHeap.len())
recomputeHeapIDs := eg.RecomputeHeapIDs()
testutil.Equal(t, 2, len(recomputeHeapIDs))
testutil.Any(t, recomputeHeapIDs, func(id Identifier) bool { return id == n1.n.id })
testutil.Any(t, recomputeHeapIDs, func(id Identifier) bool { return id == n2.n.id })
}