Commit 46f277b9 authored by Damien Lespiau's avatar Damien Lespiau

stats: Exercise the reallocation paths

Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent 66e0bf66
......@@ -204,6 +204,29 @@ static void test_std_deviation(void)
igt_stats_fini(&stats);
}
static void test_reallocation(void)
{
igt_stats_t stats;
unsigned int i;
igt_stats_init_with_size(&stats, 1);
for (i = 0; i < 101; i++) {
igt_stats_push(&stats, i);
/* also triggers ->sorted reallocations */
if (i > 10)
igt_stats_get_median(&stats);
}
igt_assert_eq(stats.n_values, 101);
for (i = 0; i < 101; i++)
igt_assert_eq(stats.values[i], i);
igt_assert_eq_double(igt_stats_get_mean(&stats), 50.0);
igt_assert_eq_double(igt_stats_get_median(&stats), 50.0);
igt_stats_fini(&stats);
}
igt_simple_main
{
test_init_zero();
......@@ -215,4 +238,5 @@ igt_simple_main
test_mean();
test_invalidate_mean();
test_std_deviation();
test_reallocation();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment