forked from awalterschulze/gographviz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug_test.go
42 lines (38 loc) · 799 Bytes
/
bug_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
package gographviz
import (
"github.com/awalterschulze/gographviz/ast"
"github.com/awalterschulze/gographviz/parser"
"testing"
)
type bugSubGraphWorldVisitor struct {
t *testing.T
found bool
}
func (this *bugSubGraphWorldVisitor) Visit(v ast.Elem) ast.Visitor {
edge, ok := v.(ast.EdgeStmt)
if !ok {
return this
}
if edge.Source.GetId().String() != "2" {
return this
}
dst := edge.EdgeRHS[0].Destination
if _, ok := dst.(*ast.SubGraph); !ok {
this.t.Fatalf("2 -> Not SubGraph")
} else {
this.found = true
}
return this
}
func TestBugSubGraphWorld(t *testing.T) {
g := analtest(t, "world.gv.txt")
st, err := parser.ParseString(g.String())
check(t, err)
s := &bugSubGraphWorldVisitor{
t: t,
}
st.Walk(s)
if !s.found {
t.Fatalf("2 -> SubGraph not found")
}
}