Files

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

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