diff options
author | Phil Edwards <pme@gcc.gnu.org> | 2001-12-27 21:51:28 +0000 |
---|---|---|
committer | Phil Edwards <pme@gcc.gnu.org> | 2001-12-27 21:51:28 +0000 |
commit | bb2ae697ab610f10045da76435c9934d06dce608 (patch) | |
tree | c626dd3ff096f498ecf01785588f1b74915a1627 | |
parent | a4b593ef7da891ee4521dc0a6b07228eb9ddbd79 (diff) | |
download | gcc-bb2ae697ab610f10045da76435c9934d06dce608.tar.gz |
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/deque_ctor.cc | 46 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/testsuite_hooks.h | 24 |
3 files changed, 75 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 671df4ffa0f..2be936a44cd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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): diff --git a/libstdc++-v3/testsuite/23_containers/deque_ctor.cc b/libstdc++-v3/testsuite/23_containers/deque_ctor.cc new file mode 100644 index 00000000000..b02175dd734 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque_ctor.cc @@ -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; +} diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h index b7e96cb2cf0..97bf04bd519 100644 --- a/libstdc++-v3/testsuite/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/testsuite_hooks.h @@ -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 |