New tests: plane/line/topology_compression/serializer/memory_pool/ interval/format_utils/sat/ray_intersect/tri_intersect Expanded: quality_feedback/gdt/validate/interference/motion/ explode/convex_hull/distance/polygon/transaction/sdf Total test files: 162 → 172 (+10)
43 lines
949 B
C++
43 lines
949 B
C++
#include <gtest/gtest.h>
|
|
#include "vde/foundation/memory_pool.h"
|
|
|
|
using namespace vde::foundation;
|
|
|
|
struct PodObj { int a; double b; };
|
|
|
|
TEST(MemoryPoolTest, AllocateDeallocate) {
|
|
MemoryPool<PodObj> pool(64);
|
|
auto* p = pool.allocate();
|
|
ASSERT_NE(p, nullptr);
|
|
p->a = 42;
|
|
p->b = 3.14;
|
|
pool.deallocate(p);
|
|
}
|
|
|
|
TEST(MemoryPoolTest, AllocateMany) {
|
|
MemoryPool<PodObj> pool(32);
|
|
std::vector<PodObj*> ptrs;
|
|
for (int i = 0; i < 100; ++i) {
|
|
ptrs.push_back(pool.allocate());
|
|
}
|
|
for (auto* p : ptrs) {
|
|
pool.deallocate(p);
|
|
}
|
|
// Should not crash — verifies chunk expansion works
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST(MemoryPoolTest, ChunkSizeDefault) {
|
|
MemoryPool<int> pool;
|
|
auto* p = pool.allocate();
|
|
ASSERT_NE(p, nullptr);
|
|
*p = 123;
|
|
pool.deallocate(p);
|
|
}
|
|
|
|
TEST(MemoryPoolTest, DeallocateNullDoesNotCrash) {
|
|
MemoryPool<int> pool(16);
|
|
pool.deallocate(nullptr, 0);
|
|
SUCCEED();
|
|
}
|