diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-11-26 09:53:27 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-11-26 09:53:27 +0100 |
commit | b86f5adb5a266dfd2ef5f7a406c22f286786351d (patch) | |
tree | 64628caff3b99f44d0ab4641a8501cbb959cabed /src | |
parent | 85ae4b874262012af277492beb0c45cb4d86feef (diff) |
Added test
Diffstat (limited to 'src')
-rw-r--r-- | src/test/ECSTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp index 6903731..9dbeee5 100644 --- a/src/test/ECSTest.cpp +++ b/src/test/ECSTest.cpp @@ -349,3 +349,33 @@ TEST_F(ECSTest, persistent) { EXPECT_EQ(transform[2].get().game_object_id, 2); EXPECT_EQ(transform[2].get().scale, 5); } + +TEST_F(ECSTest, resetPersistent) { + GameObject obj0 = mgr.new_object("obj0", "obj0", vec2{0, 0}, 0, 1); + GameObject obj1 = mgr.new_object("obj1", "obj1", vec2{0, 0}, 0, 1); + obj1.set_persistent(); + GameObject obj2 = mgr.new_object("obj2", "obj2", vec2{0, 0}, 0, 1); + + vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>(); + vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>(); + + EXPECT_EQ(metadata.size(), 3); + EXPECT_EQ(transform.size(), 3); + + mgr.delete_all_components(); + + metadata = mgr.get_components_by_type<Metadata>(); + transform = mgr.get_components_by_type<Transform>(); + + EXPECT_EQ(metadata.size(), 1); + EXPECT_EQ(transform.size(), 1); + + mgr.set_persistent(1, false); + mgr.delete_all_components(); + + metadata = mgr.get_components_by_type<Metadata>(); + transform = mgr.get_components_by_type<Transform>(); + + EXPECT_EQ(metadata.size(), 0); + EXPECT_EQ(transform.size(), 0); +} |