@@ -178,7 +178,7 @@ func baseAttrsAndConfig() (*DotAttributes, *DotConfig) {
178178 }
179179 c := & DotConfig {
180180 Title : "testtitle" ,
181- Labels : []string {"label1" , "label2" },
181+ Labels : []string {"label1" , "label2" , `label3: "foo"` },
182182 Total : 100 ,
183183 FormatValue : func (v int64 ) string {
184184 return strconv .FormatInt (v , 10 )
@@ -326,6 +326,46 @@ func TestTagCollapse(t *testing.T) {
326326 }
327327}
328328
329+ func TestEscapeDoubleQuotes (t * testing.T ) {
330+ for _ , tc := range []struct {
331+ desc string
332+ input string
333+ want string
334+ }{
335+ {
336+ desc : "with multiple doubles quotes" ,
337+ input : `label: "foo" and "bar"` ,
338+ want : `label: \"foo\" and \"bar\"` ,
339+ },
340+ {
341+ desc : "with already escaped doubles quotes" ,
342+ input : `label: \"foo\" and \"bar\"` ,
343+ want : `label: \"foo\" and \"bar\"` ,
344+ },
345+ {
346+ desc : "with escaped character but no doubles quotes" ,
347+ input : `label: \$foo and bar` ,
348+ want : `label: \$foo and bar` ,
349+ },
350+ {
351+ desc : "with escaped backslash but not escaped doubles quotes" ,
352+ input : `label: \\"foo" and bar` ,
353+ want : `label: \\\"foo\" and bar` ,
354+ },
355+ {
356+ desc : "with two double quotes together" ,
357+ input : `label: ""` ,
358+ want : `label: \"\"` ,
359+ },
360+ } {
361+ t .Run (tc .desc , func (t * testing.T ) {
362+ if got := escapeDoubleQuotes (tc .input ); got != tc .want {
363+ t .Errorf ("escapeDoubleQuotes(%s) = %s, want %s" , tc .input , got , tc .want )
364+ }
365+ })
366+ }
367+ }
368+
329369func tagString (t []* Tag ) string {
330370 var ret []string
331371 for _ , s := range t {
0 commit comments