LeechCraft 0.6.70-17335-ge406ffdcaf
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 namespace
21 {
22 template<typename T>
23 void PrintType ()
24 {
25 qDebug () << Q_FUNC_INFO;
26 }
27 }
28
29 void TypeGetterTest::testArgType ()
30 {
31 const auto f = [] (int, const double) {};
32 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int>);
33 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, double>);
34 }
35
36 void TypeGetterTest::testArgTypeRef ()
37 {
38 const auto f = [] (int&, const double&) {};
39 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&>);
40 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&>);
41 }
42
43 void TypeGetterTest::testArgTypeRvalueRef ()
44 {
45 const auto f = [] (int&&, const double&&) {};
46 static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&&>);
47 static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&&>);
48 }
49
50 void TypeGetterTest::testRetType ()
51 {
52 const auto f = [] (int val, const double) { return val; };
53 static_assert (std::is_same_v<RetType_t<decltype (f)>, int>);
54 }
55
56 void TypeGetterTest::testRetTypeVoid ()
57 {
58 const auto f = [] {};
59 static_assert (std::is_same_v<RetType_t<decltype (f)>, void>);
60 }
61
62 void TypeGetterTest::testRetTypeRef ()
63 {
64 int x;
65 const auto f = [&x] (int, const double) -> int& { return x; };
66 static_assert (std::is_same_v<RetType_t<decltype (f)>, int&>);
67 }
68
69 void TypeGetterTest::testRetTypeConstRef ()
70 {
71 int x;
72 const auto f = [&x] (int, const double) -> const int& { return x; };
73 static_assert (std::is_same_v<RetType_t<decltype (f)>, const int&>);
74 }
75
76 void TypeGetterTest::testArgCount ()
77 {
78 const auto f = [] (int, const double) {};
79 static_assert (ArgCount_v<decltype (f)> == 2);
80 }
81}
82}
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
Definition oral.h:936
std::tuple_element_t< 0, detail::CallTypeGetter_t< F > > RetType_t
Definition typegetter.h:43
constexpr auto ArgCount_v
Definition typegetter.h:46
std::tuple_element_t< Idx+1, detail::CallTypeGetter_t< F > > ArgType_t
Definition typegetter.h:40
Definition constants.h:15