def test_get_lines_on_empty_square_board(self): """Test whether the _get_lines function provides the correct lines for an empty square board.""" board = TicTacToeBoard() lines = board._get_lines() # Make sure there are the correct number of lines self.assertEqual(len(lines), board.column_count + board.row_count + 2) # Make sure all lines are empty emptyLine = [board.CELL_NO_PLAYER for i in xrange(board.column_count)] for line in lines: self.assertEqual(line, emptyLine)
def test_get_lines_on_board(self): """Test whether the _get_lines function provides the correct lines for a non empty square board.""" # Create non-empty square tic-tac-toe game board board = TicTacToeBoard() board.matrix[0] = [1, 2, 0] board.matrix[1] = [0, 1, 0] board.matrix[2] = [0, 2, 0] lines = board._get_lines() # Make sure there are the correct number of lines self.assertEqual(board.column_count + board.row_count + 2, 8) self.assertEqual(len(lines), 8) # Make sure the lines are correct self.assertEqual(lines.count([0,0,0]), 1) self.assertEqual(lines.count([1,0,0]), 1) self.assertEqual(lines.count([1,2,0]), 1) self.assertEqual(lines.count([0,1,0]), 2) self.assertEqual(lines.count([1,1,0]), 1) self.assertEqual(lines.count([0,2,0]), 1) self.assertEqual(lines.count([2,1,2]), 1)