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_c.hpp>
15 #include <boost/mpl/front.hpp>
16 #include <boost/mpl/size.hpp>
17 #include <boost/static_assert.hpp>
18
19 #include <boost/mpl/aux_/test.hpp>
20
21
22 #if !BOOST_WORKAROUND(BOOST_MSVC,<= 1200)
MPL_TEST_CASE()23 MPL_TEST_CASE()
24 {
25 typedef list_c<bool,true>::type l1;
26 typedef list_c<bool,false>::type l2;
27
28 MPL_ASSERT(( is_same< l1::value_type, bool > ));
29 MPL_ASSERT(( is_same< l2::value_type, bool > ));
30
31 MPL_ASSERT_RELATION( front<l1>::type::value, ==, true );
32 MPL_ASSERT_RELATION( front<l2>::type::value, ==, false );
33 }
34 #endif
35
MPL_TEST_CASE()36 MPL_TEST_CASE()
37 {
38 typedef list_c<int,-1>::type l1;
39 typedef list_c<int,0,1>::type l2;
40 typedef list_c<int,1,2,3>::type l3;
41
42 MPL_ASSERT(( is_same< l1::value_type, int > ));
43 MPL_ASSERT(( is_same< l2::value_type, int > ));
44 MPL_ASSERT(( is_same< l3::value_type, int > ));
45
46 MPL_ASSERT_RELATION( size<l1>::value, ==, 1 );
47 MPL_ASSERT_RELATION( size<l2>::value, ==, 2 );
48 MPL_ASSERT_RELATION( size<l3>::value, ==, 3 );
49 MPL_ASSERT_RELATION( front<l1>::type::value, ==, -1 );
50 MPL_ASSERT_RELATION( front<l2>::type::value, ==, 0 );
51 MPL_ASSERT_RELATION( front<l3>::type::value, ==, 1 );
52 }
53
MPL_TEST_CASE()54 MPL_TEST_CASE()
55 {
56 typedef list_c<unsigned,0>::type l1;
57 typedef list_c<unsigned,1,2>::type l2;
58
59 MPL_ASSERT(( is_same< l1::value_type, unsigned > ));
60 MPL_ASSERT(( is_same< l2::value_type, unsigned > ));
61
62 MPL_ASSERT_RELATION( size<l1>::value, ==, 1 );
63 MPL_ASSERT_RELATION( size<l2>::value, ==, 2 );
64 MPL_ASSERT_RELATION( front<l1>::type::value, ==, 0 );
65 MPL_ASSERT_RELATION( front<l2>::type::value, ==, 1 );
66 }
67
MPL_TEST_CASE()68 MPL_TEST_CASE()
69 {
70 typedef list_c<unsigned,2,1> l2;
71
72 MPL_ASSERT(( is_same< l2::value_type, unsigned > ));
73
74 typedef begin<l2>::type i1;
75 typedef next<i1>::type i2;
76 typedef next<i2>::type i3;
77
78 MPL_ASSERT_RELATION( deref<i1>::type::value, ==, 2 );
79 MPL_ASSERT_RELATION( deref<i2>::type::value, ==, 1 );
80 MPL_ASSERT(( is_same< i3, end<l2>::type > ));
81 }
82