summaryrefslogtreecommitdiff
path: root/test/csv/interface/test_read.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2022-12-09 08:46:14 +0900
committerHiroshi SHIBATA <[email protected]>2022-12-09 16:36:22 +0900
commit643918ecfe9c980f251247de6acd3be6280da24c (patch)
treea5b4011c13ee3af5b110e377a839e79045266dcd /test/csv/interface/test_read.rb
parent260a00d80e4dcc930b040313a99da29e4b1e6678 (diff)
Merge csv-3.2.6
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6890
Diffstat (limited to 'test/csv/interface/test_read.rb')
-rw-r--r--test/csv/interface/test_read.rb18
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"))