]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | (c) 2012-2015 Glen Joseph Fernandes | |
3 | <glenjofe -at- gmail.com> | |
4 | ||
5 | Distributed under the Boost Software | |
6 | License, Version 1.0. | |
7 | http://boost.org/LICENSE_1_0.txt | |
8 | */ | |
9 | #include <boost/detail/lightweight_test.hpp> | |
10 | #include <boost/smart_ptr/make_shared.hpp> | |
11 | ||
12 | class type { | |
13 | public: | |
14 | static unsigned int instances; | |
15 | explicit type() { | |
16 | if (instances == 5) { | |
17 | throw true; | |
18 | } | |
19 | instances++; | |
20 | } | |
21 | ~type() { | |
22 | instances--; | |
23 | } | |
24 | private: | |
25 | type(const type&); | |
26 | type& operator=(const type&); | |
27 | }; | |
28 | ||
29 | unsigned int type::instances = 0; | |
30 | ||
31 | int main() | |
32 | { | |
33 | try { | |
34 | boost::make_shared<type[]>(6); | |
35 | BOOST_ERROR("make_shared did not throw"); | |
36 | } catch (...) { | |
37 | BOOST_TEST(type::instances == 0); | |
38 | } | |
39 | try { | |
40 | boost::make_shared<type[][2]>(3); | |
41 | BOOST_ERROR("make_shared did not throw"); | |
42 | } catch (...) { | |
43 | BOOST_TEST(type::instances == 0); | |
44 | } | |
45 | try { | |
46 | boost::make_shared<type[6]>(); | |
47 | BOOST_ERROR("make_shared did not throw"); | |
48 | } catch (...) { | |
49 | BOOST_TEST(type::instances == 0); | |
50 | } | |
51 | try { | |
52 | boost::make_shared<type[3][2]>(); | |
53 | BOOST_ERROR("make_shared did not throw"); | |
54 | } catch (...) { | |
55 | BOOST_TEST(type::instances == 0); | |
56 | } | |
57 | try { | |
58 | boost::make_shared_noinit<type[]>(6); | |
59 | BOOST_ERROR("make_shared_noinit did not throw"); | |
60 | } catch (...) { | |
61 | BOOST_TEST(type::instances == 0); | |
62 | } | |
63 | try { | |
64 | boost::make_shared_noinit<type[][2]>(3); | |
65 | BOOST_ERROR("make_shared_noinit did not throw"); | |
66 | } catch (...) { | |
67 | BOOST_TEST(type::instances == 0); | |
68 | } | |
69 | try { | |
70 | boost::make_shared_noinit<type[6]>(); | |
71 | BOOST_ERROR("make_shared_noinit did not throw"); | |
72 | } catch (...) { | |
73 | BOOST_TEST(type::instances == 0); | |
74 | } | |
75 | try { | |
76 | boost::make_shared_noinit<type[3][2]>(); | |
77 | BOOST_ERROR("make_shared_noinit did not throw"); | |
78 | } catch (...) { | |
79 | BOOST_TEST(type::instances == 0); | |
80 | } | |
81 | return boost::report_errors(); | |
82 | } |