예제 #1
0
 def test_round_trip(self):
     test_data = [
         _pad_to(bin(struct.unpack('<I', os.urandom(4))[0]), 32)
         for _ in range(1000)]
     for value in test_data:
         round_tripped = hex_to_bin(bin_to_hex(value))
         assert round_tripped == value
예제 #2
0
 def test_round_trip(self):
     test_data = [
         _pad_to(bin(struct.unpack('<I', os.urandom(4))[0]), 32)
         for _ in range(1000)
     ]
     for value in test_data:
         round_tripped = hex_to_bin(bin_to_hex(value))
         assert round_tripped == value
예제 #3
0
 def test_negative_zero(self):
     expected = '0x80000000'
     result = bin_to_hex('0b10000000000000000000000000000000')
     assert result == expected
예제 #4
0
 def test_zero(self):
     expected = '0x00000000'
     result = bin_to_hex('0b00000000000000000000000000000000')
     assert result == expected
예제 #5
0
 def test_negative_zero(self):
     expected = '0x80000000'
     result = bin_to_hex('0b10000000000000000000000000000000')
     assert result == expected
예제 #6
0
 def test_zero(self):
     expected = '0x00000000'
     result = bin_to_hex('0b00000000000000000000000000000000')
     assert result == expected