Sha256: e996b0be8da3c3ac70d559abb83135c60f701b42625d9d6aacbf73eadac579f6

Contents?: true

Size: 777 Bytes

Versions: 3

Compression:

Stored size: 777 Bytes

Contents

require "test/unit"
require "glue/hash"

class TestCaseGlueCache < Test::Unit::TestCase # :nodoc: all
  include Glue

  def setup
    @safe_cache = SafeHash.new(Hash.new)
  end

  def teardown
    @safe_cache = nil
  end

  def test_safe_cache
    assert_equal(nil, @safe_cache["no_item"])
    item1 =  "item1"
    @safe_cache["key1"] = item1
    assert_equal(item1, @safe_cache["key1"])

    @safe_cache["rem1"] = item1
    @safe_cache.delete("rem1")
    assert_equal(nil, @safe_cache["rem1"])

    @safe_cache.clear()
    assert_equal(0, @safe_cache.size)

    @safe_cache["i1"] = "i1"
    @safe_cache["i2"] = "i1"
    @safe_cache["i3"] = "i1"
    assert_equal(3, @safe_cache.size)

    assert_equal(3, @safe_cache.values.size)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glue-0.21.0 test/glue/tc_hash.rb
glue-0.21.2 test/glue/tc_hash.rb
glue-0.22.0 test/glue/tc_hash.rb