summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/text')
-rw-r--r--tests/auto/corelib/text/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/text/qbytearray/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp123
-rw-r--r--tests/auto/corelib/text/qbytearray_large/.gitattributes (renamed from tests/auto/corelib/text/qbytearray/.gitattributes)0
-rw-r--r--tests/auto/corelib/text/qbytearray_large/CMakeLists.txt11
-rw-r--r--tests/auto/corelib/text/qbytearray_large/rfc3252.txt (renamed from tests/auto/corelib/text/qbytearray/rfc3252.txt)0
-rw-r--r--tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp216
-rw-r--r--tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp6
-rw-r--r--tests/auto/corelib/text/qchar/tst_qchar.cpp2
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp26
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp344
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp109
-rw-r--r--tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp4
-rw-r--r--tests/auto/corelib/text/qstringview/tst_qstringview.cpp2
-rw-r--r--tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp6
-rw-r--r--tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp2
16 files changed, 673 insertions, 183 deletions
diff --git a/tests/auto/corelib/text/CMakeLists.txt b/tests/auto/corelib/text/CMakeLists.txt
index 5264c3e2fc..2562ca4f10 100644
--- a/tests/auto/corelib/text/CMakeLists.txt
+++ b/tests/auto/corelib/text/CMakeLists.txt
@@ -2,6 +2,7 @@
add_subdirectory(qanystringview)
add_subdirectory(qbytearray)
+add_subdirectory(qbytearray_large)
add_subdirectory(qbytearrayapisymmetry)
add_subdirectory(qbytearraylist)
add_subdirectory(qbytearraymatcher)
diff --git a/tests/auto/corelib/text/qbytearray/CMakeLists.txt b/tests/auto/corelib/text/qbytearray/CMakeLists.txt
index d1a65adcd8..54b29e70ee 100644
--- a/tests/auto/corelib/text/qbytearray/CMakeLists.txt
+++ b/tests/auto/corelib/text/qbytearray/CMakeLists.txt
@@ -4,15 +4,11 @@
## tst_qbytearray Test:
#####################################################################
-# Collect test data
-list(APPEND test_data "rfc3252.txt")
-
qt_internal_add_test(tst_qbytearray
SOURCES
tst_qbytearray.cpp
PUBLIC_LIBRARIES
Qt::CorePrivate
- TESTDATA ${test_data}
)
## Scopes:
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index 823dd679e5..5566d64bc4 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -12,9 +12,6 @@
#include "../shared/test_number_shared.h"
-#include <stdexcept>
-#include <string_view>
-
class tst_QByteArray : public QObject
{
Q_OBJECT
@@ -26,13 +23,6 @@ private slots:
void swap();
void qChecksum_data();
void qChecksum();
- void qCompress_data();
-#ifndef QT_NO_COMPRESS
- void qCompress();
- void qUncompressCorruptedData_data();
- void qUncompressCorruptedData();
- void qCompressionZeroTermination();
-#endif
void constByteArray();
void leftJustified();
void rightJustified();
@@ -43,7 +33,6 @@ private slots:
void split();
void base64_data();
void base64();
- void base64_2GiB();
void fromBase64_data();
void fromBase64();
void qvsnprintf();
@@ -235,79 +224,6 @@ void tst_QByteArray::qChecksum()
QCOMPARE(::qChecksum(QByteArrayView(data.constData(), len), standard), static_cast<quint16>(checksum));
}
-void tst_QByteArray::qCompress_data()
-{
- QTest::addColumn<QByteArray>("ba");
-
- const int size1 = 1024*1024;
- QByteArray ba1( size1, 0 );
-
- QTest::newRow( "00" ) << QByteArray();
-
- int i;
- for ( i=0; i<size1; i++ )
- ba1[i] = (char)( i / 1024 );
- QTest::newRow( "01" ) << ba1;
-
- for ( i=0; i<size1; i++ )
- ba1[i] = (char)( i % 256 );
- QTest::newRow( "02" ) << ba1;
-
- ba1.fill( 'A' );
- QTest::newRow( "03" ) << ba1;
-
- QFile file( QFINDTESTDATA("rfc3252.txt") );
- QVERIFY( file.open(QIODevice::ReadOnly) );
- QTest::newRow( "04" ) << file.readAll();
-}
-
-#ifndef QT_NO_COMPRESS
-void tst_QByteArray::qCompress()
-{
- QFETCH( QByteArray, ba );
- QByteArray compressed = ::qCompress( ba );
- QTEST( ::qUncompress( compressed ), "ba" );
-}
-
-void tst_QByteArray::qUncompressCorruptedData_data()
-{
- QTest::addColumn<QByteArray>("in");
-
- QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4);
- QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4);
- QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00", 4);
- QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff", 4);
- QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00", 4);
- QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff", 4);
- QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00", 4);
- QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff", 4);
- QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00", 4);
- QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff", 4);
- QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00", 4);
- QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4);
-}
-
-// This test is expected to produce some warning messages in the test output.
-void tst_QByteArray::qUncompressCorruptedData()
-{
- QFETCH(QByteArray, in);
-
- QByteArray res;
- res = ::qUncompress(in);
- QCOMPARE(res, QByteArray());
-
- res = ::qUncompress(in + "blah");
- QCOMPARE(res, QByteArray());
-}
-
-void tst_QByteArray::qCompressionZeroTermination()
-{
- QByteArray s = "Hello, I'm a string.";
- QByteArray ba = ::qUncompress(::qCompress(s));
- QCOMPARE(ba.data()[ba.size()], '\0');
- QCOMPARE(ba, s);
-}
-#endif
void tst_QByteArray::constByteArray()
{
@@ -579,42 +495,6 @@ void tst_QByteArray::base64()
QCOMPARE(arr64, base64urlnoequals);
}
-void tst_QByteArray::base64_2GiB()
-{
- if constexpr (sizeof(qsizetype) > sizeof(int)) {
- try {
- constexpr qint64 GiB = 1024 * 1024 * 1024;
- static_assert((2 * GiB + 1) % 3 == 0);
- const char inputChar = '\0'; // all-NULs encode as
- const char outputChar = 'A'; // all-'A's
- const qint64 inputSize = 2 * GiB + 1;
- const qint64 outputSize = inputSize / 3 * 4;
- const auto sv = [](const QByteArray &ba) {
- return std::string_view{ba.data(), size_t(ba.size())};
- };
- QByteArray output;
- {
- const QByteArray input(inputSize, inputChar);
- output = input.toBase64();
- QCOMPARE(output.size(), outputSize);
- QCOMPARE(sv(output).find_first_not_of(outputChar),
- std::string_view::npos);
- }
- {
- auto r = QByteArray::fromBase64Encoding(output);
- QCOMPARE_EQ(r.decodingStatus, QByteArray::Base64DecodingStatus::Ok);
- QCOMPARE(r.decoded.size(), inputSize);
- QCOMPARE(sv(r.decoded).find_first_not_of(inputChar),
- std::string_view::npos);
- }
- } catch (const std::bad_alloc &) {
- QSKIP("Could not allocate enough RAM.");
- }
- } else {
- QSKIP("This is a 64-bit only test");
- }
-}
-
//different from the previous test as the input are invalid
void tst_QByteArray::fromBase64_data()
{
@@ -857,7 +737,10 @@ void tst_QByteArray::qstrncpy()
// src == nullptr
QCOMPARE(::qstrncpy(dst.data(), 0, 0), (char*)0);
+ QCOMPARE(*dst.data(), 'b'); // must not have written to dst
QCOMPARE(::qstrncpy(dst.data(), 0, 10), (char*)0);
+ QCOMPARE(*dst.data(), '\0'); // must have written to dst
+ *dst.data() = 'b'; // restore
// valid pointers, but len == 0
QCOMPARE(::qstrncpy(dst.data(), src.data(), 0), dst.data());
diff --git a/tests/auto/corelib/text/qbytearray/.gitattributes b/tests/auto/corelib/text/qbytearray_large/.gitattributes
index e04709aa2e..e04709aa2e 100644
--- a/tests/auto/corelib/text/qbytearray/.gitattributes
+++ b/tests/auto/corelib/text/qbytearray_large/.gitattributes
diff --git a/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt b/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt
new file mode 100644
index 0000000000..898c1662f0
--- /dev/null
+++ b/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qbytearray_large
+ SOURCES
+ tst_qbytearray_large.cpp
+ LIBRARIES
+ Qt::Core
+ TESTDATA "rfc3252.txt"
+)
+
diff --git a/tests/auto/corelib/text/qbytearray/rfc3252.txt b/tests/auto/corelib/text/qbytearray_large/rfc3252.txt
index b80c61bf0a..b80c61bf0a 100644
--- a/tests/auto/corelib/text/qbytearray/rfc3252.txt
+++ b/tests/auto/corelib/text/qbytearray_large/rfc3252.txt
diff --git a/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp b/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp
new file mode 100644
index 0000000000..65ba2f54ff
--- /dev/null
+++ b/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp
@@ -0,0 +1,216 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// Copyright (C) 2022 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QTest>
+
+#include <qbytearray.h>
+
+#include <q20iterator.h>
+#include <stdexcept>
+#include <string_view>
+
+class tst_QByteArrayLarge : public QObject
+{
+ Q_OBJECT
+
+private slots:
+#ifndef QT_NO_COMPRESS
+ void qCompress_data();
+ void qCompress();
+ void qUncompressCorruptedData_data();
+ void qUncompressCorruptedData();
+ void qUncompress4GiBPlus();
+ void qCompressionZeroTermination();
+#endif
+ void base64_2GiB();
+};
+
+#ifndef QT_NO_COMPRESS
+void tst_QByteArrayLarge::qCompress_data()
+{
+ QTest::addColumn<QByteArray>("ba");
+
+ const int size1 = 1024*1024;
+ QByteArray ba1( size1, 0 );
+
+ QTest::newRow( "00" ) << QByteArray();
+
+ int i;
+ for ( i=0; i<size1; i++ )
+ ba1[i] = (char)( i / 1024 );
+ QTest::newRow( "01" ) << ba1;
+
+ for ( i=0; i<size1; i++ )
+ ba1[i] = (char)( i % 256 );
+ QTest::newRow( "02" ) << ba1;
+
+ ba1.fill( 'A' );
+ QTest::newRow( "03" ) << ba1;
+
+ QFile file( QFINDTESTDATA("rfc3252.txt") );
+ QVERIFY( file.open(QIODevice::ReadOnly) );
+ QTest::newRow( "04" ) << file.readAll();
+}
+
+void tst_QByteArrayLarge::qCompress()
+{
+ QFETCH( QByteArray, ba );
+ QByteArray compressed = ::qCompress( ba );
+ QTEST( ::qUncompress( compressed ), "ba" );
+}
+
+void tst_QByteArrayLarge::qUncompressCorruptedData_data()
+{
+ QTest::addColumn<QByteArray>("in");
+
+ QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4);
+ QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4);
+ QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00", 4);
+ QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff", 4);
+ QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00", 4);
+ QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff", 4);
+ QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00", 4);
+ QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff", 4);
+ QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00", 4);
+ QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff", 4);
+ QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00", 4);
+ QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4);
+}
+
+// This test is expected to produce some warning messages in the test output.
+void tst_QByteArrayLarge::qUncompressCorruptedData()
+{
+ QFETCH(QByteArray, in);
+
+ QByteArray res;
+ res = ::qUncompress(in);
+ QCOMPARE(res, QByteArray());
+
+ res = ::qUncompress(in + "blah");
+ QCOMPARE(res, QByteArray());
+}
+
+void tst_QByteArrayLarge::qUncompress4GiBPlus()
+{
+ // after three rounds, this decompresses to 4GiB + 1 'X' bytes:
+ constexpr uchar compressed_3x[] = {
+ 0x00, 0x00, 0x1a, 0x76, 0x78, 0x9c, 0x63, 0xb0, 0xdf, 0xb4, 0xad, 0x62,
+ 0xce, 0xdb, 0x3b, 0x0b, 0xf3, 0x26, 0x27, 0x4a, 0xb4, 0x3d, 0x34, 0x5b,
+ 0xed, 0xb4, 0x41, 0xf1, 0xc0, 0x99, 0x2f, 0x02, 0x05, 0x67, 0x26, 0x88,
+ 0x6c, 0x66, 0x71, 0x34, 0x62, 0x9c, 0x75, 0x26, 0xb1, 0xa0, 0xe5, 0xcc,
+ 0xda, 0x94, 0x83, 0xc9, 0x05, 0x73, 0x0e, 0x3c, 0x39, 0xc2, 0xc7, 0xd0,
+ 0xae, 0x38, 0x53, 0x7b, 0x87, 0xdc, 0x01, 0x91, 0x45, 0x59, 0x4f, 0xda,
+ 0xbf, 0xca, 0xcc, 0x52, 0xdb, 0xbb, 0xde, 0xbb, 0xf6, 0xd3, 0x55, 0xff,
+ 0x7d, 0x77, 0x0e, 0x1b, 0xf0, 0xa4, 0xdf, 0xcf, 0xdb, 0x5f, 0x2f, 0xf5,
+ 0xd7, 0x7c, 0xfe, 0xbf, 0x3f, 0xbf, 0x3f, 0x9d, 0x7c, 0xda, 0x2c, 0xc8,
+ 0xc0, 0xc0, 0xb0, 0xe1, 0xf1, 0xb3, 0xfd, 0xfa, 0xdf, 0x8e, 0x7d, 0xef,
+ 0x7f, 0xb9, 0xc1, 0xc2, 0xae, 0x92, 0x19, 0x28, 0xf2, 0x66, 0xd7, 0xe5,
+ 0xbf, 0xed, 0x93, 0xbf, 0x6a, 0x14, 0x7c, 0xff, 0xf6, 0xe1, 0xe8, 0xb6,
+ 0x7e, 0x46, 0xa0, 0x90, 0xd9, 0xbb, 0xcf, 0x9f, 0x17, 0x37, 0x7f, 0xe5,
+ 0x6f, 0xb4, 0x7f, 0xfe, 0x5e, 0xfd, 0xb6, 0x1d, 0x1b, 0x50, 0xe8, 0xc6,
+ 0x8e, 0xe3, 0xab, 0x9f, 0xe6, 0xec, 0x65, 0xfd, 0x23, 0xb1, 0x4e, 0x7e,
+ 0xef, 0xbd, 0x6f, 0xa6, 0x40, 0xa1, 0x03, 0xc7, 0xfe, 0x0a, 0xf1, 0x00,
+ 0xe9, 0x06, 0x91, 0x83, 0x40, 0x92, 0x21, 0x43, 0x10, 0xcc, 0x11, 0x03,
+ 0x73, 0x3a, 0x90, 0x39, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0x34, 0x90, 0x99, 0xb6, 0x7e, 0xf5,
+ 0xd3, 0xe9, 0xbf, 0x35, 0x13, 0xca, 0x8c, 0x75, 0xec, 0xec, 0xa4, 0x2f,
+ 0x7e, 0x2d, 0xf9, 0xf3, 0xf0, 0xee, 0xea, 0xd5, 0xf5, 0xd3, 0x14, 0x57,
+ 0x06, 0x00, 0x00, 0xb9, 0x1e, 0x35, 0xce
+ };
+
+ constexpr qint64 GiB = 1024LL * 1024 * 1024;
+
+ if constexpr (sizeof(qsizetype) == sizeof(int)) {
+ QSKIP("This is a 64-bit-only test.");
+ } else {
+
+ // 1st
+ auto c = ::qUncompress(std::data(compressed_3x), q20::ssize(compressed_3x));
+ QVERIFY(!c.isNull()); // check for decompression error
+
+ // 2nd
+ c = ::qUncompress(c);
+ QVERIFY(!c.isNull());
+
+ // 3rd
+ try {
+ c = ::qUncompress(c);
+ if (c.isNull()) // this step (~18MiB -> 4GiB) might have run out of memory
+ QSKIP("Failed to allocate enough memory.");
+ } catch (const std::bad_alloc &) {
+ QSKIP("Failed to allocate enough memory.");
+ }
+
+ QCOMPARE(c.size(), 4 * GiB + 1);
+ QCOMPARE(std::string_view{c}.find_first_not_of('X'),
+ std::string_view::npos);
+
+ // re-compress once
+ // (produces 18MiB, we shouldn't use much more than that in allocated capacity)
+ c = ::qCompress(c);
+ QVERIFY(!c.isNull());
+
+ // and un-compress again, to make sure compression worked (we
+ // can't compare with compressed_3x, because zlib may change):
+ c = ::qUncompress(c);
+
+ QCOMPARE(c.size(), 4 * GiB + 1);
+ QCOMPARE(std::string_view{c}.find_first_not_of('X'),
+ std::string_view::npos);
+ }
+}
+
+void tst_QByteArrayLarge::qCompressionZeroTermination()
+{
+ QByteArray s = "Hello, I'm a string.";
+ QByteArray ba = ::qUncompress(::qCompress(s));
+ QCOMPARE(ba.data()[ba.size()], '\0');
+ QCOMPARE(ba, s);
+}
+#endif
+
+void tst_QByteArrayLarge::base64_2GiB()
+{
+#ifdef Q_OS_ANDROID
+ QSKIP("Android kills the test when using too much memory");
+#endif
+ if constexpr (sizeof(qsizetype) > sizeof(int)) {
+ try {
+ constexpr qint64 GiB = 1024 * 1024 * 1024;
+ static_assert((2 * GiB + 1) % 3 == 0);
+ const char inputChar = '\0'; // all-NULs encode as
+ const char outputChar = 'A'; // all-'A's
+ const qint64 inputSize = 2 * GiB + 1;
+ const qint64 outputSize = inputSize / 3 * 4;
+ const auto sv = [](const QByteArray &ba) {
+ return std::string_view{ba.data(), size_t(ba.size())};
+ };
+ QByteArray output;
+ {
+ const QByteArray input(inputSize, inputChar);
+ output = input.toBase64();
+ QCOMPARE(output.size(), outputSize);
+ QCOMPARE(sv(output).find_first_not_of(outputChar),
+ std::string_view::npos);
+ }
+ {
+ auto r = QByteArray::fromBase64Encoding(output);
+ QCOMPARE_EQ(r.decodingStatus, QByteArray::Base64DecodingStatus::Ok);
+ QCOMPARE(r.decoded.size(), inputSize);
+ QCOMPARE(sv(r.decoded).find_first_not_of(inputChar),
+ std::string_view::npos);
+ }
+ } catch (const std::bad_alloc &) {
+ QSKIP("Could not allocate enough RAM.");
+ }
+ } else {
+ QSKIP("This is a 64-bit only test");
+ }
+}
+
+QTEST_MAIN(tst_QByteArrayLarge)
+#include "tst_qbytearray_large.moc"
diff --git a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
index a01b097576..3d3b724599 100644
--- a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
+++ b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
@@ -91,12 +91,12 @@ void tst_QByteArrayMatcher::interface()
QCOMPARE(matcher5.indexIn(haystack), 42);
QCOMPARE(matcher6.indexIn(haystack), 42);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length()), 42);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size()), 42);
QCOMPARE(matcher1.indexIn(haystack, 43), 84);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 43), 84);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 43), 84);
QCOMPARE(matcher1.indexIn(haystack, 85), -1);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 85), -1);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 85), -1);
QByteArrayMatcher matcher7(QByteArray("123"));
QCOMPARE(matcher7.indexIn(haystack), 6);
diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp
index 725a7e0d72..9f887bb59f 100644
--- a/tests/auto/corelib/text/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp
@@ -797,7 +797,7 @@ void tst_QChar::normalization_data()
line = line.trimmed();
if (line.endsWith(';'))
- line.truncate(line.length()-1);
+ line.truncate(line.size()-1);
QList<QByteArray> l = line.split(';');
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 4dd2cf6aff..4897218fcc 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -13,7 +13,9 @@
# include <QProcess>
#endif
#include <QScopedArrayPointer>
+#if QT_CONFIG(timezone)
#include <QTimeZone>
+#endif
#include <private/qlocale_p.h>
#include <private/qlocale_tools_p.h>
@@ -1493,8 +1495,7 @@ void tst_QLocale::fpExceptions()
# define _EM_INEXACT 0x00000001
# endif
_clearfp();
- unsigned int oldbits = _controlfp(0, 0);
- _controlfp( 0 | _EM_INEXACT, _MCW_EM );
+ unsigned int oldbits = _controlfp(0 | _EM_INEXACT, _MCW_EM);
#endif
#ifdef QT_USE_FENV
@@ -1512,7 +1513,7 @@ void tst_QLocale::fpExceptions()
#ifdef Q_OS_WIN
_clearfp();
- _controlfp(oldbits, 0xFFFFF);
+ _controlfp(oldbits, _MCW_EM);
#endif
#ifdef QT_USE_FENV
@@ -2313,7 +2314,7 @@ void tst_QLocale::windowsDefaultLocale()
locale.toString(QDate(1974, 12, 1), QLocale::ShortFormat));
QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::LongFormat),
QStringView(u"\u3021@\u3021\u3022@\u3021\u3029\u3027\u3024"));
- const QString expectedFormattedShortTime = QStringView(u"\u3021^\u3022").toString();
+ const QString expectedFormattedShortTime = QStringView(u"\u3021^\u3022^\u3023").toString();
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime);
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat),
locale.toString(QTime(1,2,3), QLocale::ShortFormat));
@@ -3237,7 +3238,12 @@ public:
QVariant query(QueryType type, QVariant /*in*/) const override
{
- return type == UILanguages ? QVariant(QStringList{m_name}) : QVariant();
+ if (type == UILanguages) {
+ if (m_name == u"en-DE") // QTBUG-104930: simulate macOS's list not including m_name.
+ return QVariant(QStringList{QStringLiteral("en-GB"), QStringLiteral("de-DE")});
+ return QVariant(QStringList{m_name});
+ }
+ return QVariant();
}
QLocale fallbackLocale() const override
@@ -3266,6 +3272,12 @@ void tst_QLocale::systemLocale_data()
QTest::addRow("ukrainian")
<< QString("uk") << QLocale::Ukrainian
<< QStringList{QStringLiteral("uk"), QStringLiteral("uk-Cyrl-UA"), QStringLiteral("uk-UA")};
+ QTest::addRow("english-germany")
+ << QString("en-DE") << QLocale::English
+ // First two were missed out before fix to QTBUG-104930:
+ << QStringList{QStringLiteral("en-DE"), QStringLiteral("en-Latn-DE"),
+ QStringLiteral("en-GB"), QStringLiteral("en-Latn-GB"),
+ QStringLiteral("de-DE"), QStringLiteral("de-Latn-DE"), QStringLiteral("de")};
QTest::addRow("german")
<< QString("de") << QLocale::German
<< QStringList{QStringLiteral("de"), QStringLiteral("de-Latn-DE"), QStringLiteral("de-DE")};
@@ -3290,7 +3302,11 @@ void tst_QLocale::systemLocale()
MySystemLocale sLocale(name);
QCOMPARE(QLocale().language(), language);
QCOMPARE(QLocale::system().language(), language);
+ auto reporter = qScopeGuard([]() {
+ qDebug("\n\t%s", qPrintable(QLocale::system().uiLanguages().join(u"\n\t")));
+ });
QCOMPARE(QLocale::system().uiLanguages(), uiLanguages);
+ reporter.dismiss();
}
QCOMPARE(QLocale(), originalLocale);
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 239b3498a9..64e9d5623a 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -56,7 +56,7 @@ class ArgBase
protected:
QString pinned;
explicit ArgBase(const char *str)
- : pinned(QString::fromLatin1(str)) {}
+ : pinned(QString::fromUtf8(str)) {}
};
template <>
@@ -67,11 +67,11 @@ public:
template <typename MemFun>
void apply0(QString &s, MemFun mf) const
- { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(ch); }
+ { for (QChar ch : std::as_const(this->pinned)) (s.*mf)(ch); }
template <typename MemFun, typename A1>
void apply1(QString &s, MemFun mf, A1 a1) const
- { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(a1, ch); }
+ { for (QChar ch : std::as_const(this->pinned)) (s.*mf)(a1, ch); }
};
template <>
@@ -276,6 +276,13 @@ static void do_apply1(MemFun mf)
class tst_QString : public QObject
{
Q_OBJECT
+public:
+ enum DataOption {
+ EmptyIsNoop = 0x1,
+ Latin1Encoded = 0x2
+ };
+ Q_DECLARE_FLAGS(DataOptions, DataOption)
+private:
#if QT_CONFIG(regularexpression)
template<typename List, class RegExp>
@@ -288,22 +295,22 @@ class tst_QString : public QObject
void append_impl() const { do_apply0<ArgType>(MemFun(&QString::append)); }
template <typename ArgType>
void append_impl() const { append_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void append_data(bool emptyIsNoop = false);
+ void append_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void operator_pluseq_impl() const { do_apply0<ArgType>(MemFun(&QString::operator+=)); }
template <typename ArgType>
void operator_pluseq_impl() const { operator_pluseq_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void operator_pluseq_data(bool emptyIsNoop = false);
+ void operator_pluseq_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void prepend_impl() const { do_apply0<ArgType>(MemFun(&QString::prepend)); }
template <typename ArgType>
void prepend_impl() const { prepend_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void prepend_data(bool emptyIsNoop = false);
+ void prepend_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void insert_impl() const { do_apply1<ArgType, int>(MemFun(&QString::insert)); }
template <typename ArgType>
void insert_impl() const { insert_impl<ArgType, QString &(QString::*)(qsizetype, const ArgType&)>(); }
- void insert_data(bool emptyIsNoop = false);
+ void insert_data(DataOptions options = {});
class TransientDefaultLocale
{
@@ -369,38 +376,38 @@ private slots:
void swap();
void prepend_qstring() { prepend_impl<QString>(); }
- void prepend_qstring_data() { prepend_data(true); }
+ void prepend_qstring_data() { prepend_data(EmptyIsNoop); }
void prepend_qstringview() { prepend_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void prepend_qstringview_data() { prepend_data(true); }
+ void prepend_qstringview_data() { prepend_data(EmptyIsNoop); }
void prepend_qlatin1string() { prepend_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void prepend_qlatin1string_data() { prepend_data(true); }
+ void prepend_qlatin1string_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); }
void prepend_qcharstar_int() { prepend_impl<QPair<const QChar *, int>, QString &(QString::*)(const QChar *, qsizetype)>(); }
- void prepend_qcharstar_int_data() { prepend_data(true); }
+ void prepend_qcharstar_int_data() { prepend_data(EmptyIsNoop); }
void prepend_qchar() { prepend_impl<Reversed<QChar>, QString &(QString::*)(QChar)>(); }
- void prepend_qchar_data() { prepend_data(true); }
+ void prepend_qchar_data() { prepend_data(EmptyIsNoop); }
void prepend_qbytearray() { prepend_impl<QByteArray>(); }
- void prepend_qbytearray_data() { prepend_data(true); }
+ void prepend_qbytearray_data() { prepend_data(EmptyIsNoop); }
void prepend_char() { prepend_impl<Reversed<char>, QString &(QString::*)(QChar)>(); }
- void prepend_char_data() { prepend_data(true); }
+ void prepend_char_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); }
void prepend_charstar() { prepend_impl<const char *, QString &(QString::*)(const char *)>(); }
- void prepend_charstar_data() { prepend_data(true); }
+ void prepend_charstar_data() { prepend_data(EmptyIsNoop); }
void prepend_bytearray_special_cases_data();
void prepend_bytearray_special_cases();
void append_qstring() { append_impl<QString>(); }
void append_qstring_data() { append_data(); }
void append_qstringview() { append_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void append_qstringview_data() { append_data(true); }
+ void append_qstringview_data() { append_data(EmptyIsNoop); }
void append_qlatin1string() { append_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void append_qlatin1string_data() { append_data(); }
+ void append_qlatin1string_data() { append_data(Latin1Encoded); }
void append_qcharstar_int() { append_impl<QPair<const QChar *, int>, QString&(QString::*)(const QChar *, qsizetype)>(); }
- void append_qcharstar_int_data() { append_data(true); }
+ void append_qcharstar_int_data() { append_data(EmptyIsNoop); }
void append_qchar() { append_impl<QChar, QString &(QString::*)(QChar)>(); }
- void append_qchar_data() { append_data(true); }
+ void append_qchar_data() { append_data(EmptyIsNoop); }
void append_qbytearray() { append_impl<QByteArray>(); }
void append_qbytearray_data() { append_data(); }
void append_char() { append_impl<char, QString &(QString::*)(QChar)>(); }
- void append_char_data() { append_data(true); }
+ void append_char_data() { append_data({EmptyIsNoop, Latin1Encoded}); }
void append_charstar() { append_impl<const char *, QString &(QString::*)(const char *)>(); }
void append_charstar_data() { append_data(); }
void append_special_cases();
@@ -410,11 +417,11 @@ private slots:
void operator_pluseq_qstring() { operator_pluseq_impl<QString>(); }
void operator_pluseq_qstring_data() { operator_pluseq_data(); }
void operator_pluseq_qstringview() { operator_pluseq_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void operator_pluseq_qstringview_data() { operator_pluseq_data(true); }
+ void operator_pluseq_qstringview_data() { operator_pluseq_data(EmptyIsNoop); }
void operator_pluseq_qlatin1string() { operator_pluseq_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void operator_pluseq_qlatin1string_data() { operator_pluseq_data(); }
+ void operator_pluseq_qlatin1string_data() { operator_pluseq_data(Latin1Encoded); }
void operator_pluseq_qchar() { operator_pluseq_impl<QChar, QString &(QString::*)(QChar)>(); }
- void operator_pluseq_qchar_data() { operator_pluseq_data(true); }
+ void operator_pluseq_qchar_data() { operator_pluseq_data(EmptyIsNoop); }
void operator_pluseq_qbytearray() { operator_pluseq_impl<QByteArray>(); }
void operator_pluseq_qbytearray_data() { operator_pluseq_data(); }
void operator_pluseq_charstar() { operator_pluseq_impl<const char *, QString &(QString::*)(const char *)>(); }
@@ -429,21 +436,21 @@ private slots:
void operator_smaller();
void insert_qstring() { insert_impl<QString>(); }
- void insert_qstring_data() { insert_data(true); }
+ void insert_qstring_data() { insert_data(EmptyIsNoop); }
void insert_qstringview() { insert_impl<QStringView, QString &(QString::*)(qsizetype, QStringView)>(); }
- void insert_qstringview_data() { insert_data(true); }
+ void insert_qstringview_data() { insert_data(EmptyIsNoop); }
void insert_qlatin1string() { insert_impl<QLatin1String, QString &(QString::*)(qsizetype, QLatin1String)>(); }
- void insert_qlatin1string_data() { insert_data(true); }
+ void insert_qlatin1string_data() { insert_data({EmptyIsNoop, Latin1Encoded}); }
void insert_qcharstar_int() { insert_impl<QPair<const QChar *, int>, QString &(QString::*)(qsizetype, const QChar*, qsizetype) >(); }
- void insert_qcharstar_int_data() { insert_data(true); }
+ void insert_qcharstar_int_data() { insert_data(EmptyIsNoop); }
void insert_qchar() { insert_impl<Reversed<QChar>, QString &(QString::*)(qsizetype, QChar)>(); }
- void insert_qchar_data() { insert_data(true); }
+ void insert_qchar_data() { insert_data(EmptyIsNoop); }
void insert_qbytearray() { insert_impl<QByteArray>(); }
- void insert_qbytearray_data() { insert_data(true); }
+ void insert_qbytearray_data() { insert_data(EmptyIsNoop); }
void insert_char() { insert_impl<Reversed<char>, QString &(QString::*)(qsizetype, QChar)>(); }
- void insert_char_data() { insert_data(true); }
+ void insert_char_data() { insert_data({EmptyIsNoop, Latin1Encoded}); }
void insert_charstar() { insert_impl<const char *, QString &(QString::*)(qsizetype, const char*) >(); }
- void insert_charstar_data() { insert_data(true); }
+ void insert_charstar_data() { insert_data(EmptyIsNoop); }
void insert_special_cases();
void simplified_data();
@@ -587,6 +594,8 @@ private slots:
void chopped();
void removeIf();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(tst_QString::DataOptions)
+
template <class T> const T &verifyZeroTermination(const T &t) { return t; }
@@ -600,7 +609,7 @@ QString verifyZeroTermination(const QString &str)
if (!strDataPtr->isMutable())
return str;
- int strSize = str.size();
+ qsizetype strSize = str.size();
QChar strTerminator = str.constData()[strSize];
if (QChar('\0') != strTerminator)
return QString::fromLatin1(
@@ -856,6 +865,9 @@ void tst_QString::replace_regexp_data()
// Columns (all QString): string, regexp, after, result; string.replace(regexp, after) == result
// Test-cases with empty after (replacement text, third column) go in remove_regexp_data()
+ QTest::newRow("empty-in-null") << QString() << "" << "after" << "after";
+ QTest::newRow("empty-in-empty") << "" << "" << "after" << "after";
+
QTest::newRow( "rep00" ) << QString("A <i>bon mot</i>.") << QString("<i>([^<]*)</i>") << QString("\\emph{\\1}") << QString("A \\emph{bon mot}.");
QTest::newRow( "rep01" ) << QString("banana") << QString("^.a()") << QString("\\1") << QString("nana");
QTest::newRow( "rep02" ) << QString("banana") << QString("(ba)") << QString("\\1X\\1") << QString("baXbanana");
@@ -1393,6 +1405,43 @@ void tst_QString::asprintf()
double d = -514.25683;
QCOMPARE(QString::asprintf("%f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%1.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1.6f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%1.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%-1f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-1.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%-1.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%-1.6f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-1.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%10f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%10.f", d), QLatin1String(" -514"));
+ QCOMPARE(QString::asprintf("%10.0f", d), QLatin1String(" -514"));
+ QCOMPARE(QString::asprintf("%-10f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-10.f", d), QLatin1String("-514 "));
+ QCOMPARE(QString::asprintf("%-10.0f", d), QLatin1String("-514 "));
+ QCOMPARE(QString::asprintf("%010f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%010.f", d), QLatin1String("-000000514"));
+ QCOMPARE(QString::asprintf("%010.0f", d), QLatin1String("-000000514"));
+ QCOMPARE(QString::asprintf("%15f", d), QLatin1String(" -514.256830"));
+ QCOMPARE(QString::asprintf("%15.6f", d), QLatin1String(" -514.256830"));
+ QCOMPARE(QString::asprintf("%15.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%-15f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-15.6f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-15.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%015f", d), QLatin1String("-0000514.256830"));
+ QCOMPARE(QString::asprintf("%015.6f", d), QLatin1String("-0000514.256830"));
+ QCOMPARE(QString::asprintf("%015.10f", d), QLatin1String("-514.2568300000"));
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wformat")
+QT_WARNING_DISABLE_CLANG("-Wformat") // Flag '0' ignored when flag '-' is present
+ QCOMPARE(QString::asprintf("%-015f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-015.6f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-015.10f", d), QLatin1String("-514.2568300000"));
+QT_WARNING_POP
{
/* This code crashed. I don't know how to reduce it further. In other words,
@@ -1913,6 +1962,21 @@ void tst_QString::count()
QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
QCOMPARE(emptyStr.count(QRegularExpression("invalid regex\\")), 0);
#endif
+
+ QString nonBmpString = u8"\U00010000\U00010000abc\U00010000";
+ QCOMPARE(nonBmpString.count(u"\U00010000"), 3);
+#if QT_CONFIG(regularexpression)
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000")), 3);
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000a?")), 3);
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000a")), 1);
+ QCOMPARE(nonBmpString.count(QRegularExpression(".")), 6);
+
+ // can't search for unpaired surrogates
+ QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
+ QCOMPARE(nonBmpString.count(QRegularExpression(QChar(0xd800))), 0);
+ QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
+ QCOMPARE(nonBmpString.count(QRegularExpression(QChar(0xdc00))), 0);
+#endif
}
void tst_QString::contains()
@@ -2587,19 +2651,22 @@ void tst_QString::simplified()
QCOMPARE(std::move(full).simplified(), simple);
}
-void tst_QString::insert_data(bool emptyIsNoop)
+void tst_QString::insert_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<int>("a1");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
//const CharStarContainer abC("ab");
const CharStarContainer baC("ba");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2608,6 +2675,10 @@ void tst_QString::insert_data(bool emptyIsNoop)
const QString ab("ab");
const QString ba("ba");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString yumlautA = QStringLiteral("\u00ffa");
+ const QString aYumlaut = QStringLiteral("a\u00ff");
+
QTest::newRow("null.insert(0, null)") << null << nullC << 0 << null;
QTest::newRow("null.insert(0, empty)") << null << emptyC << 0 << (emptyIsNoop ? null : empty);
QTest::newRow("null.insert(0, a)") << null << aC << 0 << a;
@@ -2624,6 +2695,79 @@ void tst_QString::insert_data(bool emptyIsNoop)
QTest::newRow("a.insert(1, ba)") << a << baC << 1 << (a + ba);
QTest::newRow("ba.insert(1, a)") << ba << aC << 1 << (ba + a);
QTest::newRow("ba.insert(2, b)") << ba << bC << 2 << (ba + b);
+
+ QTest::newRow("null-insert-0-yumlaut") << null << yumlautC << 0 << yumlaut;
+ QTest::newRow("empty-insert-0-yumlaut") << empty << yumlautC << 0 << yumlaut;
+ QTest::newRow("yumlaut-insert-0-null") << yumlaut << nullC << 0 << yumlaut;
+ QTest::newRow("yumlaut-insert-0-empty") << yumlaut << emptyC << 0 << yumlaut;
+ QTest::newRow("a-insert-0-yumlaut") << a << yumlautC << 0 << yumlautA;
+ QTest::newRow("a-insert-1-yumlaut") << a << yumlautC << 1 << aYumlaut;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto aSmallTheta = QStringLiteral("a\u03b8");
+ const auto aSsa = QStringLiteral("a\u0937");
+ const auto aChakmaZero = QStringLiteral("a\U00011136");
+
+ const auto smallThetaA = QStringLiteral("\u03b8a");
+ const auto ssaA = QStringLiteral("\u0937a");
+ const auto chakmaZeroA = QStringLiteral("\U00011136a");
+
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null-insert-0-theta") << null << smallThetaC << 0 << smallTheta;
+ QTest::newRow("null-insert-0-ssa") << null << ssaC << 0 << ssa;
+ QTest::newRow("null-insert-0-chakma") << null << chakmaZeroC << 0 << chakmaZero;
+
+ QTest::newRow("empty-insert-0-theta") << empty << smallThetaC << 0 << smallTheta;
+ QTest::newRow("empty-insert-0-ssa") << empty << ssaC << 0 << ssa;
+ QTest::newRow("empty-insert-0-chakma") << empty << chakmaZeroC << 0 << chakmaZero;
+
+ QTest::newRow("theta-insert-0-null") << smallTheta << nullC << 0 << smallTheta;
+ QTest::newRow("ssa-insert-0-null") << ssa << nullC << 0 << ssa;
+ QTest::newRow("chakma-insert-0-null") << chakmaZero << nullC << 0 << chakmaZero;
+
+ QTest::newRow("theta-insert-0-empty") << smallTheta << emptyC << 0 << smallTheta;
+ QTest::newRow("ssa-insert-0-empty") << ssa << emptyC << 0 << ssa;
+ QTest::newRow("chakma-insert-0-empty") << chakmaZero << emptyC << 0 << chakmaZero;
+
+ QTest::newRow("a-insert-0-theta") << a << smallThetaC << 0 << smallThetaA;
+ QTest::newRow("a-insert-0-ssa") << a << ssaC << 0 << ssaA;
+ QTest::newRow("a-insert-0-chakma") << a << chakmaZeroC << 0 << chakmaZeroA;
+ QTest::newRow("yumlaut-insert-0-theta") << yumlaut << smallThetaC << 0 << thetaUmlaut;
+ QTest::newRow("theta-insert-0-yumlaut") << smallTheta << yumlautC << 0 << umlautTheta;
+ QTest::newRow("ssa-insert-0-chakma") << ssa << chakmaZeroC << 0 << chakmaSsa;
+ QTest::newRow("chakma-insert-0-ssa") << chakmaZero << ssaC << 0 << ssaChakma;
+
+ QTest::newRow("theta-insert-1-null") << smallTheta << nullC << 1 << smallTheta;
+ QTest::newRow("ssa-insert-1-null") << ssa << nullC << 1 << ssa;
+ QTest::newRow("chakma-insert-1-null") << chakmaZero << nullC << 1 << chakmaZero;
+
+ QTest::newRow("theta-insert-1-empty") << smallTheta << emptyC << 1 << smallTheta;
+ QTest::newRow("ssa-insert-1-empty") << ssa << emptyC << 1 << ssa;
+ QTest::newRow("chakma-insert-1-empty") << chakmaZero << emptyC << 1 << chakmaZero;
+
+ QTest::newRow("a-insert-1-theta") << a << smallThetaC << 1 << aSmallTheta;
+ QTest::newRow("a-insert-1-ssa") << a << ssaC << 1 << aSsa;
+ QTest::newRow("a-insert-1-chakma") << a << chakmaZeroC << 1 << aChakmaZero;
+ QTest::newRow("yumlaut-insert-1-theta") << yumlaut << smallThetaC << 1 << umlautTheta;
+ QTest::newRow("theta-insert-1-yumlaut") << smallTheta << yumlautC << 1 << thetaUmlaut;
+ QTest::newRow("ssa-insert-1-chakma") << ssa << chakmaZeroC << 1 << ssaChakma;
+ // Beware, this will insert ssa right into the middle of the chakma:
+ // Actual (s) : "\uD804\u0937\uDD36"
+ // Expected (expected): "\uD804\uDD36\u0937"
+ // QTest::newRow("chakma.insert(1, ssa)") << chakmaZero << ssaC << 1 << chakmaSsa;
+ }
}
void tst_QString::insert_special_cases()
@@ -2698,17 +2842,20 @@ void tst_QString::insert_special_cases()
}
}
-void tst_QString::append_data(bool emptyIsNoop)
+void tst_QString::append_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
//const CharStarContainer abC("ab");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2716,6 +2863,9 @@ void tst_QString::append_data(bool emptyIsNoop)
//const QString b("b");
const QString ab("ab");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString aYumlaut = QStringLiteral("a\u00ff");
+
QTest::newRow("null + null") << null << nullC << null;
QTest::newRow("null + empty") << null << emptyC << (emptyIsNoop ? null : empty);
QTest::newRow("null + a") << null << aC << a;
@@ -2725,6 +2875,64 @@ void tst_QString::append_data(bool emptyIsNoop)
QTest::newRow("a + null") << a << nullC << a;
QTest::newRow("a + empty") << a << emptyC << a;
QTest::newRow("a + b") << a << bC << ab;
+
+ QTest::newRow("null+yumlaut") << null << yumlautC << yumlaut;
+ QTest::newRow("empty+yumlaut") << empty << yumlautC << yumlaut;
+ QTest::newRow("a+yumlaut") << a << yumlautC << aYumlaut;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto aSmallTheta = QStringLiteral("a\u03b8");
+ const auto aSsa = QStringLiteral("a\u0937");
+ const auto aChakmaZero = QStringLiteral("a\U00011136");
+
+ const auto thetaChakma = QStringLiteral("\u03b8\U00011136");
+ const auto chakmaTheta = QStringLiteral("\U00011136\u03b8");
+ const auto ssaTheta = QStringLiteral("\u0937\u03b8");
+ const auto thetaSsa = QStringLiteral("\u03b8\u0937");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto ssaUmlaut = QStringLiteral("\u0937\u00ff");
+ const auto umlautSsa = QStringLiteral("\u00ff\u0937");
+ const auto chakmaUmlaut = QStringLiteral("\U00011136\u00ff");
+ const auto umlautChakma = QStringLiteral("\u00ff\U00011136");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null+smallTheta") << null << smallThetaC << smallTheta;
+ QTest::newRow("empty+smallTheta") << empty << smallThetaC << smallTheta;
+ QTest::newRow("a+smallTheta") << a << smallThetaC << aSmallTheta;
+
+ QTest::newRow("null+ssa") << null << ssaC << ssa;
+ QTest::newRow("empty+ssa") << empty << ssaC << ssa;
+ QTest::newRow("a+ssa") << a << ssaC << aSsa;
+
+ QTest::newRow("null+chakma") << null << chakmaZeroC << chakmaZero;
+ QTest::newRow("empty+chakma") << empty << chakmaZeroC << chakmaZero;
+ QTest::newRow("a+chakma") << a << chakmaZeroC << aChakmaZero;
+
+ QTest::newRow("smallTheta+chakma") << smallTheta << chakmaZeroC << thetaChakma;
+ QTest::newRow("chakma+smallTheta") << chakmaZero << smallThetaC << chakmaTheta;
+ QTest::newRow("smallTheta+ssa") << smallTheta << ssaC << thetaSsa;
+
+ QTest::newRow("ssa+smallTheta") << ssa << smallThetaC << ssaTheta;
+ QTest::newRow("ssa+chakma") << ssa << chakmaZeroC << ssaChakma;
+ QTest::newRow("chakma+ssa") << chakmaZero << ssaC << chakmaSsa;
+
+ QTest::newRow("smallTheta+yumlaut") << smallTheta << yumlautC << thetaUmlaut;
+ QTest::newRow("yumlaut+smallTheta") << yumlaut << smallThetaC << umlautTheta;
+ QTest::newRow("ssa+yumlaut") << ssa << yumlautC << ssaUmlaut;
+ QTest::newRow("yumlaut+ssa") << yumlaut << ssaC << umlautSsa;
+ QTest::newRow("chakma+yumlaut") << chakmaZero << yumlautC << chakmaUmlaut;
+ QTest::newRow("yumlaut+chakma") << yumlaut << chakmaZeroC << umlautChakma;
+ }
}
void tst_QString::append_special_cases()
@@ -2873,9 +3081,9 @@ void tst_QString::operator_pluseq_special_cases()
}
}
-void tst_QString::operator_pluseq_data(bool emptyIsNoop)
+void tst_QString::operator_pluseq_data(DataOptions options)
{
- append_data(emptyIsNoop);
+ append_data(options);
}
void tst_QString::operator_pluseq_bytearray_special_cases_data()
@@ -2940,17 +3148,20 @@ void tst_QString::swap()
QCOMPARE(s2,QLatin1String("s1"));
}
-void tst_QString::prepend_data(bool emptyIsNoop)
+void tst_QString::prepend_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
const CharStarContainer baC("ba");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2958,6 +3169,9 @@ void tst_QString::prepend_data(bool emptyIsNoop)
//const QString b("b");
const QString ba("ba");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString yumlautA = QStringLiteral("\u00ffa");
+
QTest::newRow("null.prepend(null)") << null << nullC << null;
QTest::newRow("null.prepend(empty)") << null << emptyC << (emptyIsNoop ? null : empty);
QTest::newRow("null.prepend(a)") << null << aC << a;
@@ -2968,6 +3182,62 @@ void tst_QString::prepend_data(bool emptyIsNoop)
QTest::newRow("a.prepend(empty)") << a << emptyC << a;
QTest::newRow("a.prepend(b)") << a << bC << ba;
QTest::newRow("a.prepend(ba)") << a << baC << (ba + a);
+
+ QTest::newRow("null-prepend-yumlaut") << null << yumlautC << yumlaut;
+ QTest::newRow("empty-prepend-yumlaut") << empty << yumlautC << yumlaut;
+ QTest::newRow("a-prepend-yumlaut") << a << yumlautC << yumlautA;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto smallThetaA = QStringLiteral("\u03b8a");
+ const auto ssaA = QStringLiteral("\u0937a");
+ const auto chakmaZeroA = QStringLiteral("\U00011136a");
+
+ const auto thetaChakma = QStringLiteral("\u03b8\U00011136");
+ const auto chakmaTheta = QStringLiteral("\U00011136\u03b8");
+ const auto ssaTheta = QStringLiteral("\u0937\u03b8");
+ const auto thetaSsa = QStringLiteral("\u03b8\u0937");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto ssaUmlaut = QStringLiteral("\u0937\u00ff");
+ const auto umlautSsa = QStringLiteral("\u00ff\u0937");
+ const auto chakmaUmlaut = QStringLiteral("\U00011136\u00ff");
+ const auto umlautChakma = QStringLiteral("\u00ff\U00011136");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null-prepend-smallTheta") << null << smallThetaC << smallTheta;
+ QTest::newRow("empty-prepend-smallTheta") << empty << smallThetaC << smallTheta;
+ QTest::newRow("a-prepend-smallTheta") << a << smallThetaC << smallThetaA;
+
+ QTest::newRow("null-prepend-ssa") << null << ssaC << ssa;
+ QTest::newRow("empty-prepend-ssa") << empty << ssaC << ssa;
+ QTest::newRow("a-prepend-ssa") << a << ssaC << ssaA;
+
+ QTest::newRow("null-prepend-chakma") << null << chakmaZeroC << chakmaZero;
+ QTest::newRow("empty-prepend-chakma") << empty << chakmaZeroC << chakmaZero;
+ QTest::newRow("a-prepend-chakma") << a << chakmaZeroC << chakmaZeroA;
+
+ QTest::newRow("smallTheta-prepend-chakma") << smallTheta << chakmaZeroC << chakmaTheta;
+ QTest::newRow("chakma-prepend-smallTheta") << chakmaZero << smallThetaC << thetaChakma;
+ QTest::newRow("smallTheta-prepend-ssa") << smallTheta << ssaC << ssaTheta;
+ QTest::newRow("ssa-prepend-smallTheta") << ssa << smallThetaC << thetaSsa;
+ QTest::newRow("ssa-prepend-chakma") << ssa << chakmaZeroC << chakmaSsa;
+ QTest::newRow("chakma-prepend-ssa") << chakmaZero << ssaC << ssaChakma;
+ QTest::newRow("smallTheta-prepend-yumlaut") << smallTheta << yumlautC << umlautTheta;
+ QTest::newRow("yumlaut-prepend-smallTheta") << yumlaut << smallThetaC << thetaUmlaut;
+ QTest::newRow("ssa-prepend-yumlaut") << ssa << yumlautC << umlautSsa;
+ QTest::newRow("yumlaut-prepend-ssa") << yumlaut << ssaC << ssaUmlaut;
+ QTest::newRow("chakma-prepend-yumlaut") << chakmaZero << yumlautC << umlautChakma;
+ QTest::newRow("yumlaut-prepend-chakma") << yumlaut << chakmaZeroC << chakmaUmlaut;
+ }
}
void tst_QString::prepend_bytearray_special_cases_data()
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index e4f3759c6f..cf406293e4 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -130,6 +130,7 @@ private Q_SLOTS:
void overload_QAnyStringView() { overload<QAnyStringView>(); }
void overload_QLatin1String() { overload<QLatin1String>(); }
void overload_QByteArray() { overload<QByteArray>(); }
+ void overload_QByteArrayView() { overload<QByteArrayView>(); }
void overload_const_char_star() { overload<const char*>(); }
void overload_const_char8_t_star() { IF_CHAR8T(overload<const char8_t*>()); }
void overload_const_char16_t_star() { overload<const char16_t*>(); }
@@ -160,7 +161,7 @@ private:
void compare_impl() const;
private Q_SLOTS:
- // test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray, const char*}
+ // test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray/View, const char*}
void compare_QChar_QChar_data() { compare_data(false); }
void compare_QChar_QChar() { compare_impl<QChar, QChar>(); }
void compare_QChar_char16_t_data() { compare_data(false); }
@@ -175,6 +176,8 @@ private Q_SLOTS:
void compare_QChar_QLatin1String() { compare_impl<QChar, QLatin1String>(); }
void compare_QChar_QByteArray_data() { compare_data(false); }
void compare_QChar_QByteArray() { compare_impl<QChar, QByteArray>(); }
+ void compare_QChar_QByteArrayView_data() { compare_data(false); }
+ void compare_QChar_QByteArrayView() { compare_impl<QChar, QByteArrayView>(); }
void compare_QChar_const_char_star_data() { compare_data(false); }
void compare_QChar_const_char_star() { compare_impl<QChar, const char *>(); }
@@ -192,6 +195,8 @@ private Q_SLOTS:
void compare_char16_t_QLatin1String() { compare_impl<char16_t, QLatin1String>(); }
void compare_char16_t_QByteArray_data() { compare_data(false); }
void compare_char16_t_QByteArray() { compare_impl<char16_t, QByteArray>(); }
+ void compare_char16_t_QByteArrayView_data() { compare_data(false); }
+ void compare_char16_t_QByteArrayView() { compare_impl<char16_t, QByteArrayView>(); }
//void compare_char16_t_const_char_star_data() { compare_data(false); }
//void compare_char16_t_const_char_star() { compare_impl<char16_t, const char *>(); }
@@ -209,6 +214,8 @@ private Q_SLOTS:
void compare_QString_QLatin1String() { compare_impl<QString, QLatin1String>(); }
void compare_QString_QByteArray_data() { compare_data(); }
void compare_QString_QByteArray() { compare_impl<QString, QByteArray>(); }
+ void compare_QString_QByteArrayView_data() { compare_data(); }
+ void compare_QString_QByteArrayView() { compare_impl<QString, QByteArrayView>(); }
void compare_QString_const_char_star_data() { compare_data(); }
void compare_QString_const_char_star() { compare_impl<QString, const char *>(); }
@@ -220,13 +227,17 @@ private Q_SLOTS:
void compare_QStringView_QString() { compare_impl<QStringView, QString>(); }
void compare_QStringView_QStringView_data() { compare_data(); }
void compare_QStringView_QStringView() { compare_impl<QStringView, QStringView>(); }
+#ifdef NOT_YET_IMPLEMENTED
void compare_QStringView_QUtf8StringView_data() { compare_data(); }
- void compare_QStringView_QUtf8StringView() { compare_impl<QStringView, QStringView>(); }
+ void compare_QStringView_QUtf8StringView() { compare_impl<QStringView, QUtf8StringView>(); }
+#endif
void compare_QStringView_QLatin1String_data() { compare_data(); }
void compare_QStringView_QLatin1String() { compare_impl<QStringView, QLatin1String>(); }
#ifdef NOT_YET_IMPLMENTED
void compare_QStringView_QByteArray_data() { compare_data(); }
void compare_QStringView_QByteArray() { compare_impl<QStringView, QByteArray>(); }
+ void compare_QStringView_QByteArrayView_data() { compare_data(); }
+ void compare_QStringView_QByteArrayView() { compare_impl<QStringView, QByteArrayView>(); }
void compare_QStringView_const_char_star_data() { compare_data(); }
void compare_QStringView_const_char_star() { compare_impl<QStringView, const char *>(); }
#endif
@@ -246,6 +257,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLMENTED
void compare_QUtf8StringView_QByteArray_data() { compare_data(); }
void compare_QUtf8StringView_QByteArray() { compare_impl<QUtf8StringView, QByteArray>(); }
+ void compare_QUtf8StringView_QByteArrayView_data() { compare_data(); }
+ void compare_QUtf8StringView_QByteArrayView() { compare_impl<QUtf8StringView, QByteArrayView>(); }
void compare_QUtf8StringView_const_char_star_data() { compare_data(); }
void compare_QUtf8StringView_const_char_star() { compare_impl<QUtf8StringView, const char *>(); }
#endif
@@ -264,6 +277,10 @@ private Q_SLOTS:
void compare_QLatin1String_QLatin1String() { compare_impl<QLatin1String, QLatin1String>(); }
void compare_QLatin1String_QByteArray_data() { compare_data(); }
void compare_QLatin1String_QByteArray() { compare_impl<QLatin1String, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QLatin1String_QByteArrayView_data() { compare_data(); }
+ void compare_QLatin1String_QByteArrayView() { compare_impl<QLatin1String, QByteArrayView>(); }
+#endif
void compare_QLatin1String_const_char_star_data() { compare_data(); }
void compare_QLatin1String_const_char_star() { compare_impl<QLatin1String, const char *>(); }
@@ -283,9 +300,38 @@ private Q_SLOTS:
void compare_QByteArray_QLatin1String() { compare_impl<QByteArray, QLatin1String>(); }
void compare_QByteArray_QByteArray_data() { compare_data(); }
void compare_QByteArray_QByteArray() { compare_impl<QByteArray, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArray_QByteArrayView_data() { compare_data(); }
+ void compare_QByteArray_QByteArrayView() { compare_impl<QByteArray, QByteArrayView>(); }
+#endif
void compare_QByteArray_const_char_star_data() { compare_data(); }
void compare_QByteArray_const_char_star() { compare_impl<QByteArray, const char *>(); }
+ void compare_QByteArrayView_QChar_data() { compare_data(false); }
+ void compare_QByteArrayView_QChar() { compare_impl<QByteArrayView, QChar>(); }
+ void compare_QByteArrayView_char16_t_data() { compare_data(false); }
+ void compare_QByteArrayView_char16_t() { compare_impl<QByteArrayView, char16_t>(); }
+ void compare_QByteArrayView_QString_data() { compare_data(); }
+ void compare_QByteArrayView_QString() { compare_impl<QByteArrayView, QString>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void compare_QByteArrayView_QStringView_data() { compare_data(); }
+ void compare_QByteArrayView_QStringView() { compare_impl<QByteArrayView, QStringView>(); }
+#endif
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArrayView_QUtf8StringView_data() { compare_data(); }
+ void compare_QByteArrayView_QUtf8StringView() { compare_impl<QByteArrayView, QUtf8StringView>(); }
+ void compare_QByteArrayView_QLatin1String_data() { compare_data(); }
+ void compare_QByteArrayView_QLatin1String() { compare_impl<QByteArrayView, QLatin1String>(); }
+ void compare_QByteArrayView_QByteArray_data() { compare_data(); }
+ void compare_QByteArrayView_QByteArray() { compare_impl<QByteArrayView, QByteArray>(); }
+#endif
+ void compare_QByteArrayView_QByteArrayView_data() { compare_data(); }
+ void compare_QByteArrayView_QByteArrayView() { compare_impl<QByteArrayView, QByteArrayView>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArrayView_const_char_star_data() { compare_data(); }
+ void compare_QByteArrayView_const_char_star() { compare_impl<QByteArrayView, const char *>(); }
+#endif
+
void compare_const_char_star_QChar_data() { compare_data(false); }
void compare_const_char_star_QChar() { compare_impl<const char *, QChar>(); }
//void compare_const_char_star_char16_t_data() { compare_data(false); }
@@ -298,6 +344,10 @@ private Q_SLOTS:
void compare_const_char_star_QLatin1String() { compare_impl<const char *, QLatin1String>(); }
void compare_const_char_star_QByteArray_data() { compare_data(); }
void compare_const_char_star_QByteArray() { compare_impl<const char *, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_const_char_star_QByteArrayView_data() { compare_data(); }
+ void compare_const_char_star_QByteArrayView() { compare_impl<const char *, QByteArrayView>(); }
+#endif
//void compare_const_char_star_const_char_star_data() { compare_data(); }
//void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
@@ -321,6 +371,8 @@ private Q_SLOTS:
void member_compare_QChar_QLatin1String() { member_compare_impl<QChar, QLatin1String>(); }
void member_compare_QChar_QByteArray_data() { member_compare_data(false); }
void member_compare_QChar_QByteArray() { member_compare_impl<QChar, QByteArray>(); }
+ void member_compare_QChar_QByteArrayView_data() { member_compare_data(false); }
+ void member_compare_QChar_QByteArrayView() { member_compare_impl<QChar, QByteArrayView>(); }
void member_compare_QChar_const_char_star_data() { member_compare_data(false); }
void member_compare_QChar_const_char_star() { member_compare_impl<QChar, const char *>(); }
#endif
@@ -339,6 +391,10 @@ private Q_SLOTS:
void member_compare_QString_QLatin1String() { member_compare_impl<QString, QLatin1String>(); }
void member_compare_QString_QByteArray_data() { member_compare_data(); }
void member_compare_QString_QByteArray() { member_compare_impl<QString, QByteArray>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QString_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QString_QByteArrayView() { member_compare_impl<QString, QByteArrayView>(); }
+#endif
void member_compare_QString_const_char_star_data() { member_compare_data(); }
void member_compare_QString_const_char_star() { member_compare_impl<QString, const char *>(); }
@@ -355,6 +411,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QStringView_QByteArray_data() { member_compare_data(); }
void member_compare_QStringView_QByteArray() { member_compare_impl<QStringView, QByteArray>(); }
+ void member_compare_QStringView_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QStringView_QByteArrayView() { member_compare_impl<QStringView, QByteArrayView>(); }
void member_compare_QStringView_const_char_star_data() { member_compare_data(); }
void member_compare_QStringView_const_char_star() { member_compare_impl<QStringView, const char *>(); }
#endif
@@ -374,9 +432,13 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QLatin1String_QByteArray_data() { member_compare_data(); }
void member_compare_QLatin1String_QByteArray() { member_compare_impl<QLatin1String, QByteArray>(); }
+ void member_compare_QLatin1String_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QByteArrayView() { member_compare_impl<QLatin1String, QByteArrayView>(); }
void member_compare_QLatin1String_const_char_star_data() { member_compare_data(); }
void member_compare_QLatin1String_const_char_star() { member_compare_impl<QLatin1String, const char *>(); }
+#endif
+#ifdef NOT_YET_IMPLEMENTED
void member_compare_QByteArray_QChar_data() { member_compare_data(false); }
void member_compare_QByteArray_QChar() { member_compare_impl<QByteArray, QChar>(); }
void member_compare_QByteArray_char16_t_data() { member_compare_data(false); }
@@ -388,9 +450,28 @@ private Q_SLOTS:
#endif
void member_compare_QByteArray_QByteArray_data() { member_compare_data(); }
void member_compare_QByteArray_QByteArray() { member_compare_impl<QByteArray, QByteArray>(); }
+ void member_compare_QByteArray_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QByteArray_QByteArrayView() { member_compare_impl<QByteArray, QByteArrayView>(); }
void member_compare_QByteArray_const_char_star_data() { member_compare_data(); }
void member_compare_QByteArray_const_char_star() { member_compare_impl<QByteArray, const char *>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QByteArrayView_QChar_data() { member_compare_data(false); }
+ void member_compare_QByteArrayView_QChar() { member_compare_impl<QByteArrayView, QChar>(); }
+ void member_compare_QByteArrayView_char16_t_data() { member_compare_data(false); }
+ void member_compare_QByteArrayView_char16_t() { member_compare_impl<QByteArrayView, char16_t>(); }
+ void member_compare_QByteArrayView_QString_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QString() { member_compare_impl<QByteArrayView, QString>(); }
+ void member_compare_QByteArrayView_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QLatin1String() { member_compare_impl<QByteArrayView, QLatin1String>(); }
+#endif
+ void member_compare_QByteArrayView_QByteArray_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QByteArray() { member_compare_impl<QByteArrayView, QByteArray>(); }
+ void member_compare_QByteArrayView_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QByteArrayView() { member_compare_impl<QByteArrayView, QByteArrayView>(); }
+ void member_compare_QByteArrayView_const_char_star_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_const_char_star() { member_compare_impl<QByteArrayView, const char *>(); }
+
private:
void localeAwareCompare_data();
template<typename LHS, typename RHS>
@@ -667,6 +748,8 @@ private Q_SLOTS:
void sliced_QUtf8StringView() { sliced_impl<QUtf8StringView>(); }
void sliced_QByteArray_data() { sliced_data(); }
void sliced_QByteArray() { sliced_impl<QByteArray>(); }
+ void sliced_QByteArrayView_data() { sliced_data(); }
+ void sliced_QByteArrayView() { sliced_impl<QByteArrayView>(); }
void first_truncate_QString_data() { first_data(); }
void first_truncate_QString() { first_impl<QString>(); }
@@ -678,6 +761,8 @@ private Q_SLOTS:
void first_truncate_QUtf8StringView() { first_impl<QUtf8StringView>(); }
void first_truncate_QByteArray_data() { first_data(); }
void first_truncate_QByteArray() { first_impl<QByteArray>(); }
+ void first_truncate_QByteArrayView_data() { first_data(); }
+ void first_truncate_QByteArrayView() { first_impl<QByteArrayView>(); }
void last_QString_data() { last_data(); }
void last_QString() { last_impl<QString>(); }
@@ -689,6 +774,8 @@ private Q_SLOTS:
void last_QUtf8StringView() { last_impl<QUtf8StringView>(); }
void last_QByteArray_data() { last_data(); }
void last_QByteArray() { last_impl<QByteArray>(); }
+ void last_QByteArrayView_data() { last_data(); }
+ void last_QByteArrayView() { last_impl<QByteArrayView>(); }
void chop_QString_data() { chop_data(); }
void chop_QString() { chop_impl<QString>(); }
@@ -700,6 +787,8 @@ private Q_SLOTS:
void chop_QLatin1String() { chop_impl<QLatin1String>(); }
void chop_QByteArray_data() { chop_data(); }
void chop_QByteArray() { chop_impl<QByteArray>(); }
+ void chop_QByteArrayView_data() { chop_data(); }
+ void chop_QByteArrayView() { chop_impl<QByteArrayView>(); }
private:
void trimmed_data();
@@ -714,6 +803,8 @@ private Q_SLOTS:
void trim_trimmed_QLatin1String() { trimmed_impl<QLatin1String>(); }
void trim_trimmed_QByteArray_data() { trimmed_data(); }
void trim_trimmed_QByteArray() { trimmed_impl<QByteArray>(); }
+ void trim_trimmed_QByteArrayView_data() { trimmed_data(); }
+ void trim_trimmed_QByteArrayView() { trimmed_impl<QByteArrayView>(); }
private:
void toNumber_data();
@@ -726,19 +817,23 @@ private Q_SLOTS:
void toNumber_QString() { toNumber_impl<QString>(); }
void toNumber_QStringView_data() { toNumber_data(); }
void toNumber_QStringView() { toNumber_impl<QStringView>(); }
- void toNumber_QByteArray_data() { toNumber_data(); }
- void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
void toNumber_QLatin1String_data() { toNumber_data(); }
void toNumber_QLatin1String() { toNumber_impl<QLatin1String>(); }
+ void toNumber_QByteArray_data() { toNumber_data(); }
+ void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
+ void toNumber_QByteArrayView_data() { toNumber_data(); }
+ void toNumber_QByteArrayView() { toNumber_impl<QByteArrayView>(); }
void toNumberWithBases_QString_data() { toNumberWithBases_data(); }
void toNumberWithBases_QString() { toNumberWithBases_impl<QString>(); }
void toNumberWithBases_QStringView_data() { toNumberWithBases_data(); }
void toNumberWithBases_QStringView() { toNumberWithBases_impl<QStringView>(); }
- void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
- void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
void toNumberWithBases_QLatin1String_data() { toNumberWithBases_data(); }
void toNumberWithBases_QLatin1String() { toNumberWithBases_impl<QLatin1String>(); }
+ void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
+ void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
+ void toNumberWithBases_QByteArrayView_data() { toNumberWithBases_data(); }
+ void toNumberWithBases_QByteArrayView() { toNumberWithBases_impl<QByteArrayView>(); }
private:
void count_data();
@@ -1179,6 +1274,7 @@ MAKE(QString) { return sv.toString(); }
MAKE(QStringView) { return sv; }
MAKE(QLatin1String) { return l1; }
MAKE(QByteArray) { return u8; }
+MAKE(QByteArrayView) { return u8; }
MAKE(const char *) { return u8.data(); }
MAKE(const char16_t *) { return sv.utf16(); } // assumes `sv` doesn't represent a substring
MAKE(std::u16string) { return sv.toString().toStdU16String(); }
@@ -1193,6 +1289,7 @@ MAKE(QAnyStringViewUsingU16) { return {QAnyStringView{sv}}; }
template <typename> constexpr bool is_bytearray_like_v = false;
template <> constexpr bool is_bytearray_like_v<const char *> = true;
template <> constexpr bool is_bytearray_like_v<QByteArray> = true;
+template <> constexpr bool is_bytearray_like_v<QByteArrayView> = true;
template <typename LHS, typename RHS>
constexpr bool has_nothrow_member_compare_v = is_bytearray_like_v<LHS> == is_bytearray_like_v<RHS>;
diff --git a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
index 89e8ae89b1..58d2fab09f 100644
--- a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
@@ -174,12 +174,12 @@ void tst_QStringList::sort()
list4 << "alpha" << "beta" << "BETA" << "epsilon" << "Gamma" << "gAmma" << "gamma";
// with this list, case insensitive sorting can give more than one permutation for "equivalent"
// elements; so we check that the sort gave the formally correct result (list[i] <= list[i+1])
- for (int i = 0; i < list4.count() - 1; ++i)
+ for (int i = 0; i < list4.size() - 1; ++i)
QVERIFY2(QString::compare(list4.at(i), list4.at(i + 1), Qt::CaseInsensitive) <= 0, qPrintable(QString("index %1 failed").arg(i)));
// additional checks
QCOMPARE(list4.at(0), QString("alpha"));
QVERIFY(list4.indexOf("epsilon") > 0);
- QVERIFY(list4.indexOf("epsilon") < (list4.count() - 1));
+ QVERIFY(list4.indexOf("epsilon") < (list4.size() - 1));
}
void tst_QStringList::replaceInStrings()
diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
index ccb12488a7..9eab2f6966 100644
--- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
+++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
@@ -854,7 +854,7 @@ void tst_QStringView::overloadResolution()
{
std::u16string string;
QStringViewOverloadResolution::test(string);
- QStringViewOverloadResolution::test(qAsConst(string));
+ QStringViewOverloadResolution::test(std::as_const(string));
QStringViewOverloadResolution::test(std::move(string));
}
}
diff --git a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 0b29740e53..ea7d2f6982 100644
--- a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -186,7 +186,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea
QVERIFY(boundaryFinder.boundaryReasons() == QTextBoundaryFinder::NotAtBoundary);
// test boundaryReasons()
- for (int i = 0; i <= testString.length(); ++i) {
+ for (int i = 0; i <= testString.size(); ++i) {
boundaryFinder.setPosition(i);
QCOMPARE(!!(boundaryFinder.boundaryReasons() & reasons), expectedBreakPositions.contains(i));
}
@@ -768,7 +768,7 @@ void tst_QTextBoundaryFinder::emptyText()
void tst_QTextBoundaryFinder::fastConstructor()
{
QString text("Hello World");
- QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.length(), /*buffer*/0, /*buffer size*/0);
+ QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.size(), /*buffer*/0, /*buffer size*/0);
QCOMPARE(finder.position(), 0);
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem);
@@ -782,7 +782,7 @@ void tst_QTextBoundaryFinder::fastConstructor()
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem);
finder.toNextBoundary();
- QCOMPARE(finder.position(), text.length());
+ QCOMPARE(finder.position(), text.size());
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::EndOfItem);
finder.toNextBoundary();
diff --git a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
index 15aec7d63e..5232a62778 100644
--- a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
+++ b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
@@ -47,7 +47,7 @@ static void verifyCharClassPattern(QString str, qulonglong pattern,
QCharAttributes cleared;
memset(&cleared, 0, sizeof(QCharAttributes));
QList<QCharAttributes> attributes(str.size() + 1, cleared);
- QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.count(),
+ QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.size(),
attributes.data(), type);
qulonglong bit = 1ull << str.size();