From fe1726fd7d33a5e1bda863ca6000bc3b9806b1aa Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 22 Jan 2015 10:38:34 +0100 Subject: Document and further test that QJsonObject::keys() is sorted. Change-Id: I6b145c1240cce85ad3fea6fb90ddbed629487f83 Reviewed-by: Lars Knoll --- src/corelib/json/qjsonobject.cpp | 2 ++ tests/auto/corelib/json/tst_qtjson.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index bc74092f59..cd68db8dc6 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -223,6 +223,8 @@ QVariantMap QJsonObject::toVariantMap() const /*! Returns a list of all keys in this object. + + The list is sorted lexographically. */ QStringList QJsonObject::keys() const { diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 56a5a28c50..b6cfc39bb9 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1051,6 +1051,8 @@ void tst_QtJson::keySorting() QCOMPARE(it.key(), QLatin1String("A")); ++it; QCOMPARE(it.key(), QLatin1String("B")); + + QCOMPARE(o.keys(), QStringList() << QLatin1String("A") << QLatin1String("B")); } void tst_QtJson::undefinedValues() -- cgit v1.2.3