]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/test/unordered/fwd_map_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / unordered / test / unordered / fwd_map_test.cpp
1
2 // Copyright 2008-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)
5
6 #include "../helpers/prefix.hpp"
7 #include <boost/unordered/unordered_map_fwd.hpp>
8 #include "../helpers/postfix.hpp"
9
10 template <typename T>
11 void call_swap(boost::unordered_map<T,T>& x,
12 boost::unordered_map<T,T>& y)
13 {
14 swap(x,y);
15 }
16
17 template <typename T>
18 bool call_equals(boost::unordered_map<T,T>& x,
19 boost::unordered_map<T,T>& y)
20 {
21 return x == y;
22 }
23
24 template <typename T>
25 bool call_not_equals(boost::unordered_map<T,T>& x,
26 boost::unordered_map<T,T>& y)
27 {
28 return x != y;
29 }
30
31 template <typename T>
32 void call_swap(boost::unordered_multimap<T,T>& x,
33 boost::unordered_multimap<T,T>& y)
34 {
35 swap(x,y);
36 }
37
38 template <typename T>
39 bool call_equals(boost::unordered_multimap<T,T>& x,
40 boost::unordered_multimap<T,T>& y)
41 {
42 return x == y;
43 }
44
45 template <typename T>
46 bool call_not_equals(boost::unordered_multimap<T,T>& x,
47 boost::unordered_multimap<T,T>& y)
48 {
49 return x != y;
50 }
51
52 #include <boost/unordered_map.hpp>
53 #include "../helpers/test.hpp"
54
55 typedef boost::unordered_map<int, int> int_map;
56 typedef boost::unordered_multimap<int, int> int_multimap;
57
58 UNORDERED_AUTO_TEST(use_map_fwd_declared_function) {
59 int_map x, y;
60 x[1] = 2;
61 y[2] = 1;
62 call_swap(x, y);
63
64 BOOST_TEST(y.find(1) != y.end() && y.find(1)->second == 2);
65 BOOST_TEST(y.find(2) == y.end());
66
67 BOOST_TEST(x.find(1) == x.end());
68 BOOST_TEST(x.find(2) != x.end() && x.find(2)->second == 1);
69
70 BOOST_TEST(!call_equals(x, y));
71 BOOST_TEST(call_not_equals(x, y));
72 }
73
74 UNORDERED_AUTO_TEST(use_multimap_fwd_declared_function) {
75 int_multimap x, y;
76 call_swap(x, y);
77 BOOST_TEST(call_equals(x, y));
78 BOOST_TEST(!call_not_equals(x, y));
79 }
80
81 RUN_TESTS()