1
2 // Copyright Aleksey Gurtovoy 2000-2004
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/libs/mpl for documentation.
9
10 // $Id$
11 // $Date$
12 // $Revision$
13
14 #include <boost/mpl/list.hpp>
15 #include <boost/mpl/push_front.hpp>
16 #include <boost/mpl/pop_front.hpp>
17 #include <boost/mpl/front.hpp>
18 #include <boost/mpl/size.hpp>
19 #include <boost/mpl/empty.hpp>
20
21 #include <boost/mpl/aux_/test.hpp>
22
23
MPL_TEST_CASE()24 MPL_TEST_CASE()
25 {
26 typedef list0<> l0;
27 typedef list1<char> l1;
28 typedef list2<char,long> l2;
29 typedef list9<char,char,char,char,char,char,char,char,char> l9;
30
31 MPL_ASSERT_RELATION(size<l0>::value, ==, 0);
32 MPL_ASSERT_RELATION(size<l1>::value, ==, 1);
33 MPL_ASSERT_RELATION(size<l2>::value, ==, 2);
34 MPL_ASSERT_RELATION(size<l9>::value, ==, 9);
35
36 MPL_ASSERT(( empty<l0> ));
37 MPL_ASSERT_NOT(( empty<l1> ));
38 MPL_ASSERT_NOT(( empty<l2> ));
39 MPL_ASSERT_NOT(( empty<l9> ));
40
41 MPL_ASSERT(( is_same<front<l1>::type,char> ));
42 MPL_ASSERT(( is_same<front<l2>::type,char> ));
43 MPL_ASSERT(( is_same<front<l9>::type,char> ));
44 }
45
MPL_TEST_CASE()46 MPL_TEST_CASE()
47 {
48 typedef list2<char,long> l2;
49
50 typedef begin<l2>::type i1;
51 typedef next<i1>::type i2;
52 typedef next<i2>::type i3;
53
54 MPL_ASSERT(( is_same<deref<i1>::type,char> ));
55 MPL_ASSERT(( is_same<deref<i2>::type,long> ));
56 MPL_ASSERT(( is_same< i3, end<l2>::type > ));
57 }
58
MPL_TEST_CASE()59 MPL_TEST_CASE()
60 {
61 typedef list0<> l0;
62
63 typedef push_front<l0,char>::type l1;
64 MPL_ASSERT(( is_same<front<l1>::type,char> ));
65
66 typedef push_front<l1,long>::type l2;
67 MPL_ASSERT(( is_same<front<l2>::type,long> ));
68 }
69