size.cpp 528 B

1234567891011121314151617181920212223
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2023
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. #include <string>
  7. TEST_CASE("JsonObject::size()") {
  8. DynamicJsonBuffer jb;
  9. JsonObject& _object = jb.createObject();
  10. SECTION("increases when values are added") {
  11. _object.set("hello", 42);
  12. REQUIRE(1 == _object.size());
  13. }
  14. SECTION("doesn't increase when the smae key is added twice") {
  15. _object["hello"] = 1;
  16. _object["hello"] = 2;
  17. REQUIRE(1 == _object.size());
  18. }
  19. }