-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_graph_test.go
More file actions
41 lines (32 loc) · 869 Bytes
/
Copy pathdynamic_graph_test.go
File metadata and controls
41 lines (32 loc) · 869 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
package graph
import (
"graph/edge"
"graph/vertex"
"graph/weight"
"testing"
"time"
)
func TestNewDynamicGraph_AddVertex(t *testing.T) {
g := NewDynamicGraph(map[string]vertex.Vertex{}, map[string]edge.Edge{})
a := g.AddVertex(vertex.NewVertex("A"))
b := g.AddVertex(vertex.NewVertex("B"))
if a == nil {
t.Errorf("vertex a is nil")
}
if b == nil {
t.Errorf("vertex b is nil")
}
}
func TestNewDynamicGraph_AddEdge(t *testing.T) {
g := NewDynamicGraph(map[string]vertex.Vertex{}, map[string]edge.Edge{})
a := g.AddVertex(vertex.NewVertex("A"))
b := g.AddVertex(vertex.NewVertex("B"))
e := g.AddEdge("1", edge.NewEdge(a, b, weight.NewWeight(5, 3*time.Second, true)))
f := g.AddEdge("2", edge.NewEdge(b, a, weight.NewWeight(5, 3*time.Second, true)))
if e == nil {
t.Errorf("edge e is nil")
}
if f == nil {
t.Errorf("edge f is nil")
}
}