]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite_allocator.h (check_delete): New.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 29 Oct 2004 21:03:07 +0000 (21:03 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 29 Oct 2004 21:03:07 +0000 (21:03 +0000)
2004-10-29  Benjamin Kosnik  <bkoz@redhat.com>

* testsuite/testsuite_allocator.h (check_delete): New.
(check_new): Simplify.
* testsuite/ext/array_allocator/check_delete.cc: New.
* testsuite/ext/array_allocator/check_new.cc: Simplify.
* testsuite/ext/debug_allocator/check_delete.cc: New.
* testsuite/ext/debug_allocator/check_new.cc: Simplify.
* testsuite/ext/malloc_allocator/check_delete.cc: New.
* testsuite/ext/malloc_allocator/check_new.cc: Simplify.
* testsuite/ext/mt_allocator/check_delete.cc: New.
* testsuite/ext/mt_allocator/check_new.cc: Simplify.
* testsuite/ext/new_allocator/check_delete.cc: New.
* testsuite/ext/new_allocator/check_new.cc: Simplify.
* testsuite/ext/pool_allocator/check_delete.cc: New.
* testsuite/ext/pool_allocator/check_new.cc: Simplify.

From-SVN: r89850

14 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/array_allocator/check_new.cc
libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/debug_allocator/check_new.cc
libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/malloc_allocator/check_new.cc
libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc
libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/new_allocator/check_new.cc
libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/pool_allocator/check_new.cc
libstdc++-v3/testsuite/testsuite_allocator.h

index 81f88ffda31fcae57102cbdbfa52bbaebc7a53ab..f716244fe18bf72288f7bbf454369caae2e3522c 100644 (file)
@@ -1,3 +1,20 @@
+2004-10-29  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * testsuite/testsuite_allocator.h (check_delete): New.
+       (check_new): Simplify.
+       * testsuite/ext/array_allocator/check_delete.cc: New.
+       * testsuite/ext/array_allocator/check_new.cc: Simplify.
+       * testsuite/ext/debug_allocator/check_delete.cc: New.
+       * testsuite/ext/debug_allocator/check_new.cc: Simplify.
+       * testsuite/ext/malloc_allocator/check_delete.cc: New.
+       * testsuite/ext/malloc_allocator/check_new.cc: Simplify.
+       * testsuite/ext/mt_allocator/check_delete.cc: New.
+       * testsuite/ext/mt_allocator/check_new.cc: Simplify.
+       * testsuite/ext/new_allocator/check_delete.cc: New.
+       * testsuite/ext/new_allocator/check_new.cc: Simplify.
+       * testsuite/ext/pool_allocator/check_delete.cc: New.
+       * testsuite/ext/pool_allocator/check_new.cc: Simplify.
+
 2004-10-28  Chris Jefferson  <chris@bubblescope.net>
 
        PR libstdc++/18159
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..fa35f33
--- /dev/null
@@ -0,0 +1,61 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/array_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::array_allocator;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void *v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+// These just help tracking down error messages.
+void test01() 
+{ 
+  bool test __attribute__((unused)) = true;
+  typedef unsigned int value_type;
+  typedef std::tr1::array<value_type, 15> array_type;
+  typedef array_allocator<value_type, array_type> allocator_type;
+  array_type store;
+  allocator_type a(&store);
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, false>(a)) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
+
index 2d15972f6a7900669620dabae8758eef88024ca5..5978904929858a629190b3c739ac6733f58fcb06 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <cstdlib>
 #include <ext/array_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::array_allocator;
@@ -30,7 +31,6 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
@@ -42,18 +42,20 @@ operator delete(void *v) throw()
 }
 
 // These just help tracking down error messages.
