Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def ~

# Returns true if two ipaddrs are equal.
def ==(other)
if other.nil?
return false
end

other = coerce_other(other)
rescue
false
Expand Down
2 changes: 2 additions & 0 deletions test/test_ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ def test_equal
assert_equal(false, @a != IPAddr.new("3ffe:505:2::"))
assert_equal(false, @a == @inconvertible_range)
assert_equal(false, @a == @inconvertible_string)
assert_equal(false, IPAddr.new("0.0.0.0") == nil)
assert_equal(false, IPAddr.new("::") == nil)
end

def test_compare
Expand Down