size.cpp 657 B

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