mirror of
https://github.com/gonum/gonum.git
synced 2025-10-07 08:01:20 +08:00
graph/encoding/dot: (un)quote attributes if needed during (un)marshal
This commit is contained in:

committed by
Dan Kortschak

parent
9b1d387736
commit
24f0d081ca
@@ -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
|
||||
|
Reference in New Issue
Block a user