diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2012-06-04 18:52:36 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-06 02:03:11 +0200 |
commit | 944221001c67d01fc528f5e7a0d3b1c9578cec32 (patch) | |
tree | f79b2509e1f5dcd30fbedb4f6f9cda51259d89d0 /tests | |
parent | 9b0aa9dc4c82410004ed5079e81ace31d48ce757 (diff) |
Fixed QJsonObject::find()
The function returns mutable iterator on the object that can later be passed to
e.g. erase(), hence it should detach() to be consistent with
QJsonObject::begin() which also detaches.
Change-Id: Id79e8e012fd5469e06b68fbc9eecb7c6848ce9c1
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/json/tst_qtjson.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 00810889bb..5498c890fe 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -590,6 +590,16 @@ void TestQtJson::testObjectIteration() } { + QJsonObject object2 = object; + QVERIFY(object == object2); + + QJsonObject::iterator it = object2.find(QString::number(5)); + object2.erase(it); + QCOMPARE(object.size(), 10); + QCOMPARE(object2.size(), 9); + } + + { QJsonObject::Iterator it = object.begin(); it += 5; QCOMPARE(QJsonValue(it.value()).toDouble(), 5.); |