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.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp
index 4ebe65e..ed550ca 100644
--- a/async/autotests/asynctest.cpp
+++ b/async/autotests/asynctest.cpp
@@ -25,6 +25,7 @@
25#include <QString> 25#include <QString>
26#include <QTimer> 26#include <QTimer>
27#include <QtTest/QTest> 27#include <QtTest/QTest>
28#include <QDebug>
28 29
29class AsyncTest : public QObject 30class AsyncTest : public QObject
30{ 31{
@@ -42,6 +43,8 @@ private Q_SLOTS:
42 void testAsyncPromises(); 43 void testAsyncPromises();
43 void testAsyncPromises2(); 44 void testAsyncPromises2();
44 void testNestedAsync(); 45 void testNestedAsync();
46 void testStartValue();
47
45 void testAsyncThen(); 48 void testAsyncThen();
46 void testSyncThen(); 49 void testSyncThen();
47 void testAsyncEach(); 50 void testAsyncEach();
@@ -52,6 +55,8 @@ private Q_SLOTS:
52 55
53}; 56};
54 57
58
59
55void AsyncTest::testSyncPromises() 60void AsyncTest::testSyncPromises()
56{ 61{
57 auto baseJob = Async::start<int>( 62 auto baseJob = Async::start<int>(
@@ -160,6 +165,23 @@ void AsyncTest::testNestedAsync()
160 QTRY_VERIFY(done); 165 QTRY_VERIFY(done);
161} 166}
162 167
168void AsyncTest::testStartValue()
169{
170 auto job = Async::start<int, int>(
171 [](int in, Async::Future<int> &future) {
172 future.setValue(in);
173 future.setFinished();
174 });
175
176 auto future = job.exec(42);
177 QVERIFY(future.isFinished());
178 QCOMPARE(future.value(), 42);
179}
180
181
182
183
184
163void AsyncTest::testAsyncThen() 185void AsyncTest::testAsyncThen()
164{ 186{
165 auto job = Async::start<int>( 187 auto job = Async::start<int>(