~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to libs/fusion/test/sequence/back_extended_deque.cpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
ImportĀ upstreamĀ versionĀ 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=============================================================================
 
2
    Copyright (c) 1999-2003 Jaakko Jarvi
 
3
    Copyright (c) 2001-2011 Joel de Guzman
 
4
    Copyright (c) 2006 Dan Marsden
 
5
 
 
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>
 
10
 
 
11
#include <boost/fusion/container/deque/deque.hpp>
 
12
#include <boost/fusion/container/deque/back_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>
 
16
 
 
17
#include <boost/fusion/sequence/intrinsic.hpp>
 
18
#include <boost/fusion/iterator.hpp>
 
19
 
 
20
#include <boost/mpl/assert.hpp>
 
21
#include <boost/type_traits/is_same.hpp>
 
22
 
 
23
int main()
 
24
{
 
25
    using namespace boost::fusion;
 
26
    {
 
27
        typedef deque<int, char> initial_deque_type;
 
28
        initial_deque_type initial_deque(1, 'a');
 
29
        typedef back_extended_deque<initial_deque_type, long> extended_type;
 
30
        extended_type extended(initial_deque, 101L);
 
31
 
 
32
        BOOST_TEST(size(extended) == 3);
 
33
        BOOST_TEST(extended == make_vector(1, 'a', 101L));
 
34
        BOOST_TEST(*begin(extended) == 1);
 
35
        BOOST_TEST(*next(begin(extended)) == 'a');
 
36
        BOOST_TEST(*prior(end(extended)) == 101L);
 
37
        BOOST_TEST(distance(begin(extended), end(extended)) == 3);
 
38
        BOOST_TEST(*advance_c<2>(begin(extended)) == 101L);
 
39
    }
 
40
    {
 
41
        namespace mpl = boost::mpl;
 
42
        typedef deque<int, char> initial_deque_type;
 
43
        typedef back_extended_deque<initial_deque_type, long> extended_type;
 
44
 
 
45
        BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 0>::type, int>));
 
46
        BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 1>::type, char>));
 
47
        BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 2>::type, long>));
 
48
        BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, int>));
 
49
        BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<3> >));
 
50
    }
 
51
    {
 
52
        char ch('a');
 
53
        long l(101L);
 
54
        int i(1);
 
55
        typedef deque<int&, char&> initial_deque_type;
 
56
        initial_deque_type initial_deque(i, ch);
 
57
        typedef back_extended_deque<initial_deque_type, long&> extended_type;
 
58
        extended_type extended(initial_deque, l);
 
59
        BOOST_TEST(extended == make_vector(1, 'a', 101L));
 
60
 
 
61
        char ch2('b');
 
62
        long l2(202L);
 
63
        int i2(2);
 
64
        extended_type extended2(initial_deque_type(i2, ch2), l2);
 
65
 
 
66
        extended = extended2;
 
67
 
 
68
        BOOST_TEST(extended == make_vector(2, 'b', 202L));
 
69
 
 
70
        BOOST_TEST(i == i2);
 
71
        BOOST_TEST(ch == ch2);
 
72
        BOOST_TEST(l == l2);
 
73
    }
 
74
    return boost::report_errors();
 
75
}