feat(mempool): add MemPool

This commit is contained in:
fallenoak 2023-01-01 22:50:45 -06:00 committed by GitHub
parent 90246804d0
commit 33be859acd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 218 additions and 0 deletions

36
test/MemPool.cpp Normal file
View file

@ -0,0 +1,36 @@
#include "common/MemPool.hpp"
#include "test/Test.hpp"
TEST_CASE("MemPool::MemPool", "[mempool]") {
SECTION("constructs new mem pool") {
MemPool pool;
SUCCEED();
}
}
TEST_CASE("MemPool::Init", "[mempool]") {
SECTION("inits mem pool") {
MemPool pool;
pool.Init(16, 16 << 10);
SUCCEED();
}
}
TEST_CASE("MemPool::MemAlloc", "[mempool]") {
SECTION("allocates pointer to new free memory") {
MemPool pool;
pool.Init(16, 16 << 10);
auto ptr = pool.MemAlloc();
REQUIRE(ptr);
}
}
TEST_CASE("MemPool::MemFree", "[mempool]") {
SECTION("frees allocated pointer") {
MemPool pool;
pool.Init(16, 16 << 10);
auto ptr = pool.MemAlloc();
pool.MemFree(ptr);
SUCCEED();
}
}