From: Alec Thomas Date: Mon, 30 Mar 2015 00:53:41 +0000 (+1100) Subject: Test that components aren't reused on deleted entities. X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=0981e010eda7aa872fe2c6ee83a1e20654fa69ef;p=clyne%2Fentityx.git Test that components aren't reused on deleted entities. See #92. --- diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 index c026e6c..206acea --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(ENTITYX_VERSION ${ENTITYX_MAJOR_VERSION}.${ENTITYX_MINOR_VERSION}.${ENTITYX_ include_directories(${CMAKE_CURRENT_LIST_DIR}) -set(ENTITYX_BUILD_TESTING false CACHE BOOL "Enable building of tests.") +set(ENTITYX_BUILD_TESTING true CACHE BOOL "Enable building of tests.") set(ENTITYX_RUN_BENCHMARKS false CACHE BOOL "Run benchmarks (in conjunction with -DENTITYX_BUILD_TESTING=1).") set(ENTITYX_MAX_COMPONENTS 64 CACHE STRING "Set the maximum number of components.") set(ENTITYX_DT_TYPE double CACHE STRING "The type used for delta time in EntityX update methods.") diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 6d0dfa1..7ea4231 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -578,3 +578,17 @@ TEST_CASE("TestComponentDestructorCalledWhenEntityDestroyed") { test.destroy(); REQUIRE(freed == true); } + +TEST_CASE_METHOD(EntityManagerFixture, "TestComponentsRemovedFromReusedEntities") { + Entity a = em.create(); + Entity::Id aid = a.id(); + a.assign(1, 2); + a.destroy(); + + Entity b = em.create(); + Entity::Id bid = b.id(); + + REQUIRE(aid.index() == bid.index()); + REQUIRE(!b.has_component()); + b.assign(3, 4); +}