14 #include <boost/test/unit_test.hpp>
18 template<
unsigned int N,
typename T>
33 template <
typename A,
typename B>
61 for (
const T& v : const_pre_vector) {
70 for (
Size s = 0; s <
ss1.size(); s++) {
183 size_t r = values.size();
190 for (
auto v : values) {
195 for (
auto v : values) {
214 for (
int j = 0; j < 64; j++) {
216 for (
int i = 0; i < 2048; i++) {
217 int r = InsecureRand32();
219 test.
insert(InsecureRand32() % (test.
size() + 1), InsecureRand32());
221 if (test.
size() > 0 && ((r >> 2) % 4) == 1) {
222 test.
erase(InsecureRand32() % test.
size());
224 if (((r >> 4) % 8) == 2) {
225 int new_size = std::max<int>(0, std::min<int>(30, test.
size() + (InsecureRand32() % 5) - 2));
228 if (((r >> 7) % 8) == 3) {
229 test.
insert(InsecureRand32() % (test.
size() + 1), 1 + (InsecureRand32() % 2), InsecureRand32());
231 if (((r >> 10) % 8) == 4) {
232 int del = std::min<int>(test.
size(), 1 + (InsecureRand32() % 2));
233 int beg = InsecureRand32() % (test.
size() + 1 - del);
234 test.
erase(beg, beg + del);
236 if (((r >> 13) % 16) == 5) {
239 if (test.
size() > 0 && ((r >> 17) % 16) == 6) {
242 if (((r >> 21) % 32) == 7) {
244 int num = 1 + (InsecureRand32() % 4);
245 for (
int i = 0; i < num; i++) {
246 values[i] = InsecureRand32();
248 test.
insert_range(InsecureRand32() % (test.
size() + 1), values, values + num);
250 if (((r >> 26) % 32) == 8) {
251 int del = std::min<int>(test.
size(), 1 + (InsecureRand32() % 4));
252 int beg = InsecureRand32() % (test.
size() + 1 - del);
253 test.
erase(beg, beg + del);
255 r = InsecureRand32();
257 test.
reserve(InsecureRand32() % 32);
259 if ((r >> 5) % 64 == 10) {
262 if (test.
size() > 0) {
263 test.
update(InsecureRand32() % test.
size(), InsecureRand32());
265 if (((r >> 11) % 1024) == 11) {
268 if (((r >> 21) % 512) == 12) {
269 test.
assign(InsecureRand32() % 32, InsecureRand32());
271 if (((r >> 15) % 8) == 3) {
274 if (((r >> 15) % 16) == 8) {
277 if (((r >> 15) % 32) == 18) {
280 if (InsecureRandBits(5) == 19) {
281 unsigned int num = 1 + (InsecureRandBits(4));
282 std::vector<int> values(num);
283 for (
auto &v : values) {
284 v = InsecureRand32();
std::string ToString() const
void erase(Size position)
void update(Size pos, const T &value)
void local_check_equal(A a, B b)
void insert(Size position, Size count, const T &value)
prevector< N, T > pretype
void erase(Size first, Size last)
void insert(Size position, const T &value)
std::vector< T > realtype
void assign(Size n, const T &value)
FastRandomContext rand_cache
void insert_range(Size position, I first, I last)
void resize_uninitialized(realtype values)
void push_back(const T &value)
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
void swap(prevector< N, T, Size, Diff > &other)
iterator erase(iterator pos)
void reserve(size_type new_capacity)
void resize_uninitialized(size_type new_size)
void resize(size_type new_size)
iterator insert(iterator pos, const T &value)
void assign(size_type n, const T &val)
void push_back(const T &value)
BOOST_AUTO_TEST_SUITE_END()
#define T(expected, seed, data)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
BOOST_AUTO_TEST_CASE(PrevectorTestInt)