mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-24 07:47:32 +02:00
Create more memory pools as needed (resolves #1074)
This commit is contained in:
@ -6,25 +6,21 @@
|
||||
#include <ArduinoJson/Memory/VariantPoolImpl.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Allocators.hpp"
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
TEST_CASE("ResourceManager::capacity()") {
|
||||
const size_t capacity = 4 * sizeof(VariantSlot);
|
||||
ResourceManager resources(capacity);
|
||||
REQUIRE(capacity == resources.capacity());
|
||||
}
|
||||
|
||||
TEST_CASE("ResourceManager::size()") {
|
||||
ResourceManager resources(4096);
|
||||
TimebombAllocator allocator(0);
|
||||
ResourceManager resources(4096, &allocator);
|
||||
|
||||
SECTION("Initial size is 0") {
|
||||
REQUIRE(0 == resources.size());
|
||||
}
|
||||
|
||||
SECTION("Doesn't grow when memory pool is full") {
|
||||
const size_t variantCount = resources.capacity() / sizeof(VariantSlot);
|
||||
|
||||
for (size_t i = 0; i < variantCount; i++)
|
||||
SECTION("Doesn't grow when allocation of second pool fails") {
|
||||
allocator.setCountdown(2);
|
||||
for (size_t i = 0; i < ARDUINOJSON_POOL_CAPACITY; i++)
|
||||
resources.allocSlot();
|
||||
size_t size = resources.size();
|
||||
|
||||
|
Reference in New Issue
Block a user