test/tc_csv_parsing.rb in fastercsv-1.5.3 vs test/tc_csv_parsing.rb in fastercsv-1.5.4
- old
+ new
@@ -107,9 +107,25 @@
# in these cases, but <tt>Array.new</tt> makes more sense to me.
#
assert_equal(Array.new, FasterCSV.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, FasterCSV.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\"", ["foo", "foo,bar,baz,foo", "foo"]]].each do |edge_case|
assert_equal(edge_case.last, FasterCSV.parse_line(edge_case.first))
end