mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Decouple VariantData
from MemoryPool
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user