1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // Split into two calls for C++20
14 // void reserve(size_type res_arg);
20 #include "test_macros.h"
21 #include "min_allocator.h"
27 typename S::size_type old_cap = s.capacity();
30 LIBCPP_ASSERT(s.__invariants());
32 assert(s.capacity() <= old_cap);
33 assert(s.capacity() >= s.size());
38 test(S s, typename S::size_type res_arg)
40 typename S::size_type old_cap = s.capacity();
41 ((void)old_cap); // Prevent unused warning
43 if (res_arg <= s.max_size())
47 assert(s.capacity() >= res_arg);
48 assert(s.capacity() >= s.size());
50 assert(s.capacity() >= old_cap); // resize never shrinks as of P0966
53 #ifndef TEST_HAS_NO_EXCEPTIONS
61 catch (std::length_error&)
63 assert(res_arg > s.max_size());
72 typedef std::string S;
102 #if TEST_STD_VER >= 11
104 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;