]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/owner_less_test.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / owner_less_test.cpp
1 //
2 // owner_less_test.cpp
3 //
4 // A regression test for owner_less
5 //
6 // Copyright (c) 2008 Frank Mori Hess
7 //
8 // Distributed under the Boost Software License, Version 1.0.
9 //
10 // See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12 //
13
14 #include <boost/core/lightweight_test.hpp>
15 #include <boost/smart_ptr/owner_less.hpp>
16 #include <boost/shared_ptr.hpp>
17 #include <boost/weak_ptr.hpp>
18
19 int main()
20 {
21 boost::owner_less<boost::shared_ptr<int> > comp;
22 {
23 boost::shared_ptr<int> x;
24 boost::shared_ptr<int> y;
25 boost::weak_ptr<int> w;
26 BOOST_TEST(!(comp(x, w) || comp(w, x)));
27 }
28 {
29 boost::shared_ptr<int> z((int*)0);
30 boost::weak_ptr<int> w;
31 BOOST_TEST(comp(z, w) || comp(w, z));
32 {
33 boost::shared_ptr<int> zz(z);
34 w = boost::weak_ptr<int>(zz);
35 BOOST_TEST(!(comp(z, zz) || comp(z, zz)));
36 BOOST_TEST(!(comp(z, w) || comp(z, w)));
37 }
38 BOOST_TEST(!(comp(z, w) || comp(w, z)));
39 }
40 {
41 boost::shared_ptr<int> x;
42 boost::shared_ptr<int> z((int*)0);
43 BOOST_TEST(comp(x, z) || comp(z, x));
44 }
45 {
46 boost::shared_ptr<int> a((int*)0);
47 boost::shared_ptr<int> b((int*)0);
48 BOOST_TEST(comp(a, b) || comp(b, a));
49 boost::weak_ptr<int> w(a);
50 BOOST_TEST(!(comp(a, w) || comp(w, a)));
51 BOOST_TEST(comp(b, w) || comp(w, b));
52 }
53
54 boost::owner_less<boost::weak_ptr<int> > weak_comp;
55 {
56 boost::shared_ptr<int> a((int*)0);
57 boost::weak_ptr<int> wa(a);
58 boost::shared_ptr<int> b((int*)0);
59 boost::weak_ptr<int> wb(b);
60 BOOST_TEST(!(weak_comp(a, wa) || weak_comp(wa, a)));
61 BOOST_TEST(!(weak_comp(b, wb) || weak_comp(wb, b)));
62 BOOST_TEST(weak_comp(wa, wb) || weak_comp(wb, wa));
63 BOOST_TEST(weak_comp(wa, b) || weak_comp(b, wa));
64 }
65
66 return boost::report_errors();
67 }