From a21f7c6b305bbc354ebc54c85b8e403edd3ddb5b Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 12 Feb 2012 11:45:44 +0100 Subject: [PATCH] Documentation updates and parsing fixes --- parse_test.go | 21 ++++++++++++++++++++- zscan.go | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/parse_test.go b/parse_test.go index 431e50e8..6320813a 100644 --- a/parse_test.go +++ b/parse_test.go @@ -153,6 +153,26 @@ func TestDomainName(t *testing.T) { } } +func TestParseDirective(t *testing.T) { + tests := map[string]string{ + "$ORIGIN miek.nl.\na IN NS b": "a.miek.nl.\tIN\tNS\tb.miek.nl.", + } + for i, o := range tests { + rr, e := NewRR(i) + if e != nil { + t.Log("Failed to parse RR: " + e.Error()) + t.Fail() + continue + } + if rr.String() != o { + t.Logf("`%s' should be equal to\n`%s', but is `%s'\n", i, o, rr.String()) + t.Fail() + } else { + t.Logf("RR is OK: `%s'", rr.String()) + } + } +} + // Another one hear, geared to NSECx func TestParseNSEC(t *testing.T) { nsectests := map[string]string{ @@ -175,7 +195,6 @@ func TestParseNSEC(t *testing.T) { t.Logf("RR is OK: `%s'", rr.String()) } } - } func TestParseBrace(t *testing.T) { diff --git a/zscan.go b/zscan.go index 75c38e9b..3b6ecb2b 100644 --- a/zscan.go +++ b/zscan.go @@ -98,7 +98,7 @@ func NewRR(s string) (RR, error) { // Ioreader here, or filename which *we* open....??? // ReadRR reads the RR contained in q. Only the first RR is returned. -// The class defaults to IN and TTL defaults to DefaultTtl +// The class defaults to IN and TTL defaults to DefaultTtl. func ReadRR(q io.Reader, filename string) (RR, error) { r := <-ParseZone(q, filename) if r.Error != nil { @@ -107,7 +107,7 @@ func ReadRR(q io.Reader, filename string) (RR, error) { return r.RR, nil } -// ParseZone reads a RFC 1035 zone from r. It returns each parsed RR or on error +// ParseZone reads a RFC 1035 zone from r. It returns each parsed RR or an error // on the returned channel. The channel t is closed by ParseZone when the end of r is reached. func ParseZone(r io.Reader, file string) chan Token { t := make(chan Token)