Sha256: 89ca1a6ffc5a9908c7d38fa542bdc7e72dfd0e7003776e5c4ddb690cfd084148

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

#!/usr/local/bin/ruby
if $0 == __FILE__
  Dir.chdir File.dirname(__FILE__)+'/../'
  $:.unshift File.expand_path('../lib/')
end

require 'rio'
require 'tc/testcase'
require 'tc/csvutil'

class TC_csv_columns < Test::RIO::TestCase
  include CSV_Util

  @@once = false
  def self.once
    @@once = true
  end
  def setup()
    super
    @src = rio(?")
    @dst_name = 'dst.csv'
    @records,@strings,@lines,@string = create_test_csv_data(@src,1, 8, false)
  end

  def test_basic

    rio('src1.csv') < @src
    r = @records[0]
    assert_equal([[r[1],r[2],r[5]]],rio('src1.csv').csv.columns(1,2,5).to_a)
    assert_equal([r[3...6]],rio('src1.csv').csv.columns(3...6).to_a)
    assert_equal([[r[3],r[5]]],rio('src1.csv').csv.columns(3...6).nocolumns(4).to_a)
    assert_equal([[r[0],r[7]]],rio('src1.csv').csv.nocolumns(1..6).to_a)
    assert_equal([[]],rio('src1.csv').csv.nocolumns.to_a)
    assert_equal([r],rio('src1.csv').csv.to_a)
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rio-0.3.3 test/tc/csv_columns.rb
rio-0.3.4 test/tc/csv_columns.rb