diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-02 09:05:32 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-02 09:05:32 (GMT) |
commit | ead144c19b2226f82f5c0d9ae3cb26b59dcbf0c7 (patch) | |
tree | c289a5001db71cbec59af71a0f2c0ad4ccf93a66 /Lib/test/test_time.py | |
parent | acea9f6208c74186df62f8c4cfd269919e33779f (diff) | |
download | cpython-ead144c19b2226f82f5c0d9ae3cb26b59dcbf0c7.zip cpython-ead144c19b2226f82f5c0d9ae3cb26b59dcbf0c7.tar.gz cpython-ead144c19b2226f82f5c0d9ae3cb26b59dcbf0c7.tar.bz2 |
test_time: add more tests on HALF_UP rounding mode
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 926e700..db96277 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -1082,9 +1082,18 @@ class TestOldPyTime(unittest.TestCase): (-1.9, -2, FLOOR), (-1.9, -2, HALF_UP), (-1.9, -1, CEILING), + (1.9, 1, FLOOR), (1.9, 2, HALF_UP), (1.9, 2, CEILING), + + (-0.6, -1, HALF_UP), + (-0.5, -1, HALF_UP), + (-0.4, 0, HALF_UP), + + (0.4, 0, HALF_UP), + (0.5, 1, HALF_UP), + (0.6, 1, HALF_UP), ): self.assertEqual(pytime_object_to_time_t(obj, rnd), time_t) @@ -1127,13 +1136,19 @@ class TestOldPyTime(unittest.TestCase): (1e-7, (0, 1), CEILING), (1e-7, (0, 0), HALF_UP), - (0.4e-6, (0, 0), HALF_UP), - (0.5e-6, (0, 1), HALF_UP), - (0.6e-6, (0, 1), HALF_UP), - (0.9999999, (0, 999999), FLOOR), (0.9999999, (1, 0), CEILING), (0.9999999, (1, 0), HALF_UP), + + (-0.6e-6, (-1, 999999), HALF_UP), + # skipped, -0.5e-6 is inexact in base 2 + #(-0.5e-6, (-1, 999999), HALF_UP), + (-0.4e-6, (0, 0), HALF_UP), + + (0.4e-6, (0, 0), HALF_UP), + # skipped, 0.5e-6 is inexact in base 2 + #(0.5e-6, (0, 1), HALF_UP), + (0.6e-6, (0, 1), HALF_UP), ): with self.subTest(obj=obj, round=rnd, timeval=timeval): self.assertEqual(pytime_object_to_timeval(obj, rnd), timeval) @@ -1177,13 +1192,18 @@ class TestOldPyTime(unittest.TestCase): (1e-10, (0, 1), CEILING), (1e-10, (0, 0), HALF_UP), - (0.4e-9, (0, 0), HALF_UP), - (0.5e-9, (0, 1), HALF_UP), - (0.6e-9, (0, 1), HALF_UP), - (0.9999999999, (0, 999999999), FLOOR), (0.9999999999, (1, 0), CEILING), (0.9999999999, (1, 0), HALF_UP), + + (-0.6e-9, (-1, 999999999), HALF_UP), + # skipped, 0.5e-6 is inexact in base 2 + #(-0.5e-9, (-1, 999999999), HALF_UP), + (-0.4e-9, (0, 0), HALF_UP), + + (0.4e-9, (0, 0), HALF_UP), + (0.5e-9, (0, 1), HALF_UP), + (0.6e-9, (0, 1), HALF_UP), ): with self.subTest(obj=obj, round=rnd, timespec=timespec): self.assertEqual(pytime_object_to_timespec(obj, rnd), timespec) |