From 453526c7553c650f9a5bb3fe4452306d9dd3740f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 19 Apr 2015 12:22:28 +0200 Subject: Fixed void async each. --- async/autotests/asynctest.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'async/autotests') diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp index d709567..9789950 100644 --- a/async/autotests/asynctest.cpp +++ b/async/autotests/asynctest.cpp @@ -55,7 +55,8 @@ private Q_SLOTS: void testAsyncEach(); void testSyncEach(); void testJoinedEach(); - void testVoidEach(); + void testVoidEachThen(); + void testAsyncVoidEachThen(); void testAsyncReduce(); void testSyncReduce(); @@ -382,7 +383,7 @@ void AsyncTest::testJoinedEach() QCOMPARE(future.value(), expected); } -void AsyncTest::testVoidEach() +void AsyncTest::testVoidEachThen() { QList check; auto job = Async::start>( @@ -391,12 +392,37 @@ void AsyncTest::testVoidEach() }).each( [&check](const int &v) { check << v; + }).then([](){}); + + auto future = job.exec(); + + const QList expected({ 1, 2, 3, 4 }); + QVERIFY(future.isFinished()); + QCOMPARE(check, expected); +} + +void AsyncTest::testAsyncVoidEachThen() +{ + bool completedJob = false; + QList check; + auto job = Async::start>( + [](Async::Future > &future) { + new AsyncSimulator>(future, { 1, 2, 3, 4 }); + }).each( + [&check](const int &v, Async::Future &future) { + check << v; + new AsyncSimulator(future); + }).then([&completedJob](Async::Future &future) { + completedJob = true; + future.setFinished(); }); auto future = job.exec(); + future.waitForFinished(); const QList expected({ 1, 2, 3, 4 }); QVERIFY(future.isFinished()); + QVERIFY(completedJob); QCOMPARE(check, expected); } -- cgit v1.2.3