diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-04 19:34:36 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-04 19:34:36 +0200 |
commit | 80604a0786628a0c57eac7cc856720537956cc7f (patch) | |
tree | e31b9b56584e77d6aefd4dfd072ce4e8e3648f3d /tests/auto/corelib/json | |
parent | 1c901913c0af79b2bbde1b9da71f5267cb4fc76a (diff) | |
parent | c11a7d16c7056da4086a87c9e85b89f8466be032 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/corelib/global/qglobal.h
src/plugins/platforms/cocoa/qnsview.mm
Change-Id: I6fe345df5c417cb7a55a3f91285d9b47a22c04fa
Diffstat (limited to 'tests/auto/corelib/json')
-rw-r--r-- | tests/auto/corelib/json/tst_qtjson.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 010c8acb5f..84deb72696 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -131,6 +131,8 @@ private Q_SLOTS: void bom(); void nesting(); + + void longStrings(); private: QString testDataDir; }; @@ -2204,5 +2206,48 @@ void tst_QtJson::nesting() } +void tst_QtJson::longStrings() +{ + // test around 15 and 16 bit boundaries, as these are limits + // in the data structures (for Latin1String in qjson_p.h) + QString s(0x7ff0, 'a'); + for (int i = 0x7ff0; i < 0x8010; i++) { + s.append("c"); + + QMap <QString, QVariant> map; + map["key"] = s; + + /* Create a QJsonDocument from the QMap ... */ + QJsonDocument d1 = QJsonDocument::fromVariant(QVariant(map)); + /* ... and a QByteArray from the QJsonDocument */ + QByteArray a1 = d1.toJson(); + + /* Create a QJsonDocument from the QByteArray ... */ + QJsonDocument d2 = QJsonDocument::fromJson(a1); + /* ... and a QByteArray from the QJsonDocument */ + QByteArray a2 = d2.toJson(); + QVERIFY(a1 == a2); + } + + s = QString(0xfff0, 'a'); + for (int i = 0xfff0; i < 0x10010; i++) { + s.append("c"); + + QMap <QString, QVariant> map; + map["key"] = s; + + /* Create a QJsonDocument from the QMap ... */ + QJsonDocument d1 = QJsonDocument::fromVariant(QVariant(map)); + /* ... and a QByteArray from the QJsonDocument */ + QByteArray a1 = d1.toJson(); + + /* Create a QJsonDocument from the QByteArray ... */ + QJsonDocument d2 = QJsonDocument::fromJson(a1); + /* ... and a QByteArray from the QJsonDocument */ + QByteArray a2 = d2.toJson(); + QVERIFY(a1 == a2); + } +} + QTEST_MAIN(tst_QtJson) #include "tst_qtjson.moc" |