testsuite_hooks.h (gnu_counting_struct): Add.

2001-12-27  Phil Edwards  <pme@gcc.gnu.org>

	* testsuite/testsuite_hooks.h (gnu_counting_struct):  Add.
	* testsuite/23_containers/deque_ctor.cc:  New file.

From-SVN: r48332
This commit is contained in:
Phil Edwards 2001-12-27 21:51:28 +00:00
parent a4b593ef7d
commit bb2ae697ab
3 changed files with 75 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2001-12-27 Phil Edwards <pme@gcc.gnu.org>
* testsuite/testsuite_hooks.h (gnu_counting_struct): Add.
* testsuite/23_containers/deque_ctor.cc: New file.
2001-12-27 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (collate::do_transform):

View file

@ -0,0 +1,46 @@
// 2001-12-27 pme
//
// Copyright (C) 2001 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 23.2.1.1 deque constructors, copy, and assignment
#include <deque>
#include <testsuite_hooks.h>
typedef std::deque<gnu_counting_struct> gdeque;
// basic alloc/dealloc sanity check
void
test01()
{
assert_count (0);
{
gdeque d(10);
assert_count (10);
}
assert_count (0);
}
int main()
{
test01();
return 0;
}

View file

@ -40,6 +40,12 @@
// calling application. The argument to __set_testsuite_memlimit() is the
// limit in megabytes (a floating-point number). If _GLIBCPP_MEM_LIMITS is
// #defined before including this header, then no limiting is attempted.
//
// 3) gnu_counting_struct
// This is a POD with a static data member, gnu_counting_struct::count,
// which starts at zero, increments on instance construction, and decrements
// on instance destruction. "assert_count(n)" can be called to VERIFY()
// that the count equals N.
#ifndef _GLIBCPP_TESTSUITE_HOOKS_H
#define _GLIBCPP_TESTSUITE_HOOKS_H
@ -99,5 +105,23 @@ __set_testsuite_memlimit(float __size = MEMLIMIT_MB)
}
#endif
struct gnu_counting_struct
{
// Specifically and glaringly-obviously marked 'signed' so that when
// count mistakenly goes negative, we can track the patterns of
// deletions easier.
typedef signed int size_type;
static size_type count;
gnu_counting_struct() { ++count; }
gnu_counting_struct (const gnu_counting_struct&) { ++count; }
~gnu_counting_struct() { --count; }
};
#define assert_count(n) VERIFY(gnu_counting_struct::count == n)
gnu_counting_struct::size_type gnu_counting_struct::count = 0;
#endif // _GLIBCPP_TESTSUITE_HOOKS_H