diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-25 15:29:17 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-27 07:56:15 +0000 |
commit | 66e147309698d8cc5ce7da10d4cd2e1e216c3786 (patch) | |
tree | 28bcc417f3201401c843fb4b94babff54f7b1c07 /tests | |
parent | 4413f7070aa0a1b16944de552a72d7fe62681b1c (diff) |
Use move more consistently in QScopedValueRollback
Use move on the existing value as well so the constructor makes more
of a difference.
Change-Id: Iee2080da7b7d2d88eb108f0448c61423c7256979
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index 656dd6a6e3..9b607db608 100644 --- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void rollbackToPreviousCommit(); void exceptions(); void earlyExitScope(); + void moveOnly(); private: void earlyExitScope_helper(int exitpoint, int &member); }; @@ -190,5 +191,17 @@ void tst_QScopedValueRollback::earlyExitScope_helper(int exitpoint, int& member) r.commit(); } +void tst_QScopedValueRollback::moveOnly() +{ + std::unique_ptr<int> uniquePtr; + std::unique_ptr<int> newVal(new int(5)); + QVERIFY(!uniquePtr); + { + QScopedValueRollback<std::unique_ptr<int>> r(uniquePtr, std::move(newVal)); + QVERIFY(uniquePtr); + } + QVERIFY(!uniquePtr); +} + QTEST_MAIN(tst_QScopedValueRollback) #include "tst_qscopedvaluerollback.moc" |