-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sudoku_Test.py
39 lines (33 loc) · 1016 Bytes
/
Sudoku_Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import unittest
from Sudoku import Sudoku
class SudokuTest(unittest.TestCase):
def setUp(self) -> None:
self.sudoku = Sudoku()
def test_custom_board(self):
board = [
[7,8,0,4,0,0,1,2,0],
[6,0,0,0,7,5,0,0,9],
[0,0,0,6,0,1,0,7,8],
[0,0,7,0,4,0,2,6,0],
[0,0,1,0,5,0,9,3,0],
[9,0,4,0,6,0,0,0,5],
[0,7,0,3,0,0,0,1,2],
[1,2,0,0,0,7,4,0,0],
[0,4,9,2,0,6,0,0,7]
]
answer = [
[7,8,5,4,3,9,1,2,6],
[6,1,2,8,7,5,3,4,9],
[4,9,3,6,2,1,5,7,8],
[8,5,7,9,4,3,2,6,1],
[2,6,1,7,5,8,9,3,4],
[9,3,4,1,6,2,7,8,5],
[5,7,8,3,9,4,6,1,2],
[1,2,6,5,8,7,4,9,3],
[3,4,9,2,1,6,8,5,7],
]
self.sudoku.board = board
self.assertEqual(self.sudoku.solve(), True)
self.assertEqual(self.sudoku.board, answer)
if __name__ == "__main__":
unittest.main()