mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/csv/test_csv.rb: run on test/unit original layer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
98abf532a4
commit
af5a9fd8c2
2 changed files with 32 additions and 42 deletions
|
@ -1,15 +1,21 @@
|
||||||
|
Wed Sep 4 15:40:07 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/csv/test_csv.rb: run on test/unit original layer.
|
||||||
|
|
||||||
Thu Sep 4 12:54:50 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
|
Thu Sep 4 12:54:50 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
|
||||||
|
|
||||||
* ext/syck/token.c: headerless documents with root-level spacing now
|
* ext/syck/token.c: headerless documents with root-level spacing now
|
||||||
honored.
|
honored.
|
||||||
|
|
||||||
Wed Sep 3 21:33:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
Wed Sep 3 21:33:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||||
|
|
||||||
* test: add test directory. Test::Unit aware testcases and needed
|
* test: add test directory. Test::Unit aware testcases and needed
|
||||||
files should be located in this directory. dir/file name convention;
|
files should be located in this directory. dir/file name convention;
|
||||||
test/{module_name}/test_{testcase_name}.rb
|
test/{module_name}/test_{testcase_name}.rb
|
||||||
test/{module_name}/{needed_files}
|
test/{module_name}/{needed_files}
|
||||||
someday, someone will write testrunner which searches test_*.rb and
|
someday, someone will write testrunner which searches test_*.rb and
|
||||||
run testcases automatically.
|
run testcases automatically.
|
||||||
|
|
||||||
* test/csv/*: add testcase for lib/csv.rb.
|
* test/csv/*: add testcase for lib/csv.rb.
|
||||||
|
|
||||||
Tue Sep 2 20:37:15 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Tue Sep 2 20:37:15 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
require 'runit/testcase'
|
require 'test/unit'
|
||||||
require 'runit/cui/testrunner'
|
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
||||||
#require '../lib/csv.rb'
|
require '../../lib/csv'
|
||||||
require 'csv'
|
|
||||||
|
|
||||||
class CSV
|
class CSV
|
||||||
class StreamBuf
|
class StreamBuf
|
||||||
|
@ -12,7 +10,7 @@ class CSV
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestCSV < RUNIT::TestCase
|
class TestCSV < Test::Unit::TestCase
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def d(data, is_null = false)
|
def d(data, is_null = false)
|
||||||
|
@ -72,7 +70,7 @@ class TestCSV < RUNIT::TestCase
|
||||||
[d('foo'), d('"'), d('baz')] => 'foo,"""",baz',
|
[d('foo'), d('"'), d('baz')] => 'foo,"""",baz',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@tmpdir = 'tmp'
|
@@tmpdir = 'tmp' # File.join(Dir.tmpdir, "ruby_test_csv_tmp_#{$$}"); Dir.mkdir(@@tmpdir)
|
||||||
@@infile = File.join(@@tmpdir, 'in.csv')
|
@@infile = File.join(@@tmpdir, 'in.csv')
|
||||||
@@infiletsv = File.join(@@tmpdir, 'in.tsv')
|
@@infiletsv = File.join(@@tmpdir, 'in.tsv')
|
||||||
@@emptyfile = File.join(@@tmpdir, 'empty.csv')
|
@@emptyfile = File.join(@@tmpdir, 'empty.csv')
|
||||||
|
@ -289,13 +287,13 @@ public
|
||||||
|
|
||||||
# Illegal format.
|
# Illegal format.
|
||||||
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
reader.each do |row|
|
reader.each do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
reader = CSV::Reader.create("a,b\r\n\"")
|
reader = CSV::Reader.create("a,b\r\n\"")
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
reader.each do |row|
|
reader.each do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -323,13 +321,13 @@ public
|
||||||
|
|
||||||
# Illegal format.
|
# Illegal format.
|
||||||
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
reader.shift
|
reader.shift
|
||||||
reader.shift
|
reader.shift
|
||||||
end
|
end
|
||||||
|
|
||||||
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
reader.shift
|
reader.shift
|
||||||
reader.shift
|
reader.shift
|
||||||
end
|
end
|
||||||
|
@ -338,7 +336,7 @@ public
|
||||||
def test_Reader_getRow
|
def test_Reader_getRow
|
||||||
if CSV::Reader.respond_to?(:allocate)
|
if CSV::Reader.respond_to?(:allocate)
|
||||||
obj = CSV::Reader.allocate
|
obj = CSV::Reader.allocate
|
||||||
assert_exception(NotImplementedError) do
|
assert_raises(NotImplementedError) do
|
||||||
row = []
|
row = []
|
||||||
obj.shift
|
obj.shift
|
||||||
end
|
end
|
||||||
|
@ -368,7 +366,7 @@ public
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_Reader_s_new
|
def test_Reader_s_new
|
||||||
assert_exception(RuntimeError) do
|
assert_raises(RuntimeError) do
|
||||||
CSV::Reader.new(nil)
|
CSV::Reader.new(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -422,12 +420,12 @@ public
|
||||||
}
|
}
|
||||||
|
|
||||||
# Illegal format.
|
# Illegal format.
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
CSV::Reader.parse("a,b\r\na,b,\"c\"\ra") do |row|
|
CSV::Reader.parse("a,b\r\na,b,\"c\"\ra") do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
CSV::Reader.parse("a,b\r\na,b\"") do |row|
|
CSV::Reader.parse("a,b\r\na,b\"") do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -437,7 +435,7 @@ public
|
||||||
#### CSV::Writer unit test
|
#### CSV::Writer unit test
|
||||||
|
|
||||||
def test_Writer_s_new
|
def test_Writer_s_new
|
||||||
assert_exception(RuntimeError) do
|
assert_raises(RuntimeError) do
|
||||||
CSV::Writer.new(nil)
|
CSV::Writer.new(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -529,11 +527,11 @@ public
|
||||||
#### CSV unit test
|
#### CSV unit test
|
||||||
|
|
||||||
def test_s_open_reader
|
def test_s_open_reader
|
||||||
assert_exception(ArgumentError, 'Illegal mode') do
|
assert_raises(ArgumentError, 'Illegal mode') do
|
||||||
CSV.open("temp", "a")
|
CSV.open("temp", "a")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(ArgumentError, 'Illegal mode') do
|
assert_raises(ArgumentError, 'Illegal mode') do
|
||||||
CSV.open("temp", "a", ?;)
|
CSV.open("temp", "a", ?;)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -559,11 +557,11 @@ public
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(Errno::ENOENT) do
|
assert_raises(Errno::ENOENT) do
|
||||||
CSV.open("NoSuchFileOrDirectory", "r")
|
CSV.open("NoSuchFileOrDirectory", "r")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(Errno::ENOENT) do
|
assert_raises(Errno::ENOENT) do
|
||||||
CSV.open("NoSuchFileOrDirectory", "r", ?;)
|
CSV.open("NoSuchFileOrDirectory", "r", ?;)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -571,7 +569,7 @@ public
|
||||||
File.open(@@outfile, "w") do |f|
|
File.open(@@outfile, "w") do |f|
|
||||||
f << "a,b\r\na,b,\"c\"\ra"
|
f << "a,b\r\na,b,\"c\"\ra"
|
||||||
end
|
end
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
CSV.open(@@outfile, "r") do |row|
|
CSV.open(@@outfile, "r") do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -579,7 +577,7 @@ public
|
||||||
File.open(@@outfile, "w") do |f|
|
File.open(@@outfile, "w") do |f|
|
||||||
f << "a,b\r\na,b\""
|
f << "a,b\r\na,b\""
|
||||||
end
|
end
|
||||||
assert_exception(CSV::IllegalFormatError) do
|
assert_raises(CSV::IllegalFormatError) do
|
||||||
CSV.open(@@outfile, "r") do |row|
|
CSV.open(@@outfile, "r") do |row|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -612,11 +610,11 @@ public
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(Errno::ENOENT) do
|
assert_raises(Errno::ENOENT) do
|
||||||
CSV.parse("NoSuchFileOrDirectory")
|
CSV.parse("NoSuchFileOrDirectory")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(Errno::ENOENT) do
|
assert_raises(Errno::ENOENT) do
|
||||||
CSV.parse("NoSuchFileOrDirectory", ?;)
|
CSV.parse("NoSuchFileOrDirectory", ?;)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1221,12 +1219,12 @@ public
|
||||||
dropped = s.drop(1)
|
dropped = s.drop(1)
|
||||||
assert_equal(0, dropped)
|
assert_equal(0, dropped)
|
||||||
|
|
||||||
assert_exception(TestCSV::ErrBuf::Error) do
|
assert_raises(TestCSV::ErrBuf::Error) do
|
||||||
s = ErrBuf.new
|
s = ErrBuf.new
|
||||||
s[1024]
|
s[1024]
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_exception(TestCSV::ErrBuf::Error) do
|
assert_raises(TestCSV::ErrBuf::Error) do
|
||||||
s = ErrBuf.new
|
s = ErrBuf.new
|
||||||
s.drop(1024)
|
s.drop(1024)
|
||||||
end
|
end
|
||||||
|
@ -1423,7 +1421,7 @@ public
|
||||||
|
|
||||||
def test_StreamBuf_s_new
|
def test_StreamBuf_s_new
|
||||||
# NotImplementedError should be raised from StreamBuf#read.
|
# NotImplementedError should be raised from StreamBuf#read.
|
||||||
assert_exception(NotImplementedError) do
|
assert_raises(NotImplementedError) do
|
||||||
CSV::StreamBuf.new
|
CSV::StreamBuf.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1435,9 +1433,8 @@ public
|
||||||
|
|
||||||
f = File.open(@@outfile, "rb")
|
f = File.open(@@outfile, "rb")
|
||||||
iobuf = CSV::IOBuf.new(f)
|
iobuf = CSV::IOBuf.new(f)
|
||||||
assert_no_exception do
|
iobuf.close
|
||||||
iobuf.close
|
assert(true) # iobuf.close does not raise any exception.
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_IOBuf_s_new
|
def test_IOBuf_s_new
|
||||||
|
@ -1495,16 +1492,3 @@ public
|
||||||
assert_equal(csvStrTerminated, buf)
|
assert_equal(csvStrTerminated, buf)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
|
||||||
testrunner = RUNIT::CUI::TestRunner.new
|
|
||||||
if ARGV.size == 0
|
|
||||||
suite = TestCSV.suite
|
|
||||||
else
|
|
||||||
suite = RUNIT::TestSuite.new
|
|
||||||
ARGV.each do |testmethod|
|
|
||||||
suite.add_test(TestCSV.new(testmethod))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
testrunner.run(suite)
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue