From a40160b8f8930dbe2a0abde4b45e5796264f5782 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 1 Apr 2015 01:35:51 +0200 Subject: Added Async::dowhile --- async/autotests/asynctest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'async/autotests') 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: void testLifetimeWithoutHandle(); void testLifetimeWithHandle(); + void testWhile(); + void benchmarkSyncThenExecutor(); private: @@ -377,6 +379,23 @@ void AsyncTest::testVoidEach() QCOMPARE(check, expected); } +void AsyncTest::testWhile() +{ + + QList processed; + QList list({1, 2, 3, 4}); + auto it = QSharedPointer >::create(list); + Async::dowhile( + [it]() -> bool { return it->hasNext(); }, + [it, &processed](Async::Future future) { + auto value = it->next(); + processed << value; + future.setFinished(); + } + ).exec().waitForFinished(); + QCOMPARE(processed, list); +} + -- cgit v1.2.3