aboutsummaryrefslogtreecommitdiffstats
path: root/test/csv/tc_encodings.rb
diff options
context:
space:
mode:
authorjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-10 15:09:34 +0000
committerjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-10 15:09:34 +0000
commit7d3d3535584bd70d0a9a0f5f9abc3aeeea115c5a (patch)
treeb2f1a5c1c3c8816f2fb2a23f16be169cc89ed9c8 /test/csv/tc_encodings.rb
parentaa2797ee41a531ac05b4a92ad713a4b9f3c9f756 (diff)
downloadruby-7d3d3535584bd70d0a9a0f5f9abc3aeeea115c5a.tar.gz
* lib/csv/csv.rb: Added support for Encoding::default_internal.
* lib/csv/csv.rb: Switched to new Hash syntax. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/tc_encodings.rb')
-rw-r--r--test/csv/tc_encodings.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/csv/tc_encodings.rb b/test/csv/tc_encodings.rb
index 6f88d089ea..0a300af291 100644
--- a/test/csv/tc_encodings.rb
+++ b/test/csv/tc_encodings.rb
@@ -67,7 +67,7 @@ class TestEncodings < Test::Unit::TestCase
each_encoding do |encoding|
begin
assert_parses( [ %w[ abc def ],
- %w[ ghi jkl ] ], encoding, :col_sep => "|" )
+ %w[ ghi jkl ] ], encoding, col_sep: "|" )
rescue Encoding::ConverterNotFoundError
fail("Failed to properly escape #{encoding.name}.")
end
@@ -80,7 +80,7 @@ class TestEncodings < Test::Unit::TestCase
def test_auto_line_ending_detection
# arrange data to place a \r at the end of CSV's read ahead point
- encode_for_tests([["a" * 509]], :row_sep => "\r\n") do |data|
+ encode_for_tests([["a" * 509]], row_sep: "\r\n") do |data|
assert_equal("\r\n".encode(data.encoding), CSV.new(data).row_sep)
end
end
@@ -96,7 +96,7 @@ class TestEncodings < Test::Unit::TestCase
def test_parser_works_with_encoded_headers
encode_for_tests([%w[one two three], %w[1 2 3]]) do |data|
- parsed = CSV.parse(data, :headers => true)
+ parsed = CSV.parse(data, headers: true)
assert( parsed.headers.all? { |h| h.encoding == data.encoding },
"Wrong data encoding." )
parsed.each do |row|
@@ -108,7 +108,7 @@ class TestEncodings < Test::Unit::TestCase
def test_built_in_converters_transcode_to_utf_8_then_convert
encode_for_tests([%w[one two three], %w[1 2 3]]) do |data|
- parsed = CSV.parse(data, :converters => :integer)
+ parsed = CSV.parse(data, converters: :integer)
assert( parsed[0].all? { |f| f.encoding == data.encoding },
"Wrong data encoding." )
assert_equal([1, 2, 3], parsed[1])
@@ -117,8 +117,8 @@ class TestEncodings < Test::Unit::TestCase
def test_built_in_header_converters_transcode_to_utf_8_then_convert
encode_for_tests([%w[one two three], %w[1 2 3]]) do |data|
- parsed = CSV.parse( data, :headers => true,
- :header_converters => :downcase )
+ parsed = CSV.parse( data, headers: true,
+ header_converters: :downcase )
assert( parsed.headers.all? { |h| h.encoding.name == "UTF-8" },
"Wrong data encoding." )
assert( parsed[0].fields.all? { |f| f.encoding == data.encoding },
@@ -154,7 +154,7 @@ class TestEncodings < Test::Unit::TestCase
encode_for_tests([%w[abc def]]) do |data|
# read and write in encoding
File.open(@temp_csv_path, "wb:#{data.encoding.name}") { |f| f << data }
- CSV.foreach(@temp_csv_path, :encoding => data.encoding.name) do |row|
+ CSV.foreach(@temp_csv_path, encoding: data.encoding.name) do |row|
assert( row.all? { |f| f.encoding == data.encoding },
"Wrong data encoding." )
end
@@ -164,7 +164,7 @@ class TestEncodings < Test::Unit::TestCase
f << data
end
CSV.foreach( @temp_csv_path,
- :encoding => "UTF-32BE:#{data.encoding.name}" ) do |row|
+ encoding: "UTF-32BE:#{data.encoding.name}" ) do |row|
assert( row.all? { |f| f.encoding == data.encoding },
"Wrong data encoding." )
end
@@ -175,7 +175,7 @@ class TestEncodings < Test::Unit::TestCase
encode_for_tests([%w[abc def]]) do |data|
# read and write in encoding
File.open(@temp_csv_path, "wb:#{data.encoding.name}") { |f| f << data }
- rows = CSV.read(@temp_csv_path, :encoding => data.encoding.name)
+ rows = CSV.read(@temp_csv_path, encoding: data.encoding.name)
assert( rows.flatten.all? { |f| f.encoding == data.encoding },
"Wrong data encoding." )
@@ -184,7 +184,7 @@ class TestEncodings < Test::Unit::TestCase
f << data
end
rows = CSV.read( @temp_csv_path,
- :encoding => "UTF-32BE:#{data.encoding.name}" )
+ encoding: "UTF-32BE:#{data.encoding.name}" )
assert( rows.flatten.all? { |f| f.encoding == data.encoding },
"Wrong data encoding." )
end
@@ -198,11 +198,11 @@ class TestEncodings < Test::Unit::TestCase
each_encoding do |encoding|
# test generate_line with encoding hint
csv = %w[abc d|ef].map { |f| f.encode(encoding) }.
- to_csv(:col_sep => "|", :encoding => encoding.name)
+ to_csv(col_sep: "|", encoding: encoding.name)
assert_equal(encoding, csv.encoding)
# test generate_line with encoding guessing from fields
- csv = %w[abc d|ef].map { |f| f.encode(encoding) }.to_csv(:col_sep => "|")
+ csv = %w[abc d|ef].map { |f| f.encode(encoding) }.to_csv(col_sep: "|")
assert_equal(encoding, csv.encoding)
# writing to files
@@ -210,7 +210,7 @@ class TestEncodings < Test::Unit::TestCase
CSV.open(@temp_csv_path, "wb:#{encoding.name}") do |f|
data.each { |row| f << row }
end
- assert_equal(data, CSV.read(@temp_csv_path, :encoding => encoding.name))
+ assert_equal(data, CSV.read(@temp_csv_path, encoding: encoding.name))
end
end