Exemplo n.º 1
0
 def testAssignHiddenSingles(self):
     board = Board();
     board.boardFromString(self.NAKED_SINGLES)
     
     # Create a copy of the original board
     originalBoard = Board(board)
     
     easySolver = EasySolver(board)
     result = easySolver.assignHiddenSingles()
     
     # Make sure all were assigned
     assert(result == 6)
     
     # Make sure that the board now has the singles assigned
     assert(board.getPosition(5, 5) == '3')
     assert(board.getPosition(7, 6) == '3')
     assert(board.getPosition(3, 6) == '5')
     assert(board.getPosition(2, 0) == '6')
     assert(board.getPosition(8, 7) == '7')
     assert(board.getPosition(4, 1) == '7')
     
     # Ensure the only changes to the board are the assigned singles
     assert(board != originalBoard)
     for y in xrange(board.getDimensions()):
         for x in xrange(board.getDimensions()):
             # Don't bother checking fields we know have changed
             if not (x, y) in [(5, 5), (7, 6), (3, 6), (2, 0), (8, 7), (4, 1)]:                         
                 assert(board.getPosition(x, y) ==
                    originalBoard.getPosition(x, y))