allocSlot.cpp 619 B

123456789101112131415161718192021222324252627
  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::allocSlot()") {
  8. DynamicMemoryPool memoryPool;
  9. SECTION("Returns different pointer") {
  10. Slot* s1 = memoryPool.allocSlot();
  11. Slot* s2 = memoryPool.allocSlot();
  12. REQUIRE(s1 != s2);
  13. }
  14. SECTION("Returns same pointer after freeSlot()") {
  15. Slot* s1 = memoryPool.allocSlot();
  16. memoryPool.freeSlot(s1);
  17. Slot* s2 = memoryPool.allocSlot();
  18. REQUIRE(s1 == s2);
  19. }
  20. }