Skip to content

Commit b455a09

Browse files
committed
test: consolidate unquoted CR tests, remove duplication
1 parent 313f849 commit b455a09

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

test/csv/parse/test_general.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,29 +156,13 @@ def test_unquoted_cr_with_custom_row_separator
156156
assert_equal(expected, CSV.parse(data, row_sep: "|"))
157157
end
158158

159-
def test_unquoted_cr_with_crlf_row_separator
160-
data = "field1\r,field2,field3\r\nrow2,data,here\r\n"
161-
assert_raise(CSV::MalformedCSVError) do
162-
CSV.parse(data, row_sep: "\r\n")
163-
end
164-
end
165-
166159
def test_unquoted_cr_rejected_when_included_in_row_separator
167160
data = "field1,field\r2,field3\r\nrow2,data,here\r\n"
168161
assert_raise(CSV::MalformedCSVError) do
169162
CSV.parse(data, row_sep: "\r\n")
170163
end
171164
end
172165

173-
def test_liberal_parsing_with_unquoted_cr_and_custom_row_separator
174-
data = "field1,field\rwith\rcr,field3|row2,data,here|"
175-
expected = [
176-
["field1", "field\rwith\rcr", "field3"],
177-
["row2", "data", "here"]
178-
]
179-
assert_equal(expected, CSV.parse(data, row_sep: "|", liberal_parsing: true))
180-
end
181-
182166
def test_quoted_cr_with_custom_row_separator
183167
data = "field1,\"field\rwith\rcr\",field3|row2,data,here|"
184168
expected = [

test/csv/parse/test_liberal_parsing.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ def test_space_quote
8080
CSV.parse(input, liberal_parsing: true))
8181
end
8282

83+
def test_unquoted_cr_with_custom_row_separator
84+
data = "field1,field\rwith\rcr,field3|row2,data,here|"
85+
expected = [
86+
["field1", "field\rwith\rcr", "field3"],
87+
["row2", "data", "here"]
88+
]
89+
assert_equal(expected, CSV.parse(data, row_sep: "|", liberal_parsing: true))
90+
end
91+
8392
def test_double_quote_outside_quote
8493
data = %Q{a,""b""}
8594
error = assert_raise(CSV::MalformedCSVError) do

0 commit comments

Comments
 (0)