diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-06 17:13:59 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-06 17:13:59 +0100 |
commit | f4824f5e7e6cee12bec602f3240770945a73d043 (patch) | |
tree | 7d51652e5395ca70f995c0d059c36e1dd18bd8ae /src/test/ECSTest.cpp | |
parent | 0bed469e2ececfa240085a34252dd7ed23519de3 (diff) |
add more fetching functions to ComponentManager
Diffstat (limited to 'src/test/ECSTest.cpp')
-rw-r--r-- | src/test/ECSTest.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp index 3e6c61c..a169b3b 100644 --- a/src/test/ECSTest.cpp +++ b/src/test/ECSTest.cpp @@ -1,6 +1,7 @@ #include <gtest/gtest.h> #define protected public +#define private public #include <crepe/api/GameObject.h> #include <crepe/api/Metadata.h> @@ -387,3 +388,36 @@ TEST_F(ECSTest, resetPersistent) { EXPECT_EQ(metadata.size(), 0); EXPECT_EQ(transform.size(), 0); } + +TEST_F(ECSTest, GetByName) { + GameObject foo = mgr.new_object("foo"); + GameObject bar = mgr.new_object("bar"); + + { + auto objects = mgr.get_objects_by_name(""); + EXPECT_EQ(objects.size(), 0); + } + + { + auto objects = mgr.get_objects_by_name("foo"); + EXPECT_EQ(objects.size(), 1); + EXPECT_TRUE(objects.contains(foo.id)); + } +} + +TEST_F(ECSTest, GetByTag) { + GameObject foo = mgr.new_object("foo", "common tag"); + GameObject bar = mgr.new_object("bar", "common tag"); + + { + auto objects = mgr.get_objects_by_tag(""); + EXPECT_EQ(objects.size(), 0); + } + + { + auto objects = mgr.get_objects_by_tag("common tag"); + EXPECT_EQ(objects.size(), 2); + EXPECT_TRUE(objects.contains(foo.id)); + EXPECT_TRUE(objects.contains(bar.id)); + } +} |