mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
merges r28431 and r28432 from trunk into ruby_1_9_2.
-- * lib/csv.rb: Fixing a bug that prevented CSV from parsing all multi-line fields correctly. Patch by Rob Biedenham. -- Fixing a spelling error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a1a68a5810
commit
ba87ab3a7e
3 changed files with 29 additions and 2 deletions
|
@ -115,6 +115,22 @@ class TestCSVParsing < Test::Unit::TestCase
|
|||
assert_equal(Array.new, CSV.parse_line("\n1,2,3\n"))
|
||||
end
|
||||
|
||||
def test_rob_edge_cases
|
||||
[ [%Q{"a\nb"}, ["a\nb"]],
|
||||
[%Q{"\n\n\n"}, ["\n\n\n"]],
|
||||
[%Q{a,"b\n\nc"}, ['a', "b\n\nc"]],
|
||||
[%Q{,"\r\n"}, [nil,"\r\n"]],
|
||||
[%Q{,"\r\n."}, [nil,"\r\n."]],
|
||||
[%Q{"a\na","one newline"}, ["a\na", 'one newline']],
|
||||
[%Q{"a\n\na","two newlines"}, ["a\n\na", 'two newlines']],
|
||||
[%Q{"a\r\na","one CRLF"}, ["a\r\na", 'one CRLF']],
|
||||
[%Q{"a\r\n\r\na","two CRLFs"}, ["a\r\n\r\na", 'two CRLFs']],
|
||||
[%Q{with blank,"start\n\nfinish"\n}, ['with blank', "start\n\nfinish"]],
|
||||
].each do |edge_case|
|
||||
assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
|
||||
end
|
||||
end
|
||||
|
||||
def test_non_regex_edge_cases
|
||||
# An early version of the non-regex parser fails this test
|
||||
[ [ "foo,\"foo,bar,baz,foo\",\"foo\"",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue