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 //===----------------------------------------------------------------------===//
13 // void push_front(value_type&& v);
19 #include "test_macros.h"
21 #include "min_allocator.h"
26 make(int size
, int start
= 0 )
28 const int b
= 4096 / sizeof(int);
32 init
= (start
+1) / b
+ ((start
+1) % b
!= 0);
37 for (int i
= 0; i
< init
-start
; ++i
)
39 for (int i
= 0; i
< size
; ++i
)
40 c
.push_back(MoveOnly(i
));
41 for (int i
= 0; i
< start
; ++i
)
50 typedef typename
C::iterator I
;
51 std::size_t c1_osize
= c1
.size();
52 c1
.push_front(MoveOnly(x
));
53 assert(c1
.size() == c1_osize
+ 1);
54 assert(static_cast<std::size_t>(distance(c1
.begin(), c1
.end())) == c1
.size());
56 assert(*i
== MoveOnly(x
));
58 for (int j
= 0; static_cast<std::size_t>(j
) < c1_osize
; ++j
, ++i
)
59 assert(*i
== MoveOnly(j
));
64 testN(int start
, int N
)
66 C c1
= make
<C
>(N
, start
);
74 int rng
[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
75 const int N
= sizeof(rng
)/sizeof(rng
[0]);
76 for (int i
= 0; i
< N
; ++i
)
77 for (int j
= 0; j
< N
; ++j
)
78 testN
<std::deque
<MoveOnly
> >(rng
[i
], rng
[j
]);
81 int rng
[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
82 const int N
= sizeof(rng
)/sizeof(rng
[0]);
83 for (int i
= 0; i
< N
; ++i
)
84 for (int j
= 0; j
< N
; ++j
)
85 testN
<std::deque
<MoveOnly
, min_allocator
<MoveOnly
>> >(rng
[i
], rng
[j
]);