1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // void reserve(size_type n);
15 #include "test_macros.h"
16 #include "test_allocator.h"
17 #include "min_allocator.h"
18 #include "asan_testing.h"
25 assert(v
.capacity() >= 10);
26 assert(is_contiguous_container_asan_correct(v
));
29 std::vector
<int> v(100);
30 assert(v
.capacity() == 100);
32 assert(v
.size() == 100);
33 assert(v
.capacity() == 100);
35 assert(v
.size() == 100);
36 assert(v
.capacity() == 150);
37 assert(is_contiguous_container_asan_correct(v
));
40 // Add 1 for implementations that dynamically allocate a container proxy.
41 std::vector
<int, limited_allocator
<int, 250 + 1> > v(100);
42 assert(v
.capacity() == 100);
44 assert(v
.size() == 100);
45 assert(v
.capacity() == 100);
47 assert(v
.size() == 100);
48 assert(v
.capacity() == 150);
49 assert(is_contiguous_container_asan_correct(v
));
51 #if TEST_STD_VER >= 11
53 std::vector
<int, min_allocator
<int>> v
;
55 assert(v
.capacity() >= 10);
56 assert(is_contiguous_container_asan_correct(v
));
59 std::vector
<int, min_allocator
<int>> v(100);
60 assert(v
.capacity() == 100);
62 assert(v
.size() == 100);
63 assert(v
.capacity() == 100);
65 assert(v
.size() == 100);
66 assert(v
.capacity() == 150);
67 assert(is_contiguous_container_asan_correct(v
));