From 7a16c0805ab91e2a73256f45fb141266cf06102c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 Oct 2023 18:44:00 +0200 Subject: [PATCH] tst_QPointer: add checks for CTAD No pathological findings :) Change-Id: Ifbbca223a5e612e7abb67c0364d4354a9d8174e3 Reviewed-by: Thiago Macieira (cherry picked from commit 1cf0f8e7c3feb923ff08247d83d185c6aea986eb) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit e4f5d86f88a5345257964bf4db56520d852ead83) (cherry picked from commit f476a68ee9678f4f2db6585868937d42d7fbfbd6) --- .../corelib/kernel/qpointer/tst_qpointer.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index 6f9a422820d..b1b408db8c6 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -44,6 +44,7 @@ public: private slots: void constructors(); + void ctad(); void destructor(); void assignment_operators(); void equality_operators(); @@ -69,6 +70,47 @@ void tst_QPointer::constructors() QCOMPARE(p3, QPointer(this)); } +void tst_QPointer::ctad() +{ + + { + QObject o; + QPointer po = &o; + static_assert(std::is_same_v>); + QPointer poc = po; + static_assert(std::is_same_v>); + QPointer pom = std::move(po); + static_assert(std::is_same_v>); + } + { + const QObject co; + QPointer pco = &co; + static_assert(std::is_same_v>); + QPointer pcoc = pco; + static_assert(std::is_same_v>); + QPointer pcom = std::move(pco); + static_assert(std::is_same_v>); + } + { + QFile f; + QPointer pf = &f; + static_assert(std::is_same_v>); + QPointer pfc = pf; + static_assert(std::is_same_v>); + QPointer pfm = std::move(pf); + static_assert(std::is_same_v>); + } + { + const QFile cf; + QPointer pcf = &cf; + static_assert(std::is_same_v>); + QPointer pcfc = pcf; + static_assert(std::is_same_v>); + QPointer pcfm = std::move(pcf); + static_assert(std::is_same_v>); + } +} + void tst_QPointer::destructor() { // Make two QPointer's to the same object