-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_test.go
54 lines (47 loc) · 934 Bytes
/
path_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
package graph
import (
"testing"
)
func TestPathsBetween(t *testing.T) {
t.Parallel()
tests := [...]struct {
name string
Graph[int]
dst int
count int
}{
{"line", Line(5), 4, 1},
{"Q2", Q(2), 3, 2},
{"K4", K(4), 3, 5},
{"loop", Ring(5), 4, 1},
{"tree", Tree(5), 4, 1},
{"star", Star(5), 4, 1},
}
for _, test := range tests {
paths := PathsBetween(test.Graph, test.Graph.Node(0), test.Graph.Node(test.dst))
if len(paths) != test.count {
t.Errorf("test %s = %v", test.name, paths)
}
}
}
func TestPaths(t *testing.T) {
t.Parallel()
tests := [...]struct {
string
Graph[int]
int
}{
{"line", Line(5), 1},
{"loop", Ring(5), 1},
{"Q2", Q(2), 6},
{"K4", K(4), 15},
{"tree", Tree(5), 3},
{"star", Star(5), 4},
}
for _, test := range tests {
paths := Paths(test.Graph, test.Graph.Node(0))
if len(paths) != test.int {
t.Errorf("test %s = %v", test.string, paths)
}
}
}