-
Notifications
You must be signed in to change notification settings - Fork 35
/
storage_test.go
65 lines (54 loc) · 1.48 KB
/
storage_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
package dag
type testVertex struct {
WID string `json:"i"`
Val string `json:"v"`
}
func (tv testVertex) ID() string {
return tv.WID
}
func (tv testVertex) Vertex() (id string, value interface{}) {
return tv.WID, tv.Val
}
type testStorableDAG struct {
StorableVertices []testVertex `json:"vs"`
StorableEdges []storableEdge `json:"es"`
}
func (g testStorableDAG) Vertices() []Vertexer {
l := make([]Vertexer, 0, len(g.StorableVertices))
for _, v := range g.StorableVertices {
l = append(l, v)
}
return l
}
func (g testStorableDAG) Edges() []Edger {
l := make([]Edger, 0, len(g.StorableEdges))
for _, v := range g.StorableEdges {
l = append(l, v)
}
return l
}
type testNonComparableStorableVertex struct {
Id string `json:"i"`
NotComparableVertex testNonComparableVertexType `json:"v"`
}
func (tv testNonComparableStorableVertex) Vertex() (id string, value interface{}) {
return tv.Id, tv.NotComparableVertex
}
type testNonComparableStorableDAG struct {
StorableVertices []testNonComparableStorableVertex `json:"vs"`
StorableEdges []storableEdge `json:"es"`
}
func (g testNonComparableStorableDAG) Vertices() []Vertexer {
l := make([]Vertexer, 0, len(g.StorableVertices))
for _, v := range g.StorableVertices {
l = append(l, v)
}
return l
}
func (g testNonComparableStorableDAG) Edges() []Edger {
l := make([]Edger, 0, len(g.StorableEdges))
for _, v := range g.StorableEdges {
l = append(l, v)
}
return l
}