# :nodoc: all require "test/unit" require "n/utils/cache" class TC_N2_Utils_Cache < Test::Unit::TestCase # :nodoc: all include N 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