Files
ArduinoJson/extras/tests/ResourceManager/clear.cpp
T

31 lines
726 B
C++
Raw Normal View History

// ArduinoJson - https://arduinojson.org
2023-02-16 11:45:01 +01:00
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
2023-06-17 16:10:56 +02:00
#include <ArduinoJson/Memory/ResourceManager.hpp>
2023-06-17 16:24:12 +02:00
#include <ArduinoJson/Memory/VariantPoolImpl.hpp>
2020-07-21 20:15:31 +02:00
#include <ArduinoJson/Strings/StringAdapters.hpp>
#include <catch.hpp>
using namespace ArduinoJson::detail;
2023-06-17 16:10:56 +02:00
TEST_CASE("ResourceManager::clear()") {
ResourceManager resources;
SECTION("Discards allocated variants") {
resources.allocSlot();
2023-06-17 16:10:56 +02:00
resources.clear();
REQUIRE(resources.size() == 0);
}
SECTION("Discards allocated strings") {
2023-06-17 16:10:56 +02:00
resources.saveString(adaptString("123456789"));
REQUIRE(resources.size() == sizeofString(9));
2023-06-17 16:10:56 +02:00
resources.clear();
2023-06-17 16:10:56 +02:00
REQUIRE(resources.size() == 0);
}
}