Moved ancillary files to extras/ (fixes #1011)

This commit is contained in:
Benoit Blanchon
2019-09-03 15:11:05 +02:00
parent ed18e77655
commit b47ac27ac6
226 changed files with 19 additions and 54 deletions

View File

@ -0,0 +1,41 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// MIT License
#include <ArduinoJson/Memory/MemoryPool.hpp>
#include <ArduinoJson/Memory/StringBuilder.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
static char buffer[4096];
TEST_CASE("StringBuilder") {
SECTION("Works when buffer is big enough") {
MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(6)));
StringBuilder str(&pool);
str.append("hello");
REQUIRE(str.complete() == std::string("hello"));
}
SECTION("Returns null when too small") {
MemoryPool pool(buffer, sizeof(void*));
StringBuilder str(&pool);
str.append("hello world!");
REQUIRE(str.complete() == 0);
}
SECTION("Increases size of memory pool") {
MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(6)));
StringBuilder str(&pool);
str.append('h');
str.complete();
REQUIRE(JSON_STRING_SIZE(2) == pool.size());
}
}