Exemplo n.º 1
0
 def testPayloadDecoderReset(self):
     ''' Test the payload decoder reset functionality '''
     decoder = PayloadDecoder('\x12\x34')
     self.assertEqual(0x12, decoder.decode_8bit_uint())
     self.assertEqual(0x34, decoder.decode_8bit_uint())
     decoder.reset()
     self.assertEqual(0x3412, decoder.decode_16bit_uint())
Exemplo n.º 2
0
 def testPayloadDecoderReset(self):
     ''' Test the payload decoder reset functionality '''
     decoder = PayloadDecoder('\x12\x34')
     self.assertEqual(0x12, decoder.decode_8bit_uint())
     self.assertEqual(0x34, decoder.decode_8bit_uint())
     decoder.reset()   
     self.assertEqual(0x3412, decoder.decode_16bit_uint())
Exemplo n.º 3
0
 def testLittleEndianPayloadDecoder(self):
     ''' Test basic bit message encoding/decoding '''
     decoder = PayloadDecoder(self.little_endian_payload, endian=Endian.Little)
     self.assertEqual(1,      decoder.decode_8bit_uint())
     self.assertEqual(2,      decoder.decode_16bit_uint())
     self.assertEqual(3,      decoder.decode_32bit_uint())
     self.assertEqual(4,      decoder.decode_64bit_uint())
     self.assertEqual(-1,     decoder.decode_8bit_int())
     self.assertEqual(-2,     decoder.decode_16bit_int())
     self.assertEqual(-3,     decoder.decode_32bit_int())
     self.assertEqual(-4,     decoder.decode_64bit_int())
     self.assertEqual(1.25,   decoder.decode_32bit_float())
     self.assertEqual(6.25,   decoder.decode_64bit_float())
     self.assertEqual('test', decoder.decode_string(4))
Exemplo n.º 4
0
 def testBigEndianPayloadDecoder(self):
     ''' Test basic bit message encoding/decoding '''
     decoder = PayloadDecoder(self.big_endian_payload, endian=Endian.Big)
     self.assertEqual(1, decoder.decode_8bit_uint())
     self.assertEqual(2, decoder.decode_16bit_uint())
     self.assertEqual(3, decoder.decode_32bit_uint())
     self.assertEqual(4, decoder.decode_64bit_uint())
     self.assertEqual(-1, decoder.decode_8bit_int())
     self.assertEqual(-2, decoder.decode_16bit_int())
     self.assertEqual(-3, decoder.decode_32bit_int())
     self.assertEqual(-4, decoder.decode_64bit_int())
     self.assertEqual(1.25, decoder.decode_32bit_float())
     self.assertEqual(6.25, decoder.decode_64bit_float())
     self.assertEqual('test', decoder.decode_string(4))