]> code.bitgloo.com Git - clyne/entityx.git/commitdiff
Test that components aren't reused on deleted entities.
authorAlec Thomas <alec@swapoff.org>
Mon, 30 Mar 2015 00:53:41 +0000 (11:53 +1100)
committerAlec Thomas <alec@swapoff.org>
Mon, 30 Mar 2015 00:53:41 +0000 (11:53 +1100)
See #92.

CMakeLists.txt [changed mode: 0755->0644]
entityx/Entity_test.cc

old mode 100755 (executable)
new mode 100644 (file)
index c026e6c..206acea
@@ -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.")
index 6d0dfa118ee43ff6c457c9b5485e4a9cfcda5754..7ea42315761fffbd4d865a0ec6a207f58e571fe1 100644 (file)
@@ -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<Position>(1, 2);
+  a.destroy();
+
+  Entity b = em.create();
+  Entity::Id bid = b.id();
+
+  REQUIRE(aid.index() == bid.index());
+  REQUIRE(!b.has_component<Position>());
+  b.assign<Position>(3, 4);
+}