2021-03-29 17:14:01 +02:00
|
|
|
// ArduinoJson - https://arduinojson.org
|
2024-01-03 08:47:06 +01:00
|
|
|
// Copyright © 2014-2024, Benoit BLANCHON
|
2019-03-22 09:00:00 +01:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
2024-06-07 09:35:45 +02:00
|
|
|
#include "Literals.hpp"
|
|
|
|
|
2019-03-22 09:00:00 +01:00
|
|
|
TEST_CASE("JsonVariant::containsKey()") {
|
2023-07-17 18:15:13 +02:00
|
|
|
JsonDocument doc;
|
2019-03-22 09:00:00 +01:00
|
|
|
JsonVariant var = doc.to<JsonVariant>();
|
|
|
|
|
2022-04-27 15:06:58 +02:00
|
|
|
SECTION("containsKey(const char*)") {
|
2019-03-22 09:00:00 +01:00
|
|
|
var["hello"] = "world";
|
|
|
|
|
|
|
|
REQUIRE(var.containsKey("hello") == true);
|
|
|
|
REQUIRE(var.containsKey("world") == false);
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:06:58 +02:00
|
|
|
SECTION("containsKey(std::string)") {
|
2019-03-22 09:00:00 +01:00
|
|
|
var["hello"] = "world";
|
|
|
|
|
2024-06-07 09:35:45 +02:00
|
|
|
REQUIRE(var.containsKey("hello"_s) == true);
|
|
|
|
REQUIRE(var.containsKey("world"_s) == false);
|
2019-03-22 09:00:00 +01:00
|
|
|
}
|
2024-05-14 21:06:02 +02:00
|
|
|
|
|
|
|
SECTION("containsKey(JsonVariant)") {
|
|
|
|
var["hello"] = "world";
|
|
|
|
var["key"] = "hello";
|
|
|
|
|
|
|
|
REQUIRE(var.containsKey(doc["key"]) == true);
|
|
|
|
REQUIRE(var.containsKey(doc["foo"]) == false);
|
|
|
|
}
|
2019-03-22 09:00:00 +01:00
|
|
|
}
|