Replacing a value now releases the memory

This commit is contained in:
Benoit Blanchon
2018-11-12 18:28:34 +01:00
parent f375459d53
commit 720e6548c7
18 changed files with 335 additions and 132 deletions

View File

@ -22,4 +22,17 @@ TEST_CASE("JsonObject::createNestedObject()") {
obj.createNestedObject(vla);
}
#endif
SECTION("releases memory from nested object") {
obj.createNestedObject(std::string("a"))
.createNestedObject(std::string("b"))
.set(std::string("c"))
.set(1);
// {"a":{"b":{"c":1}}}
REQUIRE(doc.memoryUsage() ==
3 * JSON_OBJECT_SIZE(1) + 3 * JSON_STRING_SIZE(2));
obj.createNestedObject(std::string("a"));
REQUIRE(doc.memoryUsage() == JSON_OBJECT_SIZE(1) + JSON_STRING_SIZE(2));
}
}