summaryrefslogtreecommitdiff
path: root/test/test_ipaddr.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-12-02 10:56:39 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-02-10 17:18:05 +0900
commit100253c7f0f4d105ae88340a0314506cde69cfd2 (patch)
tree2e839fd73cb3452aadc3be865baaf68cd24aef79 /test/test_ipaddr.rb
parent5221cb4468526a18875c21cff5dee5ac96d9873b (diff)
downloadruby-100253c7f0f4d105ae88340a0314506cde69cfd2.tar.gz
[ruby/ipaddr] Ipaddr#native must also coerce `@mask_addr`
Before it would be left as an IPv6 mask causing `to_range` to fail. ``` >> IPAddr.new("::2").native.to_range /opt/rubies/3.0.3/lib/ruby/3.0.0/ipaddr.rb:479:in `set': invalid address (IPAddr::InvalidAddressError) ``` https://github.com/ruby/ipaddr/commit/af485192f3
Diffstat (limited to 'test/test_ipaddr.rb')
-rw-r--r--test/test_ipaddr.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb
index 2afe749db3..bd163283b2 100644
--- a/test/test_ipaddr.rb
+++ b/test/test_ipaddr.rb
@@ -360,6 +360,11 @@ class TC_Operator < Test::Unit::TestCase
end
+ def test_native_coerce_mask_addr
+ assert_equal(IPAddr.new("0.0.0.2/255.255.255.255"), IPAddr.new("::2").native)
+ assert_equal(IPAddr.new("0.0.0.2/255.255.255.255").to_range, IPAddr.new("::2").native.to_range)
+ end
+
def test_loopback?
assert_equal(true, IPAddr.new('127.0.0.1').loopback?)
assert_equal(true, IPAddr.new('127.127.1.1').loopback?)