Sha256: 5157a1de14f0544b139397eccdda879b2966be0f6475f016da4e1689225cf204

Contents?: true

Size: 555 Bytes

Versions: 93

Compression:

Stored size: 555 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/utils/lru_cache'

describe HexaPDF::Utils::LRUCache do
  before do
    @cache = HexaPDF::Utils::LRUCache.new(5)
    5.times {|i| @cache[i] = i * 2 }
  end

  it "removes the LRU item when the size is reached" do
    assert([1, 2], @cache.instance_variable_get(:@cache).first)
    @cache[6] = 7
    assert([2, 4], @cache.instance_variable_get(:@cache).first)
  end

  it "freshes an item on access" do
    @cache[1]
    assert([2, 4], @cache.instance_variable_get(:@cache).first)
  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
hexapdf-1.1.1 test/hexapdf/utils/test_lru_cache.rb
hexapdf-1.1.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-1.0.3 test/hexapdf/utils/test_lru_cache.rb
hexapdf-1.0.2 test/hexapdf/utils/test_lru_cache.rb
hexapdf-1.0.1 test/hexapdf/utils/test_lru_cache.rb
hexapdf-1.0.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.47.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.46.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.45.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.44.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.41.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.40.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.39.1 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.39.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.38.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.37.2 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.37.1 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.37.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.36.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.35.1 test/hexapdf/utils/test_lru_cache.rb