Esempio n. 1
0
    def test_combine_length(self):
        #test for values that differ in length
        #valueerror exception should be thrown
        minterms = [1, 2, 3, 4, 5, 6, 15]
        qm = QM(minterms)
        with self.assertRaises(ValueError):
            qm.combine('00000', '0001'), ValueError

        #test for values that are the same
        #None should be returned
        self.assertEqual(qm.combine('0000', '0000'), None)
Esempio n. 2
0
    def test_combine_single_values(self):
        #test for two terms that are not supposed to be combined
        #expected return value should be None
        minterms = [1, 2, 3, 4, 5, 6, 15]
        qm = QM(minterms)

        self.assertEqual(qm.combine('0000', '1001'), None)
        #test for values(without _ ) that differ by exactly one position
        #expected return value should have a new value with a _ in the positiion of difference

        self.assertEqual(qm.combine('0000', '0001'), '000_')
        #test for values(without _ ) that differ by exactly one position
        #expected return value should have a new value with a _ in the positiion of difference

        self.assertEqual(qm.combine('000_', '100_'), '_00_')
Esempio n. 3
0
    def test_combine(self):
        #test for two terms that are not supposed to be combined
        #expected return value should be None
        minterms = [1,2,3,4,5,6,15]
        qm =  QM(minterms)

        self.assertEqual(qm.combine('0000','1001'),None)
        #test for values(without _ ) that differ by exactly one position 
        #expected return value should have a new value with a _ in the positiion of difference

        self.assertEqual(qm.combine('0000','0001'),'000_')
        #test for values(without _ ) that differ by exactly one position 
        #expected return value should have a new value with a _ in the positiion of difference

        self.assertEqual(qm.combine('000_','100_'),'_00_')

        #test for values that differ in length 
        #valueerror exception should be thrown
        with self.assertRaises(ValueError):
            qm.combine('00000','0001'),ValueError

        #test for values that are the same 
        #None should be returned
        self.assertEqual(qm.combine('0000','0000'),None)