summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp31
-rw-r--r--libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp27
-rw-r--r--libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp27
-rw-r--r--libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp33
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp34
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp21
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp42
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp32
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp32
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp42
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp23
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp45
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp42
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp28
-rw-r--r--libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp44
-rw-r--r--libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp33
-rw-r--r--libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp59
-rw-r--r--libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp25
18 files changed, 171 insertions, 449 deletions
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
index f7c957baecc..9fcedddbd43 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
@@ -13,45 +13,28 @@
// ~ctype();
-// UNSUPPORTED: asan, msan
-
#include <locale>
#include <cassert>
-#include <new>
-
-unsigned delete_called = 0;
-void* operator new[](size_t sz) throw(std::bad_alloc)
-{
- return operator new(sz);
-}
-
-void operator delete[](void* p) throw()
-{
- operator delete(p);
- ++delete_called;
-}
+#include "count_new.hpp"
int main()
{
{
- delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>);
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
{
std::ctype<char>::mask table[256];
- delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>(table));
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
{
- delete_called = 0;
std::locale l(std::locale::classic(),
new std::ctype<char>(new std::ctype<char>::mask[256], true));
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 1);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(1));
}
diff --git a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
index 7e38021ba9a..a61a9c928d7 100644
--- a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
+++ b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
@@ -17,43 +17,26 @@
// // unspecified
// };
-// UNSUPPORTED: asan, msan
-
// Not a portable test
#include <codecvt>
#include <cstdlib>
#include <cassert>
-int outstanding_news = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++outstanding_news;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- if (p)
- {
- --outstanding_news;
- std::free(p);
- }
-}
+#include "count_new.hpp"
int main()
{
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
typedef std::codecvt_utf16<wchar_t> C;
C c;
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
typedef std::codecvt_utf16<wchar_t> C;
std::locale loc(std::locale::classic(), new C);
- assert(outstanding_news != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
index cc06e95f406..5fa0eaaf8eb 100644
--- a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
+++ b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
@@ -17,43 +17,26 @@
// // unspecified
// };
-// UNSUPPORTED: asan, msan
-
// Not a portable test
#include <codecvt>
#include <cstdlib>
#include <cassert>
-int outstanding_news = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++outstanding_news;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- if (p)
- {
- --outstanding_news;
- std::free(p);
- }
-}
+#include "count_new.hpp"
int main()
{
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
typedef std::codecvt_utf8<wchar_t> C;
C c;
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
typedef std::codecvt_utf8<wchar_t> C;
std::locale loc(std::locale::classic(), new C);
- assert(outstanding_news != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
index 3649f157d04..5f57df12f02 100644
--- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
@@ -14,27 +14,12 @@
// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt,
// state_type state = state_type());
-// UNSUPPORTED: asan, msan
-
#include <locale>
#include <codecvt>
#include <sstream>
#include <cassert>
-#include <new>
-
-int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
int main()
{
@@ -46,28 +31,28 @@ int main()
{
B b;
assert(b.rdbuf() == nullptr);
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf());
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
index 25db9bbf1ac..1efc939f3c2 100644
--- a/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
@@ -11,27 +11,11 @@
// locale() throw();
-// UNSUPPORTED: asan, msan
-
#include <locale>
-#include <new>
#include <cassert>
#include "platform_support.h" // locale name macros
-
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
void check(const std::locale& loc)
{
@@ -73,19 +57,19 @@ int main()
int ok;
{
std::locale loc;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(loc.name() == "C");
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
check(loc);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
- ok = new_called;
+ ok = globalMemCounter.outstanding_new;
std::locale loc2;
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
check(loc2);
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
}
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
}
diff --git a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
index 8f189c70f81..e956102c08f 100644
--- a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
@@ -11,25 +11,10 @@
// template <class Facet> locale combine(const locale& other) const;
-// UNSUPPORTED: asan, msan
-
#include <locale>
-#include <new>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
void check(const std::locale& loc)
{
@@ -89,7 +74,7 @@ int main()
const my_facet& f = std::use_facet<my_facet>(loc3);
assert(f.test() == 5);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
{
@@ -104,6 +89,6 @@ int main()
{
}
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
index b8995bffe0f..58192c928d5 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
@@ -14,26 +14,12 @@
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
-// UNSUPPORTED: asan, msan
#include <functional>
-#include <new>
#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -73,65 +59,65 @@ int h(int) {return 1;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
swap(f1, f2);
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
swap(f1, f2);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
swap(f1, f2);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
swap(f1, f2);
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
index 3a43be73f7a..f506af0e001 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
@@ -13,26 +13,10 @@
// function(nullptr_t);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -67,34 +51,34 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = (int (*)(int))0;
assert(!f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
{
std::function<int(const A*, int)> f = &A::foo;
assert(f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int (A::*)(int) const>() != 0);
}
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
index ba65cd3330b..7784943cb13 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
@@ -16,26 +16,10 @@
// && Convertible<Callable<F, ArgTypes...>::result_type
// operator=(F f);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -70,30 +54,30 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
f = (int (*)(int))0;
assert(!f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
}
@@ -101,7 +85,7 @@ int main()
std::function<int(const A*, int)> f;
f = &A::foo;
assert(f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int (A::*)(int) const>() != 0);
}
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
index 38e65fc845f..15bf3398f5f 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -13,28 +13,12 @@
// template<class A> function(allocator_arg_t, const A&, const function&);
-// UNSUPPORTED: asan, msan
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
#include "test_allocator.h"
-
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -67,48 +51,48 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), f);
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2(std::allocator_arg, test_allocator<int(*)(int)>(), f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
non_default_test_allocator<std::function<int(int)>> al(1);
std::function<int(int)> f2(std::allocator_arg, al, g);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2(std::allocator_arg, test_allocator<int>(), f);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
index 2180b8936d7..15b7c8b5aa4 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -13,26 +13,11 @@
// template<class A> function(allocator_arg_t, const A&, function&&);
-// UNSUPPORTED: asan, msan
-
#include <functional>
#include <cassert>
#include "test_allocator.h"
-
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -64,16 +49,16 @@ int A::count = 0;
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), std::move(f));
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
index 2fbd7cfa9fb..f603da9dd13 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
@@ -13,26 +13,11 @@
// function(const function& f);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -65,65 +50,65 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = f;
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2 = f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
{
std::function<int(int)> f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
assert(!f);
std::function<long(int)> g = f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(g.target<long(*)(int)>() == 0);
assert(g.target<A>() == 0);
assert(!g);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2 = std::move(f);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
index cfa79e24401..c91eaa2d567 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
@@ -13,26 +13,10 @@
// function& operator=(const function& f);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -65,57 +49,57 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = f;
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>());
assert(f2.target<A>() == 0);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
std::function<int(int)> f2;
f2 = f;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
std::function<int(int)> f2;
f2 = std::move(f);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f2.target<A>());
assert(f2.target<int(*)(int)>() == 0);
assert(f.target<A>() == 0);
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
index b8c597b63ce..9b2482fb9d5 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
@@ -13,26 +13,10 @@
// function& operator=(nullptr_t);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -65,24 +49,24 @@ int g(int) {return 0;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f = A();
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f.target<A>());
f = nullptr;
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<A>() == 0);
}
{
std::function<int(int)> f = g;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
f = nullptr;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(f.target<int(*)(int)>() == 0);
}
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
index 3c012d1db4f..f94e689b2a6 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
@@ -13,26 +13,10 @@
// void swap(function& other);
-// UNSUPPORTED: asan, msan
-
#include <functional>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
class A
{
@@ -72,65 +56,65 @@ int h(int) {return 1;}
int main()
{
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = A(2);
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f1.target<A>()->id() == 1);
assert(f2.target<A>()->id() == 2);
f1.swap(f2);
assert(A::count == 2);
- assert(new_called == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
assert(f1.target<A>()->id() == 2);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> f2 = g;
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
f1.swap(f2);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = A(1);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(*f1.target<int(*)(int)>() == g);
assert(f2.target<A>()->id() == 1);
f1.swap(f2);
assert(A::count == 1);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(f1.target<A>()->id() == 1);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::function<int(int)> f1 = g;
std::function<int(int)> f2 = h;
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(*f1.target<int(*)(int)>() == g);
assert(*f2.target<int(*)(int)>() == h);
f1.swap(f2);
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(*f1.target<int(*)(int)>() == h);
assert(*f2.target<int(*)(int)>() == g);
}
assert(A::count == 0);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
index a4a84e877dc..253515e3db3 100644
--- a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
+++ b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
@@ -12,27 +12,10 @@
// allocator:
// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
-// UNSUPPORTED: asan, msan
-
#include <memory>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- assert(s == 3 * sizeof(int));
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
int A_constructed = 0;
@@ -47,19 +30,23 @@ struct A
int main()
{
std::allocator<A> a;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
+ globalMemCounter.last_new_size = 0;
A* ap = a.allocate(3);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(A_constructed == 0);
a.deallocate(ap, 3);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
+ globalMemCounter.last_new_size = 0;
A* ap2 = a.allocate(3, (const void*)5);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(A_constructed == 0);
a.deallocate(ap2, 3);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
}
diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
index b9a174973f2..d0a870e6069 100644
--- a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
+++ b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
@@ -12,27 +12,10 @@
// allocator:
// template <class... Args> void construct(pointer p, Args&&... args);
-// UNSUPPORTED: asan, msan
-
#include <memory>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- assert(s == 3 * sizeof(int));
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
int A_constructed = 0;
@@ -80,76 +63,80 @@ int main()
{
{
std::allocator<A> a;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
+ globalMemCounter.last_new_size = 0;
A* ap = a.allocate(3);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(A_constructed == 0);
a.construct(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 0);
a.construct(ap, A());
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 0);
a.construct(ap, 5);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 0);
a.construct(ap, 5, (int*)0);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(A_constructed == 0);
a.deallocate(ap, 3);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
}
{
std::allocator<move_only> a;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(move_only_constructed == 0);
+ globalMemCounter.last_new_size = 0;
move_only* ap = a.allocate(3);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(move_only_constructed == 0);
a.construct(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(move_only_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(move_only_constructed == 0);
a.construct(ap, move_only());
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(move_only_constructed == 1);
a.destroy(ap);
- assert(new_called == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
assert(move_only_constructed == 0);
a.deallocate(ap, 3);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(move_only_constructed == 0);
}
}
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
index 30a4984003b..5dfa4cd66bc 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -13,25 +13,10 @@
// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
-// UNSUPPORTED: asan, msan
-
#include <memory>
-#include <new>
-#include <cstdlib>
#include <cassert>
-int new_count = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_count;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- std::free(p);
-}
+#include "count_new.hpp"
struct A
{
@@ -54,22 +39,22 @@ int A::count = 0;
int main()
{
- int nc = new_count;
+ int nc = globalMemCounter.outstanding_new;
{
int i = 67;
char c = 'e';
std::shared_ptr<A> p = std::make_shared<A>(i, c);
- assert(new_count == nc+1);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
assert(A::count == 1);
assert(p->get_int() == 67);
assert(p->get_char() == 'e');
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- nc = new_count;
+ nc = globalMemCounter.outstanding_new;
{
char c = 'e';
std::shared_ptr<A> p = std::make_shared<A>(67, c);
- assert(new_count == nc+1);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
assert(A::count == 1);
assert(p->get_int() == 67);
assert(p->get_char() == 'e');
OpenPOWER on IntegriCloud