2015-05-17 13:38:25 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
class TestObject < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
2015-07-20 12:01:15 +02:00
|
|
|
@object = ::Parfait::Object.new
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
|
2015-05-17 14:34:29 +02:00
|
|
|
def test_object_create
|
2015-11-02 10:34:08 +01:00
|
|
|
# another test sometime adds a field variable. Maybe should reboot ?
|
2015-11-02 16:32:06 +01:00
|
|
|
res = 1
|
|
|
|
[:boo1 , :boo2 , :runner].each { |v| res += 1 if @object.get_layout.variable_index(v) }
|
2015-11-02 10:34:08 +01:00
|
|
|
assert_equal res , @object.get_layout.instance_length , @object.get_layout.inspect
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
|
2015-05-17 14:34:29 +02:00
|
|
|
def test_empty_object_doesnt_return
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal nil , @object.get_internal(3)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_one_set1
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal 1 , @object.set_internal(1,1)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_one_set2
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal :some , @object.set_internal(2,:some)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
2015-10-26 11:22:32 +01:00
|
|
|
|
2015-05-17 13:38:25 +02:00
|
|
|
def test_two_sets
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal 1 , @object.set_internal(1,1)
|
|
|
|
assert_equal :some , @object.set_internal(1,:some)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
def test_one_get1
|
|
|
|
test_one_set1
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal 1 , @object.get_internal(1)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
def test_one_get2
|
|
|
|
test_one_set2
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal :some , @object.get_internal(2)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
def test_many_get
|
|
|
|
shouldda = { 1 => :one , 2 => :two , 3 => :three}
|
|
|
|
shouldda.each do |k,v|
|
2015-11-07 16:40:59 +01:00
|
|
|
@object.set_internal(k,v)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
shouldda.each do |k,v|
|
2015-11-07 16:40:59 +01:00
|
|
|
assert_equal v , @object.get_internal(k)
|
2015-05-17 13:38:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|