def test_xor_2bit(self): function = BoolFunction(examples.bit_xor_2bit) truth_table = function.simulate_all() self.assertEqual(len(truth_table), 2) output0 = BitVec(16, 0xaaaa) ^ BitVec(16, 0xf0f0) output1 = BitVec(16, 0xcccc) ^ BitVec(16, 0xff00) self.assertEqual(str(truth_table[0]), str(output0)) self.assertEqual(str(truth_table[1]), str(output1))
def test_or(self): function = BoolFunction(examples.bool_or) truth_table = function.simulate_all() self.assertEqual(len(truth_table), 1) self.assertEqual(str(truth_table[0]), '1110')
def test_xor_str(self): function = BoolFunction("x ^ b") truth_table = function.simulate_all() self.assertEqual(len(truth_table), 1) self.assertEqual(str(truth_table[0]), '0110')
def test_and_str(self): function = BoolFunction("x & b") truth_table = function.simulate_all() self.assertEqual(len(truth_table), 1) self.assertEqual(str(truth_table[0]), '1000')
def test_not_2bit(self): function = BoolFunction(examples.bit_not_2bit) truth_table = function.simulate_all() self.assertEqual(len(truth_table), 2) self.assertEqual(str(truth_table[0]), '0101') self.assertEqual(str(truth_table[1]), '0011')
def test_not_str(self): function = BoolFunction("~x") truth_table = function.simulate_all() self.assertEqual(len(truth_table), 1) self.assertEqual(str(truth_table[0]), '01')
def test_id_2bit(self): function = BoolFunction(examples.identity_2bit) truth_table = function.simulate_all() self.assertEqual(len(truth_table), 2) self.assertEqual(str(truth_table[0]), '1010') self.assertEqual(str(truth_table[1]), '1100')
def test_id(self): function = BoolFunction(examples.identity) truth_table = function.simulate_all() self.assertEqual(len(truth_table), 1) self.assertEqual(str(truth_table[0]), '10')