diff options
author | Lars Pensjö <lars.pensjo@gmail.com> | 2013-03-02 15:23:10 +0100 |
---|---|---|
committer | Lars Pensjö <lars.pensjo@gmail.com> | 2013-03-02 15:23:10 +0100 |
commit | 86f4b35e96b0999a164450d569f591b95cd6be20 (patch) | |
tree | bc868891c1755cd73f0082713a21f8080fdfc63b | |
parent | 87785361dc273e8ae8ed14cc6d55a81ba9c647af (diff) |
Add test for reusing an Entity.
This will lead to a crash.
-rw-r--r-- | entityx/Entity_test.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 67026e8..3fa6548 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -75,8 +75,19 @@ class EntityManagerTest : public ::testing::Test { TEST_F(EntityManagerTest, TestCreateEntity) { + ASSERT_TRUE(em.size() == 0); Entity e = em.create(); ASSERT_TRUE(em.exists(e)); + ASSERT_TRUE(em.size() == 1); +} + +TEST_F(EntityManagerTest, TestEntityReuse) { + Entity e1 = em.create(); + auto id = e1.id(); + em.destroy(e1); + ASSERT_TRUE(!em.exists(e1)); + Entity e2 = em.create(); + ASSERT_EQ(e2.id(), id); } TEST_F(EntityManagerTest, TestComponentConstruction) { |