OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [dnsname_test.go] - Blame information for rev 848

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// 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.
4
 
5
package net
6
 
7
import (
8
        "testing"
9
)
10
 
11
type testCase struct {
12
        name   string
13
        result bool
14
}
15
 
16
var tests = []testCase{
17
        // RFC2181, section 11.
18
        {"_xmpp-server._tcp.google.com", true},
19
        {"_xmpp-server._tcp.google.com", true},
20
        {"foo.com", true},
21
        {"1foo.com", true},
22
        {"26.0.0.73.com", true},
23
        {"fo-o.com", true},
24
        {"fo1o.com", true},
25
        {"foo1.com", true},
26
        {"a.b..com", false},
27
}
28
 
29
func getTestCases(ch chan<- testCase) {
30
        defer close(ch)
31
        var char59 = ""
32
        var char63 = ""
33
        var char64 = ""
34
        for i := 0; i < 59; i++ {
35
                char59 += "a"
36
        }
37
        char63 = char59 + "aaaa"
38
        char64 = char63 + "a"
39
 
40
        for _, tc := range tests {
41
                ch <- tc
42
        }
43
 
44
        ch <- testCase{char63 + ".com", true}
45
        ch <- testCase{char64 + ".com", false}
46
        // 255 char name is fine:
47
        ch <- testCase{char59 + "." + char63 + "." + char63 + "." +
48
                char63 + ".com",
49
                true}
50
        // 256 char name is bad:
51
        ch <- testCase{char59 + "a." + char63 + "." + char63 + "." +
52
                char63 + ".com",
53
                false}
54
}
55
 
56
func TestDNSNames(t *testing.T) {
57
        ch := make(chan testCase)
58
        go getTestCases(ch)
59
        for tc := range ch {
60
                if isDomainName(tc.name) != tc.result {
61
                        t.Errorf("isDomainName(%v) failed: Should be %v",
62
                                tc.name, tc.result)
63
                }
64
        }
65
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.