]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/test/exception/merge_exception_tests.cpp
1 #include "../helpers/exception_test.hpp"
2 #include "../helpers/invariants.hpp"
3 #include "../helpers/metafunctions.hpp"
4 #include "../helpers/random_values.hpp"
5 #include "./containers.hpp"
7 template <typename T1
, typename T2
> void merge_exception_test(T1 x
, T2 y
)
9 std::size_t size
= x
.size() + y
.size();
15 test::check_equivalent_keys(x
);
16 test::check_equivalent_keys(y
);
20 // Not a full check, just want to make sure the merge completed.
21 BOOST_TEST(size
== x
.size() + y
.size());
23 BOOST_TEST(test::has_unique_keys
<T1
>::value
);
24 for (typename
T2::iterator it
= y
.begin(); it
!= y
.end(); ++it
) {
25 BOOST_TEST(x
.find(test::get_key
<T2
>(*it
)) != x
.end());
28 test::check_equivalent_keys(x
);
29 test::check_equivalent_keys(y
);
32 template <typename T1
, typename T2
>
33 void merge_exception_test(T1
const*, T2
const*, std::size_t count12
, int tag12
,
34 test::random_generator gen1
, test::random_generator gen2
)
36 std::size_t count1
= count12
/ 256;
37 std::size_t count2
= count12
% 256;
38 int tag1
= tag12
/ 256;
39 int tag2
= tag12
% 256;
40 test::random_values
<T1
> v1(count1
, gen1
);
41 test::random_values
<T2
> v2(count2
, gen2
);
42 T1
x(v1
.begin(), v1
.end(), 0, test::exception::hash(tag1
),
43 test::exception::equal_to(tag1
));
44 T2
y(v2
.begin(), v2
.end(), 0, test::exception::hash(tag2
),
45 test::exception::equal_to(tag2
));
47 EXCEPTION_LOOP(merge_exception_test(x
, y
))
50 boost::unordered_set
<test::exception::object
, test::exception::hash
,
51 test::exception::equal_to
,
52 test::exception::allocator
<test::exception::object
> >* test_set_
;
53 boost::unordered_multiset
<test::exception::object
, test::exception::hash
,
54 test::exception::equal_to
,
55 test::exception::allocator
<test::exception::object
> >* test_multiset_
;
56 boost::unordered_map
<test::exception::object
, test::exception::object
,
57 test::exception::hash
, test::exception::equal_to
,
58 test::exception::allocator2
<test::exception::object
> >* test_map_
;
59 boost::unordered_multimap
<test::exception::object
, test::exception::object
,
60 test::exception::hash
, test::exception::equal_to
,
61 test::exception::allocator2
<test::exception::object
> >* test_multimap_
;
63 using test::default_generator
;
64 using test::generate_collisions
;
65 using test::limited_range
;
68 UNORDERED_MULTI_TEST(set_merge
, merge_exception_test
,
69 ((test_set_
)(test_multiset_
))
70 ((test_set_
)(test_multiset_
))
71 ((0x0000)(0x6400)(0x0064)(0x0a64)(0x3232))
72 ((0x0000)(0x0001)(0x0102))
73 ((default_generator
)(limited_range
))
74 ((default_generator
)(limited_range
))
76 UNORDERED_MULTI_TEST(map_merge
, merge_exception_test
,
77 ((test_map_
)(test_multimap_
))
78 ((test_map_
)(test_multimap_
))
79 ((0x0000)(0x6400)(0x0064)(0x0a64)(0x3232))
80 ((0x0101)(0x0200)(0x0201))
81 ((default_generator
)(limited_range
))
82 ((default_generator
)(limited_range
))
84 // Run fewer generate_collisions tests, as they're slow.
85 UNORDERED_MULTI_TEST(set_merge_collisions
, merge_exception_test
,
86 ((test_set_
)(test_multiset_
))
87 ((test_set_
)(test_multiset_
))
89 ((0x0202)(0x0100)(0x0201))
90 ((generate_collisions
))
91 ((generate_collisions
))
93 UNORDERED_MULTI_TEST(map_merge_collisions
, merge_exception_test
,
94 ((test_map_
)(test_multimap_
))
95 ((test_map_
)(test_multimap_
))
97 ((0x0000)(0x0002)(0x0102))
98 ((generate_collisions
))
99 ((generate_collisions
))