2017-03-14 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libstdc++-v3 / testsuite / util / testsuite_allocator.cc
blob3085d4523476823c400b28daf64ffc28d8123348
1 // -*- C++ -*-
2 // Testing allocator for the C++ library testsuite.
3 //
4 // Copyright (C) 2002-2017 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 #include <iostream>
23 #include <testsuite_allocator.h>
25 namespace __gnu_test
27 typedef tracker_allocator_counter counter_type;
29 counter_type::size_type
30 counter_type::allocationCount_ = 0;
32 counter_type::size_type
33 counter_type::deallocationCount_ = 0;
35 int counter_type::constructCount_ = 0;
36 int counter_type::destructCount_ = 0;
38 bool
39 check_construct_destroy(const char* tag, int expected_c, int expected_d)
41 bool ret = true;
42 if (counter_type::get_construct_count() != expected_c
43 || counter_type::get_destruct_count() != expected_d)
45 std::cerr << tag << ": "
46 << " construct = " << counter_type::get_construct_count()
47 << " (should be " << expected_c << "),"
48 << " destroy = " << counter_type::get_destruct_count()
49 << " (should be " << expected_d << ")"
50 << std::endl;
51 ret = false;
53 return ret;
55 } // namespace __cxx_test