From 13806e6787502f55754660c6241b31d41e6d9ac7 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sun, 29 Dec 2013 16:19:13 -0500 Subject: Added convenience methods to QJsonArray for appending QJsonValues operators for +, +=, and << were added to QJsonArray to make it easier to work with, and more closely resemble the Qt container classes [ChangeLog][QtCore][QJsonArray] Added convenience methods to QJsonArray for appending QJsonValues Change-Id: I96e0a43015f7c0f980cbbef7f20bd2085ee04795 Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto/corelib/json') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 8ff6c8be6b..45ce836cbf 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -76,6 +76,7 @@ private Q_SLOTS: void testObjectNested(); void testArrayNested(); void testArrayNestedEmpty(); + void testArrayComfortOperators(); void testObjectNestedEmpty(); void testValueRef(); @@ -665,6 +666,20 @@ void tst_QtJson::testObjectNestedEmpty() QCOMPARE(reconstituted.value("inner2").type(), QJsonValue::Object); } +void tst_QtJson::testArrayComfortOperators() +{ + QJsonArray first; + first.append(123.); + first.append(QLatin1String("foo")); + + QJsonArray second = QJsonArray() << 123. << QLatin1String("foo"); + QCOMPARE(first, second); + + first = first + QLatin1String("bar"); + second += QLatin1String("bar"); + QCOMPARE(first, second); +} + void tst_QtJson::testValueRef() { QJsonArray array; -- cgit v1.2.3