summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-01 07:49:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-01 07:49:31 +0000
commit79060f6116545135339d75f2f6f24e5e474536c0 (patch)
tree968a89c07b8213fc3e0e30202efed808e8992633 /test
parent2c7632c603af4e97994521561250ae305d98077c (diff)
downloadruby-79060f6116545135339d75f2f6f24e5e474536c0.tar.gz
ruby-79060f6116545135339d75f2f6f24e5e474536c0.tar.xz
ruby-79060f6116545135339d75f2f6f24e5e474536c0.zip
* ext/socket/mkconstants.rb: generate family_to_int().
* ext/socket/socket.c (setup_domain_and_type): use family_to_int. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/socket/test_socket.rb13
-rw-r--r--test/socket/test_unix.rb14
2 files changed, 27 insertions, 0 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 90f1037db..3133590ab 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 5b041f173..853fb28ef 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