Call shrinkToFit() in deserializeJson() and deserializeMsgPack()

This commit is contained in:
Benoit Blanchon
2023-07-31 17:34:17 +02:00
parent 752d01a7f1
commit 218a12ca46
14 changed files with 209 additions and 67 deletions

View File

@ -296,6 +296,7 @@ TEST_CASE("deserialize JSON object") {
Deallocate(sizeofString("b")),
Deallocate(sizeofString("c")),
Deallocate(sizeofStringBuffer()),
Reallocate(sizeofPool(), sizeofObject(2) + sizeofObject(1)),
});
}
@ -318,22 +319,17 @@ TEST_CASE("deserialize JSON object") {
SECTION("Should clear the JsonObject") {
deserializeJson(doc, "{\"hello\":\"world\"}");
spy.clearLog();
deserializeJson(doc, "{}");
JsonObject obj = doc.as<JsonObject>();
REQUIRE(doc.is<JsonObject>());
REQUIRE(obj.size() == 0);
REQUIRE(spy.log() ==
AllocatorLog{
Allocate(sizeofStringBuffer()),
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
Allocate(sizeofPool()),
Allocate(sizeofStringBuffer()),
Reallocate(sizeofStringBuffer(), sizeofString("world")),
Deallocate(sizeofPool()),
Deallocate(sizeofString("hello")),
Deallocate(sizeofString("world")),
});
REQUIRE(doc.size() == 0);
REQUIRE(spy.log() == AllocatorLog{
Deallocate(sizeofObject(1)),
Deallocate(sizeofString("hello")),
Deallocate(sizeofString("world")),
});
}
SECTION("Issue #1335") {