Phase 11
This commit is contained in:
commit
c5bcb95d74
172 files changed
+9487
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
|
||||
from src.fps_counter import FPSCounter
|
||||
|
||||
|
||||
def test_initial_and_tick_and_average(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
times = iter([1.0, 1.5, 1.75])
|
||||
monkeypatch.setattr("src.fps_counter.time.perf_counter", lambda: next(times))
|
||||
counter = FPSCounter(2)
|
||||
assert counter.current_fps == counter.average_fps == 0.0
|
||||
assert counter.tick() == 0.0
|
||||
assert counter.tick() == pytest.approx(2.0)
|
||||
assert counter.tick() == pytest.approx(4.0)
|
||||
assert counter.average_fps == pytest.approx(3.0)
|
||||
|
||||
|
||||
def test_reset(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
times = iter([1.0, 2.0])
|
||||
monkeypatch.setattr("src.fps_counter.time.perf_counter", lambda: next(times))
|
||||
counter = FPSCounter(3)
|
||||
counter.tick()
|
||||
counter.tick()
|
||||
counter.reset()
|
||||
assert counter.current_fps == counter.average_fps == 0.0
|
||||
assert counter.sample_count == 0
|
||||
|
||||
|
||||
def test_invalid_window() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
FPSCounter(0)
|
||||
Reference in new issue
Block a user