1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 type testCase struct {
16 var tests = []testCase{
17 // RFC2181, section 11.
18 {"_xmpp-server._tcp.google.com", true},
19 {"_xmpp-server._tcp.google.com", true},
22 {"26.0.0.73.com", true},
29 func getTestCases(ch chan<- testCase) {
34 for i := 0; i < 59; i++ {
37 char63 = char59 + "aaaa"
40 for _, tc := range tests {
44 ch <- testCase{char63 + ".com", true}
45 ch <- testCase{char64 + ".com", false}
46 // 255 char name is fine:
47 ch <- testCase{char59 + "." + char63 + "." + char63 + "." +
50 // 256 char name is bad:
51 ch <- testCase{char59 + "a." + char63 + "." + char63 + "." +
56 func TestDNSNames(t *testing.T) {
57 ch := make(chan testCase)
60 if isDomainName(tc.name) != tc.result {
61 t.Errorf("isDomainName(%v) failed: Should be %v",