testsuite_hooks.h (gnu_counting_struct): Add.
authorPhil Edwards <pme@gcc.gnu.org>
Thu, 27 Dec 2001 21:51:28 +0000 (21:51 +0000)
committerPhil Edwards <pme@gcc.gnu.org>
Thu, 27 Dec 2001 21:51:28 +0000 (21:51 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/23_containers/deque_ctor.cc [new file with mode: 0644]
libstdc++-v3/testsuite/testsuite_hooks.h

index 671df4ffa0f5b66b6d0368300c9d2cb2402a3b49..2be936a44cd0d711bcd593c676f69af8ace57c97 100644 (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):
diff --git a/libstdc++-v3/testsuite/23_containers/deque_ctor.cc b/libstdc++-v3/testsuite/23_containers/deque_ctor.cc
new file mode 100644 (file)
index 0000000..b02175d
--- /dev/null
@@ -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;
+}
index b7e96cb2cf05b10d9baaa5ae9d3a6851c4771e75..97bf04bd5199238ce9297fc3f7ebf06544eab1d1 100644 (file)
 //   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