1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/resolv/test_addr.rb

17 lines
415 B
Ruby
Raw Normal View History

require 'test/unit'
require 'resolv'
require 'socket'
class TestResolvAddr < Test::Unit::TestCase
def test_invalid_ipv4_address
assert_not_match(Resolv::IPv4::Regex, "1.2.3.256", "[ruby-core:29501]")
1000.times {|i|
if i < 256
assert_match(Resolv::IPv4::Regex, "#{i}.#{i}.#{i}.#{i}")
else
assert_not_match(Resolv::IPv4::Regex, "#{i}.#{i}.#{i}.#{i}")
end
}
end
end