diff --git a/tests/zecsy.cpp b/tests/zecsy.cpp index 3054eb7..ad7042a 100644 --- a/tests/zecsy.cpp +++ b/tests/zecsy.cpp @@ -10,14 +10,25 @@ TEST_CASE("Create a single entity and verify its existence") world w; auto e = w.make_entity(); + REQUIRE(w.is_alive(e)); } TEST_CASE("Destroy an entity and ensure it no longer exists in the world") { world w; - + auto e = w.make_entity(); w.destroy_entity(e); + REQUIRE_FALSE(w.is_alive(e)); } + +TEST_CASE("Entity #0 should be reserved and never used") +{ + world w; + + auto e = w.make_entity(); + + REQUIRE(e != 0); +} diff --git a/zecsy.hpp b/zecsy.hpp index ed7d0f8..d9d0b4a 100644 --- a/zecsy.hpp +++ b/zecsy.hpp @@ -31,11 +31,8 @@ namespace zecsy inline entity_id world::make_entity() { - auto id = entity_counter; + auto id = ++entity_counter; entities_bitset.set(id); - - entity_counter++; - return id; }