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). --- .../basic.string/string.cons/alloc.pass.cpp | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 test/std/strings/basic.string/string.cons/alloc.pass.cpp (limited to 'test/std/strings/basic.string/string.cons/alloc.pass.cpp') diff --git a/test/std/strings/basic.string/string.cons/alloc.pass.cpp b/test/std/strings/basic.string/string.cons/alloc.pass.cpp new file mode 100644 index 0000000000000..1c4f2044834e5 --- /dev/null +++ b/test/std/strings/basic.string/string.cons/alloc.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit basic_string(const Allocator& a = Allocator()); + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test() +{ + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" ); +#endif + S s; + assert(s.__invariants()); + assert(s.data()); + assert(s.size() == 0); + assert(s.capacity() >= s.size()); + assert(s.get_allocator() == typename S::allocator_type()); + } + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{typename S::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible::value), "" ); +#endif + S s(typename S::allocator_type(5)); + assert(s.__invariants()); + assert(s.data()); + assert(s.size() == 0); + assert(s.capacity() >= s.size()); + assert(s.get_allocator() == typename S::allocator_type(5)); + } +} + +#if TEST_STD_VER >= 11 + +template +void +test2() +{ + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" ); +#endif + S s; + assert(s.__invariants()); + assert(s.data()); + assert(s.size() == 0); + assert(s.capacity() >= s.size()); + assert(s.get_allocator() == typename S::allocator_type()); + } + { +#if TEST_STD_VER > 14 + static_assert((noexcept(S{typename S::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible::value), "" ); +#endif + S s(typename S::allocator_type{}); + assert(s.__invariants()); + assert(s.data()); + assert(s.size() == 0); + assert(s.capacity() >= s.size()); + assert(s.get_allocator() == typename S::allocator_type()); + } +} + +#endif + +int main() +{ + test, test_allocator > >(); +#if TEST_STD_VER >= 11 + test2, min_allocator > >(); +#endif +} -- cgit v1.2.3