forked from bblanchon/ArduinoJson
Return JsonArray
and JsonObject
by value (closes #309)
This commit is contained in:
@ -9,7 +9,7 @@ using namespace Catch::Matchers;
|
||||
|
||||
TEST_CASE("JsonArray::set()") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonArray& _array = doc.to<JsonArray>();
|
||||
JsonArray _array = doc.to<JsonArray>();
|
||||
_array.add(0);
|
||||
|
||||
SECTION("int") {
|
||||
@ -42,29 +42,29 @@ TEST_CASE("JsonArray::set()") {
|
||||
|
||||
SECTION("nested array") {
|
||||
DynamicJsonDocument doc2;
|
||||
JsonArray& arr = doc2.to<JsonArray>();
|
||||
JsonArray arr = doc2.to<JsonArray>();
|
||||
|
||||
_array.set(0, arr);
|
||||
|
||||
REQUIRE(&arr == &_array[0].as<JsonArray&>());
|
||||
REQUIRE(_array[0].is<JsonArray&>());
|
||||
REQUIRE(arr == _array[0].as<JsonArray>());
|
||||
REQUIRE(_array[0].is<JsonArray>());
|
||||
REQUIRE_FALSE(_array[0].is<int>());
|
||||
}
|
||||
|
||||
SECTION("nested object") {
|
||||
DynamicJsonDocument doc2;
|
||||
JsonObject& obj = doc2.to<JsonObject>();
|
||||
JsonObject obj = doc2.to<JsonObject>();
|
||||
|
||||
_array.set(0, obj);
|
||||
|
||||
REQUIRE(&obj == &_array[0].as<JsonObject&>());
|
||||
REQUIRE(_array[0].is<JsonObject&>());
|
||||
REQUIRE(obj == _array[0].as<JsonObject>());
|
||||
REQUIRE(_array[0].is<JsonObject>());
|
||||
REQUIRE_FALSE(_array[0].is<int>());
|
||||
}
|
||||
|
||||
SECTION("array subscript") {
|
||||
DynamicJsonDocument doc2;
|
||||
JsonArray& arr = doc2.to<JsonArray>();
|
||||
JsonArray arr = doc2.to<JsonArray>();
|
||||
arr.add("hello");
|
||||
|
||||
_array.set(0, arr[0]);
|
||||
@ -74,7 +74,7 @@ TEST_CASE("JsonArray::set()") {
|
||||
|
||||
SECTION("object subscript") {
|
||||
DynamicJsonDocument doc2;
|
||||
JsonObject& obj = doc2.to<JsonObject>();
|
||||
JsonObject obj = doc2.to<JsonObject>();
|
||||
obj["x"] = "hello";
|
||||
|
||||
_array.set(0, obj["x"]);
|
||||
|
Reference in New Issue
Block a user