test/rbbt/util/tsv/test_index.rb in rbbt-util-3.1.0 vs test/rbbt/util/tsv/test_index.rb in rbbt-util-3.2.0
- old
+ new
@@ -151,7 +151,39 @@
assert_equal %w(a b d), f[3].sort
assert_equal %w(a b c d e), f[(3..4)].sort
end
end
+ def test_pos_index
+ content =<<-EOF
+#Id ValueA ValueB Pos
+row1 a|aa|aaa b 0|10
+row2 A B 30
+ EOF
+
+ TmpFile.with_file(content) do |filename|
+ tsv = TSV.new(File.open(filename), :double, :sep => /\s+/)
+ index = tsv.pos_index("Pos", :memory, true)
+ assert_equal ["row1"], index[10]
+ end
+ end
+
+
+ def test_range_index
+ content =<<-EOF
+#Id ValueA ValueB Pos1 Pos2
+row1 a|aa|aaa b 0|10 10|30
+row2 A B 30 35
+ EOF
+
+ TmpFile.with_file(content) do |filename|
+ tsv = TSV.new(File.open(filename), :double, :sep => /\s+/)
+ index = tsv.pos_index("Pos1", :memory, true)
+ assert_equal ["row1"], index[10]
+
+ index = tsv.range_index("Pos1", "Pos2", :memory, true)
+ assert_equal ["row1"], index[20]
+ end
+ end
+
end