def test_cost(): test = astar.graph(100, 50) cur = (0, 0) xy0 = (5, 5) xy1 = (49, 49) #dummy coor.s test.weights = {cur: 0, xy0: 25, xy1: 49 * 49} #dummy weights cost_to_xy0 = test.cost(cur, xy0) cost_to_xy1 = test.cost(cur, xy1) assert cost_to_xy1 > cost_to_xy0
def test_graphInit(): testObject = astar.graph(24, 42) assert testObject.width == 24 assert testObject.height == 42
def test_neighbors_invalidNeighbor(): test = astar.graph(100, 50) dummyCoor = (42, 42) neighbors = test.neighbors(dummyCoor) assert (42, 46) not in neighbors, "(42, 46) cannot be adjacent"
def test_neighbors_totalNum(): test = astar.graph(100, 50) dummyCoor = (42, 42) neighbors = test.neighbors(dummyCoor) assert len(neighbors) == 4
def test_passable_00(): test = astar.graph(100, 50) target = (42, 42) assert test.passable(target), "no walls yet so must assert 1"
def test_inbounds_02(): test = astar.graph(100, 50) badxy = (-1, 25) assert test.in_bounds(badxy) == 0, "Should NOT assert 1 --neg value"
def test_inbounds_01(): test = astar.graph(100, 50) badxy = (150, 25) assert test.in_bounds(badxy) == 0, "Should NOT assert 1 --too big"
def test_inbounds(): test = astar.graph(100, 50) goodxy = (25, 25) toobig = (150, 50) assert test.in_bounds(goodxy), "This should pass"