diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-06 03:56:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-06 03:56:38 +0000 |
commit | 287a34ae0dfc23e4158f67cb7783d239f202c368 (patch) | |
tree | 5e35d5b41aae961b37cf6632f60c42f51c7aa775 /test/csv/test_headers.rb | |
parent | 9b52ae2e6491bb5d6c59e1799449f6268baf6f89 (diff) | |
download | ruby-287a34ae0dfc23e4158f67cb7783d239f202c368.tar.gz |
* {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/test_headers.rb')
-rw-r--r-- | test/csv/test_headers.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/test/csv/test_headers.rb b/test/csv/test_headers.rb index 6ce5675816..6e56ffc27c 100644 --- a/test/csv/test_headers.rb +++ b/test/csv/test_headers.rb @@ -19,12 +19,12 @@ class TestCSVHeaders < Test::Unit::TestCase 1,2,3 END_CSV end - + def test_first_row [:first_row, true].each do |setting| # two names for the same setting # activate headers csv = nil - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse(@data, headers: setting) end @@ -44,11 +44,11 @@ class TestCSVHeaders < Test::Unit::TestCase assert_nil(csv[2]) end end - + def test_array_of_headers # activate headers csv = nil - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse(@data, headers: [:my, :new, :headers]) end @@ -73,7 +73,7 @@ class TestCSVHeaders < Test::Unit::TestCase # empty assert_nil(csv[3]) - + # with return and convert assert_nothing_raised(Exception) do csv = CSV.parse( @data, headers: [:my, :new, :headers], @@ -87,11 +87,11 @@ class TestCSVHeaders < Test::Unit::TestCase assert(row.header_row?) assert(!row.field_row?) end - + def test_csv_header_string # activate headers csv = nil - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse(@data, headers: "my,new,headers") end @@ -115,7 +115,7 @@ class TestCSVHeaders < Test::Unit::TestCase # empty assert_nil(csv[3]) - + # with return and convert assert_nothing_raised(Exception) do csv = CSV.parse( @data, headers: "my,new,headers", @@ -129,11 +129,11 @@ class TestCSVHeaders < Test::Unit::TestCase assert(row.header_row?) assert(!row.field_row?) end - + def test_csv_header_string_inherits_separators # parse with custom col_sep csv = nil - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse( @data.tr(",", "|"), col_sep: "|", headers: "my|new|headers" ) end @@ -144,7 +144,7 @@ class TestCSVHeaders < Test::Unit::TestCase assert_instance_of(CSV::Row, row) assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a) end - + def test_return_headers # activate headers and request they are returned csv = nil @@ -180,14 +180,14 @@ class TestCSVHeaders < Test::Unit::TestCase # empty assert_nil(csv[3]) end - + def test_converters # create test data where headers and fields look alike data = <<-END_MATCHING_CSV.gsub(/^\s+/, "") 1,2,3 1,2,3 END_MATCHING_CSV - + # normal converters do not affect headers csv = CSV.parse( data, headers: true, return_headers: true, @@ -195,9 +195,9 @@ class TestCSVHeaders < Test::Unit::TestCase assert_equal([%w{1 1}, %w{2 2}, %w{3 3}], csv[0].to_a) assert_equal([["1", 1], ["2", 2], ["3", 3]], csv[1].to_a) assert_nil(csv[2]) - + # header converters do affect headers (only) - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse( data, headers: true, return_headers: true, converters: :numeric, @@ -207,21 +207,21 @@ class TestCSVHeaders < Test::Unit::TestCase assert_equal([[:"1", 1], [:"2", 2], [:"3", 3]], csv[1].to_a) assert_nil(csv[2]) end - + def test_builtin_downcase_converter csv = CSV.parse( "One,TWO Three", headers: true, return_headers: true, header_converters: :downcase ) assert_equal(%w{one two\ three}, csv.headers) end - + def test_builtin_symbol_converter csv = CSV.parse( "One,TWO Three", headers: true, return_headers: true, header_converters: :symbol ) assert_equal([:one, :two_three], csv.headers) end - + def test_custom_converter converter = lambda { |header| header.tr(" ", "_") } csv = CSV.parse( "One,TWO Three", @@ -230,56 +230,56 @@ class TestCSVHeaders < Test::Unit::TestCase header_converters: converter ) assert_equal(%w{One TWO_Three}, csv.headers) end - + def test_table_support csv = nil - assert_nothing_raised(Exception) do + assert_nothing_raised(Exception) do csv = CSV.parse(@data, headers: true) end - + assert_instance_of(CSV::Table, csv) end - + def test_skip_blanks @data = <<-END_CSV.gsub(/^ +/, "") - + A,B,C - + 1,2,3 - - - + + + END_CSV - + expected = [%w[1 2 3]] CSV.parse(@data, headers: true, skip_blanks: true) do |row| assert_equal(expected.shift, row.fields) end - + expected = [%w[A B C], %w[1 2 3]] CSV.parse( @data, headers: true, - return_headers: true, + return_headers: true, skip_blanks: true ) do |row| assert_equal(expected.shift, row.fields) end end - + def test_headers_reader # no headers assert_nil(CSV.new(@data).headers) - + # headers csv = CSV.new(@data, headers: true) assert_equal(true, csv.headers) # before headers are read csv.shift # set headers assert_equal(%w[first second third], csv.headers) # after headers are read end - + def test_blank_row_bug_fix @data += "\n#{@data}" # add a blank row - + # ensure that everything returned is a Row object CSV.parse(@data, headers: true) do |row| assert_instance_of(CSV::Row, row) |