DynamicJsonBuffer_Object_Tests.cpp 635 B

12345678910111213141516171819202122232425
  1. // Copyright Benoit Blanchon 2014-2017
  2. // MIT License
  3. //
  4. // Arduino JSON library
  5. // https://github.com/bblanchon/ArduinoJson
  6. // If you like this project, please add a star!
  7. #include <ArduinoJson.h>
  8. #include <gtest/gtest.h>
  9. TEST(DynamicJsonBuffer_Object_Tests, GrowsWithObject) {
  10. DynamicJsonBuffer json;
  11. JsonObject &obj = json.createObject();
  12. ASSERT_EQ(JSON_OBJECT_SIZE(0), json.size());
  13. obj["hello"] = 1;
  14. ASSERT_EQ(JSON_OBJECT_SIZE(1), json.size());
  15. obj["world"] = 2;
  16. ASSERT_EQ(JSON_OBJECT_SIZE(2), json.size());
  17. obj["world"] = 3; // <- same key, should not grow
  18. ASSERT_EQ(JSON_OBJECT_SIZE(2), json.size());
  19. }