aboutsummaryrefslogtreecommitdiff
path: root/src/test/ScriptECSTest.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 14:18:54 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-07 14:18:54 +0100
commit90c6bf03e59fdec64f850310bcbff45ae86f69e3 (patch)
treef80305e8b712e17c41a1860ec82a139842c67ba0 /src/test/ScriptECSTest.cpp
parentf4824f5e7e6cee12bec602f3240770945a73d043 (diff)
more script utilities
Diffstat (limited to 'src/test/ScriptECSTest.cpp')
-rw-r--r--src/test/ScriptECSTest.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ScriptECSTest.cpp b/src/test/ScriptECSTest.cpp
new file mode 100644
index 0000000..4477e55
--- /dev/null
+++ b/src/test/ScriptECSTest.cpp
@@ -0,0 +1,42 @@
+#include <gtest/gtest.h>
+
+#define protected public
+
+#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/GameObject.h>
+#include <crepe/api/Script.h>
+#include <crepe/api/Metadata.h>
+#include <crepe/manager/ComponentManager.h>
+#include <crepe/system/ScriptSystem.h>
+
+#include "ScriptTest.h"
+
+using namespace std;
+using namespace crepe;
+using namespace testing;
+
+class ScriptECSTest : public ScriptTest {
+public:
+ class TestComponent : public Component {
+ using Component::Component;
+ };
+};
+
+TEST_F(ScriptECSTest, GetOwnComponent) {
+ MyScript & script = this->script;
+ Metadata & metadata = script.get_component<Metadata>();
+
+ EXPECT_EQ(metadata.name, OBJ_NAME);
+}
+
+TEST_F(ScriptECSTest, GetOwnComponents) {
+ const unsigned COUNT = 4;
+
+ for (unsigned i = 0; i < COUNT; i++)
+ entity.add_component<TestComponent>();
+
+ MyScript & script = this->script;
+ RefVector<TestComponent> components = script.get_components<TestComponent>();
+
+ EXPECT_EQ(components.size(), COUNT);
+}