LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
functortest.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 "functortest.h"
10 #include <QtTest>
11 #include <functor.h>
12 
13 QTEST_MAIN (LC::Util::FunctorTest)
14 
15 namespace LC
16 {
17 namespace Util
18 {
19  void FunctorTest::testBoostOptionalFMap ()
20  {
21  std::optional<int> value { 2 };
22  const auto& fmapped = Fmap (value, [] (int val) { return QString::number (val); });
23  QCOMPARE (std::optional<QString> { "2" }, fmapped);
24  }
25 
26  void FunctorTest::testBoostOptionalFMapEmpty ()
27  {
28  std::optional<int> value;
29  const auto& fmapped = Fmap (value, [] (int val) { return QString::number (val); });
30  QCOMPARE (std::optional<QString> {}, fmapped);
31  }
32 
33  void FunctorTest::testIsFunctorTrue ()
34  {
35  static_assert (IsFunctor<std::optional<int>> (), "test failed");
36  }
37 
38  void FunctorTest::testIsFunctorFalse ()
39  {
40  static_assert (!IsFunctor<int> (), "test failed");
41  }
42 }
43 }
LC::Util::FunctorTest
Definition: functortest.h:29
LC::Util::Fmap
FmapResult_t< T, F > Fmap(const T &functor, const F &function)
Apply the function f to the elements in functor.
Definition: functor.h:140
functortest.h
LC::Util::IsFunctor
constexpr bool IsFunctor()
Checks whether the given type has a Functor instance for it.
Definition: functor.h:104
LC
Definition: constants.h:14
functor.h