summaryrefslogtreecommitdiffstats
path: root/async/autotests
diff options
context:
space:
mode:
Diffstat (limited to 'async/autotests')
-rw-r--r--async/autotests/asynctest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp
index 85f5ea5..a387dd6 100644
--- a/async/autotests/asynctest.cpp
+++ b/async/autotests/asynctest.cpp
@@ -68,6 +68,8 @@ private Q_SLOTS:
68 void testLifetimeWithoutHandle(); 68 void testLifetimeWithoutHandle();
69 void testLifetimeWithHandle(); 69 void testLifetimeWithHandle();
70 70
71 void testWhile();
72
71 void benchmarkSyncThenExecutor(); 73 void benchmarkSyncThenExecutor();
72 74
73private: 75private:
@@ -377,6 +379,23 @@ void AsyncTest::testVoidEach()
377 QCOMPARE(check, expected); 379 QCOMPARE(check, expected);
378} 380}
379 381
382void AsyncTest::testWhile()
383{
384
385 QList<int> processed;
386 QList<int> list({1, 2, 3, 4});
387 auto it = QSharedPointer<QListIterator<int> >::create(list);
388 Async::dowhile<void>(
389 [it]() -> bool { return it->hasNext(); },
390 [it, &processed](Async::Future<void> future) {
391 auto value = it->next();
392 processed << value;
393 future.setFinished();
394 }
395 ).exec().waitForFinished();
396 QCOMPARE(processed, list);
397}
398
380 399
381 400
382 401