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 push_back(const value_type& x);
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
19 #include "asan_testing.h"
26 assert(c
.size() == 1);
27 assert(is_contiguous_container_asan_correct(c
));
28 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
31 assert(c
.size() == 2);
32 assert(is_contiguous_container_asan_correct(c
));
33 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
36 assert(c
.size() == 3);
37 assert(is_contiguous_container_asan_correct(c
));
38 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
41 assert(c
.size() == 4);
42 assert(is_contiguous_container_asan_correct(c
));
43 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
46 assert(c
.size() == 5);
47 assert(is_contiguous_container_asan_correct(c
));
48 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
52 // libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
53 // Use 17 for implementations that dynamically allocate a container proxy
54 // and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
55 std::vector
<int, limited_allocator
<int, 17> > c
;
57 assert(c
.size() == 1);
58 assert(is_contiguous_container_asan_correct(c
));
59 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
62 assert(c
.size() == 2);
63 assert(is_contiguous_container_asan_correct(c
));
64 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
67 assert(c
.size() == 3);
68 assert(is_contiguous_container_asan_correct(c
));
69 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
72 assert(c
.size() == 4);
73 assert(is_contiguous_container_asan_correct(c
));
74 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
77 assert(c
.size() == 5);
78 assert(is_contiguous_container_asan_correct(c
));
79 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
82 #if TEST_STD_VER >= 11
84 std::vector
<int, min_allocator
<int>> c
;
86 assert(c
.size() == 1);
87 assert(is_contiguous_container_asan_correct(c
));
88 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
91 assert(c
.size() == 2);
92 assert(is_contiguous_container_asan_correct(c
));
93 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
96 assert(c
.size() == 3);
97 assert(is_contiguous_container_asan_correct(c
));
98 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
101 assert(c
.size() == 4);
102 assert(is_contiguous_container_asan_correct(c
));
103 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)
106 assert(c
.size() == 5);
107 assert(is_contiguous_container_asan_correct(c
));
108 for (int j
= 0; static_cast<std::size_t>(j
) < c
.size(); ++j
)