Skip to content

Commit

Permalink
net: move TestLookupPort into lookup_test.go
Browse files Browse the repository at this point in the history
No code changes.

Change-Id: Ibbba7c86007d74b853fb59aa742f87783bd69503
Reviewed-on: https://go-review.googlesource.com/16541
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
cixtor committed Nov 21, 2015
1 parent 7e31224 commit 91977d0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 63 deletions.
54 changes: 54 additions & 0 deletions src/net/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package net
import (
"bytes"
"fmt"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -501,3 +502,56 @@ func srvString(srvs []*SRV) string {
fmt.Fprintf(&buf, "]")
return buf.String()
}

var lookupPortTests = []struct {
network string
name string
port int
ok bool
}{
{"tcp", "0", 0, true},
{"tcp", "echo", 7, true},
{"tcp", "discard", 9, true},
{"tcp", "systat", 11, true},
{"tcp", "daytime", 13, true},
{"tcp", "chargen", 19, true},
{"tcp", "ftp-data", 20, true},
{"tcp", "ftp", 21, true},
{"tcp", "telnet", 23, true},
{"tcp", "smtp", 25, true},
{"tcp", "time", 37, true},
{"tcp", "domain", 53, true},
{"tcp", "finger", 79, true},
{"tcp", "42", 42, true},

{"udp", "0", 0, true},
{"udp", "echo", 7, true},
{"udp", "tftp", 69, true},
{"udp", "bootpc", 68, true},
{"udp", "bootps", 67, true},
{"udp", "domain", 53, true},
{"udp", "ntp", 123, true},
{"udp", "snmp", 161, true},
{"udp", "syslog", 514, true},
{"udp", "42", 42, true},

{"--badnet--", "zzz", 0, false},
{"tcp", "--badport--", 0, false},
{"tcp", "-1", 0, false},
{"tcp", "65536", 0, false},
{"udp", "-1", 0, false},
{"udp", "65536", 0, false},
}

func TestLookupPort(t *testing.T) {
switch runtime.GOOS {
case "nacl":
t.Skipf("not supported on %s", runtime.GOOS)
}

for _, tt := range lookupPortTests {
if port, err := LookupPort(tt.network, tt.name); port != tt.port || (err == nil) != tt.ok {
t.Errorf("LookupPort(%q, %q) = %d, %v; want %d", tt.network, tt.name, port, err, tt.port)
}
}
}
63 changes: 0 additions & 63 deletions src/net/port_test.go

This file was deleted.

0 comments on commit 91977d0

Please sign in to comment.