From c1ad186588cbda5df8159fe15fb21a37dde87012 Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Thu, 29 Nov 2018 09:48:02 +1030 Subject: [PATCH] Use compressionMapsEqual in TestPackDomainNameCompressionMap --- msg_test.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/msg_test.go b/msg_test.go index 0d8e5196..c8ff41d3 100644 --- a/msg_test.go +++ b/msg_test.go @@ -214,8 +214,15 @@ func TestUnpackDomainName(t *testing.T) { } func TestPackDomainNameCompressionMap(t *testing.T) { - msg := make([]byte, 256) + expected := map[string]struct{}{ + `www.this.is.\131an.example.org.`: struct{}{}, + `is.\131an.example.org.`: struct{}{}, + "\x83an.example.org.": struct{}{}, + `example.org.`: struct{}{}, + `org.`: struct{}{}, + } + msg := make([]byte, 256) for _, compress := range []bool{true, false} { compression := make(map[string]int) @@ -224,16 +231,8 @@ func TestPackDomainNameCompressionMap(t *testing.T) { t.Fatalf("PackDomainName failed: %v", err) } - for _, dname := range []string{ - `www.this.is.\131an.example.org.`, - `is.\131an.example.org.`, - "\x83an.example.org.", - `example.org.`, - `org.`, - } { - if _, ok := compression[dname]; !ok { - t.Errorf("expected to find %q in compression map", dname) - } + if !compressionMapsEqual(expected, compression) { + t.Errorf("expected compression maps to be equal; expected %v, got %v", expected, compression) } } }