aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 15:01:46 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 15:01:46 +0100
commite49893e8de74534494792955c50ea0eabaf3ba38 (patch)
treec85a80001d4c17e467d69698defb628109559ecf /src/test
parent68bf20b491b4b7673c2ece7a6497b9faffd44eb1 (diff)
WIP fix LoopTimerManager
Diffstat (limited to 'src/test')
-rw-r--r--src/test/LoopTimerTest.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/test/LoopTimerTest.cpp b/src/test/LoopTimerTest.cpp
index 1216e5e..f99f109 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();
@@ -68,8 +71,9 @@ TEST_F(LoopTimerTest, getCurrentTime) {
auto end_time = steady_clock::now();
// Get the elapsed time in seconds as a double
- auto elapsed_time = std::chrono::duration_cast<ElapsedTime_t>(end_time - start_time).count();
+ auto elapsed_time = std::chrono::duration_cast<elapsed_time_t>(end_time - start_time).count();
ASSERT_NEAR(loop_timer.get_elapsed_time().count(), elapsed_time, 5);
}
+