Core/MemoryPool: Add iterator

This commit is contained in:
Jérôme Leclercq
2022-02-21 20:45:25 +01:00
parent cc0fc53bd3
commit ad544a595d
3 changed files with 217 additions and 14 deletions

View File

@@ -97,6 +97,23 @@ SCENARIO("MemoryPool", "[CORE][MEMORYPOOL]")
CHECK(*vector1 == Nz::Vector2<int>(3, 2));
CHECK(*vector2 == Nz::Vector2<int>(3, 5));
CHECK(vector3->GetSquaredLength() == Approx(61.f));
AND_THEN("We iterate on the memory pool")
{
std::size_t count = 0;
int sumX = 0;
int sumY = 0;
for (T& vec : memoryPool)
{
count++;
sumX += vec.x;
sumY += vec.y;
}
CHECK(count == 3);
CHECK(sumX == 11);
CHECK(sumY == 13);
}
}
memoryPool.Reset();
@@ -105,6 +122,12 @@ SCENARIO("MemoryPool", "[CORE][MEMORYPOOL]")
CHECK(memoryPool.GetBlockCount() == 2);
CHECK(memoryPool.GetFreeEntryCount() == 4);
bool failure = false;
for (T& vec : memoryPool)
failure = true;
CHECK_FALSE(failure);
memoryPool.Clear();
CHECK(allocationCount == 0);
CHECK(memoryPool.GetAllocatedEntryCount() == 0);