Exemplo n.º 1
0
def test_distances() -> None:
    a_cell = Cell(0, 0)
    another_cell = Cell(0, 1)
    yet_another_cell = Cell(0, 2)

    a_cell.east = another_cell
    a_cell += another_cell
    another_cell.east = yet_another_cell
    another_cell += yet_another_cell
    distances = a_cell.distances
    assert set(distances.cells) == {yet_another_cell, another_cell, a_cell}
    assert distances[a_cell] == 0
    assert distances[another_cell] == 1
    assert distances[yet_another_cell] == 2
Exemplo n.º 2
0
def test_has_neighbors() -> None:
    a_cell = Cell(1, 1)
    another_cell = Cell(1, 2)
    yet_another_cell = Cell(2, 1)

    a_cell.north = another_cell
    another_cell.south = yet_another_cell
    yet_another_cell.east = another_cell
    yet_another_cell.west = a_cell

    assert another_cell in a_cell.neighbors
    assert yet_another_cell not in a_cell.neighbors
    assert len(a_cell.neighbors) == 1
    assert a_cell not in another_cell.neighbors
    assert yet_another_cell in another_cell.neighbors
    assert len(another_cell.neighbors) == 1
    assert a_cell in yet_another_cell.neighbors
    assert another_cell in yet_another_cell.neighbors
    assert len(yet_another_cell.neighbors) == 2