diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-01-12 23:14:44 +0100 |
---|---|---|
committer | Jamey Hicks <jamey.hicks@nokia.com> | 2012-01-13 03:52:59 +0100 |
commit | be87296e8ac10b5058ba6b9519f677bc7625d5a4 (patch) | |
tree | 9fcd5088766b6a895e9c2e3a73aa533a857b5110 | |
parent | e5c4f0bc6c048010c3b01b7da856b75a2bf4d7d5 (diff) |
Add another test case
This test that we correctly convert sub objects and
arrays to documents.
Change-Id: I859a1d9b27554da920b1f53b3e83e1e21110c2c7
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
-rw-r--r-- | tests/auto/tst_qtjson.cpp | 30 |
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() { |