test-priorityq.c revision 48acc31adebfdd4e4945ee76e1f5259e4b1b6fff
/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "priorityq.h"
#include <stdlib.h>
struct pq_test_item {
struct priorityq_item item;
int num;
};
{
}
void test_priorityq(void)
{
#define PQ_MAX_ITEMS 100
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 */
for (i = 0; input[i] != -1; i++) {
for (j = 0; input[i] != -1; i++, j++) {
if (priorityq_count(pq) != j)
}
for (j = 0; j < N_ELEMENTS(output); j++) {
}
if (priorityq_count(pq) != 0)
}
/* randomized tests, remove elements */
for (i = 0; i < 100; i++) {
for (j = 0; j < PQ_MAX_ITEMS; j++) {
}
for (j = 0; j < PQ_MAX_ITEMS; j++) {
if (rand() % 3 == 0) {
}
}
prev = 0;
while (priorityq_count(pq) > 0) {
}
for (j = 0; j < PQ_MAX_ITEMS; j++) {
}
}
pool_unref(&pool);
}