Files
ArduinoJson/test/DynamicJsonBuffer/createArray.cpp
2017-04-18 18:22:24 +02:00

32 lines
741 B
C++

// Copyright Benoit Blanchon 2014-2017
// MIT License
//
// Arduino JSON library
// https://bblanchon.github.io/ArduinoJson/
// If you like this project, please add a star!
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("DynamicJsonBuffer::createArray()") {
DynamicJsonBuffer jsonBuffer;
JsonArray &array = jsonBuffer.createArray();
SECTION("GrowsWithArray") {
REQUIRE(JSON_ARRAY_SIZE(0) == jsonBuffer.size());
array.add("hello");
REQUIRE(JSON_ARRAY_SIZE(1) == jsonBuffer.size());
array.add("world");
REQUIRE(JSON_ARRAY_SIZE(2) == jsonBuffer.size());
}
SECTION("CanAdd1000Values") {
for (size_t i = 1; i <= 1000; i++) {
array.add("hello");
REQUIRE(array.size() == i);
}
}
}