Renamed JsonBuffer to MemoryPool

This commit is contained in:
Benoit Blanchon
2018-09-03 16:14:21 +02:00
parent e5c4778ff7
commit 2998a55f0b
48 changed files with 365 additions and 361 deletions

View File

@ -0,0 +1,49 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson/Memory/DynamicMemoryPool.hpp>
#include <catch.hpp>
using namespace ArduinoJson::Internals;
TEST_CASE("DynamicMemoryPool::startString()") {
SECTION("WorksWhenBufferIsBigEnough") {
DynamicMemoryPool memoryPool(6);
DynamicMemoryPool::String str = memoryPool.startString();
str.append('h');
str.append('e');
str.append('l');
str.append('l');
str.append('o');
REQUIRE(std::string("hello") == str.c_str());
}
SECTION("GrowsWhenBufferIsTooSmall") {
DynamicMemoryPool memoryPool(5);
DynamicMemoryPool::String str = memoryPool.startString();
str.append('h');
str.append('e');
str.append('l');
str.append('l');
str.append('o');
REQUIRE(std::string("hello") == str.c_str());
}
SECTION("SizeIncreases") {
DynamicMemoryPool memoryPool(5);
DynamicMemoryPool::String str = memoryPool.startString();
REQUIRE(0 == memoryPool.size());
str.append('h');
REQUIRE(1 == memoryPool.size());
str.c_str();
REQUIRE(2 == memoryPool.size());
}
}