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

* test/uri/*: translated RUNIT to Test::Unit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akira 2003-10-05 06:09:26 +00:00
parent 16658578a5
commit 12c8c18f09
7 changed files with 81 additions and 172 deletions

View file

@ -1,3 +1,7 @@
Sun Oct 5 15:05:06 2003 akira yamada <akira@ruby-lang.org>
* test/uri/*: translated RUNIT to Test::Unit.
Sun Oct 5 14:37:39 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/xsd/datatypes.rb: Rational -> Decimal string bug fix.

View file

@ -1,15 +1,10 @@
#
# $Id$
#
# Copyright (c) 2002 akira yamada <akira@ruby-lang.org>
# You can redistribute it and/or modify it under the same term as Ruby.
#
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri'
class TestCommon < RUNIT::TestCase
module URI
class TestCommon < Test::Unit::TestCase
def setup
end
@ -36,14 +31,5 @@ class TestCommon < RUNIT::TestCase
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestCommon.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestGeneric.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end

View file

@ -1,24 +1,10 @@
#
# $Id$
#
# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
# You can redistribute it and/or modify it under the same term as Ruby.
#
require 'runit/testcase'
require 'runit/testsuite'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri/ftp'
module URI
class Generic
def to_ary
component_ary
end
end
end
class TestFTP < RUNIT::TestCase
module URI
class TestFTP < Test::Unit::TestCase
def setup
end
@ -31,7 +17,10 @@ class TestFTP < RUNIT::TestCase
'user:pass', 'host.com', URI::FTP.default_port,
'/abc/def', nil,
]
ary = url.to_ary
ary = [
url.scheme, url.userinfo, url.host, url.port,
url.path, url.opaque
]
assert_equal(exp, ary)
assert_equal('user', url.user)
@ -41,21 +30,13 @@ class TestFTP < RUNIT::TestCase
def test_select
assert_equal(['ftp', 'a.b.c', 21], URI.parse('ftp://a.b.c/').select(:scheme, :host, :port))
u = URI.parse('ftp://a.b.c/')
assert_equal(u.to_ary, u.select(*u.component))
assert_exception(ArgumentError) do
ary = u.component.collect {|c| u.send(c)}
assert_equal(ary, u.select(*u.component))
assert_raises(ArgumentError) do
u.select(:scheme, :host, :not_exist, :port)
end
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestFTP.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestFTP.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end

View file

@ -1,22 +1,10 @@
#
# $Id$
#
# Copyright (c) 2002 akira yamada <akira@ruby-lang.org>
# You can redistribute it and/or modify it under the same term as Ruby.
#
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri'
module URI
class Generic
def to_ary
component_ary
end
end
end
class TestGeneric < RUNIT::TestCase
module URI
class TestGeneric < Test::Unit::TestCase
def setup
@url = 'http://a/b/c/d;p?q'
@base_url = URI.parse(@url)
@ -25,6 +13,10 @@ class TestGeneric < RUNIT::TestCase
def teardown
end
def uri_to_ary(uri)
uri.class.component.collect {|c| uri.send(c)}
end
def test_parse
# 0
assert_kind_of(URI::HTTP, @base_url)
@ -36,7 +28,7 @@ class TestGeneric < RUNIT::TestCase
'q',
nil
]
ary = @base_url.to_ary
ary = uri_to_ary(@base_url)
assert_equal(exp, ary)
# 1
@ -48,7 +40,7 @@ class TestGeneric < RUNIT::TestCase
nil, 'ftp.is.co.za', URI::FTP.default_port,
'/rfc/rfc1808.txt', nil,
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 2
@ -62,7 +54,7 @@ class TestGeneric < RUNIT::TestCase
nil,
nil
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 3
@ -76,7 +68,7 @@ class TestGeneric < RUNIT::TestCase
nil,
nil
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 4
@ -88,7 +80,7 @@ class TestGeneric < RUNIT::TestCase
'mduerst@ifi.unizh.ch',
[]
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 5
@ -102,7 +94,7 @@ class TestGeneric < RUNIT::TestCase
nil,
nil
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 6
@ -116,13 +108,13 @@ class TestGeneric < RUNIT::TestCase
nil,
nil
]
ary = url.to_ary
ary = uri_to_ary(url)
assert_equal(exp, ary)
# 7
# reported by Mr. Kubota <em6t-kbt@asahi-net.or.jp>
assert_exception(URI::InvalidURIError) { URI.parse('http://a_b:80/') }
assert_exception(URI::InvalidURIError) { URI.parse('http://a_b/') }
assert_raises(URI::InvalidURIError) { URI.parse('http://a_b:80/') }
assert_raises(URI::InvalidURIError) { URI.parse('http://a_b/') }
# 8
# reporte by m_seki
@ -621,14 +613,5 @@ class TestGeneric < RUNIT::TestCase
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestGeneric.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestGeneric.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end

View file

@ -1,27 +1,26 @@
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri/http'
module URI
class Generic
def to_ary
component_ary
end
end
end
class TestHTTP < RUNIT::TestCase
module URI
class TestHTTP < Test::Unit::TestCase
def setup
end
def teardown
end
def uri_to_ary(uri)
uri.class.component.collect {|c| uri.send(c)}
end
def test_parse
u = URI.parse('http://a')
assert_kind_of(URI::HTTP, u)
assert_equal(['http',
nil, 'a', URI::HTTP.default_port,
'', nil, nil], u.to_ary)
'', nil, nil], uri_to_ary(u))
end
def test_normalize
@ -53,21 +52,12 @@ class TestHTTP < RUNIT::TestCase
def test_select
assert_equal(['http', 'a.b.c', 80], URI.parse('http://a.b.c/').select(:scheme, :host, :port))
u = URI.parse('http://a.b.c/')
assert_equal(u.to_ary, u.select(*u.component))
assert_exception(ArgumentError) do
assert_equal(uri_to_ary(u), u.select(*u.component))
assert_raises(ArgumentError) do
u.select(:scheme, :host, :not_exist, :port)
end
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestHTTP.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestHTTP.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end

View file

@ -1,29 +1,20 @@
#
# $Id$
#
# Copyright (c) 2001 Takaaki Tateishi <ttate@jaist.ac.jp> and
# akira yamada <akira@ruby-lang.org>.
# You can redistribute it and/or modify it under the same term as Ruby.
#
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri/ldap'
module URI
class Generic
def to_ary
component_ary
end
end
end
class TestLDAP < RUNIT::TestCase
module URI
class TestLDAP < Test::Unit::TestCase
def setup
end
def teardown
end
def uri_to_ary(uri)
uri.class.component.collect {|c| uri.send(c)}
end
def test_parse
url = 'ldap://ldap.jaist.ac.jp/o=JAIST,c=JP?sn?base?(sn=ttate*)'
u = URI.parse(url)
@ -92,27 +83,18 @@ class TestLDAP < RUNIT::TestCase
nil, 'sub', nil, '!bindname=cn=Manager%2co=Foo'],
}.each do |url, ary|
u = URI.parse(url)
assert_equal(ary, u.to_ary)
assert_equal(ary, uri_to_ary(u))
end
end
def test_select
u = URI.parse('ldap:///??sub??!bindname=cn=Manager%2co=Foo')
assert_equal(u.to_ary, u.select(*u.component))
assert_exception(ArgumentError) do
assert_equal(uri_to_ary(u), u.select(*u.component))
assert_raises(ArgumentError) do
u.select(:scheme, :host, :not_exist, :port)
end
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestLDAP.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestLDAP.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end

View file

@ -1,22 +1,10 @@
#
# $Id$
#
# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
# You can redistribute it and/or modify it under the same term as Ruby.
#
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'test/unit'
require 'uri/mailto'
module URI
class Generic
def to_ary
component_ary
end
end
end
class TestMailTo < RUNIT::TestCase
module URI
class TestMailTo < Test::Unit::TestCase
def setup
@u = URI::MailTo
end
@ -24,6 +12,10 @@ class TestMailTo < RUNIT::TestCase
def teardown
end
def uri_to_ary(uri)
uri.class.component.collect {|c| uri.send(c)}
end
def test_build
ok = []
bad = []
@ -109,7 +101,7 @@ class TestMailTo < RUNIT::TestCase
end
bad.each do |x|
assert_exception(URI::InvalidComponentError) {
assert_raises(URI::InvalidComponentError) {
@u.build(x)
}
end
@ -119,21 +111,12 @@ class TestMailTo < RUNIT::TestCase
def test_select
u = URI.parse('mailto:joe@example.com?cc=bob@example.com&body=hello')
assert_equal(u.to_ary, u.select(*u.component))
assert_exception(ArgumentError) do
assert_equal(uri_to_ary(u), u.select(*u.component))
assert_raises(ArgumentError) do
u.select(:scheme, :host, :not_exist, :port)
end
end
end
if $0 == __FILE__
if ARGV.size == 0
suite = TestMailTo.suite
else
suite = RUNIT::TestSuite.new
ARGV.each do |testmethod|
suite.add_test(TestMailTo.new(testmethod))
end
end
RUNIT::CUI::TestRunner.run(suite)
end