summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-10-02 18:44:00 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-10-12 19:45:22 +0000
commitf476a68ee9678f4f2db6585868937d42d7fbfbd6 (patch)
treedfc67395f5d90a1c9b68a3328ec25b105dd04679
parent71c6911182aba9e7c571094242e2f6fa94c32a3b (diff)
tst_QPointer: add checks for CTAD
No pathological findings :) Pick-to: 6.2 Change-Id: Ifbbca223a5e612e7abb67c0364d4354a9d8174e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 1cf0f8e7c3feb923ff08247d83d185c6aea986eb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit e4f5d86f88a5345257964bf4db56520d852ead83)
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 4705ff0756..ca87aa03c0 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -19,6 +19,7 @@ public:
private slots:
void constructors();
+ void ctad();
void destructor();
void assignment_operators();
void equality_operators();
@@ -48,6 +49,47 @@ void tst_QPointer::constructors()
QCOMPARE(p3, QPointer<QObject>(this));
}
+void tst_QPointer::ctad()
+{
+
+ {
+ QObject o;
+ QPointer po = &o;
+ static_assert(std::is_same_v<decltype(po), QPointer<QObject>>);
+ QPointer poc = po;
+ static_assert(std::is_same_v<decltype(poc), QPointer<QObject>>);
+ QPointer pom = std::move(po);
+ static_assert(std::is_same_v<decltype(pom), QPointer<QObject>>);
+ }
+ {
+ const QObject co;
+ QPointer pco = &co;
+ static_assert(std::is_same_v<decltype(pco), QPointer<const QObject>>);
+ QPointer pcoc = pco;
+ static_assert(std::is_same_v<decltype(pcoc), QPointer<const QObject>>);
+ QPointer pcom = std::move(pco);
+ static_assert(std::is_same_v<decltype(pcom), QPointer<const QObject>>);
+ }
+ {
+ QFile f;
+ QPointer pf = &f;
+ static_assert(std::is_same_v<decltype(pf), QPointer<QFile>>);
+ QPointer pfc = pf;
+ static_assert(std::is_same_v<decltype(pfc), QPointer<QFile>>);
+ QPointer pfm = std::move(pf);
+ static_assert(std::is_same_v<decltype(pfm), QPointer<QFile>>);
+ }
+ {
+ const QFile cf;
+ QPointer pcf = &cf;
+ static_assert(std::is_same_v<decltype(pcf), QPointer<const QFile>>);
+ QPointer pcfc = pcf;
+ static_assert(std::is_same_v<decltype(pcfc), QPointer<const QFile>>);
+ QPointer pcfm = std::move(pcf);
+ static_assert(std::is_same_v<decltype(pcfm), QPointer<const QFile>>);
+ }
+}
+
void tst_QPointer::destructor()
{
// Make two QPointer's to the same object