LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
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
13QTEST_MAIN (LC::Util::FunctorTest)
14
15namespace LC
16{
17namespace 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}
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
FmapResult_t< T, F > Fmap(const T &functor, const F &function)
Apply the function f to the elements in functor.
Definition functor.h:128
Definition constants.h:15