Test parsing of TXT records containing empty-strings

This commit is contained in:
Andrew Tunnell-Jones 2014-01-11 05:31:43 +00:00
parent 91f31a2b71
commit 938210c3ad
1 changed files with 20 additions and 0 deletions

View File

@ -738,6 +738,26 @@ func TestTXT(t *testing.T) {
t.Error("Bad size of serialized multi value record:", rr.len())
}
}
// Test empty-string in TXT record
rr, err = NewRR(`_raop._tcp.local. 60 IN TXT ""`)
if err != nil {
t.Error("Failed to parse empty-string TXT record", err)
} else if rr, ok := rr.(*TXT); !ok {
t.Error("Wrong type, record should be of type TXT")
} else {
if len(rr.Txt) != 1 {
t.Error("Bad size of TXT empty-string value:", len(rr.Txt))
} else if rr.Txt[0] != "" {
t.Error("Bad value for empty-string TXT record")
}
if rr.String() != `_raop._tcp.local. 60 IN TXT ""` {
t.Error("Bad representation of empty-string TXT record:", rr.String())
}
if rr.len() != 28+1 {
t.Error("Bad size of serialized record:", rr.len())
}
}
}
func TestTypeXXXX(t *testing.T) {