]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/unordered/test/unordered/fwd_set_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / unordered / test / unordered / fwd_set_test.cpp
CommitLineData
7c673cae
FG
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_set_fwd.hpp>
8#include "../helpers/postfix.hpp"
9
10struct true_type { char x[100]; };
11struct false_type { char x; };
12
13false_type is_unordered_set_impl(void*);
14
15template <class Value, class Hash, class Pred, class Alloc>
16true_type is_unordered_set_impl(
17 boost::unordered_set<Value, Hash, Pred, Alloc>*);
18
19template<typename T>
20void call_swap(boost::unordered_set<T>& x,
21 boost::unordered_set<T>& y)
22{
23 swap(x,y);
24}
25
26template<typename T>
27bool call_equals(boost::unordered_set<T>& x,
28 boost::unordered_set<T>& y)
29{
30 return x == y;
31}
32
33template<typename T>
34bool call_not_equals(boost::unordered_set<T>& x,
35 boost::unordered_set<T>& y)
36{
37 return x != y;
38}
39
40template<typename T>
41void call_swap(boost::unordered_multiset<T>& x,
42 boost::unordered_multiset<T>& y)
43{
44 swap(x,y);
45}
46
47template<typename T>
48bool call_equals(boost::unordered_multiset<T>& x,
49 boost::unordered_multiset<T>& y)
50{
51 return x == y;
52}
53
54template<typename T>
55bool call_not_equals(boost::unordered_multiset<T>& x,
56 boost::unordered_multiset<T>& y)
57{
58 return x != y;
59}
60
61#include "../helpers/test.hpp"
62
63typedef boost::unordered_set<int> int_set;
64typedef boost::unordered_multiset<int> int_multiset;
65
66UNORDERED_AUTO_TEST(use_fwd_declared_trait_without_definition) {
67 BOOST_TEST(sizeof(is_unordered_set_impl((int_set*) 0))
68 == sizeof(true_type));
69}
70
71#include <boost/unordered_set.hpp>
72
73UNORDERED_AUTO_TEST(use_fwd_declared_trait) {
74 boost::unordered_set<int> x;
75 BOOST_TEST(sizeof(is_unordered_set_impl(&x)) == sizeof(true_type));
76
77 BOOST_TEST(sizeof(is_unordered_set_impl((int*) 0)) == sizeof(false_type));
78}
79
80UNORDERED_AUTO_TEST(use_set_fwd_declared_function) {
81 int_set x, y;
82 x.insert(1);
83 y.insert(2);
84 call_swap(x, y);
85
86 BOOST_TEST(y.find(1) != y.end());
87 BOOST_TEST(y.find(2) == y.end());
88
89 BOOST_TEST(x.find(1) == x.end());
90 BOOST_TEST(x.find(2) != x.end());
91
92 BOOST_TEST(!call_equals(x, y));
93 BOOST_TEST(call_not_equals(x, y));
94}
95
96UNORDERED_AUTO_TEST(use_multiset_fwd_declared_function) {
97 int_multiset x, y;
98 call_swap(x, y);
99 BOOST_TEST(call_equals(x, y));
100 BOOST_TEST(!call_not_equals(x, y));
101}
102
103RUN_TESTS()