From 1e8afcf787c76fe7264d465c5fd32eb8596500e7 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 11 Jan 2015 17:55:39 +0000 Subject: [PATCH] Fix the tests, add the %s verb as well --- format.go | 5 +++++ parse_test.go | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/format.go b/format.go index b1e05695..f3ddf125 100644 --- a/format.go +++ b/format.go @@ -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())) } } diff --git a/parse_test.go b/parse_test.go index 5c0199cf..c809f043 100644 --- a/parse_test.go +++ b/parse_test.go @@ -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 }