QtConcurrent::run() test: Add tests taking static function
Change-Id: I75d862a756d0543d8925459b3871abb979ffd481 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
6532dc5d37
commit
52eae99b51
@ -1089,12 +1089,25 @@ void report3(QPromise<int> &promise)
|
||||
promise.addResult(1);
|
||||
}
|
||||
|
||||
static void staticReport3(QPromise<int> &promise)
|
||||
{
|
||||
promise.addResult(0);
|
||||
promise.addResult(2);
|
||||
promise.addResult(1);
|
||||
}
|
||||
|
||||
void reportN(QPromise<double> &promise, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i)
|
||||
promise.addResult(0);
|
||||
}
|
||||
|
||||
static void staticReportN(QPromise<double> &promise, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i)
|
||||
promise.addResult(0);
|
||||
}
|
||||
|
||||
void reportString1(QPromise<QString> &promise, const QString &s)
|
||||
{
|
||||
promise.addResult(s);
|
||||
@ -1168,11 +1181,21 @@ void tst_QtConcurrentRun::withPromise()
|
||||
QCOMPARE(run(report3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
|
||||
QCOMPARE(run(reportN, 4).results(),
|
||||
QList<double>({0, 0, 0, 0}));
|
||||
QCOMPARE(run(&staticReport3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
QCOMPARE(run(staticReport3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
|
||||
QCOMPARE(run(&reportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
QCOMPARE(run(reportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
|
||||
QCOMPARE(run(&staticReportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
QCOMPARE(run(staticReportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
|
||||
QString s = QLatin1String("string");
|
||||
const QString &crs = QLatin1String("cr string");
|
||||
const QString cs = QLatin1String("c string");
|
||||
@ -1259,11 +1282,21 @@ void tst_QtConcurrentRun::withPromiseInThreadPool()
|
||||
QCOMPARE(run(pool.data(), report3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
|
||||
QCOMPARE(run(pool.data(), reportN, 4).results(),
|
||||
QList<double>({0, 0, 0, 0}));
|
||||
QCOMPARE(run(pool.data(), &staticReport3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
QCOMPARE(run(pool.data(), staticReport3).results(),
|
||||
QList<int>({0, 2, 1}));
|
||||
|
||||
QCOMPARE(run(pool.data(), &reportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
QCOMPARE(run(pool.data(), reportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
|
||||
QCOMPARE(run(pool.data(), &staticReportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
QCOMPARE(run(pool.data(), staticReportN, 2).results(),
|
||||
QList<double>({0, 0}));
|
||||
|
||||
QString s = QLatin1String("string");
|
||||
const QString &crs = QLatin1String("cr string");
|
||||
const QString cs = QLatin1String("c string");
|
||||
|
Loading…
x
Reference in New Issue
Block a user