aboutsummaryrefslogtreecommitdiff
path: root/simloop/test
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2026-04-11 16:35:25 -0700
committer3gg <3gg@shellblade.net>2026-04-11 16:35:25 -0700
commit896a6ef5959043db5463637d84ed524ae7bade1e (patch)
tree65b6cac3b4d2fe4e51eaf0d377f4578eabaf1488 /simloop/test
parent879e5af4eb1a8972fc944853a515e1003f94bd7c (diff)
Render only if there was an update
Diffstat (limited to 'simloop/test')
-rw-r--r--simloop/test/simloop_test.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/simloop/test/simloop_test.c b/simloop/test/simloop_test.c
index c79ee32..9f11e86 100644
--- a/simloop/test/simloop_test.c
+++ b/simloop/test/simloop_test.c
@@ -44,7 +44,7 @@ TEST_CASE(simloop_initial_render_not_retriggered) {
44 44
45/// A simulation loop with no render frame cap: 45/// A simulation loop with no render frame cap:
46/// 1. Updates based on the desired update frame rate. 46/// 1. Updates based on the desired update frame rate.
47/// 2. Renders at every loop. 47/// 2. Renders at every loop (provided there are updates).
48TEST_CASE(simloop_no_render_frame_cap) { 48TEST_CASE(simloop_no_render_frame_cap) {
49 constexpr int UPDATE_FPS = 10; 49 constexpr int UPDATE_FPS = 10;
50 const time_delta EXPECT_UPDATE = sec_to_time_delta(1.0 / (double)UPDATE_FPS); 50 const time_delta EXPECT_UPDATE = sec_to_time_delta(1.0 / (double)UPDATE_FPS);
@@ -59,8 +59,10 @@ TEST_CASE(simloop_no_render_frame_cap) {
59 for (time_delta t = 0; t < SIM_TIME_SEC; t += STEP) { 59 for (time_delta t = 0; t < SIM_TIME_SEC; t += STEP) {
60 timer_advance(&timer, t); 60 timer_advance(&timer, t);
61 simloop_update(&simloop, &simout); 61 simloop_update(&simloop, &simout);
62 TEST_TRUE(simout.should_render); 62 const bool expect_update = (t > 0) && ((t % EXPECT_UPDATE) == 0);
63 TEST_EQUAL((t > 0) && ((t % EXPECT_UPDATE) == 0), simout.should_update); 63 // A render is still expected at time 0.
64 TEST_EQUAL(simout.should_render, (t == 0) || expect_update);
65 TEST_EQUAL(simout.should_update, expect_update);
64 } 66 }
65} 67}
66 68
@@ -83,9 +85,9 @@ TEST_CASE(simloop_with_render_frame_cap) {
83 for (time_delta t = 0; t < SIM_TIME_SEC; t += STEP) { 85 for (time_delta t = 0; t < SIM_TIME_SEC; t += STEP) {
84 timer_advance(&timer, t); 86 timer_advance(&timer, t);
85 simloop_update(&simloop, &simout); 87 simloop_update(&simloop, &simout);
86 // Also expecting initial render at t=0. 88 // A render is still expected at time 0.
87 TEST_EQUAL((t % EXPECT_RENDER) == 0, simout.should_render); 89 TEST_EQUAL(simout.should_render, (t % EXPECT_RENDER) == 0);
88 TEST_EQUAL((t > 0) && ((t % EXPECT_UPDATE) == 0), simout.should_update); 90 TEST_EQUAL(simout.should_update, (t > 0) && ((t % EXPECT_UPDATE) == 0));
89 } 91 }
90} 92}
91 93