Commit b19cac02 authored by Eike Ziller's avatar Eike Ziller

runAsync: Add test for move-only types

Excludes MSVC2013 which doesn't really support moving.

Change-Id: I2bffa546f2c90946b4d99e0eee292741b900a386
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 1f8e5bd3
......@@ -27,6 +27,10 @@
#include <QtTest>
#if !defined(Q_CC_MSVC) || _MSC_VER >= 1900 // MSVC2015
#define SUPPORTS_MOVE
#endif
class tst_RunExtensions : public QObject
{
Q_OBJECT
......@@ -34,6 +38,9 @@ class tst_RunExtensions : public QObject
private slots:
void runAsync();
void runInThreadPool();
#ifdef SUPPORTS_MOVE
void moveOnlyType();
#endif
};
void report3(QFutureInterface<int> &fi)
......@@ -268,6 +275,35 @@ void tst_RunExtensions::runInThreadPool()
QList<QString>({QString(QLatin1String("rvalue"))}));
}
#ifdef SUPPORTS_MOVE
class MoveOnlyType
{
public:
MoveOnlyType() = default;
MoveOnlyType(const MoveOnlyType &) = delete;
MoveOnlyType(MoveOnlyType &&) = default;
MoveOnlyType &operator=(const MoveOnlyType &) = delete;
MoveOnlyType &operator=(MoveOnlyType &&) = default;
};
class MoveOnlyCallable : public MoveOnlyType
{
public:
void operator()(QFutureInterface<int> &fi, const MoveOnlyType &)
{
fi.reportResult(1);
}
};
void tst_RunExtensions::moveOnlyType()
{
QCOMPARE(Utils::runAsync<int>(MoveOnlyCallable(), MoveOnlyType()).results(),
QList<int>({1}));
}
#endif
QTEST_MAIN(tst_RunExtensions)
#include "tst_runextensions.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment