From 938210c3ad77eb3819b384d93800d707cdaf65fb Mon Sep 17 00:00:00 2001 From: Andrew Tunnell-Jones Date: Sat, 11 Jan 2014 05:31:43 +0000 Subject: [PATCH] Test parsing of TXT records containing empty-strings --- parse_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/parse_test.go b/parse_test.go index a78e00b3..bfdd942a 100644 --- a/parse_test.go +++ b/parse_test.go @@ -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) {