unbound.cpp 535 B

123456789101112131415161718192021222324252627
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2025, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. using namespace Catch::Matchers;
  7. TEST_CASE("Unbound JsonObject") {
  8. JsonObject obj;
  9. SECTION("retrieve member") {
  10. REQUIRE(obj["key"].isNull());
  11. }
  12. SECTION("add member") {
  13. obj["hello"] = "world";
  14. REQUIRE(0 == obj.size());
  15. }
  16. SECTION("serialize") {
  17. char buffer[32];
  18. serializeJson(obj, buffer, sizeof(buffer));
  19. REQUIRE_THAT(buffer, Equals("null"));
  20. }
  21. }