diff options
Diffstat (limited to 'src/test/ECSTest.cpp')
-rw-r--r-- | src/test/ECSTest.cpp | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp index 8f86a91..92436a9 100644 --- a/src/test/ECSTest.cpp +++ b/src/test/ECSTest.cpp @@ -16,7 +16,7 @@ class ECSTest : public ::testing::Test { Mediator m; public: - ComponentManager mgr{m}; + ComponentManager mgr {m}; class TestComponent : public Component { using Component::Component; @@ -24,7 +24,7 @@ public: }; TEST_F(ECSTest, createGameObject) { - GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); + GameObject obj = mgr.new_object("body", "person", 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>(); @@ -44,8 +44,8 @@ TEST_F(ECSTest, createGameObject) { } TEST_F(ECSTest, deleteAllGameObjects) { - GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); - GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); + GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); + GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); mgr.delete_all_components(); @@ -55,7 +55,7 @@ TEST_F(ECSTest, deleteAllGameObjects) { EXPECT_EQ(metadata.size(), 0); EXPECT_EQ(transform.size(), 0); - GameObject obj2 = mgr.new_object("body2", "person2", vec2{1, 0}, 5, 1); + GameObject obj2 = mgr.new_object("body2", "person2", vec2 {1, 0}, 5, 1); metadata = mgr.get_components_by_type<Metadata>(); transform = mgr.get_components_by_type<Transform>(); @@ -77,8 +77,8 @@ TEST_F(ECSTest, deleteAllGameObjects) { } TEST_F(ECSTest, deleteGameObject) { - GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); - GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); + GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); + GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); mgr.delete_all_components_of_id(0); @@ -103,7 +103,7 @@ TEST_F(ECSTest, deleteGameObject) { TEST_F(ECSTest, manyGameObjects) { for (int i = 0; i < 5000; i++) { - GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, i); + GameObject obj = mgr.new_object("body", "person", vec2 {0, 0}, 0, i); } vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>(); @@ -135,7 +135,7 @@ TEST_F(ECSTest, manyGameObjects) { for (int i = 0; i < 10000 - 5000; i++) { string tag = "person" + to_string(i); - GameObject obj = mgr.new_object("body", tag, vec2{0, 0}, i, 0); + GameObject obj = mgr.new_object("body", tag, vec2 {0, 0}, i, 0); } metadata = mgr.get_components_by_type<Metadata>(); @@ -168,7 +168,7 @@ TEST_F(ECSTest, manyGameObjects) { for (int i = 0; i < 10000; i++) { string name = "body" + to_string(i); - GameObject obj = mgr.new_object(name, "person", vec2{0, 0}, 0, 0); + GameObject obj = mgr.new_object(name, "person", vec2 {0, 0}, 0, 0); } metadata = mgr.get_components_by_type<Metadata>(); @@ -193,8 +193,8 @@ TEST_F(ECSTest, manyGameObjects) { } TEST_F(ECSTest, getComponentsByID) { - GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); - GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); + GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); + GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_id<Metadata>(0); vector<reference_wrapper<Transform>> transform = mgr.get_components_by_id<Transform>(1); @@ -217,19 +217,21 @@ TEST_F(ECSTest, getComponentsByID) { TEST_F(ECSTest, tooMuchComponents) { try { - GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); - obj0.add_component<Transform>(vec2{10, 10}, 0, 1); + GameObject obj0 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); + obj0.add_component<Transform>(vec2 {10, 10}, 0, 1); } catch (const exception & e) { - EXPECT_EQ(e.what(), - string("Exceeded maximum number of instances for this component type")); + EXPECT_EQ( + e.what(), string("Exceeded maximum number of instances for this component type") + ); } try { - GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); + GameObject obj1 = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); obj1.add_component<Metadata>("body", "person"); } catch (const exception & e) { - EXPECT_EQ(e.what(), - string("Exceeded maximum number of instances for this component type")); + EXPECT_EQ( + e.what(), string("Exceeded maximum number of instances for this component type") + ); } vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>(); @@ -241,11 +243,11 @@ TEST_F(ECSTest, tooMuchComponents) { TEST_F(ECSTest, partentChild) { { - GameObject body = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); - GameObject right_leg = mgr.new_object("rightLeg", "person", vec2{1, 1}, 0, 1); - GameObject left_leg = mgr.new_object("leftLeg", "person", vec2{1, 1}, 0, 1); - GameObject right_foot = mgr.new_object("rightFoot", "person", vec2{2, 2}, 0, 1); - GameObject left_foot = mgr.new_object("leftFoot", "person", vec2{2, 2}, 0, 1); + GameObject body = mgr.new_object("body", "person", vec2 {0, 0}, 0, 1); + GameObject right_leg = mgr.new_object("rightLeg", "person", vec2 {1, 1}, 0, 1); + GameObject left_leg = mgr.new_object("leftLeg", "person", vec2 {1, 1}, 0, 1); + GameObject right_foot = mgr.new_object("rightFoot", "person", vec2 {2, 2}, 0, 1); + GameObject left_foot = mgr.new_object("leftFoot", "person", vec2 {2, 2}, 0, 1); // Set the parent of each GameObject right_foot.set_parent(right_leg); @@ -290,10 +292,10 @@ TEST_F(ECSTest, partentChild) { } TEST_F(ECSTest, persistent) { - GameObject obj0 = mgr.new_object("obj0", "obj0", vec2{0, 0}, 0, 1); - GameObject obj1 = mgr.new_object("obj1", "obj1", vec2{0, 0}, 0, 1); + 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); + 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>(); @@ -329,8 +331,8 @@ TEST_F(ECSTest, persistent) { EXPECT_EQ(transform[0].get().position.x, 0); EXPECT_EQ(transform[0].get().position.y, 0); - GameObject obj3 = mgr.new_object("obj3", "obj3", vec2{0, 0}, 0, 5); - GameObject obj4 = mgr.new_object("obj4", "obj4", vec2{0, 0}, 0, 5); + GameObject obj3 = mgr.new_object("obj3", "obj3", vec2 {0, 0}, 0, 5); + GameObject obj4 = mgr.new_object("obj4", "obj4", vec2 {0, 0}, 0, 5); metadata = mgr.get_components_by_type<Metadata>(); transform = mgr.get_components_by_type<Transform>(); @@ -358,10 +360,10 @@ TEST_F(ECSTest, persistent) { } 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); + 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); + 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>(); @@ -478,5 +480,5 @@ TEST_F(ECSTest, Snapshot) { mgr.restore(snapshot); - EXPECT_EQ(foo.transform.position, (vec2{1, 1})); + EXPECT_EQ(foo.transform.position, (vec2 {1, 1})); } |