Update test and gofmt

This commit is contained in:
Miek Gieben 2014-11-09 16:09:49 +00:00
parent 7619917e11
commit d33af8db79
5 changed files with 21 additions and 18 deletions

22
msg.go
View File

@ -564,20 +564,20 @@ func unpackTxtString(msg []byte, offset int) (string, int, error) {
s = append(s, `\n`...)
default:
if b < 32 || b > 127 { // unprintable
var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
s = append(s, '\\')
for i := 0; i < 3-len(bufs); i++ {
s = append(s, '0')
var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
s = append(s, '\\')
for i := 0; i < 3-len(bufs); i++ {
s = append(s, '0')
}
for _, r := range bufs {
s = append(s, r)
}
} else {
s = append(s, b)
}
for _, r := range bufs {
s = append(s, r)
}
} else {
s = append(s, b)
}
}
}
offset += 1 + l
return string(s), offset, nil
}

View File

@ -68,7 +68,7 @@ func TestServing(t *testing.T) {
m := new(Msg)
m.SetQuestion("miek.nl.", TypeTXT)
r, _, err := c.Exchange(m, addrstr)
if err != nil {
if err != nil || len(r.Extra) == 0 {
t.Log("failed to exchange miek.nl", err)
t.Fatal()
}

View File

@ -830,7 +830,7 @@ func (rr *LOC) String() string {
// SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931.
type SIG struct {
RRSIG
RRSIG
}
type RRSIG struct {
@ -1031,11 +1031,11 @@ func (rr *IPSECKEY) len() int {
}
type KEY struct {
DNSKEY
DNSKEY
}
type CDNSKEY struct {
DNSKEY
DNSKEY
}
type DNSKEY struct {

View File

@ -23,11 +23,14 @@ func TestDynamicUpdateParsing(t *testing.T) {
func TestDynamicUpdateUnpack(t *testing.T) {
// From https://github.com/miekg/dns/issues/150#issuecomment-62296803
// It should be an update message for the zone "example.",
// deleting the A RRset "example." and then adding an A record at "example.".
// class ANY, TYPE A
buf := []byte{171, 68, 40, 0, 0, 1, 0, 0, 0, 2, 0, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 0, 6, 0, 1, 192, 12, 0, 1, 0, 255, 0, 0, 0, 0, 0, 0, 192, 12, 0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 127, 0, 0, 1}
msg := new(Msg)
err := msg.Unpack(buf)
if err != nil {
t.Log("failed to unpack: " + err.Error())
// t.Fail()
t.Log("failed to unpack: " + err.Error() + "\n" + msg.String()))
t.Fail()
}
}

View File

@ -1653,7 +1653,7 @@ func setDSs(h RR_Header, c chan lex, o, f, typ string) (RR, *ParseError, string)
} else {
rr.DigestType = uint8(i)
}
s, e, c1 := endingToString(c, "bad " + typ + " Digest", f)
s, e, c1 := endingToString(c, "bad "+typ+" Digest", f)
if e != nil {
return nil, e, c1
}