-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
45 lines (42 loc) · 872 Bytes
/
main_test.go
File metadata and controls
45 lines (42 loc) · 872 Bytes
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
package main
import (
"fmt"
"reflect"
"testing"
)
func Test_main(t *testing.T) {
edge := new(edges)
edge.src = 0
edge.dest = 1
edge.tree = make(map[int32][]int32)
edge.AddEdges()
edge.src = 0
edge.dest = 2
edge.AddEdges()
edge.src = 1
edge.dest = 2
edge.AddEdges()
edge.src = 2
edge.dest = 0
edge.AddEdges()
edge.src = 2
edge.dest = 3
edge.AddEdges()
edge.src = 3
edge.dest = 3
edge.AddEdges()
want := []int32{2, 0, 1, 3}
output := edge.doDFS(2)
fmt.Println("Following is DFS from (starting from vertex 2)")
fmt.Println(output)
if !reflect.DeepEqual(output, want) {
t.Errorf("got %v, wanted %v", output, want)
}
want = []int32{2, 0, 3, 1}
output = edge.doBFS(2)
fmt.Println("Following is BFS from (starting from vertex 2)")
fmt.Println(output)
if !reflect.DeepEqual(output, want) {
t.Errorf("got %v, wanted %v", output, want)
}
}