1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <vector>
10 
11 // vector(size_type n, const value_type& x);
12 
13 #include <vector>
14 #include <cassert>
15 
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
19 #include "asan_testing.h"
20 
21 template <class C>
22 void
test(typename C::size_type n,const typename C::value_type & x)23 test(typename C::size_type n, const typename C::value_type& x)
24 {
25     C c(n, x);
26     LIBCPP_ASSERT(c.__invariants());
27     assert(c.size() == n);
28     LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
29     for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
30         assert(*i == x);
31 }
32 
main(int,char **)33 int main(int, char**)
34 {
35     test<std::vector<int> >(50, 3);
36     // Add 1 for implementations that dynamically allocate a container proxy.
37     test<std::vector<int, limited_allocator<int, 50 + 1> > >(50, 5);
38 #if TEST_STD_VER >= 11
39     test<std::vector<int, min_allocator<int>> >(50, 3);
40 #endif
41 
42   return 0;
43 }
44