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