diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index ade9c5e7543..e97848fb1cb 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -40,6 +40,7 @@ #include "nontracked.h" #include "wrapper.h" +#include #include #include @@ -232,6 +233,12 @@ struct NoDefaultConstructorRRef1 int &i; NoDefaultConstructorRRef1(int &&i) : i(i) {} }; + +struct NoDefaultConstructorRRef2 +{ + std::unique_ptr i; + NoDefaultConstructorRRef2(std::unique_ptr &&i) : i(std::move(i)) {} +}; #endif void tst_QSharedPointer::basics_data() @@ -1820,14 +1827,19 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(&ptr->i, &i); } { - NoDefaultConstructorRRef1(1); // control check - QSharedPointer ptr = QSharedPointer::create(1); - QCOMPARE(ptr->i, 1); - NoDefaultConstructorRRef1(std::move(i)); // control check - ptr = QSharedPointer::create(std::move(i)); + QSharedPointer ptr = QSharedPointer::create(std::move(i)); QCOMPARE(ptr->i, i); } + { + NoDefaultConstructorRRef2(std::unique_ptr(new int(1))); // control check + QSharedPointer ptr = QSharedPointer::create(std::unique_ptr(new int(1))); + QCOMPARE(*ptr->i, 1); + + std::unique_ptr p(new int(i)); + ptr = QSharedPointer::create(std::move(p)); + QCOMPARE(*ptr->i, i); + } { QString text("Hello, World"); NoDefaultConstructorRef2(text, 1); // control check