testsuite_allocator.cc revision 1.1.1.1
1// -*- C++ -*- 2// Testing allocator for the C++ library testsuite. 3// 4// Copyright (C) 2002, 2003, 2009 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. 11// 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. 16// 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/>. 20// 21 22#include <iostream> 23#include <testsuite_allocator.h> 24 25namespace __gnu_test 26{ 27 typedef tracker_allocator_counter counter_type; 28 29 counter_type::size_type 30 counter_type::allocationCount_ = 0; 31 32 counter_type::size_type 33 counter_type::deallocationCount_ = 0; 34 35 int counter_type::constructCount_ = 0; 36 int counter_type::destructCount_ = 0; 37 38 bool 39 check_construct_destroy(const char* tag, int expected_c, int expected_d) 40 { 41 bool ret = true; 42 if (counter_type::get_construct_count() != expected_c 43 || counter_type::get_destruct_count() != expected_d) 44 { 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; 52 } 53 return ret; 54 } 55} // namespace __cxx_test 56 57