Merge DynamicJsonDocument with JsonDocument

This commit is contained in:
Benoit Blanchon
2023-03-20 10:49:01 +01:00
parent db9258bcd7
commit 540901e219
164 changed files with 550 additions and 666 deletions

View File

@ -7,68 +7,68 @@
TEST_CASE("JsonDocument::overflowed()") {
SECTION("returns false on a fresh object") {
DynamicJsonDocument doc(0);
JsonDocument doc(0);
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed insertion") {
DynamicJsonDocument doc(0);
JsonDocument doc(0);
doc.add(0);
CHECK(doc.overflowed() == true);
}
SECTION("returns false after successful insertion") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
doc.add(0);
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed string copy") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
doc.add(std::string("example"));
CHECK(doc.overflowed() == true);
}
SECTION("returns false after a successful string copy") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
JsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
doc.add(std::string("example"));
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed member add") {
DynamicJsonDocument doc(1);
JsonDocument doc(1);
doc["example"] = true;
CHECK(doc.overflowed() == true);
}
SECTION("returns true after a failed deserialization") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
deserializeJson(doc, "[\"example\"]");
CHECK(doc.overflowed() == true);
}
SECTION("returns false after a successful deserialization") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
JsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
deserializeJson(doc, "[\"example\"]");
CHECK(doc.overflowed() == false);
}
SECTION("returns false after clear()") {
DynamicJsonDocument doc(0);
JsonDocument doc(0);
doc.add(0);
doc.clear();
CHECK(doc.overflowed() == false);
}
SECTION("remains false after shrinkToFit()") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
doc.add(0);
doc.shrinkToFit();
CHECK(doc.overflowed() == false);
}
SECTION("remains true after shrinkToFit()") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
doc.add(0);
doc.add(0);
doc.shrinkToFit();
@ -76,7 +76,7 @@ TEST_CASE("JsonDocument::overflowed()") {
}
SECTION("return false after garbageCollect()") {
DynamicJsonDocument doc(JSON_ARRAY_SIZE(1));
JsonDocument doc(JSON_ARRAY_SIZE(1));
doc.add(0);
doc.add(0);
doc.garbageCollect();