From 83795bc54d056f0533ccf2331ba664705176d45c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 1 Jul 2014 09:54:40 -0700 Subject: [PATCH] digraph: double-quote dot graph elements --- digraph/graphviz.go | 4 ++-- digraph/graphviz_test.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/digraph/graphviz.go b/digraph/graphviz.go index 788112fec..2908dfcd8 100644 --- a/digraph/graphviz.go +++ b/digraph/graphviz.go @@ -11,10 +11,10 @@ func GenerateDot(nodes []Node, w io.Writer) { w.Write([]byte("digraph {\n")) defer w.Write([]byte("}\n")) 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() { target := edge.Tail() - line := fmt.Sprintf("\t%s -> %s [label=\"%s\"];\n", + line := fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\"];\n", n, target, edge) w.Write([]byte(line)) } diff --git a/digraph/graphviz_test.go b/digraph/graphviz_test.go index 88939480f..17bcb6c7e 100644 --- a/digraph/graphviz_test.go +++ b/digraph/graphviz_test.go @@ -27,31 +27,31 @@ b -> e if !strings.HasSuffix(out, "\n}\n") { 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) } - if !strings.Contains(out, "\n\tb;\n") { + if !strings.Contains(out, "\n\t\"b\";\n") { 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) } - if !strings.Contains(out, "\n\td;\n") { + if !strings.Contains(out, "\n\t\"d\";\n") { 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) } - 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) } - 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) } - 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) } - 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) } }