Exemplo n.º 1
0
    def test_get_minterms_from_string(self):
        '''Test getting the minterms from a string'''

        strings = ['A AND (B OR C)', '(A XOR B) OR C', 
                'NOT (A OR B) AND NOT C', '']

        minterms_list = [[5, 6, 7], [1, 2, 3, 4, 5, 7], [0], []]

        variables = ['C', 'B', 'A']

        for string, minterms in zip(strings, minterms_list):

            self.assertEqual(logic.get_minterms_from_string(
                string, variables), minterms)
Exemplo n.º 2
0
    def test_get_minterms_from_string(self):
        '''Test getting the minterms from a string'''

        strings = [
            'A AND (B OR C)', '(A XOR B) OR C', 'NOT (A OR B) AND NOT C', ''
        ]

        minterms_list = [[5, 6, 7], [1, 2, 3, 4, 5, 7], [0], []]

        variables = ['C', 'B', 'A']

        for string, minterms in zip(strings, minterms_list):

            self.assertEqual(logic.get_minterms_from_string(string, variables),
                             minterms)
Exemplo n.º 3
0
    def test_get_canonical_minimal_sop_from_string(self):

        strings = [
            'A AND (B OR C)', '(A XOR B) OR C', 'NOT (A OR B) AND NOT C'
        ]

        minterms_list = [[5, 6, 7], [1, 2, 3, 4, 5, 7], [0]]

        variables = ['C', 'B', 'A']

        for string, minterms in zip(strings, minterms_list):

            sop = logic.get_canonical_minimal_sop_from_string(
                string, variables)

            _qm = qm.QM(variables)

            self.assertEqual(
                logic.get_minterms_from_string(_qm.get_function(sop),
                                               variables), minterms)
Exemplo n.º 4
0
    def test_get_canonical_minimal_sop_from_string(self):

        strings = ['A AND (B OR C)', '(A XOR B) OR C', 
                'NOT (A OR B) AND NOT C']

        minterms_list = [[5, 6, 7], [1, 2, 3, 4, 5, 7], [0]]

        variables = ['C', 'B', 'A']

        for string, minterms in zip(strings, minterms_list):

            sop = logic.get_canonical_minimal_sop_from_string(
                    string, variables)

            _qm = qm.QM(variables)

            self.assertEqual(
                    logic.get_minterms_from_string(_qm.get_function(sop), 
                        variables), 
                    minterms)