From 23c73b061e3c4c984935ab5aebb413d97129611f Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 31 May 2025 16:37:08 +0200 Subject: [PATCH] JsonArrayTests pass --- extras/tests/Helpers/Allocators.hpp | 4 ++-- extras/tests/JsonArray/add.cpp | 5 +++-- src/ArduinoJson/Memory/ResourceManager.hpp | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/extras/tests/Helpers/Allocators.hpp b/extras/tests/Helpers/Allocators.hpp index 6b65ad01..37684113 100644 --- a/extras/tests/Helpers/Allocators.hpp +++ b/extras/tests/Helpers/Allocators.hpp @@ -269,10 +269,10 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) { return sizeof(MemoryPool) * n; } +template inline size_t sizeofPool( ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) { - using namespace ArduinoJson::detail; - return MemoryPool::slotsToBytes(n); + return ArduinoJson::detail::MemoryPool::slotsToBytes(n); } inline size_t sizeofStaticStringPool( diff --git a/extras/tests/JsonArray/add.cpp b/extras/tests/JsonArray/add.cpp index bb64ef06..e8b09241 100644 --- a/extras/tests/JsonArray/add.cpp +++ b/extras/tests/JsonArray/add.cpp @@ -8,7 +8,7 @@ #include "Allocators.hpp" #include "Literals.hpp" -using ArduinoJson::detail::sizeofArray; +using namespace ArduinoJson::detail; TEST_CASE("JsonArray::add(T)") { SpyingAllocator spy; @@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") { REQUIRE(array[0].is()); REQUIRE_FALSE(array[0].is()); REQUIRE(spy.log() == AllocatorLog{ - Allocate(sizeofPool()), + Allocate(sizeofPool()), + Allocate(sizeofPool()), }); } diff --git a/src/ArduinoJson/Memory/ResourceManager.hpp b/src/ArduinoJson/Memory/ResourceManager.hpp index cfbec45a..4d044b9e 100644 --- a/src/ArduinoJson/Memory/ResourceManager.hpp +++ b/src/ArduinoJson/Memory/ResourceManager.hpp @@ -30,6 +30,9 @@ class ResourceManager { stringPool_.clear(allocator_); variantPools_.clear(allocator_); staticStringsPools_.clear(allocator_); +#if ARDUINOJSON_USE_8_BYTE_POOL + eightBytePools_.clear(allocator_); +#endif } ResourceManager(const ResourceManager&) = delete; @@ -39,8 +42,9 @@ class ResourceManager { swap(a.stringPool_, b.stringPool_); swap(a.variantPools_, b.variantPools_); swap(a.staticStringsPools_, b.staticStringsPools_); +#if ARDUINOJSON_USE_8_BYTE_POOL swap(a.eightBytePools_, b.eightBytePools_); - swap_(a.allocator_, b.allocator_); +#endif swap_(a.overflowed_, b.overflowed_); }