Esempio n. 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))
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')