Sha256: 7f4299accd67ad82a486aec5f401303c4645e157082e403f5ce5531ebbe4c77e

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper.rb')
require 'rbbt/packed_index'

class TestPackedIndex < Test::Unit::TestCase
  def test_index

    TmpFile.with_file do |tmpfile|
      pi = PackedIndex.new 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
      pi = PackedIndex.new tmpfile, false
      Misc.benchmark(1000) do
      100.times do |i|
        assert_equal i, pi[i][0] 
        assert_equal i+2, pi[i][1] 
      end
      end
      assert_equal nil, pi[100]
      assert_equal nil, pi[101]

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbbt-util-5.14.3 test/rbbt/test_packed_index.rb
rbbt-util-5.14.2 test/rbbt/test_packed_index.rb
rbbt-util-5.14.1 test/rbbt/test_packed_index.rb
rbbt-util-5.14.0 test/rbbt/test_packed_index.rb