Files
Benoit Blanchon 18671a5f3b Replace catch with doctest
This reduces the build times by about 38%
2026-07-06 17:59:49 +02:00

32 lines
651 B
C++

// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <doctest.h>
TEST_CASE("JsonArray::size()") {
JsonDocument doc;
JsonArray array = doc.to<JsonArray>();
SUBCASE("returns 0 is empty") {
REQUIRE(0U == array.size());
}
SUBCASE("increases after add()") {
array.add("hello");
REQUIRE(1U == array.size());
array.add("world");
REQUIRE(2U == array.size());
}
SUBCASE("remains the same after replacing an element") {
array.add("hello");
REQUIRE(1U == array.size());
array[0] = "hello";
REQUIRE(1U == array.size());
}
}