diff options
author | Bogdan Irimie <[email protected]> | 2019-10-09 13:23:27 +0300 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-10-07 18:22:43 +0900 |
commit | 74ed881e109ee2480854f5d47e8ef4a84b0cc1c5 (patch) | |
tree | 7f374a99f605a80f2d40410177c81bbf532c1862 /test/test_ipaddr.rb | |
parent | abad5e10e80c06f2e756667cd2d7f7d9b6e78ba5 (diff) |
[ruby/ipaddr] Add netmask method that returns net mask as string.
https://github.com/ruby/ipaddr/commit/283d16f3a3
Diffstat (limited to 'test/test_ipaddr.rb')
-rw-r--r-- | test/test_ipaddr.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb index 2b6e5c7524..c055f4b2c4 100644 --- a/test/test_ipaddr.rb +++ b/test/test_ipaddr.rb @@ -220,6 +220,17 @@ class TC_IPAddr < Test::Unit::TestCase assert_equal("3ffe:0505:0002:0000:0000:0000:0000:0001", IPAddr.new("3ffe:505:2::1").to_string) assert_equal("3ffe:505:2::1", IPAddr.new("3ffe:505:2::1").to_s) end + + def test_netmask + a = IPAddr.new("192.168.1.2/8") + assert_equal(a.netmask, "255.0.0.0") + + a = IPAddr.new("192.168.1.2/16") + assert_equal(a.netmask, "255.255.0.0") + + a = IPAddr.new("192.168.1.2/24") + assert_equal(a.netmask, "255.255.255.0") + end end class TC_Operator < Test::Unit::TestCase |