mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 12:02:14 +02:00
36 lines
905 B
C++
36 lines
905 B
C++
// ArduinoJson - https://arduinojson.org
|
|
// Copyright © 2014-2023, Benoit BLANCHON
|
|
// MIT License
|
|
|
|
#include <ArduinoJson/Memory/ResourceManager.hpp>
|
|
#include <ArduinoJson/Memory/VariantPoolImpl.hpp>
|
|
#include <catch.hpp>
|
|
|
|
using namespace ArduinoJson::detail;
|
|
|
|
TEST_CASE("ResourceManager::capacity()") {
|
|
const size_t capacity = 4 * sizeof(VariantSlot);
|
|
ResourceManager resources(capacity);
|
|
REQUIRE(capacity == resources.capacity());
|
|
}
|
|
|
|
TEST_CASE("ResourceManager::size()") {
|
|
ResourceManager resources(4096);
|
|
|
|
SECTION("Initial size is 0") {
|
|
REQUIRE(0 == resources.size());
|
|
}
|
|
|
|
SECTION("Doesn't grow when memory pool is full") {
|
|
const size_t variantCount = resources.capacity() / sizeof(VariantSlot);
|
|
|
|
for (size_t i = 0; i < variantCount; i++)
|
|
resources.allocSlot();
|
|
size_t size = resources.size();
|
|
|
|
resources.allocSlot();
|
|
|
|
REQUIRE(size == resources.size());
|
|
}
|
|
}
|