summaryrefslogtreecommitdiffstats
path: root/async/autotests/asynctest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'async/autotests/asynctest.cpp')
-rw-r--r--async/autotests/asynctest.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp
index a387dd6..78a834e 100644
--- a/async/autotests/asynctest.cpp
+++ b/async/autotests/asynctest.cpp
@@ -69,6 +69,7 @@ private Q_SLOTS:
69 void testLifetimeWithHandle(); 69 void testLifetimeWithHandle();
70 70
71 void testWhile(); 71 void testWhile();
72 void testWhileWithoutCondition();
72 73
73 void benchmarkSyncThenExecutor(); 74 void benchmarkSyncThenExecutor();
74 75
@@ -385,7 +386,7 @@ void AsyncTest::testWhile()
385 QList<int> processed; 386 QList<int> processed;
386 QList<int> list({1, 2, 3, 4}); 387 QList<int> list({1, 2, 3, 4});
387 auto it = QSharedPointer<QListIterator<int> >::create(list); 388 auto it = QSharedPointer<QListIterator<int> >::create(list);
388 Async::dowhile<void>( 389 Async::dowhile(
389 [it]() -> bool { return it->hasNext(); }, 390 [it]() -> bool { return it->hasNext(); },
390 [it, &processed](Async::Future<void> future) { 391 [it, &processed](Async::Future<void> future) {
391 auto value = it->next(); 392 auto value = it->next();
@@ -396,6 +397,22 @@ void AsyncTest::testWhile()
396 QCOMPARE(processed, list); 397 QCOMPARE(processed, list);
397} 398}
398 399
400void AsyncTest::testWhileWithoutCondition()
401{
402
403 QList<int> processed;
404 QList<int> list({1, 2, 3, 4});
405 auto it = QSharedPointer<QListIterator<int> >::create(list);
406 Async::dowhile(
407 [it, &processed](Async::Future<bool> future) {
408 auto value = it->next();
409 processed << value;
410 future.setValue(it->hasNext());
411 future.setFinished();
412 }
413 ).exec().waitForFinished();
414 QCOMPARE(processed, list);
415}
399 416
400 417
401 418