Add RFC1464 tests

This commit is contained in:
Patrick Sodré 2017-08-10 21:36:50 -04:00 committed by Frank Schroeder
parent 865f087ec9
commit 2cc6ac542c
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
1 changed files with 29 additions and 0 deletions

View File

@ -101,6 +101,35 @@ func TestRecursorAddr(t *testing.T) {
}
}
func TestEncodeKVasRFC1464(t *testing.T) {
// Test cases are from rfc1464
type rfc1464Test struct {
key, value, internalForm, externalForm string
}
tests := []rfc1464Test{
{"color", "blue", "color=blue", "color=blue"},
{"equation", "a=4", "equation=a=4", "equation=a=4"},
{"a=a", "true", "a`=a=true", "a`=a=true"},
{"a\\=a", "false", "a\\`=a=false", "a\\`=a=false"},
{"=", "\\=", "`==\\=", "`==\\="},
{"string", "\"Cat\"", "string=\"Cat\"", "string=\"Cat\""},
{"string2", "`abc`", "string2=``abc``", "string2=``abc``"},
{"novalue", "", "novalue=", "novalue="},
{"a b", "c d", "a b=c d", "a b=c d"},
{"abc ", "123 ", "abc` =123 ", "abc` =123 "},
// Additional tests
{" abc", " 321", "` abc= 321", "` abc= 321"},
{"`a", "b", "``a=b", "``a=b"},
}
for _, test := range tests {
answer := encodeKVasRFC1464(test.key, test.value)
verify.Values(t, "internalForm", answer, test.internalForm)
}
}
func TestDNS_NodeLookup(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), "")