From 2a1651cc164b270dac81f4caa1fb8ded4fab6e4b Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Fri, 10 May 2019 16:45:56 +0300 Subject: Make moc grok binary literals with digit separators Task-number: QTBUG-75656 Change-Id: I6011ef2fb07497cc2a055d6828a1b6356927c281 Reviewed-by: Lars Knoll --- tests/auto/tools/moc/tst_moc.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 293cbd8323..41bc4bc73b 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -524,6 +524,7 @@ private: #ifdef Q_MOC_RUN int xx = 11'11; // digit separator must not confuse moc (QTBUG-59351) + int xx = 0b11'11; // digit separator in a binary literal must not confuse moc (QTBUG-75656) #endif private slots: -- cgit v1.2.3 From 1e5deb06416b6efc33a2009d9678fd8f743c5ce7 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 2 May 2019 18:02:45 +0200 Subject: Add 'well-formated' JSON string values Add support for surrogate code points U+D800 through U+DFFF, represent them with JSON escape sequences. https://github.com/tc39/proposal-well-formed-stringify Change-Id: I84fea53a8ef400beebefdba10ea82dc510fe7dda Reviewed-by: Thiago Macieira --- .../auto/corelib/serialization/json/tst_qtjson.cpp | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 083e78375a..8907704a33 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -163,7 +163,8 @@ private Q_SLOTS: void streamSerializationQJsonValue(); void streamSerializationQJsonValueEmpty(); void streamVariantSerialization(); - + void escapeSurrogateCodePoints_data(); + void escapeSurrogateCodePoints(); private: QString testDataDir; }; @@ -3093,6 +3094,9 @@ void tst_QtJson::streamSerializationQJsonValue_data() QTest::newRow("string") << QJsonValue{QStringLiteral("bum")}; QTest::newRow("array") << QJsonValue{QJsonArray{12,1,5,6,7}}; QTest::newRow("object") << QJsonValue{QJsonObject{{"foo", 665}, {"bar", 666}}}; + // test json escape sequence + QTest::newRow("array with 0xD800") << QJsonValue(QJsonArray{QString(0xD800)}); + QTest::newRow("array with 0xDF06,0xD834") << QJsonValue(QJsonArray{QString(0xDF06).append(0xD834)}); } void tst_QtJson::streamSerializationQJsonValue() @@ -3181,5 +3185,26 @@ void tst_QtJson::streamVariantSerialization() } } +void tst_QtJson::escapeSurrogateCodePoints_data() +{ + QTest::addColumn("str"); + QTest::addColumn("escStr"); + QTest::newRow("0xD800") << QString(0xD800) << QByteArray("\\ud800"); + QTest::newRow("0xDF06,0xD834") << QString(0xDF06).append(0xD834) << QByteArray("\\udf06\\ud834"); +} + +void tst_QtJson::escapeSurrogateCodePoints() +{ + QFETCH(QString, str); + QFETCH(QByteArray, escStr); + QJsonArray array; + array.append(str); + QByteArray buffer; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << array; + // verify the buffer has escaped values + QVERIFY(buffer.contains(escStr)); +} + QTEST_MAIN(tst_QtJson) #include "tst_qtjson.moc" -- cgit v1.2.3