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 mpl unit tests */
31 //#include "mpl.test.hh"
32 //#include "mpl.test.ih"
37 #include <senf/Utils/auto_unit_test.hh>
38 #include <boost/test/test_tools.hpp>
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 static bool const has_int_value = false;
48 static bool const has_class_value = false;
51 senf::mpl::rv<0> select_(...);
56 static bool const has_int_value = true;
57 static bool const has_class_value = false;
60 senf::mpl::rv<1> select_(int, senf::mpl::take_int<T::value> * = 0);
64 static bool const has_int_value = false;
65 static bool const has_class_value = true;
68 senf::mpl::rv<2> select_(int, senf::mpl::take_class<typename T::value> * = 0);
71 struct choice : public select<SENF_MPL_RV( select_<T>(0) )> {};
73 struct A { static const int value = 0; };
74 struct B { struct value {}; };
78 SENF_AUTO_UNIT_TEST(senfmpl)
80 BOOST_CHECK( choice<A>::has_int_value );
81 BOOST_CHECK( ! choice<A>::has_class_value );
83 BOOST_CHECK( ! choice<B>::has_int_value );
84 BOOST_CHECK( choice<B>::has_class_value );
86 BOOST_CHECK( ! choice<C>::has_int_value );
87 BOOST_CHECK( ! choice<C>::has_class_value );
92 # define Begin() SENF_MPL_SLOT_DEF(accum, 0)
93 # define Add(n) SENF_MPL_SLOT_SET(accum, SENF_MPL_SLOT_GET(accum)+n)
94 # define End() BOOST_STATIC_CONSTANT(unsigned, total = SENF_MPL_SLOT_GET(accum))
103 // Here some comment ...
112 SENF_AUTO_UNIT_TEST(mplSlot)
114 BOOST_CHECK_EQUAL( unsigned(Test::total), 8u );
117 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 // comment-column: 40
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"