summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/json
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2012-01-26 11:13:41 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-26 13:28:16 +0100
commite62fe9ed4fd8d33f881dedeeafafc4a0c65e5278 (patch)
treee8148f0ed05f2b1584c483ad87f9f462b78badd1 /tests/auto/corelib/json
parent68e5fd9ebc8a3f510e3144e981a0cb358945fb9c (diff)
Fixed QString::operator<(QLatin1String)
QLatin1String now has a constructor that takes explicit length, which makes it possible to create QLatin1String that do not have null-termination character. Fixed QString::operator> and < to be safe in that case. In the same patch fixed qtjson which had operator< implemented in the same way. QString::compare(QLatin1String) is still broken and will be fixed separately. Change-Id: I48ec1183a6f44034129cc17312af854795085408 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/json')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index d5575b0e28..97504d178a 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -61,6 +61,7 @@ private Q_SLOTS:
void testNumbers();
void testObjectSimple();
+ void testObjectSmallKeys();
void testArraySimple();
void testValueObject();
void testValueArray();
@@ -277,6 +278,22 @@ void TestQtJson::testObjectSimple()
QVERIFY2(object.value("string").toString() != before, "value should have been updated");
}
+void TestQtJson::testObjectSmallKeys()
+{
+ QJsonObject data1;
+ data1.insert(QStringLiteral("1"), 123);
+ QVERIFY(data1.contains(QStringLiteral("1")));
+ QCOMPARE(data1.value(QStringLiteral("1")).toDouble(), (double)123);
+ data1.insert(QStringLiteral("12"), 133);
+ QCOMPARE(data1.value(QStringLiteral("12")).toDouble(), (double)133);
+ QVERIFY(data1.contains(QStringLiteral("12")));
+ data1.insert(QStringLiteral("123"), 323);
+ QCOMPARE(data1.value(QStringLiteral("12")).toDouble(), (double)133);
+ QVERIFY(data1.contains(QStringLiteral("123")));
+ QCOMPARE(data1.value(QStringLiteral("123")).type(), QJsonValue::Double);
+ QCOMPARE(data1.value(QStringLiteral("123")).toDouble(), (double)323);
+}
+
void TestQtJson::testArraySimple()
{
QJsonArray array;