]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/owner_less_test.cpp
4 // A regression test for owner_less
6 // Copyright (c) 2008 Frank Mori Hess
8 // Distributed under the Boost Software License, Version 1.0.
10 // See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
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>
21 boost::owner_less
<boost::shared_ptr
<int> > comp
;
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
)));
29 boost::shared_ptr
<int> z((int*)0);
30 boost::weak_ptr
<int> w
;
31 BOOST_TEST(comp(z
, w
) || comp(w
, z
));
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
)));
38 BOOST_TEST(!(comp(z
, w
) || comp(w
, z
)));
41 boost::shared_ptr
<int> x
;
42 boost::shared_ptr
<int> z((int*)0);
43 BOOST_TEST(comp(x
, z
) || comp(z
, x
));
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
));
54 boost::owner_less
<boost::weak_ptr
<int> > weak_comp
;
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
));
66 return boost::report_errors();