Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix unit tests, TestKeyObserver needs to be removed from the entity n…
…ode before it is destroyed
  • Loading branch information
codereader committed Nov 27, 2021
1 parent 91f58de commit a9ed8c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/Entity.cpp
Expand Up @@ -1615,6 +1615,7 @@ TEST_F(EntityTest, EntityNodeAttachKeyObserver)
entityNode->addKeyObserver(TEST_KEY, observer);
EXPECT_EQ(observer.invocationCount, 1);
EXPECT_EQ(observer.receivedValue, "");
entityNode->removeKeyObserver(TEST_KEY, observer);
}

{
Expand All @@ -1626,6 +1627,7 @@ TEST_F(EntityTest, EntityNodeAttachKeyObserver)
entityNode->addKeyObserver(TEST_KEY, observer);
EXPECT_EQ(observer.invocationCount, 1);
EXPECT_EQ(observer.receivedValue, "Blah");
entityNode->removeKeyObserver(TEST_KEY, observer);
}

// Destroying the entity node should not crash
Expand Down Expand Up @@ -1664,6 +1666,8 @@ TEST_F(EntityTest, EntityNodeObserveKeyChange)
entityNode->getEntity().setKeyValue("another", "Something");
EXPECT_EQ(observer.invocationCount, 4);
EXPECT_EQ(observer.receivedValue, "Foobar");

entityNode->removeKeyObserver(TEST_KEY, observer);
}

TEST_F(EntityTest, EntityNodeObserveKeyViaFunc)
Expand Down

0 comments on commit a9ed8c3

Please sign in to comment.