diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-05-10 13:24:28 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-10 13:50:35 +0200 |
commit | 1f9a958e3668a32270d63dc4216804ef6333c9f3 (patch) | |
tree | 1d6ac51f268cc6f592bd475a51488bc31615ba51 /tests/auto/corelib | |
parent | f6bd10b8ff5aacc6d214d8dd5be570a5301f9433 (diff) |
Correctly parse json documents with a leading BOM
A leading byte order mark is valid in utf-8 and we should
parse documents starting with those correctly.
Change-Id: Id85398ff6e05b93ceefbaf4a6de5571d5e61ca13
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/json/bom.json | 3 | ||||
-rw-r--r-- | tests/auto/corelib/json/tst_qtjson.cpp | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/bom.json b/tests/auto/corelib/json/bom.json new file mode 100644 index 0000000000..d1e8d90e28 --- /dev/null +++ b/tests/auto/corelib/json/bom.json @@ -0,0 +1,3 @@ +{ + "info-version": "1.0" +} diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 7a11b5aec2..84913f9289 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -125,6 +125,8 @@ private Q_SLOTS: void testDetachBug(); void valueEquals(); + + void bom(); private: QString testDataDir; }; @@ -1908,5 +1910,19 @@ void TestQtJson::valueEquals() QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(QJsonArray())); } +void TestQtJson::bom() +{ + QFile file(testDataDir + "/bom.json"); + file.open(QFile::ReadOnly); + QByteArray json = file.readAll(); + + // Import json document into a QJsonDocument + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson(json, &error); + + QVERIFY(!doc.isNull()); + QVERIFY(error.error == QJsonParseError::NoError); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" |