summaryrefslogtreecommitdiffstats
path: root/tests/auto/tst_qtjson.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tst_qtjson.cpp')
-rw-r--r--tests/auto/tst_qtjson.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/tst_qtjson.cpp b/tests/auto/tst_qtjson.cpp
index 4a749ec..5ed02f4 100644
--- a/tests/auto/tst_qtjson.cpp
+++ b/tests/auto/tst_qtjson.cpp
@@ -100,6 +100,8 @@ private Q_SLOTS:
void validation();
+ void assignToDocument();
+
void testDuplicateKeys();
void testCompaction();
void testDebugStream();
@@ -1326,6 +1328,34 @@ void TestQtJson::validation()
}
}
+void TestQtJson::assignToDocument()
+{
+ {
+ const char *json = "{ \"inner\": { \"key\": true } }";
+ QJsonDocument doc = QJsonDocument::fromJson(json);
+
+ QJsonObject o = doc.object();
+ QJsonValue inner = o.value("inner");
+
+ QJsonDocument innerDoc(inner.toObject());
+
+ QVERIFY(innerDoc != doc);
+ QVERIFY(innerDoc.object() == inner.toObject());
+ }
+ {
+ const char *json = "[ [ true ] ]";
+ QJsonDocument doc = QJsonDocument::fromJson(json);
+
+ QJsonArray a = doc.array();
+ QJsonValue inner = a.at(0);
+
+ QJsonDocument innerDoc(inner.toArray());
+
+ QVERIFY(innerDoc != doc);
+ QVERIFY(innerDoc.array() == inner.toArray());
+ }
+}
+
void TestQtJson::testDuplicateKeys()
{