// ArduinoJson - https://arduinojson.org // Copyright © 2014-2022, Benoit BLANCHON // MIT License #include #include TEST_CASE("JsonDocument::remove()") { DynamicJsonDocument doc(4096); SECTION("remove(int)") { doc.add(1); doc.add(2); doc.add(3); doc.remove(1); REQUIRE(doc.as() == "[1,3]"); } SECTION("remove(const char *)") { doc["a"] = 1; doc["b"] = 2; doc.remove("a"); REQUIRE(doc.as() == "{\"b\":2}"); } SECTION("remove(std::string)") { doc["a"] = 1; doc["b"] = 2; doc.remove(std::string("b")); REQUIRE(doc.as() == "{\"a\":1}"); } #ifdef HAS_VARIABLE_LENGTH_ARRAY SECTION("remove(vla)") { doc["a"] = 1; doc["b"] = 2; size_t i = 4; char vla[i]; strlcpy(vla, "b"); doc.remove(vla); REQUIRE(doc.as() == "{\"a\":1}"); } #endif }