Commit 72dbc4cc authored by Mikio Hara's avatar Mikio Hara

net: drop unnecessary indirection from PacketConn tests

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/83880043
parent 22bc710f
......@@ -15,12 +15,6 @@ import (
"time"
)
func strfunc(s string) func() string {
return func() string {
return s
}
}
func packetConnTestData(t *testing.T, net string, i int) ([]byte, func()) {
switch net {
case "udp":
......@@ -62,12 +56,12 @@ func packetConnTestData(t *testing.T, net string, i int) ([]byte, func()) {
var packetConnTests = []struct {
net string
addr1 func() string
addr2 func() string
addr1 string
addr2 string
}{
{"udp", strfunc("127.0.0.1:0"), strfunc("127.0.0.1:0")},
{"ip:icmp", strfunc("127.0.0.1"), strfunc("127.0.0.1")},
{"unixgram", testUnixAddr, testUnixAddr},
{"udp", "127.0.0.1:0", "127.0.0.1:0"},
{"ip:icmp", "127.0.0.1", "127.0.0.1"},
{"unixgram", testUnixAddr(), testUnixAddr()},
}
func TestPacketConn(t *testing.T) {
......@@ -88,22 +82,21 @@ func TestPacketConn(t *testing.T) {
continue
}
addr1, addr2 := tt.addr1(), tt.addr2()
c1, err := ListenPacket(tt.net, addr1)
c1, err := ListenPacket(tt.net, tt.addr1)
if err != nil {
t.Fatalf("ListenPacket failed: %v", err)
}
defer closer(c1, netstr[0], addr1, addr2)
defer closer(c1, netstr[0], tt.addr1, tt.addr2)
c1.LocalAddr()
c1.SetDeadline(time.Now().Add(100 * time.Millisecond))
c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
c2, err := ListenPacket(tt.net, addr2)
c2, err := ListenPacket(tt.net, tt.addr2)
if err != nil {
t.Fatalf("ListenPacket failed: %v", err)
}
defer closer(c2, netstr[0], addr1, addr2)
defer closer(c2, netstr[0], tt.addr1, tt.addr2)
c2.LocalAddr()
c2.SetDeadline(time.Now().Add(100 * time.Millisecond))
c2.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
......@@ -145,12 +138,11 @@ func TestConnAndPacketConn(t *testing.T) {
continue
}
addr1, addr2 := tt.addr1(), tt.addr2()
c1, err := ListenPacket(tt.net, addr1)
c1, err := ListenPacket(tt.net, tt.addr1)
if err != nil {
t.Fatalf("ListenPacket failed: %v", err)
}
defer closer(c1, netstr[0], addr1, addr2)
defer closer(c1, netstr[0], tt.addr1, tt.addr2)
c1.LocalAddr()
c1.SetDeadline(time.Now().Add(100 * time.Millisecond))
c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
......
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