size.cpp 467 B

12345678910111213141516171819202122
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2024, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. #include <string>
  7. TEST_CASE("JsonObjectConst::size()") {
  8. JsonDocument doc;
  9. JsonObjectConst obj = doc.to<JsonObject>();
  10. SECTION("returns 0 when empty") {
  11. REQUIRE(0 == obj.size());
  12. }
  13. SECTION("returns the number of members") {
  14. doc["hello"] = 1;
  15. doc["world"] = 2;
  16. REQUIRE(2 == obj.size());
  17. }
  18. }