Update to ArduinoJson 7.0.4

This commit is contained in:
iranl
2024-04-19 14:44:01 +02:00
parent 1378732081
commit 81be0a689a
444 changed files with 10842 additions and 9422 deletions

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2023, Benoit BLANCHON
// Copyright © 2014-2024, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
@@ -12,7 +12,7 @@ static void eraseString(std::string& str) {
}
TEST_CASE("std::string") {
DynamicJsonDocument doc(4096);
JsonDocument doc;
SECTION("operator[]") {
char json[] = "{\"key\":\"value\"}";
@@ -32,26 +32,6 @@ TEST_CASE("std::string") {
REQUIRE(std::string("value") == obj[std::string("key")]);
}
SECTION("createNestedObject()") {
JsonObject obj = doc.to<JsonObject>();
std::string key = "key";
char json[64];
obj.createNestedObject(key);
eraseString(key);
serializeJson(doc, json, sizeof(json));
REQUIRE(std::string("{\"key\":{}}") == json);
}
SECTION("createNestedArray()") {
JsonObject obj = doc.to<JsonObject>();
std::string key = "key";
char json[64];
obj.createNestedArray(key);
eraseString(key);
serializeJson(doc, json, sizeof(json));
REQUIRE(std::string("{\"key\":[]}") == json);
}
SECTION("containsKey()") {
char json[] = "{\"key\":\"value\"}";
deserializeJson(doc, json);
@@ -83,28 +63,4 @@ TEST_CASE("std::string") {
eraseString(value);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("memoryUsage() increases when adding a new key") {
std::string key1("hello"), key2("world");
JsonObject obj = doc.to<JsonObject>();
obj[key1] = 1;
size_t sizeBefore = doc.memoryUsage();
obj[key2] = 2;
size_t sizeAfter = doc.memoryUsage();
REQUIRE(sizeAfter - sizeBefore >= key2.size());
}
SECTION("memoryUsage() remains when adding the same key") {
std::string key("hello");
JsonObject obj = doc.to<JsonObject>();
obj[key] = 1;
size_t sizeBefore = doc.memoryUsage();
obj[key] = 2;
size_t sizeAfter = doc.memoryUsage();
REQUIRE(sizeBefore == sizeAfter);
}
}