-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathchecked_delete_test.cpp
More file actions
58 lines (40 loc) · 962 Bytes
/
checked_delete_test.cpp
File metadata and controls
58 lines (40 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Boost checked_delete test program
// Copyright Beman Dawes 2001. Copyright 2014 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/checked_delete.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{
static int instances;
X()
{
++instances;
}
~X()
{
--instances;
}
private:
X( X const & );
X & operator=( X const & );
};
int X::instances = 0;
int main()
{
BOOST_TEST( X::instances == 0 );
{
X * p = new X;
BOOST_TEST( X::instances == 1 );
boost::checked_delete( p );
BOOST_TEST( X::instances == 0 );
}
{
X * p = new X[ 3 ];
BOOST_TEST( X::instances == 3 );
boost::checked_array_delete( p );
BOOST_TEST( X::instances == 0 );
}
return boost::report_errors();
}