[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.modifiers / push_back_rvalue.pass.cpp
blob1cb3b35174cec9b85f9c31944cf84696743afc37
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 <deque>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "MoveOnly.h"
22 #include "min_allocator.h"
25 template <class C>
27 make(int size, int start = 0 )
29 const int b = 4096 / sizeof(int);
30 int init = 0;
31 if (start > 0)
33 init = (start+1) / b + ((start+1) % b != 0);
34 init *= b;
35 --init;
37 C c(init);
38 for (int i = 0; i < init-start; ++i)
39 c.pop_back();
40 for (int i = 0; i < size; ++i)
41 c.push_back(MoveOnly(i));
42 for (int i = 0; i < start; ++i)
43 c.pop_front();
44 return c;
47 template <class C>
48 void test(int size)
50 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
51 const int N = sizeof(rng)/sizeof(rng[0]);
52 for (int j = 0; j < N; ++j)
54 C c = make<C>(size, rng[j]);
55 typename C::const_iterator it = c.begin();
56 for (int i = 0; i < size; ++i, ++it)
57 assert(*it == MoveOnly(i));
62 int main(int, char**)
65 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
66 const int N = sizeof(rng)/sizeof(rng[0]);
67 for (int j = 0; j < N; ++j)
68 test<std::deque<MoveOnly> >(rng[j]);
71 int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
72 const int N = sizeof(rng)/sizeof(rng[0]);
73 for (int j = 0; j < N; ++j)
74 test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
77 return 0;