aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorpme <pme@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-27 21:51:28 +0000
committerpme <pme@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-27 21:51:28 +0000
commit5edc4f6599d0b5f0379bed87722f90cd9f94da53 (patch)
treec626dd3ff096f498ecf01785588f1b74915a1627 /libstdc++-v3/testsuite
parent85c82a70e896e6622c1949c856dbfc96720cdde4 (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48332 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque_ctor.cc46
-rw-r--r--libstdc++-v3/testsuite/testsuite_hooks.h24
2 files changed, 70 insertions, 0 deletions
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