diff options
author | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-24 00:44:41 +0000 |
---|---|---|
committer | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-24 00:44:41 +0000 |
commit | 895e9b0acd986cf3dba7df60fb00c5ca3607c844 (patch) | |
tree | 77fc34aee486de9e092b82b7427d8d7f461b2128 /test/csv/test_interface.rb | |
parent | 34176b023eb42478bad22481d90d6223b5a31d48 (diff) | |
download | ruby-895e9b0acd986cf3dba7df60fb00c5ca3607c844.tar.gz |
* lib/csv.rb: Optimize header hashes by freezing string keys.
[ruby-core:58510]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/test_interface.rb')
-rwxr-xr-x | test/csv/test_interface.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/csv/test_interface.rb b/test/csv/test_interface.rb index ad310fae49..22907d2dd0 100755 --- a/test/csv/test_interface.rb +++ b/test/csv/test_interface.rb @@ -198,6 +198,25 @@ class TestCSV::Interface < TestCSV end end + def test_write_hash_with_string_keys + File.unlink(@path) + + lines = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}] + CSV.open( @path, "wb", headers: true ) do |csv| + csv << lines.first.keys + lines.each { |line| csv << line } + end + CSV.open( @path, "rb", headers: true ) do |csv| + csv.each do |line| + csv.headers.each_with_index do |header, h| + keys = line.to_hash.keys + assert_instance_of(String, keys[h]) + assert_same(header, keys[h]) + end + end + end + end + def test_write_hash_with_headers_array File.unlink(@path) |