~ubuntu-branches/ubuntu/oneiric/bombono-dvd/oneiric

« back to all changes in this revision

Viewing changes to src/mlib/tests/range/adaptor_test/map_keys_example.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101104114625-2tfaxma74eqggp5r
Tags: 0.8.0-0ubuntu1
* New upstream release (LP: #670193).
* Refresh 02_sparc.diff patch.
* Replace 05-boost_filesystem-link.patch with 05-fix_boost.patch, it fixes
  build failure with Boost <= 1.44.
* Bump Standards.

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_keys_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_keys,
 
36
        //    std::ostream_iterator<int>(std::cout, ","));
 
37
 
 
38
        
 
39
        std::vector<int> reference;
 
40
        reference += 0,1,2,3,4,5,6,7,8,9;
 
41
 
 
42
        std::vector<int> test;
 
43
        boost::push_back(test, input | map_keys);
 
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_keys_example_test )
 
51
{
 
52
    map_keys_example_test();
 
53
}
 
54