MemoryPool calls the Allocator directly

This commit is contained in:
Benoit Blanchon
2023-03-20 12:28:34 +01:00
parent 540901e219
commit 5faa3df43f
10 changed files with 131 additions and 86 deletions

View File

@ -8,22 +8,20 @@
using namespace ArduinoJson::detail;
TEST_CASE("MemoryPool::capacity()") {
char buffer[4096];
const size_t capacity = 64;
MemoryPool pool(buffer, capacity);
MemoryPool pool(capacity);
REQUIRE(capacity == pool.capacity());
}
TEST_CASE("MemoryPool::size()") {
char buffer[4096];
MemoryPool pool(buffer, sizeof(buffer));
MemoryPool pool(4096);
SECTION("Initial size is 0") {
REQUIRE(0 == pool.size());
}
SECTION("Doesn't grow when memory pool is full") {
const size_t variantCount = sizeof(buffer) / sizeof(VariantSlot);
const size_t variantCount = pool.capacity() / sizeof(VariantSlot);
for (size_t i = 0; i < variantCount; i++)
pool.allocVariant();