Basic and working entity system with a really ugly test case

This commit is contained in:
sippeangelo
2015-12-03 15:07:35 +01:00
parent c7430a9338
commit d3d2e594fe
11 changed files with 286 additions and 135 deletions
+25 -19
View File
@@ -4,25 +4,31 @@
BOOST_AUTO_TEST_CASE(ComponentPoolTest)
{
ComponentInfo ci;
ci.Name = "Test";
ci.FieldTypes["Field"] = "int";
ci.FieldOffsets["Field"] = sizeof(EntityID);
ci.Meta.Allocation = 4;
ci.Meta.Stride = sizeof(EntityID) + sizeof(int);
// TODO: Write an updated test for component pool
BOOST_CHECK(false);
//ComponentInfo ci;
//ci.Name = "Test";
//ci.FieldTypes["Field"] = "int";
//ci.FieldOffsets["Field"] = 0;
//ci.Meta.Allocation = 3;
//ci.Meta.Stride = sizeof(EntityID) + sizeof(int);
ComponentPool pool(ci);
for (int i = 0; i < 3; i++) {
ComponentWrapper c = pool.New();
c.EntityID = i;
unsigned int offset = c.Info.FieldOffsets.at("Field");
memcpy(&c.Data[offset], &i, sizeof(int));
}
//std::vector<ComponentWrapper> wrappers;
//ComponentPool pool(ci);
//for (int i = 0; i < 4; i++) {
// ComponentWrapper c = pool.New();
// c.EntityID = i;
// unsigned int offset = c.Info.FieldOffsets.at("Field");
// memcpy(&c.Data[offset], &i, sizeof(int));
// wrappers.push_back(c);
//}
int i = 0;
for (auto& c : pool) {
BOOST_CHECK(c.EntityID == i);
BOOST_CHECK((int)c["Field"] == i);
i++;
}
//int i = 0;
//for (auto& c : pool) {
// BOOST_CHECK(c.EntityID == i);
// BOOST_CHECK((int)c["Field"] == i);
// i++;
//}
//pool.Delete(wrappers[1]);
}