From 0981e010eda7aa872fe2c6ee83a1e20654fa69ef Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Mon, 30 Mar 2015 11:53:41 +1100 Subject: Test that components aren't reused on deleted entities. See #92. --- CMakeLists.txt | 2 +- entityx/Entity_test.cc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) mode change 100755 => 100644 CMakeLists.txt 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); +} -- cgit v1.2.3