Files

36 lines
754 B
C++
Raw Permalink Normal View History

2024-01-08 19:10:29 +01:00
// ArduinoJson - https://arduinojson.org
2025-02-24 15:18:26 +01:00
// Copyright © 2014-2025, Benoit BLANCHON
2024-01-08 19:10:29 +01:00
// MIT License
#include <ArduinoJson.h>
2026-07-06 15:12:32 +02:00
#include <doctest.h>
2024-01-08 19:10:29 +01:00
TEST_CASE("JsonArrayConst::nesting()") {
JsonDocument doc;
JsonArrayConst arr = doc.to<JsonArray>();
2026-07-06 15:12:32 +02:00
SUBCASE("return 0 if unbound") {
2024-01-08 19:10:29 +01:00
JsonArrayConst unbound;
REQUIRE(unbound.nesting() == 0);
}
2026-07-06 15:12:32 +02:00
SUBCASE("returns 1 for empty array") {
2024-01-08 19:10:29 +01:00
REQUIRE(arr.nesting() == 1);
}
2026-07-06 15:12:32 +02:00
SUBCASE("returns 1 for flat array") {
2024-01-08 19:10:29 +01:00
doc.add("hello");
REQUIRE(arr.nesting() == 1);
}
2026-07-06 15:12:32 +02:00
SUBCASE("returns 2 with nested array") {
2024-01-08 19:10:29 +01:00
doc.add<JsonArray>();
REQUIRE(arr.nesting() == 2);
}
2026-07-06 15:12:32 +02:00
SUBCASE("returns 2 with nested object") {
2024-01-08 19:10:29 +01:00
doc.add<JsonObject>();
REQUIRE(arr.nesting() == 2);
}
}