Fix the tests, add the %s verb as well
This commit is contained in:
parent
78d0037371
commit
1e8afcf787
|
@ -43,6 +43,9 @@ func format(r RR, f fmt.State, c rune) {
|
|||
f.Write([]byte(strconv.Itoa(int(r.Header().Ttl))))
|
||||
case 'Y':
|
||||
f.Write([]byte(Type(r.Header().Rrtype).String()))
|
||||
case 's':
|
||||
f.Write([]byte(r.String()))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +59,8 @@ func format_Header(h *RR_Header, f fmt.State, c rune) {
|
|||
f.Write([]byte(strconv.Itoa(int(h.Ttl))))
|
||||
case 'Y':
|
||||
f.Write([]byte(Type(h.Rrtype).String()))
|
||||
case 's':
|
||||
f.Write([]byte(h.String()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1341,19 +1341,22 @@ func TestNewRRSpecial(t *testing.T) {
|
|||
func TestPrintfVerbs(t *testing.T) {
|
||||
x, _ := NewRR("www.miek.nl. IN A 127.0.0.1")
|
||||
if fmt.Sprintf("%N", x) != "www.miek.nl." {
|
||||
t.Errorf("%N does return name")
|
||||
t.Errorf("%N does not return name")
|
||||
}
|
||||
if fmt.Sprintf("%C", x) != "IN" {
|
||||
t.Errorf("%C does return class")
|
||||
t.Errorf("%C does not return class")
|
||||
}
|
||||
if fmt.Sprintf("%D", x) != "3600" {
|
||||
t.Errorf("%D does return ttl")
|
||||
t.Errorf("%D does not return ttl")
|
||||
}
|
||||
if fmt.Sprintf("%Y", x) != "A" {
|
||||
t.Errorf("%Y does return type")
|
||||
t.Errorf("%Y does not return type")
|
||||
}
|
||||
if fmt.Sprintf("%Y %d", x, 5) != "A 5" {
|
||||
t.Errorf("%N does return name")
|
||||
t.Errorf("%N does not return name")
|
||||
}
|
||||
if fmt.Sprintf("%s", x) != "www.miek.nl.\t3600\tIN\tA\t127.0.0.1" {
|
||||
t.Errorf("%s does return the correct string")
|
||||
}
|
||||
// TODO(miek): RDATA
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue