Skip to content

Commit 23c73b0

Browse files
committed
JsonArrayTests pass
1 parent c2e756d commit 23c73b0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

extras/tests/Helpers/Allocators.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) {
269269
return sizeof(MemoryPool<VariantData>) * n;
270270
}
271271

272+
template <typename T = ArduinoJson::detail::VariantData>
272273
inline size_t sizeofPool(
273274
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
274-
using namespace ArduinoJson::detail;
275-
return MemoryPool<VariantData>::slotsToBytes(n);
275+
return ArduinoJson::detail::MemoryPool<T>::slotsToBytes(n);
276276
}
277277

278278
inline size_t sizeofStaticStringPool(

extras/tests/JsonArray/add.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "Allocators.hpp"
99
#include "Literals.hpp"
1010

11-
using ArduinoJson::detail::sizeofArray;
11+
using namespace ArduinoJson::detail;
1212

1313
TEST_CASE("JsonArray::add(T)") {
1414
SpyingAllocator spy;
@@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") {
3333
REQUIRE(array[0].is<double>());
3434
REQUIRE_FALSE(array[0].is<bool>());
3535
REQUIRE(spy.log() == AllocatorLog{
36-
Allocate(sizeofPool()),
36+
Allocate(sizeofPool<VariantData>()),
37+
Allocate(sizeofPool<EightByteValue>()),
3738
});
3839
}
3940

src/ArduinoJson/Memory/ResourceManager.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class ResourceManager {
3030
stringPool_.clear(allocator_);
3131
variantPools_.clear(allocator_);
3232
staticStringsPools_.clear(allocator_);
33+
#if ARDUINOJSON_USE_8_BYTE_POOL
34+
eightBytePools_.clear(allocator_);
35+
#endif
3336
}
3437

3538
ResourceManager(const ResourceManager&) = delete;
@@ -39,8 +42,9 @@ class ResourceManager {
3942
swap(a.stringPool_, b.stringPool_);
4043
swap(a.variantPools_, b.variantPools_);
4144
swap(a.staticStringsPools_, b.staticStringsPools_);
45+
#if ARDUINOJSON_USE_8_BYTE_POOL
4246
swap(a.eightBytePools_, b.eightBytePools_);
43-
swap_(a.allocator_, b.allocator_);
47+
#endif
4448
swap_(a.overflowed_, b.overflowed_);
4549
}
4650

0 commit comments

Comments
 (0)