Skip to content

Commit

Permalink
feat(tests): Add test to see if spawned entities from blueprints have…
Browse files Browse the repository at this point in the history
… the right components
  • Loading branch information
diogomsmiranda committed Feb 3, 2024
1 parent 6db8272 commit 66f4a4c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/tests/ecs/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,26 @@ TEST_CASE("ecs::Blueprint")
CHECK(dict.map.at('0') == spawned0);
CHECK(dict.map.at('1') == spawned1);
}

SUBCASE("check if entities from spawned blueprint have the right components")
{
Blueprint blueprint{};
auto entity0 = blueprint.create("0");
auto entity1 = blueprint.create("1");
blueprint.add(entity0, IntegerComponent{0});
blueprint.add(entity1, IntegerComponent{1});

// Spawn the blueprint into the world and get the identifiers of the spawned entities.
auto spawned = cmds.spawn(blueprint);
auto spawned0 = spawned.entity("0");
auto spawned1 = spawned.entity("1");
cmdBuffer.commit();

auto& components0 = world.components(spawned0);
auto& components1 = world.components(spawned1);
REQUIRE(components0.has<IntegerComponent>());
REQUIRE(components1.has<IntegerComponent>());
CHECK(components0.get<IntegerComponent>().value == 0);
CHECK(components1.get<IntegerComponent>().value == 1);
}
}

0 comments on commit 66f4a4c

Please sign in to comment.