def test_path_invalid(): """ Pathクラスのテスト。不正な入力ver. """ with pytest.raises(ArithmeticError): path = Path() # (0,1) => (0,2)の経路を登録 path.set_path((0, 1), (0, 2)) # (0,2) => (0,3)の経路を登録 path.set_path((0, 2), (0, 3)) # 存在しない始点を入力として運搬経路を取得する path.search_path((1, 2), (0, 3))
def test_current_direction(): solver = create_block_bingo([(1, 0), (2, 0), (2, 1)]) # 走行体の現在地と向きを確認する assert (2.5, 1) == solver.position assert 2 == solver.direction # (2.5,1) => (2,1) => (2,2)に移動する path = Path() path.set_path((2.5, 1), (2, 1)) solver.direction = 0 solver.position = (2, 1) # 走行体の向きが北向きになっていることを確認する assert 0 == solver.current_direction((2, 1), path) path.set_path((2, 1), (2, 2)) # 走行体の向きが東向きになっていることを確認する assert 2 == solver.current_direction((2, 2), path)
def test_path(): """ Pathクラスのテスト。 """ path = Path() # (0,1) => (0,2)の経路を登録 path.set_path((0, 1), (0, 2)) # (0,1) => (0,2)の経路が登録されていることを確認 assert (0, 1) == path.get((0, 2)) # (0,1) => (0,3)の経路を登録 path.set_path((0, 1), (0, 3)) # (0,1) => (0,3)の経路が登録されていることを確認 assert (0, 1) == path.get((0, 3)) # 経路[(0,1), (0,2)]が取得できることを確認 assert [(0, 1), (0, 2)] == path.search_path((0, 1), (0, 2)) # 経路[(0,1). (0,3)]が取得できることを確認 assert [(0, 1), (0, 3)] == path.search_path((0, 1), (0, 3))