Move sourcecode into 'senf/' directory
[senf.git] / senf / Utils / type_traits.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2008 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief type_traits unit tests */
25
26 //#include "type_traits.test.hh"
27 //#include "type_traits.test.ih"
28
29 // Custom includes
30 #include <boost/static_assert.hpp>
31 #include <boost/type_traits/is_same.hpp>
32 #include "type_traits.hh"
33
34 #include "../Utils/auto_unit_test.hh"
35 #include <boost/test/test_tools.hpp>
36
37 #define prefix_
38 ///////////////////////////////cc.p////////////////////////////////////////
39
40 namespace {
41     struct Class {};
42 }
43
44 BOOST_AUTO_UNIT_TEST(typeTraits)
45 {
46     typedef boost::function_traits<void (int, double)> traits;
47
48     BOOST_STATIC_ASSERT(( boost::is_same< 
49         senf::function_traits_remove_arg< traits >::type, 
50         boost::function_traits<void (double)> 
51     >::value ));
52
53     BOOST_STATIC_ASSERT(( boost::is_same<
54         senf::function_traits_arg_type< traits, 0 >::type,
55         int
56     >::value ));
57     BOOST_STATIC_ASSERT(( boost::is_same<
58         senf::function_traits_arg_type< traits, 2 >::type,
59         void
60     >::value ));
61
62     BOOST_STATIC_ASSERT(( boost::is_same< 
63         senf::remove_member_pointer< int (Class::*) >::type, 
64         int 
65     >::value ));
66     BOOST_STATIC_ASSERT(( boost::is_same< 
67         senf::remove_member_pointer< void (Class::*)(int) >::type, 
68         void (int)
69     >::value ));
70
71     BOOST_STATIC_ASSERT(( boost::is_same<
72         senf::member_class< int (Class::*) >::type,
73         Class
74     >::value ));
75     BOOST_STATIC_ASSERT(( boost::is_same<
76         senf::member_class< int * >::type,
77         void
78     >::value ));
79
80     BOOST_STATIC_ASSERT(( boost::is_same< 
81         senf::remove_any_pointer< int (Class::*) >::type, 
82         int
83     >::value ));
84     BOOST_STATIC_ASSERT(( boost::is_same< 
85         senf::remove_any_pointer< void (Class::*)(int) >::type, 
86         void (int)
87     >::value ));
88     BOOST_STATIC_ASSERT(( boost::is_same<
89         senf::remove_any_pointer < int (*)() >::type,
90         int ()
91     >::value ));
92     BOOST_STATIC_ASSERT(( boost::is_same<
93         senf::remove_any_pointer < int >::type,
94         int
95     >::value ));
96
97     BOOST_STATIC_ASSERT((   senf::is_any_function< void () >::value ));
98     BOOST_STATIC_ASSERT((   senf::is_any_function< void (*)(int) >::value ));
99     BOOST_STATIC_ASSERT((   senf::is_any_function< void (Class::*)() >::value ));
100     BOOST_STATIC_ASSERT(( ! senf::is_any_function< int * >::value ));
101
102     BOOST_STATIC_ASSERT(( boost::is_same<
103         senf::remove_cvref<int const &>::type,
104         int
105     >::value ));
106 }
107
108 ///////////////////////////////cc.e////////////////////////////////////////
109 #undef prefix_
110
111 \f
112 // Local Variables:
113 // mode: c++
114 // fill-column: 100
115 // comment-column: 40
116 // c-file-style: "senf"
117 // indent-tabs-mode: nil
118 // ispell-local-dictionary: "american"
119 // compile-command: "scons -u test"
120 // End: