forked from sdboyer/gogl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder_test.go
93 lines (73 loc) · 2.99 KB
/
builder_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package gogl
import (
. "github.com/sdboyer/gocheck"
)
type SpecTestSuite struct{}
var _ = Suite(&SpecTestSuite{})
const baseline = G_UNDIRECTED | G_SIMPLE | G_BASIC | G_MUTABLE
func (s *SpecTestSuite) TestInitialState(c *C) {
c.Assert(Spec().Props == baseline, Equals, true)
}
// Because as long as we're playing the coverage game, why not be ridiculous?
func (s *SpecTestSuite) permuteField() []GraphProperties {
field := make([]GraphProperties, 16, 16)
for i := uint(0); i < 16; i++ {
field[i] = 1 << i
}
return field
}
func (s *SpecTestSuite) TestMutators(c *C) {
var spec GraphSpec
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Directed().Props&G_DIRECTED == G_DIRECTED, Equals, true)
c.Assert(spec.Directed().Props&G_UNDIRECTED == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Undirected().Props&G_UNDIRECTED == G_UNDIRECTED, Equals, true)
c.Assert(spec.Undirected().Props&G_DIRECTED == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Basic().Props&G_BASIC == G_BASIC, Equals, true)
c.Assert(spec.Basic().Props&(G_LABELED|G_WEIGHTED|G_DATA) == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Labeled().Props&G_LABELED == G_LABELED, Equals, true)
c.Assert(spec.Labeled().Props&G_BASIC == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Weighted().Props&G_WEIGHTED == G_WEIGHTED, Equals, true)
c.Assert(spec.Weighted().Props&G_BASIC == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.DataEdges().Props&G_DATA == G_DATA, Equals, true)
c.Assert(spec.DataEdges().Props&G_BASIC == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.SimpleGraph().Props&G_SIMPLE == G_SIMPLE, Equals, true)
c.Assert(spec.SimpleGraph().Props&(G_LOOPS|G_PARALLEL) == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.MultiGraph().Props&G_PARALLEL == G_PARALLEL, Equals, true)
c.Assert(spec.MultiGraph().Props&(G_LOOPS|G_SIMPLE) == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.PseudoGraph().Props&(G_LOOPS|G_PARALLEL) == (G_LOOPS|G_PARALLEL), Equals, true)
c.Assert(spec.PseudoGraph().Props&G_SIMPLE == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Parallel().Props&G_PARALLEL == G_PARALLEL, Equals, true)
c.Assert(spec.Parallel().Props&G_SIMPLE == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Loop().Props&G_LOOPS == G_LOOPS, Equals, true)
c.Assert(spec.Loop().Props&G_SIMPLE == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Mutable().Props&G_MUTABLE == G_MUTABLE, Equals, true)
c.Assert(spec.Mutable().Props&G_IMMUTABLE == 0, Equals, true)
}
for _, spec.Props = range s.permuteField() {
c.Assert(spec.Immutable().Props&G_IMMUTABLE == G_IMMUTABLE, Equals, true)
c.Assert(spec.Immutable().Props&G_MUTABLE == 0, Equals, true)
}
}