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 | // $Source: /cvsroot/boost/boost/libs/mpl/test/deque.cpp,v $ |
---|
11 | // $Date: 2004/11/28 03:35:12 $ |
---|
12 | // $Revision: 1.2 $ |
---|
13 | |
---|
14 | #include <boost/mpl/deque.hpp> |
---|
15 | #include <boost/mpl/push_back.hpp> |
---|
16 | #include <boost/mpl/pop_back.hpp> |
---|
17 | #include <boost/mpl/push_front.hpp> |
---|
18 | #include <boost/mpl/pop_front.hpp> |
---|
19 | #include <boost/mpl/back.hpp> |
---|
20 | #include <boost/mpl/front.hpp> |
---|
21 | #include <boost/mpl/size.hpp> |
---|
22 | #include <boost/mpl/empty.hpp> |
---|
23 | |
---|
24 | #include <boost/mpl/aux_/test.hpp> |
---|
25 | |
---|
26 | |
---|
27 | MPL_TEST_CASE() |
---|
28 | { |
---|
29 | typedef deque<> d0; |
---|
30 | typedef deque<char> d1; |
---|
31 | typedef deque<char,long> d2; |
---|
32 | typedef deque<char,char,char,char,char,char,char,char,int> d9; |
---|
33 | |
---|
34 | MPL_ASSERT_RELATION( size<d0>::value, ==, 0 ); |
---|
35 | MPL_ASSERT_RELATION( size<d1>::value, ==, 1 ); |
---|
36 | MPL_ASSERT_RELATION( size<d2>::value, ==, 2 ); |
---|
37 | MPL_ASSERT_RELATION( size<d9>::value, ==, 9 ); |
---|
38 | |
---|
39 | MPL_ASSERT(( empty<d0> )); |
---|
40 | MPL_ASSERT_NOT(( empty<d1> )); |
---|
41 | MPL_ASSERT_NOT(( empty<d2> )); |
---|
42 | MPL_ASSERT_NOT(( empty<d9> )); |
---|
43 | |
---|
44 | MPL_ASSERT(( is_same< front<d1>::type,char > )); |
---|
45 | MPL_ASSERT(( is_same< back<d1>::type,char > )); |
---|
46 | MPL_ASSERT(( is_same< front<d2>::type,char > )); |
---|
47 | MPL_ASSERT(( is_same< back<d2>::type,long > )); |
---|
48 | MPL_ASSERT(( is_same< front<d9>::type,char > )); |
---|
49 | MPL_ASSERT(( is_same< back<d9>::type,int > )); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | MPL_TEST_CASE() |
---|
54 | { |
---|
55 | typedef deque<char,long> d2; |
---|
56 | |
---|
57 | typedef begin<d2>::type i1; |
---|
58 | typedef next<i1>::type i2; |
---|
59 | typedef next<i2>::type i3; |
---|
60 | |
---|
61 | MPL_ASSERT(( is_same<deref<i1>::type,char> )); |
---|
62 | MPL_ASSERT(( is_same<deref<i2>::type,long> )); |
---|
63 | MPL_ASSERT(( is_same< i3, end<d2>::type > )); |
---|
64 | } |
---|
65 | |
---|
66 | MPL_TEST_CASE() |
---|
67 | { |
---|
68 | typedef deque<> d0; |
---|
69 | |
---|
70 | typedef push_back<d0,int>::type d1; |
---|
71 | MPL_ASSERT(( is_same< back<d1>::type,int > )); |
---|
72 | |
---|
73 | typedef push_front<d1,char>::type d2; |
---|
74 | MPL_ASSERT(( is_same< back<d2>::type,int > )); |
---|
75 | MPL_ASSERT(( is_same< front<d2>::type,char > )); |
---|
76 | |
---|
77 | typedef push_back<d2,long>::type d3; |
---|
78 | MPL_ASSERT(( is_same< back<d3>::type,long > )); |
---|
79 | } |
---|
80 | |
---|
81 | MPL_TEST_CASE() |
---|
82 | { |
---|
83 | typedef deque<> d0; |
---|
84 | typedef deque<char> d1; |
---|
85 | typedef deque<char,long> d2; |
---|
86 | typedef deque<char,char,char,char,char,char,char,char,int> d9; |
---|
87 | |
---|
88 | MPL_ASSERT_RELATION( size<d0>::value, ==, 0 ); |
---|
89 | MPL_ASSERT_RELATION( size<d1>::value, ==, 1 ); |
---|
90 | MPL_ASSERT_RELATION( size<d2>::value, ==, 2 ); |
---|
91 | MPL_ASSERT_RELATION( size<d9>::value, ==, 9 ); |
---|
92 | } |
---|