From f407e12321dada7470e561cefd576031cd9e4168 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 1 Apr 2015 10:59:36 +0200 Subject: dowhile cleanup, second dowhile version without separate condition. --- async/autotests/asynctest.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'async/autotests') 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: void testLifetimeWithHandle(); void testWhile(); + void testWhileWithoutCondition(); void benchmarkSyncThenExecutor(); @@ -385,7 +386,7 @@ void AsyncTest::testWhile() QList processed; QList list({1, 2, 3, 4}); auto it = QSharedPointer >::create(list); - Async::dowhile( + Async::dowhile( [it]() -> bool { return it->hasNext(); }, [it, &processed](Async::Future future) { auto value = it->next(); @@ -396,6 +397,22 @@ void AsyncTest::testWhile() QCOMPARE(processed, list); } +void AsyncTest::testWhileWithoutCondition() +{ + + QList processed; + QList list({1, 2, 3, 4}); + auto it = QSharedPointer >::create(list); + Async::dowhile( + [it, &processed](Async::Future future) { + auto value = it->next(); + processed << value; + future.setValue(it->hasNext()); + future.setFinished(); + } + ).exec().waitForFinished(); + QCOMPARE(processed, list); +} -- cgit v1.2.3