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

This commit is contained in:
2026-05-15 23:24:00 +02:00
parent 09ff240423
commit acdbfb505e
2 changed files with 31 additions and 3 deletions

View File

@@ -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);
}
/****************************************************************************************/