Clear the JsonObject or JsonArray in deserializeJson()

This commit is contained in:
Benoit Blanchon
2018-03-18 14:50:52 +01:00
parent cf149940ed
commit 0d1623edef
15 changed files with 126 additions and 9 deletions

View File

@ -76,4 +76,15 @@ TEST_CASE("deserializeJson(StaticJsonArray&)") {
// note: we use a string of 8 bytes to be sure that the StaticJsonBuffer
// will not insert bytes to enforce alignement
}
SECTION("Should clear the JsonArray") {
StaticJsonArray<JSON_ARRAY_SIZE(4)> arr;
char input[] = "[1,2,3,4]";
deserializeJson(arr, input);
deserializeJson(arr, "[]");
REQUIRE(arr.size() == 0);
REQUIRE(arr.memoryUsage() == JSON_ARRAY_SIZE(0));
}
}