diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-28 17:33:19 +0900 |
---|---|---|
committer | usa <usa@garbagecollect.jp> | 2023-03-29 10:17:23 +0900 |
commit | 6855779d580358a6a0b4c9ee06f20e7cae72955a (patch) | |
tree | 38acb83f6ed853417c4efdc256014a89726b3897 /test | |
parent | 36cadad6434bc31bc2d60697698cd5b930c097ce (diff) |
Merge URI-0.10.0.2
Diffstat (limited to 'test')
-rw-r--r-- | test/uri/test_common.rb | 11 | ||||
-rw-r--r-- | test/uri/test_parser.rb | 7 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 1afa35f93d..2b877c10d7 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -56,6 +56,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..10).map {|i| i * 100}, 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", diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index b13a26ca84..37e7107bca 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -58,4 +58,11 @@ class URI::TestParser < Test::Unit::TestCase assert_equal("\u3042", p1.unescape('%e3%81%82'.force_encoding(Encoding::US_ASCII))) assert_equal("\xe3\x83\x90\xe3\x83\x90", p1.unescape("\xe3\x83\x90%e3%83%90")) end + + def test_split + assert_equal(["http", nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("http://example.com")) + assert_equal(["http", nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("http://[0::0]")) + assert_equal([nil, nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("//example.com")) + assert_equal([nil, nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("//[0::0]")) + end end |