зеркало из https://github.com/github/ruby.git
add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0f82f65cee
Коммит
7f247b9d0c
|
@ -209,7 +209,40 @@ class TestSocket < Test::Unit::TestCase
|
|||
ensure
|
||||
servers.each {|s| s.close if !s.closed? }
|
||||
end
|
||||
end
|
||||
|
||||
def test_accept_loop_multi_port
|
||||
servers = []
|
||||
begin
|
||||
servers = Socket.tcp_server_sockets(0)
|
||||
port = servers[0].local_address.ip_port
|
||||
servers2 = Socket.tcp_server_sockets(0)
|
||||
servers.concat servers2
|
||||
port2 = servers2[0].local_address.ip_port
|
||||
|
||||
Socket.tcp("localhost", port) {|s1|
|
||||
Socket.accept_loop(servers) {|s2, client_ai|
|
||||
begin
|
||||
assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack)
|
||||
ensure
|
||||
s2.close
|
||||
end
|
||||
break
|
||||
}
|
||||
}
|
||||
Socket.tcp("localhost", port2) {|s1|
|
||||
Socket.accept_loop(servers) {|s2, client_ai|
|
||||
begin
|
||||
assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack)
|
||||
ensure
|
||||
s2.close
|
||||
end
|
||||
break
|
||||
}
|
||||
}
|
||||
ensure
|
||||
servers.each {|s| s.close if !s.closed? }
|
||||
end
|
||||
end
|
||||
|
||||
def test_udp_server
|
||||
|
|
Загрузка…
Ссылка в новой задаче