2018-05-10 19:56:12 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
module Position
|
|
|
|
# tests that do no require a boot and only test basic positioning
|
|
|
|
class TestPositionBasic < MiniTest::Test
|
|
|
|
|
|
|
|
def test_creation_ok
|
2018-05-23 20:34:49 +02:00
|
|
|
assert ObjectPosition.new(self,0)
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
def test_creation_fail
|
|
|
|
assert_raises {Position.new("0")}
|
|
|
|
end
|
|
|
|
def test_add
|
2018-05-23 20:34:49 +02:00
|
|
|
res = ObjectPosition.new(self,0) + 5
|
2018-05-10 19:56:12 +02:00
|
|
|
assert_equal 5 , res
|
|
|
|
end
|
|
|
|
def test_sub
|
2018-05-23 20:34:49 +02:00
|
|
|
res = ObjectPosition.new(self,0) - 1
|
|
|
|
assert_equal -1 , res
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
def test_sub_pos
|
2018-05-23 20:34:49 +02:00
|
|
|
res = ObjectPosition.new(self,0) - ObjectPosition.new(self,0)
|
|
|
|
assert_equal 0 , res
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
def test_set
|
|
|
|
pos = Position.set(self , 5)
|
|
|
|
assert_equal 5 , pos.at
|
|
|
|
end
|
|
|
|
def tet_tos
|
|
|
|
assert_equal "0x10" , Position.set(self).to_s
|
|
|
|
end
|
|
|
|
def test_reset_ok
|
|
|
|
pos = Position.set(self , 5)
|
|
|
|
pos = Position.set(self , 10)
|
|
|
|
assert_equal 10 , pos.at
|
|
|
|
end
|
|
|
|
def test_reset_fail
|
|
|
|
Position.set(self , 5)
|
|
|
|
assert_raises{Position.set(self , 10000)}
|
|
|
|
end
|
|
|
|
def test_raises_set_nil
|
|
|
|
assert_raises { Position.set(self,nil)}
|
|
|
|
end
|
2018-05-17 19:13:33 +02:00
|
|
|
def test_at
|
|
|
|
pos = Position.set(self , 5)
|
|
|
|
pos = Position.at(5)
|
|
|
|
assert_equal 5 , pos.at
|
|
|
|
end
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|