]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | /*============================================================================= |
2 | Copyright (c) 2004 Angus Leeming | |
3 | Copyright (c) 2017 Kohei Takahashi | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ==============================================================================*/ | |
8 | #include "container_tests.hpp" | |
9 | #include <boost/static_assert.hpp> | |
10 | ||
11 | std::unordered_map<int, int> const build_unordered_map() | |
12 | { | |
13 | typedef std::unordered_map<int, int> int_map; | |
14 | typedef std::vector<int> int_vector; | |
15 | ||
16 | int_map result; | |
17 | int_vector const data = build_vector(); | |
18 | int_vector::const_iterator it = data.begin(); | |
19 | int_vector::const_iterator const end = data.end(); | |
20 | for (; it != end; ++it) { | |
21 | int const value = *it; | |
22 | result[value] = 100 * value; | |
23 | } | |
24 | return result; | |
25 | } | |
26 | ||
27 | std::vector<int> const init_vector() | |
28 | { | |
29 | typedef std::vector<int> int_vector; | |
30 | int const data[] = { -4, -3, -2, -1, 0 }; | |
31 | int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); | |
32 | return int_vector(data, data + data_size); | |
33 | } | |
34 | ||
35 | std::vector<int> const build_vector() | |
36 | { | |
37 | typedef std::vector<int> int_vector; | |
38 | static int_vector data = init_vector(); | |
39 | int_vector::size_type const size = data.size(); | |
40 | int_vector::iterator it = data.begin(); | |
41 | int_vector::iterator const end = data.end(); | |
42 | for (; it != end; ++it) | |
43 | *it += size; | |
44 | return data; | |
45 | } | |
46 | ||
47 | int | |
48 | main() | |
49 | { | |
50 | BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::unordered_map<int, int> >::value)); | |
51 | BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_map<int, int> >::value)); | |
52 | ||
53 | std::unordered_map<int, int> const data = build_unordered_map(); | |
54 | test_begin(data); | |
55 | test_clear(data); | |
56 | test_empty(data); | |
57 | test_end(data); | |
58 | test_map_erase(data); | |
59 | test_get_allocator(data); | |
60 | return boost::report_errors(); | |
61 | } | |
62 |