示例#1
0
 def test_zero_bytes(self):
   self.assertEqual(uint_to_bytes(bytes_to_uint(zero_bytes)),
                    one_zero_byte)
   self.assertEqual(uint_to_bytes(bytes_to_uint_naive(zero_bytes)),
                    one_zero_byte)
   self.assertEqual(uint_to_bytes(bytes_to_uint_simple(zero_bytes)),
                    one_zero_byte)
示例#2
0
 def test_zero_bytes(self):
   self.assertEqual(integer.uint_to_bytes(integer.bytes_to_uint(ZERO_BYTES)),
                    ONE_ZERO_BYTE)
   self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_naive(ZERO_BYTES)),
                    ONE_ZERO_BYTE)
   self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_simple(ZERO_BYTES)),
                    ONE_ZERO_BYTE)
示例#3
0
 def test_codec_equivalence(self):
   # Padding bytes are not preserved (it is acceptable here).
   random_bytes = b("\x00\xbcE\x9a\xda]")
   expected_bytes = b("\xbcE\x9a\xda]")
   self.assertEqual(uint_to_bytes(bytes_to_uint(random_bytes)),
                    expected_bytes)
   self.assertEqual(uint_to_bytes(bytes_to_uint_naive(random_bytes)),
                    expected_bytes)
   self.assertEqual(uint_to_bytes(bytes_to_uint_simple(random_bytes)),
                    expected_bytes)
示例#4
0
 def test_codec_equivalence(self):
   # Padding bytes are not preserved (it is acceptable here).
   random_bytes = b("\x00\xbcE\x9a\xda]")
   expected_bytes = b("\xbcE\x9a\xda]")
   self.assertEqual(integer.uint_to_bytes(integer.bytes_to_uint(random_bytes)),
                    expected_bytes)
   self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_naive(random_bytes)),
                    expected_bytes)
   self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_simple(random_bytes)),
                    expected_bytes)