add a testcase in ValueTest:CopyObject (#1028)

This commit is contained in:
Vincent 2019-09-18 03:46:29 +08:00 committed by Jordan Bayles
parent 81ae1d55f7
commit c97bd59ff2

View File

@ -1515,6 +1515,24 @@ JSONTEST_FIXTURE(ValueTest, CopyObject) {
JSONTEST_ASSERT(copy1 == "string value");
copy2.copy(arrayVal);
JSONTEST_ASSERT(copy2.size() == 5);
{
Json::Value srcObject, objectCopy, otherObject;
srcObject["key0"] = 10;
objectCopy.copy(srcObject);
JSONTEST_ASSERT(srcObject["key0"] == 10);
JSONTEST_ASSERT(objectCopy["key0"] == 10);
JSONTEST_ASSERT(srcObject.getMemberNames().size() == 1);
JSONTEST_ASSERT(objectCopy.getMemberNames().size() == 1);
otherObject["key1"] = 15;
otherObject["key2"] = 16;
JSONTEST_ASSERT(otherObject.getMemberNames().size() == 2);
objectCopy.copy(otherObject);
JSONTEST_ASSERT(objectCopy["key1"] == 15);
JSONTEST_ASSERT(objectCopy["key2"] == 16);
JSONTEST_ASSERT(objectCopy.getMemberNames().size() == 2);
otherObject["key1"] = 20;
JSONTEST_ASSERT(objectCopy["key1"] == 15);
}
}
void ValueTest::checkIsLess(const Json::Value& x, const Json::Value& y) {