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 mpl unit tests */
26 //#include "mpl.test.hh"
27 //#include "mpl.test.ih"
32 #include <senf/Utils/auto_unit_test.hh>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
42 static bool const has_int_value = false;
43 static bool const has_class_value = false;
46 senf::mpl::rv<0> select_(...);
51 static bool const has_int_value = true;
52 static bool const has_class_value = false;
55 senf::mpl::rv<1> select_(int, senf::mpl::take_int<T::value> * = 0);
59 static bool const has_int_value = false;
60 static bool const has_class_value = true;
63 senf::mpl::rv<2> select_(int, senf::mpl::take_class<typename T::value> * = 0);
66 struct choice : public select<SENF_MPL_RV( select_<T>(0) )> {};
68 struct A { static const int value = 0; };
69 struct B { struct value {}; };
73 SENF_AUTO_UNIT_TEST(senfmpl)
75 BOOST_CHECK( choice<A>::has_int_value );
76 BOOST_CHECK( ! choice<A>::has_class_value );
78 BOOST_CHECK( ! choice<B>::has_int_value );
79 BOOST_CHECK( choice<B>::has_class_value );
81 BOOST_CHECK( ! choice<C>::has_int_value );
82 BOOST_CHECK( ! choice<C>::has_class_value );
87 # define Begin() SENF_MPL_SLOT_DEF(accum, 0)
88 # define Add(n) SENF_MPL_SLOT_SET(accum, SENF_MPL_SLOT_GET(accum)+n)
89 # define End() BOOST_STATIC_CONSTANT(unsigned, total = SENF_MPL_SLOT_GET(accum))
98 // Here some comment ...
107 SENF_AUTO_UNIT_TEST(mplSlot)
109 BOOST_CHECK_EQUAL( unsigned(Test::total), 8u );
112 ///////////////////////////////cc.e////////////////////////////////////////
119 // comment-column: 40
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"