diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-02 10:59:17 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-02 10:59:17 +0000 |
commit | 352dcd9ee75818eaefbb3fce2df822b840bf24bc (patch) | |
tree | 0589e38655704c6a25ebf78de70b09641e79d2e4 /test | |
parent | 765a6be7008d0eba3f374d9e9875aa9e65ea4112 (diff) | |
download | ruby-352dcd9ee75818eaefbb3fce2df822b840bf24bc.tar.gz |
* test/socket/test_addrinfo.rb: use AddrInfo.getaddrinfo to generate
IPv6 address. AddrInfo.ip generates IPv4 address for IPv4 mapped
IPv6 address if --with-lookup-order-hack=INET.
[ruby-dev:37868]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/socket/test_addrinfo.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb index 851e5a11ea..a8e1dc7f21 100644 --- a/test/socket/test_addrinfo.rb +++ b/test/socket/test_addrinfo.rb @@ -345,6 +345,10 @@ class TestSocketAddrInfo < Test::Unit::TestCase assert_equal(ai1.canonname, ai2.canonname) end + def ipv6(str) + AddrInfo.getaddrinfo(str, nil, :INET6, :DGRAM).fetch(0) + end + def test_ipv6_address_predicates list = [ [:ipv6_unspecified?, "::"], @@ -364,24 +368,26 @@ class TestSocketAddrInfo < Test::Unit::TestCase ] list.each {|meth, *addrs| addrs.each {|addr| - assert(AddrInfo.ip(addr).send(meth), "AddrInfo.ip(#{addr.inspect}).#{meth}") + addr_exp = "AddrInfo.getaddrinfo(#{addr.inspect}, nil, :INET6, :DGRAM).fetch(0)" + assert(ipv6(addr).send(meth), "#{addr_exp}.#{meth}") list.each {|meth2,| next if meth == meth2 - assert(!AddrInfo.ip(addr).send(meth2), "!AddrInfo.ip(#{addr.inspect}).#{meth2}") + assert(!ipv6(addr).send(meth2), "!#{addr_exp}.#{meth2}") } } } mlist.each {|meth, *addrs| addrs.each {|addr| - assert(AddrInfo.ip(addr).send(meth), "AddrInfo.ip(#{addr.inspect}).#{meth}") - assert(AddrInfo.ip(addr).ipv6_multicast?, "AddrInfo.ip(#{addr.inspect}).ipv6_multicast?") + addr_exp = "AddrInfo.getaddrinfo(#{addr.inspect}, nil, :INET6, :DGRAM).fetch(0)" + assert(ipv6(addr).send(meth), "#{addr_exp}.#{meth}") + assert(ipv6(addr).ipv6_multicast?, "#{addr_exp}.ipv6_multicast?") mlist.each {|meth2,| next if meth == meth2 - assert(!AddrInfo.ip(addr).send(meth2), "!AddrInfo.ip(#{addr.inspect}).#{meth2}") + assert(!ipv6(addr).send(meth2), "!#{addr_exp}.#{meth2}") } list.each {|meth2,| next if :ipv6_multicast? == meth2 - assert(!AddrInfo.ip(addr).send(meth2), "!AddrInfo.ip(#{addr.inspect}).#{meth2}") + assert(!ipv6(addr).send(meth2), "!#{addr_exp}.#{meth2}") } } } |