コード例 #1
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_round_trip(self):
     test_data = [struct.unpack('<f', os.urandom(4))[0]
                  for _ in range(1000)]
     for value in test_data:
         round_tripped = bin_to_float(float_to_bin(value))
         if math.isnan(value):
             assert math.isnan(round_tripped)
         else:
             assert round_tripped == value
コード例 #2
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 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
コード例 #3
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_round_trip(self):
     test_data = [
         struct.unpack('<f', os.urandom(4))[0] for _ in range(1000)
     ]
     for value in test_data:
         round_tripped = bin_to_float(float_to_bin(value))
         if math.isnan(value):
             assert math.isnan(round_tripped)
         else:
             assert round_tripped == value
コード例 #4
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 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
コード例 #5
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_negative_inf(self):
     result = bin_to_float('0b11111111100000000000000000000000')
     assert math.isinf(result)
     assert result < 0
コード例 #6
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_inf(self):
     result = bin_to_float('0b01111111100000000000000000000000')
     assert math.isinf(result)
     assert result > 0
コード例 #7
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_nan(self):
     result = bin_to_float('0b01111111100000000000000000000001')
     assert math.isnan(result)
コード例 #8
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_negative_zero(self):
     expected = -0.0
     result = bin_to_float('0b10000000000000000000000000000000')
     assert result == expected
コード例 #9
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_zero(self):
     expected = 0.0
     result = bin_to_float('0b00000000000000000000000000000000')
     assert result == expected
コード例 #10
0
ファイル: test_float_bin.py プロジェクト: ajdawson/fconvert
 def test_nan(self):
     round_tripped = bin_to_float(float_to_bin(float('nan')))
     assert math.isnan(round_tripped)
コード例 #11
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_negative_inf(self):
     result = bin_to_float('0b11111111100000000000000000000000')
     assert math.isinf(result)
     assert result < 0
コード例 #12
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_inf(self):
     result = bin_to_float('0b01111111100000000000000000000000')
     assert math.isinf(result)
     assert result > 0
コード例 #13
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_nan(self):
     result = bin_to_float('0b01111111100000000000000000000001')
     assert math.isnan(result)
コード例 #14
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_negative_zero(self):
     expected = -0.0
     result = bin_to_float('0b10000000000000000000000000000000')
     assert result == expected
コード例 #15
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_zero(self):
     expected = 0.0
     result = bin_to_float('0b00000000000000000000000000000000')
     assert result == expected
コード例 #16
0
ファイル: test_float_bin.py プロジェクト: dawson-ec/fconvert
 def test_nan(self):
     round_tripped = bin_to_float(float_to_bin(float('nan')))
     assert math.isnan(round_tripped)