From 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 6 Sep 2015 18:46:46 +0000 Subject: Import libc++ 3.7.0 release (r246257). --- .../func.wrap.func.con/alloc_F.pass.cpp | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp (limited to 'test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp') diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp new file mode 100644 index 000000000000..352ecfc602be --- /dev/null +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -0,0 +1,106 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&, F); + +#include +#include + +#include "min_allocator.h" +#include "test_allocator.h" +#include "count_new.hpp" +#include "../function_types.h" + +class DummyClass {}; + +template +void test_FunctionObject(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + FunctionObject target; + assert(FunctionObject::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(FunctionObject::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f2.template target()); + assert(f2.template target() == 0); + assert(f2.template target() == 0); + } + assert(FunctionObject::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + + +template +void test_FreeFunction(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + FuncType* target = &FreeFunction; + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_MemFunClass(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + TargetType target = &MemFunClass::foo; + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_for_alloc(Alloc& alloc) { + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + + test_MemFunClass(alloc); + test_MemFunClass(alloc); + test_MemFunClass(alloc); +} + +int main() +{ + { + bare_allocator bare_alloc; + test_for_alloc(bare_alloc); + } + { + non_default_test_allocator non_default_alloc(42); + test_for_alloc(non_default_alloc); + } +} -- cgit v1.3