mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
feat(mempool): add MemPool
This commit is contained in:
parent
90246804d0
commit
33be859acd
7 changed files with 218 additions and 0 deletions
36
test/MemPool.cpp
Normal file
36
test/MemPool.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue