summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/json
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-09-05 12:58:19 +0200
committerLars Knoll <lars.knoll@digia.com>2014-09-10 21:10:35 +0200
commit853845a4a2570302def9526a99f2b09433c286c5 (patch)
treeacb735a0549df5d36631d84c57cf2417d810d565 /tests/auto/corelib/json
parent395d865b8047f5ac20a082e846e37ceeb1c7afbd (diff)
Fix bugs in internal comparison operators
The comparison operators between QJsonPrivate::String and QJsonPrivate::Latin1String weren't all correct, leading to wrong sorting of keys in QJsonObjects when the keys were outside of the latin1 range and resulting lookup errors. Task-number: QTBUG-41100 Change-Id: Idceff615f85d7ab874ad2a8e4a6c1ce8c2aa0f65 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests/auto/corelib/json')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index d4ce123fcc..ba19e4855d 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -149,6 +149,8 @@ private Q_SLOTS:
void arrayInitializerList();
void objectInitializerList();
+
+ void unicodeKeys();
private:
QString testDataDir;
};
@@ -2753,5 +2755,27 @@ void tst_QtJson::objectInitializerList()
#endif
}
+void tst_QtJson::unicodeKeys()
+{
+ QByteArray json = "{"
+ "\"x\u2090_1\": \"hello_1\","
+ "\"y\u2090_2\": \"hello_2\","
+ "\"T\u2090_3\": \"hello_3\","
+ "\"xyz_4\": \"hello_4\","
+ "\"abc_5\": \"hello_5\""
+ "}";
+
+ QJsonParseError error;
+ QJsonDocument doc = QJsonDocument::fromJson(json, &error);
+ QVERIFY(error.error == QJsonParseError::NoError);
+ QJsonObject o = doc.object();
+
+ QCOMPARE(o.keys().size(), 5);
+ Q_FOREACH (const QString &key, o.keys()) {
+ QString suffix = key.mid(key.indexOf(QLatin1Char('_')));
+ QCOMPARE(o[key].toString(), QString("hello") + suffix);
+ }
+}
+
QTEST_MAIN(tst_QtJson)
#include "tst_qtjson.moc"