Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions coresdk/src/test/unit_tests/unit_test_timers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Timer Unit Tests
*/

#include "catch.hpp"
#include "timers.h"
#include "logging_handling.h"

using namespace splashkit_lib;

TEST_CASE(
"timer can be created, started, paused, and freed",
"[timers][create_timer][free_timer][start_timer][pause_timer]")
{
timer t = create_timer("test");
REQUIRE(has_timer("test"));

REQUIRE(timer_ticks(t) == 0); // starts at 0

int attempts = 0;
start_timer(t);
while (timer_ticks(t) == 0 || attempts < 1000)
{
attempts++;
};

REQUIRE(timer_ticks(t) > 0); // time has advanced

pause_timer(t);
unsigned int ticks = timer_ticks(t);
REQUIRE(timer_ticks(t) == ticks); // ticks do not change while paused

free_timer(t);
REQUIRE_FALSE(has_timer("test")); // check the same name we created
}
1 change: 1 addition & 0 deletions splashkit-core
Submodule splashkit-core added at 4cc178