示例#1
0
def test_win_vrt_true():
    """Given a cell, check if there is win from it in vertical line
    """

    array = [[1, 2, 1, 1, 2, 2, 2], [1, 2, 1, 1, 2, 1,
                                     2], [1, 2, 2, 1, 2, 2, 2],
             [1, 1, 0, 1, 2, 0, 2], [0, 0, 0, 1, 2, 0, 0],
             [0, 0, 0, 0, 2, 0, 0]]
    board = Board()
    board.board = array
    test_pos_1 = [[3, 0], [4, 3], [3, 3], [5, 4], [4, 4], [3, 4], [3, 6]]
    size_line = 3
    sym_p1 = 1
    sym_p2 = 2

    assert (board.win_vrt(test_pos_1[0][0], test_pos_1[0][1], sym_p1) >=
            size_line)
    assert (board.win_vrt(test_pos_1[1][0], test_pos_1[1][1], sym_p1) >=
            size_line)
    assert (board.win_vrt(test_pos_1[2][0], test_pos_1[2][1], sym_p1) >=
            size_line)
    assert (board.win_vrt(test_pos_1[3][0], test_pos_1[3][1], sym_p2) >=
            size_line)
    assert (board.win_vrt(test_pos_1[4][0], test_pos_1[4][1], sym_p2) >=
            size_line)
    assert (board.win_vrt(test_pos_1[5][0], test_pos_1[5][1], sym_p2) >=
            size_line)
    assert (board.win_vrt(test_pos_1[6][0], test_pos_1[6][1], sym_p2) >=
            size_line)
示例#2
0
def test_win_vrt_false():
    """Given a cell, check if there is not win from it in vertical line
    """

    array = [[1, 2, 1, 1, 2, 2, 2], [1, 2, 1, 1, 2, 1,
                                     2], [1, 2, 2, 1, 2, 2, 2],
             [1, 1, 0, 1, 2, 0, 2], [0, 0, 0, 1, 2, 0, 0],
             [0, 0, 0, 0, 2, 0, 0]]
    board = Board()
    board.board = array
    test_pos_1 = [[3, 0], [4, 3], [3, 3], [5, 4], [4, 4], [3, 4], [3, 6]]
    test_pos_2 = [[-1, 0], [9, 10], [5, -5]]
    size_line = 3
    sym_p1 = 1
    sym_p2 = 2
    sym_p3 = 3

    assert (board.win_vrt(test_pos_1[0][0], test_pos_1[0][1], sym_p2) <
            size_line)
    assert (board.win_vrt(test_pos_1[1][0], test_pos_1[1][1], sym_p2) <
            size_line)
    assert (board.win_vrt(test_pos_1[2][0], test_pos_1[2][1], sym_p2) <
            size_line)
    assert (board.win_vrt(test_pos_1[3][0], test_pos_1[3][1], sym_p1) <
            size_line)
    assert (board.win_vrt(test_pos_1[4][0], test_pos_1[4][1], sym_p1) <
            size_line)
    assert (board.win_vrt(test_pos_1[5][0], test_pos_1[5][1], sym_p1) <
            size_line)
    assert (board.win_vrt(test_pos_1[6][0], test_pos_1[6][1], sym_p1) <
            size_line)
    # compare with symbol not valid
    assert (board.win_vrt(test_pos_1[4][0], test_pos_1[4][1], sym_p3) <
            size_line)
    assert (board.win_vrt(test_pos_1[5][0], test_pos_1[5][1], sym_p3) <
            size_line)
    assert (board.win_vrt(test_pos_1[6][0], test_pos_1[6][1], sym_p3) <
            size_line)
    # compare with cell (row, col) not valid
    assert (board.win_vrt(test_pos_2[0][0], test_pos_2[0][1], sym_p3) <
            size_line)
    assert (board.win_vrt(test_pos_2[1][0], test_pos_2[1][1], sym_p3) <
            size_line)
    assert (board.win_vrt(test_pos_2[2][0], test_pos_2[2][1], sym_p3) <
            size_line)