]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/test/unordered/equivalent_keys_tests.cpp
f040819dbeab6d9a183c0d6eb45c635dd0f1c4da
2 // Copyright 2006-2009 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #include "../helpers/prefix.hpp"
8 #include <boost/unordered_set.hpp>
9 #include <boost/unordered_map.hpp>
10 #include "../helpers/postfix.hpp"
13 #include "../helpers/test.hpp"
16 #include "../helpers/list.hpp"
17 #include "../helpers/tracker.hpp"
18 #include "../helpers/invariants.hpp"
20 template <class Container
, class Iterator
>
21 void test_equal_insertion(Iterator begin
, Iterator end
)
23 typedef test::ordered
<Container
> tracker
;
26 tracker x2
= test::create_ordered(x1
);
28 for (Iterator it
= begin
; it
!= end
; ++it
) {
31 x2
.compare_key(x1
, *it
);
35 test::check_equivalent_keys(x1
);
38 UNORDERED_AUTO_TEST (set_tests
) {
39 int values
[][5] = {{1}, {54, 23}, {-13, 65}, {77, 77}, {986, 25, 986}};
41 typedef boost::unordered_set
<int> set
;
42 typedef boost::unordered_multiset
<int> multiset
;
44 test_equal_insertion
<set
>(values
[0], values
[0] + 1);
45 test_equal_insertion
<set
>(values
[1], values
[1] + 2);
46 test_equal_insertion
<set
>(values
[2], values
[2] + 2);
47 test_equal_insertion
<set
>(values
[3], values
[3] + 2);
48 test_equal_insertion
<set
>(values
[4], values
[4] + 3);
50 test_equal_insertion
<multiset
>(values
[0], values
[0] + 1);
51 test_equal_insertion
<multiset
>(values
[1], values
[1] + 2);
52 test_equal_insertion
<multiset
>(values
[2], values
[2] + 2);
53 test_equal_insertion
<multiset
>(values
[3], values
[3] + 2);
54 test_equal_insertion
<multiset
>(values
[4], values
[4] + 3);
57 UNORDERED_AUTO_TEST (map_tests
) {
58 typedef test::list
<std::pair
<int const, int> > values_type
;
60 v
[0].push_back(std::pair
<int const, int>(1, 1));
61 v
[1].push_back(std::pair
<int const, int>(28, 34));
62 v
[1].push_back(std::pair
<int const, int>(16, 58));
63 v
[1].push_back(std::pair
<int const, int>(-124, 62));
64 v
[2].push_back(std::pair
<int const, int>(432, 12));
65 v
[2].push_back(std::pair
<int const, int>(9, 13));
66 v
[2].push_back(std::pair
<int const, int>(432, 24));
68 for (int i
= 0; i
< 5; ++i
)
69 test_equal_insertion
<boost::unordered_map
<int, int> >(
70 v
[i
].begin(), v
[i
].end());
72 for (int i2
= 0; i2
< 5; ++i2
)
73 test_equal_insertion
<boost::unordered_multimap
<int, int> >(
74 v
[i2
].begin(), v
[i2
].end());