diff options
Diffstat (limited to 'async/autotests/asynctest.cpp')
-rw-r--r-- | async/autotests/asynctest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/async/autotests/asynctest.cpp b/async/autotests/asynctest.cpp index 9789950..9bc9f6b 100644 --- a/async/autotests/asynctest.cpp +++ b/async/autotests/asynctest.cpp | |||
@@ -68,6 +68,7 @@ private Q_SLOTS: | |||
68 | void testErrorPropagation(); | 68 | void testErrorPropagation(); |
69 | void testErrorHandlerAsync(); | 69 | void testErrorHandlerAsync(); |
70 | void testErrorPropagationAsync(); | 70 | void testErrorPropagationAsync(); |
71 | void testNestedErrorPropagation(); | ||
71 | 72 | ||
72 | void testChainingRunningJob(); | 73 | void testChainingRunningJob(); |
73 | void testChainingFinishedJob(); | 74 | void testChainingFinishedJob(); |
@@ -688,6 +689,28 @@ void AsyncTest::testErrorPropagationAsync() | |||
688 | QCOMPARE(error, 1); | 689 | QCOMPARE(error, 1); |
689 | } | 690 | } |
690 | 691 | ||
692 | void AsyncTest::testNestedErrorPropagation() | ||
693 | { | ||
694 | int error = 0; | ||
695 | auto job = Async::start<void>([](){}) | ||
696 | .then<void>(Async::error<void>(1, "error")) //Nested job that throws error | ||
697 | .then<void>([](Async::Future<void> &future) { | ||
698 | //We should never get here | ||
699 | Q_ASSERT(false); | ||
700 | }, | ||
701 | [&error](int errorCode, const QString &errorMessage) { | ||
702 | error += errorCode; | ||
703 | } | ||
704 | ); | ||
705 | auto future = job.exec(); | ||
706 | |||
707 | future.waitForFinished(); | ||
708 | |||
709 | QVERIFY(future.isFinished()); | ||
710 | QCOMPARE(future.errorCode(), 1); | ||
711 | QCOMPARE(future.errorMessage(), QString::fromLatin1("error")); | ||
712 | QCOMPARE(error, 1); | ||
713 | } | ||
691 | 714 | ||
692 | 715 | ||
693 | 716 | ||