]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/smart_ptr/test/make_shared_array_throws_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_shared_array_throws_test.cpp
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2012-2015 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/detail/lightweight_test.hpp>
9#include <boost/smart_ptr/make_shared.hpp>
10
11class type {
12public:
b32b8144
FG
13 static unsigned instances;
14
15 type() {
7c673cae
FG
16 if (instances == 5) {
17 throw true;
18 }
b32b8144 19 ++instances;
7c673cae 20 }
b32b8144 21
7c673cae 22 ~type() {
b32b8144 23 --instances;
7c673cae 24 }
b32b8144 25
7c673cae
FG
26private:
27 type(const type&);
28 type& operator=(const type&);
29};
30
b32b8144 31unsigned type::instances = 0;
7c673cae
FG
32
33int main()
34{
35 try {
36 boost::make_shared<type[]>(6);
37 BOOST_ERROR("make_shared did not throw");
38 } catch (...) {
39 BOOST_TEST(type::instances == 0);
40 }
41 try {
42 boost::make_shared<type[][2]>(3);
43 BOOST_ERROR("make_shared did not throw");
44 } catch (...) {
45 BOOST_TEST(type::instances == 0);
46 }
47 try {
48 boost::make_shared<type[6]>();
49 BOOST_ERROR("make_shared did not throw");
50 } catch (...) {
51 BOOST_TEST(type::instances == 0);
52 }
53 try {
54 boost::make_shared<type[3][2]>();
55 BOOST_ERROR("make_shared did not throw");
56 } catch (...) {
57 BOOST_TEST(type::instances == 0);
58 }
59 try {
60 boost::make_shared_noinit<type[]>(6);
61 BOOST_ERROR("make_shared_noinit did not throw");
62 } catch (...) {
63 BOOST_TEST(type::instances == 0);
64 }
65 try {
66 boost::make_shared_noinit<type[][2]>(3);
67 BOOST_ERROR("make_shared_noinit did not throw");
68 } catch (...) {
69 BOOST_TEST(type::instances == 0);
70 }
71 try {
72 boost::make_shared_noinit<type[6]>();
73 BOOST_ERROR("make_shared_noinit did not throw");
74 } catch (...) {
75 BOOST_TEST(type::instances == 0);
76 }
77 try {
78 boost::make_shared_noinit<type[3][2]>();
79 BOOST_ERROR("make_shared_noinit did not throw");
80 } catch (...) {
81 BOOST_TEST(type::instances == 0);
82 }
83 return boost::report_errors();
84}