mirror of
https://github.com/python/cpython.git
synced 2025-11-18 01:57:37 +00:00
Issue #25155: Fix _PyTime_Divide() rounding
_PyTime_Divide() rounding was wrong: copy code from Python default which has now much better unit tests.
This commit is contained in:
parent
02d6a25bea
commit
ec26f83f2e
2 changed files with 16 additions and 11 deletions
|
|
@ -946,14 +946,14 @@ class TestPyTime_t(unittest.TestCase):
|
|||
# nanoseconds
|
||||
(1, 0, FLOOR),
|
||||
(1, 1, CEILING),
|
||||
(-1, 0, FLOOR),
|
||||
(-1, -1, CEILING),
|
||||
(-1, -1, FLOOR),
|
||||
(-1, 0, CEILING),
|
||||
|
||||
# seconds + nanoseconds
|
||||
(1234 * MS_TO_NS + 1, 1234, FLOOR),
|
||||
(1234 * MS_TO_NS + 1, 1235, CEILING),
|
||||
(-1234 * MS_TO_NS - 1, -1234, FLOOR),
|
||||
(-1234 * MS_TO_NS - 1, -1235, CEILING),
|
||||
(-1234 * MS_TO_NS - 1, -1235, FLOOR),
|
||||
(-1234 * MS_TO_NS - 1, -1234, CEILING),
|
||||
):
|
||||
with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd):
|
||||
self.assertEqual(PyTime_AsMilliseconds(ns, rnd), ms)
|
||||
|
|
@ -983,14 +983,14 @@ class TestPyTime_t(unittest.TestCase):
|
|||
# nanoseconds
|
||||
(1, 0, FLOOR),
|
||||
(1, 1, CEILING),
|
||||
(-1, 0, FLOOR),
|
||||
(-1, -1, CEILING),
|
||||
(-1, -1, FLOOR),
|
||||
(-1, 0, CEILING),
|
||||
|
||||
# seconds + nanoseconds
|
||||
(1234 * US_TO_NS + 1, 1234, FLOOR),
|
||||
(1234 * US_TO_NS + 1, 1235, CEILING),
|
||||
(-1234 * US_TO_NS - 1, -1234, FLOOR),
|
||||
(-1234 * US_TO_NS - 1, -1235, CEILING),
|
||||
(-1234 * US_TO_NS - 1, -1235, FLOOR),
|
||||
(-1234 * US_TO_NS - 1, -1234, CEILING),
|
||||
):
|
||||
with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd):
|
||||
self.assertEqual(PyTime_AsMicroseconds(ns, rnd), ms)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue