Use QList instead of QVector in concurrent tests

Task-number: QTBUG-84469
Change-Id: Ia8113ef044a918e46176bfa3f4b34781dc69dd03
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
Jarek Kobus 2020-06-22 15:07:48 +02:00
parent b0792f391d
commit 95a5cd71b6
3 changed files with 22 additions and 21 deletions

View File

@ -356,8 +356,8 @@ void tst_QtConcurrentFilter::filteredReduced()
const int intSum = 6; // sum of even values
const Number numberSum = 6; // sum of even values
void (QVector<int>::*pushBackInt)(const int &) = &QVector<int>::push_back;
void (QVector<Number>::*pushBackNumber)(const Number &) = &QVector<Number>::push_back;
void (QList<int>::*pushBackInt)(const int &) = &QList<int>::push_back;
void (QList<Number>::*pushBackNumber)(const Number &) = &QList<Number>::push_back;
auto lambdaIsEven = [](const int &x) {
return (x & 1) == 0;
@ -612,8 +612,8 @@ void tst_QtConcurrentFilter::filteredReducedInitialValue()
const int intSum = 16; // sum of even values and initial value
const Number numberSum = 16; // sum of even values and initial value
void (QVector<int>::*pushBackInt)(const int &) = &QVector<int>::push_back;
void (QVector<Number>::*pushBackNumber)(const Number &) = &QVector<Number>::push_back;
void (QList<int>::*pushBackInt)(const int &) = &QList<int>::push_back;
void (QList<Number>::*pushBackNumber)(const Number &) = &QList<Number>::push_back;
auto lambdaIsEven = [](const int &x) {
return (x & 1) == 0;

View File

@ -609,7 +609,7 @@ void tst_QtConcurrentMap::mappedReduced()
const int sum = 6;
const int sumOfSquares = 14;
void (QVector<int>::*push_back)(const int &) = &QVector<int>::push_back;
void (QList<int>::*push_back)(const int &) = &QList<int>::push_back;
auto lambdaSquare = [](int x) {
return x * x;
@ -857,7 +857,7 @@ void tst_QtConcurrentMap::mappedReducedInitialValue()
const int sumOfSquares = 24;
const int intInitial = 10;
void (QVector<int>::*push_back)(const int &) = &QVector<int>::push_back;
void (QList<int>::*push_back)(const int &) = &QList<int>::push_back;
auto lambdaSquare = [](int x) {
return x * x;
@ -1161,7 +1161,7 @@ public:
}
};
Q_DECLARE_METATYPE(QVector<MemFnTester>);
Q_DECLARE_METATYPE(QList<MemFnTester>);
void tst_QtConcurrentMap::functionOverloads()
{
@ -1175,10 +1175,10 @@ void tst_QtConcurrentMap::functionOverloads()
QtConcurrent::mapped(classList, &MemFnTester::fnConst);
QtConcurrent::mapped(constMemFnTesterList, &MemFnTester::fnConst);
QtConcurrent::blockingMapped<QVector<int> >(intList, fnConst);
QtConcurrent::blockingMapped<QVector<int> >(constIntList, fnConst);
QtConcurrent::blockingMapped<QVector<MemFnTester> >(classList, &MemFnTester::fnConst);
QtConcurrent::blockingMapped<QVector<MemFnTester> >(constMemFnTesterList, &MemFnTester::fnConst);
QtConcurrent::blockingMapped<QList<int>>(intList, fnConst);
QtConcurrent::blockingMapped<QList<int>>(constIntList, fnConst);
QtConcurrent::blockingMapped<QList<MemFnTester>>(classList, &MemFnTester::fnConst);
QtConcurrent::blockingMapped<QList<MemFnTester>>(constMemFnTesterList, &MemFnTester::fnConst);
QtConcurrent::blockingMapped<QList<QString> >(intList, changeTypeConst);
QtConcurrent::blockingMapped<QList<QString> >(constIntList, changeTypeConst);
@ -1198,10 +1198,11 @@ void tst_QtConcurrentMap::noExceptFunctionOverloads()
QtConcurrent::mapped(classList, &MemFnTester::fnConstNoExcept);
QtConcurrent::mapped(constMemFnTesterList, &MemFnTester::fnConstNoExcept);
QtConcurrent::blockingMapped<QVector<int> >(intList, fnConstNoExcept);
QtConcurrent::blockingMapped<QVector<int> >(constIntList, fnConstNoExcept);
QtConcurrent::blockingMapped<QVector<MemFnTester> >(classList, &MemFnTester::fnConstNoExcept);
QtConcurrent::blockingMapped<QVector<MemFnTester> >(constMemFnTesterList, &MemFnTester::fnConstNoExcept);
QtConcurrent::blockingMapped<QList<int>>(intList, fnConstNoExcept);
QtConcurrent::blockingMapped<QList<int>>(constIntList, fnConstNoExcept);
QtConcurrent::blockingMapped<QList<MemFnTester>>(classList, &MemFnTester::fnConstNoExcept);
QtConcurrent::blockingMapped<QList<MemFnTester>>(constMemFnTesterList,
&MemFnTester::fnConstNoExcept);
QtConcurrent::blockingMapped<QList<QString> >(intList, changeTypeConstNoExcept);
QtConcurrent::blockingMapped<QList<QString> >(constIntList, changeTypeConstNoExcept);

View File

@ -107,18 +107,18 @@ void tst_QtConcurrentTask::setPriority()
QSemaphore sem;
QVector<QFuture<void>> futureResults;
QList<QFuture<void>> futureResults;
futureResults << task([&]{ sem.acquire(); })
.onThreadPool(pool)
.spawn();
const int tasksCount = 10;
QVector<int> priorities(tasksCount);
QList<int> priorities(tasksCount);
std::iota(priorities.begin(), priorities.end(), 1);
auto seed = std::chrono::system_clock::now().time_since_epoch().count();
std::shuffle(priorities.begin(), priorities.end(), std::default_random_engine(seed));
QVector<int> actual;
QList<int> actual;
for (int priority : priorities)
futureResults << task([priority, &actual] { actual << priority; })
.onThreadPool(pool)
@ -131,7 +131,7 @@ void tst_QtConcurrentTask::setPriority()
for (const auto &f : futureResults)
QVERIFY(f.isFinished());
QVector<int> expected(priorities);
QList<int> expected(priorities);
std::sort(expected.begin(), expected.end(), std::greater<>());
QCOMPARE(actual, expected);
@ -144,7 +144,7 @@ void tst_QtConcurrentTask::adjustAllSettings()
const int priority = 10;
QVector<int> result;
QList<int> result;
auto append = [&](auto &&...args){ (result << ... << args); };
task(std::move(append))
@ -154,7 +154,7 @@ void tst_QtConcurrentTask::adjustAllSettings()
.spawn()
.waitForFinished();
QCOMPARE(result, QVector<int>({1, 2, 3}));
QCOMPARE(result, QList<int>({ 1, 2, 3 }));
}
void tst_QtConcurrentTask::ignoreFutureResult()
{