Fix Invalid slotkey access when a slot is exhausted
All checks were successful
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m46s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m38s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m52s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m54s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m58s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m57s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m57s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m51s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m30s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m35s
Bigfoot / Clang Format Checks (push) Successful in 12s
All checks were successful
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m46s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m38s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m52s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m54s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m58s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m57s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m57s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m51s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m30s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m35s
Bigfoot / Clang Format Checks (push) Successful in 12s
This commit is contained in:
@@ -154,6 +154,33 @@ TEST_F(SlotMapFixture, Remove_ShouldNotRecycleASlotWhenVersionWasExhausted)
|
||||
// Dead slot must not be recycled; a new insert must allocate a fresh slot index
|
||||
const auto newKey = m_slotMap.Insert(2);
|
||||
EXPECT_NE(newKey.Index(), key.Index());
|
||||
|
||||
// Ensure an invalid key does not return an exhausted slot
|
||||
EXPECT_EQ(m_slotMap.Get(SlotMap<std::uint32_t, SlotMapVersion, SlotMapIndex>::SlotKey {}), nullptr);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SlotMapFixture, Remove_ShouldNotDoAnythingInCaseOfDoubleRemove)
|
||||
{
|
||||
const auto slotKey1 = m_slotMap.Insert(42);
|
||||
const auto slotKey2 = m_slotMap.Insert(69);
|
||||
|
||||
m_slotMap.Remove(slotKey1);
|
||||
m_slotMap.Remove(slotKey1);
|
||||
|
||||
EXPECT_EQ(*m_slotMap.Get(slotKey2), 69);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SlotMapFixture, Remove_ShouldNotDoAnythingInCaseStaleKey)
|
||||
{
|
||||
const auto slotKey1 = m_slotMap.Insert(42);
|
||||
|
||||
m_slotMap.Remove(SlotMap<std::uint32_t, SlotMapVersion, SlotMapIndex>::SlotKey {2, 0});
|
||||
|
||||
EXPECT_EQ(*m_slotMap.Get(slotKey1), 42);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user