]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/make_unique_array_test.cpp
2 (c) 2014 Glen Joseph Fernandes
3 <glenjofe -at- gmail.com>
5 Distributed under the Boost Software
7 http://boost.org/LICENSE_1_0.txt
9 #include <boost/config.hpp>
10 #if !defined(BOOST_NO_CXX11_SMART_PTR)
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/smart_ptr/make_unique.hpp>
16 static unsigned int instances
;
28 type
& operator=(const type
&);
31 unsigned int type::instances
= 0;
36 std::unique_ptr
<int[]> a1
= boost::make_unique
<int[]>(3);
37 BOOST_TEST(a1
.get() != 0);
38 BOOST_TEST(a1
[0] == 0);
39 BOOST_TEST(a1
[1] == 0);
40 BOOST_TEST(a1
[2] == 0);
44 std::unique_ptr
<int[][2]> a1
= boost::make_unique
<int[][2]>(2);
45 BOOST_TEST(a1
.get() != 0);
46 BOOST_TEST(a1
[0][0] == 0);
47 BOOST_TEST(a1
[0][1] == 0);
48 BOOST_TEST(a1
[1][0] == 0);
49 BOOST_TEST(a1
[1][1] == 0);
53 std::unique_ptr
<const int[]> a1
= boost::make_unique
<const int[]>(3);
54 BOOST_TEST(a1
.get() != 0);
55 BOOST_TEST(a1
[0] == 0);
56 BOOST_TEST(a1
[1] == 0);
57 BOOST_TEST(a1
[2] == 0);
61 std::unique_ptr
<const int[][2]> a1
= boost::make_unique
<const int[][2]>(2);
62 BOOST_TEST(a1
.get() != 0);
63 BOOST_TEST(a1
[0][0] == 0);
64 BOOST_TEST(a1
[0][1] == 0);
65 BOOST_TEST(a1
[1][0] == 0);
66 BOOST_TEST(a1
[1][1] == 0);
69 BOOST_TEST(type::instances
== 0);
71 std::unique_ptr
<type
[]> a1
= boost::make_unique
<type
[]>(3);
72 BOOST_TEST(a1
.get() != 0);
73 BOOST_TEST(type::instances
== 3);
75 BOOST_TEST(type::instances
== 0);
78 BOOST_TEST(type::instances
== 0);
80 std::unique_ptr
<type
[][2]> a1
= boost::make_unique
<type
[][2]>(2);
81 BOOST_TEST(a1
.get() != 0);
82 BOOST_TEST(type::instances
== 4);
84 BOOST_TEST(type::instances
== 0);
87 BOOST_TEST(type::instances
== 0);
89 std::unique_ptr
<const type
[]> a1
= boost::make_unique
<const type
[]>(3);
90 BOOST_TEST(a1
.get() != 0);
91 BOOST_TEST(type::instances
== 3);
93 BOOST_TEST(type::instances
== 0);
96 BOOST_TEST(type::instances
== 0);
98 std::unique_ptr
<const type
[][2]> a1
= boost::make_unique
<const type
[][2]>(2);
99 BOOST_TEST(a1
.get() != 0);
100 BOOST_TEST(type::instances
== 4);
102 BOOST_TEST(type::instances
== 0);
105 return boost::report_errors();