mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Added StaticJsonDocument::garbageCollect()
This commit is contained in:
@ -209,4 +209,16 @@ TEST_CASE("StaticJsonDocument") {
|
||||
REQUIRE_JSON(doc2, "42");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("garbageCollect()") {
|
||||
StaticJsonDocument<256> doc;
|
||||
doc[std::string("example")] = std::string("example");
|
||||
doc.remove("example");
|
||||
REQUIRE(doc.memoryUsage() == JSON_OBJECT_SIZE(1) + 16);
|
||||
|
||||
doc.garbageCollect();
|
||||
|
||||
REQUIRE(doc.memoryUsage() == JSON_OBJECT_SIZE(0));
|
||||
REQUIRE_JSON(doc, "{}");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user