diff options
author | Qt CI Bot <qt_ci_bot@qt-project.org> | 2021-03-30 13:30:26 +0000 |
---|---|---|
committer | Qt CI Bot <qt_ci_bot@qt-project.org> | 2021-03-30 13:30:26 +0000 |
commit | 31c81e08c6b0fa878ab7a22771230635ac2e85c6 (patch) | |
tree | 3664d654cc443cc116043c09bf76ac383ad8ae62 /tests | |
parent | 7ae037bc82085c73b271d70532b858fb8d8bcef9 (diff) | |
parent | c34f51d58c1e3333a663b09b974bbd7b145a2d1b (diff) |
Merge integration refs/builds/qtci/dev/1617098611
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 25 | ||||
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 29 |
2 files changed, 48 insertions, 6 deletions
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 70180bbf3b..382190567b 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -126,6 +126,7 @@ private slots: void movablity_data(); void movablity(); void literals(); + void userDefinedLiterals(); void toUpperLower_data(); void toUpperLower(); void isUpper(); @@ -1967,7 +1968,6 @@ void tst_QByteArray::movablity() QVERIFY(true); } -// Only tested on c++0x compliant compiler or gcc void tst_QByteArray::literals() { QByteArray str(QByteArrayLiteral("abcd")); @@ -1991,6 +1991,29 @@ void tst_QByteArray::literals() QVERIFY(str2.capacity() >= str2.length()); } +void tst_QByteArray::userDefinedLiterals() +{ + QByteArray str = "abcd"_qba; + + QVERIFY(str.length() == 4); + QCOMPARE(str.capacity(), 0); + QVERIFY(str == "abcd"); + QVERIFY(!str.data_ptr()->isMutable()); + + const char *s = str.constData(); + QByteArray str2 = str; + QVERIFY(str2.constData() == s); + QCOMPARE(str2.capacity(), 0); + + // detach on non const access + QVERIFY(str.data() != s); + QVERIFY(str.capacity() >= str.length()); + + QVERIFY(str2.constData() == s); + QVERIFY(str2.data() != s); + QVERIFY(str2.capacity() >= str2.length()); +} + void tst_QByteArray::toUpperLower_data() { QTest::addColumn<QByteArray>("input"); diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 79c4fa4ab0..57885f596d 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -566,9 +566,8 @@ private slots: #if QT_CONFIG(icu) void toUpperLower_icu(); #endif -#if !defined(QT_NO_UNICODE_LITERAL) void literals(); -#endif + void userDefinedLiterals(); void eightBitLiterals_data(); void eightBitLiterals(); void reserve(); @@ -6419,8 +6418,6 @@ void tst_QString::toUpperLower_icu() } #endif // icu -#if !defined(QT_NO_UNICODE_LITERAL) -// Only tested on c++0x compliant compiler or gcc void tst_QString::literals() { QString str(QStringLiteral("abcd")); @@ -6443,7 +6440,29 @@ void tst_QString::literals() QVERIFY(str2.data() != s); QVERIFY(str2.capacity() >= str2.length()); } -#endif + +void tst_QString::userDefinedLiterals() +{ + QString str = u"abcd"_qs; + + QVERIFY(str.length() == 4); + QCOMPARE(str.capacity(), 0); + QVERIFY(str == QLatin1String("abcd")); + QVERIFY(!str.data_ptr()->isMutable()); + + const QChar *s = str.constData(); + QString str2 = str; + QVERIFY(str2.constData() == s); + QCOMPARE(str2.capacity(), 0); + + // detach on non const access + QVERIFY(str.data() != s); + QVERIFY(str.capacity() >= str.length()); + + QVERIFY(str2.constData() == s); + QVERIFY(str2.data() != s); + QVERIFY(str2.capacity() >= str2.length()); +} void tst_QString::eightBitLiterals_data() { |