diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-06 19:49:01 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-06 19:49:01 +0000 |
commit | f038dae646bac2b31be98ab592c0e5206d2d96f5 (patch) | |
tree | 39530b071991b2326f881b2a30a2d82d6c133fd6 /libgo/go/net/dnsname_test.go | |
parent | f20f261304993444741e0f0a14d3147e591bc660 (diff) | |
download | gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.zip gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.tar.gz gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.tar.bz2 |
libgo: Update to October 24 version of master library.
From-SVN: r204466
Diffstat (limited to 'libgo/go/net/dnsname_test.go')
-rw-r--r-- | libgo/go/net/dnsname_test.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libgo/go/net/dnsname_test.go b/libgo/go/net/dnsname_test.go index 70df693..57dd25f 100644 --- a/libgo/go/net/dnsname_test.go +++ b/libgo/go/net/dnsname_test.go @@ -5,6 +5,7 @@ package net import ( + "strings" "testing" ) @@ -16,7 +17,6 @@ type testCase struct { var tests = []testCase{ // RFC2181, section 11. {"_xmpp-server._tcp.google.com", true}, - {"_xmpp-server._tcp.google.com", true}, {"foo.com", true}, {"1foo.com", true}, {"26.0.0.73.com", true}, @@ -24,6 +24,10 @@ var tests = []testCase{ {"fo1o.com", true}, {"foo1.com", true}, {"a.b..com", false}, + {"a.b-.com", false}, + {"a.b.com-", false}, + {"a.b..", false}, + {"b.com.", true}, } func getTestCases(ch chan<- testCase) { @@ -63,3 +67,17 @@ func TestDNSNames(t *testing.T) { } } } + +func BenchmarkDNSNames(b *testing.B) { + benchmarks := append(tests, []testCase{ + {strings.Repeat("a", 63), true}, + {strings.Repeat("a", 64), false}, + }...) + for n := 0; n < b.N; n++ { + for _, tc := range benchmarks { + if isDomainName(tc.name) != tc.result { + b.Errorf("isDomainName(%q) = %v; want %v", tc.name, !tc.result, tc.result) + } + } + } +} |