~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to src/mlib/tests/foreach/stl_byval_r.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  stl_byval.cpp
 
2
///
 
3
//  (C) Copyright Eric Niebler 2004.
 
4
//  Use, modification and distribution are subject to the
 
5
//  Boost Software License, Version 1.0. (See accompanying file
 
6
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
7
 
 
8
/*
 
9
 Revision history:
 
10
   25 August 2005 : Initial version.
 
11
*/
 
12
 
 
13
#include <mlib/tests/_pc_.h>
 
14
//#include <boost/test/minimal.hpp>
 
15
#include <list>
 
16
#include <boost/foreach.hpp>
 
17
 
 
18
///////////////////////////////////////////////////////////////////////////////
 
19
// define the container types, used by utility.hpp to generate the helper functions
 
20
typedef std::list<int> foreach_container_type;
 
21
typedef std::list<int> const foreach_const_container_type;
 
22
typedef int foreach_value_type;
 
23
typedef int &foreach_reference_type;
 
24
typedef int const &foreach_const_reference_type;
 
25
 
 
26
#include "./utility.hpp"
 
27
 
 
28
///////////////////////////////////////////////////////////////////////////////
 
29
// initialize a std::list<int>
 
30
static std::list<int> make_list()
 
31
{
 
32
    std::list<int> l;
 
33
    l.push_back(1);
 
34
    l.push_back(2);
 
35
    l.push_back(3);
 
36
    l.push_back(4);
 
37
    l.push_back(5);
 
38
    return l;
 
39
}
 
40
 
 
41
///////////////////////////////////////////////////////////////////////////////
 
42
// define some containers
 
43
//
 
44
static std::list<int> my_list = make_list();
 
45
static std::list<int> const &my_const_list = my_list;
 
46
 
 
47
///////////////////////////////////////////////////////////////////////////////
 
48
// test_main
 
49
//   
 
50
BOOST_AUTO_TEST_CASE( stl_byval_r )
 
51
{
 
52
    check_lightweight<false>(my_list);
 
53
 
 
54
    // non-const containers by value
 
55
    BOOST_CHECK(sequence_equal_byval_n_r(my_list, "\5\4\3\2\1"));
 
56
 
 
57
    // const containers by value
 
58
    BOOST_CHECK(sequence_equal_byval_c_r(my_const_list, "\5\4\3\2\1"));
 
59
}