Skip to content

Commit 9ec166f

Browse files
committed
Add assertion messages to concurrent memory tests
1 parent ac0bfbf commit 9ec166f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

tests/FoundationsTests/MemoryConcurrentTests.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ UTEST(MemoryConcurrent, Push)
101101

102102
// Assert
103103
auto allocationInfos = SystemGetMemoryArenaAllocationInfos(memoryArena);
104-
ASSERT_EQ(maxSize, allocationInfos.AllocatedBytes);
104+
ASSERT_EQ_MSG(maxSize, allocationInfos.AllocatedBytes, "Concurrent MemoryArena pushes should reserve every requested byte exactly once.");
105105
}
106106

107107
UTEST(MemoryConcurrent, PushDoesNotOverflow)
@@ -144,16 +144,16 @@ UTEST(MemoryConcurrent, PushDoesNotOverflow)
144144
{
145145
if (results[j] != nullptr)
146146
{
147-
ASSERT_TRUE(results[i] != results[j]);
147+
ASSERT_TRUE_MSG(results[i] != results[j], "Concurrent MemoryArena pushes must never return the same allocation address twice.");
148148
}
149149
}
150150
}
151151
}
152152

153-
ASSERT_EQ(capacityCount, successCount);
153+
ASSERT_EQ_MSG(capacityCount, successCount, "Concurrent MemoryArena pushes should stop exactly at arena capacity.");
154154

155155
auto allocationInfos = SystemGetMemoryArenaAllocationInfos(memoryArena);
156-
ASSERT_EQ(capacityCount * allocationSizeInBytes, allocationInfos.AllocatedBytes);
156+
ASSERT_EQ_MSG(capacityCount * allocationSizeInBytes, allocationInfos.AllocatedBytes, "Concurrent overflow attempts must not advance the MemoryArena beyond capacity.");
157157
}
158158

159159
UTEST(MemoryConcurrent, CommitSharedPage)
@@ -183,13 +183,13 @@ UTEST(MemoryConcurrent, CommitSharedPage)
183183

184184
// Assert
185185
auto allocationInfos = SystemGetMemoryArenaAllocationInfos(memoryArena);
186-
ASSERT_EQ(committedBytesBefore + pageSizeInBytes, allocationInfos.CommittedBytes);
186+
ASSERT_EQ_MSG(committedBytesBefore + pageSizeInBytes, allocationInfos.CommittedBytes, "Concurrent commits within one data page should commit that page exactly once.");
187187

188188
for (int32_t i = 0; i < threadCount; i++)
189189
{
190190
for (size_t j = 0; j < rangeSizeInBytes; j++)
191191
{
192-
ASSERT_EQ((uint8_t)(i + 1), buffer[i * rangeSizeInBytes + j]);
192+
ASSERT_EQ_MSG((uint8_t)(i + 1), buffer[i * rangeSizeInBytes + j], "Concurrent shared-page commits should preserve each thread's written range.");
193193
}
194194
}
195195
}
@@ -220,19 +220,19 @@ UTEST(MemoryConcurrent, ArenaAllocationAccounting)
220220
// Assert
221221
for (int32_t i = 0; i < threadCount; i++)
222222
{
223-
ASSERT_TRUE(memoryArenas[i].Storage != nullptr);
223+
ASSERT_TRUE_MSG(memoryArenas[i].Storage != nullptr, "Concurrent MemoryArena creation should return valid storage for every thread.");
224224
}
225225

226226
auto allocationInfosAfterAllocate = SystemGetAllocationInfos();
227-
ASSERT_EQ(allocationInfosBefore.ReservedBytes + threadCount * pageSizeInBytes * 2, allocationInfosAfterAllocate.ReservedBytes);
228-
ASSERT_EQ(allocationInfosBefore.CommittedBytes + threadCount * pageSizeInBytes, allocationInfosAfterAllocate.CommittedBytes);
227+
ASSERT_EQ_MSG(allocationInfosBefore.ReservedBytes + threadCount * pageSizeInBytes * 2, allocationInfosAfterAllocate.ReservedBytes, "Concurrent MemoryArena creation should update reserved-byte accounting exactly once per arena.");
228+
ASSERT_EQ_MSG(allocationInfosBefore.CommittedBytes + threadCount * pageSizeInBytes, allocationInfosAfterAllocate.CommittedBytes, "Concurrent MemoryArena creation should account for each committed header exactly once.");
229229

230230
for (int32_t i = 0; i < threadCount; i++)
231231
{
232232
SystemFreeMemoryArena(memoryArenas[i]);
233233
}
234234

235235
auto allocationInfosAfterFree = SystemGetAllocationInfos();
236-
ASSERT_EQ(allocationInfosBefore.ReservedBytes, allocationInfosAfterFree.ReservedBytes);
237-
ASSERT_EQ(allocationInfosBefore.CommittedBytes, allocationInfosAfterFree.CommittedBytes);
236+
ASSERT_EQ_MSG(allocationInfosBefore.ReservedBytes, allocationInfosAfterFree.ReservedBytes, "Freeing concurrently created arenas should restore reserved-byte accounting to the baseline.");
237+
ASSERT_EQ_MSG(allocationInfosBefore.CommittedBytes, allocationInfosAfterFree.CommittedBytes, "Freeing concurrently created arenas should restore committed-byte accounting to the baseline.");
238238
}

0 commit comments

Comments
 (0)