• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #include <boost/smart_ptr/local_shared_ptr.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 
main()8 int main()
9 {
10     {
11         boost::local_shared_ptr<int> p1( new int );
12         boost::local_shared_ptr<int> p2( p1 );
13 
14         BOOST_TEST( !p1.owner_before( p2 ) );
15         BOOST_TEST( !p2.owner_before( p1 ) );
16 
17         boost::local_shared_ptr<int> p3( new int );
18 
19         BOOST_TEST( p1.owner_before( p3 ) || p3.owner_before( p1 ) );
20 
21         boost::local_shared_ptr<int> p4;
22         boost::local_shared_ptr<int> p5;
23 
24         BOOST_TEST( !p4.owner_before( p5 ) );
25         BOOST_TEST( !p5.owner_before( p4 ) );
26 
27         BOOST_TEST( p4.owner_before( p3 ) || p3.owner_before( p4 ) );
28 
29         boost::local_shared_ptr<int> p6( static_cast<int*>(0) );
30 
31         BOOST_TEST( p4.owner_before( p6 ) || p6.owner_before( p4 ) );
32 
33         boost::local_shared_ptr<void> p7( p1 );
34 
35         BOOST_TEST( !p1.owner_before( p7 ) );
36         BOOST_TEST( !p7.owner_before( p1 ) );
37 
38         boost::local_shared_ptr<void> p8;
39 
40         BOOST_TEST( p1.owner_before( p8 ) || p8.owner_before( p1 ) );
41 
42         BOOST_TEST( !p4.owner_before( p8 ) );
43         BOOST_TEST( !p8.owner_before( p4 ) );
44 /*
45         boost::local_weak_ptr<int> q1( p1 );
46 
47         BOOST_TEST( !p1.owner_before( q1 ) );
48         BOOST_TEST( !q1.owner_before( p1 ) );
49 
50         boost::local_weak_ptr<int> q2( p1 );
51 
52         BOOST_TEST( !q1.owner_before( q2 ) );
53         BOOST_TEST( !q2.owner_before( q1 ) );
54 
55         boost::local_weak_ptr<int> q3( p3 );
56 
57         BOOST_TEST( p1.owner_before( q3 ) || q3.owner_before( p1 ) );
58         BOOST_TEST( q1.owner_before( q3 ) || q3.owner_before( q1 ) );
59 
60         boost::local_weak_ptr<int> q4;
61 
62         BOOST_TEST( !p4.owner_before( q4 ) );
63         BOOST_TEST( !q4.owner_before( p4 ) );
64 
65         BOOST_TEST( q1.owner_before( q4 ) || q4.owner_before( q1 ) );
66 
67         boost::local_weak_ptr<void> q5;
68 
69         BOOST_TEST( !q4.owner_before( q5 ) );
70         BOOST_TEST( !q5.owner_before( q4 ) );
71 
72         boost::local_weak_ptr<void> q7( p7 );
73 
74         BOOST_TEST( !p1.owner_before( q7 ) );
75         BOOST_TEST( !q7.owner_before( p1 ) );
76 
77         BOOST_TEST( !q1.owner_before( q7 ) );
78         BOOST_TEST( !q7.owner_before( q1 ) );
79 
80         p1.reset();
81         p2.reset();
82         p3.reset();
83         p7.reset();
84 
85         BOOST_TEST( q1.expired() );
86         BOOST_TEST( q2.expired() );
87         BOOST_TEST( q3.expired() );
88         BOOST_TEST( q7.expired() );
89 
90         BOOST_TEST( !q1.owner_before( q2 ) );
91         BOOST_TEST( !q2.owner_before( q1 ) );
92 
93         BOOST_TEST( !q1.owner_before( q7 ) );
94         BOOST_TEST( !q7.owner_before( q1 ) );
95 
96         BOOST_TEST( q1.owner_before( q3 ) || q3.owner_before( q1 ) );
97 
98         BOOST_TEST( q1.owner_before( q4 ) || q4.owner_before( q1 ) );
99 */
100     }
101 
102     return boost::report_errors();
103 }
104