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
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
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: frombin = bin_to_float(value) if math.isnan(frombin): continue round_tripped = float_to_bin(frombin) assert round_tripped == value
def test_round_trip(self): test_data = [ _pad_to(hex(struct.unpack('<I', os.urandom(4))[0]), 8) for _ in range(1000)] for value in test_data: fromhex = hex_to_float(value) if math.isnan(fromhex): continue round_tripped = float_to_hex(fromhex) assert round_tripped == value
def test_round_trip(self): test_data = [ _pad_to(bin(struct.unpack('<Q', os.urandom(8))[0]), 64) for _ in range(1000)] for value in test_data: frombin = bin_to_double(value) if math.isnan(frombin): continue round_tripped = double_to_bin(frombin) assert round_tripped == value
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: frombin = bin_to_float(value) if math.isnan(frombin): continue round_tripped = float_to_bin(frombin) assert round_tripped == value
def test_round_trip(self): test_data = [ _pad_to(hex(struct.unpack('<Q', os.urandom(8))[0]), 16) for _ in range(1000)] # Python 2 uses an L suffix on long integer types, even in hex. for value in [v.rstrip('L') for v in test_data]: fromhex = hex_to_double(value) if math.isnan(fromhex): continue round_tripped = double_to_hex(fromhex) assert round_tripped == value
def test_round_trip(self): test_data = [ _pad_to(hex(struct.unpack('<Q', os.urandom(8))[0]), 16) for _ in range(1000) ] # Python 2 uses an L suffix on long integer types, even in hex. for value in [v.rstrip('L') for v in test_data]: fromhex = hex_to_double(value) if math.isnan(fromhex): continue round_tripped = double_to_hex(fromhex) assert round_tripped == value