diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 15:04:36 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 15:04:36 +0100 |
commit | cd708c639c34cbc7d978686e54303c91f15954c0 (patch) | |
tree | a469b265dd6e7e362200290cc6267c0dd3927cf5 /src/test/LoopTimerTest.cpp | |
parent | dfa8ffbc03c4c1acd74fd14e54c6ee566a3c445c (diff) | |
parent | 68c9e7511ea52c6ee70d052bbdf2923cd68bfa8a (diff) |
Merge branch 'wouter/gameloop' of https://github.com/lonkaars/crepe into wouter/gameloop
Diffstat (limited to 'src/test/LoopTimerTest.cpp')
-rw-r--r-- | src/test/LoopTimerTest.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/test/LoopTimerTest.cpp b/src/test/LoopTimerTest.cpp index e4f8477..5e1eccf 100644 --- a/src/test/LoopTimerTest.cpp +++ b/src/test/LoopTimerTest.cpp @@ -15,6 +15,7 @@ protected: void SetUp() override { loop_timer.start(); } }; + TEST_F(LoopTimerTest, EnforcesTargetFrameRate) { // Set the target FPS to 60 (which gives a target time per frame of ~16.67 ms) loop_timer.set_target_framerate(60); @@ -28,15 +29,17 @@ TEST_F(LoopTimerTest, EnforcesTargetFrameRate) { // For 60 FPS, the target frame time is around 16.67ms ASSERT_NEAR(elapsed_ms, 16.7, 1); } + TEST_F(LoopTimerTest, SetTargetFps) { // Set the target FPS to 120 loop_timer.set_target_framerate(120); // Calculate the expected frame time (~8.33ms per frame) - Duration_t expected_frame_time = std::chrono::duration<float>(1.0 / 120.0); + duration_t expected_frame_time = std::chrono::duration<float>(1.0 / 120.0); ASSERT_NEAR(loop_timer.frame_target_time.count(), expected_frame_time.count(), 0.001); } + TEST_F(LoopTimerTest, DeltaTimeCalculation) { // Set the target FPS to 60 (16.67 ms per frame) loop_timer.set_target_framerate(60); @@ -46,7 +49,7 @@ TEST_F(LoopTimerTest, DeltaTimeCalculation) { auto end_time = steady_clock::now(); // Check the delta time - Duration_t delta_time = loop_timer.get_delta_time(); + duration_t delta_time = loop_timer.get_delta_time(); auto elapsed_time = duration_cast<seconds>(end_time - start_time).count(); @@ -69,7 +72,7 @@ TEST_F(LoopTimerTest, getCurrentTime) { // Get the elapsed time in seconds as a double auto elapsed_time - = std::chrono::duration_cast<ElapsedTime_t>(end_time - start_time).count(); + = std::chrono::duration_cast<elapsed_time_t>(end_time - start_time).count(); ASSERT_NEAR(loop_timer.get_elapsed_time().count(), elapsed_time, 5); } |