Fix concurrentrun test

This commit is contained in:
Jonas Kvinge
2020-10-19 22:33:08 +02:00
parent 06746449a1
commit 6c50077409
2 changed files with 10 additions and 9 deletions

View File

@@ -136,6 +136,7 @@ macro(add_test_file test_source gui_required)
) )
target_link_libraries(${TEST_NAME} PRIVATE target_link_libraries(${TEST_NAME} PRIVATE
${QtCore_LIBRARIES} ${QtCore_LIBRARIES}
${QtConcurrent_LIBRARIES}
${QtWidgets_LIBRARIES} ${QtWidgets_LIBRARIES}
${QtNetwork_LIBRARIES} ${QtNetwork_LIBRARIES}
${QtSql_LIBRARIES} ${QtSql_LIBRARIES}

View File

@@ -2,11 +2,11 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <QtConcurrent>
#include <QThreadPool> #include <QThreadPool>
#include <QEventLoop> #include <QEventLoop>
#include <QFutureWatcher> #include <QFutureWatcher>
#include "core/concurrentrun.h"
#include "test_utils.h" #include "test_utils.h"
int f(); int f();
@@ -17,7 +17,7 @@ int f() {
TEST(ConcurrentRunTest, ConcurrentRun0StartAndWait) { TEST(ConcurrentRunTest, ConcurrentRun0StartAndWait) {
QThreadPool threadpool; QThreadPool threadpool;
QFuture<int> future = ConcurrentRun::Run<int>(&threadpool, &f); QFuture<int> future = QtConcurrent::run(&threadpool, &f);
QFutureWatcher<int> watcher; QFutureWatcher<int> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -36,7 +36,7 @@ TEST(ConcurrentRunTest, ConcurrentRun1StartAndWait) {
QThreadPool threadpool; QThreadPool threadpool;
int i = 1336; int i = 1336;
QFuture<int> future = ConcurrentRun::Run<int, int>(&threadpool, &g, i); QFuture<int> future = QtConcurrent::run(&threadpool, &g, i);
QFutureWatcher<int> watcher; QFutureWatcher<int> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -56,7 +56,7 @@ TEST(ConcurrentRunTest, ConcurrentRun2StartAndWait) {
int i = 10; int i = 10;
int j = 42; int j = 42;
QThreadPool threadpool; QThreadPool threadpool;
QFuture<int> future = ConcurrentRun::Run<int, int, int>(&threadpool, &max, i, j); QFuture<int> future = QtConcurrent::run(&threadpool, &max, i, j);
QFutureWatcher<int> watcher; QFutureWatcher<int> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -77,7 +77,7 @@ TEST(ConcurrentRunTest, ConcurrentRun3StartAndWait) {
int j = 42; int j = 42;
int k = 50; int k = 50;
QThreadPool threadpool; QThreadPool threadpool;
QFuture<int> future = ConcurrentRun::Run<int, int, int, int>(&threadpool, &sum, i, j, k); QFuture<int> future = QtConcurrent::run(&threadpool, &sum, i, j, k);
QFutureWatcher<int> watcher; QFutureWatcher<int> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -109,7 +109,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction1Start) {
QThreadPool threadpool; QThreadPool threadpool;
int n = 10; int n = 10;
QFuture<void> future = ConcurrentRun::Run<void, int*>(&threadpool, &aFunction, &n); QFuture<void> future = QtConcurrent::run(&threadpool, &aFunction, &n);
QFutureWatcher<void> watcher; QFutureWatcher<void> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -124,7 +124,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction2Start) {
QThreadPool threadpool; QThreadPool threadpool;
int n = 10, m = 11; int n = 10, m = 11;
QFuture<void> future = ConcurrentRun::Run<void, int*, int*>(&threadpool, &bFunction, &n, &m); QFuture<void> future = QtConcurrent::run(&threadpool, &bFunction, &n, &m);
QFutureWatcher<void> watcher; QFutureWatcher<void> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -140,7 +140,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidFunction3Start) {
QThreadPool threadpool; QThreadPool threadpool;
int n = 10, m = 11, o = 12; int n = 10, m = 11, o = 12;
QFuture<void> future = ConcurrentRun::Run<void, int*, int*, int*>(&threadpool, &cFunction, &n, &m, &o); QFuture<void> future = QtConcurrent::run(&threadpool, &cFunction, &n, &m, &o);
QFutureWatcher<void> watcher; QFutureWatcher<void> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;
@@ -165,7 +165,7 @@ TEST(ConcurrentRunTest, ConcurrentRunVoidBindFunctionStart) {
A a; A a;
int nb = 10; int nb = 10;
QFuture<void> future = ConcurrentRun::Run<void>(&threadpool, std::bind(&A::f, &a, &nb)); QFuture<void> future = QtConcurrent::run(&threadpool, std::bind(&A::f, &a, &nb));
QFutureWatcher<void> watcher; QFutureWatcher<void> watcher;
watcher.setFuture(future); watcher.setFuture(future);
QEventLoop loop; QEventLoop loop;