4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief type_traits unit tests */
26 //#include "type_traits.test.hh"
27 //#include "type_traits.test.ih"
30 #include <boost/static_assert.hpp>
31 #include <boost/type_traits/is_same.hpp>
32 #include "type_traits.hh"
34 #include <senf/Utils/auto_unit_test.hh>
35 #include <boost/test/test_tools.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
44 SENF_AUTO_UNIT_TEST(typeTraits)
46 typedef boost::function_traits<void (int, double)> traits;
48 BOOST_STATIC_ASSERT(( boost::is_same<
49 senf::function_traits_remove_arg< traits >::type,
50 boost::function_traits<void (double)>
53 BOOST_STATIC_ASSERT(( boost::is_same<
54 senf::function_traits_arg_type< traits, 0 >::type,
57 BOOST_STATIC_ASSERT(( boost::is_same<
58 senf::function_traits_arg_type< traits, 2 >::type,
62 BOOST_STATIC_ASSERT(( boost::is_same<
63 senf::remove_member_pointer< Class (Class::*) >::type,
66 BOOST_STATIC_ASSERT(( boost::is_same<
67 senf::remove_member_pointer< Class const (Class::*) >::type,
70 BOOST_STATIC_ASSERT(( boost::is_same<
71 senf::remove_member_pointer< Class (Class::*)(int) >::type,
74 BOOST_STATIC_ASSERT(( boost::is_same<
75 senf::remove_member_pointer< Class const (Class::*)(int) >::type,
78 BOOST_STATIC_ASSERT(( boost::is_same<
79 senf::remove_member_pointer< void (Class::*)(int) const>::type,
82 BOOST_STATIC_ASSERT(( boost::is_same<
83 senf::remove_member_pointer< Class const (Class::*)(int) const>::type,
86 BOOST_STATIC_ASSERT(( boost::is_same<
87 senf::remove_member_pointer< void (Class::* const)(int)>::type,
90 BOOST_STATIC_ASSERT(( boost::is_same<
91 senf::remove_member_pointer< void (Class::* const)(int) const>::type,
95 BOOST_STATIC_ASSERT(( boost::is_same<
96 senf::member_class< int (Class::*) >::type,
99 BOOST_STATIC_ASSERT(( boost::is_same<
100 senf::member_class< int * >::type,
104 BOOST_STATIC_ASSERT(( boost::is_same<
105 senf::remove_any_pointer< int (Class::*) >::type,
108 BOOST_STATIC_ASSERT(( boost::is_same<
109 senf::remove_any_pointer< void (Class::*)(int) >::type,
112 BOOST_STATIC_ASSERT(( boost::is_same<
113 senf::remove_any_pointer < int (*)() >::type,
116 BOOST_STATIC_ASSERT(( boost::is_same<
117 senf::remove_any_pointer < int >::type,
121 BOOST_STATIC_ASSERT(( senf::is_any_function< void () >::value ));
122 BOOST_STATIC_ASSERT(( senf::is_any_function< void (*)(int) >::value ));
123 BOOST_STATIC_ASSERT(( senf::is_any_function< void (Class::*)() >::value ));
124 BOOST_STATIC_ASSERT(( senf::is_any_function< void (Class::*)() const >::value ));
125 BOOST_STATIC_ASSERT(( ! senf::is_any_function< int * >::value ));
127 BOOST_STATIC_ASSERT(( boost::is_same<
128 senf::remove_cvref<int const &>::type,
132 BOOST_STATIC_ASSERT(( senf::function_arity<void ()>::value == 0 ));
133 BOOST_STATIC_ASSERT(( senf::function_arity<void (int,int)>::value == 2 ));
134 BOOST_STATIC_ASSERT(( senf::function_arity<void (*)()>::value == 0 ));
135 BOOST_STATIC_ASSERT(( senf::function_arity<void (*)(int,int)>::value == 2 ));
136 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)()>::value == 0 ));
137 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)(int,int)>::value == 2 ));
139 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)(int)>::value == 1 ));
141 BOOST_STATIC_ASSERT(( senf::is_pair< std::pair<int,void*> >::value ));
142 BOOST_STATIC_ASSERT(( ! senf::is_pair< void () >::value ));
147 ///////////////////////////////cc.e////////////////////////////////////////
154 // comment-column: 40
155 // c-file-style: "senf"
156 // indent-tabs-mode: nil
157 // ispell-local-dictionary: "american"
158 // compile-command: "scons -u test"