From 24c9a9ab277897a7191d4e99213c2ab9f5d4ecd8 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Sat, 7 Dec 2024 15:32:47 +0100 Subject: make format --- src/test/LoopManagerTest.cpp | 70 +++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'src/test/LoopManagerTest.cpp') diff --git a/src/test/LoopManagerTest.cpp b/src/test/LoopManagerTest.cpp index 13a0ada..f73605e 100644 --- a/src/test/LoopManagerTest.cpp +++ b/src/test/LoopManagerTest.cpp @@ -1,67 +1,63 @@ #include -#include #include +#include #include #define private public #define protected public #include -#include #include +#include using namespace std::chrono; using namespace crepe; class LoopManagerTest : public ::testing::Test { protected: - class TestGameLoop : public crepe::LoopManager { - public: - MOCK_METHOD(void, fixed_update, (), (override)); - MOCK_METHOD(void, update, (), (override)); + class TestGameLoop : public crepe::LoopManager { + public: + MOCK_METHOD(void, fixed_update, (), (override)); + MOCK_METHOD(void, update, (), (override)); MOCK_METHOD(void, render, (), (override)); - }; + }; - TestGameLoop test_loop; - void SetUp() override { - - } + TestGameLoop test_loop; + void SetUp() override {} }; TEST_F(LoopManagerTest, FixedUpdate) { - // Arrange - test_loop.loop_timer.set_target_fps(60); + // Arrange + test_loop.loop_timer.set_target_fps(60); - // Set expectations for the mock calls - EXPECT_CALL(test_loop, render).Times(::testing::Exactly(60)); + // Set expectations for the mock calls + EXPECT_CALL(test_loop, render).Times(::testing::Exactly(60)); EXPECT_CALL(test_loop, update).Times(::testing::Exactly(60)); - EXPECT_CALL(test_loop, fixed_update).Times(::testing::Exactly(50)); + EXPECT_CALL(test_loop, fixed_update).Times(::testing::Exactly(50)); - // Start the loop in a separate thread - std::thread loop_thread([&]() { test_loop.start(); }); + // Start the loop in a separate thread + std::thread loop_thread([&]() { test_loop.start(); }); - // Let the loop run for exactly 1 second - std::this_thread::sleep_for(std::chrono::seconds(1)); + // Let the loop run for exactly 1 second + std::this_thread::sleep_for(std::chrono::seconds(1)); - // Stop the game loop - test_loop.game_running = false; - // Wait for the loop thread to finish - loop_thread.join(); + // Stop the game loop + test_loop.game_running = false; + // Wait for the loop thread to finish + loop_thread.join(); - // Test finished + // Test finished } TEST_F(LoopManagerTest, ShutDown) { - // Arrange - test_loop.loop_timer.set_target_fps(60); + // Arrange + test_loop.loop_timer.set_target_fps(60); - EXPECT_CALL(test_loop, render).Times(::testing::AtLeast(1)); + EXPECT_CALL(test_loop, render).Times(::testing::AtLeast(1)); EXPECT_CALL(test_loop, update).Times(::testing::AtLeast(1)); - EXPECT_CALL(test_loop, fixed_update).Times(::testing::AtLeast(1)); - // Start the loop in a separate thread - std::thread loop_thread([&]() { test_loop.start(); }); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + EXPECT_CALL(test_loop, fixed_update).Times(::testing::AtLeast(1)); + // Start the loop in a separate thread + std::thread loop_thread([&]() { test_loop.start(); }); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); test_loop.event_manager.trigger_event(ShutDownEvent{}); - // Wait for the loop thread to finish - loop_thread.join(); + // Wait for the loop thread to finish + loop_thread.join(); - // Test finished + // Test finished } - - -- cgit v1.2.3