diff options
Diffstat (limited to 'test/csv/parse')
-rw-r--r-- | test/csv/parse/test_general.rb | 14 | ||||
-rw-r--r-- | test/csv/parse/test_header.rb | 4 | ||||
-rw-r--r-- | test/csv/parse/test_rewind.rb | 2 |
3 files changed, 15 insertions, 5 deletions
diff --git a/test/csv/parse/test_general.rb b/test/csv/parse/test_general.rb index f340921854..655bb26560 100644 --- a/test/csv/parse/test_general.rb +++ b/test/csv/parse/test_general.rb @@ -233,11 +233,21 @@ line,5,jkl assert_equal([["a"]], CSV.parse("a\r\n")) end + def test_seeked_string_io + input_with_bom = StringIO.new("\ufeffあ,い,う\r\na,b,c\r\n") + input_with_bom.read(3) + assert_equal([ + ["あ", "い", "う"], + ["a", "b", "c"], + ], + CSV.new(input_with_bom).each.to_a) + end + private - def assert_parse_errors_out(*args, **options) + def assert_parse_errors_out(data, **options) assert_raise(CSV::MalformedCSVError) do Timeout.timeout(0.2) do - CSV.parse(*args, **options) + CSV.parse(data, **options) fail("Parse didn't error out") end end diff --git a/test/csv/parse/test_header.rb b/test/csv/parse/test_header.rb index 61346c2aac..481c5107c6 100644 --- a/test/csv/parse/test_header.rb +++ b/test/csv/parse/test_header.rb @@ -312,12 +312,12 @@ A end def test_parse_empty - assert_equal(CSV::Table.new([], **{}), + assert_equal(CSV::Table.new([]), CSV.parse("", headers: true)) end def test_parse_empty_line - assert_equal(CSV::Table.new([], **{}), + assert_equal(CSV::Table.new([]), CSV.parse("\n", headers: true)) end diff --git a/test/csv/parse/test_rewind.rb b/test/csv/parse/test_rewind.rb index 43fd8da159..0aa403b756 100644 --- a/test/csv/parse/test_rewind.rb +++ b/test/csv/parse/test_rewind.rb @@ -6,7 +6,7 @@ require_relative "../helper" class TestCSVParseRewind < Test::Unit::TestCase extend DifferentOFS - def parse(data, options={}) + def parse(data, **options) csv = CSV.new(data, **options) records = csv.to_a csv.rewind |