summaryrefslogtreecommitdiff
path: root/test/test_ipaddr.rb
diff options
context:
space:
mode:
authorEspartaco Palma <git@esparta.co>2021-12-13 01:12:07 -0800
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-02-10 17:18:05 +0900
commit9b768012f6bf5b5896d2d34feb69605d4ccc9ca3 (patch)
treefdc207e902f30614ed3556e78de9eb06cb43c474 /test/test_ipaddr.rb
parent100253c7f0f4d105ae88340a0314506cde69cfd2 (diff)
[ruby/ipaddr] Fix exception calling `to_range' after `freeze'
https://github.com/ruby/ipaddr/commit/77fe1fca0a
Diffstat (limited to 'test/test_ipaddr.rb')
-rw-r--r--test/test_ipaddr.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb
index bd163283b2..c07ee2a8ee 100644
--- a/test/test_ipaddr.rb
+++ b/test/test_ipaddr.rb
@@ -255,6 +255,28 @@ class TC_IPAddr < Test::Unit::TestCase
assert_equal("1:2:3:4:5:6:7:8%ab0", a.to_s)
assert_raise(IPAddr::InvalidAddressError) { a.zone_id = '%' }
end
+
+ def test_to_range
+ a1 = IPAddr.new("127.0.0.1")
+ range = a1..a1
+ assert_equal(range, a1.to_range)
+ assert_equal(range, a1.freeze.to_range)
+
+ a2 = IPAddr.new("192.168.0.1/16")
+ range = IPAddr.new("192.168.0.0")..IPAddr.new("192.168.255.255")
+ assert_equal(range, a2.to_range)
+ assert_equal(range, a2.freeze.to_range)
+
+ a3 = IPAddr.new("3ffe:505:2::1")
+ range = a3..a3
+ assert_equal(range, a3.to_range)
+ assert_equal(range, a3.freeze.to_range)
+
+ a4 = IPAddr.new("::ffff/127")
+ range = IPAddr.new("::fffe")..IPAddr.new("::ffff")
+ assert_equal(range, a4.to_range)
+ assert_equal(range, a4.freeze.to_range)
+ end
end
class TC_Operator < Test::Unit::TestCase