summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--test/uri/test_common.rb26
-rw-r--r--test/uri/test_ftp.rb43
-rw-r--r--test/uri/test_generic.rb53
-rw-r--r--test/uri/test_http.rb34
-rw-r--r--test/uri/test_ldap.rb42
-rw-r--r--test/uri/test_mailto.rb41
7 files changed, 76 insertions, 167 deletions
diff --git a/ChangeLog b/ChangeLog
index 003f8a3a065..b6b44170bb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb
index b93a71f5533..c213a84c2cd 100644
--- a/test/uri/test_common.rb
+++ b/test/uri/test_common.rb
@@ -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
diff --git a/test/uri/test_ftp.rb b/test/uri/test_ftp.rb
index 123eb22e4a5..a7b59efebf5 100644
--- a/test/uri/test_ftp.rb
+++ b/test/uri/test_ftp.rb
@@ -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
+
+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
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb
index 12e76b765aa..de8094e4ba1 100644
--- a/test/uri/test_generic.rb
+++ b/test/uri/test_generic.rb
@@ -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
+
+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
diff --git a/test/uri/test_http.rb b/test/uri/test_http.rb
index 65fc2ef6303..a6846141dfd 100644
--- a/test/uri/test_http.rb
+++ b/test/uri/test_http.rb
@@ -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
+
+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
diff --git a/test/uri/test_ldap.rb b/test/uri/test_ldap.rb
index df55f6490b6..866b7d80667 100644
--- a/test/uri/test_ldap.rb
+++ b/test/uri/test_ldap.rb
@@ -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
+
+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
diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb
index 4fd1476625e..ba437904f81 100644
--- a/test/uri/test_mailto.rb
+++ b/test/uri/test_mailto.rb
@@ -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
+
+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