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// UNSUPPORTED: c++03
10
11// <vector>
12
13// vector(initializer_list<value_type> il);
14
15#include <vector>
16#include <cassert>
17#include "test_macros.h"
18#include "min_allocator.h"
19#include "asan_testing.h"
20
21TEST_CONSTEXPR_CXX20 bool tests() {
22 {
23 std::vector<int> d = {3, 4, 5, 6};
24 assert(d.size() == 4);
25 assert(is_contiguous_container_asan_correct(d));
26 assert(d[0] == 3);
27 assert(d[1] == 4);
28 assert(d[2] == 5);
29 assert(d[3] == 6);
30 }
31 {
32 std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
33 assert(d.size() == 4);
34 assert(is_contiguous_container_asan_correct(d));
35 assert(d[0] == 3);
36 assert(d[1] == 4);
37 assert(d[2] == 5);
38 assert(d[3] == 6);
39 }
40 {
41 std::vector<int, safe_allocator<int>> d = {3, 4, 5, 6};
42 assert(d.size() == 4);
43 assert(is_contiguous_container_asan_correct(d));
44 assert(d[0] == 3);
45 assert(d[1] == 4);
46 assert(d[2] == 5);
47 assert(d[3] == 6);
48 }
49
50 return true;
51}
52
53int main(int, char**) {
54 tests();
55#if TEST_STD_VER > 17
56 static_assert(tests());
57#endif
58 return 0;
59}
60

source code of libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp