Esempio n. 1
0
 def test_SingleEncodeDecode(self):
     device = bytearray()
     device.extend(slip.encode(self.createMessage()))
     rest = slip.encode(self.createMessage())
     rest = rest[:10]
     device.extend(rest)
     rest = rest[1:]  # remove first END
     decoded, stillencoded = slip.decode(device)
     self.assertEqual(len(decoded), 1)
     self.assertEqual(decoded[0], self.createMessage())
     self.assertEqual(stillencoded, rest)
Esempio n. 2
0
 def test_MultipleEncodeDecode(self):
     device = bytearray()
     device.extend(slip.encode(self.createMessage()))
     device.extend(slip.encode(self.createMessage()))
     device.extend(slip.encode(self.createMessage()))
     rest = slip.encode(self.createMessage())
     rest = rest[:10]
     device.extend(rest)
     rest = rest[1:]  # remove first END
     decoded, stillencoded = slip.decode(device)
     self.assertEqual(len(decoded), 3)
     for msg in decoded:
         self.assertEqual(msg, self.createMessage())
     self.assertEqual(stillencoded, rest)
Esempio n. 3
0
 def _process(self, sequence, producer):
     for operands in sequence:
         for name, value in operands:
             data = slip.encode(value) if value else bytearray()
             yield (("data", data), )