Documentation updates and parsing fixes

This commit is contained in:
Miek Gieben 2012-02-12 11:45:44 +01:00
parent 974f4214a2
commit a21f7c6b30
2 changed files with 22 additions and 3 deletions

View File

@ -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) {

View File

@ -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)