Documentation updates and parsing fixes
This commit is contained in:
parent
974f4214a2
commit
a21f7c6b30
|
@ -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
|
// Another one hear, geared to NSECx
|
||||||
func TestParseNSEC(t *testing.T) {
|
func TestParseNSEC(t *testing.T) {
|
||||||
nsectests := map[string]string{
|
nsectests := map[string]string{
|
||||||
|
@ -175,7 +195,6 @@ func TestParseNSEC(t *testing.T) {
|
||||||
t.Logf("RR is OK: `%s'", rr.String())
|
t.Logf("RR is OK: `%s'", rr.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseBrace(t *testing.T) {
|
func TestParseBrace(t *testing.T) {
|
||||||
|
|
4
zscan.go
4
zscan.go
|
@ -98,7 +98,7 @@ func NewRR(s string) (RR, error) {
|
||||||
// Ioreader here, or filename which *we* open....???
|
// Ioreader here, or filename which *we* open....???
|
||||||
|
|
||||||
// ReadRR reads the RR contained in q. Only the first RR is returned.
|
// 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) {
|
func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
r := <-ParseZone(q, filename)
|
r := <-ParseZone(q, filename)
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
|
@ -107,7 +107,7 @@ func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
return r.RR, nil
|
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.
|
// 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 {
|
func ParseZone(r io.Reader, file string) chan Token {
|
||||||
t := make(chan Token)
|
t := make(chan Token)
|
||||||
|
|
Loading…
Reference in New Issue