2018-05-05 19:11:08 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
2018-05-08 18:59:43 +02:00
|
|
|
# tests that do no require a boot and only test basic positioning
|
2018-05-07 21:30:43 +02:00
|
|
|
class TestPositionBasic < MiniTest::Test
|
2018-05-05 19:11:08 +02:00
|
|
|
|
|
|
|
def test_creation_ok
|
|
|
|
assert Position.new(0)
|
|
|
|
end
|
|
|
|
def test_creation_fail
|
|
|
|
assert_raises {Position.new("0")}
|
|
|
|
end
|
|
|
|
def test_add
|
|
|
|
res = Position.new(0) + 5
|
|
|
|
assert_equal 5 , res
|
|
|
|
end
|
|
|
|
def test_sub
|
|
|
|
res = Position.new(5) - 1
|
|
|
|
assert_equal 4 , res
|
|
|
|
end
|
2018-05-05 19:25:10 +02:00
|
|
|
def test_sub_pos
|
|
|
|
res = Position.new(5) - Position.new(1)
|
|
|
|
assert_equal 4 , res
|
|
|
|
end
|
2018-05-05 19:11:08 +02:00
|
|
|
def test_set
|
2018-05-06 19:04:02 +02:00
|
|
|
pos = Position.set(self , 5)
|
2018-05-05 19:11:08 +02:00
|
|
|
assert_equal 5 , pos.at
|
|
|
|
end
|
2018-05-05 19:25:10 +02:00
|
|
|
def tet_tos
|
2018-05-06 19:04:02 +02:00
|
|
|
assert_equal "0x10" , Position.set(self).to_s
|
2018-05-05 19:25:10 +02:00
|
|
|
end
|
2018-05-05 19:11:08 +02:00
|
|
|
def test_reset_ok
|
2018-05-06 19:04:02 +02:00
|
|
|
pos = Position.set(self , 5)
|
|
|
|
pos = Position.set(self , 10)
|
2018-05-05 19:11:08 +02:00
|
|
|
assert_equal 10 , pos.at
|
|
|
|
end
|
|
|
|
def test_reset_fail
|
2018-05-06 19:04:02 +02:00
|
|
|
Position.set(self , 5)
|
|
|
|
assert_raises{Position.set(self , 10000)}
|
2018-05-05 19:11:08 +02:00
|
|
|
end
|
|
|
|
def test_raises_set_nil
|
2018-05-06 19:04:02 +02:00
|
|
|
assert_raises { Position.set(self,nil)}
|
2018-05-05 19:11:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|