Last change
on this file since 45 was
29,
checked in by landauf, 17 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.1 KB
|
Line | |
---|
1 | // Copyright David Abrahams 2004. Distributed under the Boost |
---|
2 | // Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | #include <boost/python/detail/destroy.hpp> |
---|
5 | |
---|
6 | #include <boost/detail/lightweight_test.hpp> |
---|
7 | |
---|
8 | int count; |
---|
9 | int marks[] = { |
---|
10 | -1 |
---|
11 | , -1, -1 |
---|
12 | , -1, -1, -1, -1 |
---|
13 | , -1 |
---|
14 | }; |
---|
15 | int* kills = marks; |
---|
16 | |
---|
17 | struct foo |
---|
18 | { |
---|
19 | foo() : n(count++) {} |
---|
20 | ~foo() |
---|
21 | { |
---|
22 | *kills++ = n; |
---|
23 | } |
---|
24 | int n; |
---|
25 | }; |
---|
26 | |
---|
27 | void assert_destructions(int n) |
---|
28 | { |
---|
29 | for (int i = 0; i < n; ++i) |
---|
30 | BOOST_TEST(marks[i] == i); |
---|
31 | BOOST_TEST(marks[n] == -1); |
---|
32 | } |
---|
33 | |
---|
34 | int main() |
---|
35 | { |
---|
36 | assert_destructions(0); |
---|
37 | typedef int a[2]; |
---|
38 | |
---|
39 | foo* f1 = new foo; |
---|
40 | boost::python::detail::destroy_referent<foo const volatile&>(f1); |
---|
41 | assert_destructions(1); |
---|
42 | |
---|
43 | foo* f2 = new foo[2]; |
---|
44 | typedef foo x[2]; |
---|
45 | |
---|
46 | boost::python::detail::destroy_referent<x const&>(f2); |
---|
47 | assert_destructions(3); |
---|
48 | |
---|
49 | typedef foo y[2][2]; |
---|
50 | x* f3 = new y; |
---|
51 | boost::python::detail::destroy_referent<y&>(f3); |
---|
52 | assert_destructions(7); |
---|
53 | |
---|
54 | return boost::report_errors(); |
---|
55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.