summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 15:34:32 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 15:34:32 +0000
commit3eab19122b1647f8f0c14786c71fdeda8e978039 (patch)
tree65ec5a4206a591defda9f30ce095dd7358ab7f27 /test
parente2f0aeb4973c81a54d38295bafc9d5b48cb0b3ef (diff)
add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/socket/test_addrinfo.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb
index 55e8183448..8ddbb06985 100644
--- a/test/socket/test_addrinfo.rb
+++ b/test/socket/test_addrinfo.rb
@@ -4,9 +4,10 @@ rescue LoadError
end
require "test/unit"
-require "tempfile"
class TestSocketAddrInfo < Test::Unit::TestCase
+ HAS_UNIXSOCKET = defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM
+
def test_addrinfo_ip
ai = AddrInfo.ip("127.0.0.1")
assert_equal([0, "127.0.0.1"], Socket.unpack_sockaddr_in(ai))
@@ -512,9 +513,22 @@ class TestSocketAddrInfo < Test::Unit::TestCase
}
end
+ def test_ipv6_to_ipv4
+ ai = AddrInfo.ip("::192.0.2.3").ipv6_to_ipv4
+ assert(ai.ipv4?)
+ assert_equal("192.0.2.3", ai.ip_address)
+ ai = AddrInfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4
+ assert(ai.ipv4?)
+ assert_equal("192.0.2.3", ai.ip_address)
+ assert_nil(AddrInfo.ip("::1").ipv6_to_ipv4)
+ assert_nil(AddrInfo.ip("192.0.2.3").ipv6_to_ipv4)
+ if HAS_UNIXSOCKET
+ assert_nil(AddrInfo.unix("/tmp/sock").ipv6_to_ipv4)
+ end
+ end
end
- if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM
+ if HAS_UNIXSOCKET
def test_addrinfo_unix
ai = AddrInfo.unix("/tmp/sock")