LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
applicativetest.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 "applicativetest.h"
10 #include <QtTest>
11 #include <applicative.h>
12 #include <curry.h>
13 
14 QTEST_MAIN (LC::Util::ApplicativeTest)
15 
16 namespace LC
17 {
18 namespace Util
19 {
20  void ApplicativeTest::testBoostOptionalPure ()
21  {
22  const auto& pure = Pure<std::optional> (2);
23  QCOMPARE (pure, std::optional<int> { 2 });
24  }
25 
26  void ApplicativeTest::testBoostOptionalGSL ()
27  {
28  const auto& pure = Pure<std::optional> ([] (int a) { return ++a; });
29  const auto& app = GSL (pure, Pure<std::optional> (2));
30  QCOMPARE (app, std::optional<int> { 3 });
31  }
32 
33  void ApplicativeTest::testBoostOptionalGSLCurry ()
34  {
35  const auto& summer = Pure<std::optional> (Curry ([] (int a, int b) { return a + b; }));
36  const auto& s1 = Pure<std::optional> (1);
37  const auto& s2 = Pure<std::optional> (2);
38  const auto& app = GSL (GSL (summer, s1), s2);
39  QCOMPARE (app, std::optional<int> { 3 });
40  }
41 
42  void ApplicativeTest::testBoostOptionalGSLOperatorCurry ()
43  {
44  const auto& summer = Pure<std::optional> (Curry ([] (int a, int b) { return a + b; }));
45  const auto& app = summer * Pure<std::optional> (1) * Pure<std::optional> (2);
46  QCOMPARE (app, std::optional<int> { 3 });
47  }
48 }
49 }
LC::Util::Curry
CurryImpl< std::decay_t< F >, Args... > Curry(F &&f, Args &&... args)
Definition: curry.h:84
LC::Util::ApplicativeTest
Definition: applicativetest.h:29
applicativetest.h
applicative.h
LC
Definition: constants.h:14
curry.h
LC::Util::GSL
GSLResult_t< AF, AV > GSL(const AF &af, const AV &av)
Definition: applicative.h:49