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

« back to all changes in this revision

Viewing changes to src/mlib/tests/range/adaptor_test/map_values_example.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
// Boost.Range library
 
2
//
 
3
//  Copyright Neil Groves 2009. Use, modification and
 
4
//  distribution is subject to the Boost Software License, Version
 
5
//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
 
6
//  http://www.boost.org/LICENSE_1_0.txt)
 
7
//
 
8
//
 
9
// For more information, see http://www.boost.org/libs/range/
 
10
//
 
11
#include <mlib/tests/_pc_.h>
 
12
 
 
13
#include <mlib/range/adaptor/map.hpp>
 
14
#include <mlib/range/algorithm/copy.hpp>
 
15
#include <mlib/range/algorithm_ext/push_back.hpp>
 
16
 
 
17
#include <boost/assign.hpp>
 
18
#include <algorithm>
 
19
#include <iostream>
 
20
#include <map>
 
21
#include <vector>
 
22
 
 
23
namespace 
 
24
{
 
25
    void map_values_example_test()
 
26
    {
 
27
        using namespace boost::assign;
 
28
        using namespace boost::adaptors;
 
29
 
 
30
        std::map<int,int> input;
 
31
        for (int i = 0; i < 10; ++i)
 
32
            input.insert(std::make_pair(i, i * 10));
 
33
 
 
34
        //boost::copy(
 
35
        //    input | map_values,
 
36
        //    std::ostream_iterator<int>(std::cout, ","));
 
37
 
 
38
        
 
39
        std::vector<int> reference;
 
40
        reference += 0,10,20,30,40,50,60,70,80,90;
 
41
 
 
42
        std::vector<int> test;
 
43
        boost::push_back(test, input | map_values);
 
44
 
 
45
        BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
 
46
            test.begin(), test.end() );
 
47
    }
 
48
}
 
49
 
 
50
BOOST_AUTO_TEST_CASE( test_range_map_values_example_test )
 
51
{
 
52
    map_values_example_test();
 
53
}
 
54