Sha256: f301db511c171a0e8e2ae8c0ce016d3344b19b8b0935faa2164c087318cbff13

Contents?: true

Size: 991 Bytes

Versions: 36

Compression:

Stored size: 991 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'rbbt/tsv'
require 'rbbt/tsv/util'
require 'rbbt/util/tmpfile'
require 'test/unit'

class TestTSVUtil < Test::Unit::TestCase

  def test_field_counts
   content =<<-EOF
#Id    ValueA    ValueB    OtherID
row1    a|aa|aaa    b    Id1|Id2
row2    A    B    Id3
    EOF

    TmpFile.with_file(content) do |filename|
      tsv = TSV.open(filename, :sep => /\s+/)

      assert_equal 2, TSV.field_match_counts(tsv, ["a","A","a","b","Id3"])["ValueA"]
      assert_equal nil, TSV.field_match_counts(tsv, ["ValueA"])["ValueA"]
    end
  end

  def test_replicates
   content =<<-EOF
#Id    ValueA    ValueB    OtherID
row1    a|aa|aaa    b|bb|bbb    Id1|Id2|Id3
row2    A    B    Id3
    EOF

    TmpFile.with_file(content) do |filename|
      tsv = TSV.open(filename, :sep => /\s+/)

      assert_equal 4, tsv.unzip_replicates.length
      assert_equal %w(aa bb Id2), tsv.unzip_replicates["row1(1)"]
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
rbbt-util-5.38.1 test/rbbt/tsv/test_util.rb
rbbt-util-5.38.0 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.16 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.15 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.14 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.13 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.12 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.11 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.10 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.9 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.8 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.6 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.4 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.3 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.1 test/rbbt/tsv/test_util.rb
rbbt-util-5.37.0 test/rbbt/tsv/test_util.rb
rbbt-util-5.36.0 test/rbbt/tsv/test_util.rb
rbbt-util-5.35.4 test/rbbt/tsv/test_util.rb
rbbt-util-5.35.3 test/rbbt/tsv/test_util.rb
rbbt-util-5.35.2 test/rbbt/tsv/test_util.rb