Files
ArduinoJson/test/JsonArray/size.cpp
T

32 lines
645 B
C++
Raw Normal View History

// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::size()") {
DynamicJsonDocument doc;
2018-07-12 09:08:20 +02:00
JsonArray array = doc.to<JsonArray>();
SECTION("InitialSizeIsZero") {
REQUIRE(0U == array.size());
}
SECTION("increases after add()") {
2018-07-12 09:08:20 +02:00
array.add("hello");
REQUIRE(1U == array.size());
2018-07-12 09:08:20 +02:00
array.add("world");
REQUIRE(2U == array.size());
}
SECTION("remains the same after replacing an element") {
2018-07-12 09:08:20 +02:00
array.add("hello");
REQUIRE(1U == array.size());
2018-07-12 09:08:20 +02:00
array[0] = "hello";
REQUIRE(1U == array.size());
}
}