From 53bbea232830af3f056cd8253c4ff4dd33f525c7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 6 Mar 2012 13:05:09 +0100 Subject: Fix parsing of unicode escape sequences Change-Id: I63a7cd3a571fb47c97157bcb2ca29c4239c600ba Reviewed-by: Thiago Macieira --- tests/auto/corelib/json/tst_qtjson.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto/corelib/json/tst_qtjson.cpp') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index f5b4f17732..f35831c900 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -115,6 +115,8 @@ private Q_SLOTS: void testCompaction(); void testDebugStream(); void testCompactionError(); + + void parseUnicodeEscapes(); private: QString testDataDir; }; @@ -1758,5 +1760,19 @@ void TestQtJson::testCompactionError() } } +void TestQtJson::parseUnicodeEscapes() +{ + const QByteArray json = "[ \"A\\u00e4\\u00C4\" ]"; + + QJsonDocument doc = QJsonDocument::fromJson(json); + QJsonArray array = doc.array(); + + QString result = QLatin1String("A"); + result += QChar(0xe4); + result += QChar(0xc4); + + QCOMPARE(array.first().toString(), result); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" -- cgit v1.2.3