2021-03-29 17:14:01 +02:00
|
|
|
// ArduinoJson - https://arduinojson.org
|
2022-01-01 10:00:54 +01:00
|
|
|
// Copyright © 2014-2022, Benoit BLANCHON
|
2018-08-22 14:37:17 +02:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
TEST_CASE("JsonObject::createNestedArray()") {
|
2019-01-14 10:32:19 +01:00
|
|
|
DynamicJsonDocument doc(4096);
|
2018-08-22 14:37:17 +02:00
|
|
|
JsonObject obj = doc.to<JsonObject>();
|
|
|
|
|
|
|
|
SECTION("key is a const char*") {
|
2018-09-11 16:05:56 +02:00
|
|
|
JsonArray arr = obj.createNestedArray("hello");
|
|
|
|
REQUIRE(arr.isNull() == false);
|
2018-08-22 14:37:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAS_VARIABLE_LENGTH_ARRAY
|
|
|
|
SECTION("key is a VLA") {
|
2022-02-25 09:23:51 +01:00
|
|
|
size_t i = 16;
|
2018-08-22 14:37:17 +02:00
|
|
|
char vla[i];
|
|
|
|
strcpy(vla, "hello");
|
|
|
|
|
2018-09-11 16:05:56 +02:00
|
|
|
JsonArray arr = obj.createNestedArray(vla);
|
|
|
|
REQUIRE(arr.isNull() == false);
|
2018-08-22 14:37:17 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|