Exemplo n.º 1
0
def test_valid_row():
    board = [[7, 0, 9, 6, 0, 4, 0, 0, 0], [3, 4, 0, 0, 0, 2, 5, 0, 0],
             [0, 0, 0, 0, 0, 7, 0, 0, 0], [5, 0, 0, 0, 6, 3, 0, 0, 0],
             [0, 0, 8, 0, 0, 0, 2, 0, 0], [0, 0, 0, 2, 7, 0, 0, 0, 4],
             [0, 0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 1, 7, 0, 0, 0, 8, 9],
             [0, 0, 0, 8, 0, 9, 1, 0, 6]]
    assert valid_row(board, 3, 2) == True, "valid_row test #1 failed"

    board = [[0, 0, 0, 2, 0, 9, 4, 0, 7], [0, 0, 8, 6, 0, 0, 0, 2, 5],
             [0, 0, 0, 7, 0, 0, 0, 0, 0], [0, 0, 0, 5, 9, 0, 0, 0, 8],
             [0, 0, 6, 0, 0, 0, 3, 0, 0], [2, 0, 0, 0, 7, 6, 0, 0, 0],
             [0, 0, 0, 0, 0, 5, 0, 0, 0], [4, 3, 0, 0, 0, 7, 1, 0, 0],
             [9, 0, 1, 4, 0, 3, 0, 0, 0]]
    assert valid_row(board, 4, 3) == False, "valid_row test #2 failed"

    board = [[4, 7, 0, 1, 0, 0, 0, 0, 0], [0, 8, 0, 0, 0, 0, 0, 0, 0],
             [2, 0, 0, 0, 5, 0, 0, 3, 0], [7, 0, 0, 0, 0, 9, 6, 5, 1],
             [0, 0, 0, 6, 0, 4, 0, 0, 0], [8, 6, 9, 5, 0, 0, 0, 0, 4],
             [0, 2, 0, 0, 8, 0, 0, 0, 7], [0, 0, 0, 0, 0, 0, 0, 1, 0],
             [0, 0, 0, 0, 0, 3, 0, 9, 6]]
    assert valid_row(board, 0, 1) == False, "valid_row test #3 failed"
Exemplo n.º 2
0
 def test_valid_row(self):
     self.assertTrue(sudoku.valid_row(self.sudokuGrid, 3))
     self.sudokuGrid[0][0] = [3]
     self.assertFalse(sudoku.valid_row(self.sudokuGrid, 0))
Exemplo n.º 3
0
	def test_valid_row(self):
		self.assertTrue(sudoku.valid_row(sudoku.listify(self.sudokuGrid), 3))
		self.sudokuGridListified[0][0] = 3
		self.assertFalse(sudoku.valid_row(self.sudokuGridListified, 0))