forked from bblanchon/ArduinoJson
Added JSON_PROXY to copy arrays and objects by reference
This commit is contained in:
@ -123,21 +123,35 @@ TEST_F(JsonObject_Serialization_Tests, OneFalse)
|
||||
object["key"] = false;
|
||||
outputMustBe("{\"key\":false}");
|
||||
}
|
||||
/*
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArray)
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArrayViaProxy)
|
||||
{
|
||||
auto nestedArray = JsonArray<1>();
|
||||
auto nestedArray = json.createArray();
|
||||
|
||||
object["key"] = nestedArray;
|
||||
|
||||
outputMustBe("{\"key\":[]}");
|
||||
}
|
||||
*/
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObject)
|
||||
{
|
||||
auto nestedObject = json.createObject();
|
||||
|
||||
object["key"] = nestedObject;
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObjectViaProxy)
|
||||
{
|
||||
auto nestedArray = json.createObject();
|
||||
|
||||
object["key"] = nestedArray;
|
||||
|
||||
outputMustBe("{\"key\":{}}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObject)
|
||||
{
|
||||
object.createNestedObject("key");
|
||||
|
||||
outputMustBe("{\"key\":{}}");
|
||||
}
|
||||
|
||||
TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArray)
|
||||
{
|
||||
object.createNestedArray("key");
|
||||
|
||||
outputMustBe("{\"key\":[]}");
|
||||
}
|
@ -101,12 +101,10 @@ TEST_F(JsonValueTests, ObjectsAreCopiedByReference)
|
||||
JsonObject object = json.createObject();
|
||||
|
||||
jsonValue1 = object;
|
||||
jsonValue2 = jsonValue1;
|
||||
|
||||
object["hello"] = "world";
|
||||
jsonValue1 = 0;
|
||||
|
||||
EXPECT_EQ(1, ((JsonObject) jsonValue2).size());
|
||||
EXPECT_EQ(1, ((JsonObject) jsonValue1).size());
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, ArraysAreCopiedByReference)
|
||||
@ -114,10 +112,8 @@ TEST_F(JsonValueTests, ArraysAreCopiedByReference)
|
||||
JsonArray array = json.createArray();
|
||||
|
||||
jsonValue1 = array;
|
||||
jsonValue2 = jsonValue1;
|
||||
jsonValue1 = 0;
|
||||
|
||||
array.add("world");
|
||||
|
||||
EXPECT_EQ(1, ((JsonObject) jsonValue2).size());
|
||||
EXPECT_EQ(1, ((JsonObject) jsonValue1).size());
|
||||
}
|
Reference in New Issue
Block a user