]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/smart_ptr/test/make_unique_array_throws_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_unique_array_throws_test.cpp
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2014 Glen Joseph Fernandes
3(glenjofe@gmail.com)
7c673cae 4
b32b8144
FG
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7c673cae
FG
7*/
8#include <boost/config.hpp>
9#if !defined(BOOST_NO_CXX11_SMART_PTR)
10#include <boost/detail/lightweight_test.hpp>
11#include <boost/smart_ptr/make_unique.hpp>
12
13class type {
14public:
b32b8144 15 static unsigned instances;
7c673cae 16
b32b8144 17 type() {
7c673cae
FG
18 if (instances == 5) {
19 throw true;
20 }
b32b8144 21 ++instances;
7c673cae
FG
22 }
23
24 ~type() {
b32b8144 25 --instances;
7c673cae
FG
26 }
27
28private:
29 type(const type&);
30 type& operator=(const type&);
31};
32
b32b8144 33unsigned type::instances = 0;
7c673cae
FG
34
35int main()
36{
37 BOOST_TEST(type::instances == 0);
38 try {
39 boost::make_unique<type[]>(6);
40 BOOST_ERROR("make_unique did not throw");
41 } catch (...) {
42 BOOST_TEST(type::instances == 0);
43 }
7c673cae
FG
44 BOOST_TEST(type::instances == 0);
45 try {
46 boost::make_unique<type[][2]>(3);
47 BOOST_ERROR("make_unique did not throw");
48 } catch (...) {
49 BOOST_TEST(type::instances == 0);
50 }
7c673cae
FG
51 BOOST_TEST(type::instances == 0);
52 try {
53 boost::make_unique_noinit<type[]>(6);
54 BOOST_ERROR("make_unique_noinit did not throw");
55 } catch (...) {
56 BOOST_TEST(type::instances == 0);
57 }
7c673cae
FG
58 BOOST_TEST(type::instances == 0);
59 try {
60 boost::make_unique_noinit<type[][2]>(3);
61 BOOST_ERROR("make_unique_noinit did not throw");
62 } catch (...) {
63 BOOST_TEST(type::instances == 0);
64 }
7c673cae
FG
65 return boost::report_errors();
66}
67#else
7c673cae
FG
68int main()
69{
70 return 0;
71}
7c673cae 72#endif