Skip to content

Commit 33f6cbc

Browse files
committed
Add additional test for :single_encoding
1 parent ba56df7 commit 33f6cbc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/csv/test_table.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,16 @@ def test_to_csv_single_encoding
381381
assert_equal('ASCII-8BIT', table.to_csv(single_encoding: true).encoding.to_s)
382382
assert_equal('UTF-8', table.to_csv(encoding: 'UTF-8').encoding.to_s)
383383
assert_raises(Encoding::CompatibilityError) {table.to_csv}
384+
385+
headers = %w{id language description}
386+
rows = [ CSV::Row.new(headers, ["English", "ascii-only row"]),
387+
CSV::Row.new(headers, ["Français", "alphabet + cédille first non-ascii row"]),
388+
CSV::Row.new(headers, ["Español", "alphabet + ntilde character row"])]
389+
table = CSV::Table.new(rows)
390+
391+
assert_equal('UTF-8', table.to_csv.encoding.to_s)
392+
assert_equal('UTF-8', table.to_csv(single_encoding: true).encoding.to_s)
393+
assert_equal(table.to_csv, table.to_csv(single_encoding: true))
384394
end
385395

386396
def test_append

0 commit comments

Comments
 (0)