42 void FuturesTest::testSequencer ()
50 .Then ([&loop, &res] (
int cnt)
58 QCoreApplication::processEvents ();
63 void FuturesTest::testHeterogeneousTypes ()
69 bool executed =
false;
70 Sequence (
nullptr,
MkWaiter () (50)) >>
71 [] (int) {
return MakeReadyFuture<Bar> ({}); } >>
72 [] (Bar) {
return MakeReadyFuture<Baz> ({}); } >>
73 [&executed, &loop] (Baz)
81 QCoreApplication::processEvents ();
83 QCOMPARE (executed,
true);
86 void FuturesTest::testDestruction ()
89 bool executed =
false;
93 Sequence (&obj, MakeReadyFuture (0)) >>
94 [&executed, &loop] (int)
101 QTimer::singleShot (100, &loop, SLOT (quit ()));
105 QCoreApplication::processEvents ();
107 QCOMPARE (executed,
false);
110 void FuturesTest::testDestructionHandler ()
112 const auto finished = 1;
113 const auto destructed = 2;
116 bool executed =
false;
122 future = Sequence (&obj,
MkWaiter () (100))
123 .DestructionValue ([] {
return destructed; }) >>
124 [=] (
int) {
return MakeReadyFuture (finished); };
126 Sequence (
nullptr, future) >>
127 [&executed, &value, &loop] (
int val)
134 QTimer::singleShot (10, &loop, SLOT (quit ()));
138 QCoreApplication::processEvents ();
140 QCOMPARE (executed,
true);
141 QCOMPARE (value, destructed);
144 void FuturesTest::testNoDestrHandler ()
150 bool executed =
false;
151 Sequence (
nullptr,
MkWaiter () (50))
152 .DestructionValue ([&executed] { executed =
true; }) >>
153 [] (
int) {
return MakeReadyFuture<Bar> ({}); } >>
154 [] (Bar) {
return MakeReadyFuture<Baz> ({}); } >>
155 [&loop] (Baz) { loop.quit (); };
159 QCoreApplication::processEvents ();
161 QCOMPARE (executed,
false);
164 void FuturesTest::testNoDestrHandlerSetBuildable ()
166 const auto finished = 1;
169 bool executed =
false;
173 [=] (int) {
return MakeReadyFuture (finished); };
174 Sequence (
nullptr, future) >>
175 [&executed, &value, &loop] (
int val)
184 QCoreApplication::processEvents ();
186 QCOMPARE (executed,
true);
187 QCOMPARE (value, finished);
190 void FuturesTest::testMulti ()
198 Sequence (
nullptr, iface.future ())
199 .MultipleResults ([&] (
int sub)
204 [&] { loop.quit (); });
206 iface.reportStarted ();
207 iface.setProgressRange (0, 2);
208 iface.reportResult (1, 0);
209 iface.reportResult (2, 1);
210 iface.reportResult (3, 2);
211 iface.reportFinished ();
215 QCoreApplication::processEvents ();
constexpr detail::AggregateType< detail::AggregateFunction::Count > count