LeechCraft 0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
monadicfuturetest.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "monadicfuturetest.h"
10#include <QtTest>
11#include <monadicfuture.h>
12#include "common.h"
13
15
16namespace LC::Util
17{
18 void MonadicFuturesTest::testFunctor ()
19 {
20 QEventLoop loop;
21
22 auto res = MkWaiter () (10) *
23 [&loop] (int val)
24 {
25 QTimer::singleShot (0, &loop, SLOT (quit ()));
26 return std::to_string (val);
27 };
28
29 loop.exec ();
30
31 QCoreApplication::processEvents ();
32
33 QCOMPARE (res.result (), std::string { "20" });
34 }
35
36 void MonadicFuturesTest::testFunctorReady ()
37 {
38 QEventLoop loop;
39
40 auto res = Util::MakeReadyFuture<int> (10) *
41 [&loop] (int val)
42 {
43 QTimer::singleShot (0, &loop, SLOT (quit ()));
44 return std::to_string (val);
45 };
46
47 loop.exec ();
48
49 QCoreApplication::processEvents ();
50
51 QCOMPARE (res.result (), std::string { "10" });
52 }
53}
auto MkWaiter()
Definition: common.h:19