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 //===----------------------------------------------------------------------===//
11 // template <class... Args> iterator emplace(const_iterator p, Args&&... args);
19 #include "test_macros.h"
20 #include "../../../Emplaceable.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(Emplaceable());
41 for (int i
= 0; i
< start
; ++i
)
50 typedef typename
C::const_iterator CI
;
51 std::size_t c1_osize
= c1
.size();
52 CI i
= c1
.emplace(c1
.begin() + P
, Emplaceable(1, 2.5));
53 assert(i
== c1
.begin() + P
);
54 assert(c1
.size() == c1_osize
+ 1);
55 assert(static_cast<std::size_t>(distance(c1
.begin(), c1
.end())) == c1
.size());
56 assert(*i
== Emplaceable(1, 2.5));
61 testN(int start
, int N
)
63 for (int i
= 0; i
<= 3; ++i
)
67 C c1
= make
<C
>(N
, start
);
71 for (int i
= N
/2-1; i
<= N
/2+1; ++i
)
75 C c1
= make
<C
>(N
, start
);
79 for (int i
= N
- 3; i
<= N
; ++i
)
83 C c1
= make
<C
>(N
, start
);
93 int rng
[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
94 const int N
= sizeof(rng
)/sizeof(rng
[0]);
95 for (int i
= 0; i
< N
; ++i
)
96 for (int j
= 0; j
< N
; ++j
)
97 testN
<std::deque
<Emplaceable
> >(rng
[i
], rng
[j
]);
100 int rng
[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
101 const int N
= sizeof(rng
)/sizeof(rng
[0]);
102 for (int i
= 0; i
< N
; ++i
)
103 for (int j
= 0; j
< N
; ++j
)
104 testN
<std::deque
<Emplaceable
, min_allocator
<Emplaceable
>> >(rng
[i
], rng
[j
]);