def test_lc_int(self):
     prefix = (b'', b'\xfc', b'\xfd', b'\xfe')
     try:
         for i, j in enumerate((8, 16, 24, 64)):
             val = 2 ** (j - 1)
             lenenc = utils.lc_int(val)
             exp = prefix[i] + \
                 getattr(utils, 'int{0}store'.format(int(j/8)))(val)
             self.assertEqual(exp, lenenc)
     except ValueError as err:
         self.fail("length_encoded_int failed for size {0}".format(j, err))
Exemple #2
0
 def test_lc_int(self):
     prefix = (b'', b'\xfc', b'\xfd', b'\xfe')
     try:
         for i, j in enumerate((8, 16, 24, 64)):
             val = 2**(j - 1)
             lenenc = utils.lc_int(val)
             exp = prefix[i] + \
                 getattr(utils, 'int{0}store'.format(int(j/8)))(val)
             self.assertEqual(exp, lenenc)
     except ValueError as err:
         self.fail("length_encoded_int failed for size {0}".format(j, err))
 def test_lc_int(self):
     prefix = (b'', b'\xfc', b'\xfd', b'\xfe')
     intstore = (1, 2, 3, 8)
     try:
         for i, j in enumerate((128, 251, 2**24-1, 2**64-1)):
             lenenc = utils.lc_int(j)
             exp = prefix[i] + \
                 getattr(utils, 'int{0}store'.format(intstore[i]))(j)
             self.assertEqual(exp, lenenc)
     except ValueError as err:
         self.fail("length_encoded_int failed for size {0}".format(j, err))
Exemple #4
0
 def test_lc_int(self):
     prefix = (b'', b'\xfc', b'\xfd', b'\xfe')
     intstore = (1, 2, 3, 8)
     try:
         for i, j in enumerate((128, 251, 2**24 - 1, 2**64 - 1)):
             lenenc = utils.lc_int(j)
             exp = prefix[i] + \
                 getattr(utils, 'int{0}store'.format(intstore[i]))(j)
             self.assertEqual(exp, lenenc)
     except ValueError as err:
         self.fail("length_encoded_int failed for size {0}".format(j, err))