Commit 59e6ceb5 authored by Matthew Holt's avatar Matthew Holt

Minor test cleanup

parent 82929b12
...@@ -67,7 +67,6 @@ func TestListenerAddrEqual(t *testing.T) { ...@@ -67,7 +67,6 @@ func TestListenerAddrEqual(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
defer ln1.Close() defer ln1.Close()
ln1port := strconv.Itoa(ln1.Addr().(*net.TCPAddr).Port) ln1port := strconv.Itoa(ln1.Addr().(*net.TCPAddr).Port)
ln2, err := net.Listen("tcp", "127.0.0.1:0") ln2, err := net.Listen("tcp", "127.0.0.1:0")
...@@ -75,7 +74,6 @@ func TestListenerAddrEqual(t *testing.T) { ...@@ -75,7 +74,6 @@ func TestListenerAddrEqual(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
defer ln2.Close() defer ln2.Close()
ln2port := strconv.Itoa(ln2.Addr().(*net.TCPAddr).Port) ln2port := strconv.Itoa(ln2.Addr().(*net.TCPAddr).Port)
for i, test := range []struct { for i, test := range []struct {
...@@ -86,12 +84,12 @@ func TestListenerAddrEqual(t *testing.T) { ...@@ -86,12 +84,12 @@ func TestListenerAddrEqual(t *testing.T) {
{ln1, ":1234", false}, {ln1, ":1234", false},
{ln1, "0.0.0.0:1234", false}, {ln1, "0.0.0.0:1234", false},
{ln1, "0.0.0.0", false}, {ln1, "0.0.0.0", false},
{ln1, ":" + ln1port + "", true}, {ln1, ":" + ln1port, true},
{ln1, "0.0.0.0:" + ln1port + "", true}, {ln1, "0.0.0.0:" + ln1port, true},
{ln2, ":" + ln2port + "", false}, {ln2, ":" + ln2port, false},
{ln2, "127.0.0.1:1234", false}, {ln2, "127.0.0.1:1234", false},
{ln2, "127.0.0.1", false}, {ln2, "127.0.0.1", false},
{ln2, "127.0.0.1:" + ln2port + "", true}, {ln2, "127.0.0.1:" + ln2port, true},
} { } {
if got, want := listenerAddrEqual(test.ln, test.addr), test.expect; got != want { if got, want := listenerAddrEqual(test.ln, test.addr), test.expect; got != want {
t.Errorf("Test %d (%s == %s): expected %v but was %v", i, test.addr, test.ln.Addr().String(), want, got) t.Errorf("Test %d (%s == %s): expected %v but was %v", i, test.addr, test.ln.Addr().String(), want, got)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment