Sha256: bf0692c1e06a595e285218486b3b209f02c4182b5db598cb702e5806954672f9

Contents?: true

Size: 554 Bytes

Versions: 6

Compression:

Stored size: 554 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

6 entries across 6 versions & 1 rubygems

Version Path
hexapdf-0.6.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.5.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.4.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.3.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.2.0 test/hexapdf/utils/test_lru_cache.rb
hexapdf-0.1.0 test/hexapdf/utils/test_lru_cache.rb