Sha256: 56b576ff1274de545edab18b4ef56fed12d2532f9926e78a6ac84a6f07e649a6

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

# :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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.2.0 test/n/utils/tc_hash.rb
nitro-0.3.0 test/n/utils/tc_hash.rb