def test_cross_check():
	for path in sorted(glob.glob('examples/*.json')):
		print(path)
		solver = NonogramSolver(path)
		solver.solve()
		solver_res = solver.NONO < 2
		with open(path) as f:
			solver_inp = json.load(f)
		assert(solver_inp == nonogramgenerator.array_to_nonogram(solver_res))
		print('....checked')
def test_solver():
	for path in sorted(glob.glob('examples/*.json')):
		print(path)
		solver = NonogramSolver(path)
		solver.set_verbose(True)
		solver.solve()
		test_res = solver.__str__().replace('\n', '')
		res_path = path.replace('.json', '.res')
		with open(res_path, 'r') as f:
			res = ''.join(f.readlines()).replace('\n', '')
		assert(test_res == res)
		print('....checked')
Exemplo n.º 3
0
 def test_extend_edge_works_for_soft_edge_backward(self, in_progress_board_with_edges):
     solver = NonogramSolver(in_progress_board_with_edges)
     assert solver._extend_edge(2, 0)
     assert solver.board.line(2, 0).tolist() == [State.YES, State.YES, State.YES, State.NO]
Exemplo n.º 4
0
 def test_extend_edge_works_for_true_edge_forward(self, in_progress_board_with_edges):
     solver = NonogramSolver(in_progress_board_with_edges)
     assert solver._extend_edge(0, 0)
     assert solver.board.line(0, 0).tolist() == [State.YES, State.YES, State.NO, State.BLANK]
Exemplo n.º 5
0
 def test_full_hint_ignores_irrelevant_line(self, blank_board):
     solver = NonogramSolver(blank_board)
     assert not solver._full_hint(4, 0)
Exemplo n.º 6
0
 def test_full_hint_fills_split_line(self, blank_board):
     solver = NonogramSolver(blank_board)
     assert solver._full_hint(0, 0)
     assert solver.board.line(0, 0).tolist() == [State.YES, State.YES, State.YES, State.NO, State.YES]
Exemplo n.º 7
0
 def test_full_hint_fills_full_line(self, blank_board):
     solver = NonogramSolver(blank_board)
     assert solver._full_hint(4, 1)
     assert solver.board.line(4, 1).tolist() == [State.YES, State.YES, State.YES, State.YES, State.YES]
Exemplo n.º 8
0
 def test_zero_hint_fills_full_line(self, blank_board_with_zero):
     solver = NonogramSolver(blank_board_with_zero)
     assert solver._zero_hint(2, 0)
     assert solver.board.line(2, 0).tolist() == [State.NO, State.NO, State.NO]