diff options
author | Sutou Kouhei <kou@cozmixng.org> | 2019-10-12 14:03:21 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-12 14:03:21 +0900 |
commit | 92df7d98b62f48cf21cdec522f2e7b34380fd718 (patch) | |
tree | a0d169e177ebd5607caefa26cef90cc70df48232 /test/csv/parse | |
parent | d6e68bb263e79cb802fa683d9c4139ddca2fd4f5 (diff) | |
download | ruby-92df7d98b62f48cf21cdec522f2e7b34380fd718.tar.gz |
Import CSV 3.1.2 (#2547)
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 |