mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
MemoryPool
calls the Allocator
directly
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user