Skip to content

Commit 8394c5f

Browse files
author
Skorobogaty Dmitry
committed
test for subtraction
1 parent 786b6c1 commit 8394c5f

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

test/ipaddress/ipv4_test.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,16 @@ def test_method_split
481481
end
482482

483483
def test_method_subnet
484-
assert_raises(ArgumentError) {@network.subnet(23)}
485-
assert_raises(ArgumentError) {@network.subnet(33)}
486-
arr = ["172.16.10.0/26", "172.16.10.64/26", "172.16.10.128/26",
487-
"172.16.10.192/26"]
488-
assert_equal arr, @network.subnet(26).map {|s| s.to_string}
489-
arr = ["172.16.10.0/25", "172.16.10.128/25"]
490-
assert_equal arr, @network.subnet(25).map {|s| s.to_string}
491-
arr = ["172.16.10.0/24"]
492-
assert_equal arr, @network.subnet(24).map {|s| s.to_string}
484+
end
485+
486+
def test_method_subtract
487+
a = IPAddress '10.0.0.0/16'
488+
b = IPAddress '10.0.128.0/18'
489+
c = IPAddress '192.168.0.0/16'
490+
491+
assert !a.subtract(b).include?(b)
492+
assert b.subtract(a).empty?
493+
assert_equal a, a.subtract(c).first
493494
end
494495

495496
def test_method_supernet

0 commit comments

Comments
 (0)