diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-01 07:49:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-01 07:49:31 +0000 |
commit | 0c838b4947a36ea0f706dfbd131b92de9a7b18a3 (patch) | |
tree | 968a89c07b8213fc3e0e30202efed808e8992633 /test | |
parent | 30f3c8c70bbfab845ea8db868e961f9482bf637f (diff) | |
download | ruby-0c838b4947a36ea0f706dfbd131b92de9a7b18a3.tar.gz |
* ext/socket/mkconstants.rb: generate family_to_int().
* ext/socket/socket.c (setup_domain_and_type): use family_to_int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/socket/test_socket.rb | 13 | ||||
-rw-r--r-- | test/socket/test_unix.rb | 14 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index 90f1037db8..3133590ab1 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -97,4 +97,17 @@ class TestSocket < Test::Unit::TestCase c.close if c IO.for_fd(fd).close if fd end + + def test_initialize + Socket.open(Socket::AF_INET, Socket::SOCK_STREAM, 0) {|s| + addr = s.getsockname + assert_nothing_raised { Socket.unpack_sockaddr_in(addr) } + assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) } + } + Socket.open("AF_INET", "SOCK_STREAM", 0) {|s| + addr = s.getsockname + assert_nothing_raised { Socket.unpack_sockaddr_in(addr) } + assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) } + } + end end if defined?(Socket) diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index 5b041f1733..853fb28ef5 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -166,4 +166,18 @@ class TestUNIXSocket < Test::Unit::TestCase assert_kind_of(UNIXSocket, pair[1]) end + def test_initialize + Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s| + addr = s.getsockname + assert_nothing_raised { Socket.unpack_sockaddr_un(addr) } + assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) } + } + Socket.open("AF_UNIX", "SOCK_STREAM", 0) {|s| + addr = s.getsockname + assert_nothing_raised { Socket.unpack_sockaddr_un(addr) } + assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) } + } + end + + end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM |