diff options
Diffstat (limited to 'tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index deb3b68c5c..df42b5dea9 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -187,6 +187,7 @@ private slots: void countInt() const; void countMovable() const; void countComplex() const; + void cpp17ctad() const; void emptyInt() const; void emptyMovable() const; void emptyComplex() const; @@ -594,6 +595,33 @@ void tst_QLinkedList::countComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +void tst_QLinkedList::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_LIST_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QLinkedList<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QLinkedList v1 = {One, Two, Three}; \ + QVERIFY_IS_LIST_OF(v1, Type); \ + QLinkedList v2(v1.begin(), v1.end()); \ + QVERIFY_IS_LIST_OF(v2, Type); \ + QLinkedList 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_QLinkedList::empty() const { |