Exemplo n.º 1
0
    def test_removeUnitClause_applyAssignment(self):
        cnf = [{-123: True}, {123: True, -352: True, 423: True}]
        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, [{-352: True, 423: True}])
        self.assertEqual(new_assignment, [-123])
        self.assertEqual(change, True)
Exemplo n.º 2
0
    def test_removeUnitClause_manyUnit(self):
        cnf = [{-123: True}, {234: True}, {423: True, -352: True}]
        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, [{423: True, -352: True}])
        self.assertEqual(new_assignment, [-123, 234])
        self.assertEqual(change, True)
Exemplo n.º 3
0
    def test_removeUnitClause_onlyPosUnit(self):
        cnf = [{123: True}]
        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, [])
        self.assertEqual(new_assignment, [123])
        self.assertEqual(change, True)
Exemplo n.º 4
0
    def test_removeUnitClause_noUnit(self):
        cnf = [{-123: True, 321: True}]
        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, cnf)
        self.assertEqual(new_assignment, assignment)
        self.assertEqual(change, False)
Exemplo n.º 5
0
    def test_removeUnitClause_empty(self):
        cnf = []
        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, cnf)
        self.assertEqual(new_assignment, assignment)
        self.assertEqual(change, False)
Exemplo n.º 6
0
    def test_removeUnitClause_copyClauses(self):
        cnf = [{-123: True}, {-123: True}]

        assignment = []

        new_cnf, new_assignment, change, _ = removeUnitClause(cnf, assignment)
        self.assertEqual(new_cnf, [])
        self.assertEqual(new_assignment, [-123])
        self.assertEqual(change, True)