diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-15 09:22:11 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-15 09:22:11 +0000 |
| commit | b5aba69e60dec153ecab3263ebc3fa5e93662a46 (patch) | |
| tree | de335981d912c9359496aff4ea93921e96655c3f /test/csv/interface/test_read_write.rb | |
| parent | 1371865130ee432d44683222982720e5ba3fd66e (diff) | |
merge revision(s) 66720:
separate downloading of Unicode property files and auxiliary files
Separate downloading of Unicode property files in ucd and in ucd/auxiliary.
This is needed because we need information from separate index.html files
to discover the exact file names of property files during a beta period.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/interface/test_read_write.rb')
| -rw-r--r-- | test/csv/interface/test_read_write.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/csv/interface/test_read_write.rb b/test/csv/interface/test_read_write.rb new file mode 100644 index 0000000000..9ce3553d61 --- /dev/null +++ b/test/csv/interface/test_read_write.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: false + +require_relative "../helper" + +class TestCSVInterfaceReadWrite < Test::Unit::TestCase + extend DifferentOFS + + def test_filter + rows = [[1, 2, 3], [4, 5]] + input = <<-CSV +1;2;3 +4;5 + CSV + output = "" + CSV.filter(input, output, + in_col_sep: ";", + out_col_sep: ",", + converters: :all) do |row| + row.map! {|n| n * 2} + row << "Added\r" + end + assert_equal(<<-CSV, output) +2,4,6,"Added\r" +8,10,"Added\r" + CSV + end + + def test_instance_same + data = "" + assert_equal(CSV.instance(data, col_sep: ";").object_id, + CSV.instance(data, col_sep: ";").object_id) + end + + def test_instance_append + output = "" + CSV.instance(output, col_sep: ";") << ["a", "b", "c"] + assert_equal(<<-CSV, output) +a;b;c + CSV + CSV.instance(output, col_sep: ";") << [1, 2, 3] + assert_equal(<<-CSV, output) +a;b;c +1;2;3 + CSV + end + + def test_instance_shortcut + assert_equal(CSV.instance, + CSV {|csv| csv}) + end +end |
