summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/memory
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2013-12-03 00:18:10 +0000
committerMarshall Clow <mclow.lists@gmail.com>2013-12-03 00:18:10 +0000
commitc3deeb5f89f0fa733e4e2c4d260d6f816d6b1b5e (patch)
treea59c2eb3bc80868163acd2b90331ceb4fed6fb67 /libcxx/test/utilities/memory
parentba71833846c66d80ccc52c3fec57772f5995bf5b (diff)
downloadbcm5719-llvm-c3deeb5f89f0fa733e4e2c4d260d6f816d6b1b5e.tar.gz
bcm5719-llvm-c3deeb5f89f0fa733e4e2c4d260d6f816d6b1b5e.zip
Found six (nmostly) identical files named 'test_allocator.h' in the libcxx test suite. Moved one to /support, made it a superset, and removed all but one of the others, and iupdated all the includes. Left the odd one (thread/futures/test_allocator.h) for later.
llvm-svn: 196174
Diffstat (limited to 'libcxx/test/utilities/memory')
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h82
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp2
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp2
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp2
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp2
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp2
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp2
7 files changed, 6 insertions, 88 deletions
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
deleted file mode 100644
index d9b72bce49e..00000000000
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef TEST_ALLOCATOR_H
-#define TEST_ALLOCATOR_H
-
-#include <cstddef>
-#include <type_traits>
-#include <cstdlib>
-#include <new>
-#include <climits>
-#include <cassert>
-
-class test_alloc_base
-{
-protected:
- static int time_to_throw;
-public:
- static int throw_after;
- static int count;
- static int alloc_count;
-};
-
-int test_alloc_base::count = 0;
-int test_alloc_base::time_to_throw = 0;
-int test_alloc_base::alloc_count = 0;
-int test_alloc_base::throw_after = INT_MAX;
-
-template <class T>
-class test_allocator
- : public test_alloc_base
-{
- int data_;
-
- template <class U> friend class test_allocator;
-public:
-
- typedef unsigned size_type;
- typedef int difference_type;
- typedef T value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef typename std::add_lvalue_reference<value_type>::type reference;
- typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
-
- template <class U> struct rebind {typedef test_allocator<U> other;};
-
- test_allocator() throw() : data_(0) {++count;}
- explicit test_allocator(int i) throw() : data_(i) {++count;}
- test_allocator(const test_allocator& a) throw()
- : data_(a.data_) {++count;}
- template <class U> test_allocator(const test_allocator<U>& a) throw()
- : data_(a.data_) {++count;}
- ~test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
- pointer address(reference x) const {return &x;}
- const_pointer address(const_reference x) const {return &x;}
- pointer allocate(size_type n, const void* = 0)
- {
- assert(data_ >= 0);
- if (time_to_throw >= throw_after) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw std::bad_alloc();
-#else
- std::terminate();
-#endif
- }
- ++time_to_throw;
- ++alloc_count;
- return (pointer)std::malloc(n * sizeof(T));
- }
- void deallocate(pointer p, size_type n)
- {assert(data_ >= 0); --alloc_count; std::free(p);}
- size_type max_size() const throw()
- {return UINT_MAX / sizeof(T);}
- void construct(pointer p, const T& val)
- {::new(p) T(val);}
- void destroy(pointer p) {p->~T();}
-
- friend bool operator==(const test_allocator& x, const test_allocator& y)
- {return x.data_ == y.data_;}
- friend bool operator!=(const test_allocator& x, const test_allocator& y)
- {return !(x == y);}
-};
-
-#endif // TEST_ALLOCATOR_H
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
index 509752e12b5..7966e00e0c5 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
@@ -14,7 +14,7 @@
#include <memory>
#include <cassert>
#include "../test_deleter.h"
-#include "../test_allocator.h"
+#include "test_allocator.h"
struct A
{
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
index 6d14920d6ae..ab2c73e0c5f 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -14,7 +14,7 @@
#include <memory>
#include <cassert>
#include "../test_deleter.h"
-#include "../test_allocator.h"
+#include "test_allocator.h"
struct A
{
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
index 98ecd1307ff..23d3f10ed35 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -14,7 +14,7 @@
#include <memory>
#include <cassert>
#include "../test_deleter.h"
-#include "../test_allocator.h"
+#include "test_allocator.h"
struct A
{
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
index 9b93a7cca36..4220993a5fd 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -14,7 +14,7 @@
#include <memory>
#include <cassert>
#include "../test_deleter.h"
-#include "../test_allocator.h"
+#include "test_allocator.h"
struct A
{
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
index 5c9d9a309e4..e019837d707 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -18,7 +18,7 @@
#include <new>
#include <cstdlib>
#include <cassert>
-#include "../test_allocator.h"
+#include "test_allocator.h"
int new_count = 0;
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
index 42360d6ed42..09070e2c059 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
@@ -16,7 +16,7 @@
#include <memory>
#include <cassert>
#include "../test_deleter.h"
-#include "../test_allocator.h"
+#include "test_allocator.h"
struct B
{
OpenPOWER on IntegriCloud