diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/serialization/json/tst_qtjson.cpp | 27 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 548b6d0059..1cbe0cae48 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; }; @@ -3085,6 +3086,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() @@ -3173,5 +3177,26 @@ void tst_QtJson::streamVariantSerialization() } } +void tst_QtJson::escapeSurrogateCodePoints_data() +{ + QTest::addColumn<QString>("str"); + QTest::addColumn<QByteArray>("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" diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 6b7aaf7c0a..ec4a44e672 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -525,6 +525,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: |