rubyx/test/parfait/test_dictionary.rb

44 lines
995 B
Ruby
Raw Normal View History

require_relative "../helper"
class TestDictionary < MiniTest::Test
2015-10-22 17:16:29 +02:00
Register.machine.boot #have to book, otherwise layouts etc not set
def setup
@lookup = ::Parfait::Dictionary.new
end
2015-05-17 14:34:29 +02:00
def test_dict_create
assert @lookup.empty?
end
2015-05-17 14:34:29 +02:00
def test_empty_dict_doesnt_return
assert_equal nil , @lookup.get(3)
assert_equal nil , @lookup.get(:any)
end
def test_one_set1
assert_equal 1 , @lookup.set(1,1)
end
def test_one_set2
assert_equal :some , @lookup.set(1,:some)
end
def test_two_sets
assert_equal 1 , @lookup.set(1,1)
assert_equal :some , @lookup.set(1,:some)
end
def test_one_get1
test_one_set1
assert_equal 1 , @lookup.get(1)
end
def test_one_get2
test_one_set2
assert_equal :some , @lookup.get(1)
end
def test_many_get
shouldda = { :one => 1 , :two => 2 , :three => 3}
shouldda.each do |k,v|
@lookup.set(k,v)
end
2015-10-16 17:34:54 +02:00
@lookup.each do |k,v|
assert_equal v , shouldda[k]
end
end
end