From 9eff2e24fa4cf0ffad2b47cc922a6558bc1a9fa1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 30 Nov 2024 16:42:21 +0100 Subject: `make format` --- src/test/AudioTest.cpp | 15 +++++++-------- src/test/ECSTest.cpp | 3 ++- src/test/EventTest.cpp | 6 ++---- src/test/ParticleTest.cpp | 3 ++- src/test/PhysicsTest.cpp | 3 ++- src/test/PrivateTest.cpp | 5 +---- src/test/RenderSystemTest.cpp | 3 ++- src/test/ResourceManagerTest.cpp | 16 ++++++---------- src/test/SceneManagerTest.cpp | 7 ++++--- src/test/ScriptEventTest.cpp | 7 +++---- src/test/ScriptSceneTest.cpp | 3 +-- src/test/ScriptTest.cpp | 3 +-- src/test/ScriptTest.h | 8 +++++--- src/test/main.cpp | 3 +-- 14 files changed, 39 insertions(+), 46 deletions(-) (limited to 'src/test') diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp index 9c3cb9c..14f57bd 100644 --- a/src/test/AudioTest.cpp +++ b/src/test/AudioTest.cpp @@ -1,10 +1,10 @@ -#include #include +#include -#include -#include #include #include +#include +#include #include using namespace std; @@ -26,21 +26,21 @@ private: public: using AudioSystem::AudioSystem; StrictMock context; - virtual SoundContext & get_context() { - return this->context; - } + virtual SoundContext & get_context() { return this->context; } }; private: Mediator mediator; ComponentManager component_manager{mediator}; ResourceManager resource_manager{mediator}; + public: - TestAudioSystem system {mediator}; + TestAudioSystem system{mediator}; TestSoundContext & context = system.context; private: GameObject entity = component_manager.new_object("name"); + public: AudioSource & component = entity.add_component("mwe/audio/bgm.ogg"); }; @@ -150,4 +150,3 @@ TEST_F(AudioTest, PlayOnActive) { system.update(); } } - diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp index 22c4fe7..3e6c61c 100644 --- a/src/test/ECSTest.cpp +++ b/src/test/ECSTest.cpp @@ -2,17 +2,18 @@ #define protected public -#include #include #include #include #include +#include using namespace std; using namespace crepe; class ECSTest : public ::testing::Test { Mediator m; + public: ComponentManager mgr{m}; }; diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp index 350dd07..dccd554 100644 --- a/src/test/EventTest.cpp +++ b/src/test/EventTest.cpp @@ -2,9 +2,9 @@ #include #include -#include #include #include +#include using namespace std; using namespace std::chrono_literals; @@ -37,9 +37,7 @@ public: }; TEST_F(EventManagerTest, EventSubscription) { - EventHandler key_handler = [](const KeyPressEvent & e) { - return true; - }; + EventHandler key_handler = [](const KeyPressEvent & e) { return true; }; // Subscribe to KeyPressEvent EventManager::get_instance().subscribe(key_handler, 1); diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp index 4e9fa4e..a659fe5 100644 --- a/src/test/ParticleTest.cpp +++ b/src/test/ParticleTest.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +17,7 @@ using namespace crepe; class ParticlesTest : public ::testing::Test { Mediator m; + public: ComponentManager component_manager{m}; ParticleSystem particle_system{m}; diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp index 01b7c51..43af8e4 100644 --- a/src/test/PhysicsTest.cpp +++ b/src/test/PhysicsTest.cpp @@ -1,8 +1,8 @@ -#include #include #include #include #include +#include #include #include @@ -12,6 +12,7 @@ using namespace crepe; class PhysicsTest : public ::testing::Test { Mediator m; + public: ComponentManager component_manager{m}; PhysicsSystem system{m}; diff --git a/src/test/PrivateTest.cpp b/src/test/PrivateTest.cpp index 0ea67d6..454789e 100644 --- a/src/test/PrivateTest.cpp +++ b/src/test/PrivateTest.cpp @@ -27,9 +27,7 @@ unsigned PrivateTest::constructors; unsigned PrivateTest::destructors; TEST_F(PrivateTest, Empty) { - { - Private foo; - } + { Private foo; } EXPECT_EQ(PrivateTest::constructors, 0); EXPECT_EQ(PrivateTest::destructors, 0); @@ -155,4 +153,3 @@ TEST_F(PrivateTest, DoubleAssignment) { EXPECT_EQ(PrivateTest::constructors, 2); EXPECT_EQ(PrivateTest::destructors, 2); } - diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp index 3528e46..c105dcb 100644 --- a/src/test/RenderSystemTest.cpp +++ b/src/test/RenderSystemTest.cpp @@ -7,11 +7,11 @@ #define protected public #include -#include #include #include #include #include +#include #include @@ -21,6 +21,7 @@ using namespace testing; class RenderSystemTest : public Test { Mediator m; + public: ComponentManager mgr{m}; RenderSystem sys{m}; diff --git a/src/test/ResourceManagerTest.cpp b/src/test/ResourceManagerTest.cpp index 1f56e23..b6be3c0 100644 --- a/src/test/ResourceManagerTest.cpp +++ b/src/test/ResourceManagerTest.cpp @@ -3,9 +3,9 @@ #define private public #define protected public -#include -#include #include +#include +#include using namespace std; using namespace crepe; @@ -13,6 +13,7 @@ using namespace testing; class ResourceManagerTest : public Test { Mediator mediator; + public: ResourceManager resource_manager{mediator}; @@ -25,19 +26,15 @@ public: public: const unsigned instance; - TestResource(const Asset & src) - : Resource(src), - instance(this->instances++) { } + TestResource(const Asset & src) : Resource(src), instance(this->instances++) {} ~TestResource() { this->instances--; } - bool operator == (const TestResource & other) const { + bool operator==(const TestResource & other) const { return this->instance == other.instance; } }; private: - void SetUp() override { - TestResource::instances = 0; - } + void SetUp() override { TestResource::instances = 0; } }; unsigned ResourceManagerTest::TestResource::instances = 0; @@ -72,4 +69,3 @@ TEST_F(ResourceManagerTest, Persistent) { resource_manager.clear_all(); EXPECT_EQ(TestResource::instances, 0); } - diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp index d027d89..9bb260c 100644 --- a/src/test/SceneManagerTest.cpp +++ b/src/test/SceneManagerTest.cpp @@ -1,13 +1,13 @@ #include -#include -#include -#include #include #include #include #include #include +#include +#include +#include using namespace std; using namespace crepe; @@ -57,6 +57,7 @@ private: class SceneManagerTest : public ::testing::Test { Mediator m; + public: ComponentManager component_mgr{m}; SceneManager scene_mgr{m}; diff --git a/src/test/ScriptEventTest.cpp b/src/test/ScriptEventTest.cpp index 7a9abbb..5da31e7 100644 --- a/src/test/ScriptEventTest.cpp +++ b/src/test/ScriptEventTest.cpp @@ -4,13 +4,13 @@ #define private public #define protected public -#include -#include #include #include #include #include #include +#include +#include #include #include "ScriptTest.h" @@ -32,7 +32,7 @@ TEST_F(ScriptEventTest, Inactive) { EventManager & evmgr = this->event_manager; unsigned event_count = 0; - script.subscribe([&](const MyEvent &){ + script.subscribe([&](const MyEvent &) { event_count++; return true; }); @@ -48,4 +48,3 @@ TEST_F(ScriptEventTest, Inactive) { evmgr.trigger_event(); EXPECT_EQ(1, event_count); } - diff --git a/src/test/ScriptSceneTest.cpp b/src/test/ScriptSceneTest.cpp index f96ae8b..9ee1e52 100644 --- a/src/test/ScriptSceneTest.cpp +++ b/src/test/ScriptSceneTest.cpp @@ -4,8 +4,8 @@ #define private public #define protected public -#include #include "ScriptTest.h" +#include using namespace std; using namespace crepe; @@ -28,4 +28,3 @@ TEST_F(ScriptSceneTest, Inactive) { script.set_next_scene(non_default_value); EXPECT_EQ(non_default_value, scene_manager.next_scene); } - diff --git a/src/test/ScriptTest.cpp b/src/test/ScriptTest.cpp index 6d0d5fb..1d2d6dd 100644 --- a/src/test/ScriptTest.cpp +++ b/src/test/ScriptTest.cpp @@ -1,5 +1,5 @@ -#include #include +#include // stupid hack to allow access to private/protected members under test #define private public @@ -75,4 +75,3 @@ TEST_F(ScriptTest, UpdateInactive) { system.update(); } } - diff --git a/src/test/ScriptTest.h b/src/test/ScriptTest.h index 9a71ba7..1bbfdd3 100644 --- a/src/test/ScriptTest.h +++ b/src/test/ScriptTest.h @@ -1,22 +1,24 @@ #pragma once -#include #include +#include -#include -#include #include #include +#include +#include class ScriptTest : public testing::Test { protected: crepe::Mediator mediator; + public: crepe::ComponentManager component_manager{mediator}; crepe::ScriptSystem system{mediator}; class MyScript : public crepe::Script { // NOTE: explicitly stating `public:` is not required on actual scripts + public: MOCK_METHOD(void, init, (), (override)); MOCK_METHOD(void, update, (), (override)); diff --git a/src/test/main.cpp b/src/test/main.cpp index 54f74fd..ed2aed5 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,5 +1,5 @@ -#include #include +#include using namespace crepe; using namespace testing; @@ -26,4 +26,3 @@ int main(int argc, char ** argv) { return RUN_ALL_TESTS(); } - -- cgit v1.2.3