PageRenderTime 48ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/phoenix/test/container/container_tests3b.cpp

http://hadesmem.googlecode.com/
C++ | 61 lines | 48 code | 7 blank | 6 comment | 4 complexity | b53e292669009ab915b313370959a96e MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2004 Angus Leeming
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#include "container_tests.hpp"
 8#include <boost/static_assert.hpp>
 9
10std::map<int, int> const build_map()
11{
12    typedef std::map<int, int> int_map;
13    typedef std::vector<int> int_vector;
14
15    int_map result;
16    int_vector const data = build_vector();
17    int_vector::const_iterator it = data.begin();
18    int_vector::const_iterator const end = data.end();
19    for (; it != end; ++it) {
20      int const value = *it;
21      result[value] = 100 * value;
22    }
23    return result;
24}
25
26std::vector<int> const init_vector()
27{
28    typedef std::vector<int> int_vector;
29    int const data[] = { -4, -3, -2, -1, 0 };
30    int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
31    return int_vector(data, data + data_size);
32}
33
34std::vector<int> const build_vector()
35{
36    typedef std::vector<int> int_vector;
37    static int_vector data = init_vector();
38    int_vector::size_type const size = data.size();
39    int_vector::iterator it = data.begin();
40    int_vector::iterator const end = data.end();
41    for (; it != end; ++it)
42        *it += size;
43    return data;
44}
45
46int
47main()
48{
49    BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value));
50
51    std::map<int, int> const data = build_map();
52    test_map_insert(data);
53    test_key_comp(data);
54    test_max_size(data);
55    test_rbegin(data);
56    test_rend(data);
57    test_size(data);
58    test_value_comp(data);
59    return boost::report_errors();
60}
61