-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_test.go
More file actions
48 lines (39 loc) · 1.02 KB
/
node_test.go
File metadata and controls
48 lines (39 loc) · 1.02 KB
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
package zss
import "testing"
func tree1() *Node {
f := &Node{Label: "f"}
d := &Node{Label: "d"}
a := &Node{Label: "a"}
c := &Node{Label: "c"}
b := &Node{Label: "b"}
e := &Node{Label: "e"}
f.AddKid(d.AddKid(a, false).AddKid(c.AddKid(b, false), false), false).AddKid(e, false)
return f
}
func TestNodeContainsWithLabel(t *testing.T) {
root := tree1()
contains := root.ContainsWithLabel("f")
if contains != true {
t.Errorf("%s not contains itself\n", root.Label)
}
contains = root.ContainsWithLabel("d")
if contains != true {
t.Errorf("%s not contains d\n", root.Label)
}
contains = root.ContainsWithLabel("e")
if contains != true {
t.Errorf("%s not contains d\n", root.Label)
}
contains = root.ContainsWithLabel("a")
if contains != true {
t.Errorf("%s not contains a\n", root.Label)
}
contains = root.ContainsWithLabel("c")
if contains != true {
t.Errorf("%s not contains c\n", root.Label)
}
contains = root.ContainsWithLabel("b")
if contains != true {
t.Errorf("%s not contains b\n", root.Label)
}
}