From 3b17bc0e979729fb374a86ca2997fd79b273cea2478c7213183972e44a50b8cb Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 30 Nov 2024 22:02:51 +0300 Subject: [PATCH] Missing non-minimal TAI64 testing --- pyac/tests/test_tai.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pyac/tests/test_tai.py b/pyac/tests/test_tai.py index d286607..5105726 100644 --- a/pyac/tests/test_tai.py +++ b/pyac/tests/test_tai.py @@ -129,6 +129,30 @@ class TestTAI64(TestCase): ) self.assertEqual(str(err.exception), "too many attoseconds") + def test_zero_nanoseconds(self) -> None: + with self.assertRaises(DecodeError) as err: + loads( + b"\x19\x40\x00\x00\x00\x00\x00\x00\x00" + + b"\x00\x00\x00\x00" + ) + self.assertEqual(str(err.exception), "non-minimal TAI64N") + + def test_zero_attoseconds(self) -> None: + with self.assertRaises(DecodeError) as err: + loads( + b"\x1a\x40\x00\x00\x00\x00\x00\x00\x00" + + b"\x00\x00\x00\x00" + + b"\x00\x00\x00\x00" + ) + self.assertEqual(str(err.exception), "non-minimal TAI64NA") + + def test_zero_nanoseconds_ok_for_tai64na(self) -> None: + loads( + b"\x1a\x40\x00\x00\x00\x00\x00\x00\x00" + + b"\x00\x00\x00\x00" + + b"\x00\x00\x00\x01" + ) + class TestLeapsecs(TestCase): def test_match_DJB(self) -> None: -- 2.50.0