/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "priorityq.h"
struct pq_test_item {
int num;
};
{
}
void test_priorityq(void)
{
static const int input[] = {
1, 2, 3, 4, 5, 6, 7, 8, -1,
8, 7, 6, 5, 4, 3, 2, 1, -1,
8, 7, 5, 6, 1, 3, 4, 2, -1,
-1
};
static const int output[] = {
1, 2, 3, 4, 5, 6, 7, 8
};
unsigned int i, j;
int prev;
/* simple tests with popping only */
test_begin("priorityq");
for (i = 0; input[i] != -1; i++) {
for (j = 0; input[i] != -1; i++, j++) {
}
}
for (j = 0; j < N_ELEMENTS(output); j++) {
}
}
test_end();
/* randomized tests, remove elements */
test_begin("priorityq randomized");
for (i = 0; i < 100; i++) {
for (j = 0; j < PQ_MAX_ITEMS; j++) {
}
for (j = 0; j < PQ_MAX_ITEMS; j++) {
if (i_rand_limit(3) == 0) {
}
}
prev = 0;
while (priorityq_count(pq) > 0) {
}
for (j = 0; j < PQ_MAX_ITEMS; j++) {
}
}
test_end();
pool_unref(&pool);
}