summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbluemonk <ceresa@gmail.com>2011-03-27 16:16:45 +0200
committerbluemonk <ceresa@gmail.com>2011-03-27 16:16:45 +0200
commitf34b5cdf6ca6c49042d02f09c6dc33f47f1718be (patch)
tree4b17df09f388739b11a498e389a20a8e68a0ab31 /test
parentbd5f741440529ca7aed72b0fcf772adc6c229b52 (diff)
downloadipaddress-f34b5cdf6ca6c49042d02f09c6dc33f47f1718be.tar.gz
Added #ipv4? and #ipv6? methods
Diffstat (limited to 'test')
-rw-r--r--test/ipaddress/ipv4_test.rb8
-rw-r--r--test/ipaddress/ipv6_test.rb38
2 files changed, 29 insertions, 17 deletions
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index 7d94144..d983543 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -248,6 +248,14 @@ class IPv4Test < Test::Unit::TestCase
assert_equal false, ip.include_all?(addr1, @klass.new("13.16.0.0/32"))
end
+ def test_method_ipv4?
+ assert_equal true, @ip.ipv4?
+ end
+
+ def test_method_ipv6?
+ assert_equal false, @ip.ipv6?
+ end
+
def test_method_private?
assert_equal true, @klass.new("192.168.10.50/24").private?
assert_equal true, @klass.new("192.168.10.50/16").private?
diff --git a/test/ipaddress/ipv6_test.rb b/test/ipaddress/ipv6_test.rb
index e46a6b2..84be76c 100644
--- a/test/ipaddress/ipv6_test.rb
+++ b/test/ipaddress/ipv6_test.rb
@@ -106,6 +106,14 @@ class IPv6Test < Test::Unit::TestCase
end
end
+ def test_method_ipv4?
+ assert_equal false, @ip.ipv4?
+ end
+
+ def test_method_ipv6?
+ assert_equal true, @ip.ipv6?
+ end
+
def test_method_network?
assert_equal true, @network.network?
assert_equal false, @ip.network?
@@ -197,22 +205,6 @@ class IPv6Test < Test::Unit::TestCase
assert_not_equal compressed, @klass.compress("2001:0db8::cd3")
end
-# def test_classmethod_create_unpecified
-# unspec = @klass.create_unspecified
-# assert_equal "::", unspec.address
-# assert_equal 128, unspec.prefix
-# assert_equal true, unspec.unspecified?
-# assert_instance_of @klass, unspec.class
-# end
-
-# def test_classmethod_create_loopback
-# loopb = @klass.create_loopback
-# assert_equal "::1", loopb.address
-# assert_equal 128, loopb.prefix
-# assert_equal true, loopb.loopback?
-# assert_instance_of @klass, loopb.class
-# end
-
def test_classmethod_parse_data
str = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
ip = @klass.parse_data str
@@ -231,7 +223,7 @@ class IPv6Test < Test::Unit::TestCase
assert_equal @ip.to_s, @klass.parse_hex(@hex,64).to_s
end
-end # class IPv4Test
+end # class IPv6Test
class IPv6UnspecifiedTest < Test::Unit::TestCase
@@ -259,6 +251,10 @@ class IPv6UnspecifiedTest < Test::Unit::TestCase
assert_equal @string, @ip.to_string_uncompressed
assert_equal @u128, @ip.to_u128
end
+
+ def test_method_ipv6?
+ assert_equal true, @ip.ipv6?
+ end
end # class IPv6UnspecifiedTest
@@ -289,6 +285,10 @@ class IPv6LoopbackTest < Test::Unit::TestCase
assert_equal @string, @ip.to_string_uncompressed
assert_equal @u128, @ip.to_u128
end
+
+ def test_method_ipv6?
+ assert_equal true, @ip.ipv6?
+ end
end # class IPv6LoopbackTest
@@ -345,6 +345,10 @@ class IPv6MappedTest < Test::Unit::TestCase
assert_equal @u128, @ip.to_u128
end
+ def test_method_ipv6?
+ assert_equal true, @ip.ipv6?
+ end
+
def test_mapped?
assert_equal true, @ip.mapped?
end