summaryrefslogtreecommitdiffstats
path: root/test/csv
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-12 13:44:58 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-12 13:44:58 +0000
commit232af9efc706919b271b89824d3d546d208c6b90 (patch)
tree19e9c0b233bd47450f92b5478ddfdbd81f7c7b88 /test/csv
parenta9545d8a7edd1d93137b84089584c705567caaee (diff)
downloadruby-232af9efc706919b271b89824d3d546d208c6b90.tar.gz
ruby-232af9efc706919b271b89824d3d546d208c6b90.tar.xz
ruby-232af9efc706919b271b89824d3d546d208c6b90.zip
* lib/csv.rb: add Cell#to_str and Cell#to_s for /.../ =~ aCell,
"#{aCell}" and so on. * test/csv/test_csv.rb: add tests. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv')
-rw-r--r--test/csv/test_csv.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/csv/test_csv.rb b/test/csv/test_csv.rb
index 782f5af8d..6cc4c5cac 100644
--- a/test/csv/test_csv.rb
+++ b/test/csv/test_csv.rb
@@ -1,4 +1,5 @@
-require 'test/unit'
+require 'test/unit/testsuite'
+require 'test/unit/testcase'
require 'tempfile'
require 'fileutils'
@@ -92,6 +93,29 @@ class TestCSVCell < Test::Unit::TestCase
d3 = CSV::Cell.new(nil, false)
assert_equal(d3.is_null, false, "Data: false.")
end
+
+ def test_to_str
+ d = CSV::Cell.new("foo", false)
+ assert_equal("foo", d.to_str)
+ assert(/foo/ =~ d)
+ d = CSV::Cell.new("foo", true)
+ begin
+ d.to_str
+ assert(false)
+ rescue
+ # NoMethodError or NameError
+ assert(true)
+ end
+ end
+
+ def test_to_s
+ d = CSV::Cell.new("foo", false)
+ assert_equal("foo", d.to_s)
+ assert_equal("foo", "#{d}")
+ d = CSV::Cell.new("foo", true)
+ assert_equal("", d.to_s)
+ assert_equal("", "#{d}")
+ end
end