-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittests.cpp
More file actions
84 lines (67 loc) · 1.76 KB
/
unittests.cpp
File metadata and controls
84 lines (67 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// main.cpp
// FunctionTraits
//
// Created by Sachit Vithaldas on 22/10/17.
//
//
#include <iostream>
#include <type_traits>
#include <functional>
#include "headers/functiontraits.h"
class Dummy
{
int a;
float b;
};
class Example
{
public:
int exampleFn1( int &&a, int const &b, int c ) const
{
(void) a;
(void) b;
(void) c;
return 5;
}
int operator()( int const a ) const
{
(void) a;
return 5;
}
void exampleDummy( Dummy const &dummy )
{
(void) dummy;
return;
}
void blank()
{
return;
}
};
int main( int argc, const char *argv[] )
{
// insert code here...
using namespace custom_traits;
using namespace std;
std::function<int( double )> test;
static_assert( is_const_member_function<decltype( &Example::exampleFn1 )>::value, "" );
static_assert( is_const_member_function<decltype( &Example::operator())>::value, "" );
using E1 = function_traits<decltype( &Example::exampleFn1 )>;
static_assert( is_same<E1::return_type, int>(), "" );
static_assert( E1::arity == 3, "" );
static_assert( is_same<E1::argument<0>::type, int &&>::value, "" );
static_assert( is_rvalue_reference<E1::argument<0>::type>::value, "" );
using E2 = function_traits<decltype( &Example::operator())>;
static_assert( E2::arity == 1, "" );
using E3 = function_traits<decltype( test )>;
static_assert( is_same<E3::return_type, int>(), "" );
static_assert( is_floating_point<E3::argument<0>::type>::value, "" );
using E4 = function_traits<decltype( &Example::blank )>;
static_assert( E4::arity == 0, "" );
using E5 = function_traits<decltype( &Example::exampleDummy )>;
static_assert( is_const<remove_reference<E5::argument<0>::type>::type>::value, "" );
static_assert( is_same<E5::return_type, void>::value, "" );
cout << "Success" << endl;
return 0;
}