LeechCraft 0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
typegettertest.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 "typegettertest.h"
10#include <type_traits>
11#include <QtTest>
12#include <typegetter.h>
13
14QTEST_MAIN (LC::Util::TypeGetterTest)
15
16namespace LC
17{
18namespace Util
19{
20 void TypeGetterTest::testArgType ()
21 {
22 const auto f = [] (int, const double) {};
23 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int>);
24 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, double>);
25 }
26
27 void TypeGetterTest::testArgTypeRef ()
28 {
29 const auto f = [] (int&, const double&) {};
30 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&>);
31 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&>);
32 }
33
34 void TypeGetterTest::testArgTypeRvalueRef ()
35 {
36 const auto f = [] (int&&, const double&&) {};
37 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&&>);
38 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&&>);
39 }
40
41 void TypeGetterTest::testRetType ()
42 {
43 const auto f = [] (int val, const double) { return val; };
44 static_assert (std::is_same_v<RetType_t<decltype (f)>, int>);
45 }
46
47 void TypeGetterTest::testRetTypeVoid ()
48 {
49 const auto f = [] {};
50 static_assert (std::is_same_v<RetType_t<decltype (f)>, void>);
51 }
52
53 void TypeGetterTest::testRetTypeRef ()
54 {
55 int x;
56 const auto f = [&x] (int, const double) -> int& { return x; };
57 static_assert (std::is_same_v<RetType_t<decltype (f)>, int&>);
58 }
59
60 void TypeGetterTest::testRetTypeConstRef ()
61 {
62 int x;
63 const auto f = [&x] (int, const double) -> const int& { return x; };
64 static_assert (std::is_same_v<RetType_t<decltype (f)>, const int&>);
65 }
66
67 void TypeGetterTest::testArgCount ()
68 {
69 const auto f = [] (int, const double) {};
70 static_assert (ArgCount_v<decltype (f)> == 2);
71 }
72}
73}
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
Definition oral.h:1079
std::tuple_element_t< 0, detail::CallTypeGetter_t< F > > RetType_t
Definition typegetter.h:52
constexpr auto ArgCount_v
Definition typegetter.h:55
std::tuple_element_t< Idx+1, detail::CallTypeGetter_t< F > > ArgType_t
Definition typegetter.h:49
Definition constants.h:15