-bool test01() 
+void test01() 
 { 
+  bool test __attribute__((unused)) = true;
   typedef unsigned int value_type;
   typedef std::tr1::array<value_type, 15> array_type;
   typedef array_allocator<value_type, array_type> allocator_type;
   array_type store;
   allocator_type a(&store);
-  return (__gnu_test::check_new<allocator_type, false>(a) == false); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, false>(a)) ); 
 }
 
 int main()
 {
-  return test01();
+  test01();
+  return 0;
 }
 
diff --git a/libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..25cf731
--- /dev/null
@@ -0,0 +1,59 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/debug_allocator.h>
+#include <ext/malloc_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::malloc_allocator;
+using __gnu_cxx::debug_allocator;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void *v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+// These just help tracking down error messages.
+void test01() 
+{ 
+  bool test __attribute__((unused)) = true;
+  typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
+
index 04358f2d4a0f3cd239134a7095bd45617e4ca600..3fe45989076be9df1aca92cf1adb8d9e628a95a3 100644 (file)
@@ -23,6 +23,7 @@
 #include <cstdlib>
 #include <ext/debug_allocator.h>
 #include <ext/malloc_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::malloc_allocator;
@@ -32,7 +33,6 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
@@ -43,14 +43,17 @@ operator delete(void *v) throw()
   return std::free(v);
 }
 
-bool test02() 
+// These just help tracking down error messages.
+void test01() 
 { 
+  bool test __attribute__((unused)) = true;
   typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
-  return (__gnu_test::check_new<allocator_type, false>() == false); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, false>()) ); 
 }
 
 int main()
 {
-  return test02();
+  test01();
+  return 0;
 }
 
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..ea40e3c
--- /dev/null
@@ -0,0 +1,57 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/malloc_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::malloc_allocator;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void *v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+// These just help tracking down error messages.
+void test01() 
+{ 
+  bool test __attribute__((unused)) = true;
+  typedef malloc_allocator<unsigned int> allocator_type;
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
+
index 544839aaad7fc445e9d7d028a35fe61c9b7e91ec..e6e159ca5109d0e3b7ce9871261e711a04d8a531 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <cstdlib>
 #include <ext/malloc_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::malloc_allocator;
@@ -30,7 +31,6 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
@@ -42,14 +42,16 @@ operator delete(void *v) throw()
 }
 
 // These just help tracking down error messages.
-bool test01() 
+void test01() 
 { 
+  bool test __attribute__((unused)) = true;
   typedef malloc_allocator<unsigned int> allocator_type;
-  return (__gnu_test::check_new<allocator_type, false>() == false); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, false>()) ); 
 }
 
 int main()
 {
-  return test01();
+  test01();
+  return 0;
 }
 
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..81fde66
--- /dev/null
@@ -0,0 +1,55 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::__mt_alloc;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void* v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+void test01() 
+{ 
+  bool test __attribute__((unused)) = true;
+  typedef __mt_alloc<unsigned int> allocator_type;
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 9e08821460234e17dca576ffda1bf773992d9aeb..e3a08f33adbe75f19aa520f6bf851aa000b521db 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <cstdlib>
 #include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::__mt_alloc;
@@ -30,25 +31,26 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
 void
-operator delete(void *v) throw()
+operator delete(voidv) throw()
 {
   delete_called = true;
   return std::free(v);
 }
 
-bool test03() 
+void test01() 
 { 
+  // Uses new but delete only optionally.
+  bool test __attribute__((unused)) = true;
   typedef __mt_alloc<unsigned int> allocator_type;
-  return (__gnu_test::check_new<allocator_type, true>() == true); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) ); 
 }
 
 int main()
 {
-  return test03();
+  test01();
+  return 0;
 }
-
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..49ce3ad
--- /dev/null
@@ -0,0 +1,57 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/new_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::new_allocator;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void *v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+// These just help tracking down error messages.
+void test01() 
+{ 
+  bool test __attribute__((unused)) = true;
+  typedef new_allocator<unsigned int> allocator_type;
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, true>()) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
+
index e2be5743fdba5664735e2101f3b6d613b6c97676..39ab08e7d818a09c92653bac34f9912b240e80ab 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <cstdlib>
 #include <ext/new_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::new_allocator;
