示例#1
0
  def test_correctness(self):
    self.assertEqual(uint_to_bytes(0xeeeeffff),
                     b('\xee\xee\xff\xff'))
    self.assertEqual(uint_to_bytes(0xeeeeff),
                     b('\xee\xee\xff'))

    self.assertEqual(uint_to_bytes_naive(0xeeeeffff),
                     b('\xee\xee\xff\xff'))
    self.assertEqual(uint_to_bytes_naive(0xeeeeff),
                     b('\xee\xee\xff'))

    self.assertEqual(uint_to_bytes_simple(0xeeeeffff),
                     b('\xee\xee\xff\xff'))
    self.assertEqual(uint_to_bytes_simple(0xeeeeff),
                     b('\xee\xee\xff'))
示例#2
0
  def test_correctness(self):
    self.assertEqual(integer.uint_to_bytes(0xeeeeffff),
                     b("\xee\xee\xff\xff"))
    self.assertEqual(integer.uint_to_bytes(0xeeeeff),
                     b("\xee\xee\xff"))

    self.assertEqual(_alt_integer.uint_to_bytes_naive(0xeeeeffff),
                     b("\xee\xee\xff\xff"))
    self.assertEqual(_alt_integer.uint_to_bytes_naive(0xeeeeff),
                     b("\xee\xee\xff"))

    self.assertEqual(_alt_integer.uint_to_bytes_simple(0xeeeeffff),
                     b("\xee\xee\xff\xff"))
    self.assertEqual(_alt_integer.uint_to_bytes_simple(0xeeeeff),
                     b("\xee\xee\xff"))
示例#3
0
  def test_zero(self):
    self.assertEqual(uint_to_bytes(0), b('\x00'))
    self.assertEqual(uint_to_bytes(0, 4), b('\x00') * 4)
    self.assertEqual(uint_to_bytes(0, 7), b('\x00') * 7)
    self.assertEqual(uint_to_bytes(0, chunk_size=1), b('\x00'))
    self.assertEqual(uint_to_bytes(0, chunk_size=4), b('\x00') * 4)
    self.assertEqual(uint_to_bytes(0, chunk_size=7), b('\x00') * 7)

    self.assertEqual(uint_to_bytes_naive(0), b('\x00'))
    self.assertEqual(uint_to_bytes_naive(0, 4), b('\x00') * 4)
    self.assertEqual(uint_to_bytes_naive(0, 7), b('\x00') * 7)

    self.assertEqual(uint_to_bytes_simple(0), b('\x00'))
示例#4
0
  def test_zero(self):
    self.assertEqual(integer.uint_to_bytes(0), b("\x00"))
    self.assertEqual(integer.uint_to_bytes(0, 4), b("\x00") * 4)
    self.assertEqual(integer.uint_to_bytes(0, 7), b("\x00") * 7)
    self.assertEqual(integer.uint_to_bytes(0, chunk_size=1), b("\x00"))
    self.assertEqual(integer.uint_to_bytes(0, chunk_size=4), b("\x00") * 4)
    self.assertEqual(integer.uint_to_bytes(0, chunk_size=7), b("\x00") * 7)

    self.assertEqual(_alt_integer.uint_to_bytes_naive(0), b("\x00"))
    self.assertEqual(_alt_integer.uint_to_bytes_naive(0, 4), b("\x00") * 4)
    self.assertEqual(_alt_integer.uint_to_bytes_naive(0, 7), b("\x00") * 7)

    self.assertEqual(_alt_integer.uint_to_bytes_simple(0), b("\x00"))