package namedconf import "testing" func TestFormatValue(t *testing.T) { for _, c := range []struct{ name, value, want string }{ {"logging", `{ channel c { file "/var/log/named/x.log" versions 3; print-time yes; }; category default { c; }; }`, // A short inner block stays on one line, as in named.conf. "{\n\tchannel c { file \"/var/log/named/x.log\" versions 3; print-time yes; };\n\tcategory default { c; };\n}"}, {"allow-query", `{ allowed_clients; }`, `{ allowed_clients; }`}, // short: unchanged {"directory", `"/var/cache/bind"`, `"/var/cache/bind"`}, {"logging", `{ broken`, `{ broken`}, // unparsable: as it is } { if got := FormatValue(c.name, c.value); got != c.want { t.Errorf("FormatValue(%s, %q) =\n%s\nwant\n%s", c.name, c.value, got, c.want) } } }