mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-22 23:07:29 +02:00
Rename MemoryPool
to ResourceManager
This commit is contained in:
32
extras/tests/ResourceManager/clear.cpp
Normal file
32
extras/tests/ResourceManager/clear.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Memory/ResourceManager.hpp>
|
||||
#include <ArduinoJson/Strings/StringAdapters.hpp>
|
||||
#include <ArduinoJson/Variant/VariantSlot.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
static const size_t poolCapacity = 512;
|
||||
|
||||
TEST_CASE("ResourceManager::clear()") {
|
||||
ResourceManager resources(poolCapacity);
|
||||
|
||||
SECTION("Discards allocated variants") {
|
||||
new (&resources) VariantSlot();
|
||||
|
||||
resources.clear();
|
||||
REQUIRE(resources.size() == 0);
|
||||
}
|
||||
|
||||
SECTION("Discards allocated strings") {
|
||||
resources.saveString(adaptString("123456789"));
|
||||
REQUIRE(resources.size() == sizeofString(9));
|
||||
|
||||
resources.clear();
|
||||
|
||||
REQUIRE(resources.size() == 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user