]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/testsuite_allocator.h
bitmap_allocator.h (allocate): Throw std::bad_alloc when n > max_size().
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / testsuite_allocator.h
index c10be5315d9da02404eea2277b9587fc9fa3ce07..7c353445e8a7baa70f31482ab4598aa9fab09d12 100644 (file)
@@ -36,6 +36,7 @@
 #define _GLIBCXX_TESTSUITE_ALLOCATOR_H
 
 #include <cstddef>
+#include <cstdlib>
 #include <limits>
 
 namespace 
@@ -205,7 +206,27 @@ namespace __gnu_test
       a.deallocate(NULL, 1);
       a.deallocate(NULL, 10);
     }
+
+  template<typename Alloc>
+    bool 
+    check_allocate_max_size()
+    {
+      Alloc a;
+      try
+       {
+         a.allocate(a.max_size() + 1);
+       }
+      catch(std::bad_alloc&)
+       {
+         return true;
+       }
+      catch(...)
+       {
+         throw;
+       }
+      throw;
+    }
+
 }; // namespace __gnu_test
 
 #endif // _GLIBCXX_TESTSUITE_ALLOCATOR_H
-