Deprecate containsKey() in favor of doc["key"].is<T>()

See #2121
This commit is contained in:
Benoit Blanchon committed 2024-09-06 17:32:09 +02:00
1 parent dd1d96e28f
commit d92eee8736
22 files changed
+263 -269

No files matched your search

-1
View File
@@ -7,7 +7,6 @@ add_executable(JsonVariantTests
as.cpp
clear.cpp
compare.cpp
containsKey.cpp
converters.cpp
copy.cpp
is.cpp
-36
View File
@@ -1,36 +0,0 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2024, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <stdint.h>
#include <catch.hpp>
#include "Literals.hpp"
TEST_CASE("JsonVariant::containsKey()") {
JsonDocument doc;
JsonVariant var = doc.to<JsonVariant>();
SECTION("containsKey(const char*)") {
var["hello"] = "world";
REQUIRE(var.containsKey("hello") == true);
REQUIRE(var.containsKey("world") == false);
}
SECTION("containsKey(std::string)") {
var["hello"] = "world";
REQUIRE(var.containsKey("hello"_s) == true);
REQUIRE(var.containsKey("world"_s) == false);
}
SECTION("containsKey(JsonVariant)") {
var["hello"] = "world";
var["key"] = "hello";
REQUIRE(var.containsKey(doc["key"]) == true);
REQUIRE(var.containsKey(doc["foo"]) == false);
}
}
-4
View File
@@ -73,10 +73,6 @@ TEST_CASE("Unbound JsonVariant") {
CHECK_FALSE(variant["key"_s].set(1));
}
SECTION("containsKey()") {
CHECK_FALSE(variant.containsKey("hello"));
}
SECTION("remove()") {
variant.remove(0);
variant.remove("hello");