Files
茂之钳 4eb4f00c57
Build & Test / build-and-test (push) Has been cancelled
VDE Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
test: max coverage — 10 new + 11 expanded test files, 140+ cases
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)
2026-08-02 16:32:36 +08:00

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();
}