From 519725bb3c075ee2462c929f5997cb068e18466a Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Mon, 26 Mar 2012 16:50:58 +0200 Subject: Imported Upstream version 2012.03.22 --- src/pkg/net/dnsmsg_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/pkg/net/dnsmsg_test.go') diff --git a/src/pkg/net/dnsmsg_test.go b/src/pkg/net/dnsmsg_test.go index 06152a01a..c39dbdb04 100644 --- a/src/pkg/net/dnsmsg_test.go +++ b/src/pkg/net/dnsmsg_test.go @@ -6,6 +6,7 @@ package net import ( "encoding/hex" + "reflect" "testing" ) @@ -19,6 +20,7 @@ func TestDNSParseSRVReply(t *testing.T) { if !ok { t.Fatalf("unpacking packet failed") } + msg.String() // exercise this code path if g, e := len(msg.answer), 5; g != e { t.Errorf("len(msg.answer) = %d; want %d", g, e) } @@ -38,6 +40,16 @@ func TestDNSParseSRVReply(t *testing.T) { t.Errorf("len(addrs) = %d; want %d", g, e) t.Logf("addrs = %#v", addrs) } + // repack and unpack. + data2, ok := msg.Pack() + msg2 := new(dnsMsg) + msg2.Unpack(data2) + switch { + case !ok: + t.Errorf("failed to repack message") + case !reflect.DeepEqual(msg, msg2): + t.Errorf("repacked message differs from original") + } } func TestDNSParseCorruptSRVReply(t *testing.T) { @@ -50,6 +62,7 @@ func TestDNSParseCorruptSRVReply(t *testing.T) { if !ok { t.Fatalf("unpacking packet failed") } + msg.String() // exercise this code path if g, e := len(msg.answer), 5; g != e { t.Errorf("len(msg.answer) = %d; want %d", g, e) } -- cgit v1.2.3