Sha256: 75d02d9c501c2fabc435b9834b300b39b9dafcedc76449c4a666b5a9f03816a8

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')

class TestClass < Test::Unit::TestCase
  def test_open
    TmpFile.with_file do |tmpfile|
      pi = Persist.open_pki tmpfile, true, %w(i i 23s f f f f f)
      100.times do |i|
        pi << [i, i+2, i.to_s * 10, rand, rand, rand, rand, rand]
      end
      pi << nil
      pi << nil
      pi.close

      TSV.setup(pi, :key_field => "Number", :fields => %w(i i2 s f1 f2 f3 f4 f5), :type => :list)

      pi = PackedIndex.new(tmpfile, false)
      100.times do |i|
        assert_equal i, pi[i][0] 
        assert_equal i+2, pi[i][1] 
      end
      assert_equal nil, pi[100]
      assert_equal nil, pi[101]

      pi = Persist.open_pki tmpfile, false, %w(i i 23s f f f f f)
      100.times do |i|
        assert_equal i, pi[i][0] 
        assert_equal i+2, pi[i][1] 
      end
      assert_equal nil, pi[100]
      assert_equal nil, pi[101]

      assert_equal "Number", pi.key_field
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scout-gear-10.7.3 test/scout/persist/tsv/adapter/test_packed_index.rb
scout-gear-10.7.2 test/scout/persist/tsv/adapter/test_packed_index.rb
scout-gear-10.7.1 test/scout/persist/tsv/adapter/test_packed_index.rb
scout-gear-10.7.0 test/scout/persist/tsv/adapter/test_packed_index.rb