/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "stats-dist.h"
#include "sort.h"
static void
unsigned int input_size)
{
unsigned int i;
i_assert(input_size > 0);
for (i = 0; i < input_size; i++) {
}
/* these aren't always fully accurate: */
/* when we have 20 elements, [19] is the max, not the 95th %ile, so subtract 1 */
}
void test_stats_dist(void)
{
20, 19, 18, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, -1
};
20, 21, 19, 18, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, -1
};
20, 21, 19, 18, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 22, -1
};
};
struct stats_dist *t;
unsigned int i, j;
for (i = 0; i < N_ELEMENTS(test_inputs); i++) {
t = stats_dist_init();
for (j = 0; test_inputs[i][j] >= 0; j++) {
stats_dist_add(t, test_inputs[i][j]);
}
stats_dist_reset(t);
test_assert(stats_dist_get_count(t) == 0);
test_assert(stats_dist_get_max(t) == 0);
stats_dist_deinit(&t);
test_end();
}
test_begin("stats_dists large");
t = stats_dist_init();
for (i = 0; i < 10000; i++)
stats_dist_add(t, i);
test_assert(stats_dist_get_count(t) == i);
test_assert(stats_dist_get_min(t) == 0);
/* just test that these work: */
stats_dist_deinit(&t);
test_end();
}