mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Remove capacity from JsonDocument
's constructor
This commit is contained in:
@ -12,7 +12,7 @@ using namespace ArduinoJson::detail;
|
||||
TEST_CASE("StringBuilder") {
|
||||
ControllableAllocator controllableAllocator;
|
||||
SpyingAllocator spyingAllocator(&controllableAllocator);
|
||||
ResourceManager resources(0, &spyingAllocator);
|
||||
ResourceManager resources(&spyingAllocator);
|
||||
|
||||
SECTION("Empty string") {
|
||||
StringBuilder str(&resources);
|
||||
@ -101,7 +101,7 @@ static StringNode* addStringToPool(ResourceManager& resources, const char* s) {
|
||||
}
|
||||
|
||||
TEST_CASE("StringBuilder::save() deduplicates strings") {
|
||||
ResourceManager resources(4096);
|
||||
ResourceManager resources;
|
||||
|
||||
SECTION("Basic") {
|
||||
auto s1 = addStringToPool(resources, "hello");
|
||||
|
@ -13,7 +13,7 @@ using namespace ArduinoJson::detail;
|
||||
|
||||
TEST_CASE("ResourceManager::allocSlot()") {
|
||||
SECTION("Returns different pointer") {
|
||||
ResourceManager resources(4096);
|
||||
ResourceManager resources;
|
||||
|
||||
VariantSlot* s1 = resources.allocSlot();
|
||||
REQUIRE(s1 != 0);
|
||||
@ -24,14 +24,14 @@ TEST_CASE("ResourceManager::allocSlot()") {
|
||||
}
|
||||
|
||||
SECTION("Returns aligned pointers") {
|
||||
ResourceManager resources(4096);
|
||||
ResourceManager resources;
|
||||
|
||||
REQUIRE(isAligned(resources.allocSlot().operator VariantSlot*()));
|
||||
REQUIRE(isAligned(resources.allocSlot().operator VariantSlot*()));
|
||||
}
|
||||
|
||||
SECTION("Returns null if pool list allocation fails") {
|
||||
ResourceManager resources(4096, FailingAllocator::instance());
|
||||
ResourceManager resources(FailingAllocator::instance());
|
||||
|
||||
auto variant = resources.allocSlot();
|
||||
REQUIRE(variant.id() == NULL_SLOT);
|
||||
@ -40,7 +40,7 @@ TEST_CASE("ResourceManager::allocSlot()") {
|
||||
|
||||
SECTION("Returns null if pool allocation fails") {
|
||||
TimebombAllocator allocator(1);
|
||||
ResourceManager resources(4096, &allocator);
|
||||
ResourceManager resources(&allocator);
|
||||
|
||||
resources.allocSlot();
|
||||
|
||||
|
@ -9,10 +9,8 @@
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
static const size_t poolCapacity = 512;
|
||||
|
||||
TEST_CASE("ResourceManager::clear()") {
|
||||
ResourceManager resources(poolCapacity);
|
||||
ResourceManager resources;
|
||||
|
||||
SECTION("Discards allocated variants") {
|
||||
resources.allocSlot();
|
||||
|
@ -20,7 +20,7 @@ static StringNode* saveString(ResourceManager& resources, const char* s,
|
||||
}
|
||||
|
||||
TEST_CASE("ResourceManager::saveString()") {
|
||||
ResourceManager resources(32);
|
||||
ResourceManager resources;
|
||||
|
||||
SECTION("Duplicates different strings") {
|
||||
auto a = saveString(resources, "hello");
|
||||
@ -63,7 +63,7 @@ TEST_CASE("ResourceManager::saveString()") {
|
||||
}
|
||||
|
||||
SECTION("Returns NULL when allocation fails") {
|
||||
ResourceManager pool2(32, FailingAllocator::instance());
|
||||
ResourceManager pool2(FailingAllocator::instance());
|
||||
REQUIRE(saveString(pool2, "a") == nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using namespace ArduinoJson::detail;
|
||||
|
||||
TEST_CASE("ResourceManager::size()") {
|
||||
TimebombAllocator allocator(0);
|
||||
ResourceManager resources(4096, &allocator);
|
||||
ResourceManager resources(&allocator);
|
||||
|
||||
SECTION("Initial size is 0") {
|
||||
REQUIRE(0 == resources.size());
|
||||
|
Reference in New Issue
Block a user