From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/test/resolv/test_addr.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 jni/ruby/test/resolv/test_addr.rb (limited to 'jni/ruby/test/resolv/test_addr.rb') diff --git a/jni/ruby/test/resolv/test_addr.rb b/jni/ruby/test/resolv/test_addr.rb new file mode 100644 index 0000000..e06c3c2 --- /dev/null +++ b/jni/ruby/test/resolv/test_addr.rb @@ -0,0 +1,29 @@ +require 'test/unit' +require 'resolv' +require 'socket' +require 'tempfile' + +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 + + def test_invalid_byte_comment + bug9273 = '[ruby-core:59239] [Bug #9273]' + Tempfile.create('resolv_test_addr_') do |tmpfile| + tmpfile.print("\xff\x00\x40") + tmpfile.close + hosts = Resolv::Hosts.new(tmpfile.path) + assert_nothing_raised(ArgumentError, bug9273) do + hosts.each_address("") {break} + end + end + end +end -- cgit v1.2.3