summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/mpl/test/vector.cpp
blob: e1f6e0cbbb3c33dac359348f2ebb4509adc13943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright Aleksey Gurtovoy 2000-2005
//
// Distributed under the Boost Software License, Version 1.0. 
// (See accompanying file LICENSE_1_0.txt or copy at 
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.

// $Id$
// $Date$
// $Revision$

#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/pop_back.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>

#include <boost/mpl/aux_/test.hpp>


MPL_TEST_CASE()
{
    typedef vector0<> v0;
    typedef vector1<char> v1;
    typedef vector2<char,long> v2;
    typedef vector9<char,char,char,char,char,char,char,char,int> v9;

    MPL_ASSERT(( equal< v0,v0::type > ));
    MPL_ASSERT(( equal< v1,v1::type > ));
    MPL_ASSERT(( equal< v2,v2::type > ));
    MPL_ASSERT(( equal< v9,v9::type > ));

    MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
    MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
    MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
    MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );

    MPL_ASSERT(( empty<v0> ));
    MPL_ASSERT_NOT(( empty<v1> ));
    MPL_ASSERT_NOT(( empty<v2> ));
    MPL_ASSERT_NOT(( empty<v9> ));

    MPL_ASSERT(( is_same< front<v1>::type,char > ));
    MPL_ASSERT(( is_same< back<v1>::type,char > ));
    MPL_ASSERT(( is_same< front<v2>::type,char > ));
    MPL_ASSERT(( is_same< back<v2>::type,long > ));
    MPL_ASSERT(( is_same< front<v9>::type,char > ));
    MPL_ASSERT(( is_same< back<v9>::type,int > ));
}


MPL_TEST_CASE()
{
    typedef vector2<char,long> v2;
    
    typedef begin<v2>::type i1;
    typedef next<i1>::type  i2;
    typedef next<i2>::type  i3;
    
    MPL_ASSERT(( is_same<deref<i1>::type,char> ));
    MPL_ASSERT(( is_same<deref<i2>::type,long> ));
    MPL_ASSERT(( is_same< i3, end<v2>::type > ));
}

MPL_TEST_CASE()
{
    typedef vector0<> v0;

    typedef push_back<v0,int>::type     v1;
    typedef push_front<v1,char>::type   v2;
    typedef push_back<v2,long>::type    v3;

    MPL_ASSERT(( is_same< back<v1>::type,int > ));
    MPL_ASSERT(( is_same< back<v2>::type,int > ));
    MPL_ASSERT(( is_same< front<v2>::type,char > ));
    MPL_ASSERT(( is_same< back<v3>::type,long > ));

    MPL_ASSERT(( equal< v1,v1::type > ));
    MPL_ASSERT(( equal< v2,v2::type > ));
    MPL_ASSERT(( equal< v3,v3::type > ));
}

MPL_TEST_CASE()
{
    typedef vector9<char,bool,char,char,char,char,bool,long,int> v9;

    typedef pop_back<v9>::type  v8;
    typedef pop_front<v8>::type v7;

    MPL_ASSERT(( is_same< back<v9>::type,int > ));
    MPL_ASSERT(( is_same< back<v8>::type,long > ));
    MPL_ASSERT(( is_same< back<v7>::type,long > ));
    MPL_ASSERT(( is_same< front<v7>::type,bool > ));

    MPL_ASSERT(( equal< v9,v9::type > ));
    MPL_ASSERT(( equal< v8,v8::type > ));
    MPL_ASSERT(( equal< v7,v7::type > ));
}

MPL_TEST_CASE()
{
    typedef vector<> v0;
    typedef vector<char> v1;
    typedef vector<char,long> v2;
    typedef vector<char,char,char,char,char,char,char,char,int> v9;

    MPL_ASSERT(( equal< v0,v0::type > ));
    MPL_ASSERT(( equal< v1,v1::type > ));
    MPL_ASSERT(( equal< v2,v2::type > ));
    MPL_ASSERT(( equal< v9,v9::type > ));

    MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
    MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
    MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
    MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );
}