def test_diag_back_false(): """Given a cell, check if there is not win from it in diagonal_back line """ array = [[1, 2, 1, 1, 2, 2, 2], [1, 2, 1, 2, 2, 1, 2], [1, 1, 2, 1, 1, 2, 2], [1, 2, 2, 1, 2, 2, 2], [2, 2, 1, 1, 2, 0, 0], [0, 1, 0, 2, 2, 0, 0]] board = Board() board.board = array test_pos_1 = [[3, 0], [4, 0], [3, 1], [5, 1], [4, 2], [5, 3]] test_pos_2 = [[0, 3], [0, 4], [1, 3], [1, 5], [2, 4], [2, 6]] test_pos_3 = [[-1, 5], [7, 8], [8, 9], [-6, -5]] size_line = 3 sym_p1 = 1 sym_p2 = 2 sym_p3 = 3 # compare cases left to rigth assert (board.win_diag_back(test_pos_1[0][0], test_pos_1[0][1], True, sym_p2) < size_line) assert (board.win_diag_back(test_pos_1[1][0], test_pos_1[1][1], True, sym_p1) < size_line) assert (board.win_diag_back(test_pos_1[2][0], test_pos_1[2][1], True, sym_p1) < size_line) assert (board.win_diag_back(test_pos_1[3][0], test_pos_1[3][1], True, sym_p2) < size_line) assert (board.win_diag_back(test_pos_1[4][0], test_pos_1[4][1], True, sym_p2) < size_line) assert (board.win_diag_back(test_pos_1[5][0], test_pos_1[5][1], True, sym_p1) < size_line) # compare cases rigth to left assert (board.win_diag_back(test_pos_2[0][0], test_pos_2[0][1], False, sym_p2) < size_line) assert (board.win_diag_back(test_pos_2[1][0], test_pos_2[1][1], False, sym_p1) < size_line) assert (board.win_diag_back(test_pos_2[2][0], test_pos_2[2][1], False, sym_p1) < size_line) assert (board.win_diag_back(test_pos_2[3][0], test_pos_2[3][1], False, sym_p2) < size_line) assert (board.win_diag_back(test_pos_2[4][0], test_pos_2[4][1], False, sym_p2) < size_line) assert (board.win_diag_back(test_pos_2[5][0], test_pos_2[5][1], False, sym_p1) < size_line) # compare with symbol not valid assert (board.win_diag_back(test_pos_1[4][0], test_pos_1[4][1], True, sym_p3) < size_line) assert (board.win_diag_back(test_pos_1[5][0], test_pos_1[5][1], True, sym_p3) < size_line) assert (board.win_diag_back(test_pos_2[0][0], test_pos_2[0][1], False, sym_p3) < size_line) assert (board.win_diag_back(test_pos_2[1][0], test_pos_2[1][1], False, sym_p3) < size_line) # compare with cell (row, col) not valid assert (board.win_diag_back(test_pos_3[0][0], test_pos_3[0][1], True, sym_p3) < size_line) assert (board.win_diag_back(test_pos_3[1][0], test_pos_3[1][1], True, sym_p3) < size_line) assert (board.win_diag_back(test_pos_3[2][0], test_pos_3[2][1], False, sym_p3) < size_line) assert (board.win_diag_back(test_pos_3[3][0], test_pos_3[3][1], False, sym_p3) < size_line)
def test_diag_back_true(): """Given a cell, check if there is win from it in diagonal_back line """ array = [[1, 2, 1, 1, 2, 2, 2], [1, 2, 1, 2, 2, 1, 2], [1, 1, 2, 1, 1, 2, 2], [1, 2, 2, 1, 2, 2, 2], [2, 2, 1, 1, 2, 0, 0], [0, 1, 0, 2, 2, 0, 0]] board = Board() board.board = array test_pos_1 = [[3, 0], [4, 0], [3, 1], [5, 1], [4, 2], [5, 3]] test_pos_2 = [[0, 3], [0, 4], [1, 3], [1, 5], [2, 4], [2, 6]] size_line = 3 sym_p1 = 1 sym_p2 = 2 # compare cases left to rigth assert (board.win_diag_back(test_pos_1[0][0], test_pos_1[0][1], True, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_1[1][0], test_pos_1[1][1], True, sym_p2) >= size_line) assert (board.win_diag_back(test_pos_1[2][0], test_pos_1[2][1], True, sym_p2) >= size_line) assert (board.win_diag_back(test_pos_1[3][0], test_pos_1[3][1], True, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_1[4][0], test_pos_1[4][1], True, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_1[5][0], test_pos_1[5][1], True, sym_p2) >= size_line) # compare cases rigth to left assert (board.win_diag_back(test_pos_2[0][0], test_pos_2[0][1], False, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_2[1][0], test_pos_2[1][1], False, sym_p2) >= size_line) assert (board.win_diag_back(test_pos_2[2][0], test_pos_2[2][1], False, sym_p2) >= size_line) assert (board.win_diag_back(test_pos_2[3][0], test_pos_2[3][1], False, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_2[4][0], test_pos_2[4][1], False, sym_p1) >= size_line) assert (board.win_diag_back(test_pos_2[5][0], test_pos_2[5][1], False, sym_p2) >= size_line)