1 /*=============================================================================
2 Copyright (c) 1999-2003 Jaakko Jarvi
3 Copyright (c) 2001-2011 Joel de Guzman
4 Copyright (c) 2006 Dan Marsden
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #include <boost/detail/lightweight_test.hpp>
11 #include <boost/fusion/container/deque/deque.hpp>
12 #include <boost/fusion/container/deque/front_extended_deque.hpp>
13 #include <boost/fusion/sequence/comparison.hpp>
14 #include <boost/fusion/container/generation/make_vector.hpp>
15 #include <boost/fusion/mpl.hpp>
17 #include <boost/fusion/sequence/intrinsic.hpp>
18 #include <boost/fusion/iterator.hpp>
20 #include <boost/mpl/assert.hpp>
21 #include <boost/type_traits/is_same.hpp>
25 using namespace boost::fusion
;
27 typedef deque
<> initial_deque_type
;
28 initial_deque_type initial_deque
;
29 typedef front_extended_deque
<initial_deque_type
, int> extended_type
;
30 extended_type
extended(initial_deque
, 1);
32 BOOST_TEST(size(extended
) == 1);
33 BOOST_TEST(extended
== make_vector(1));
34 BOOST_TEST(*begin(extended
) == 1);
35 BOOST_TEST(*prior(end(extended
)) == 1);
36 BOOST_TEST(distance(begin(extended
), end(extended
)) == 1);
39 namespace mpl
= boost::mpl
;
40 typedef deque
<> initial_deque_type
;
41 typedef front_extended_deque
<initial_deque_type
, int> extended_type
;
43 BOOST_MPL_ASSERT((boost::is_same
<mpl::at_c
<extended_type
, 0>::type
, int>));
44 BOOST_MPL_ASSERT((boost::is_same
<mpl::deref
<mpl::begin
<extended_type
>::type
>::type
, int>));
45 BOOST_MPL_ASSERT((mpl::equal_to
<mpl::size
<extended_type
>::type
, mpl::int_
<1> >));
49 typedef deque
<> initial_deque_type
;
50 initial_deque_type initial_deque
;
51 typedef front_extended_deque
<initial_deque_type
, int&> extended_type
;
52 extended_type
extended(initial_deque
, i
);
53 BOOST_TEST(extended
== make_vector(1));
56 extended_type
extended2(initial_deque_type(), i2
);
60 BOOST_TEST(extended
== make_vector(2));
66 typedef deque
<char, long> initial_deque_type
;
67 initial_deque_type
initial_deque('a', 101L);
68 typedef front_extended_deque
<initial_deque_type
, int> extended_type
;
69 extended_type
extended(initial_deque
, 1);
71 BOOST_TEST(size(extended
) == 3);
72 BOOST_TEST(extended
== make_vector(1, 'a', 101L));
73 BOOST_TEST(*begin(extended
) == 1);
74 BOOST_TEST(*next(begin(extended
)) == 'a');
75 BOOST_TEST(*prior(end(extended
)) == 101L);
76 BOOST_TEST(distance(begin(extended
), end(extended
)) == 3);
77 BOOST_TEST(*advance_c
<2>(begin(extended
)) == 101L);
80 namespace mpl
= boost::mpl
;
81 typedef deque
<char, long> initial_deque_type
;
82 typedef front_extended_deque
<initial_deque_type
, int> extended_type
;
84 BOOST_MPL_ASSERT((boost::is_same
<mpl::at_c
<extended_type
, 0>::type
, int>));
85 BOOST_MPL_ASSERT((boost::is_same
<mpl::at_c
<extended_type
, 1>::type
, char>));
86 BOOST_MPL_ASSERT((boost::is_same
<mpl::at_c
<extended_type
, 2>::type
, long>));
87 BOOST_MPL_ASSERT((boost::is_same
<mpl::deref
<mpl::begin
<extended_type
>::type
>::type
, int>));
88 BOOST_MPL_ASSERT((mpl::equal_to
<mpl::size
<extended_type
>::type
, mpl::int_
<3> >));
94 typedef deque
<char&, long&> initial_deque_type
;
95 initial_deque_type
initial_deque(ch
, l
);
96 typedef front_extended_deque
<initial_deque_type
, int&> extended_type
;
97 extended_type
extended(initial_deque
, i
);
98 BOOST_TEST(extended
== make_vector(1, 'a', 101L));
103 extended_type
extended2(initial_deque_type(ch2
, l2
), i2
);
105 extended
= extended2
;
107 BOOST_TEST(extended
== make_vector(2, 'b', 202L));
110 BOOST_TEST(ch
== ch2
);
113 return boost::report_errors();