summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 079ff6e76b..87820d2e78 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -120,6 +120,8 @@ private Q_SLOTS:
void assignObjects();
void assignArrays();
+
+ void testTrailingComma();
private:
QString testDataDir;
};
@@ -1807,5 +1809,16 @@ void TestQtJson::assignArrays()
QCOMPARE(inner.at(0).toDouble(), 2.);
}
+void TestQtJson::testTrailingComma()
+{
+ const char *jsons[] = { "{ \"Key\": 1, }", "[ { \"Key\": 1 }, ]" };
+
+ for (unsigned i = 0; i < sizeof(jsons)/sizeof(jsons[0]); ++i) {
+ QJsonParseError error;
+ QJsonDocument doc = QJsonDocument::fromJson(jsons[i], &error);
+ QCOMPARE(error.error, QJsonParseError::MissingObject);
+ }
+}
+
QTEST_MAIN(TestQtJson)
#include "tst_qtjson.moc"