This repository was archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnull_test.go
72 lines (57 loc) · 2.31 KB
/
null_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
66
67
68
69
70
71
72
package gogl
import (
. "github.com/sdboyer/gocheck"
"math"
)
type NullGraphSuite bool
var _ = Suite(NullGraphSuite(false))
func (s NullGraphSuite) TestEnumerators(c *C) {
NullGraph.Vertices(func(v Vertex) (terminate bool) {
c.Error("The NullGraph should not have any vertices.")
return
})
NullGraph.Edges(func(e Edge) (terminate bool) {
c.Error("The NullGraph should not have any edges.")
return
})
NullGraph.IncidentTo("foo", func(e Edge) (terminate bool) {
c.Error("The NullGraph should be empty of edges and vertices.")
return
})
NullGraph.AdjacentTo("foo", func(v Vertex) (terminate bool) {
c.Error("The NullGraph should be empty of edges and vertices.")
return
})
NullGraph.ArcsFrom("foo", func(e Arc) (terminate bool) {
c.Error("The NullGraph should be empty of edges and vertices.")
return
})
NullGraph.ArcsTo("foo", func(e Arc) (terminate bool) {
c.Error("The NullGraph should be empty of edges and vertices.")
return
})
}
func (s NullGraphSuite) TestMembership(c *C) {
c.Assert(NullGraph.HasVertex("foo"), Equals, false) // must always be false
c.Assert(NullGraph.HasEdge(NewEdge("qux", "quark")), Equals, false) // must always be false
c.Assert(NullGraph.HasWeightedEdge(NewWeightedEdge("qux", "quark", 0)), Equals, false) // must always be false
c.Assert(NullGraph.HasLabeledEdge(NewLabeledEdge("qux", "quark", "")), Equals, false) // must always be false
c.Assert(NullGraph.HasDataEdge(NewDataEdge("qux", "quark", func() {})), Equals, false) // must always be false
}
func (s NullGraphSuite) TestDegree(c *C) {
deg, exists := NullGraph.DegreeOf("foo")
c.Assert(exists, Equals, false) // vertex is not present in graph
c.Assert(deg, Equals, 0) // always will have degree 0
deg, exists = NullGraph.InDegreeOf("foo")
c.Assert(exists, Equals, false) // vertex is not present in graph
c.Assert(deg, Equals, 0) // always will have indegree 0
deg, exists = NullGraph.OutDegreeOf("foo")
c.Assert(exists, Equals, false) // vertex is not present in graph
c.Assert(deg, Equals, 0) // always will have outdegree 0
}
func (s NullGraphSuite) TestSizingOps(c *C) {
c.Assert(math.IsNaN(NullGraph.Density()), Equals, true)
}
func (s NullGraphSuite) TestTranspose(c *C) {
c.Assert(NullGraph.Transpose(), Equals, NullGraph)
}