diff options
author | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-01 02:44:48 +0000 |
---|---|---|
committer | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-01 02:44:48 +0000 |
commit | 9c63aecfa75d94efb2f5d86d12023ef6ef85af85 (patch) | |
tree | 4b565a7cf7873e9de8ab876579c951238f47ed87 /test | |
parent | 1ddab13b9d3965f5dac4f39bdbf9883ba8dfc7dd (diff) | |
download | ruby-9c63aecfa75d94efb2f5d86d12023ef6ef85af85.tar.gz |
Adding a liberal_parsing option to CSV. Patch by Braden Anderson.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rwxr-xr-x | test/csv/test_features.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb index 37fdab8636..a558875522 100755 --- a/test/csv/test_features.rb +++ b/test/csv/test_features.rb @@ -142,6 +142,29 @@ class TestCSV::Features < TestCSV assert_equal(3, count) end + def test_liberal_parsing + input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson' + assert_raise(CSV::MalformedCSVError) do + CSV.parse_line(input) + end + assert_equal(["Johnson, Dwayne", 'Dwayne "The Rock" Johnson'], + CSV.parse_line(input, liberal_parsing: true)) + + input = '"quoted" field' + assert_raise(CSV::MalformedCSVError) do + CSV.parse_line(input) + end + assert_equal(['"quoted" field'], + CSV.parse_line(input, liberal_parsing: true)) + + assert_raise(CSV::MalformedCSVError) do + CSV.parse_line('is,this "three," or four,fields', liberal_parsing: true) + end + + assert_equal(["is", 'this "three', ' or four"', "fields"], + CSV.parse_line('is,this "three, or four",fields', liberal_parsing: true)) + end + def test_csv_behavior_readers %w[ unconverted_fields return_headers write_headers skip_blanks force_quotes ].each do |behavior| |