diff options
Diffstat (limited to 'test/csv/interface/test_read.rb')
-rw-r--r-- | test/csv/interface/test_read.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/csv/interface/test_read.rb b/test/csv/interface/test_read.rb index d73622d554..001177036a 100644 --- a/test/csv/interface/test_read.rb +++ b/test/csv/interface/test_read.rb @@ -26,7 +26,7 @@ class TestCSVInterfaceRead < Test::Unit::TestCase def test_foreach rows = [] - CSV.foreach(@input.path, col_sep: "\t", row_sep: "\r\n").each do |row| + CSV.foreach(@input.path, col_sep: "\t", row_sep: "\r\n") do |row| rows << row end assert_equal(@rows, rows) @@ -37,7 +37,7 @@ class TestCSVInterfaceRead < Test::Unit::TestCase def test_foreach_in_ractor ractor = Ractor.new(@input.path) do |path| rows = [] - CSV.foreach(path, col_sep: "\t", row_sep: "\r\n").each do |row| + CSV.foreach(path, col_sep: "\t", row_sep: "\r\n") do |row| rows << row end rows @@ -52,13 +52,13 @@ class TestCSVInterfaceRead < Test::Unit::TestCase def test_foreach_mode rows = [] - CSV.foreach(@input.path, "r", col_sep: "\t", row_sep: "\r\n").each do |row| + CSV.foreach(@input.path, "r", col_sep: "\t", row_sep: "\r\n") do |row| rows << row end assert_equal(@rows, rows) end - def test_foreach_enumurator + def test_foreach_enumerator rows = CSV.foreach(@input.path, col_sep: "\t", row_sep: "\r\n").to_a assert_equal(@rows, rows) end @@ -205,6 +205,16 @@ class TestCSVInterfaceRead < Test::Unit::TestCase end end + def test_open_with_newline + CSV.open(@input.path, col_sep: "\t", universal_newline: true) do |csv| + assert_equal(@rows, csv.to_a) + end + File.binwrite(@input.path, "1,2,3\r\n" "4,5\n") + CSV.open(@input.path, newline: :universal) do |csv| + assert_equal(@rows, csv.to_a) + end + end + def test_parse assert_equal(@rows, CSV.parse(@data, col_sep: "\t", row_sep: "\r\n")) |