From 30e14294a74915ab359de5bc45881c391e259c4c Mon Sep 17 00:00:00 2001 From: nahi Date: Fri, 12 Dec 2003 13:44:58 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@5177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/csv/test_csv.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test/csv') diff --git a/test/csv/test_csv.rb b/test/csv/test_csv.rb index 782f5af8d4..6cc4c5cac7 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 -- cgit v1.2.3