diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_float.py | 6 | ||||
-rw-r--r-- | Lib/test/test_getargs2.py | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 66726d6..a16c05c 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -617,6 +617,12 @@ class IEEEFormatTestCase(unittest.TestCase): ('<f', LE_FLOAT_NAN)]: struct.unpack(fmt, data) + @support.requires_IEEE_754 + def test_serialized_float_rounding(self): + from _testcapi import FLT_MAX + self.assertEqual(struct.pack("<f", 3.40282356e38), struct.pack("<f", FLT_MAX)) + self.assertEqual(struct.pack("<f", -3.40282356e38), struct.pack("<f", -FLT_MAX)) + class FormatTestCase(unittest.TestCase): def test_format(self): diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 86df3a4..20f6f4d 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -377,6 +377,12 @@ class Float_TestCase(unittest.TestCase): r = getargs_f(NAN) self.assertNotEqual(r, r) + @support.requires_IEEE_754 + def test_f_rounding(self): + from _testcapi import getargs_f + self.assertEqual(getargs_f(3.40282356e38), FLT_MAX) + self.assertEqual(getargs_f(-3.40282356e38), -FLT_MAX) + def test_d(self): from _testcapi import getargs_d self.assertEqual(getargs_d(4.25), 4.25) |