From aa0552277273ebefe29d5b27a506c977f24ec502 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 14 Mar 2016 20:36:05 +0900 Subject: [PATCH] Slight change to unit tests, docs Unit test now creates Component with Manager::addComponent. --- src/EC/Manager.hpp | 6 +++++- src/test/ECTest.cpp | 13 ++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/EC/Manager.hpp b/src/EC/Manager.hpp index 0095a51..94b6781 100644 --- a/src/EC/Manager.hpp +++ b/src/EC/Manager.hpp @@ -253,6 +253,8 @@ namespace EC EC::Manager must be created with a list of all used Components and all used tags. + Note that all components must have a default constructor. + Example: \code{.cpp} EC::Manager, TypeList> manager; @@ -349,7 +351,9 @@ namespace EC \code{.cpp} struct C0 { - C0(int a, char b) : a(a), b(b) + // constructor is compatible as a default constructor + C0(int a = 0, char b = 'b') : + a(a), b(b) {} int a; diff --git a/src/test/ECTest.cpp b/src/test/ECTest.cpp index 08f7f8a..3fd03cd 100644 --- a/src/test/ECTest.cpp +++ b/src/test/ECTest.cpp @@ -8,6 +8,11 @@ #include struct C0 { + C0(int x = 0, int y = 0) : + x(x), + y(y) + {} + int x, y; }; struct C1 { @@ -60,19 +65,13 @@ TEST(EC, Manager) std::size_t e0 = manager.addEntity(); std::size_t e1 = manager.addEntity(); - manager.addComponent(e0); + manager.addComponent(e0, 5, 5); manager.addComponent(e0); manager.addComponent(e1); manager.addComponent(e1); manager.addTag(e1); - { - auto& pos = manager.getEntityData(e0); - pos.x = 5; - pos.y = 5; - } - { auto& vel = manager.getEntityData(e0); vel.vx = 1;