size.cpp 622 B

1234567891011121314151617181920212223242526272829
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2018
  3. // MIT License
  4. #include <ArduinoJson/Memory/DynamicJsonBuffer.hpp>
  5. #include <catch.hpp>
  6. using namespace ArduinoJson::Internals;
  7. TEST_CASE("DynamicJsonBuffer::size()") {
  8. DynamicJsonBuffer buffer;
  9. SECTION("Initial size is 0") {
  10. REQUIRE(0 == buffer.size());
  11. }
  12. SECTION("Increases after alloc()") {
  13. buffer.alloc(1);
  14. REQUIRE(1U <= buffer.size());
  15. buffer.alloc(1);
  16. REQUIRE(2U <= buffer.size());
  17. }
  18. SECTION("Goes back to 0 after clear()") {
  19. buffer.alloc(1);
  20. buffer.clear();
  21. REQUIRE(0 == buffer.size());
  22. }
  23. }