summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp')
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 3d90644aa3..a1d0100f96 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -44,6 +44,7 @@ private slots:
void realloc();
void reverseIterators();
void count();
+ void cpp17ctad();
void first();
void last();
void squeeze();
@@ -717,6 +718,34 @@ void tst_QVarLengthArray::count()
}
}
+void tst_QVarLengthArray::cpp17ctad()
+{
+#ifdef __cpp_deduction_guides
+#define QVERIFY_IS_VLA_OF(obj, Type) \
+ QVERIFY2((std::is_same<decltype(obj), QVarLengthArray<Type>>::value), \
+ QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
+#define CHECK(Type, One, Two, Three) \
+ do { \
+ const Type v[] = {One, Two, Three}; \
+ QVarLengthArray v1 = {One, Two, Three}; \
+ QVERIFY_IS_VLA_OF(v1, Type); \
+ QVarLengthArray v2(v1.begin(), v1.end()); \
+ QVERIFY_IS_VLA_OF(v2, Type); \
+ QVarLengthArray v3(std::begin(v), std::end(v)); \
+ QVERIFY_IS_VLA_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_VLA_OF
+#undef CHECK
+#else
+ QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler.");
+#endif
+
+}
+
void tst_QVarLengthArray::first()
{
// append some items, make sure it stays sane