summaryrefslogtreecommitdiff
path: root/test/test_ipaddr.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-10-31 10:06:13 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-10-11 13:50:54 +0900
commit9a321dd9b2fb929873a6b50b41efdf3bd3119536 (patch)
tree469c1870ae05bd2cf524d00dde36f5489aa8a4c8 /test/test_ipaddr.rb
parentb9f7286fe95827631b11342501e471e5e6f13bbb (diff)
[ruby/ipaddr] Make IPAddr#include? consider range of argument
It would be nice to use Range#cover? here, but it doesn't work correctly before Ruby 2.6. Switch to manual checks of the beginning of end of the ranges. Fixes Ruby Bug 14119 https://github.com/ruby/ipaddr/commit/f45630da31
Diffstat (limited to 'test/test_ipaddr.rb')
-rw-r--r--test/test_ipaddr.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb
index 029ad06642..2afe749db3 100644
--- a/test/test_ipaddr.rb
+++ b/test/test_ipaddr.rb
@@ -350,6 +350,8 @@ class TC_Operator < Test::Unit::TestCase
assert_equal(true, net1.include?(IPAddr.new("192.168.2.0")))
assert_equal(true, net1.include?(IPAddr.new("192.168.2.255")))
assert_equal(false, net1.include?(IPAddr.new("192.168.3.0")))
+ assert_equal(true, net1.include?(IPAddr.new("192.168.2.0/28")))
+ assert_equal(false, net1.include?(IPAddr.new("192.168.2.0/16")))
# test with integer parameter
int = (192 << 24) + (168 << 16) + (2 << 8) + 13