[lld][WebAssembly] Introduce Ctx::arg
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.modifiers / push_back_rvalue.pass.cpp
blob817379b62ae078c1333b2252bba561284bad6967
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 // UNSUPPORTED: c++03
11 // <deque>
13 // void push_back(value_type&& v);
14 // void pop_back();
15 // void pop_front();
17 #include "asan_testing.h"
18 #include <deque>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "MoveOnly.h"
23 #include "min_allocator.h"
26 template <class C>
28 make(int size, int start = 0 )
30 const int b = 4096 / sizeof(int);
31 int init = 0;
32 if (start > 0)
34 init = (start+1) / b + ((start+1) % b != 0);
35 init *= b;
36 --init;
38 C c(init);
39 for (int i = 0; i < init-start; ++i)
40 c.pop_back();
41 for (int i = 0; i < size; ++i)
42 c.push_back(MoveOnly(i));
43 for (int i = 0; i < start; ++i)
44 c.pop_front();
45 return c;
48 template <class C>
49 void test(int size)
51 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
52 const int N = sizeof(rng)/sizeof(rng[0]);
53 for (int j = 0; j < N; ++j)
55 C c = make<C>(size, rng[j]);
56 typename C::const_iterator it = c.begin();
57 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
58 for (int i = 0; i < size; ++i, (void) ++it)
59 assert(*it == MoveOnly(i));
64 int main(int, char**)
67 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
68 const int N = sizeof(rng)/sizeof(rng[0]);
69 for (int j = 0; j < N; ++j)
70 test<std::deque<MoveOnly> >(rng[j]);
73 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
74 const int N = sizeof(rng)/sizeof(rng[0]);
75 for (int j = 0; j < N; ++j)
76 test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
79 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
80 const int N = sizeof(rng)/sizeof(rng[0]);
81 for (int j = 0; j < N; ++j)
82 test<std::deque<MoveOnly, safe_allocator<MoveOnly>> >(rng[j]);
85 return 0;