Files
Benoit Blanchon 18671a5f3b Replace catch with doctest
This reduces the build times by about 38%
2026-07-06 17:59:49 +02:00

32 lines
724 B
C++

// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson/Memory/ResourceManager.hpp>
#include <doctest.h>
#include "Allocators.hpp"
using namespace ArduinoJson::detail;
TEST_CASE("ResourceManager::size()") {
TimebombAllocator timebomb(0);
ResourceManager resources(&timebomb);
SUBCASE("Initial size is 0") {
REQUIRE(0 == resources.size());
}
SUBCASE("Doesn't grow when allocation of second pool fails") {
timebomb.setCountdown(1);
for (size_t i = 0; i < ARDUINOJSON_POOL_CAPACITY; i++)
resources.allocVariant();
size_t size = resources.size();
resources.allocVariant();
REQUIRE(size == resources.size());
}
}