示例#1
0
 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))
示例#2
0
 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')
示例#3
0
 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')
示例#4
0
 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')
示例#5
0
 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')
示例#6
0
 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')
示例#7
0
 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')
示例#8
0
 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')