Store index of slot in the pool instead of a pointer or a distance

This commit is contained in:
Benoit Blanchon
2023-06-14 11:57:31 +02:00
parent 068c40d6ed
commit c4e5051a7a
44 changed files with 343 additions and 310 deletions

View File

@ -22,8 +22,9 @@ TEST_CASE("JsonDocument constructor") {
}
SECTION("JsonDocument(const JsonDocument&)") {
const size_t capacity = 100 * sizeof(ArduinoJson::detail::VariantSlot);
{
JsonDocument doc1(4096, &spyingAllocator);
JsonDocument doc1(capacity, &spyingAllocator);
doc1.set(std::string("The size of this string is 32!!"));
JsonDocument doc2(doc1);
@ -32,14 +33,14 @@ TEST_CASE("JsonDocument constructor") {
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
}
REQUIRE(spyingAllocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(4096)
AllocatorLog() << AllocatorLog::Allocate(capacity)
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Allocate(4096)
<< AllocatorLog::Allocate(capacity)
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31))
<< AllocatorLog::Deallocate(4096)
<< AllocatorLog::Deallocate(capacity)
<< AllocatorLog::Deallocate(sizeofString(31))
<< AllocatorLog::Deallocate(4096));
<< AllocatorLog::Deallocate(capacity));
}
SECTION("JsonDocument(JsonDocument&&)") {