41 lines
913 B
Python
41 lines
913 B
Python
|
"""All tests for the Sudoku Solver."""
|
||
|
|
||
|
import unittest
|
||
|
from square import Square
|
||
|
|
||
|
|
||
|
class TestSquare(unittest.TestCase):
|
||
|
"""TestCase for Square"""
|
||
|
|
||
|
def setUp(self):
|
||
|
content = '.'
|
||
|
self.board = [
|
||
|
Square(line, column, content)
|
||
|
for line in range(9)
|
||
|
for column in range(9)
|
||
|
]
|
||
|
|
||
|
self.assertEqual(len(self.board), 81)
|
||
|
|
||
|
def test_grid_is_correctly_computed(self):
|
||
|
"""Square.grid is correctly computed for all values."""
|
||
|
|
||
|
correct_grids = (
|
||
|
"000111222"
|
||
|
"000111222"
|
||
|
"000111222"
|
||
|
"333444555"
|
||
|
"333444555"
|
||
|
"333444555"
|
||
|
"666777888"
|
||
|
"666777888"
|
||
|
"666777888"
|
||
|
)
|
||
|
|
||
|
for i, square in enumerate(self.board):
|
||
|
self.assertEqual(square.grid, int(correct_grids[i]))
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|