JsonArray::remove() and JsonObject::remove() now release the memory of the variant

This commit is contained in:
Benoit Blanchon
2018-10-19 19:40:21 +02:00
parent ae089dcff7
commit d8d939660b
15 changed files with 174 additions and 37 deletions

View File

@ -0,0 +1,27 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson/Memory/DynamicMemoryPool.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("DynamicMemoryPool::allocSlot()") {
DynamicMemoryPool memoryPool;
SECTION("Returns different pointer") {
Slot* s1 = memoryPool.allocSlot();
Slot* s2 = memoryPool.allocSlot();
REQUIRE(s1 != s2);
}
SECTION("Returns same pointer after freeSlot()") {
Slot* s1 = memoryPool.allocSlot();
memoryPool.freeSlot(s1);
Slot* s2 = memoryPool.allocSlot();
REQUIRE(s1 == s2);
}
}