2014-06-25 15:00:24 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
2015-05-12 18:03:14 +02:00
|
|
|
class TestDictionary < MiniTest::Test
|
2014-06-25 15:00:24 +02:00
|
|
|
|
|
|
|
def setup
|
2015-05-12 18:10:45 +02:00
|
|
|
@lookup = ::Parfait::Dictionary.new
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_list_create
|
2015-05-12 18:03:14 +02:00
|
|
|
assert @lookup.empty?
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_empty_list_doesnt_return
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal nil , @lookup.get(3)
|
|
|
|
assert_equal nil , @lookup.get(:any)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_one_set1
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal 1 , @lookup.set(1,1)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_one_set2
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal :some , @lookup.set(1,:some)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_two_sets
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal 1 , @lookup.set(1,1)
|
|
|
|
assert_equal :some , @lookup.set(1,:some)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_one_get1
|
|
|
|
test_one_set1
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal 1 , @lookup.get(1)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_one_get2
|
|
|
|
test_one_set2
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal :some , @lookup.get(1)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
def test_many_get
|
|
|
|
shouldda = { :one => 1 , :two => 2 , :three => 3}
|
|
|
|
shouldda.each do |k,v|
|
2015-05-12 18:03:14 +02:00
|
|
|
@lookup.set(k,v)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
shouldda.each do |k,v|
|
2015-05-12 18:03:14 +02:00
|
|
|
assert_equal v , @lookup.get(k)
|
2014-06-25 15:00:24 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|