Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 3fc237f

Browse files
committed
Additional invalid AM timecode tests (failing)
1 parent 497164e commit 3fc237f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/testwwvb.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,38 @@ def test_epoch2(self) -> None:
395395
self.assertEqual(WWVBMinute2k(2070, 1, 1, 0, 0).year, 2070)
396396
self.assertEqual(WWVBMinute2k(2099, 1, 1, 0, 0).year, 2099)
397397

398+
def test_invalid_minute(self) -> None:
399+
"""Check that minute 61 is not valid in an AM timecode"""
400+
base_minute = wwvb.WWVBMinute(2021, 1, 1, 0, 0)
401+
minute = base_minute.as_timecode()
402+
minute._put_am_bcd(61, 1, 2, 3, 5, 6, 7, 8) # valid BCD, invalid minute
403+
decoded_minute = wwvb.WWVBMinute.from_timecode_am(minute)
404+
assert decoded_minute is None
405+
406+
def test_invalid_hour(self) -> None:
407+
"""Check that hour 25 is not valid in an AM timecode"""
408+
base_minute = wwvb.WWVBMinute(2021, 1, 1, 0, 0)
409+
minute = base_minute.as_timecode()
410+
minute._put_am_bcd(29, 12, 13, 15, 16, 17, 18) # valid BCD, invalid hour
411+
decoded_minute = wwvb.WWVBMinute.from_timecode_am(minute)
412+
assert decoded_minute is None
413+
414+
def test_invalid_bcd_day(self) -> None:
415+
"""Check that invalid BCD is detected in AM timecode"""
416+
base_minute = wwvb.WWVBMinute(2021, 1, 1, 0, 0)
417+
minute = base_minute.as_timecode()
418+
minute.am[30:34] = [wwvb.AmplitudeModulation.ONE] * 4 # invalid BCD 0xf
419+
decoded_minute = wwvb.WWVBMinute.from_timecode_am(minute)
420+
assert decoded_minute is None
421+
422+
def test_invalid_mark(self) -> None:
423+
"""Check that invalid presence of MARK in a data field is detected"""
424+
base_minute = wwvb.WWVBMinute(2021, 1, 1, 0, 0)
425+
minute = base_minute.as_timecode()
426+
minute.am[57] = wwvb.AmplitudeModulation.MARK
427+
decoded_minute = wwvb.WWVBMinute.from_timecode_am(minute)
428+
assert decoded_minute is None
429+
398430

399431
if __name__ == "__main__":
400432
unittest.main()

0 commit comments

Comments
 (0)