mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-31 19:24:48 +02:00
JsonArrayTests pass
This commit is contained in:
@@ -269,10 +269,10 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) {
|
|||||||
return sizeof(MemoryPool<VariantData>) * n;
|
return sizeof(MemoryPool<VariantData>) * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T = ArduinoJson::detail::VariantData>
|
||||||
inline size_t sizeofPool(
|
inline size_t sizeofPool(
|
||||||
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
|
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
|
||||||
using namespace ArduinoJson::detail;
|
return ArduinoJson::detail::MemoryPool<T>::slotsToBytes(n);
|
||||||
return MemoryPool<VariantData>::slotsToBytes(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t sizeofStaticStringPool(
|
inline size_t sizeofStaticStringPool(
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
#include "Allocators.hpp"
|
#include "Allocators.hpp"
|
||||||
#include "Literals.hpp"
|
#include "Literals.hpp"
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using namespace ArduinoJson::detail;
|
||||||
|
|
||||||
TEST_CASE("JsonArray::add(T)") {
|
TEST_CASE("JsonArray::add(T)") {
|
||||||
SpyingAllocator spy;
|
SpyingAllocator spy;
|
||||||
@@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") {
|
|||||||
REQUIRE(array[0].is<double>());
|
REQUIRE(array[0].is<double>());
|
||||||
REQUIRE_FALSE(array[0].is<bool>());
|
REQUIRE_FALSE(array[0].is<bool>());
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool<VariantData>()),
|
||||||
|
Allocate(sizeofPool<EightByteValue>()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,9 @@ class ResourceManager {
|
|||||||
stringPool_.clear(allocator_);
|
stringPool_.clear(allocator_);
|
||||||
variantPools_.clear(allocator_);
|
variantPools_.clear(allocator_);
|
||||||
staticStringsPools_.clear(allocator_);
|
staticStringsPools_.clear(allocator_);
|
||||||
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
||||||
|
eightBytePools_.clear(allocator_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager(const ResourceManager&) = delete;
|
ResourceManager(const ResourceManager&) = delete;
|
||||||
@@ -39,8 +42,9 @@ class ResourceManager {
|
|||||||
swap(a.stringPool_, b.stringPool_);
|
swap(a.stringPool_, b.stringPool_);
|
||||||
swap(a.variantPools_, b.variantPools_);
|
swap(a.variantPools_, b.variantPools_);
|
||||||
swap(a.staticStringsPools_, b.staticStringsPools_);
|
swap(a.staticStringsPools_, b.staticStringsPools_);
|
||||||
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
||||||
swap(a.eightBytePools_, b.eightBytePools_);
|
swap(a.eightBytePools_, b.eightBytePools_);
|
||||||
swap_(a.allocator_, b.allocator_);
|
#endif
|
||||||
swap_(a.overflowed_, b.overflowed_);
|
swap_(a.overflowed_, b.overflowed_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user