summaryrefslogtreecommitdiff
path: root/test/uri/test_common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/uri/test_common.rb')
-rw-r--r--test/uri/test_common.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb
index 038f483a83..1df19e6968 100644
--- a/test/uri/test_common.rb
+++ b/test/uri/test_common.rb
@@ -3,10 +3,7 @@ require 'test/unit'
require 'envutil'
require 'uri'
-module URI
-
-
-class TestCommon < Test::Unit::TestCase
+class URI::TestCommon < Test::Unit::TestCase
def setup
end
@@ -112,6 +109,17 @@ class TestCommon < Test::Unit::TestCase
assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") }
end
+ def test_parse_timeout
+ pre = ->(n) {
+ 'https://example.com/dir/' + 'a' * (n * 100) + '/##.jpg'
+ }
+ assert_linear_performance((1..3).map {|i| 10**i}, rehearsal: 1000, pre: pre) do |uri|
+ assert_raise(URI::InvalidURIError) do
+ URI.parse(uri)
+ end
+ end
+ end
+
def test_encode_www_form_component
assert_equal("%00+%21%22%23%24%25%26%27%28%29*%2B%2C-.%2F09%3A%3B%3C%3D%3E%3F%40" \
"AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E",
@@ -281,6 +289,3 @@ class TestCommon < Test::Unit::TestCase
private
def s(str) str.force_encoding(Encoding::Windows_31J); end
end
-
-
-end