containsKey.cpp 638 B

1234567891011121314151617181920212223242526
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2024, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <stdint.h>
  6. #include <catch.hpp>
  7. TEST_CASE("JsonVariant::containsKey()") {
  8. JsonDocument doc;
  9. JsonVariant var = doc.to<JsonVariant>();
  10. SECTION("containsKey(const char*)") {
  11. var["hello"] = "world";
  12. REQUIRE(var.containsKey("hello") == true);
  13. REQUIRE(var.containsKey("world") == false);
  14. }
  15. SECTION("containsKey(std::string)") {
  16. var["hello"] = "world";
  17. REQUIRE(var.containsKey(std::string("hello")) == true);
  18. REQUIRE(var.containsKey(std::string("world")) == false);
  19. }
  20. }