Ejemplo n.º 1
0
 def test_encode_decode_empty(self):
     data = b'\xff'
     options, _ = protocol_options.decode(memoryview(data))
     self.assertIsInstance(options, protocol_options.ProtocolOptions)
     self.assertTrue(all(option is None for option in options))
     result = protocol_options.encode(options)
     self.assertEqual(result, data)
Ejemplo n.º 2
0
 def test_encode_decode_empty(self):
     data = b'\xff'
     options, _ = protocol_options.decode(memoryview(data))
     self.assertIsInstance(options, protocol_options.ProtocolOptions)
     self.assertTrue(all(option is None for option in options))
     result = protocol_options.encode(options)
     self.assertEqual(result, data)
Ejemplo n.º 3
0
 def test_decode_duplicate_options(self):
     data = b'\x00\x01\x00\x01'
     with self.assertRaises(ValueError):
         protocol_options.decode(memoryview(data))
Ejemplo n.º 4
0
 def test_encode_decode(self, options):
     data = protocol_options.encode(options)
     self.assertIsInstance(data, bytearray)
     result, _ = protocol_options.decode(memoryview(data))
     from pprint import pformat
     self.assertEqual(result, options, pformat(list(zip(result, options))))
Ejemplo n.º 5
0
 def test_decode_duplicate_options(self):
     data = b'\x00\x01\x00\x01'
     with self.assertRaises(ValueError):
         protocol_options.decode(memoryview(data))
Ejemplo n.º 6
0
 def test_encode_decode(self, options):
     data = protocol_options.encode(options)
     self.assertIsInstance(data, bytearray)
     result, _ = protocol_options.decode(memoryview(data))
     from pprint import pformat
     self.assertEqual(result, options, pformat(list(zip(result, options))))