[lld][WebAssembly] Introduce Ctx::arg
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.modifiers / push_back.pass.cpp
blob70aa1baa1efcba949c91ada7725fcd449af801cc
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 //===----------------------------------------------------------------------===//
9 // <deque>
11 // void push_back(const value_type& v);
12 // void pop_back();
13 // void pop_front();
15 #include "asan_testing.h"
16 #include <deque>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
22 template <class C>
24 make(int size, int start = 0 )
26 const int b = 4096 / sizeof(int);
27 int init = 0;
28 if (start > 0)
30 init = (start+1) / b + ((start+1) % b != 0);
31 init *= b;
32 --init;
34 C c(init, 0);
35 for (int i = 0; i < init-start; ++i)
36 c.pop_back();
37 for (int i = 0; i < size; ++i)
38 c.push_back(i);
39 for (int i = 0; i < start; ++i)
40 c.pop_front();
41 return c;
44 template <class C>
45 void test(int size)
47 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
48 const int N = sizeof(rng)/sizeof(rng[0]);
49 for (int j = 0; j < N; ++j)
51 C c = make<C>(size, rng[j]);
52 typename C::const_iterator it = c.begin();
53 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
54 for (int i = 0; i < size; ++i, ++it)
55 assert(*it == i);
59 int main(int, char**)
62 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
63 const int N = sizeof(rng)/sizeof(rng[0]);
64 for (int j = 0; j < N; ++j)
65 test<std::deque<int> >(rng[j]);
67 #if TEST_STD_VER >= 11
69 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
70 const int N = sizeof(rng)/sizeof(rng[0]);
71 for (int j = 0; j < N; ++j)
72 test<std::deque<int, min_allocator<int>> >(rng[j]);
74 #endif
76 return 0;