Esempio n. 1
0
 def test_unpack_response_with_string_no_format(self):
   expected_string = 'abcde\x00'
   b = bytearray()
   b.extend(expected_string)
   data = Encoder.unpack_response_with_string('',b)
   assert(len(data) == 1)
   assert data[0] == expected_string
Esempio n. 2
0
 def test_unpack_response_with_string(self):
   expected_data = [1, 'a', 'b', 'c', 'ABCDE\x00']
   b = bytearray()
   b.extend(Encoder.encode_uint32(1))
   for data in expected_data[1:-1]:
     b.append(data)
   b.extend(expected_data[-1])
   data = Encoder.unpack_response_with_string('<Iccc',b)
   for expected, d in zip(expected_data, data):
     self.assertEqual(expected, d)
Esempio n. 3
0
 def test_unpack_response_with_string_empty_string(self):
   expected_string = '\x00'
   b = bytearray()
   b.append(expected_string)
   data = Encoder.unpack_response_with_string('', b)
   self.assertEqual(expected_string, data[0])