diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/AudioTest.cpp | 15 | ||||
-rw-r--r-- | src/test/ECSTest.cpp | 3 | ||||
-rw-r--r-- | src/test/EventTest.cpp | 6 | ||||
-rw-r--r-- | src/test/ParticleTest.cpp | 3 | ||||
-rw-r--r-- | src/test/PhysicsTest.cpp | 3 | ||||
-rw-r--r-- | src/test/PrivateTest.cpp | 5 | ||||
-rw-r--r-- | src/test/RenderSystemTest.cpp | 3 | ||||
-rw-r--r-- | src/test/ResourceManagerTest.cpp | 16 | ||||
-rw-r--r-- | src/test/SceneManagerTest.cpp | 7 | ||||
-rw-r--r-- | src/test/ScriptEventTest.cpp | 7 | ||||
-rw-r--r-- | src/test/ScriptSceneTest.cpp | 3 | ||||
-rw-r--r-- | src/test/ScriptTest.cpp | 3 | ||||
-rw-r--r-- | src/test/ScriptTest.h | 8 | ||||
-rw-r--r-- | src/test/main.cpp | 3 |
14 files changed, 39 insertions, 46 deletions
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 <gtest/gtest.h> #include <gmock/gmock.h> +#include <gtest/gtest.h> -#include <crepe/manager/ComponentManager.h> -#include <crepe/manager/ResourceManager.h> #include <crepe/api/AudioSource.h> #include <crepe/api/GameObject.h> +#include <crepe/manager/ComponentManager.h> +#include <crepe/manager/ResourceManager.h> #include <crepe/system/AudioSystem.h> using namespace std; @@ -26,21 +26,21 @@ private: public: using AudioSystem::AudioSystem; StrictMock<TestSoundContext> 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<AudioSource>("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 <crepe/manager/ComponentManager.h> #include <crepe/api/GameObject.h> #include <crepe/api/Metadata.h> #include <crepe/api/Transform.h> #include <crepe/api/Vector2.h> +#include <crepe/manager/ComponentManager.h> 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 <gtest/gtest.h> #include <crepe/api/Event.h> -#include <crepe/manager/EventManager.h> #include <crepe/api/IKeyListener.h> #include <crepe/api/IMouseListener.h> +#include <crepe/manager/EventManager.h> using namespace std; using namespace std::chrono_literals; @@ -37,9 +37,7 @@ public: }; TEST_F(EventManagerTest, EventSubscription) { - EventHandler<KeyPressEvent> key_handler = [](const KeyPressEvent & e) { - return true; - }; + EventHandler<KeyPressEvent> key_handler = [](const KeyPressEvent & e) { return true; }; // Subscribe to KeyPressEvent EventManager::get_instance().subscribe<KeyPressEvent>(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 <crepe/manager/ComponentManager.h> #include <crepe/Particle.h> #include <crepe/api/Config.h> #include <crepe/api/GameObject.h> @@ -7,6 +6,7 @@ #include <crepe/api/Sprite.h> #include <crepe/api/Texture.h> #include <crepe/api/Transform.h> +#include <crepe/manager/ComponentManager.h> #include <crepe/system/ParticleSystem.h> #include <gtest/gtest.h> #include <math.h> @@ -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 <crepe/manager/ComponentManager.h> #include <crepe/api/Config.h> #include <crepe/api/GameObject.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/Transform.h> +#include <crepe/manager/ComponentManager.h> #include <crepe/system/PhysicsSystem.h> #include <gtest/gtest.h> @@ -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 <crepe/api/Camera.h> -#include <crepe/manager/ComponentManager.h> #include <crepe/api/Color.h> #include <crepe/api/GameObject.h> #include <crepe/api/Sprite.h> #include <crepe/api/Texture.h> +#include <crepe/manager/ComponentManager.h> #include <crepe/system/RenderSystem.h> @@ -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 <crepe/util/Log.h> -#include <crepe/manager/ResourceManager.h> #include <crepe/api/GameObject.h> +#include <crepe/manager/ResourceManager.h> +#include <crepe/util/Log.h> 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 <gtest/gtest.h> -#include <crepe/types.h> -#include <crepe/manager/SceneManager.h> -#include <crepe/manager/ComponentManager.h> #include <crepe/api/GameObject.h> #include <crepe/api/Metadata.h> #include <crepe/api/Scene.h> #include <crepe/api/Transform.h> #include <crepe/api/Vector2.h> +#include <crepe/manager/ComponentManager.h> +#include <crepe/manager/SceneManager.h> +#include <crepe/types.h> 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 <crepe/manager/ComponentManager.h> -#include <crepe/manager/EventManager.h> #include <crepe/api/BehaviorScript.h> #include <crepe/api/Event.h> #include <crepe/api/GameObject.h> #include <crepe/api/Script.h> #include <crepe/api/Vector2.h> +#include <crepe/manager/ComponentManager.h> +#include <crepe/manager/EventManager.h> #include <crepe/system/ScriptSystem.h> #include "ScriptTest.h" @@ -32,7 +32,7 @@ TEST_F(ScriptEventTest, Inactive) { EventManager & evmgr = this->event_manager; unsigned event_count = 0; - script.subscribe<MyEvent>([&](const MyEvent &){ + script.subscribe<MyEvent>([&](const MyEvent &) { event_count++; return true; }); @@ -48,4 +48,3 @@ TEST_F(ScriptEventTest, Inactive) { evmgr.trigger_event<MyEvent>(); 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 <crepe/manager/SceneManager.h> #include "ScriptTest.h" +#include <crepe/manager/SceneManager.h> 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 <gtest/gtest.h> #include <gmock/gmock.h> +#include <gtest/gtest.h> // 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 <gtest/gtest.h> #include <gmock/gmock.h> +#include <gtest/gtest.h> -#include <crepe/manager/ComponentManager.h> -#include <crepe/system/ScriptSystem.h> #include <crepe/api/BehaviorScript.h> #include <crepe/api/Script.h> +#include <crepe/manager/ComponentManager.h> +#include <crepe/system/ScriptSystem.h> 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 <gtest/gtest.h> #include <crepe/api/Config.h> +#include <gtest/gtest.h> using namespace crepe; using namespace testing; @@ -26,4 +26,3 @@ int main(int argc, char ** argv) { return RUN_ALL_TESTS(); } - |