Skip to content
Snippets Groups Projects
Commit 09bde2a5 authored by Mike Mackintosh's avatar Mike Mackintosh
Browse files

added bugfix/40 fix with test

parent f562a7f7
No related branches found
No related tags found
No related merge requests found
......@@ -1026,12 +1026,9 @@ module IPAddress;
#
private
# Tweaked to remove the #upto(32)
def newprefix(num)
num.upto(32) do |i|
if (a = Math::log2(i).to_i) == Math::log2(i)
return @prefix + a
end
end
return @prefix + (Math::log2(num).to_i)
end
def sum_first_found(arr)
......
......@@ -542,6 +542,15 @@ class IPv4Test < Minitest::Test
assert_raises(ArgumentError){ @klass.parse_classful("192.168.256.257") }
end
def test_network_split
@classful.each do |ip,net|
x = @klass.new("#{ip}/#{net}")
assert_equal x.split(1).length, 1
assert_equal x.split(2).length, 2
assert_equal x.split(32).length, 32
assert_equal x.split(256).length, 256
end
end
end # class IPv4Test
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment