From 6e03da99701b1916ee2f6a3dd7d10f7d283f2dd9 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Sun, 24 Nov 2024 19:38:13 +0100 Subject: loopTimer tests --- src/test/gameLoopTest.cpp | 34 ---------------------------------- src/test/loopTimerTest.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 34 deletions(-) delete mode 100644 src/test/gameLoopTest.cpp create mode 100644 src/test/loopTimerTest.cpp (limited to 'src/test') diff --git a/src/test/gameLoopTest.cpp b/src/test/gameLoopTest.cpp deleted file mode 100644 index af80b27..0000000 --- a/src/test/gameLoopTest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#define private public -#define protected public -#include "api/LoopManager.h" -#include "api/LoopTimer.h" -#include -#include - -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(elapsed_time).count()); // delta_time should match or be slightly less -} diff --git a/src/test/loopTimerTest.cpp b/src/test/loopTimerTest.cpp new file mode 100644 index 0000000..a3b1646 --- /dev/null +++ b/src/test/loopTimerTest.cpp @@ -0,0 +1,32 @@ +#define private public +#define protected public +#include "api/LoopManager.h" +#include "api/LoopTimer.h" +#include +#include + +using namespace std; +using namespace std::chrono_literals; +using namespace crepe; + +class LoopTimerTest : public ::testing::Test { +public: +LoopTimer loop_timer = LoopTimer::get_instance(); +protected: + void SetUp() override { + loop_timer.start(); + } + + void TearDown() override { + + } +}; +TEST_F(LoopTimerTest, 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(elapsed_time).count()); +} -- cgit v1.2.3