32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import unittest
|
|
from zeller_dow import dow
|
|
|
|
class TestZellerDow(unittest.TestCase):
|
|
def test_gap_dates_raise(self):
|
|
for day in range(5, 15):
|
|
with self.assertRaises(ValueError):
|
|
dow(1582, 10, day)
|
|
|
|
def test_silent_month_length_aliases_raise(self):
|
|
cases = [(2026, 2, 31), (2026, 2, 30), (2026, 4, 31),
|
|
(1900, 2, 29), (2000, 2, 30), (2024, 13, 1),
|
|
(2024, 0, 1), (2024, 1, 0), (2024, 1, 32)]
|
|
for y, m, d in cases:
|
|
with self.assertRaises(ValueError):
|
|
dow(y, m, d)
|
|
|
|
def test_valid_anchors(self):
|
|
# 1582-10-15 was a Friday (Gregorian cutover)
|
|
self.assertEqual(dow(1582, 10, 15), "Friday")
|
|
# 1582-10-04 Julian Thursday
|
|
self.assertEqual(dow(1582, 10, 4), "Thursday")
|
|
self.assertEqual(dow(2024, 2, 29), "Thursday") # leap day exists
|
|
self.assertEqual(dow(2026, 10, 27), "Tuesday")
|
|
|
|
def test_leap_day_invalid_non_leap(self):
|
|
with self.assertRaises(ValueError):
|
|
dow(2023, 2, 29)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|