summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Mackintosh <m@zyp.io>2015-01-26 16:31:59 -0500
committerMike Mackintosh <m@zyp.io>2015-01-26 16:31:59 -0500
commit35af5ddc8f602ba2cdde1c72b70c92c0f19548cb (patch)
treeeb7f84ae8fb60825f1acd32da99090c0d339bbf0 /test
parenta44e5018eb6d19ae4955ce2ec0b0f45f46fb7dc3 (diff)
downloadipaddress-35af5ddc8f602ba2cdde1c72b70c92c0f19548cb.tar.gz
added #to_h tests
Diffstat (limited to 'test')
-rw-r--r--test/ipaddress/ipv4_test.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index 5177c75..534349e 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -34,7 +34,13 @@ class IPv4Test < Test::Unit::TestCase
"172.16.0.0/16" => 2886729728,
"192.168.0.0/24" => 3232235520,
"192.168.100.4/30" => 3232261124}
-
+
+ @hex_values = {
+ "10.0.0.0" => "0a000000",
+ "172.16.5.4" => "ac100504",
+ "192.168.100.4" => "c0a86404",
+ }
+
@ip = @klass.new("172.16.10.1/24")
@network = @klass.new("172.16.10.0/24")
@@ -144,6 +150,13 @@ class IPv4Test < Test::Unit::TestCase
end
end
+ def test_method_to_hex
+ @hex_values.each do |addr,hex|
+ ip = @klass.new(addr)
+ assert_equal hex, ip.to_hex
+ end
+ end
+
def test_method_network?
assert_equal true, @network.network?
assert_equal false, @ip.network?