diff options
author | bluemonk <ceresa@gmail.com> | 2011-05-10 22:04:13 +0200 |
---|---|---|
committer | bluemonk <ceresa@gmail.com> | 2011-05-10 22:04:13 +0200 |
commit | 05d1cc71bfa12bfdfe1bf61afed1b0fc78449531 (patch) | |
tree | 0cc6f1a423ffb6001a5228afcd9c338a9199f510 /test | |
parent | dba60ba1b34db3d817ef20158e2cb2d7e2e3f34d (diff) | |
download | ipaddress-05d1cc71bfa12bfdfe1bf61afed1b0fc78449531.tar.gz |
Added IPv6#each, IPv6#broadcast_u128 and Prefix128#host_prefix
Diffstat (limited to 'test')
-rw-r--r-- | test/ipaddress/ipv6_test.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/ipaddress/ipv6_test.rb b/test/ipaddress/ipv6_test.rb index 4c84e4b..898938f 100644 --- a/test/ipaddress/ipv6_test.rb +++ b/test/ipaddress/ipv6_test.rb @@ -127,7 +127,22 @@ class IPv6Test < Test::Unit::TestCase def test_method_network_u128 assert_equal 42540766411282592856903984951653826560, @ip.network_u128 end - + + def test_method_broadcast_u128 + assert_equal 42540766411282592875350729025363378175, @ip.broadcast_u128 + end + + def test_method_size + ip = @klass.new("2001:db8::8:800:200c:417a/64") + assert_equal 2**64, ip.size + ip = @klass.new("2001:db8::8:800:200c:417a/32") + assert_equal 2**96, ip.size + ip = @klass.new("2001:db8::8:800:200c:417a/120") + assert_equal 2**8, ip.size + ip = @klass.new("2001:db8::8:800:200c:417a/124") + assert_equal 2**4, ip.size + end + def test_method_include? assert_equal true, @ip.include?(@ip) # test prefix on same address @@ -199,6 +214,16 @@ class IPv6Test < Test::Unit::TestCase assert_equal net, ip.network.to_string end end + + def test_method_each + ip = @klass.new("2001:db8::4/125") + arr = [] + ip.each {|i| arr << i.compressed} + expected = ["2001:db8::","2001:db8::1","2001:db8::2", + "2001:db8::3","2001:db8::4","2001:db8::5", + "2001:db8::6","2001:db8::7"] + assert_equal expected, arr + end def test_classmethod_expand compressed = "2001:db8:0:cd30::" |