diff options
Diffstat (limited to 'tests/auto/corelib/tools/qlist/tst_qlist.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qlist/tst_qlist.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index b3f8130d27..cc9a3a16d1 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -310,6 +310,7 @@ private slots: void lastComplex() const; void constFirst() const; void constLast() const; + void cpp17ctad() const; void beginOptimal() const; void beginMovable() const; void beginComplex() const; @@ -364,12 +365,14 @@ private slots: void takeLastOptimal() const; void takeLastMovable() const; void takeLastComplex() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toSetOptimal() const; void toSetMovable() const; void toSetComplex() const; void toStdListOptimal() const; void toStdListMovable() const; void toStdListComplex() const; +#endif void toVectorOptimal() const; void toVectorMovable() const; void toVectorComplex() const; @@ -426,8 +429,10 @@ private: template<typename T> void takeAt() const; template<typename T> void takeFirst() const; template<typename T> void takeLast() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template<typename T> void toSet() const; template<typename T> void toStdList() const; +#endif template<typename T> void toVector() const; template<typename T> void value() const; @@ -860,6 +865,33 @@ void tst_QList::constLast() const QVERIFY(listCopy.isSharedWith(list)); } +void tst_QList::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_LIST_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QList v1 = {One, Two, Three}; \ + QVERIFY_IS_LIST_OF(v1, Type); \ + QList v2(v1.begin(), v1.end()); \ + QVERIFY_IS_LIST_OF(v2, Type); \ + QList v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_LIST_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_LIST_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + template<typename T> void tst_QList::last() const { @@ -1457,11 +1489,11 @@ void tst_QList::swap() const list << T_FOO << T_BAR << T_BAZ; // swap - list.swap(0, 2); + list.swapItemsAt(0, 2); QCOMPARE(list, QList<T>() << T_BAZ << T_BAR << T_FOO); // swap again - list.swap(1, 2); + list.swapItemsAt(1, 2); QCOMPARE(list, QList<T>() << T_BAZ << T_FOO << T_BAR); QList<T> list2; @@ -1595,6 +1627,7 @@ void tst_QList::takeLastComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template<typename T> void tst_QList::toSet() const { @@ -1669,6 +1702,7 @@ void tst_QList::toStdListComplex() const toStdList<Complex>(); QCOMPARE(liveCount, Complex::getLiveCount()); } +#endif template<typename T> void tst_QList::toVector() const @@ -1871,7 +1905,6 @@ void tst_QList::testSTLIteratorsComplex() const void tst_QList::initializeList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS QList<int> v1{2,3,4}; QCOMPARE(v1, QList<int>() << 2 << 3 << 4); QCOMPARE(v1, (QList<int>{2,3,4})); @@ -1880,7 +1913,6 @@ void tst_QList::initializeList() const QList<QList<int>> v3; v3 << v1 << (QList<int>() << 1) << QList<int>() << v1; QCOMPARE(v3, v2); -#endif } template<typename T> |