summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/miekg/dns/sanitize_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/miekg/dns/sanitize_test.go')
-rw-r--r--vendor/github.com/miekg/dns/sanitize_test.go51
1 files changed, 21 insertions, 30 deletions
diff --git a/vendor/github.com/miekg/dns/sanitize_test.go b/vendor/github.com/miekg/dns/sanitize_test.go
index 2ba3fe9a3..b2c0e2081 100644
--- a/vendor/github.com/miekg/dns/sanitize_test.go
+++ b/vendor/github.com/miekg/dns/sanitize_test.go
@@ -3,37 +3,36 @@ package dns
import "testing"
func TestDedup(t *testing.T) {
- // make it []string
testcases := map[[3]RR][]string{
[...]RR{
- newRR(t, "mIek.nl. IN A 127.0.0.1"),
- newRR(t, "mieK.nl. IN A 127.0.0.1"),
- newRR(t, "miek.Nl. IN A 127.0.0.1"),
+ testRR("mIek.nl. IN A 127.0.0.1"),
+ testRR("mieK.nl. IN A 127.0.0.1"),
+ testRR("miek.Nl. IN A 127.0.0.1"),
}: {"mIek.nl.\t3600\tIN\tA\t127.0.0.1"},
[...]RR{
- newRR(t, "miEk.nl. 2000 IN A 127.0.0.1"),
- newRR(t, "mieK.Nl. 1000 IN A 127.0.0.1"),
- newRR(t, "Miek.nL. 500 IN A 127.0.0.1"),
+ testRR("miEk.nl. 2000 IN A 127.0.0.1"),
+ testRR("mieK.Nl. 1000 IN A 127.0.0.1"),
+ testRR("Miek.nL. 500 IN A 127.0.0.1"),
}: {"miEk.nl.\t500\tIN\tA\t127.0.0.1"},
[...]RR{
- newRR(t, "miek.nl. IN A 127.0.0.1"),
- newRR(t, "miek.nl. CH A 127.0.0.1"),
- newRR(t, "miek.nl. IN A 127.0.0.1"),
+ testRR("miek.nl. IN A 127.0.0.1"),
+ testRR("miek.nl. CH A 127.0.0.1"),
+ testRR("miek.nl. IN A 127.0.0.1"),
}: {"miek.nl.\t3600\tIN\tA\t127.0.0.1",
"miek.nl.\t3600\tCH\tA\t127.0.0.1",
},
[...]RR{
- newRR(t, "miek.nl. CH A 127.0.0.1"),
- newRR(t, "miek.nl. IN A 127.0.0.1"),
- newRR(t, "miek.de. IN A 127.0.0.1"),
+ testRR("miek.nl. CH A 127.0.0.1"),
+ testRR("miek.nl. IN A 127.0.0.1"),
+ testRR("miek.de. IN A 127.0.0.1"),
}: {"miek.nl.\t3600\tCH\tA\t127.0.0.1",
"miek.nl.\t3600\tIN\tA\t127.0.0.1",
"miek.de.\t3600\tIN\tA\t127.0.0.1",
},
[...]RR{
- newRR(t, "miek.de. IN A 127.0.0.1"),
- newRR(t, "miek.nl. 200 IN A 127.0.0.1"),
- newRR(t, "miek.nl. 300 IN A 127.0.0.1"),
+ testRR("miek.de. IN A 127.0.0.1"),
+ testRR("miek.nl. 200 IN A 127.0.0.1"),
+ testRR("miek.nl. 300 IN A 127.0.0.1"),
}: {"miek.de.\t3600\tIN\tA\t127.0.0.1",
"miek.nl.\t200\tIN\tA\t127.0.0.1",
},
@@ -51,9 +50,9 @@ func TestDedup(t *testing.T) {
func BenchmarkDedup(b *testing.B) {
rrs := []RR{
- newRR(nil, "miEk.nl. 2000 IN A 127.0.0.1"),
- newRR(nil, "mieK.Nl. 1000 IN A 127.0.0.1"),
- newRR(nil, "Miek.nL. 500 IN A 127.0.0.1"),
+ testRR("miEk.nl. 2000 IN A 127.0.0.1"),
+ testRR("mieK.Nl. 1000 IN A 127.0.0.1"),
+ testRR("Miek.nL. 500 IN A 127.0.0.1"),
}
m := make(map[string]RR)
for i := 0; i < b.N; i++ {
@@ -63,9 +62,9 @@ func BenchmarkDedup(b *testing.B) {
func TestNormalizedString(t *testing.T) {
tests := map[RR]string{
- newRR(t, "mIEk.Nl. 3600 IN A 127.0.0.1"): "miek.nl.\tIN\tA\t127.0.0.1",
- newRR(t, "m\\ iek.nL. 3600 IN A 127.0.0.1"): "m\\ iek.nl.\tIN\tA\t127.0.0.1",
- newRR(t, "m\\\tIeK.nl. 3600 in A 127.0.0.1"): "m\\009iek.nl.\tIN\tA\t127.0.0.1",
+ testRR("mIEk.Nl. 3600 IN A 127.0.0.1"): "miek.nl.\tIN\tA\t127.0.0.1",
+ testRR("m\\ iek.nL. 3600 IN A 127.0.0.1"): "m\\ iek.nl.\tIN\tA\t127.0.0.1",
+ testRR("m\\\tIeK.nl. 3600 in A 127.0.0.1"): "m\\009iek.nl.\tIN\tA\t127.0.0.1",
}
for tc, expected := range tests {
n := normalizedString(tc)
@@ -74,11 +73,3 @@ func TestNormalizedString(t *testing.T) {
}
}
}
-
-func newRR(t *testing.T, s string) RR {
- r, err := NewRR(s)
- if err != nil {
- t.Logf("newRR: %v", err)
- }
- return r
-}