diff options
| author | Earlopain <14981592+Earlopain@users.noreply.github.com> | 2023-12-16 13:58:58 +0100 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-12-25 21:12:49 +0900 |
| commit | 86fa418dea646e52929b9df9163902c4728442d1 (patch) | |
| tree | d4d1e3b815069f71f81ce874390adc168653276e /test | |
| parent | da77c79d80a615130bc67b42d3795db2a3fdd3fe (diff) | |
[ruby/ipaddr] Consider IPv4-mapped IPv6 addresses link local/loopback if IPV4 address is private
Same as #57
https://github.com/ruby/ipaddr/commit/d56acecb80
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_ipaddr.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb index 21843a04e7..4829d9620c 100644 --- a/test/test_ipaddr.rb +++ b/test/test_ipaddr.rb @@ -415,6 +415,12 @@ class TC_Operator < Test::Unit::TestCase assert_equal(true, IPAddr.new('::1').loopback?) assert_equal(false, IPAddr.new('::').loopback?) assert_equal(false, IPAddr.new('3ffe:505:2::1').loopback?) + + assert_equal(true, IPAddr.new('::ffff:127.0.0.1').loopback?) + assert_equal(true, IPAddr.new('::ffff:127.127.1.1').loopback?) + assert_equal(false, IPAddr.new('::ffff:0.0.0.0').loopback?) + assert_equal(false, IPAddr.new('::ffff:192.168.2.0').loopback?) + assert_equal(false, IPAddr.new('::ffff:255.0.0.0').loopback?) end def test_private? @@ -482,6 +488,15 @@ class TC_Operator < Test::Unit::TestCase assert_equal(false, IPAddr.new('fb84:8bf7:e905::1').link_local?) assert_equal(true, IPAddr.new('fe80::dead:beef:cafe:1234').link_local?) + + assert_equal(false, IPAddr.new('::ffff:0.0.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:127.0.0.1').link_local?) + assert_equal(false, IPAddr.new('::ffff:10.0.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:172.16.0.0').link_local?) + assert_equal(false, IPAddr.new('::ffff:192.168.0.0').link_local?) + + assert_equal(true, IPAddr.new('::ffff:169.254.1.1').link_local?) + assert_equal(true, IPAddr.new('::ffff:169.254.254.255').link_local?) end def test_hash |
