JsonObject::createNestedArray() returns JsonArray::invalid() if key is null

This commit is contained in:
Benoit Blanchon
2023-03-16 17:52:34 +01:00
parent 63c89f166d
commit 46bd98fd10
4 changed files with 29 additions and 3 deletions

View File

@ -0,0 +1,23 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2023
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonObject::createNestedArray()") {
DynamicJsonBuffer _jsonBuffer;
JsonObject& _object = _jsonBuffer.createObject();
SECTION("success() should return true if key is non-null") {
JsonArray& arr = _object.createNestedArray("key");
REQUIRE(arr.success() == true);
}
SECTION("success() should return false if key is null") {
const char* null = 0;
JsonArray& arr = _object.createNestedArray(null);
REQUIRE(arr.success() == false);
}
}