Skip to content

Commit

Permalink
do not consider /32 address as being a network address
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ammous committed Jun 28, 2011
1 parent 10c9350 commit 759ab15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ipaddress/ipv4.rb
Expand Up @@ -311,7 +311,7 @@ def broadcast
# #=> true
#
def network?
@u32 | @prefix.to_u32 == @prefix.to_u32
(@prefix < 32) && (@u32 | @prefix.to_u32 == @prefix.to_u32)
end

#
Expand Down
5 changes: 5 additions & 0 deletions test/ipaddress/ipv4_test.rb
Expand Up @@ -144,6 +144,11 @@ def test_method_network?
assert_equal true, @network.network?
assert_equal false, @ip.network?
end

def test_one_address_network
network = @klass.new("172.16.10.1/32")
assert_equal false, network.network?
end

def test_method_broadcast
@broadcast.each do |addr,bcast|
Expand Down

0 comments on commit 759ab15

Please sign in to comment.