Skip to content

Commit

Permalink
test(core): adde extra check to observer test
Browse files Browse the repository at this point in the history
  • Loading branch information
SrGesus committed Oct 19, 2024
1 parent a96d17e commit be10029
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions core/tests/ecs/cubos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,28 @@ TEST_CASE("ecs::Cubos")
{
cubos.component<int>();

cubos.observer("destroy observed entity").onRemove<int>().call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.remove<int>(ent);
}
});
cubos.observer("remove observed component from observed entity")
.onRemove<int>()
.call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.remove<int>(ent);
}
});

cubos.startupSystem("remove observed component").call([](Commands cmds) {
cubos.startupSystem("remove component").call([](Commands cmds) {
auto ent1 = cmds.create().add<int>(1).entity();
cmds.create().entity();
cmds.create().add<int>(2);
cmds.remove<int>(ent1);
});

cubos.system("check if component is gone").call([](Query<Entity, int&> query) {
for (auto [entity, i] : query)
{
CHECK(i == 2);
}
});

cubos.run();
}

Expand All @@ -351,7 +360,6 @@ TEST_CASE("ecs::Cubos")

cubos.startupSystem("destroy entity with observed component").call([](Commands cmds) {
auto ent1 = cmds.create().add<int>(1).entity();
cmds.create().entity();
cmds.destroy(ent1);
});

Expand Down

0 comments on commit be10029

Please sign in to comment.