diff options
Diffstat (limited to 'tests/auto/corelib/tools')
16 files changed, 227 insertions, 47 deletions
diff --git a/tests/auto/corelib/tools/collections/collections.pro b/tests/auto/corelib/tools/collections/collections.pro index 5c04515fa0..b074fa9338 100644 --- a/tests/auto/corelib/tools/collections/collections.pro +++ b/tests/auto/corelib/tools/collections/collections.pro @@ -5,3 +5,4 @@ QT = core testlib # This test does not work with strict iterators DEFINES -= QT_STRICT_ITERATORS +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index b911be3ffb..e79a4dba29 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -67,7 +67,6 @@ void foo() #include <algorithm> -#include "qalgorithms.h" #include "qbitarray.h" #include "qbytearray.h" #include "qcache.h" @@ -191,16 +190,6 @@ void tst_Collections::list() QVERIFY(list.size() == 6); QVERIFY(list.end() - list.begin() == list.size()); -#if !defined(Q_CC_MSVC) && !defined(Q_CC_SUN) - QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true); - QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false); -#endif - QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qUpperBound(list.begin(), list.end(), 2) == list.begin() + 2); - QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qUpperBound(list.begin(), list.end(), 9) == list.end()); { int sum = 0; QListIterator<int> i(list); @@ -996,16 +985,8 @@ void tst_Collections::vector() v.append(2); QVERIFY(*v.begin() == 2); v.prepend(1); - - v << 3 << 4 << 5 << 6; - QVERIFY(std::binary_search(v.begin(), v.end(), 2) == true); - QVERIFY(std::binary_search(v.begin(), v.end(), 9) == false); - QVERIFY(qBinaryFind(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qLowerBound(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qUpperBound(v.begin(), v.end(), 2) == v.begin() + 2); - QVERIFY(qBinaryFind(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qLowerBound(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qUpperBound(v.begin(), v.end(), 9) == v.end()); + QVERIFY(*v.begin() == 1); + QVERIFY(*(v.begin() + 1) == 2); v.clear(); v << 1 << 2 << 3; @@ -1370,7 +1351,7 @@ void tst_Collections::hash() { typedef QHash<QString, QString> Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { @@ -2013,13 +1994,17 @@ void tst_Collections::qstring() QString nonNull = ""; QVERIFY(null.left(10).isNull()); QVERIFY(null.mid(0).isNull()); + QVERIFY(null.isNull()); + QVERIFY(!nonNull.isNull()); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(null == QString::null); QVERIFY(QString::null == null); QVERIFY(nonNull != QString::null); QVERIFY(QString::null != nonNull); QVERIFY(null == nonNull); QVERIFY(QString::null == QString::null); +#endif QString fill = "123"; fill.fill('a'); diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 06db0e8546..18432e51a6 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -48,6 +48,11 @@ class tst_QAlgorithms : public QObject { Q_OBJECT private slots: + void swap(); + void swap2(); + void convenienceAPI(); + +#if QT_DEPRECATED_SINCE(5, 2) void test_qLowerBound_data(); void test_qLowerBound(); void test_qUpperBound_data(); @@ -55,19 +60,23 @@ private slots: void test_qBinaryFind_data(); void test_qBinaryFind(); void qBinaryFindOneEntry(); - void swap(); - void swap2(); void sortEmptyList(); void sortedList(); void sortAPItest(); void stableSortTest(); void stableSortCorrectnessTest_data(); void stableSortCorrectnessTest(); - void convenienceAPI(); + void convenienceAPI_deprecated(); void qCountIterators() const; void qCountContainer() const; void binaryFindOnLargeContainer() const; +#if Q_TEST_PERFORMANCE + void performance(); +#endif + +#endif // QT_DEPRECATED_SINCE(5, 2) + void popCount08_data() { popCount_data_impl(sizeof(quint8 )); } void popCount16_data() { popCount_data_impl(sizeof(quint16)); } void popCount32_data() { popCount_data_impl(sizeof(quint32)); } @@ -96,9 +105,6 @@ private slots: void countLeading64() { countLeading_impl<quint64>(); } private: -#if Q_TEST_PERFORMANCE - void performance(); -#endif void popCount_data_impl(size_t sizeof_T_Int); template <typename T_Int> void popCount_impl(); @@ -112,6 +118,8 @@ private: void countLeading_impl(); }; +#if QT_DEPRECATED_SINCE(5, 2) + class TestInt { public: @@ -172,7 +180,7 @@ ResultSet testRun(ContainerType &container, Algorithm &algorithm, int millisecs) { TestInt::lessThanRefCount = 0; int count = 0; - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() < millisecs) { ++count; @@ -257,6 +265,8 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes) } #endif +#endif // QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::swap() { { @@ -391,6 +401,17 @@ void tst_QAlgorithms::swap2() } } +void tst_QAlgorithms::convenienceAPI() +{ + // Compile-test for QAlgorithm convenience functions. + + QList<int *> pointerList; + qDeleteAll(pointerList); + qDeleteAll(pointerList.begin(), pointerList.end()); +} + +#if QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::sortEmptyList() { // Only test if it crashes @@ -676,7 +697,7 @@ void tst_QAlgorithms::stableSortCorrectnessTest() QVERIFY(isSorted(sorted)); } -void tst_QAlgorithms::convenienceAPI() +void tst_QAlgorithms::convenienceAPI_deprecated() { // Compile-test for QAlgorithm convenience functions. QList<int> list, list2; @@ -716,10 +737,6 @@ void tst_QAlgorithms::convenienceAPI() qBinaryFind(list, 1); qBinaryFind(list.begin(), list.end(), 1); qBinaryFind(list.begin(), list.end(), 1, qLess<int>()); - - QList<int *> pointerList; - qDeleteAll(pointerList); - qDeleteAll(pointerList.begin(), pointerList.end()); } template <typename DataType> @@ -1041,6 +1058,8 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const QCOMPARE(foundIt.pos(), 1073987655); } +#endif // QT_DEPRECATED_SINCE(5, 2) + // alternative implementation of qPopulationCount for comparison: static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 7db7d71b1f..25e2f21d03 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -1625,6 +1625,18 @@ void tst_QArrayData::literals() QCOMPARE(const_(v)[i], char('A' + i)); QCOMPARE(const_(v)[10], char('\0')); } + + { + struct LiteralType { + int value; + Q_DECL_CONSTEXPR LiteralType(int v = 0) : value(v) {} + }; + + QArrayDataPointer<LiteralType> d = Q_ARRAY_LITERAL(LiteralType, LiteralType(0), LiteralType(1), LiteralType(2)); + QCOMPARE(d->size, 3); + for (int i = 0; i < 3; ++i) + QCOMPARE(d->data()[i].value, i); + } } // Variadic Q_ARRAY_LITERAL need to be available in the current configuration. diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index b9bcecd607..513c811788 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -74,10 +74,12 @@ int main(int argc, char *argv[]) hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR")); hiddenOption.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(hiddenOption); +#if QT_DEPRECATED_SINCE(5, 8) QCommandLineOption hiddenOption2(QStringList() << QStringLiteral("hidden2")); hiddenOption2.setDescription(QStringLiteral("NEITHER SHOULD THIS")); hiddenOption2.setHidden(true); parser.addOption(hiddenOption2); +#endif // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. diff --git a/tests/auto/corelib/tools/qhash/qhash.pro b/tests/auto/corelib/tools/qhash/qhash.pro index 79ffd4e9d1..e96c0d1bf1 100644 --- a/tests/auto/corelib/tools/qhash/qhash.pro +++ b/tests/auto/corelib/tools/qhash/qhash.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qhash QT = core testlib SOURCES = $$PWD/tst_qhash.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index d70d488e96..f0aaad98bd 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -273,7 +273,7 @@ void tst_QHash::insert1() { typedef QHash<QString, QString> Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 915a24a1f6..0418daf640 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -53,8 +53,10 @@ private slots: void testNormalVector(); void testNormalVector_data(); +#if QT_DEPRECATED_SINCE(5, 14) void testAngle(); void testAngle_data(); +#endif void testAngle2(); void testAngle2_data(); @@ -378,6 +380,7 @@ void tst_QLine::testNormalVector() QCOMPARE(n.dy(), qreal(nvy)); } +#if QT_DEPRECATED_SINCE(5, 14) void tst_QLine::testAngle_data() { QTest::addColumn<double>("xa1"); @@ -426,6 +429,7 @@ void tst_QLine::testAngle() double resultAngle = a.angle(b); QCOMPARE(qRound(resultAngle), qRound(angle)); } +#endif void tst_QLine::testAngle2_data() { diff --git a/tests/auto/corelib/tools/qmap/qmap.pro b/tests/auto/corelib/tools/qmap/qmap.pro index 27820a76c8..2cc772720d 100644 --- a/tests/auto/corelib/tools/qmap/qmap.pro +++ b/tests/auto/corelib/tools/qmap/qmap.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qmap QT = core testlib SOURCES = $$PWD/tst_qmap.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro index 10ae3307d1..d0c6337147 100644 --- a/tests/auto/corelib/tools/qset/qset.pro +++ b/tests/auto/corelib/tools/qset/qset.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qset QT = core testlib SOURCES = tst_qset.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 187b73eeec..f3c647515a 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -75,8 +75,10 @@ private slots: void functionCallDownCast(); void upCast(); void qobjectWeakManagement(); +#if QT_DEPRECATED_SINCE(5, 0) void noSharedPointerFromWeakQObject(); void sharedPointerFromQObjectWithWeak(); +#endif void weakQObjectFromSharedPointer(); void objectCast(); void objectCastStdSharedPtr(); @@ -882,6 +884,78 @@ void tst_QSharedPointer::qobjectWeakManagement() QWeakPointer<QObject> weak; weak = QWeakPointer<QObject>(); QVERIFY(weak.isNull()); + QVERIFY(weak.toStrongRef().isNull()); + } + + { + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, bit with operator= + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak; + weak = shared; + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // with two QWeakPointers + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + + { + QWeakPointer<QObject> weak2(shared); + QVERIFY(!weak2.isNull()); + QVERIFY(weak == weak2); + } + QVERIFY(!weak.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, but delete the pointer while two QWeakPointers exist + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + + { + QWeakPointer<QObject> weak2(shared); + QVERIFY(!weak2.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + QVERIFY(weak2.isNull()); + } + QVERIFY(weak.isNull()); + } + safetyCheck(); + +#if QT_DEPRECATED_SINCE(5, 0) + { + QWeakPointer<QObject> weak; + weak = QWeakPointer<QObject>(); + QVERIFY(weak.isNull()); QVERIFY(!weak.data()); } @@ -972,8 +1046,10 @@ void tst_QSharedPointer::qobjectWeakManagement() QVERIFY(weak.isNull()); } safetyCheck(); +#endif } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QSharedPointer::noSharedPointerFromWeakQObject() { // you're not allowed to create a QSharedPointer from an unmanaged QObject @@ -1007,18 +1083,32 @@ void tst_QSharedPointer::sharedPointerFromQObjectWithWeak() } QVERIFY(weak.isNull()); } +#endif void tst_QSharedPointer::weakQObjectFromSharedPointer() { - // this is the inverse of the above: you're allowed to create a QWeakPointer - // from a managed QObject - QSharedPointer<QObject> shared(new QObject); - QWeakPointer<QObject> weak = shared.data(); - QVERIFY(!weak.isNull()); +#if QT_DEPRECATED_SINCE(5, 0) + { + // this is the inverse of the above: you're allowed to create a QWeakPointer + // from a managed QObject + QSharedPointer<QObject> shared(new QObject); + QWeakPointer<QObject> weak = shared.data(); + QVERIFY(!weak.isNull()); - // delete: - shared.clear(); - QVERIFY(weak.isNull()); + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } +#endif + { + QSharedPointer<QObject> shared(new QObject); + QWeakPointer<QObject> weak = shared; + QVERIFY(!weak.isNull()); + + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } } void tst_QSharedPointer::objectCast() @@ -2376,6 +2466,7 @@ void tst_QSharedPointer::qvariantCast() // Intentionally does not compile. // QSharedPointer<int> sop = qSharedPointerFromVariant<int>(v); +#if QT_DEPRECATED_SINCE(5, 0) v = QVariant::fromValue(sp.toWeakRef()); { @@ -2419,6 +2510,7 @@ void tst_QSharedPointer::qvariantCast() QWeakPointer<QThread> other = qWeakPointerFromVariant<QThread>(v); QVERIFY(!other); } +#endif } class SomeClass : public QEnableSharedFromThis<SomeClass> diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 79f5a8c46d..e4aa00f500 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -521,7 +521,9 @@ private slots: void stringRef_local8Bit_data(); void stringRef_local8Bit(); void fromLatin1(); +#if QT_DEPRECATED_SINCE(5, 0) void fromAscii(); +#endif void fromUcs4(); void toUcs4(); void arg(); @@ -4284,9 +4286,9 @@ void tst_QString::fromLocal8Bit_data() //QTest::newRow("null5") << QByteArray() << 5 << QString(); //QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << -1 << QString(); //QTest::newRow("empty0") << QByteArray() << 0 << QString(); - //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromAscii("\0abcd", 5); - //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromAscii("ab"); - //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromAscii("ab\0cd", 5); + //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromLatin1("\0abcd", 5); + //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromLatin1("ab"); + //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromLatin1("ab\0cd", 5); } void tst_QString::fromLocal8Bit() @@ -4590,6 +4592,7 @@ void tst_QString::fromLatin1() QVERIFY(a.size() == 5); } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QString::fromAscii() { QString a; @@ -4610,6 +4613,7 @@ void tst_QString::fromAscii() a = QString::fromAscii("\0abcd", 5); QVERIFY(a.size() == 5); } +#endif void tst_QString::fromUcs4() { diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 2b5aa8e98b..66d4744454 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -259,6 +259,12 @@ void tst_QStringList::filter() list5 = list5.filter( QRegularExpression("[i]ll") ); list6 << "Bill Gates" << "Bill Clinton"; QCOMPARE( list5, list6 ); + + QStringList list7, list8; + list7 << "Bill Gates" << "Joe Blow" << "Bill Clinton"; + list7 = list7.filter( QStringView(QString("Bill")) ); + list8 << "Bill Gates" << "Bill Clinton"; + QCOMPARE( list7, list8 ); } void tst_QStringList::sort() @@ -316,6 +322,16 @@ void tst_QStringList::replaceInStrings() list10 << "Bill Clinton" << "Bill Gates"; list9.replaceInStrings( QRegularExpression("^(.*), (.*)$"), "\\2 \\1" ); QCOMPARE( list9, list10 ); + + QStringList list11, list12, list13, list14; + list11 << "alpha" << "beta" << "gamma" << "epsilon"; + list12 << "alpha" << "beta" << "gamma" << "epsilon"; + list13 << "alpha" << "beta" << "gamma" << "epsilon"; + list11.replaceInStrings( QStringView(QString("a")), QStringView(QString("o")) ); + list12.replaceInStrings( QStringView(QString("a")), QString("o") ); + list13.replaceInStrings( QString("a"), QStringView(QString("o")) ); + list14 << "olpho" << "beto" << "gommo" << "epsilon"; + QCOMPARE( list11, list12 ); } void tst_QStringList::contains() @@ -427,6 +443,7 @@ void tst_QStringList::join() const QCOMPARE(input.join(separator), expectedResult); QCOMPARE(input.join(QLatin1String(separator.toLatin1())), expectedResult); + QCOMPARE(input.join(QStringView(separator)), expectedResult); } void tst_QStringList::join_data() const diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index 581e9152e6..6f01947131 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -596,7 +596,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("C")); QVERIFY(!ref.startsWith("ABCDEF")); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(ref.startsWith('A')); QVERIFY(ref.startsWith(QLatin1Char('A'))); QVERIFY(ref.startsWith(QChar('A'))); @@ -623,7 +626,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.startsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.startsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.startsWith('a', Qt::CaseInsensitive)); QVERIFY(ref.startsWith('A', Qt::CaseInsensitive)); QVERIFY(ref.startsWith(QLatin1Char('a'), Qt::CaseInsensitive)); @@ -656,7 +662,10 @@ void tst_QStringRef::startsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(ref.startsWith(QLatin1String(""))); @@ -670,7 +679,10 @@ void tst_QStringRef::startsWith() { const QStringRef ref; QVERIFY(!ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(!ref.startsWith(QLatin1String(""))); @@ -693,7 +705,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("C")); QVERIFY(!ref.endsWith("ABCDEF")); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(ref.endsWith('B')); QVERIFY(ref.endsWith(QLatin1Char('B'))); QVERIFY(ref.endsWith(QChar('B'))); @@ -720,7 +735,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.endsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.endsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.endsWith('b', Qt::CaseInsensitive)); QVERIFY(ref.endsWith('B', Qt::CaseInsensitive)); QVERIFY(ref.endsWith(QLatin1Char('b'), Qt::CaseInsensitive)); @@ -754,7 +772,10 @@ void tst_QStringRef::endsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1Char(0))); QVERIFY(!ref.endsWith(QLatin1Char('x'))); @@ -768,7 +789,10 @@ void tst_QStringRef::endsWith() { QStringRef ref; QVERIFY(!ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1String(""))); diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 5467d438a3..a46011ff6c 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -192,7 +192,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea // test toPreviousBoundary() { QList<int> expectedBreakPositionsRev = expectedBreakPositions; - std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), qGreater<int>()); + std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), std::greater<int>()); QList<int> actualBreakPositions; boundaryFinder.toEnd(); @@ -539,6 +539,13 @@ void tst_QTextBoundaryFinder::sentenceBoundaries_manual_data() QTest::newRow("data3") << testString << expectedBreakPositions; } + { + QString testString(QString::fromUtf8("Doing TEST, doing another test.")); + QList<int> expectedBreakPositions; + expectedBreakPositions << 0 << 31; + + QTest::newRow("data4") << testString << expectedBreakPositions; + } } void tst_QTextBoundaryFinder::sentenceBoundaries_manual() diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index fff8c75a90..070c25368b 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -57,6 +57,7 @@ private slots: void initializeListComplex(); void insertMove(); void nonCopyable(); + void implicitDefaultCtor(); private: template<typename T> @@ -1078,5 +1079,11 @@ void tst_QVarLengthArray::nonCopyable() QVERIFY(ptr6 == vec.at(5).get()); } +void tst_QVarLengthArray::implicitDefaultCtor() +{ + QVarLengthArray<int> def = {}; + QCOMPARE(def.size(), 0); +} + QTEST_APPLESS_MAIN(tst_QVarLengthArray) #include "tst_qvarlengtharray.moc" |