| 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 | // <deque> |
| 12 | |
| 13 | // iterator insert(const_iterator p, initializer_list<value_type> il); |
| 14 | |
| 15 | #include "asan_testing.h" |
| 16 | #include <deque> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | #include "min_allocator.h" |
| 21 | |
| 22 | int main(int, char**) { |
| 23 | { |
| 24 | std::deque<int> d(10, 1); |
| 25 | std::deque<int>::iterator i = d.insert(p: d.cbegin() + 2, l: {3, 4, 5, 6}); |
| 26 | assert(d.size() == 14); |
| 27 | assert(i == d.begin() + 2); |
| 28 | assert(d[0] == 1); |
| 29 | assert(d[1] == 1); |
| 30 | assert(d[2] == 3); |
| 31 | assert(d[3] == 4); |
| 32 | assert(d[4] == 5); |
| 33 | assert(d[5] == 6); |
| 34 | assert(d[6] == 1); |
| 35 | assert(d[7] == 1); |
| 36 | assert(d[8] == 1); |
| 37 | assert(d[9] == 1); |
| 38 | assert(d[10] == 1); |
| 39 | assert(d[11] == 1); |
| 40 | assert(d[12] == 1); |
| 41 | assert(d[13] == 1); |
| 42 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d)); |
| 43 | } |
| 44 | { |
| 45 | std::deque<int, min_allocator<int>> d(10, 1); |
| 46 | std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); |
| 47 | assert(d.size() == 14); |
| 48 | assert(i == d.begin() + 2); |
| 49 | assert(d[0] == 1); |
| 50 | assert(d[1] == 1); |
| 51 | assert(d[2] == 3); |
| 52 | assert(d[3] == 4); |
| 53 | assert(d[4] == 5); |
| 54 | assert(d[5] == 6); |
| 55 | assert(d[6] == 1); |
| 56 | assert(d[7] == 1); |
| 57 | assert(d[8] == 1); |
| 58 | assert(d[9] == 1); |
| 59 | assert(d[10] == 1); |
| 60 | assert(d[11] == 1); |
| 61 | assert(d[12] == 1); |
| 62 | assert(d[13] == 1); |
| 63 | LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d)); |
| 64 | } |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |