summaryrefslogtreecommitdiff
path: root/test/csv
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-25 08:32:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-25 08:32:27 +0000
commit9c017ca5fb24e89463e5aee0304bd6a2305143df (patch)
treeee21e9905aaf9933c9e8f3ddd9b2bc1966cf1781 /test/csv
parent9a907880f05fef475d5b61ed7f03f045b6103ed8 (diff)
* lib/csv.rb (CSV#init_separators): use IO#gets with length
parameter to get rid of wrong convertion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv')
-rwxr-xr-xtest/csv/test_encodings.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb
index 0f2ec12..59f43b1 100755
--- a/test/csv/test_encodings.rb
+++ b/test/csv/test_encodings.rb
@@ -238,12 +238,28 @@ class TestCSV::Encodings < TestCSV
def assert_parses(fields, encoding, options = { })
encoding = Encoding.find(encoding) unless encoding.is_a? Encoding
+ orig_fields = fields
fields = encode_ary(fields, encoding)
- parsed = CSV.parse(ary_to_data(fields, options), options)
+ data = ary_to_data(fields, options)
+ parsed = CSV.parse(data, options)
assert_equal(fields, parsed)
parsed.flatten.each_with_index do |field, i|
assert_equal(encoding, field.encoding, "Field[#{i + 1}] was transcoded.")
end
+ File.open(@temp_csv_path, "wb") {|f| f.print(data)}
+ CSV.open(@temp_csv_path, "rb:#{encoding}", options) do |csv|
+ csv.each_with_index do |row, i|
+ assert_equal(fields[i], row)
+ end
+ end
+ begin
+ CSV.open(@temp_csv_path, "rb:#{encoding}:#{__ENCODING__}", options) do |csv|
+ csv.each_with_index do |row, i|
+ assert_equal(orig_fields[i], row)
+ end
+ end unless encoding == __ENCODING__
+ rescue Encoding::ConverterNotFoundError
+ end
end
def encode_ary(ary, encoding)