Skip to content

Commit

Permalink
add clock utest
Browse files Browse the repository at this point in the history
  • Loading branch information
Leterax committed Dec 2, 2024
1 parent 6e4a8fb commit 75abfc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ def test_not_started(self) -> None:
t, real_t = timer.stop()
self.assertTrue(t == 0)
self.assertTrue(real_t == 0)

def test_zero_delta(self) -> None:
"""Test that timer handles zero delta gracefully"""
timer = clock.Timer()
timer.start()
# Force a zero delta by setting the same time twice
timer.time = 1.0
timer.next_frame()
timer.time = 1.0
timer.next_frame()
# FPS should be 0 when delta is 0 to avoid division by zero
self.assertEqual(timer.fps, 0)

0 comments on commit 75abfc0

Please sign in to comment.