#include "gtest/gtest.h" #include #include #include #include "core/concurrentrun.h" #include "test_utils.h" int max(int i, int j) { return (i > j ? i : j); } TEST(ConcurrentRunTest, ConcurrentRunStartAndWait) { int i = 10; int j = 42; QThreadPool threadpool; QFuture future = ConcurrentRun::Run(&threadpool, &max, i, j); QFutureWatcher watcher; watcher.setFuture(future); QEventLoop loop; QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); EXPECT_EQ(42, watcher.result()); } // TODO: add some more complex test cases? (e.g. with several CPU-consuming // tasks launched in parallel, with/without threadpool's threads numbers // decreased, etc.)