containsKey.cpp 714 B

123456789101112131415161718192021222324252627282930
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2023
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. TEST_CASE("JsonObject::containsKey()") {
  7. DynamicJsonBuffer _jsonBuffer;
  8. JsonObject& _object = _jsonBuffer.createObject();
  9. SECTION("ContainsKeyReturnsFalseForNonExistingKey") {
  10. _object.set("hello", 42);
  11. REQUIRE(false == _object.containsKey("world"));
  12. }
  13. SECTION("ContainsKeyReturnsTrueForDefinedValue") {
  14. _object.set("hello", 42);
  15. REQUIRE(true == _object.containsKey("hello"));
  16. }
  17. SECTION("ContainsKeyReturnsFalseAfterRemove") {
  18. _object.set("hello", 42);
  19. _object.remove("hello");
  20. REQUIRE(false == _object.containsKey("hello"));
  21. }
  22. }