@@ -30,7 +31,6 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
@@ -42,14 +42,16 @@ operator delete(void *v) throw()
 }
 
 // These just help tracking down error messages.
-bool test01() 
+void test01() 
 { 
+  bool test __attribute__((unused)) = true;
   typedef new_allocator<unsigned int> allocator_type;
-  return (__gnu_test::check_new<allocator_type, true>() == true); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) ); 
 }
 
 int main()
 {
-  return test01();
+  test01();
+  return 0;
 }
 
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc
new file mode 100644 (file)
index 0000000..79ce858
--- /dev/null
@@ -0,0 +1,57 @@
+// 2001-11-25  Phil Edwards  <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/pool_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using __gnu_cxx::__pool_alloc;
+
+void* 
+operator new(std::size_t n) throw(std::bad_alloc)
+{
+  new_called = true;
+  return std::malloc(n);
+}
+
+void
+operator delete(void *v) throw()
+{
+  delete_called = true;
+  return std::free(v);
+}
+
+void test01() 
+{ 
+  // Uses new, but delete only sometimes.
+  bool test __attribute__((unused)) = true;
+  typedef __pool_alloc<unsigned int> allocator_type;
+  VERIFY( bool(__gnu_test::check_delete<allocator_type, false>()) ); 
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
+
index ba6c75118ee14e342f7f704f883d17ebf0d6540f..be37b8658e38d2e3fb0020daff9bb0df427569d4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <cstdlib>
 #include <ext/pool_allocator.h>
+#include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
 using __gnu_cxx::__pool_alloc;
@@ -30,7 +31,6 @@ void*
 operator new(std::size_t n) throw(std::bad_alloc)
 {
   new_called = true;
-  requested = n;
   return std::malloc(n);
 }
 
@@ -41,14 +41,16 @@ operator delete(void *v) throw()
   return std::free(v);
 }
 
-bool test03() 
+void test01() 
 { 
+  bool test __attribute__((unused)) = true;
   typedef __pool_alloc<unsigned int> allocator_type;
-  return (__gnu_test::check_new<allocator_type, true>() == true); 
+  VERIFY( bool(__gnu_test::check_new<allocator_type, true>()) ); 
 }
 
 int main()
 {
-  return test03();
+  test01();
+  return 0;
 }
 
index a13df804ed3549851629b0f1181f459a671dd234..7be830e83aa1da8d712852c71e800f479b8ad06e 100644 (file)
@@ -40,9 +40,8 @@
 
 namespace 
 {
-  bool         new_called = false;
-  bool         delete_called = false;
-  std::size_t  requested = 0;
+  bool new_called = false;
+  bool delete_called = false;
 };
 
 namespace __gnu_test
@@ -180,19 +179,24 @@ namespace __gnu_test
   bool
   check_construct_destroy(const char* tag, int expected_c, int expected_d);
 
-  template<typename Alloc, bool uses_global_new_and_delete>
+  template<typename Alloc, bool uses_global_new>
     bool 
     check_new(Alloc a = Alloc())
     {
       bool test __attribute__((unused)) = true;
       typename Alloc::pointer p = a.allocate(10);
-      if (uses_global_new_and_delete)  
-       test &= ( requested >= (10 * 15 * sizeof(long)) );
-      
-      test &= ( new_called == uses_global_new_and_delete );
+      test &= ( new_called == uses_global_new );
+      return test;
+    }
+
+  template<typename Alloc, bool uses_global_delete>
+    bool 
+    check_delete(Alloc a = Alloc())
+    {
+      bool test __attribute__((unused)) = true;
+      typename Alloc::pointer p = a.allocate(10);
       a.deallocate(p, 10);
-      test &= ( delete_called == uses_global_new_and_delete );
-      
+      test &= ( delete_called == uses_global_delete );
       return test;
     }