diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-24 19:36:32 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-24 19:36:32 +0100 |
commit | 9f4f2fa8eac190ccb407c3f911ac5978cb4c3e3a (patch) | |
tree | ae76c898732170b219ba4b2ac26f96d3053aa2ce /src | |
parent | eb11f6609ab91bc46948ca9fc5743078f88ae48e (diff) |
start of tests
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/LoopTimer.h | 1 | ||||
-rw-r--r-- | src/test/gameLoopTest.cpp | 34 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/crepe/api/LoopTimer.h b/src/crepe/api/LoopTimer.h index eea60bb..0a48e20 100644 --- a/src/crepe/api/LoopTimer.h +++ b/src/crepe/api/LoopTimer.h @@ -68,7 +68,6 @@ private: * Initializes the timer to begin tracking frame times. */ void start(); - /** * \brief Enforce the frame rate limit. * diff --git a/src/test/gameLoopTest.cpp b/src/test/gameLoopTest.cpp new file mode 100644 index 0000000..af80b27 --- /dev/null +++ b/src/test/gameLoopTest.cpp @@ -0,0 +1,34 @@ +#define private public +#define protected public +#include "api/LoopManager.h" +#include "api/LoopTimer.h" +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +using namespace std; +using namespace std::chrono_literals; +using namespace crepe; + +class GameLoopTest : public ::testing::Test { +public: +LoopManager loop_manager; +LoopTimer loop_timer = LoopTimer::get_instance(); +protected: + void SetUp() override { + loop_timer.start(); + loop_manager.start(); + } + + void TearDown() override { + + } +}; +TEST_F(GameLoopTest, TestDeltaTime) { + auto start_time = std::chrono::steady_clock::now(); + + loop_timer.update(); + double delta_time = loop_timer.get_delta_time(); + + auto elapsed_time = std::chrono::steady_clock::now() - start_time; + EXPECT_LE(delta_time, std::chrono::duration<double>(elapsed_time).count()); // delta_time should match or be slightly less +} |