aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-22 09:46:35 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-22 09:46:35 +0100
commit2052988dba049cfa2032d01ff9e6f7bb53d084fe (patch)
tree7444cfa41a69a21800d4ec3905a9a3b2303e71cf /src
parentef6acbee3bd00c322a56221d992d08a64e15e3b9 (diff)
Added perfect forwarding test
Diffstat (limited to 'src')
-rw-r--r--src/test/SceneManagerTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp
index 1706de0..cd3b827 100644
--- a/src/test/SceneManagerTest.cpp
+++ b/src/test/SceneManagerTest.cpp
@@ -35,6 +35,21 @@ public:
string get_name() const { return "scene2"; }
};
+class ConcreteScene3 : public Scene {
+public:
+ ConcreteScene3(const string & name) : name(name) {}
+
+ void load_scene() {
+ ComponentManager & mgr = this->component_manager;
+ GameObject object1 = mgr.new_object("scene_3", "tag_scene_3", Vector2{0, 0}, 0, 1);
+ }
+
+ string get_name() const { return name; }
+
+private:
+ const string name;
+};
+
class SceneManagerTest : public ::testing::Test {
public:
ComponentManager component_mgr{};
@@ -120,3 +135,25 @@ TEST_F(SceneManagerTest, loadScene) {
EXPECT_EQ(transform[3].get().position.x, 0);
EXPECT_EQ(transform[3].get().position.y, 3);
}
+
+TEST_F(SceneManagerTest, perfectForwarding) {
+ scene_mgr.add_scene<ConcreteScene3>("scene3");
+
+ scene_mgr.load_next_scene();
+
+ vector<reference_wrapper<Metadata>> metadata
+ = component_mgr.get_components_by_type<Metadata>();
+ vector<reference_wrapper<Transform>> transform
+ = component_mgr.get_components_by_type<Transform>();
+
+ EXPECT_EQ(metadata.size(), 1);
+ EXPECT_EQ(transform.size(), 1);
+
+ EXPECT_EQ(metadata[0].get().game_object_id, 0);
+ EXPECT_EQ(metadata[0].get().name, "scene_3");
+ EXPECT_EQ(metadata[0].get().tag, "tag_scene_3");
+ EXPECT_EQ(metadata[0].get().parent, -1);
+ EXPECT_EQ(metadata[0].get().children.size(), 0);
+ EXPECT_EQ(transform[0].get().position.x, 0);
+ EXPECT_EQ(transform[0].get().position.y, 0);
+}