digraph: double-quote dot graph elements
This commit is contained in:
parent
29d6a4242e
commit
83795bc54d
|
@ -11,10 +11,10 @@ func GenerateDot(nodes []Node, w io.Writer) {
|
||||||
w.Write([]byte("digraph {\n"))
|
w.Write([]byte("digraph {\n"))
|
||||||
defer w.Write([]byte("}\n"))
|
defer w.Write([]byte("}\n"))
|
||||||
for _, n := range nodes {
|
for _, n := range nodes {
|
||||||
w.Write([]byte(fmt.Sprintf("\t%s;\n", n)))
|
w.Write([]byte(fmt.Sprintf("\t\"%s\";\n", n)))
|
||||||
for _, edge := range n.Edges() {
|
for _, edge := range n.Edges() {
|
||||||
target := edge.Tail()
|
target := edge.Tail()
|
||||||
line := fmt.Sprintf("\t%s -> %s [label=\"%s\"];\n",
|
line := fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\"];\n",
|
||||||
n, target, edge)
|
n, target, edge)
|
||||||
w.Write([]byte(line))
|
w.Write([]byte(line))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,31 +27,31 @@ b -> e
|
||||||
if !strings.HasSuffix(out, "\n}\n") {
|
if !strings.HasSuffix(out, "\n}\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\ta;\n") {
|
if !strings.Contains(out, "\n\t\"a\";\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\tb;\n") {
|
if !strings.Contains(out, "\n\t\"b\";\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\tc;\n") {
|
if !strings.Contains(out, "\n\t\"c\";\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\td;\n") {
|
if !strings.Contains(out, "\n\t\"d\";\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\te;\n") {
|
if !strings.Contains(out, "\n\t\"e\";\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\ta -> b [label=\"foo\"];\n") {
|
if !strings.Contains(out, "\n\t\"a\" -> \"b\" [label=\"foo\"];\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\ta -> c [label=\"Edge\"];\n") {
|
if !strings.Contains(out, "\n\t\"a\" -> \"c\" [label=\"Edge\"];\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\tb -> d [label=\"Edge\"];\n") {
|
if !strings.Contains(out, "\n\t\"b\" -> \"d\" [label=\"Edge\"];\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
if !strings.Contains(out, "\n\tb -> e [label=\"Edge\"];\n") {
|
if !strings.Contains(out, "\n\t\"b\" -> \"e\" [label=\"Edge\"];\n") {
|
||||||
t.Fatalf("bad: %v", out)
|
t.Fatalf("bad: %v", out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue