Sha256: 2faa70559f2b973334cd3fb6228daa1d53b119b237c3e2b4b221e7c19fa9c175
Contents?: true
Size: 1.42 KB
Versions: 23
Compression:
Stored size: 1.42 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'test_helper.rb')) require 'rbbt/tsv' class TestTSVParser < Test::Unit::TestCase def test_flat TmpFile.with_file do |tmpdir| file = File.join(tmpdir, 'file') str =<<-EOF #: :type=:flat#:sep=' ' #Key Value a b c d e A B C D E EOF Open.write(file, str) Open.open(file) do |io| parser = TSV::Parser.new(io, :merge => true, :zipped => true, :type => :double) parser.traverse do |k,v| assert v.length > 1 end end end end def test_traverse content =<<-EOF row1 a|aa|aaa b Id1|Id2 EOF TmpFile.with_file(content) do |filename| TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :double) do |k,v| assert_equal ["row1"], k assert_equal [%w(a aa aaa)], v end TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :list) do |k,v| assert_equal "row1", k assert_equal ["a|aa|aaa"], v end TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :single) do |k,v| assert_equal "row1", k assert_equal "a|aa|aaa", v end TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :flat) do |k,v| assert_equal ["row1"], k assert_equal %w(a aa aaa), v end end end end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
rbbt-util-5.25.13 | test/rbbt/tsv/test_parser.rb |
rbbt-util-5.25.12 | test/rbbt/tsv/test_parser.rb |
rbbt-util-5.25.10 | test/rbbt/tsv/test_parser.rb |