
【主 题】:不从配置文件远端获取 ArduinoJson库 添加到根目录调用 【描 述】: [原因]:防止版本不同 造成bug [过程]: [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
36 lines
833 B
C++
36 lines
833 B
C++
// ArduinoJson - https://arduinojson.org
|
|
// Copyright © 2014-2022, Benoit BLANCHON
|
|
// MIT License
|
|
|
|
#include <ArduinoJson/Memory/MemoryPool.hpp>
|
|
#include <catch.hpp>
|
|
|
|
using namespace ARDUINOJSON_NAMESPACE;
|
|
|
|
TEST_CASE("MemoryPool::capacity()") {
|
|
char buffer[4096];
|
|
const size_t capacity = 64;
|
|
MemoryPool pool(buffer, capacity);
|
|
REQUIRE(capacity == pool.capacity());
|
|
}
|
|
|
|
TEST_CASE("MemoryPool::size()") {
|
|
char buffer[4096];
|
|
MemoryPool pool(buffer, sizeof(buffer));
|
|
|
|
SECTION("Initial size is 0") {
|
|
REQUIRE(0 == pool.size());
|
|
}
|
|
|
|
SECTION("Doesn't grow when memory pool is full") {
|
|
const size_t variantCount = sizeof(buffer) / sizeof(VariantSlot);
|
|
|
|
for (size_t i = 0; i < variantCount; i++) pool.allocVariant();
|
|
size_t size = pool.size();
|
|
|
|
pool.allocVariant();
|
|
|
|
REQUIRE(size == pool.size());
|
|
}
|
|
}
|