containsKey.cpp 695 B

12345678910111213141516171819202122232425262728
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <stdint.h>
  6. #include <catch.hpp>
  7. static const char* null = 0;
  8. TEST_CASE("JsonVariant::containsKey()") {
  9. DynamicJsonDocument doc(4096);
  10. JsonVariant var = doc.to<JsonVariant>();
  11. SECTION("containsKey(const char*) returns true") {
  12. var["hello"] = "world";
  13. REQUIRE(var.containsKey("hello") == true);
  14. REQUIRE(var.containsKey("world") == false);
  15. }
  16. SECTION("containsKey(std::string) returns true") {
  17. var["hello"] = "world";
  18. REQUIRE(var.containsKey(std::string("hello")) == true);
  19. REQUIRE(var.containsKey(std::string("world")) == false);
  20. }
  21. }