]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | /* |
b32b8144 FG |
2 | Copyright 2012-2015 Glen Joseph Fernandes |
3 | (glenjofe@gmail.com) | |
7c673cae | 4 | |
b32b8144 FG |
5 | Distributed under the Boost Software License, Version 1.0. |
6 | (http://www.boost.org/LICENSE_1_0.txt) | |
7c673cae | 7 | */ |
f67539c2 | 8 | #include <boost/core/lightweight_test.hpp> |
7c673cae FG |
9 | #include <boost/smart_ptr/make_shared.hpp> |
10 | ||
11 | class type { | |
12 | public: | |
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 |
26 | private: |
27 | type(const type&); | |
28 | type& operator=(const type&); | |
29 | }; | |
30 | ||
b32b8144 | 31 | unsigned type::instances = 0; |
7c673cae FG |
32 | |
33 | int 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 | } |