-fix some memory leaks in unittests

-change name in dub.json ecs->bubel_ecs
-add dependeny in meson.build
This commit is contained in:
Mergul 2021-01-09 14:30:56 +01:00
parent 84ba5f9eb5
commit edaa2286f4
4 changed files with 8 additions and 1 deletions

View file

@ -1,5 +1,5 @@
{ {
"name": "ecs", "name": "bubel_ecs",
"authors": [ "authors": [
"Michał Masiukiewicz", "Dawid Masiukiewicz" "Michał Masiukiewicz", "Dawid Masiukiewicz"
], ],

View file

@ -67,6 +67,8 @@ ecs_lib = library('ecs', src, include_directories : [tests_inc, inc], d_args: ar
executable('tests', tests_src, include_directories : [tests_inc, inc], d_args: args, link_args: link_args, link_with: ecs_lib) executable('tests', tests_src, include_directories : [tests_inc, inc], d_args: args, link_args: link_args, link_with: ecs_lib)
bubel_ecs_dep = declare_dependency(include_directories : [inc], link_with : ecs_lib)
if BuildDemos_opt if BuildDemos_opt
subdir('demos/utils') subdir('demos/utils')
subdir('demos') subdir('demos')

View file

@ -158,6 +158,7 @@ unittest
unittest unittest
{ {
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray); EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray);
scope(exit)gEM.freeTemplate(tmpl_);
assert(tmpl_.info.components.length == 3); assert(tmpl_.info.components.length == 3);
assert(tmpl_.info.size == (CInt.sizeof + CFloat.sizeof + EntityID.sizeof)); assert(tmpl_.info.size == (CInt.sizeof + CFloat.sizeof + EntityID.sizeof));
assert(tmpl_.getComponent!CInt); assert(tmpl_.getComponent!CInt);
@ -346,6 +347,7 @@ unittest
assert(*tmpl_7.getComponent!CLong == 10); assert(*tmpl_7.getComponent!CLong == 10);
gEM.freeTemplate(tmpl_d); gEM.freeTemplate(tmpl_d);
gEM.freeTemplate(tmpl_cp);
gEM.freeTemplate(tmpl_); gEM.freeTemplate(tmpl_);
gEM.freeTemplate(tmpl_2); gEM.freeTemplate(tmpl_2);
gEM.freeTemplate(tmpl_3); gEM.freeTemplate(tmpl_3);
@ -369,6 +371,8 @@ unittest
assert(*tmpl_.getComponent!CInt == 1); assert(*tmpl_.getComponent!CInt == 1);
assert(*tmpl_.getComponent!CFloat == 2.0); assert(*tmpl_.getComponent!CFloat == 2.0);
assert(tmpl_.info == tmpl_2.info); assert(tmpl_.info == tmpl_2.info);
gEM.freeTemplate(tmpl_);
gEM.freeTemplate(tmpl_2);
} }
@("MultiRegister") @("MultiRegister")

View file

@ -1014,6 +1014,7 @@ else:
writeEntityComponents(gEM.getEntity(entity)); writeEntityComponents(gEM.getEntity(entity));
//import std.stdio; //import std.stdio;
////writeln((cast(uint*)tmpl.info.first_block)[0..48]); ////writeln((cast(uint*)tmpl.info.first_block)[0..48]);
gEM.freeTemplate(tmpl_empty);
gEM.freeTemplate(tmpl); gEM.freeTemplate(tmpl);
gEM.freeTemplate(tmpl2); gEM.freeTemplate(tmpl2);
gEM.freeTemplate(copy_tempalte); gEM.freeTemplate(copy_tempalte);