summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrancis Luong (Franco) <franco@definefunk.com>2017-08-30 07:46:53 -0400
committerGitHub <noreply@github.com>2017-08-30 07:46:53 -0400
commit9dedeaf13caddb1827a48091c353c8f953b517ac (patch)
treef4347c4d451e147661ea01d93aebc6eac6b053ff /test
parent032e8247f7840a490b226d6fbee89b4799b88660 (diff)
parente5c9039420d0d38e066aa2f81c46cba698d7803a (diff)
downloadipaddress-9dedeaf13caddb1827a48091c353c8f953b517ac.tar.gz
Merge pull request #76 from smortex/spaceship_compare
Fix <=> for IPv4 and IPv6.
Diffstat (limited to 'test')
-rw-r--r--test/ipaddress/ipv4_test.rb6
-rw-r--r--test/ipaddress/ipv6_test.rb6
2 files changed, 12 insertions, 0 deletions
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index 19264e2..33b3a31 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -372,6 +372,12 @@ class IPv4Test < Minitest::Test
ip3 = @klass.new("10.0.0.0/8")
arr = ["10.0.0.0/8","10.0.0.0/16","10.0.0.0/24"]
assert_equal arr, [ip1,ip2,ip3].sort.map{|s| s.to_string}
+ # compare with alien thing
+ ip1 = @klass.new('127.0.0.1')
+ ip2 = IPAddress::IPv6.new('::1')
+ not_ip = String
+ assert_equal nil, ip1 <=> ip2
+ assert_equal nil, ip1 <=> not_ip
end
def test_method_minus
diff --git a/test/ipaddress/ipv6_test.rb b/test/ipaddress/ipv6_test.rb
index 7eaa765..3c3da90 100644
--- a/test/ipaddress/ipv6_test.rb
+++ b/test/ipaddress/ipv6_test.rb
@@ -260,6 +260,12 @@ class IPv6Test < Minitest::Test
arr = ["2001:db8:1::1/64","2001:db8:1::1/65",
"2001:db8:1::2/64","2001:db8:2::1/64"]
assert_equal arr, [ip1,ip2,ip3,ip4].sort.map{|s| s.to_string}
+ # compare with alien thing
+ ip1 = @klass.new('::1')
+ ip2 = IPAddress::IPv4.new('127.0.0.1')
+ not_ip = String
+ assert_equal nil, ip1 <=> ip2
+ assert_equal nil, ip1 <=> not_ip
end
def test_classmethod_expand