Decouple VariantData from MemoryPool

This commit is contained in:
Benoit Blanchon
2023-04-17 10:41:37 +02:00
parent 30c111fd3d
commit b7c8e0d25c
17 changed files with 395 additions and 266 deletions

View File

@ -10,6 +10,8 @@
#include <catch.hpp>
#include "Allocators.hpp"
using ArduinoJson::detail::sizeofArray;
using ArduinoJson::detail::sizeofObject;
using ArduinoJson::detail::sizeofString;
@ -388,3 +390,19 @@ TEST_CASE("Deduplicate keys") {
CHECK(key1 == key2);
}
}
TEST_CASE("MemberProxy under memory constraints") {
ControllableAllocator allocator;
JsonDocument doc(4096, &allocator);
SECTION("key allocation fails") {
allocator.disable();
doc[std::string("hello")] = "world";
REQUIRE(doc.is<JsonObject>());
REQUIRE(doc.size() == 0);
REQUIRE(doc.memoryUsage() == sizeofObject(1));
REQUIRE(doc.overflowed() == true);
}
}