graph/encoding/dot: (un)quote attributes if needed during (un)marshal

This commit is contained in:
Robin Eklind
2019-01-14 04:57:56 +01:00
committed by Dan Kortschak
parent 9b1d387736
commit 24f0d081ca
5 changed files with 288 additions and 74 deletions

View File

@@ -43,6 +43,14 @@ func TestRoundTrip(t *testing.T) {
want: undirectedWithPorts,
directed: false,
},
{
want: directedAttrs,
directed: true,
},
{
want: undirectedAttrs,
directed: false,
},
}
for i, g := range golden {
var dst encoding.Builder
@@ -165,6 +173,46 @@ const undirectedWithPorts = `strict graph {
E:_ -- F:c;
}`
const directedAttrs = `strict digraph {
node [
shape=circle
style=filled
label="NODE"
];
edge [
penwidth=5
color=gray
label=3.14
];
// Node definitions.
A [label=<br>];
B [label=-14];
// Edge definitions.
A -> B [label="hello world"];
}`
const undirectedAttrs = `strict graph {
node [
shape=circle
style=filled
label="NODE"
];
edge [
penwidth=5
color=gray
label=3.14
];
// Node definitions.
A [label=<br>];
B [label=-14];
// Edge definitions.
A -- B [label="hello world"];
}`
func TestChainedEdgeAttributes(t *testing.T) {
golden := []struct {
in, want string