4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief type_traits unit tests */
31 //#include "type_traits.test.hh"
32 //#include "type_traits.test.ih"
35 #include <boost/static_assert.hpp>
36 #include <boost/type_traits/is_same.hpp>
37 #include "type_traits.hh"
39 #include <senf/Utils/auto_unit_test.hh>
40 #include <boost/test/test_tools.hpp>
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 SENF_AUTO_UNIT_TEST(typeTraits)
51 typedef boost::function_traits<void (int, double)> traits;
53 BOOST_STATIC_ASSERT(( boost::is_same<
54 senf::function_traits_remove_arg< traits >::type,
55 boost::function_traits<void (double)>
58 BOOST_STATIC_ASSERT(( boost::is_same<
59 senf::function_traits_arg_type< traits, 0 >::type,
62 BOOST_STATIC_ASSERT(( boost::is_same<
63 senf::function_traits_arg_type< traits, 2 >::type,
67 BOOST_STATIC_ASSERT(( boost::is_same<
68 senf::remove_member_pointer< Class (Class::*) >::type,
71 BOOST_STATIC_ASSERT(( boost::is_same<
72 senf::remove_member_pointer< Class const (Class::*) >::type,
75 BOOST_STATIC_ASSERT(( boost::is_same<
76 senf::remove_member_pointer< Class (Class::*)(int) >::type,
79 BOOST_STATIC_ASSERT(( boost::is_same<
80 senf::remove_member_pointer< Class const (Class::*)(int) >::type,
83 BOOST_STATIC_ASSERT(( boost::is_same<
84 senf::remove_member_pointer< void (Class::*)(int) const>::type,
87 BOOST_STATIC_ASSERT(( boost::is_same<
88 senf::remove_member_pointer< Class const (Class::*)(int) const>::type,
91 BOOST_STATIC_ASSERT(( boost::is_same<
92 senf::remove_member_pointer< void (Class::* const)(int)>::type,
95 BOOST_STATIC_ASSERT(( boost::is_same<
96 senf::remove_member_pointer< void (Class::* const)(int) const>::type,
100 BOOST_STATIC_ASSERT(( boost::is_same<
101 senf::member_class< int (Class::*) >::type,
104 BOOST_STATIC_ASSERT(( boost::is_same<
105 senf::member_class< int * >::type,
109 BOOST_STATIC_ASSERT(( boost::is_same<
110 senf::remove_any_pointer< int (Class::*) >::type,
113 BOOST_STATIC_ASSERT(( boost::is_same<
114 senf::remove_any_pointer< void (Class::*)(int) >::type,
117 BOOST_STATIC_ASSERT(( boost::is_same<
118 senf::remove_any_pointer < int (*)() >::type,
121 BOOST_STATIC_ASSERT(( boost::is_same<
122 senf::remove_any_pointer < int >::type,
126 BOOST_STATIC_ASSERT(( senf::is_any_function< void () >::value ));
127 BOOST_STATIC_ASSERT(( senf::is_any_function< void (*)(int) >::value ));
128 BOOST_STATIC_ASSERT(( senf::is_any_function< void (Class::*)() >::value ));
129 BOOST_STATIC_ASSERT(( senf::is_any_function< void (Class::*)() const >::value ));
130 BOOST_STATIC_ASSERT(( ! senf::is_any_function< int * >::value ));
132 BOOST_STATIC_ASSERT(( boost::is_same<
133 senf::remove_cvref<int const &>::type,
137 BOOST_STATIC_ASSERT(( senf::function_arity<void ()>::value == 0 ));
138 BOOST_STATIC_ASSERT(( senf::function_arity<void (int,int)>::value == 2 ));
139 BOOST_STATIC_ASSERT(( senf::function_arity<void (*)()>::value == 0 ));
140 BOOST_STATIC_ASSERT(( senf::function_arity<void (*)(int,int)>::value == 2 ));
141 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)()>::value == 0 ));
142 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)(int,int)>::value == 2 ));
144 BOOST_STATIC_ASSERT(( senf::function_arity<void (Class::*)(int)>::value == 1 ));
146 BOOST_STATIC_ASSERT(( senf::is_pair< std::pair<int,void*> >::value ));
147 BOOST_STATIC_ASSERT(( ! senf::is_pair< void () >::value ));
152 //-/////////////////////////////////////////////////////////////////////////////////////////////////
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"